@ -453,24 +453,23 @@ extern "C" {
// it is safe to call mutating functions is a little tricky due to various
// internal caches.
// The following constants are version numbers of X.509-related structures. Note
// APIs typically return the numerical value of X.509 versions, which are one
// less than the named version.
# define X509V1_VERSION 0
# define X509V2_VERSION 1
# define X509V3_VERSION 2
// X509_VERSION_* are X.509 version numbers. Note the numerical values of all
// defined X.509 versions are one less than the named version.
# define X509_VERSION_1 0
# define X509_VERSION_2 1
# define X509_VERSION_3 2
// X509_get_version returns the numerical value of |x509|'s version. Callers may
// compare the result to the |X509V* _VERSION| constants. Unknown versions are
// compare the result to the |X509_VERSION_* | constants. Unknown versions are
// rejected by the parser, but a manually-created |X509| object may encode
// invalid versions. In that case, the function will return the invalid version,
// or -1 on overflow.
OPENSSL_EXPORT long X509_get_version ( const X509 * x509 ) ;
// X509_set_version sets |x509|'s version to |version|, which should be one of
// the |X509V* _VERSION| constants. It returns one on success and zero on error.
// the |X509V_VERSION_* | constants. It returns one on success and zero on error.
//
// If unsure, use |X509V3 _VERSION|.
// If unsure, use |X509_VERSION_3 |.
OPENSSL_EXPORT int X509_set_version ( X509 * x509 , long version ) ;
// X509_get0_serialNumber returns |x509|'s serial number.
@ -542,9 +541,15 @@ OPENSSL_EXPORT void X509_get0_uids(const X509 *x509,
// |EXFLAG_INVALID| bit.
OPENSSL_EXPORT long X509_get_pathlen ( X509 * x509 ) ;
// X509_REQ_get_version returns the numerical value of |req|'s version. Callers
// may compare the result to |X509V*_VERSION| constants. If |req| is invalid, it
// may return another value, or -1 on overflow.
// X509_REQ_VERSION_1 is the version constant for |X509_REQ| objects. Note no
// other versions are defined.
# define X509_REQ_VERSION_1 0
// X509_REQ_get_version returns the numerical value of |req|'s version. This
// will be |X509_REQ_VERSION_1| for valid certificate requests. If |req| is
// invalid, it may return another value, or -1 on overflow.
//
// TODO(davidben): Enforce the version number in the parser.
OPENSSL_EXPORT long X509_REQ_get_version ( const X509_REQ * req ) ;
// X509_REQ_get_subject_name returns |req|'s subject name. Note this function is
@ -557,9 +562,14 @@ OPENSSL_EXPORT X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
// X509_name_cmp is a legacy alias for |X509_NAME_cmp|.
# define X509_name_cmp(a, b) X509_NAME_cmp((a), (b))
# define X509_CRL_VERSION_1 0
# define X509_CRL_VERSION_2 1
// X509_CRL_get_version returns the numerical value of |crl|'s version. Callers
// may compare the result to |X509V*_VERSION| constants. If |crl| is invalid,
// it may return another value, or -1 on overflow.
// may compare the result to |X509_CRL_VERSION_*| constants. If |crl| is
// invalid, it may return another value, or -1 on overflow.
//
// TODO(davidben): Enforce the version number in the parser.
OPENSSL_EXPORT long X509_CRL_get_version ( const X509_CRL * crl ) ;
// X509_CRL_get0_lastUpdate returns |crl|'s lastUpdate time.
@ -1158,9 +1168,9 @@ OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_get0_extensions(
OPENSSL_EXPORT const X509_ALGOR * X509_get0_tbs_sigalg ( const X509 * x509 ) ;
// X509_REQ_set_version sets |req|'s version to |version|, which should be
// |X509V1_VERSION |. It returns one on success and zero on error.
// |X509_REQ_VERSION_1 |. It returns one on success and zero on error.
//
// Note no versions other than |X509V1_VERSION | are defined for CSRs.
// Note no versions other than |X509_REQ_VERSION_1 | are defined for CSRs.
OPENSSL_EXPORT int X509_REQ_set_version ( X509_REQ * req , long version ) ;
// X509_REQ_set_subject_name sets |req|'s subject to a copy of |name|. It
@ -1292,11 +1302,11 @@ OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
int len ) ;
// X509_CRL_set_version sets |crl|'s version to |version|, which should be one
// of the |X509V*_VERSION | constants. It returns one on success and zero on
// of the |X509_CRL_VERSION_* | constants. It returns one on success and zero on
// error.
//
// If unsure, use |X509V2_VERSION|. Note |X509V3_VERSION| is not defined for
// CRLs .
// If unsure, use |X509_CRL_VERSION_2|. Note that, unlike certificates, CRL
// versions are only defined up to v2. Callers should not use |X509_VERSION_3| .
OPENSSL_EXPORT int X509_CRL_set_version ( X509_CRL * crl , long version ) ;
// X509_CRL_set_issuer_name sets |crl|'s issuer to a copy of |name|. It returns