Add EX_DATA support to X509.

Fix a bug in the X509_get_d2i() functions which didn't check if crit was NULL.
This commit is contained in:
Dr. Stephen Henson 1999-10-11 01:30:04 +00:00
parent 4654ef985b
commit 56a3fec1b1
4 changed files with 33 additions and 2 deletions

View File

@ -4,6 +4,10 @@
Changes between 0.9.4 and 0.9.5 [xx XXX 1999]
*) Add a CRYPTO_EX_DATA to X509 certificate structure and associated
functions.
[Steve Henson]
*) New X509V3_{X509,CRL,REVOKED}_get_d2i() functions. These will search
for, obtain and decode and extension and obtain its critical flag.
This allows all the necessary extension code to be handled in a

View File

@ -62,6 +62,9 @@
#include <openssl/asn1_mac.h>
#include <openssl/x509.h>
static int x509_meth_num = 0;
static STACK *x509_meth = NULL;
static ASN1_METHOD meth={
(int (*)()) i2d_X509,
(char *(*)())d2i_X509,
@ -117,6 +120,7 @@ X509 *X509_new(void)
M_ASN1_New(ret->cert_info,X509_CINF_new);
M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
CRYPTO_new_ex_data(x509_meth, (char *)ret, &ret->ex_data);
return(ret);
M_ASN1_New_Error(ASN1_F_X509_NEW);
}
@ -140,7 +144,7 @@ void X509_free(X509 *a)
}
#endif
/* CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); */
CRYPTO_free_ex_data(x509_meth,(char *)a,&a->ex_data);
X509_CINF_free(a->cert_info);
X509_ALGOR_free(a->sig_alg);
ASN1_BIT_STRING_free(a->signature);
@ -149,3 +153,21 @@ void X509_free(X509 *a)
Free((char *)a);
}
int X509_get_ex_new_index(long argl, char *argp, int (*new_func)(),
int (*dup_func)(), void (*free_func)())
{
x509_meth_num++;
return(CRYPTO_get_ex_new_index(x509_meth_num-1,
&x509_meth,argl,argp,new_func,dup_func,free_func));
}
int X509_set_ex_data(X509 *r, int idx, char *arg)
{
return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
}
char *X509_get_ex_data(X509 *r, int idx)
{
return(CRYPTO_get_ex_data(&r->ex_data,idx));
}

View File

@ -238,6 +238,7 @@ typedef struct x509_st
int valid;
int references;
char *name;
CRYPTO_EX_DATA ex_data;
} X509;
DECLARE_STACK_OF(X509)
@ -724,6 +725,10 @@ X509 * X509_new(void);
void X509_free(X509 *a);
int i2d_X509(X509 *a,unsigned char **pp);
X509 * d2i_X509(X509 **a,unsigned char **pp,long length);
int X509_get_ex_new_index(long argl, char *argp, int (*new_func)(),
int (*dup_func)(), void (*free_func)());
int X509_set_ex_data(X509 *r, int idx, char *arg);
char *X509_get_ex_data(X509 *r, int idx);
X509_REVOKED * X509_REVOKED_new(void);
void X509_REVOKED_free(X509_REVOKED *a);

View File

@ -219,7 +219,7 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
}
if(found_ex) {
/* Found it */
*crit = found_ex->critical;
if(crit) *crit = found_ex->critical;
return X509V3_EXT_d2i(found_ex);
}