diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2015-02-09 16:04:47 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2015-02-09 16:04:47 +0000 |
commit | 2e98c50d1cab09e899f8ee544ffa8ca3a9ebfff0 (patch) | |
tree | 3261b53bc8160c974d27f6f4dd8a5fd9a9f934a4 | |
parent | 8d8292131b2ae2efd5982152b95618b052468217 (diff) |
Expand the IMPLEMENT_ASN1_FUNCTIONS macro so that the code is visible and
functions can be readily located.
Change has been scripted and there is no change to the generated assembly.
Discussed with beck@ miod@ tedu@
-rw-r--r-- | lib/libcrypto/gost/gost_asn1.c | 130 | ||||
-rw-r--r-- | lib/libcrypto/krb5/krb5_asn.c | 288 | ||||
-rw-r--r-- | lib/libcrypto/ocsp/ocsp_asn.c | 392 | ||||
-rw-r--r-- | lib/libcrypto/pkcs12/p12_asn.c | 106 | ||||
-rw-r--r-- | lib/libcrypto/pkcs7/pk7_asn1.c | 262 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_asn1.c | 28 |
6 files changed, 1155 insertions, 51 deletions
diff --git a/lib/libcrypto/gost/gost_asn1.c b/lib/libcrypto/gost/gost_asn1.c index b8ed244e492..5d7fb51177e 100644 --- a/lib/libcrypto/gost/gost_asn1.c +++ b/lib/libcrypto/gost/gost_asn1.c @@ -21,20 +21,92 @@ ASN1_NDEF_SEQUENCE(GOST_KEY_TRANSPORT) = { ASN1_SIMPLE(GOST_KEY_TRANSPORT, key_info, GOST_KEY_INFO), ASN1_IMP(GOST_KEY_TRANSPORT, key_agreement_info, GOST_KEY_AGREEMENT_INFO, 0) } ASN1_NDEF_SEQUENCE_END(GOST_KEY_TRANSPORT) -IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_TRANSPORT) + +GOST_KEY_TRANSPORT * +d2i_GOST_KEY_TRANSPORT(GOST_KEY_TRANSPORT **a, const unsigned char **in, long len) +{ + return (GOST_KEY_TRANSPORT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &GOST_KEY_TRANSPORT_it); +} + +int +i2d_GOST_KEY_TRANSPORT(GOST_KEY_TRANSPORT *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_TRANSPORT_it); +} + +GOST_KEY_TRANSPORT * +GOST_KEY_TRANSPORT_new(void) +{ + return (GOST_KEY_TRANSPORT *)ASN1_item_new(&GOST_KEY_TRANSPORT_it); +} + +void +GOST_KEY_TRANSPORT_free(GOST_KEY_TRANSPORT *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_TRANSPORT_it); +} ASN1_NDEF_SEQUENCE(GOST_KEY_INFO) = { ASN1_SIMPLE(GOST_KEY_INFO, encrypted_key, ASN1_OCTET_STRING), ASN1_SIMPLE(GOST_KEY_INFO, imit, ASN1_OCTET_STRING) } ASN1_NDEF_SEQUENCE_END(GOST_KEY_INFO) -IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_INFO) + +GOST_KEY_INFO * +d2i_GOST_KEY_INFO(GOST_KEY_INFO **a, const unsigned char **in, long len) +{ + return (GOST_KEY_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &GOST_KEY_INFO_it); +} + +int +i2d_GOST_KEY_INFO(GOST_KEY_INFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_INFO_it); +} + +GOST_KEY_INFO * +GOST_KEY_INFO_new(void) +{ + return (GOST_KEY_INFO *)ASN1_item_new(&GOST_KEY_INFO_it); +} + +void +GOST_KEY_INFO_free(GOST_KEY_INFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_INFO_it); +} ASN1_NDEF_SEQUENCE(GOST_KEY_AGREEMENT_INFO) = { ASN1_SIMPLE(GOST_KEY_AGREEMENT_INFO, cipher, ASN1_OBJECT), ASN1_IMP_OPT(GOST_KEY_AGREEMENT_INFO, ephem_key, X509_PUBKEY, 0), ASN1_SIMPLE(GOST_KEY_AGREEMENT_INFO, eph_iv, ASN1_OCTET_STRING) } ASN1_NDEF_SEQUENCE_END(GOST_KEY_AGREEMENT_INFO) -IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_AGREEMENT_INFO) + +GOST_KEY_AGREEMENT_INFO * +d2i_GOST_KEY_AGREEMENT_INFO(GOST_KEY_AGREEMENT_INFO **a, const unsigned char **in, long len) +{ + return (GOST_KEY_AGREEMENT_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &GOST_KEY_AGREEMENT_INFO_it); +} + +int +i2d_GOST_KEY_AGREEMENT_INFO(GOST_KEY_AGREEMENT_INFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_AGREEMENT_INFO_it); +} + +GOST_KEY_AGREEMENT_INFO * +GOST_KEY_AGREEMENT_INFO_new(void) +{ + return (GOST_KEY_AGREEMENT_INFO *)ASN1_item_new(&GOST_KEY_AGREEMENT_INFO_it); +} + +void +GOST_KEY_AGREEMENT_INFO_free(GOST_KEY_AGREEMENT_INFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_AGREEMENT_INFO_it); +} ASN1_NDEF_SEQUENCE(GOST_KEY_PARAMS) = { @@ -42,12 +114,60 @@ ASN1_NDEF_SEQUENCE(GOST_KEY_PARAMS) = { ASN1_SIMPLE(GOST_KEY_PARAMS, hash_params, ASN1_OBJECT), ASN1_OPT(GOST_KEY_PARAMS, cipher_params, ASN1_OBJECT), } ASN1_NDEF_SEQUENCE_END(GOST_KEY_PARAMS) -IMPLEMENT_ASN1_FUNCTIONS(GOST_KEY_PARAMS) + +GOST_KEY_PARAMS * +d2i_GOST_KEY_PARAMS(GOST_KEY_PARAMS **a, const unsigned char **in, long len) +{ + return (GOST_KEY_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &GOST_KEY_PARAMS_it); +} + +int +i2d_GOST_KEY_PARAMS(GOST_KEY_PARAMS *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_PARAMS_it); +} + +GOST_KEY_PARAMS * +GOST_KEY_PARAMS_new(void) +{ + return (GOST_KEY_PARAMS *)ASN1_item_new(&GOST_KEY_PARAMS_it); +} + +void +GOST_KEY_PARAMS_free(GOST_KEY_PARAMS *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_PARAMS_it); +} ASN1_NDEF_SEQUENCE(GOST_CIPHER_PARAMS) = { ASN1_SIMPLE(GOST_CIPHER_PARAMS, iv, ASN1_OCTET_STRING), ASN1_SIMPLE(GOST_CIPHER_PARAMS, enc_param_set, ASN1_OBJECT), } ASN1_NDEF_SEQUENCE_END(GOST_CIPHER_PARAMS) -IMPLEMENT_ASN1_FUNCTIONS(GOST_CIPHER_PARAMS) + +GOST_CIPHER_PARAMS * +d2i_GOST_CIPHER_PARAMS(GOST_CIPHER_PARAMS **a, const unsigned char **in, long len) +{ + return (GOST_CIPHER_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &GOST_CIPHER_PARAMS_it); +} + +int +i2d_GOST_CIPHER_PARAMS(GOST_CIPHER_PARAMS *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_CIPHER_PARAMS_it); +} + +GOST_CIPHER_PARAMS * +GOST_CIPHER_PARAMS_new(void) +{ + return (GOST_CIPHER_PARAMS *)ASN1_item_new(&GOST_CIPHER_PARAMS_it); +} + +void +GOST_CIPHER_PARAMS_free(GOST_CIPHER_PARAMS *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &GOST_CIPHER_PARAMS_it); +} #endif diff --git a/lib/libcrypto/krb5/krb5_asn.c b/lib/libcrypto/krb5/krb5_asn.c index bcef47a7bdb..1a95e62935a 100644 --- a/lib/libcrypto/krb5/krb5_asn.c +++ b/lib/libcrypto/krb5/krb5_asn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: krb5_asn.c,v 1.2 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: krb5_asn.c,v 1.3 2015/02/09 16:04:46 jsing Exp $ */ /* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project, ** using ocsp/{*.h,*asn*.c} as a starting point */ @@ -66,7 +66,31 @@ ASN1_SEQUENCE(KRB5_ENCDATA) = { ASN1_EXP(KRB5_ENCDATA, cipher, ASN1_OCTET_STRING,2) } ASN1_SEQUENCE_END(KRB5_ENCDATA) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCDATA) + +KRB5_ENCDATA * +d2i_KRB5_ENCDATA(KRB5_ENCDATA **a, const unsigned char **in, long len) +{ + return (KRB5_ENCDATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_ENCDATA_it); +} + +int +i2d_KRB5_ENCDATA(KRB5_ENCDATA *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_ENCDATA_it); +} + +KRB5_ENCDATA * +KRB5_ENCDATA_new(void) +{ + return (KRB5_ENCDATA *)ASN1_item_new(&KRB5_ENCDATA_it); +} + +void +KRB5_ENCDATA_free(KRB5_ENCDATA *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_ENCDATA_it); +} ASN1_SEQUENCE(KRB5_PRINCNAME) = { @@ -74,7 +98,31 @@ ASN1_SEQUENCE(KRB5_PRINCNAME) = { ASN1_EXP_SEQUENCE_OF(KRB5_PRINCNAME, namestring, ASN1_GENERALSTRING, 1) } ASN1_SEQUENCE_END(KRB5_PRINCNAME) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_PRINCNAME) + +KRB5_PRINCNAME * +d2i_KRB5_PRINCNAME(KRB5_PRINCNAME **a, const unsigned char **in, long len) +{ + return (KRB5_PRINCNAME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_PRINCNAME_it); +} + +int +i2d_KRB5_PRINCNAME(KRB5_PRINCNAME *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_PRINCNAME_it); +} + +KRB5_PRINCNAME * +KRB5_PRINCNAME_new(void) +{ + return (KRB5_PRINCNAME *)ASN1_item_new(&KRB5_PRINCNAME_it); +} + +void +KRB5_PRINCNAME_free(KRB5_PRINCNAME *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_PRINCNAME_it); +} /* [APPLICATION 1] = 0x61 */ @@ -85,7 +133,31 @@ ASN1_SEQUENCE(KRB5_TKTBODY) = { ASN1_EXP(KRB5_TKTBODY, encdata, KRB5_ENCDATA, 3) } ASN1_SEQUENCE_END(KRB5_TKTBODY) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_TKTBODY) + +KRB5_TKTBODY * +d2i_KRB5_TKTBODY(KRB5_TKTBODY **a, const unsigned char **in, long len) +{ + return (KRB5_TKTBODY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_TKTBODY_it); +} + +int +i2d_KRB5_TKTBODY(KRB5_TKTBODY *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_TKTBODY_it); +} + +KRB5_TKTBODY * +KRB5_TKTBODY_new(void) +{ + return (KRB5_TKTBODY *)ASN1_item_new(&KRB5_TKTBODY_it); +} + +void +KRB5_TKTBODY_free(KRB5_TKTBODY *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_TKTBODY_it); +} ASN1_ITEM_TEMPLATE(KRB5_TICKET) = @@ -93,7 +165,31 @@ ASN1_ITEM_TEMPLATE(KRB5_TICKET) = KRB5_TICKET, KRB5_TKTBODY) ASN1_ITEM_TEMPLATE_END(KRB5_TICKET) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_TICKET) + +KRB5_TICKET * +d2i_KRB5_TICKET(KRB5_TICKET **a, const unsigned char **in, long len) +{ + return (KRB5_TICKET *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_TICKET_it); +} + +int +i2d_KRB5_TICKET(KRB5_TICKET *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_TICKET_it); +} + +KRB5_TICKET * +KRB5_TICKET_new(void) +{ + return (KRB5_TICKET *)ASN1_item_new(&KRB5_TICKET_it); +} + +void +KRB5_TICKET_free(KRB5_TICKET *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_TICKET_it); +} /* [APPLICATION 14] = 0x6e */ @@ -105,14 +201,62 @@ ASN1_SEQUENCE(KRB5_APREQBODY) = { ASN1_EXP(KRB5_APREQBODY, authenticator, KRB5_ENCDATA, 4), } ASN1_SEQUENCE_END(KRB5_APREQBODY) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQBODY) + +KRB5_APREQBODY * +d2i_KRB5_APREQBODY(KRB5_APREQBODY **a, const unsigned char **in, long len) +{ + return (KRB5_APREQBODY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_APREQBODY_it); +} + +int +i2d_KRB5_APREQBODY(KRB5_APREQBODY *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_APREQBODY_it); +} + +KRB5_APREQBODY * +KRB5_APREQBODY_new(void) +{ + return (KRB5_APREQBODY *)ASN1_item_new(&KRB5_APREQBODY_it); +} + +void +KRB5_APREQBODY_free(KRB5_APREQBODY *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_APREQBODY_it); +} ASN1_ITEM_TEMPLATE(KRB5_APREQ) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 14, KRB5_APREQ, KRB5_APREQBODY) ASN1_ITEM_TEMPLATE_END(KRB5_APREQ) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQ) + +KRB5_APREQ * +d2i_KRB5_APREQ(KRB5_APREQ **a, const unsigned char **in, long len) +{ + return (KRB5_APREQ *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_APREQ_it); +} + +int +i2d_KRB5_APREQ(KRB5_APREQ *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_APREQ_it); +} + +KRB5_APREQ * +KRB5_APREQ_new(void) +{ + return (KRB5_APREQ *)ASN1_item_new(&KRB5_APREQ_it); +} + +void +KRB5_APREQ_free(KRB5_APREQ *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_APREQ_it); +} /* Authenticator stuff */ @@ -122,7 +266,31 @@ ASN1_SEQUENCE(KRB5_CHECKSUM) = { ASN1_EXP(KRB5_CHECKSUM, checksum, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_CHECKSUM) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_CHECKSUM) + +KRB5_CHECKSUM * +d2i_KRB5_CHECKSUM(KRB5_CHECKSUM **a, const unsigned char **in, long len) +{ + return (KRB5_CHECKSUM *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_CHECKSUM_it); +} + +int +i2d_KRB5_CHECKSUM(KRB5_CHECKSUM *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_CHECKSUM_it); +} + +KRB5_CHECKSUM * +KRB5_CHECKSUM_new(void) +{ + return (KRB5_CHECKSUM *)ASN1_item_new(&KRB5_CHECKSUM_it); +} + +void +KRB5_CHECKSUM_free(KRB5_CHECKSUM *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_CHECKSUM_it); +} ASN1_SEQUENCE(KRB5_ENCKEY) = { @@ -130,7 +298,31 @@ ASN1_SEQUENCE(KRB5_ENCKEY) = { ASN1_EXP(KRB5_ENCKEY, keyvalue, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_ENCKEY) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCKEY) + +KRB5_ENCKEY * +d2i_KRB5_ENCKEY(KRB5_ENCKEY **a, const unsigned char **in, long len) +{ + return (KRB5_ENCKEY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_ENCKEY_it); +} + +int +i2d_KRB5_ENCKEY(KRB5_ENCKEY *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_ENCKEY_it); +} + +KRB5_ENCKEY * +KRB5_ENCKEY_new(void) +{ + return (KRB5_ENCKEY *)ASN1_item_new(&KRB5_ENCKEY_it); +} + +void +KRB5_ENCKEY_free(KRB5_ENCKEY *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_ENCKEY_it); +} /* SEQ OF SEQ; see ASN1_EXP_SEQUENCE_OF_OPT() below */ @@ -139,7 +331,31 @@ ASN1_SEQUENCE(KRB5_AUTHDATA) = { ASN1_EXP(KRB5_AUTHDATA, addata, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_AUTHDATA) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHDATA) + +KRB5_AUTHDATA * +d2i_KRB5_AUTHDATA(KRB5_AUTHDATA **a, const unsigned char **in, long len) +{ + return (KRB5_AUTHDATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_AUTHDATA_it); +} + +int +i2d_KRB5_AUTHDATA(KRB5_AUTHDATA *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_AUTHDATA_it); +} + +KRB5_AUTHDATA * +KRB5_AUTHDATA_new(void) +{ + return (KRB5_AUTHDATA *)ASN1_item_new(&KRB5_AUTHDATA_it); +} + +void +KRB5_AUTHDATA_free(KRB5_AUTHDATA *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_AUTHDATA_it); +} /* [APPLICATION 2] = 0x62 */ @@ -156,12 +372,60 @@ ASN1_SEQUENCE(KRB5_AUTHENTBODY) = { (KRB5_AUTHENTBODY, authorization, KRB5_AUTHDATA, 8), } ASN1_SEQUENCE_END(KRB5_AUTHENTBODY) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) + +KRB5_AUTHENTBODY * +d2i_KRB5_AUTHENTBODY(KRB5_AUTHENTBODY **a, const unsigned char **in, long len) +{ + return (KRB5_AUTHENTBODY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_AUTHENTBODY_it); +} + +int +i2d_KRB5_AUTHENTBODY(KRB5_AUTHENTBODY *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_AUTHENTBODY_it); +} + +KRB5_AUTHENTBODY * +KRB5_AUTHENTBODY_new(void) +{ + return (KRB5_AUTHENTBODY *)ASN1_item_new(&KRB5_AUTHENTBODY_it); +} + +void +KRB5_AUTHENTBODY_free(KRB5_AUTHENTBODY *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_AUTHENTBODY_it); +} ASN1_ITEM_TEMPLATE(KRB5_AUTHENT) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 2, KRB5_AUTHENT, KRB5_AUTHENTBODY) ASN1_ITEM_TEMPLATE_END(KRB5_AUTHENT) -IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENT) + +KRB5_AUTHENT * +d2i_KRB5_AUTHENT(KRB5_AUTHENT **a, const unsigned char **in, long len) +{ + return (KRB5_AUTHENT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &KRB5_AUTHENT_it); +} + +int +i2d_KRB5_AUTHENT(KRB5_AUTHENT *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &KRB5_AUTHENT_it); +} + +KRB5_AUTHENT * +KRB5_AUTHENT_new(void) +{ + return (KRB5_AUTHENT *)ASN1_item_new(&KRB5_AUTHENT_it); +} + +void +KRB5_AUTHENT_free(KRB5_AUTHENT *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &KRB5_AUTHENT_it); +} diff --git a/lib/libcrypto/ocsp/ocsp_asn.c b/lib/libcrypto/ocsp/ocsp_asn.c index a9178d525bd..6ca21af89a2 100644 --- a/lib/libcrypto/ocsp/ocsp_asn.c +++ b/lib/libcrypto/ocsp/ocsp_asn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_asn.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: ocsp_asn.c,v 1.7 2015/02/09 16:04:46 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -65,7 +65,31 @@ ASN1_SEQUENCE(OCSP_SIGNATURE) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SIGNATURE, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_SIGNATURE) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE) + +OCSP_SIGNATURE * +d2i_OCSP_SIGNATURE(OCSP_SIGNATURE **a, const unsigned char **in, long len) +{ + return (OCSP_SIGNATURE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_SIGNATURE_it); +} + +int +i2d_OCSP_SIGNATURE(OCSP_SIGNATURE *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SIGNATURE_it); +} + +OCSP_SIGNATURE * +OCSP_SIGNATURE_new(void) +{ + return (OCSP_SIGNATURE *)ASN1_item_new(&OCSP_SIGNATURE_it); +} + +void +OCSP_SIGNATURE_free(OCSP_SIGNATURE *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_SIGNATURE_it); +} ASN1_SEQUENCE(OCSP_CERTID) = { ASN1_SIMPLE(OCSP_CERTID, hashAlgorithm, X509_ALGOR), @@ -74,14 +98,62 @@ ASN1_SEQUENCE(OCSP_CERTID) = { ASN1_SIMPLE(OCSP_CERTID, serialNumber, ASN1_INTEGER) } ASN1_SEQUENCE_END(OCSP_CERTID) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID) + +OCSP_CERTID * +d2i_OCSP_CERTID(OCSP_CERTID **a, const unsigned char **in, long len) +{ + return (OCSP_CERTID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_CERTID_it); +} + +int +i2d_OCSP_CERTID(OCSP_CERTID *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CERTID_it); +} + +OCSP_CERTID * +OCSP_CERTID_new(void) +{ + return (OCSP_CERTID *)ASN1_item_new(&OCSP_CERTID_it); +} + +void +OCSP_CERTID_free(OCSP_CERTID *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTID_it); +} ASN1_SEQUENCE(OCSP_ONEREQ) = { ASN1_SIMPLE(OCSP_ONEREQ, reqCert, OCSP_CERTID), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_ONEREQ, singleRequestExtensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END(OCSP_ONEREQ) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_ONEREQ) + +OCSP_ONEREQ * +d2i_OCSP_ONEREQ(OCSP_ONEREQ **a, const unsigned char **in, long len) +{ + return (OCSP_ONEREQ *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_ONEREQ_it); +} + +int +i2d_OCSP_ONEREQ(OCSP_ONEREQ *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_ONEREQ_it); +} + +OCSP_ONEREQ * +OCSP_ONEREQ_new(void) +{ + return (OCSP_ONEREQ *)ASN1_item_new(&OCSP_ONEREQ_it); +} + +void +OCSP_ONEREQ_free(OCSP_ONEREQ *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_ONEREQ_it); +} ASN1_SEQUENCE(OCSP_REQINFO) = { ASN1_EXP_OPT(OCSP_REQINFO, version, ASN1_INTEGER, 0), @@ -90,14 +162,62 @@ ASN1_SEQUENCE(OCSP_REQINFO) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_REQINFO, requestExtensions, X509_EXTENSION, 2) } ASN1_SEQUENCE_END(OCSP_REQINFO) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO) + +OCSP_REQINFO * +d2i_OCSP_REQINFO(OCSP_REQINFO **a, const unsigned char **in, long len) +{ + return (OCSP_REQINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_REQINFO_it); +} + +int +i2d_OCSP_REQINFO(OCSP_REQINFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REQINFO_it); +} + +OCSP_REQINFO * +OCSP_REQINFO_new(void) +{ + return (OCSP_REQINFO *)ASN1_item_new(&OCSP_REQINFO_it); +} + +void +OCSP_REQINFO_free(OCSP_REQINFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_REQINFO_it); +} ASN1_SEQUENCE(OCSP_REQUEST) = { ASN1_SIMPLE(OCSP_REQUEST, tbsRequest, OCSP_REQINFO), ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0) } ASN1_SEQUENCE_END(OCSP_REQUEST) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQUEST) + +OCSP_REQUEST * +d2i_OCSP_REQUEST(OCSP_REQUEST **a, const unsigned char **in, long len) +{ + return (OCSP_REQUEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_REQUEST_it); +} + +int +i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REQUEST_it); +} + +OCSP_REQUEST * +OCSP_REQUEST_new(void) +{ + return (OCSP_REQUEST *)ASN1_item_new(&OCSP_REQUEST_it); +} + +void +OCSP_REQUEST_free(OCSP_REQUEST *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_REQUEST_it); +} /* OCSP_RESPONSE templates */ @@ -106,28 +226,124 @@ ASN1_SEQUENCE(OCSP_RESPBYTES) = { ASN1_SIMPLE(OCSP_RESPBYTES, response, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(OCSP_RESPBYTES) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPBYTES) + +OCSP_RESPBYTES * +d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, const unsigned char **in, long len) +{ + return (OCSP_RESPBYTES *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_RESPBYTES_it); +} + +int +i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPBYTES_it); +} + +OCSP_RESPBYTES * +OCSP_RESPBYTES_new(void) +{ + return (OCSP_RESPBYTES *)ASN1_item_new(&OCSP_RESPBYTES_it); +} + +void +OCSP_RESPBYTES_free(OCSP_RESPBYTES *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPBYTES_it); +} ASN1_SEQUENCE(OCSP_RESPONSE) = { ASN1_SIMPLE(OCSP_RESPONSE, responseStatus, ASN1_ENUMERATED), ASN1_EXP_OPT(OCSP_RESPONSE, responseBytes, OCSP_RESPBYTES, 0) } ASN1_SEQUENCE_END(OCSP_RESPONSE) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE) + +OCSP_RESPONSE * +d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, const unsigned char **in, long len) +{ + return (OCSP_RESPONSE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_RESPONSE_it); +} + +int +i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPONSE_it); +} + +OCSP_RESPONSE * +OCSP_RESPONSE_new(void) +{ + return (OCSP_RESPONSE *)ASN1_item_new(&OCSP_RESPONSE_it); +} + +void +OCSP_RESPONSE_free(OCSP_RESPONSE *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPONSE_it); +} ASN1_CHOICE(OCSP_RESPID) = { ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1), ASN1_EXP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2) } ASN1_CHOICE_END(OCSP_RESPID) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID) + +OCSP_RESPID * +d2i_OCSP_RESPID(OCSP_RESPID **a, const unsigned char **in, long len) +{ + return (OCSP_RESPID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_RESPID_it); +} + +int +i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPID_it); +} + +OCSP_RESPID * +OCSP_RESPID_new(void) +{ + return (OCSP_RESPID *)ASN1_item_new(&OCSP_RESPID_it); +} + +void +OCSP_RESPID_free(OCSP_RESPID *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPID_it); +} ASN1_SEQUENCE(OCSP_REVOKEDINFO) = { ASN1_SIMPLE(OCSP_REVOKEDINFO, revocationTime, ASN1_GENERALIZEDTIME), ASN1_EXP_OPT(OCSP_REVOKEDINFO, revocationReason, ASN1_ENUMERATED, 0) } ASN1_SEQUENCE_END(OCSP_REVOKEDINFO) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) + +OCSP_REVOKEDINFO * +d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, const unsigned char **in, long len) +{ + return (OCSP_REVOKEDINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_REVOKEDINFO_it); +} + +int +i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_REVOKEDINFO_it); +} + +OCSP_REVOKEDINFO * +OCSP_REVOKEDINFO_new(void) +{ + return (OCSP_REVOKEDINFO *)ASN1_item_new(&OCSP_REVOKEDINFO_it); +} + +void +OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_REVOKEDINFO_it); +} ASN1_CHOICE(OCSP_CERTSTATUS) = { ASN1_IMP(OCSP_CERTSTATUS, value.good, ASN1_NULL, 0), @@ -135,7 +351,31 @@ ASN1_CHOICE(OCSP_CERTSTATUS) = { ASN1_IMP(OCSP_CERTSTATUS, value.unknown, ASN1_NULL, 2) } ASN1_CHOICE_END(OCSP_CERTSTATUS) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTSTATUS) + +OCSP_CERTSTATUS * +d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, const unsigned char **in, long len) +{ + return (OCSP_CERTSTATUS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_CERTSTATUS_it); +} + +int +i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CERTSTATUS_it); +} + +OCSP_CERTSTATUS * +OCSP_CERTSTATUS_new(void) +{ + return (OCSP_CERTSTATUS *)ASN1_item_new(&OCSP_CERTSTATUS_it); +} + +void +OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_CERTSTATUS_it); +} ASN1_SEQUENCE(OCSP_SINGLERESP) = { ASN1_SIMPLE(OCSP_SINGLERESP, certId, OCSP_CERTID), @@ -145,7 +385,31 @@ ASN1_SEQUENCE(OCSP_SINGLERESP) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SINGLERESP, singleExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_SINGLERESP) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP) + +OCSP_SINGLERESP * +d2i_OCSP_SINGLERESP(OCSP_SINGLERESP **a, const unsigned char **in, long len) +{ + return (OCSP_SINGLERESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_SINGLERESP_it); +} + +int +i2d_OCSP_SINGLERESP(OCSP_SINGLERESP *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SINGLERESP_it); +} + +OCSP_SINGLERESP * +OCSP_SINGLERESP_new(void) +{ + return (OCSP_SINGLERESP *)ASN1_item_new(&OCSP_SINGLERESP_it); +} + +void +OCSP_SINGLERESP_free(OCSP_SINGLERESP *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_SINGLERESP_it); +} ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0), @@ -155,7 +419,31 @@ ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_RESPDATA) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA) + +OCSP_RESPDATA * +d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, const unsigned char **in, long len) +{ + return (OCSP_RESPDATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_RESPDATA_it); +} + +int +i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_RESPDATA_it); +} + +OCSP_RESPDATA * +OCSP_RESPDATA_new(void) +{ + return (OCSP_RESPDATA *)ASN1_item_new(&OCSP_RESPDATA_it); +} + +void +OCSP_RESPDATA_free(OCSP_RESPDATA *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_RESPDATA_it); +} ASN1_SEQUENCE(OCSP_BASICRESP) = { ASN1_SIMPLE(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA), @@ -164,7 +452,31 @@ ASN1_SEQUENCE(OCSP_BASICRESP) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_BASICRESP) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_BASICRESP) + +OCSP_BASICRESP * +d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, const unsigned char **in, long len) +{ + return (OCSP_BASICRESP *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_BASICRESP_it); +} + +int +i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_BASICRESP_it); +} + +OCSP_BASICRESP * +OCSP_BASICRESP_new(void) +{ + return (OCSP_BASICRESP *)ASN1_item_new(&OCSP_BASICRESP_it); +} + +void +OCSP_BASICRESP_free(OCSP_BASICRESP *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_BASICRESP_it); +} ASN1_SEQUENCE(OCSP_CRLID) = { ASN1_EXP_OPT(OCSP_CRLID, crlUrl, ASN1_IA5STRING, 0), @@ -172,11 +484,59 @@ ASN1_SEQUENCE(OCSP_CRLID) = { ASN1_EXP_OPT(OCSP_CRLID, crlTime, ASN1_GENERALIZEDTIME, 2) } ASN1_SEQUENCE_END(OCSP_CRLID) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_CRLID) + +OCSP_CRLID * +d2i_OCSP_CRLID(OCSP_CRLID **a, const unsigned char **in, long len) +{ + return (OCSP_CRLID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_CRLID_it); +} + +int +i2d_OCSP_CRLID(OCSP_CRLID *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_CRLID_it); +} + +OCSP_CRLID * +OCSP_CRLID_new(void) +{ + return (OCSP_CRLID *)ASN1_item_new(&OCSP_CRLID_it); +} + +void +OCSP_CRLID_free(OCSP_CRLID *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_CRLID_it); +} ASN1_SEQUENCE(OCSP_SERVICELOC) = { ASN1_SIMPLE(OCSP_SERVICELOC, issuer, X509_NAME), ASN1_SEQUENCE_OF_OPT(OCSP_SERVICELOC, locator, ACCESS_DESCRIPTION) } ASN1_SEQUENCE_END(OCSP_SERVICELOC) -IMPLEMENT_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +OCSP_SERVICELOC * +d2i_OCSP_SERVICELOC(OCSP_SERVICELOC **a, const unsigned char **in, long len) +{ + return (OCSP_SERVICELOC *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &OCSP_SERVICELOC_it); +} + +int +i2d_OCSP_SERVICELOC(OCSP_SERVICELOC *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &OCSP_SERVICELOC_it); +} + +OCSP_SERVICELOC * +OCSP_SERVICELOC_new(void) +{ + return (OCSP_SERVICELOC *)ASN1_item_new(&OCSP_SERVICELOC_it); +} + +void +OCSP_SERVICELOC_free(OCSP_SERVICELOC *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &OCSP_SERVICELOC_it); +} diff --git a/lib/libcrypto/pkcs12/p12_asn.c b/lib/libcrypto/pkcs12/p12_asn.c index 5b3285ebe29..8e6ee29cb7b 100644 --- a/lib/libcrypto/pkcs12/p12_asn.c +++ b/lib/libcrypto/pkcs12/p12_asn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_asn.c,v 1.6 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: p12_asn.c,v 1.7 2015/02/09 16:04:46 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -69,7 +69,31 @@ ASN1_SEQUENCE(PKCS12) = { ASN1_OPT(PKCS12, mac, PKCS12_MAC_DATA) } ASN1_SEQUENCE_END(PKCS12) -IMPLEMENT_ASN1_FUNCTIONS(PKCS12) + +PKCS12 * +d2i_PKCS12(PKCS12 **a, const unsigned char **in, long len) +{ + return (PKCS12 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS12_it); +} + +int +i2d_PKCS12(PKCS12 *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_it); +} + +PKCS12 * +PKCS12_new(void) +{ + return (PKCS12 *)ASN1_item_new(&PKCS12_it); +} + +void +PKCS12_free(PKCS12 *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS12_it); +} ASN1_SEQUENCE(PKCS12_MAC_DATA) = { ASN1_SIMPLE(PKCS12_MAC_DATA, dinfo, X509_SIG), @@ -77,7 +101,31 @@ ASN1_SEQUENCE(PKCS12_MAC_DATA) = { ASN1_OPT(PKCS12_MAC_DATA, iter, ASN1_INTEGER) } ASN1_SEQUENCE_END(PKCS12_MAC_DATA) -IMPLEMENT_ASN1_FUNCTIONS(PKCS12_MAC_DATA) + +PKCS12_MAC_DATA * +d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, const unsigned char **in, long len) +{ + return (PKCS12_MAC_DATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS12_MAC_DATA_it); +} + +int +i2d_PKCS12_MAC_DATA(PKCS12_MAC_DATA *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_MAC_DATA_it); +} + +PKCS12_MAC_DATA * +PKCS12_MAC_DATA_new(void) +{ + return (PKCS12_MAC_DATA *)ASN1_item_new(&PKCS12_MAC_DATA_it); +} + +void +PKCS12_MAC_DATA_free(PKCS12_MAC_DATA *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS12_MAC_DATA_it); +} ASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0); @@ -96,7 +144,31 @@ ASN1_SEQUENCE(PKCS12_BAGS) = { ASN1_ADB_OBJECT(PKCS12_BAGS), } ASN1_SEQUENCE_END(PKCS12_BAGS) -IMPLEMENT_ASN1_FUNCTIONS(PKCS12_BAGS) + +PKCS12_BAGS * +d2i_PKCS12_BAGS(PKCS12_BAGS **a, const unsigned char **in, long len) +{ + return (PKCS12_BAGS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS12_BAGS_it); +} + +int +i2d_PKCS12_BAGS(PKCS12_BAGS *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_BAGS_it); +} + +PKCS12_BAGS * +PKCS12_BAGS_new(void) +{ + return (PKCS12_BAGS *)ASN1_item_new(&PKCS12_BAGS_it); +} + +void +PKCS12_BAGS_free(PKCS12_BAGS *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS12_BAGS_it); +} ASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_ANY, 0); @@ -122,7 +194,31 @@ ASN1_SEQUENCE(PKCS12_SAFEBAG) = { ASN1_SET_OF_OPT(PKCS12_SAFEBAG, attrib, X509_ATTRIBUTE) } ASN1_SEQUENCE_END(PKCS12_SAFEBAG) -IMPLEMENT_ASN1_FUNCTIONS(PKCS12_SAFEBAG) + +PKCS12_SAFEBAG * +d2i_PKCS12_SAFEBAG(PKCS12_SAFEBAG **a, const unsigned char **in, long len) +{ + return (PKCS12_SAFEBAG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS12_SAFEBAG_it); +} + +int +i2d_PKCS12_SAFEBAG(PKCS12_SAFEBAG *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_SAFEBAG_it); +} + +PKCS12_SAFEBAG * +PKCS12_SAFEBAG_new(void) +{ + return (PKCS12_SAFEBAG *)ASN1_item_new(&PKCS12_SAFEBAG_it); +} + +void +PKCS12_SAFEBAG_free(PKCS12_SAFEBAG *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS12_SAFEBAG_it); +} /* SEQUENCE OF SafeBag */ ASN1_ITEM_TEMPLATE(PKCS12_SAFEBAGS) = diff --git a/lib/libcrypto/pkcs7/pk7_asn1.c b/lib/libcrypto/pkcs7/pk7_asn1.c index 5191eb50765..2522a1ae6c7 100644 --- a/lib/libcrypto/pkcs7/pk7_asn1.c +++ b/lib/libcrypto/pkcs7/pk7_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_asn1.c,v 1.7 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pk7_asn1.c,v 1.8 2015/02/09 16:04:46 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -116,7 +116,31 @@ ASN1_NDEF_SEQUENCE_cb(PKCS7, pk7_cb) = { ASN1_ADB_OBJECT(PKCS7) }ASN1_NDEF_SEQUENCE_END_cb(PKCS7, PKCS7) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7) + +PKCS7 * +d2i_PKCS7(PKCS7 **a, const unsigned char **in, long len) +{ + return (PKCS7 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_it); +} + +int +i2d_PKCS7(PKCS7 *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_it); +} + +PKCS7 * +PKCS7_new(void) +{ + return (PKCS7 *)ASN1_item_new(&PKCS7_it); +} + +void +PKCS7_free(PKCS7 *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_it); +} IMPLEMENT_ASN1_NDEF_FUNCTION(PKCS7) IMPLEMENT_ASN1_DUP_FUNCTION(PKCS7) @@ -129,7 +153,31 @@ ASN1_NDEF_SEQUENCE(PKCS7_SIGNED) = { ASN1_SET_OF(PKCS7_SIGNED, signer_info, PKCS7_SIGNER_INFO) } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGNED) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNED) + +PKCS7_SIGNED * +d2i_PKCS7_SIGNED(PKCS7_SIGNED **a, const unsigned char **in, long len) +{ + return (PKCS7_SIGNED *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_SIGNED_it); +} + +int +i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNED_it); +} + +PKCS7_SIGNED * +PKCS7_SIGNED_new(void) +{ + return (PKCS7_SIGNED *)ASN1_item_new(&PKCS7_SIGNED_it); +} + +void +PKCS7_SIGNED_free(PKCS7_SIGNED *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNED_it); +} /* Minor tweak to operation: free up EVP_PKEY */ static int @@ -159,14 +207,62 @@ ASN1_SEQUENCE_cb(PKCS7_SIGNER_INFO, si_cb) = { ASN1_IMP_SET_OF_OPT(PKCS7_SIGNER_INFO, unauth_attr, X509_ATTRIBUTE, 1) } ASN1_SEQUENCE_END_cb(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) + +PKCS7_SIGNER_INFO * +d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **a, const unsigned char **in, long len) +{ + return (PKCS7_SIGNER_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_SIGNER_INFO_it); +} + +int +i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNER_INFO_it); +} + +PKCS7_SIGNER_INFO * +PKCS7_SIGNER_INFO_new(void) +{ + return (PKCS7_SIGNER_INFO *)ASN1_item_new(&PKCS7_SIGNER_INFO_it); +} + +void +PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNER_INFO_it); +} ASN1_SEQUENCE(PKCS7_ISSUER_AND_SERIAL) = { ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, issuer, X509_NAME), ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, serial, ASN1_INTEGER) } ASN1_SEQUENCE_END(PKCS7_ISSUER_AND_SERIAL) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +PKCS7_ISSUER_AND_SERIAL * +d2i_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL **a, const unsigned char **in, long len) +{ + return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_ISSUER_AND_SERIAL_it); +} + +int +i2d_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ISSUER_AND_SERIAL_it); +} + +PKCS7_ISSUER_AND_SERIAL * +PKCS7_ISSUER_AND_SERIAL_new(void) +{ + return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_new(&PKCS7_ISSUER_AND_SERIAL_it); +} + +void +PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ISSUER_AND_SERIAL_it); +} ASN1_NDEF_SEQUENCE(PKCS7_ENVELOPE) = { ASN1_SIMPLE(PKCS7_ENVELOPE, version, ASN1_INTEGER), @@ -174,7 +270,31 @@ ASN1_NDEF_SEQUENCE(PKCS7_ENVELOPE) = { ASN1_SIMPLE(PKCS7_ENVELOPE, enc_data, PKCS7_ENC_CONTENT) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENVELOPE) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE) + +PKCS7_ENVELOPE * +d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **a, const unsigned char **in, long len) +{ + return (PKCS7_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_ENVELOPE_it); +} + +int +i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENVELOPE_it); +} + +PKCS7_ENVELOPE * +PKCS7_ENVELOPE_new(void) +{ + return (PKCS7_ENVELOPE *)ASN1_item_new(&PKCS7_ENVELOPE_it); +} + +void +PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENVELOPE_it); +} /* Minor tweak to operation: free up X509 */ static int @@ -195,7 +315,31 @@ ASN1_SEQUENCE_cb(PKCS7_RECIP_INFO, ri_cb) = { ASN1_SIMPLE(PKCS7_RECIP_INFO, enc_key, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END_cb(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) + +PKCS7_RECIP_INFO * +d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **a, const unsigned char **in, long len) +{ + return (PKCS7_RECIP_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_RECIP_INFO_it); +} + +int +i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_RECIP_INFO_it); +} + +PKCS7_RECIP_INFO * +PKCS7_RECIP_INFO_new(void) +{ + return (PKCS7_RECIP_INFO *)ASN1_item_new(&PKCS7_RECIP_INFO_it); +} + +void +PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_RECIP_INFO_it); +} ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = { ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT), @@ -203,7 +347,31 @@ ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = { ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING_NDEF, 0) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENC_CONTENT) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) + +PKCS7_ENC_CONTENT * +d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **a, const unsigned char **in, long len) +{ + return (PKCS7_ENC_CONTENT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_ENC_CONTENT_it); +} + +int +i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENC_CONTENT_it); +} + +PKCS7_ENC_CONTENT * +PKCS7_ENC_CONTENT_new(void) +{ + return (PKCS7_ENC_CONTENT *)ASN1_item_new(&PKCS7_ENC_CONTENT_it); +} + +void +PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENC_CONTENT_it); +} ASN1_NDEF_SEQUENCE(PKCS7_SIGN_ENVELOPE) = { ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, version, ASN1_INTEGER), @@ -215,14 +383,62 @@ ASN1_NDEF_SEQUENCE(PKCS7_SIGN_ENVELOPE) = { ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, signer_info, PKCS7_SIGNER_INFO) } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGN_ENVELOPE) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) + +PKCS7_SIGN_ENVELOPE * +d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a, const unsigned char **in, long len) +{ + return (PKCS7_SIGN_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_SIGN_ENVELOPE_it); +} + +int +i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGN_ENVELOPE_it); +} + +PKCS7_SIGN_ENVELOPE * +PKCS7_SIGN_ENVELOPE_new(void) +{ + return (PKCS7_SIGN_ENVELOPE *)ASN1_item_new(&PKCS7_SIGN_ENVELOPE_it); +} + +void +PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGN_ENVELOPE_it); +} ASN1_NDEF_SEQUENCE(PKCS7_ENCRYPT) = { ASN1_SIMPLE(PKCS7_ENCRYPT, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS7_ENCRYPT, enc_data, PKCS7_ENC_CONTENT) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENCRYPT) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENCRYPT) + +PKCS7_ENCRYPT * +d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a, const unsigned char **in, long len) +{ + return (PKCS7_ENCRYPT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_ENCRYPT_it); +} + +int +i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENCRYPT_it); +} + +PKCS7_ENCRYPT * +PKCS7_ENCRYPT_new(void) +{ + return (PKCS7_ENCRYPT *)ASN1_item_new(&PKCS7_ENCRYPT_it); +} + +void +PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENCRYPT_it); +} ASN1_NDEF_SEQUENCE(PKCS7_DIGEST) = { ASN1_SIMPLE(PKCS7_DIGEST, version, ASN1_INTEGER), @@ -231,7 +447,31 @@ ASN1_NDEF_SEQUENCE(PKCS7_DIGEST) = { ASN1_SIMPLE(PKCS7_DIGEST, digest, ASN1_OCTET_STRING) } ASN1_NDEF_SEQUENCE_END(PKCS7_DIGEST) -IMPLEMENT_ASN1_FUNCTIONS(PKCS7_DIGEST) + +PKCS7_DIGEST * +d2i_PKCS7_DIGEST(PKCS7_DIGEST **a, const unsigned char **in, long len) +{ + return (PKCS7_DIGEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &PKCS7_DIGEST_it); +} + +int +i2d_PKCS7_DIGEST(PKCS7_DIGEST *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_DIGEST_it); +} + +PKCS7_DIGEST * +PKCS7_DIGEST_new(void) +{ + return (PKCS7_DIGEST *)ASN1_item_new(&PKCS7_DIGEST_it); +} + +void +PKCS7_DIGEST_free(PKCS7_DIGEST *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &PKCS7_DIGEST_it); +} /* Specials for authenticated attributes */ diff --git a/lib/libcrypto/rsa/rsa_asn1.c b/lib/libcrypto/rsa/rsa_asn1.c index 573b9f8b8d0..a75b80fa10b 100644 --- a/lib/libcrypto/rsa/rsa_asn1.c +++ b/lib/libcrypto/rsa/rsa_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_asn1.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: rsa_asn1.c,v 1.10 2015/02/09 16:04:46 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -105,7 +105,31 @@ ASN1_SEQUENCE(RSA_PSS_PARAMS) = { ASN1_EXP_OPT(RSA_PSS_PARAMS, trailerField, ASN1_INTEGER, 3) } ASN1_SEQUENCE_END(RSA_PSS_PARAMS) -IMPLEMENT_ASN1_FUNCTIONS(RSA_PSS_PARAMS) + +RSA_PSS_PARAMS * +d2i_RSA_PSS_PARAMS(RSA_PSS_PARAMS **a, const unsigned char **in, long len) +{ + return (RSA_PSS_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &RSA_PSS_PARAMS_it); +} + +int +i2d_RSA_PSS_PARAMS(RSA_PSS_PARAMS *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSA_PSS_PARAMS_it); +} + +RSA_PSS_PARAMS * +RSA_PSS_PARAMS_new(void) +{ + return (RSA_PSS_PARAMS *)ASN1_item_new(&RSA_PSS_PARAMS_it); +} + +void +RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &RSA_PSS_PARAMS_it); +} IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey) |