Skip to content

Commit 6597674

Browse files
davidbendkostic
authored and
dkostic
committed
Some miscellaneous openssl/x509.h documentation fixes
Bug: 426 Change-Id: Ie1ba74a940db1525926da1856bb98d350d977674 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65149 Reviewed-by: Bob Beck <[email protected]> Commit-Queue: David Benjamin <[email protected]> (cherry picked from commit 2a88b4b65da2794378044be9d125ce987ffd39f3)
1 parent 0b66a45 commit 6597674

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

crypto/x509/x_name.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,17 @@ int X509_NAME_set(X509_NAME **xn, X509_NAME *name) {
513513

514514
int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne) { return ne->set; }
515515

516-
int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,
517-
size_t *pderlen) {
516+
int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **out_der,
517+
size_t *out_der_len) {
518518
// Make sure encoding is valid
519519
if (i2d_X509_NAME(nm, NULL) <= 0) {
520520
return 0;
521521
}
522-
if (pder != NULL) {
523-
*pder = (unsigned char *)nm->bytes->data;
522+
if (out_der != NULL) {
523+
*out_der = (unsigned char *)nm->bytes->data;
524524
}
525-
if (pderlen != NULL) {
526-
*pderlen = nm->bytes->length;
525+
if (out_der_len != NULL) {
526+
*out_der_len = nm->bytes->length;
527527
}
528528
return 1;
529529
}

include/openssl/x509.h

+14-9
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ OPENSSL_EXPORT uint32_t X509_get_extension_flags(X509 *x509);
277277
//
278278
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
279279
// invalid extensions. To detect the error case, call
280-
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
280+
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
281281
OPENSSL_EXPORT long X509_get_pathlen(X509 *x509);
282282

283283
// X509v3_KU_* are key usage bits returned from |X509_get_key_usage|.
@@ -336,7 +336,7 @@ OPENSSL_EXPORT uint32_t X509_get_extended_key_usage(X509 *x509);
336336
//
337337
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
338338
// invalid extensions. To detect the error case, call
339-
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
339+
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
340340
OPENSSL_EXPORT const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x509);
341341

342342
// X509_get0_authority_key_id returns keyIdentifier of |x509|'s authority key
@@ -347,7 +347,7 @@ OPENSSL_EXPORT const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x509);
347347
//
348348
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
349349
// invalid extensions. To detect the error case, call
350-
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
350+
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
351351
OPENSSL_EXPORT const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x509);
352352

353353
DEFINE_STACK_OF(GENERAL_NAME)
@@ -361,7 +361,7 @@ typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
361361
//
362362
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
363363
// invalid extensions. To detect the error case, call
364-
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
364+
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
365365
OPENSSL_EXPORT const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x509);
366366

367367
// X509_get0_authority_serial returns the authorityCertSerialNumber of |x509|'s
@@ -372,7 +372,7 @@ OPENSSL_EXPORT const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x509);
372372
//
373373
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
374374
// invalid extensions. To detect the error case, call
375-
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
375+
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
376376
OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_authority_serial(X509 *x509);
377377

378378
// X509_get0_extensions returns |x509|'s extension list, or NULL if |x509| omits
@@ -1427,12 +1427,17 @@ OPENSSL_EXPORT X509_NAME *X509_NAME_dup(X509_NAME *name);
14271427
// Although even the library itself passes this to a sorting function.
14281428
OPENSSL_EXPORT int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
14291429

1430-
// X509_NAME_get0_der sets |*out_der| and |*out_der_len|
1430+
// X509_NAME_get0_der marshals |name| as a DER-encoded X.509 Name (RFC 5280). On
1431+
// success, it returns one and sets |*out_der| and |*out_der_len| to a buffer
1432+
// containing the result. Otherwise, it returns zero. |*out_der| is owned by
1433+
// |name| and must not be freed by the caller. It is invalidated after |name| is
1434+
// mutated or freed.
14311435
//
14321436
// Avoid this function and prefer |i2d_X509_NAME|. It is one of the reasons
1433-
// these functions are not consistently thread-safe or const-correct. Depending
1434-
// on the resolution of https://crbug.com/boringssl/407, this function may be
1435-
// removed or cause poor performance.
1437+
// |X509_NAME| functions, including this one, are not consistently thread-safe
1438+
// or const-correct. Depending on the resolution of
1439+
// https://crbug.com/boringssl/407, this function may be removed or cause poor
1440+
// performance.
14361441
OPENSSL_EXPORT int X509_NAME_get0_der(X509_NAME *name, const uint8_t **out_der,
14371442
size_t *out_der_len);
14381443

0 commit comments

Comments
 (0)