diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2015-07-24 15:47:35 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2015-07-24 15:47:35 +0000 |
commit | 4093155b358e584e6144c7d23a368462741049f8 (patch) | |
tree | bb24f319912d9652e647deb041e62620805f583e /lib | |
parent | d04d7cb73f33564a50d8c811653491179326b66f (diff) |
Expand ASN.1 template macros - no change in generated assembly.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/gost/gost_asn1.c | 166 |
1 files changed, 144 insertions, 22 deletions
diff --git a/lib/libcrypto/gost/gost_asn1.c b/lib/libcrypto/gost/gost_asn1.c index 5d7fb51177e..2652162777b 100644 --- a/lib/libcrypto/gost/gost_asn1.c +++ b/lib/libcrypto/gost/gost_asn1.c @@ -17,10 +17,32 @@ #include "gost_locl.h" #include "gost_asn1.h" -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) +static const ASN1_TEMPLATE GOST_KEY_TRANSPORT_seq_tt[] = { + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_TRANSPORT, key_info), + .field_name = "key_info", + .item = &GOST_KEY_INFO_it, + }, + { + .flags = ASN1_TFLG_IMPLICIT, + .tag = 0, + .offset = offsetof(GOST_KEY_TRANSPORT, key_agreement_info), + .field_name = "key_agreement_info", + .item = &GOST_KEY_AGREEMENT_INFO_it, + }, +}; + +const ASN1_ITEM GOST_KEY_TRANSPORT_it = { + .itype = ASN1_ITYPE_NDEF_SEQUENCE, + .utype = V_ASN1_SEQUENCE, + .templates = GOST_KEY_TRANSPORT_seq_tt, + .tcount = sizeof(GOST_KEY_TRANSPORT_seq_tt) / sizeof(ASN1_TEMPLATE), + .funcs = NULL, + .size = sizeof(GOST_KEY_TRANSPORT), + .sname = "GOST_KEY_TRANSPORT", +}; GOST_KEY_TRANSPORT * d2i_GOST_KEY_TRANSPORT(GOST_KEY_TRANSPORT **a, const unsigned char **in, long len) @@ -47,10 +69,32 @@ 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) +static const ASN1_TEMPLATE GOST_KEY_INFO_seq_tt[] = { + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_INFO, encrypted_key), + .field_name = "encrypted_key", + .item = &ASN1_OCTET_STRING_it, + }, + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_INFO, imit), + .field_name = "imit", + .item = &ASN1_OCTET_STRING_it, + }, +}; + +const ASN1_ITEM GOST_KEY_INFO_it = { + .itype = ASN1_ITYPE_NDEF_SEQUENCE, + .utype = V_ASN1_SEQUENCE, + .templates = GOST_KEY_INFO_seq_tt, + .tcount = sizeof(GOST_KEY_INFO_seq_tt) / sizeof(ASN1_TEMPLATE), + .funcs = NULL, + .size = sizeof(GOST_KEY_INFO), + .sname = "GOST_KEY_INFO", +}; GOST_KEY_INFO * d2i_GOST_KEY_INFO(GOST_KEY_INFO **a, const unsigned char **in, long len) @@ -77,11 +121,39 @@ 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) +static const ASN1_TEMPLATE GOST_KEY_AGREEMENT_INFO_seq_tt[] = { + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_AGREEMENT_INFO, cipher), + .field_name = "cipher", + .item = &ASN1_OBJECT_it, + }, + { + .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, + .tag = 0, + .offset = offsetof(GOST_KEY_AGREEMENT_INFO, ephem_key), + .field_name = "ephem_key", + .item = &X509_PUBKEY_it, + }, + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_AGREEMENT_INFO, eph_iv), + .field_name = "eph_iv", + .item = &ASN1_OCTET_STRING_it, + }, +}; + +const ASN1_ITEM GOST_KEY_AGREEMENT_INFO_it = { + .itype = ASN1_ITYPE_NDEF_SEQUENCE, + .utype = V_ASN1_SEQUENCE, + .templates = GOST_KEY_AGREEMENT_INFO_seq_tt, + .tcount = sizeof(GOST_KEY_AGREEMENT_INFO_seq_tt) / sizeof(ASN1_TEMPLATE), + .funcs = NULL, + .size = sizeof(GOST_KEY_AGREEMENT_INFO), + .sname = "GOST_KEY_AGREEMENT_INFO", +}; GOST_KEY_AGREEMENT_INFO * d2i_GOST_KEY_AGREEMENT_INFO(GOST_KEY_AGREEMENT_INFO **a, const unsigned char **in, long len) @@ -109,11 +181,39 @@ GOST_KEY_AGREEMENT_INFO_free(GOST_KEY_AGREEMENT_INFO *a) } -ASN1_NDEF_SEQUENCE(GOST_KEY_PARAMS) = { - ASN1_SIMPLE(GOST_KEY_PARAMS, key_params, ASN1_OBJECT), - 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) +static const ASN1_TEMPLATE GOST_KEY_PARAMS_seq_tt[] = { + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_PARAMS, key_params), + .field_name = "key_params", + .item = &ASN1_OBJECT_it, + }, + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_KEY_PARAMS, hash_params), + .field_name = "hash_params", + .item = &ASN1_OBJECT_it, + }, + { + .flags = ASN1_TFLG_OPTIONAL, + .tag = 0, + .offset = offsetof(GOST_KEY_PARAMS, cipher_params), + .field_name = "cipher_params", + .item = &ASN1_OBJECT_it, + }, +}; + +const ASN1_ITEM GOST_KEY_PARAMS_it = { + .itype = ASN1_ITYPE_NDEF_SEQUENCE, + .utype = V_ASN1_SEQUENCE, + .templates = GOST_KEY_PARAMS_seq_tt, + .tcount = sizeof(GOST_KEY_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE), + .funcs = NULL, + .size = sizeof(GOST_KEY_PARAMS), + .sname = "GOST_KEY_PARAMS", +}; GOST_KEY_PARAMS * d2i_GOST_KEY_PARAMS(GOST_KEY_PARAMS **a, const unsigned char **in, long len) @@ -140,10 +240,32 @@ 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) +static const ASN1_TEMPLATE GOST_CIPHER_PARAMS_seq_tt[] = { + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_CIPHER_PARAMS, iv), + .field_name = "iv", + .item = &ASN1_OCTET_STRING_it, + }, + { + .flags = 0, + .tag = 0, + .offset = offsetof(GOST_CIPHER_PARAMS, enc_param_set), + .field_name = "enc_param_set", + .item = &ASN1_OBJECT_it, + }, +}; + +const ASN1_ITEM GOST_CIPHER_PARAMS_it = { + .itype = ASN1_ITYPE_NDEF_SEQUENCE, + .utype = V_ASN1_SEQUENCE, + .templates = GOST_CIPHER_PARAMS_seq_tt, + .tcount = sizeof(GOST_CIPHER_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE), + .funcs = NULL, + .size = sizeof(GOST_CIPHER_PARAMS), + .sname = "GOST_CIPHER_PARAMS", +}; GOST_CIPHER_PARAMS * d2i_GOST_CIPHER_PARAMS(GOST_CIPHER_PARAMS **a, const unsigned char **in, long len) |