diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-12-08 19:09:35 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-12-08 19:09:35 +0000 |
commit | 9d6b1ce6441c7cc6aed344f02d9f676ab5e04217 (patch) | |
tree | 7329435a21d3289cb3caad6d3d6c065f484373e1 /crypto/x509 | |
parent | 66ebbb6a56bc1688fa37878e4feec985b0c260d7 (diff) |
Merge from the ASN1 branch of new ASN1 code
to main trunk.
Lets see if the makes it to openssl-cvs :-)
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/Makefile.ssl | 24 | ||||
-rw-r--r-- | crypto/x509/x509.h | 153 | ||||
-rw-r--r-- | crypto/x509/x509_att.c | 6 | ||||
-rw-r--r-- | crypto/x509/x509_req.c | 6 | ||||
-rw-r--r-- | crypto/x509/x509_v3.c | 9 | ||||
-rw-r--r-- | crypto/x509/x509spki.c | 1 |
6 files changed, 54 insertions, 145 deletions
diff --git a/crypto/x509/Makefile.ssl b/crypto/x509/Makefile.ssl index 94020e42aa..c3ee997b8b 100644 --- a/crypto/x509/Makefile.ssl +++ b/crypto/x509/Makefile.ssl @@ -481,18 +481,18 @@ x509rset.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h x509rset.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h x509rset.o: ../../include/openssl/x509_vfy.h ../cryptlib.h -x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h -x509spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h -x509spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -x509spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h -x509spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h -x509spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h -x509spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h -x509spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h -x509spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h -x509spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h -x509spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h -x509spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +x509spki.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +x509spki.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +x509spki.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +x509spki.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +x509spki.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +x509spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h +x509spki.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h +x509spki.o: ../../include/openssl/md2.h ../../include/openssl/md4.h +x509spki.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +x509spki.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +x509spki.o: ../../include/openssl/opensslconf.h x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h x509spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h x509spki.o: ../../include/openssl/rc5.h ../../include/openssl/rd_fst.h diff --git a/crypto/x509/x509.h b/crypto/x509/x509.h index 228a0b7062..82714b7601 100644 --- a/crypto/x509/x509.h +++ b/crypto/x509/x509.h @@ -182,11 +182,8 @@ DECLARE_STACK_OF(X509_NAME) typedef struct X509_extension_st { ASN1_OBJECT *object; - short critical; - short netscape_hack; + ASN1_BOOLEAN critical; ASN1_OCTET_STRING *value; - struct v3_ext_method *method; /* V3 method to use */ - void *ext_val; /* extension value */ } X509_EXTENSION; DECLARE_STACK_OF(X509_EXTENSION) @@ -196,27 +193,26 @@ DECLARE_ASN1_SET_OF(X509_EXTENSION) typedef struct x509_attributes_st { ASN1_OBJECT *object; - int set; /* 1 for a set, 0 for a single item (which is wrong) */ + int single; /* 0 for a set, 1 for a single item (which is wrong) */ union { char *ptr; -/* 1 */ STACK_OF(ASN1_TYPE) *set; -/* 0 */ ASN1_TYPE *single; +/* 0 */ STACK_OF(ASN1_TYPE) *set; +/* 1 */ ASN1_TYPE *single; } value; } X509_ATTRIBUTE; DECLARE_STACK_OF(X509_ATTRIBUTE) DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) + typedef struct X509_req_info_st { - unsigned char *asn1; - int length; + ASN1_ENCODING enc; ASN1_INTEGER *version; X509_NAME *subject; X509_PUBKEY *pubkey; /* d=2 hl=2 l= 0 cons: cont: 00 */ STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ - int req_kludge; } X509_REQ_INFO; typedef struct X509_req_st @@ -827,23 +823,11 @@ X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); void ERR_load_X509_strings(void ); -X509_ALGOR * X509_ALGOR_new(void ); -void X509_ALGOR_free(X509_ALGOR *a); -int i2d_X509_ALGOR(X509_ALGOR *a,unsigned char **pp); -X509_ALGOR * d2i_X509_ALGOR(X509_ALGOR **a,unsigned char **pp, - long length); +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_FUNCTIONS(X509_VAL) -X509_VAL * X509_VAL_new(void ); -void X509_VAL_free(X509_VAL *a); -int i2d_X509_VAL(X509_VAL *a,unsigned char **pp); -X509_VAL * d2i_X509_VAL(X509_VAL **a,unsigned char **pp, - long length); +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) -X509_PUBKEY * X509_PUBKEY_new(void ); -void X509_PUBKEY_free(X509_PUBKEY *a); -int i2d_X509_PUBKEY(X509_PUBKEY *a,unsigned char **pp); -X509_PUBKEY * d2i_X509_PUBKEY(X509_PUBKEY **a,unsigned char **pp, - long length); int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); int X509_get_pubkey_parameters(EVP_PKEY *pkey, @@ -862,58 +846,26 @@ DSA * d2i_DSA_PUBKEY(DSA **a,unsigned char **pp, long length); #endif -X509_SIG * X509_SIG_new(void ); -void X509_SIG_free(X509_SIG *a); -int i2d_X509_SIG(X509_SIG *a,unsigned char **pp); -X509_SIG * d2i_X509_SIG(X509_SIG **a,unsigned char **pp,long length); - -X509_REQ_INFO *X509_REQ_INFO_new(void); -void X509_REQ_INFO_free(X509_REQ_INFO *a); -int i2d_X509_REQ_INFO(X509_REQ_INFO *a,unsigned char **pp); -X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a,unsigned char **pp, - long length); - -X509_REQ * X509_REQ_new(void); -void X509_REQ_free(X509_REQ *a); -int i2d_X509_REQ(X509_REQ *a,unsigned char **pp); -X509_REQ * d2i_X509_REQ(X509_REQ **a,unsigned char **pp,long length); +DECLARE_ASN1_FUNCTIONS(X509_SIG) +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) -X509_ATTRIBUTE *X509_ATTRIBUTE_new(void ); -void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a); -int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a,unsigned char **pp); -X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a,unsigned char **pp, - long length); +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) -X509_EXTENSION *X509_EXTENSION_new(void ); -void X509_EXTENSION_free(X509_EXTENSION *a); -int i2d_X509_EXTENSION(X509_EXTENSION *a,unsigned char **pp); -X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a,unsigned char **pp, - long length); +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) -X509_NAME_ENTRY *X509_NAME_ENTRY_new(void); -void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a); -int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a,unsigned char **pp); -X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a,unsigned char **pp, - long length); +DECLARE_ASN1_FUNCTIONS(X509_NAME) -X509_NAME * X509_NAME_new(void); -void X509_NAME_free(X509_NAME *a); -int i2d_X509_NAME(X509_NAME *a,unsigned char **pp); -X509_NAME * d2i_X509_NAME(X509_NAME **a,unsigned char **pp,long length); int X509_NAME_set(X509_NAME **xn, X509_NAME *name); +DECLARE_ASN1_FUNCTIONS(X509_CINF) -X509_CINF * X509_CINF_new(void); -void X509_CINF_free(X509_CINF *a); -int i2d_X509_CINF(X509_CINF *a,unsigned char **pp); -X509_CINF * d2i_X509_CINF(X509_CINF **a,unsigned char **pp,long length); +DECLARE_ASN1_FUNCTIONS(X509) +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) -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, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); int X509_set_ex_data(X509 *r, int idx, void *arg); @@ -921,11 +873,6 @@ void *X509_get_ex_data(X509 *r, int idx); int i2d_X509_AUX(X509 *a,unsigned char **pp); X509 * d2i_X509_AUX(X509 **a,unsigned char **pp,long length); -X509_CERT_AUX * X509_CERT_AUX_new(void); -void X509_CERT_AUX_free(X509_CERT_AUX *a); -int i2d_X509_CERT_AUX(X509_CERT_AUX *a,unsigned char **pp); -X509_CERT_AUX * d2i_X509_CERT_AUX(X509_CERT_AUX **a,unsigned char **pp, - long length); int X509_alias_set1(X509 *x, unsigned char *name, int len); int X509_keyid_set1(X509 *x, unsigned char *id, int len); unsigned char * X509_alias_get0(X509 *x, int *len); @@ -935,44 +882,20 @@ int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); void X509_trust_clear(X509 *x); void X509_reject_clear(X509 *x); -X509_REVOKED * X509_REVOKED_new(void); -void X509_REVOKED_free(X509_REVOKED *a); -int i2d_X509_REVOKED(X509_REVOKED *a,unsigned char **pp); -X509_REVOKED * d2i_X509_REVOKED(X509_REVOKED **a,unsigned char **pp,long length); +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) -X509_CRL_INFO *X509_CRL_INFO_new(void); -void X509_CRL_INFO_free(X509_CRL_INFO *a); -int i2d_X509_CRL_INFO(X509_CRL_INFO *a,unsigned char **pp); -X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a,unsigned char **pp, - long length); - -X509_CRL * X509_CRL_new(void); -void X509_CRL_free(X509_CRL *a); -int i2d_X509_CRL(X509_CRL *a,unsigned char **pp); -X509_CRL * d2i_X509_CRL(X509_CRL **a,unsigned char **pp,long length); +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); X509_PKEY * X509_PKEY_new(void ); void X509_PKEY_free(X509_PKEY *a); int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,unsigned char **pp,long length); -NETSCAPE_SPKI * NETSCAPE_SPKI_new(void ); -void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a); -int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a,unsigned char **pp); -NETSCAPE_SPKI * d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a,unsigned char **pp, - long length); - -NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void ); -void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a); -int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a,unsigned char **pp); -NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a,unsigned char **pp, - long length); - - -int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp); -NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void); -NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, unsigned char **pp, long length); -void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a); +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) #ifndef NO_EVP X509_INFO * X509_INFO_new(void); @@ -1192,31 +1115,17 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, ASN1_INTEGER *serial); X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); -int i2d_PBEPARAM(PBEPARAM *a, unsigned char **pp); -PBEPARAM *PBEPARAM_new(void); -PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length); -void PBEPARAM_free(PBEPARAM *a); +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) + X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen); -int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp); -PBKDF2PARAM *PBKDF2PARAM_new(void); -PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp, long length); -void PBKDF2PARAM_free(PBKDF2PARAM *a); - -int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **pp); -PBE2PARAM *PBE2PARAM_new(void); -PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length); -void PBE2PARAM_free(PBE2PARAM *a); - /* PKCS#8 utilities */ -int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **pp); -PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, - unsigned char **pp, long length); -void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a); +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c index caafde658f..f074d2ab18 100644 --- a/crypto/x509/x509_att.c +++ b/crypto/x509/x509_att.c @@ -283,7 +283,7 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; if(!(ttmp = ASN1_TYPE_new())) goto err; if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; - attr->set = 1; + attr->single = 0; ASN1_TYPE_set(ttmp, atype, stmp); return 1; err: @@ -293,7 +293,7 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr) { - if(attr->set) return sk_ASN1_TYPE_num(attr->value.set); + if(!attr->single) return sk_ASN1_TYPE_num(attr->value.set); if(attr->value.single) return 1; return 0; } @@ -321,6 +321,6 @@ ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx) { if (attr == NULL) return(NULL); if(idx >= X509_ATTRIBUTE_count(attr)) return NULL; - if(attr->set) return sk_ASN1_TYPE_value(attr->value.set, idx); + if(!attr->single) return sk_ASN1_TYPE_value(attr->value.set, idx); else return attr->value.single; } diff --git a/crypto/x509/x509_req.c b/crypto/x509/x509_req.c index 7eca1bd57a..e2766e1a5f 100644 --- a/crypto/x509/x509_req.c +++ b/crypto/x509/x509_req.c @@ -156,9 +156,9 @@ STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req) for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { attr = sk_X509_ATTRIBUTE_value(sk, i); if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) { - if(attr->set && sk_ASN1_TYPE_num(attr->value.set)) + if(attr->single) ext = attr->value.single; + else if(sk_ASN1_TYPE_num(attr->value.set)) ext = sk_ASN1_TYPE_value(attr->value.set, 0); - else ext = attr->value.single; break; } } @@ -199,7 +199,7 @@ int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; if(!sk_ASN1_TYPE_push(attr->value.set, at)) goto err; at = NULL; - attr->set = 1; + attr->single = 0; attr->object = OBJ_nid2obj(nid); if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err; return 1; diff --git a/crypto/x509/x509_v3.c b/crypto/x509/x509_v3.c index 52887986fe..b5f7daa2e5 100644 --- a/crypto/x509/x509_v3.c +++ b/crypto/x509/x509_v3.c @@ -115,8 +115,8 @@ int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, for ( ; lastpos < n; lastpos++) { ex=sk_X509_EXTENSION_value(sk,lastpos); - if ( (ex->critical && crit) || - (!ex->critical && !crit)) + if ( ((ex->critical > 0) && crit) || + (!(ex->critical <= 0) && !crit)) return(lastpos); } return(-1); @@ -234,7 +234,7 @@ int X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj) int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) { if (ex == NULL) return(0); - ex->critical=(crit)?0xFF:0; + ex->critical=(crit)?0xFF:-1; return(1); } @@ -263,5 +263,6 @@ ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ex) int X509_EXTENSION_get_critical(X509_EXTENSION *ex) { if (ex == NULL) return(0); - return(ex->critical); + if(ex->critical > 0) return 1; + return 0; } diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c index fd0a534d88..4c3af946ec 100644 --- a/crypto/x509/x509spki.c +++ b/crypto/x509/x509spki.c @@ -59,7 +59,6 @@ #include <stdio.h> #include "cryptlib.h" #include <openssl/x509.h> -#include <openssl/asn1_mac.h> int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey) { |