From 7a85d916bec92e23d2197680fd43767173f7ff4d Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Sat, 9 Feb 2013 23:43:52 +0100 Subject: [PATCH] fixed asn1 --- npa/src/npa.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/npa/src/npa.c b/npa/src/npa.c index 59f2709..ac84186 100644 --- a/npa/src/npa.c +++ b/npa/src/npa.c @@ -65,6 +65,17 @@ typedef struct npa_mse_cd_st { ASN1_AUXILIARY_DATA *auxiliary_data; CVC_CHAT *chat; } NPA_MSE_C; +/* Note that we can not use ASN1_AUXILIARY_DATA for the auxiliary_data element + * here. Due to limitations of OpenSSL it is not possible to *encode* an + * optional item template (such as auxiliary_data) in an other item template + * (such as ASN1_AUXILIARY_DATA). However, we can do + * + * NPA_MSE_C->auxiliary_data = d2i_ASN1_AUXILIARY_DATA(...) + * + * because they both use the same underlieing struct. + * + * See also openssl/crypto/asn1/tasn_dec.c:183 + */ ASN1_SEQUENCE(NPA_MSE_C) = { /* 0x80 * Cryptographic mechanism reference */ @@ -79,8 +90,8 @@ ASN1_SEQUENCE(NPA_MSE_C) = { * Ephemeral Public Key */ ASN1_IMP_OPT(NPA_MSE_C, eph_pub_key, ASN1_OCTET_STRING, 0x11), /* 0x67 - * Auxiliary authenticated data */ - ASN1_OPT(NPA_MSE_C, auxiliary_data, ASN1_AUXILIARY_DATA), + * Auxiliary authenticated data. See note above. */ + ASN1_APP_IMP_OPT(NPA_MSE_C, auxiliary_data, CVC_DISCRETIONARY_DATA_TEMPLATES, 7), /* Certificate Holder Authorization Template */ ASN1_OPT(NPA_MSE_C, chat, CVC_CHAT), } ASN1_SEQUENCE_END(NPA_MSE_C)