@ -475,16 +475,34 @@ extern "C" {
// it is safe to call mutating functions is a little tricky due to various
// internal caches.
// X509_get_version returns the numerical value of |x509|'s version. That is,
// it returns zero for X.509v1, one for X.509v2, and two for X.509v3. 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.
// 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_get_version returns the numerical value of |x509|'s version. Callers may
// compare the result to the |X509V*_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.
//
// If unsure, use |X509V3_VERSION|.
OPENSSL_EXPORT int X509_set_version ( X509 * x509 , long version ) ;
// X509_get0_serialNumber returns |x509|'s serial number.
OPENSSL_EXPORT const ASN1_INTEGER * X509_get0_serialNumber ( const X509 * x509 ) ;
// X509_set_serialNumber sets |x509|'s serial number to |serial|. It returns one
// on success and zero on error.
OPENSSL_EXPORT int X509_set_serialNumber ( X509 * x509 ,
const ASN1_INTEGER * serial ) ;
// X509_get0_notBefore returns |x509|'s notBefore time.
OPENSSL_EXPORT const ASN1_TIME * X509_get0_notBefore ( const X509 * x509 ) ;
@ -550,9 +568,9 @@ OPENSSL_EXPORT X509_CINF *X509_get_cert_info(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. That is,
// it returns zero for a v1 request. If |req| is invalid, it may return another
// value, or -1 on overflow.
// 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.
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
@ -565,9 +583,9 @@ 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))
// X509_REQ_get_version returns the numerical value of |crl|'s version. That is,
// it returns zero for a v1 CRL and one for a v2 CRL. If |crl| is invalid, it
// may return another value, or -1 on overflow.
// 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.
OPENSSL_EXPORT long X509_CRL_get_version ( const X509_CRL * crl ) ;
// X509_CRL_get0_lastUpdate returns |crl|'s lastUpdate time.
@ -1071,8 +1089,6 @@ OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
ASN1_BIT_STRING * signature , void * asn ,
EVP_MD_CTX * ctx ) ;
OPENSSL_EXPORT int X509_set_version ( X509 * x , long version ) ;
OPENSSL_EXPORT int X509_set_serialNumber ( X509 * x , ASN1_INTEGER * serial ) ;
OPENSSL_EXPORT ASN1_INTEGER * X509_get_serialNumber ( X509 * x ) ;
OPENSSL_EXPORT int X509_set_issuer_name ( X509 * x , X509_NAME * name ) ;
OPENSSL_EXPORT X509_NAME * X509_get_issuer_name ( const X509 * a ) ;
@ -1085,7 +1101,11 @@ OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_get0_extensions(
const X509 * x ) ;
OPENSSL_EXPORT const X509_ALGOR * X509_get0_tbs_sigalg ( const X509 * x ) ;
OPENSSL_EXPORT int X509_REQ_set_version ( X509_REQ * x , long version ) ;
// X509_REQ_set_version sets |req|'s version to |version|, which should be
// |X509V1_VERSION|. It returns one on success and zero on error.
//
// Note no versions other than |X509V1_VERSION| are defined for CSRs.
OPENSSL_EXPORT int X509_REQ_set_version ( X509_REQ * req , long version ) ;
OPENSSL_EXPORT int X509_REQ_set_subject_name ( X509_REQ * req , X509_NAME * name ) ;
OPENSSL_EXPORT void X509_REQ_get0_signature ( const X509_REQ * req ,
const ASN1_BIT_STRING * * psig ,
@ -1123,7 +1143,13 @@ OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
const unsigned char * bytes ,
int len ) ;
OPENSSL_EXPORT int X509_CRL_set_version ( X509_CRL * x , long version ) ;
// 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
// error.
//
// If unsure, use |X509V2_VERSION|. Note |X509V3_VERSION| is not defined for
// CRLs.
OPENSSL_EXPORT int X509_CRL_set_version ( X509_CRL * crl , long version ) ;
OPENSSL_EXPORT int X509_CRL_set_issuer_name ( X509_CRL * x , X509_NAME * name ) ;
OPENSSL_EXPORT int X509_CRL_sort ( X509_CRL * crl ) ;
OPENSSL_EXPORT int X509_CRL_up_ref ( X509_CRL * crl ) ;