Skip to content

Commit

Permalink
Some miscellaneous openssl/x509.h documentation fixes
Browse files Browse the repository at this point in the history
Bug: 426
Change-Id: Ie1ba74a940db1525926da1856bb98d350d977674
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65149
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
  • Loading branch information
davidben authored and Boringssl LUCI CQ committed Jan 10, 2024
1 parent 04b2d61 commit 2a88b4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
12 changes: 6 additions & 6 deletions crypto/x509/x_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,17 @@ int X509_NAME_set(X509_NAME **xn, X509_NAME *name) {

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

int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,
size_t *pderlen) {
int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **out_der,
size_t *out_der_len) {
// Make sure encoding is valid
if (i2d_X509_NAME(nm, NULL) <= 0) {
return 0;
}
if (pder != NULL) {
*pder = (unsigned char *)nm->bytes->data;
if (out_der != NULL) {
*out_der = (unsigned char *)nm->bytes->data;
}
if (pderlen != NULL) {
*pderlen = nm->bytes->length;
if (out_der_len != NULL) {
*out_der_len = nm->bytes->length;
}
return 1;
}
28 changes: 17 additions & 11 deletions include/openssl/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ OPENSSL_EXPORT uint32_t X509_get_extension_flags(X509 *x509);
//
// TODO(crbug.com/boringssl/381): Decoding an |X509| object will not check for
// invalid extensions. To detect the error case, call
// |X509_get_extensions_flags| and check the |EXFLAG_INVALID| bit.
// |X509_get_extension_flags| and check the |EXFLAG_INVALID| bit.
OPENSSL_EXPORT long X509_get_pathlen(X509 *x509);

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

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

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

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

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

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

Expand Down Expand Up @@ -3835,7 +3840,7 @@ OPENSSL_EXPORT STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st,
X509_NAME *nm);

// X509_STORE_set_flags enables all values in |flags| in |store|'s verification
// flags.
// flags. |flags| should be a combination of |X509_V_FLAG_*| constants.
//
// WARNING: These flags will be combined with default flags when copied to an
// |X509_STORE_CTX|. This means it is impossible to unset those defaults from
Expand Down Expand Up @@ -3989,7 +3994,8 @@ OPENSSL_EXPORT int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx,
int trust);

// X509_STORE_CTX_set_flags enables all values in |flags| in |ctx|'s
// verification flags.
// verification flags. |flags| should be a combination of |X509_V_FLAG_*|
// constants.
OPENSSL_EXPORT void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx,
unsigned long flags);

Expand Down

0 comments on commit 2a88b4b

Please sign in to comment.