提交 5cf6abd8 编写于 作者: D Dr. Stephen Henson

Embed X509_CINF

Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 7aef39a7
...@@ -122,7 +122,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, ...@@ -122,7 +122,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
if (nmflags == X509_FLAG_COMPAT) if (nmflags == X509_FLAG_COMPAT)
nmindent = 16; nmindent = 16;
ci = x->cert_info; ci = &x->cert_info;
if (!(cflag & X509_FLAG_NO_HEADER)) { if (!(cflag & X509_FLAG_NO_HEADER)) {
if (BIO_write(bp, "Certificate:\n", 13) <= 0) if (BIO_write(bp, "Certificate:\n", 13) <= 0)
goto err; goto err;
...@@ -272,10 +272,10 @@ int X509_ocspid_print(BIO *bp, X509 *x) ...@@ -272,10 +272,10 @@ int X509_ocspid_print(BIO *bp, X509 *x)
*/ */
if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) if (BIO_printf(bp, " Subject OCSP hash: ") <= 0)
goto err; goto err;
derlen = i2d_X509_NAME(x->cert_info->subject, NULL); derlen = i2d_X509_NAME(x->cert_info.subject, NULL);
if ((der = dertmp = OPENSSL_malloc(derlen)) == NULL) if ((der = dertmp = OPENSSL_malloc(derlen)) == NULL)
goto err; goto err;
i2d_X509_NAME(x->cert_info->subject, &dertmp); i2d_X509_NAME(x->cert_info.subject, &dertmp);
if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL))
goto err; goto err;
...@@ -292,8 +292,8 @@ int X509_ocspid_print(BIO *bp, X509 *x) ...@@ -292,8 +292,8 @@ int X509_ocspid_print(BIO *bp, X509 *x)
if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0) if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0)
goto err; goto err;
if (!EVP_Digest(x->cert_info->key->public_key->data, if (!EVP_Digest(x->cert_info.key->public_key->data,
x->cert_info->key->public_key->length, x->cert_info.key->public_key->length,
SHA1md, NULL, EVP_sha1(), NULL)) SHA1md, NULL, EVP_sha1(), NULL))
goto err; goto err;
for (i = 0; i < SHA_DIGEST_LENGTH; i++) { for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
......
...@@ -106,7 +106,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, ...@@ -106,7 +106,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
case ASN1_OP_D2I_POST: case ASN1_OP_D2I_POST:
OPENSSL_free(ret->name); OPENSSL_free(ret->name);
ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); ret->name = X509_NAME_oneline(ret->cert_info.subject, NULL, 0);
break; break;
case ASN1_OP_FREE_POST: case ASN1_OP_FREE_POST:
...@@ -132,7 +132,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, ...@@ -132,7 +132,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
} }
ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = { ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = {
ASN1_SIMPLE(X509, cert_info, X509_CINF), ASN1_EMBED(X509, cert_info, X509_CINF),
ASN1_SIMPLE(X509, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509, sig_alg, X509_ALGOR),
ASN1_SIMPLE(X509, signature, ASN1_BIT_STRING) ASN1_SIMPLE(X509, signature, ASN1_BIT_STRING)
} ASN1_SEQUENCE_END_ref(X509, X509) } ASN1_SEQUENCE_END_ref(X509, X509)
...@@ -209,8 +209,8 @@ int i2d_X509_AUX(X509 *a, unsigned char **pp) ...@@ -209,8 +209,8 @@ int i2d_X509_AUX(X509 *a, unsigned char **pp)
int i2d_re_X509_tbs(X509 *x, unsigned char **pp) int i2d_re_X509_tbs(X509 *x, unsigned char **pp)
{ {
x->cert_info->enc.modified = 1; x->cert_info.enc.modified = 1;
return i2d_X509_CINF(x->cert_info, pp); return i2d_X509_CINF(&x->cert_info, pp);
} }
void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
......
...@@ -253,10 +253,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, ...@@ -253,10 +253,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
{ {
BY_DIR *ctx; BY_DIR *ctx;
union { union {
struct { X509 st_x509;
X509 st_x509;
X509_CINF st_x509_cinf;
} x509;
X509_CRL crl; X509_CRL crl;
} data; } data;
int ok = 0; int ok = 0;
...@@ -271,9 +268,8 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, ...@@ -271,9 +268,8 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
stmp.type = type; stmp.type = type;
if (type == X509_LU_X509) { if (type == X509_LU_X509) {
data.x509.st_x509.cert_info = &data.x509.st_x509_cinf; data.st_x509.cert_info.subject = name;
data.x509.st_x509_cinf.subject = name; stmp.data.x509 = &data.st_x509;
stmp.data.x509 = &data.x509.st_x509;
postfix = ""; postfix = "";
} else if (type == X509_LU_CRL) { } else if (type == X509_LU_CRL) {
data.crl.crl.issuer = name; data.crl.crl.issuer = name;
......
...@@ -68,10 +68,10 @@ ...@@ -68,10 +68,10 @@
int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b)
{ {
int i; int i;
X509_CINF *ai, *bi; const X509_CINF *ai, *bi;
ai = a->cert_info; ai = &a->cert_info;
bi = b->cert_info; bi = &b->cert_info;
i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber); i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber);
if (i) if (i)
return (i); return (i);
...@@ -87,15 +87,15 @@ unsigned long X509_issuer_and_serial_hash(X509 *a) ...@@ -87,15 +87,15 @@ unsigned long X509_issuer_and_serial_hash(X509 *a)
char *f; char *f;
EVP_MD_CTX_init(&ctx); EVP_MD_CTX_init(&ctx);
f = X509_NAME_oneline(a->cert_info->issuer, NULL, 0); f = X509_NAME_oneline(a->cert_info.issuer, NULL, 0);
if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL))
goto err; goto err;
if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f))) if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))
goto err; goto err;
OPENSSL_free(f); OPENSSL_free(f);
if (!EVP_DigestUpdate if (!EVP_DigestUpdate
(&ctx, (unsigned char *)a->cert_info->serialNumber->data, (&ctx, (unsigned char *)a->cert_info.serialNumber->data,
(unsigned long)a->cert_info->serialNumber->length)) (unsigned long)a->cert_info.serialNumber->length))
goto err; goto err;
if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL)) if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL))
goto err; goto err;
...@@ -110,12 +110,12 @@ unsigned long X509_issuer_and_serial_hash(X509 *a) ...@@ -110,12 +110,12 @@ unsigned long X509_issuer_and_serial_hash(X509 *a)
int X509_issuer_name_cmp(const X509 *a, const X509 *b) int X509_issuer_name_cmp(const X509 *a, const X509 *b)
{ {
return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer)); return (X509_NAME_cmp(a->cert_info.issuer, b->cert_info.issuer));
} }
int X509_subject_name_cmp(const X509 *a, const X509 *b) int X509_subject_name_cmp(const X509 *a, const X509 *b)
{ {
return (X509_NAME_cmp(a->cert_info->subject, b->cert_info->subject)); return (X509_NAME_cmp(a->cert_info.subject, b->cert_info.subject));
} }
int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b) int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b)
...@@ -130,40 +130,40 @@ int X509_CRL_match(const X509_CRL *a, const X509_CRL *b) ...@@ -130,40 +130,40 @@ int X509_CRL_match(const X509_CRL *a, const X509_CRL *b)
X509_NAME *X509_get_issuer_name(X509 *a) X509_NAME *X509_get_issuer_name(X509 *a)
{ {
return (a->cert_info->issuer); return (a->cert_info.issuer);
} }
unsigned long X509_issuer_name_hash(X509 *x) unsigned long X509_issuer_name_hash(X509 *x)
{ {
return (X509_NAME_hash(x->cert_info->issuer)); return (X509_NAME_hash(x->cert_info.issuer));
} }
#ifndef OPENSSL_NO_MD5 #ifndef OPENSSL_NO_MD5
unsigned long X509_issuer_name_hash_old(X509 *x) unsigned long X509_issuer_name_hash_old(X509 *x)
{ {
return (X509_NAME_hash_old(x->cert_info->issuer)); return (X509_NAME_hash_old(x->cert_info.issuer));
} }
#endif #endif
X509_NAME *X509_get_subject_name(X509 *a) X509_NAME *X509_get_subject_name(X509 *a)
{ {
return (a->cert_info->subject); return (a->cert_info.subject);
} }
ASN1_INTEGER *X509_get_serialNumber(X509 *a) ASN1_INTEGER *X509_get_serialNumber(X509 *a)
{ {
return (a->cert_info->serialNumber); return (a->cert_info.serialNumber);
} }
unsigned long X509_subject_name_hash(X509 *x) unsigned long X509_subject_name_hash(X509 *x)
{ {
return (X509_NAME_hash(x->cert_info->subject)); return (X509_NAME_hash(x->cert_info.subject));
} }
#ifndef OPENSSL_NO_MD5 #ifndef OPENSSL_NO_MD5
unsigned long X509_subject_name_hash_old(X509 *x) unsigned long X509_subject_name_hash_old(X509 *x)
{ {
return (X509_NAME_hash_old(x->cert_info->subject)); return (X509_NAME_hash_old(x->cert_info.subject));
} }
#endif #endif
...@@ -186,12 +186,12 @@ int X509_cmp(const X509 *a, const X509 *b) ...@@ -186,12 +186,12 @@ int X509_cmp(const X509 *a, const X509 *b)
if (rv) if (rv)
return rv; return rv;
/* Check for match against stored encoding too */ /* Check for match against stored encoding too */
if (!a->cert_info->enc.modified && !b->cert_info->enc.modified) { if (!a->cert_info.enc.modified && !b->cert_info.enc.modified) {
rv = (int)(a->cert_info->enc.len - b->cert_info->enc.len); rv = (int)(a->cert_info.enc.len - b->cert_info.enc.len);
if (rv) if (rv)
return rv; return rv;
return memcmp(a->cert_info->enc.enc, b->cert_info->enc.enc, return memcmp(a->cert_info.enc.enc, b->cert_info.enc.enc,
a->cert_info->enc.len); a->cert_info.enc.len);
} }
return rv; return rv;
} }
...@@ -273,15 +273,13 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, ...@@ -273,15 +273,13 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
ASN1_INTEGER *serial) ASN1_INTEGER *serial)
{ {
int i; int i;
X509_CINF cinf;
X509 x, *x509 = NULL; X509 x, *x509 = NULL;
if (!sk) if (!sk)
return NULL; return NULL;
x.cert_info = &cinf; x.cert_info.serialNumber = serial;
cinf.serialNumber = serial; x.cert_info.issuer = name;
cinf.issuer = name;
for (i = 0; i < sk_X509_num(sk); i++) { for (i = 0; i < sk_X509_num(sk); i++) {
x509 = sk_X509_value(sk, i); x509 = sk_X509_value(sk, i);
...@@ -306,16 +304,16 @@ X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) ...@@ -306,16 +304,16 @@ X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name)
EVP_PKEY *X509_get_pubkey(X509 *x) EVP_PKEY *X509_get_pubkey(X509 *x)
{ {
if ((x == NULL) || (x->cert_info == NULL)) if (x == NULL)
return (NULL); return (NULL);
return (X509_PUBKEY_get(x->cert_info->key)); return (X509_PUBKEY_get(x->cert_info.key));
} }
ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x) ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)
{ {
if (!x) if (!x)
return NULL; return NULL;
return x->cert_info->key->public_key; return x->cert_info.key->public_key;
} }
int X509_check_private_key(X509 *x, EVP_PKEY *k) int X509_check_private_key(X509 *x, EVP_PKEY *k)
......
...@@ -114,49 +114,49 @@ int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) ...@@ -114,49 +114,49 @@ int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc)
int X509_get_ext_count(X509 *x) int X509_get_ext_count(X509 *x)
{ {
return (X509v3_get_ext_count(x->cert_info->extensions)); return (X509v3_get_ext_count(x->cert_info.extensions));
} }
int X509_get_ext_by_NID(X509 *x, int nid, int lastpos) int X509_get_ext_by_NID(X509 *x, int nid, int lastpos)
{ {
return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos)); return (X509v3_get_ext_by_NID(x->cert_info.extensions, nid, lastpos));
} }
int X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos) int X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos)
{ {
return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos)); return (X509v3_get_ext_by_OBJ(x->cert_info.extensions, obj, lastpos));
} }
int X509_get_ext_by_critical(X509 *x, int crit, int lastpos) int X509_get_ext_by_critical(X509 *x, int crit, int lastpos)
{ {
return (X509v3_get_ext_by_critical return (X509v3_get_ext_by_critical
(x->cert_info->extensions, crit, lastpos)); (x->cert_info.extensions, crit, lastpos));
} }
X509_EXTENSION *X509_get_ext(X509 *x, int loc) X509_EXTENSION *X509_get_ext(X509 *x, int loc)
{ {
return (X509v3_get_ext(x->cert_info->extensions, loc)); return (X509v3_get_ext(x->cert_info.extensions, loc));
} }
X509_EXTENSION *X509_delete_ext(X509 *x, int loc) X509_EXTENSION *X509_delete_ext(X509 *x, int loc)
{ {
return (X509v3_delete_ext(x->cert_info->extensions, loc)); return (X509v3_delete_ext(x->cert_info.extensions, loc));
} }
int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc)
{ {
return (X509v3_add_ext(&(x->cert_info->extensions), ex, loc) != NULL); return (X509v3_add_ext(&(x->cert_info.extensions), ex, loc) != NULL);
} }
void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx) void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
{ {
return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx); return X509V3_get_d2i(x->cert_info.extensions, nid, crit, idx);
} }
int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
unsigned long flags) unsigned long flags)
{ {
return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit, return X509V3_add1_i2d(&x->cert_info.extensions, nid, value, crit,
flags); flags);
} }
......
...@@ -420,7 +420,6 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, ...@@ -420,7 +420,6 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
{ {
X509_OBJECT stmp; X509_OBJECT stmp;
X509 x509_s; X509 x509_s;
X509_CINF cinf_s;
X509_CRL crl_s; X509_CRL crl_s;
int idx; int idx;
...@@ -428,8 +427,7 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, ...@@ -428,8 +427,7 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
switch (type) { switch (type) {
case X509_LU_X509: case X509_LU_X509:
stmp.data.x509 = &x509_s; stmp.data.x509 = &x509_s;
x509_s.cert_info = &cinf_s; x509_s.cert_info.subject = name;
cinf_s.subject = name;
break; break;
case X509_LU_CRL: case X509_LU_CRL:
stmp.data.crl = &crl_s; stmp.data.crl = &crl_s;
......
...@@ -78,7 +78,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey) ...@@ -78,7 +78,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
} }
/* duplicate the request */ /* duplicate the request */
xi = ret->cert_info; xi = &ret->cert_info;
if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) { if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) {
if ((xi->version = ASN1_INTEGER_new()) == NULL) if ((xi->version = ASN1_INTEGER_new()) == NULL)
......
...@@ -68,15 +68,15 @@ int X509_set_version(X509 *x, long version) ...@@ -68,15 +68,15 @@ int X509_set_version(X509 *x, long version)
if (x == NULL) if (x == NULL)
return (0); return (0);
if (version == 0) { if (version == 0) {
ASN1_INTEGER_free(x->cert_info->version); ASN1_INTEGER_free(x->cert_info.version);
x->cert_info->version = NULL; x->cert_info.version = NULL;
return (1); return (1);
} }
if (x->cert_info->version == NULL) { if (x->cert_info.version == NULL) {
if ((x->cert_info->version = ASN1_INTEGER_new()) == NULL) if ((x->cert_info.version = ASN1_INTEGER_new()) == NULL)
return (0); return (0);
} }
return (ASN1_INTEGER_set(x->cert_info->version, version)); return (ASN1_INTEGER_set(x->cert_info.version, version));
} }
int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
...@@ -85,12 +85,12 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) ...@@ -85,12 +85,12 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
if (x == NULL) if (x == NULL)
return (0); return (0);
in = x->cert_info->serialNumber; in = x->cert_info.serialNumber;
if (in != serial) { if (in != serial) {
in = ASN1_INTEGER_dup(serial); in = ASN1_INTEGER_dup(serial);
if (in != NULL) { if (in != NULL) {
ASN1_INTEGER_free(x->cert_info->serialNumber); ASN1_INTEGER_free(x->cert_info.serialNumber);
x->cert_info->serialNumber = in; x->cert_info.serialNumber = in;
} }
} }
return (in != NULL); return (in != NULL);
...@@ -98,16 +98,16 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) ...@@ -98,16 +98,16 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
int X509_set_issuer_name(X509 *x, X509_NAME *name) int X509_set_issuer_name(X509 *x, X509_NAME *name)
{ {
if ((x == NULL) || (x->cert_info == NULL)) if (x == NULL)
return (0); return (0);
return (X509_NAME_set(&x->cert_info->issuer, name)); return (X509_NAME_set(&x->cert_info.issuer, name));
} }
int X509_set_subject_name(X509 *x, X509_NAME *name) int X509_set_subject_name(X509 *x, X509_NAME *name)
{ {
if ((x == NULL) || (x->cert_info == NULL)) if (x == NULL)
return (0); return (0);
return (X509_NAME_set(&x->cert_info->subject, name)); return (X509_NAME_set(&x->cert_info.subject, name));
} }
int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) int X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
...@@ -116,12 +116,12 @@ int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) ...@@ -116,12 +116,12 @@ int X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
if (x == NULL) if (x == NULL)
return (0); return (0);
in = x->cert_info->validity.notBefore; in = x->cert_info.validity.notBefore;
if (in != tm) { if (in != tm) {
in = ASN1_STRING_dup(tm); in = ASN1_STRING_dup(tm);
if (in != NULL) { if (in != NULL) {
ASN1_TIME_free(x->cert_info->validity.notBefore); ASN1_TIME_free(x->cert_info.validity.notBefore);
x->cert_info->validity.notBefore = in; x->cert_info.validity.notBefore = in;
} }
} }
return (in != NULL); return (in != NULL);
...@@ -133,12 +133,12 @@ int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) ...@@ -133,12 +133,12 @@ int X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
if (x == NULL) if (x == NULL)
return (0); return (0);
in = x->cert_info->validity.notAfter; in = x->cert_info.validity.notAfter;
if (in != tm) { if (in != tm) {
in = ASN1_STRING_dup(tm); in = ASN1_STRING_dup(tm);
if (in != NULL) { if (in != NULL) {
ASN1_TIME_free(x->cert_info->validity.notAfter); ASN1_TIME_free(x->cert_info.validity.notAfter);
x->cert_info->validity.notAfter = in; x->cert_info.validity.notAfter = in;
} }
} }
return (in != NULL); return (in != NULL);
...@@ -146,9 +146,9 @@ int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) ...@@ -146,9 +146,9 @@ int X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) int X509_set_pubkey(X509 *x, EVP_PKEY *pkey)
{ {
if ((x == NULL) || (x->cert_info == NULL)) if (x == NULL)
return (0); return (0);
return (X509_PUBKEY_set(&(x->cert_info->key), pkey)); return (X509_PUBKEY_set(&(x->cert_info.key), pkey));
} }
void X509_up_ref(X509 *x) void X509_up_ref(X509 *x)
...@@ -158,17 +158,17 @@ void X509_up_ref(X509 *x) ...@@ -158,17 +158,17 @@ void X509_up_ref(X509 *x)
long X509_get_version(X509 *x) long X509_get_version(X509 *x)
{ {
return ASN1_INTEGER_get(x->cert_info->version); return ASN1_INTEGER_get(x->cert_info.version);
} }
ASN1_TIME * X509_get_notBefore(X509 *x) ASN1_TIME * X509_get_notBefore(X509 *x)
{ {
return x->cert_info->validity.notBefore; return x->cert_info.validity.notBefore;
} }
ASN1_TIME *X509_get_notAfter(X509 *x) ASN1_TIME *X509_get_notAfter(X509 *x)
{ {
return x->cert_info->validity.notAfter; return x->cert_info.validity.notAfter;
} }
int X509_get_signature_type(const X509 *x) int X509_get_signature_type(const X509 *x)
...@@ -178,5 +178,5 @@ int X509_get_signature_type(const X509 *x) ...@@ -178,5 +178,5 @@ int X509_get_signature_type(const X509 *x)
X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x) X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x)
{ {
return x->cert_info->key; return x->cert_info.key;
} }
...@@ -74,10 +74,10 @@ ...@@ -74,10 +74,10 @@
int X509_verify(X509 *a, EVP_PKEY *r) int X509_verify(X509 *a, EVP_PKEY *r)
{ {
if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature)) if (X509_ALGOR_cmp(a->sig_alg, a->cert_info.signature))
return 0; return 0;
return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), a->sig_alg, return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), a->sig_alg,
a->signature, a->cert_info, r)); a->signature, &a->cert_info, r));
} }
int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
...@@ -94,17 +94,17 @@ int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) ...@@ -94,17 +94,17 @@ int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r)
int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
{ {
x->cert_info->enc.modified = 1; x->cert_info.enc.modified = 1;
return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature, return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info.signature,
x->sig_alg, x->signature, x->cert_info, pkey, md)); x->sig_alg, x->signature, &x->cert_info, pkey, md));
} }
int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx)
{ {
x->cert_info->enc.modified = 1; x->cert_info.enc.modified = 1;
return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CINF), return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CINF),
x->cert_info->signature, x->cert_info.signature,
x->sig_alg, x->signature, x->cert_info, ctx); x->sig_alg, x->signature, &x->cert_info, ctx);
} }
int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert) int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert)
......
...@@ -376,7 +376,7 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, ...@@ -376,7 +376,7 @@ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
{ {
STACK_OF(X509_EXTENSION) **sk = NULL; STACK_OF(X509_EXTENSION) **sk = NULL;
if (cert) if (cert)
sk = &cert->cert_info->extensions; sk = &cert->cert_info.extensions;
return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
} }
......
...@@ -128,7 +128,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, ...@@ -128,7 +128,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
if (ctx->subject_req) if (ctx->subject_req)
pk = ctx->subject_req->req_info->pubkey->public_key; pk = ctx->subject_req->req_info->pubkey->public_key;
else else
pk = ctx->subject_cert->cert_info->key->public_key; pk = ctx->subject_cert->cert_info.key->public_key;
if (!pk) { if (!pk) {
X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY); X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
......
...@@ -181,7 +181,7 @@ typedef struct x509_cinf_st { ...@@ -181,7 +181,7 @@ typedef struct x509_cinf_st {
typedef struct x509_cert_aux_st X509_CERT_AUX; typedef struct x509_cert_aux_st X509_CERT_AUX;
struct x509_st { struct x509_st {
X509_CINF *cert_info; X509_CINF cert_info;
X509_ALGOR *sig_alg; X509_ALGOR *sig_alg;
ASN1_BIT_STRING *signature; ASN1_BIT_STRING *signature;
int valid; int valid;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册