diff options
| author | jsing <> | 2019-08-11 10:15:30 +0000 |
|---|---|---|
| committer | jsing <> | 2019-08-11 10:15:30 +0000 |
| commit | 60fde5b08bfa39912d4423961b374ab94e5c325e (patch) | |
| tree | a038b26f2da29ed31383201d4852270882e9961e /src | |
| parent | 162996edf50591f53ad0e453ec26c6a86c385659 (diff) | |
| download | openbsd-60fde5b08bfa39912d4423961b374ab94e5c325e.tar.gz openbsd-60fde5b08bfa39912d4423961b374ab94e5c325e.tar.bz2 openbsd-60fde5b08bfa39912d4423961b374ab94e5c325e.zip | |
Expand ASN.1 macros.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/cms/cms.h | 23 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_asn1.c | 1610 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_ess.c | 36 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_io.c | 45 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_lcl.h | 55 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_lib.c | 36 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_pwri.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_sd.c | 6 |
8 files changed, 1544 insertions, 273 deletions
diff --git a/src/lib/libcrypto/cms/cms.h b/src/lib/libcrypto/cms/cms.h index d639667777..3c92be34f7 100644 --- a/src/lib/libcrypto/cms/cms.h +++ b/src/lib/libcrypto/cms/cms.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms.h,v 1.14 2019/08/11 08:15:27 jsing Exp $ */ | 1 | /* $OpenBSD: cms.h,v 1.15 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -78,9 +78,17 @@ DECLARE_STACK_OF(CMS_SignerInfo) | |||
| 78 | DECLARE_STACK_OF(CMS_RecipientEncryptedKey) | 78 | DECLARE_STACK_OF(CMS_RecipientEncryptedKey) |
| 79 | DECLARE_STACK_OF(CMS_RecipientInfo) | 79 | DECLARE_STACK_OF(CMS_RecipientInfo) |
| 80 | DECLARE_STACK_OF(CMS_RevocationInfoChoice) | 80 | DECLARE_STACK_OF(CMS_RevocationInfoChoice) |
| 81 | DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) | 81 | CMS_ContentInfo *CMS_ContentInfo_new(void); |
| 82 | DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest) | 82 | void CMS_ContentInfo_free(CMS_ContentInfo *a); |
| 83 | DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo) | 83 | CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a, const unsigned char **in, long len); |
| 84 | int i2d_CMS_ContentInfo(CMS_ContentInfo *a, unsigned char **out); | ||
| 85 | extern const ASN1_ITEM CMS_ContentInfo_it; | ||
| 86 | CMS_ReceiptRequest *CMS_ReceiptRequest_new(void); | ||
| 87 | void CMS_ReceiptRequest_free(CMS_ReceiptRequest *a); | ||
| 88 | CMS_ReceiptRequest *d2i_CMS_ReceiptRequest(CMS_ReceiptRequest **a, const unsigned char **in, long len); | ||
| 89 | int i2d_CMS_ReceiptRequest(CMS_ReceiptRequest *a, unsigned char **out); | ||
| 90 | extern const ASN1_ITEM CMS_ReceiptRequest_it; | ||
| 91 | int CMS_ContentInfo_print_ctx(BIO *out, CMS_ContentInfo *x, int indent, const ASN1_PCTX *pctx); | ||
| 84 | 92 | ||
| 85 | #define CMS_SIGNERINFO_ISSUER_SERIAL 0 | 93 | #define CMS_SIGNERINFO_ISSUER_SERIAL 0 |
| 86 | #define CMS_SIGNERINFO_KEYIDENTIFIER 1 | 94 | #define CMS_SIGNERINFO_KEYIDENTIFIER 1 |
| @@ -128,7 +136,12 @@ int CMS_is_detached(CMS_ContentInfo *cms); | |||
| 128 | int CMS_set_detached(CMS_ContentInfo *cms, int detached); | 136 | int CMS_set_detached(CMS_ContentInfo *cms, int detached); |
| 129 | 137 | ||
| 130 | #ifdef HEADER_PEM_H | 138 | #ifdef HEADER_PEM_H |
| 131 | DECLARE_PEM_rw_const(CMS, CMS_ContentInfo) | 139 | CMS_ContentInfo *PEM_read_bio_CMS(BIO *bp, CMS_ContentInfo **x, |
| 140 | pem_password_cb *cb, void *u); | ||
| 141 | CMS_ContentInfo *PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, | ||
| 142 | pem_password_cb *cb, void *u); | ||
| 143 | int PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x); | ||
| 144 | int PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x); | ||
| 132 | #endif | 145 | #endif |
| 133 | int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); | 146 | int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); |
| 134 | CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); | 147 | CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); |
diff --git a/src/lib/libcrypto/cms/cms_asn1.c b/src/lib/libcrypto/cms/cms_asn1.c index 43570930a0..d492591d44 100644 --- a/src/lib/libcrypto/cms/cms_asn1.c +++ b/src/lib/libcrypto/cms/cms_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_asn1.c,v 1.14 2019/08/10 18:15:52 jsing Exp $ */ | 1 | /* $OpenBSD: cms_asn1.c,v 1.15 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -59,33 +59,161 @@ | |||
| 59 | #include "cms_lcl.h" | 59 | #include "cms_lcl.h" |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = { | 62 | static const ASN1_TEMPLATE CMS_IssuerAndSerialNumber_seq_tt[] = { |
| 63 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, issuer, X509_NAME), | 63 | { |
| 64 | ASN1_SIMPLE(CMS_IssuerAndSerialNumber, serialNumber, ASN1_INTEGER) | 64 | .flags = 0, |
| 65 | } ASN1_SEQUENCE_END(CMS_IssuerAndSerialNumber) | 65 | .tag = 0, |
| 66 | .offset = offsetof(CMS_IssuerAndSerialNumber, issuer), | ||
| 67 | .field_name = "issuer", | ||
| 68 | .item = &X509_NAME_it, | ||
| 69 | }, | ||
| 70 | { | ||
| 71 | .flags = 0, | ||
| 72 | .tag = 0, | ||
| 73 | .offset = offsetof(CMS_IssuerAndSerialNumber, serialNumber), | ||
| 74 | .field_name = "serialNumber", | ||
| 75 | .item = &ASN1_INTEGER_it, | ||
| 76 | }, | ||
| 77 | }; | ||
| 66 | 78 | ||
| 67 | ASN1_SEQUENCE(CMS_OtherCertificateFormat) = { | 79 | const ASN1_ITEM CMS_IssuerAndSerialNumber_it = { |
| 68 | ASN1_SIMPLE(CMS_OtherCertificateFormat, otherCertFormat, ASN1_OBJECT), | 80 | .itype = ASN1_ITYPE_SEQUENCE, |
| 69 | ASN1_OPT(CMS_OtherCertificateFormat, otherCert, ASN1_ANY) | 81 | .utype = V_ASN1_SEQUENCE, |
| 70 | } static_ASN1_SEQUENCE_END(CMS_OtherCertificateFormat) | 82 | .templates = CMS_IssuerAndSerialNumber_seq_tt, |
| 83 | .tcount = sizeof(CMS_IssuerAndSerialNumber_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 84 | .funcs = NULL, | ||
| 85 | .size = sizeof(CMS_IssuerAndSerialNumber), | ||
| 86 | .sname = "CMS_IssuerAndSerialNumber", | ||
| 87 | }; | ||
| 71 | 88 | ||
| 72 | ASN1_CHOICE(CMS_CertificateChoices) = { | 89 | static const ASN1_TEMPLATE CMS_OtherCertificateFormat_seq_tt[] = { |
| 73 | ASN1_SIMPLE(CMS_CertificateChoices, d.certificate, X509), | 90 | { |
| 74 | ASN1_IMP(CMS_CertificateChoices, d.extendedCertificate, ASN1_SEQUENCE, 0), | 91 | .flags = 0, |
| 75 | ASN1_IMP(CMS_CertificateChoices, d.v1AttrCert, ASN1_SEQUENCE, 1), | 92 | .tag = 0, |
| 76 | ASN1_IMP(CMS_CertificateChoices, d.v2AttrCert, ASN1_SEQUENCE, 2), | 93 | .offset = offsetof(CMS_OtherCertificateFormat, otherCertFormat), |
| 77 | ASN1_IMP(CMS_CertificateChoices, d.other, CMS_OtherCertificateFormat, 3) | 94 | .field_name = "otherCertFormat", |
| 78 | } ASN1_CHOICE_END(CMS_CertificateChoices) | 95 | .item = &ASN1_OBJECT_it, |
| 96 | }, | ||
| 97 | { | ||
| 98 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 99 | .tag = 0, | ||
| 100 | .offset = offsetof(CMS_OtherCertificateFormat, otherCert), | ||
| 101 | .field_name = "otherCert", | ||
| 102 | .item = &ASN1_ANY_it, | ||
| 103 | }, | ||
| 104 | }; | ||
| 79 | 105 | ||
| 80 | ASN1_CHOICE(CMS_SignerIdentifier) = { | 106 | static const ASN1_ITEM CMS_OtherCertificateFormat_it = { |
| 81 | ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 107 | .itype = ASN1_ITYPE_SEQUENCE, |
| 82 | ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0) | 108 | .utype = V_ASN1_SEQUENCE, |
| 83 | } static_ASN1_CHOICE_END(CMS_SignerIdentifier) | 109 | .templates = CMS_OtherCertificateFormat_seq_tt, |
| 110 | .tcount = sizeof(CMS_OtherCertificateFormat_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 111 | .funcs = NULL, | ||
| 112 | .size = sizeof(CMS_OtherCertificateFormat), | ||
| 113 | .sname = "CMS_OtherCertificateFormat", | ||
| 114 | }; | ||
| 84 | 115 | ||
| 85 | ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = { | 116 | static const ASN1_TEMPLATE CMS_CertificateChoices_ch_tt[] = { |
| 86 | ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT), | 117 | { |
| 87 | ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRING_NDEF, 0) | 118 | .flags = 0, |
| 88 | } static_ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo) | 119 | .tag = 0, |
| 120 | .offset = offsetof(CMS_CertificateChoices, d.certificate), | ||
| 121 | .field_name = "d.certificate", | ||
| 122 | .item = &X509_it, | ||
| 123 | }, | ||
| 124 | { | ||
| 125 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 126 | .tag = 0, | ||
| 127 | .offset = offsetof(CMS_CertificateChoices, d.extendedCertificate), | ||
| 128 | .field_name = "d.extendedCertificate", | ||
| 129 | .item = &ASN1_SEQUENCE_it, | ||
| 130 | }, | ||
| 131 | { | ||
| 132 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 133 | .tag = 1, | ||
| 134 | .offset = offsetof(CMS_CertificateChoices, d.v1AttrCert), | ||
| 135 | .field_name = "d.v1AttrCert", | ||
| 136 | .item = &ASN1_SEQUENCE_it, | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 140 | .tag = 2, | ||
| 141 | .offset = offsetof(CMS_CertificateChoices, d.v2AttrCert), | ||
| 142 | .field_name = "d.v2AttrCert", | ||
| 143 | .item = &ASN1_SEQUENCE_it, | ||
| 144 | }, | ||
| 145 | { | ||
| 146 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 147 | .tag = 3, | ||
| 148 | .offset = offsetof(CMS_CertificateChoices, d.other), | ||
| 149 | .field_name = "d.other", | ||
| 150 | .item = &CMS_OtherCertificateFormat_it, | ||
| 151 | }, | ||
| 152 | }; | ||
| 153 | |||
| 154 | const ASN1_ITEM CMS_CertificateChoices_it = { | ||
| 155 | .itype = ASN1_ITYPE_CHOICE, | ||
| 156 | .utype = offsetof(CMS_CertificateChoices, type), | ||
| 157 | .templates = CMS_CertificateChoices_ch_tt, | ||
| 158 | .tcount = sizeof(CMS_CertificateChoices_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 159 | .funcs = NULL, | ||
| 160 | .size = sizeof(CMS_CertificateChoices), | ||
| 161 | .sname = "CMS_CertificateChoices", | ||
| 162 | }; | ||
| 163 | |||
| 164 | static const ASN1_TEMPLATE CMS_SignerIdentifier_ch_tt[] = { | ||
| 165 | { | ||
| 166 | .flags = 0, | ||
| 167 | .tag = 0, | ||
| 168 | .offset = offsetof(CMS_SignerIdentifier, d.issuerAndSerialNumber), | ||
| 169 | .field_name = "d.issuerAndSerialNumber", | ||
| 170 | .item = &CMS_IssuerAndSerialNumber_it, | ||
| 171 | }, | ||
| 172 | { | ||
| 173 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 174 | .tag = 0, | ||
| 175 | .offset = offsetof(CMS_SignerIdentifier, d.subjectKeyIdentifier), | ||
| 176 | .field_name = "d.subjectKeyIdentifier", | ||
| 177 | .item = &ASN1_OCTET_STRING_it, | ||
| 178 | }, | ||
| 179 | }; | ||
| 180 | |||
| 181 | static const ASN1_ITEM CMS_SignerIdentifier_it = { | ||
| 182 | .itype = ASN1_ITYPE_CHOICE, | ||
| 183 | .utype = offsetof(CMS_SignerIdentifier, type), | ||
| 184 | .templates = CMS_SignerIdentifier_ch_tt, | ||
| 185 | .tcount = sizeof(CMS_SignerIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 186 | .funcs = NULL, | ||
| 187 | .size = sizeof(CMS_SignerIdentifier), | ||
| 188 | .sname = "CMS_SignerIdentifier", | ||
| 189 | }; | ||
| 190 | |||
| 191 | static const ASN1_TEMPLATE CMS_EncapsulatedContentInfo_seq_tt[] = { | ||
| 192 | { | ||
| 193 | .flags = 0, | ||
| 194 | .tag = 0, | ||
| 195 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContentType), | ||
| 196 | .field_name = "eContentType", | ||
| 197 | .item = &ASN1_OBJECT_it, | ||
| 198 | }, | ||
| 199 | { | ||
| 200 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF, | ||
| 201 | .tag = 0, | ||
| 202 | .offset = offsetof(CMS_EncapsulatedContentInfo, eContent), | ||
| 203 | .field_name = "eContent", | ||
| 204 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
| 205 | }, | ||
| 206 | }; | ||
| 207 | |||
| 208 | static const ASN1_ITEM CMS_EncapsulatedContentInfo_it = { | ||
| 209 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 210 | .utype = V_ASN1_SEQUENCE, | ||
| 211 | .templates = CMS_EncapsulatedContentInfo_seq_tt, | ||
| 212 | .tcount = sizeof(CMS_EncapsulatedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 213 | .funcs = NULL, | ||
| 214 | .size = sizeof(CMS_EncapsulatedContentInfo), | ||
| 215 | .sname = "CMS_EncapsulatedContentInfo", | ||
| 216 | }; | ||
| 89 | 217 | ||
| 90 | /* Minor tweak to operation: free up signer key, cert */ | 218 | /* Minor tweak to operation: free up signer key, cert */ |
| 91 | static int | 219 | static int |
| @@ -100,68 +228,374 @@ cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 100 | return 1; | 228 | return 1; |
| 101 | } | 229 | } |
| 102 | 230 | ||
| 103 | ASN1_SEQUENCE_cb(CMS_SignerInfo, cms_si_cb) = { | 231 | static const ASN1_AUX CMS_SignerInfo_aux = { |
| 104 | ASN1_EMBED(CMS_SignerInfo, version, INT32), | 232 | .app_data = NULL, |
| 105 | ASN1_SIMPLE(CMS_SignerInfo, sid, CMS_SignerIdentifier), | 233 | .flags = 0, |
| 106 | ASN1_SIMPLE(CMS_SignerInfo, digestAlgorithm, X509_ALGOR), | 234 | .ref_offset = 0, |
| 107 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, signedAttrs, X509_ATTRIBUTE, 0), | 235 | .ref_lock = 0, |
| 108 | ASN1_SIMPLE(CMS_SignerInfo, signatureAlgorithm, X509_ALGOR), | 236 | .asn1_cb = cms_si_cb, |
| 109 | ASN1_SIMPLE(CMS_SignerInfo, signature, ASN1_OCTET_STRING), | 237 | .enc_offset = 0, |
| 110 | ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, unsignedAttrs, X509_ATTRIBUTE, 1) | 238 | }; |
| 111 | } ASN1_SEQUENCE_END_cb(CMS_SignerInfo, CMS_SignerInfo) | 239 | static const ASN1_TEMPLATE CMS_SignerInfo_seq_tt[] = { |
| 112 | 240 | { | |
| 113 | ASN1_SEQUENCE(CMS_OtherRevocationInfoFormat) = { | 241 | .flags = 0, |
| 114 | ASN1_SIMPLE(CMS_OtherRevocationInfoFormat, otherRevInfoFormat, ASN1_OBJECT), | 242 | .tag = 0, |
| 115 | ASN1_OPT(CMS_OtherRevocationInfoFormat, otherRevInfo, ASN1_ANY) | 243 | .offset = offsetof(CMS_SignerInfo, version), |
| 116 | } static_ASN1_SEQUENCE_END(CMS_OtherRevocationInfoFormat) | 244 | .field_name = "version", |
| 117 | 245 | .item = &INT32_it, | |
| 118 | ASN1_CHOICE(CMS_RevocationInfoChoice) = { | 246 | }, |
| 119 | ASN1_SIMPLE(CMS_RevocationInfoChoice, d.crl, X509_CRL), | 247 | { |
| 120 | ASN1_IMP(CMS_RevocationInfoChoice, d.other, CMS_OtherRevocationInfoFormat, 1) | 248 | .flags = 0, |
| 121 | } ASN1_CHOICE_END(CMS_RevocationInfoChoice) | 249 | .tag = 0, |
| 122 | 250 | .offset = offsetof(CMS_SignerInfo, sid), | |
| 123 | ASN1_NDEF_SEQUENCE(CMS_SignedData) = { | 251 | .field_name = "sid", |
| 124 | ASN1_EMBED(CMS_SignedData, version, INT32), | 252 | .item = &CMS_SignerIdentifier_it, |
| 125 | ASN1_SET_OF(CMS_SignedData, digestAlgorithms, X509_ALGOR), | 253 | }, |
| 126 | ASN1_SIMPLE(CMS_SignedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 254 | { |
| 127 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, certificates, CMS_CertificateChoices, 0), | 255 | .flags = 0, |
| 128 | ASN1_IMP_SET_OF_OPT(CMS_SignedData, crls, CMS_RevocationInfoChoice, 1), | 256 | .tag = 0, |
| 129 | ASN1_SET_OF(CMS_SignedData, signerInfos, CMS_SignerInfo) | 257 | .offset = offsetof(CMS_SignerInfo, digestAlgorithm), |
| 130 | } ASN1_NDEF_SEQUENCE_END(CMS_SignedData) | 258 | .field_name = "digestAlgorithm", |
| 131 | 259 | .item = &X509_ALGOR_it, | |
| 132 | ASN1_SEQUENCE(CMS_OriginatorInfo) = { | 260 | }, |
| 133 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, certificates, CMS_CertificateChoices, 0), | 261 | { |
| 134 | ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, crls, CMS_RevocationInfoChoice, 1) | 262 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
| 135 | } static_ASN1_SEQUENCE_END(CMS_OriginatorInfo) | 263 | .tag = 0, |
| 136 | 264 | .offset = offsetof(CMS_SignerInfo, signedAttrs), | |
| 137 | ASN1_NDEF_SEQUENCE(CMS_EncryptedContentInfo) = { | 265 | .field_name = "signedAttrs", |
| 138 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentType, ASN1_OBJECT), | 266 | .item = &X509_ATTRIBUTE_it, |
| 139 | ASN1_SIMPLE(CMS_EncryptedContentInfo, contentEncryptionAlgorithm, X509_ALGOR), | 267 | }, |
| 140 | ASN1_IMP_OPT(CMS_EncryptedContentInfo, encryptedContent, ASN1_OCTET_STRING_NDEF, 0) | 268 | { |
| 141 | } static_ASN1_NDEF_SEQUENCE_END(CMS_EncryptedContentInfo) | 269 | .flags = 0, |
| 142 | 270 | .tag = 0, | |
| 143 | ASN1_SEQUENCE(CMS_KeyTransRecipientInfo) = { | 271 | .offset = offsetof(CMS_SignerInfo, signatureAlgorithm), |
| 144 | ASN1_EMBED(CMS_KeyTransRecipientInfo, version, INT32), | 272 | .field_name = "signatureAlgorithm", |
| 145 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, rid, CMS_SignerIdentifier), | 273 | .item = &X509_ALGOR_it, |
| 146 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 274 | }, |
| 147 | ASN1_SIMPLE(CMS_KeyTransRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 275 | { |
| 148 | } ASN1_SEQUENCE_END(CMS_KeyTransRecipientInfo) | 276 | .flags = 0, |
| 149 | 277 | .tag = 0, | |
| 150 | ASN1_SEQUENCE(CMS_OtherKeyAttribute) = { | 278 | .offset = offsetof(CMS_SignerInfo, signature), |
| 151 | ASN1_SIMPLE(CMS_OtherKeyAttribute, keyAttrId, ASN1_OBJECT), | 279 | .field_name = "signature", |
| 152 | ASN1_OPT(CMS_OtherKeyAttribute, keyAttr, ASN1_ANY) | 280 | .item = &ASN1_OCTET_STRING_it, |
| 153 | } ASN1_SEQUENCE_END(CMS_OtherKeyAttribute) | 281 | }, |
| 154 | 282 | { | |
| 155 | ASN1_SEQUENCE(CMS_RecipientKeyIdentifier) = { | 283 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, |
| 156 | ASN1_SIMPLE(CMS_RecipientKeyIdentifier, subjectKeyIdentifier, ASN1_OCTET_STRING), | 284 | .tag = 1, |
| 157 | ASN1_OPT(CMS_RecipientKeyIdentifier, date, ASN1_GENERALIZEDTIME), | 285 | .offset = offsetof(CMS_SignerInfo, unsignedAttrs), |
| 158 | ASN1_OPT(CMS_RecipientKeyIdentifier, other, CMS_OtherKeyAttribute) | 286 | .field_name = "unsignedAttrs", |
| 159 | } ASN1_SEQUENCE_END(CMS_RecipientKeyIdentifier) | 287 | .item = &X509_ATTRIBUTE_it, |
| 160 | 288 | }, | |
| 161 | ASN1_CHOICE(CMS_KeyAgreeRecipientIdentifier) = { | 289 | }; |
| 162 | ASN1_SIMPLE(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 290 | |
| 163 | ASN1_IMP(CMS_KeyAgreeRecipientIdentifier, d.rKeyId, CMS_RecipientKeyIdentifier, 0) | 291 | const ASN1_ITEM CMS_SignerInfo_it = { |
| 164 | } static_ASN1_CHOICE_END(CMS_KeyAgreeRecipientIdentifier) | 292 | .itype = ASN1_ITYPE_SEQUENCE, |
| 293 | .utype = V_ASN1_SEQUENCE, | ||
| 294 | .templates = CMS_SignerInfo_seq_tt, | ||
| 295 | .tcount = sizeof(CMS_SignerInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 296 | .funcs = &CMS_SignerInfo_aux, | ||
| 297 | .size = sizeof(CMS_SignerInfo), | ||
| 298 | .sname = "CMS_SignerInfo", | ||
| 299 | }; | ||
| 300 | |||
| 301 | static const ASN1_TEMPLATE CMS_OtherRevocationInfoFormat_seq_tt[] = { | ||
| 302 | { | ||
| 303 | .flags = 0, | ||
| 304 | .tag = 0, | ||
| 305 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfoFormat), | ||
| 306 | .field_name = "otherRevInfoFormat", | ||
| 307 | .item = &ASN1_OBJECT_it, | ||
| 308 | }, | ||
| 309 | { | ||
| 310 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 311 | .tag = 0, | ||
| 312 | .offset = offsetof(CMS_OtherRevocationInfoFormat, otherRevInfo), | ||
| 313 | .field_name = "otherRevInfo", | ||
| 314 | .item = &ASN1_ANY_it, | ||
| 315 | }, | ||
| 316 | }; | ||
| 317 | |||
| 318 | static const ASN1_ITEM CMS_OtherRevocationInfoFormat_it = { | ||
| 319 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 320 | .utype = V_ASN1_SEQUENCE, | ||
| 321 | .templates = CMS_OtherRevocationInfoFormat_seq_tt, | ||
| 322 | .tcount = sizeof(CMS_OtherRevocationInfoFormat_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 323 | .funcs = NULL, | ||
| 324 | .size = sizeof(CMS_OtherRevocationInfoFormat), | ||
| 325 | .sname = "CMS_OtherRevocationInfoFormat", | ||
| 326 | }; | ||
| 327 | |||
| 328 | static const ASN1_TEMPLATE CMS_RevocationInfoChoice_ch_tt[] = { | ||
| 329 | { | ||
| 330 | .flags = 0, | ||
| 331 | .tag = 0, | ||
| 332 | .offset = offsetof(CMS_RevocationInfoChoice, d.crl), | ||
| 333 | .field_name = "d.crl", | ||
| 334 | .item = &X509_CRL_it, | ||
| 335 | }, | ||
| 336 | { | ||
| 337 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 338 | .tag = 1, | ||
| 339 | .offset = offsetof(CMS_RevocationInfoChoice, d.other), | ||
| 340 | .field_name = "d.other", | ||
| 341 | .item = &CMS_OtherRevocationInfoFormat_it, | ||
| 342 | }, | ||
| 343 | }; | ||
| 344 | |||
| 345 | const ASN1_ITEM CMS_RevocationInfoChoice_it = { | ||
| 346 | .itype = ASN1_ITYPE_CHOICE, | ||
| 347 | .utype = offsetof(CMS_RevocationInfoChoice, type), | ||
| 348 | .templates = CMS_RevocationInfoChoice_ch_tt, | ||
| 349 | .tcount = sizeof(CMS_RevocationInfoChoice_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 350 | .funcs = NULL, | ||
| 351 | .size = sizeof(CMS_RevocationInfoChoice), | ||
| 352 | .sname = "CMS_RevocationInfoChoice", | ||
| 353 | }; | ||
| 354 | |||
| 355 | static const ASN1_TEMPLATE CMS_SignedData_seq_tt[] = { | ||
| 356 | { | ||
| 357 | .flags = 0, | ||
| 358 | .tag = 0, | ||
| 359 | .offset = offsetof(CMS_SignedData, version), | ||
| 360 | .field_name = "version", | ||
| 361 | .item = &INT32_it, | ||
| 362 | }, | ||
| 363 | { | ||
| 364 | .flags = ASN1_TFLG_SET_OF, | ||
| 365 | .tag = 0, | ||
| 366 | .offset = offsetof(CMS_SignedData, digestAlgorithms), | ||
| 367 | .field_name = "digestAlgorithms", | ||
| 368 | .item = &X509_ALGOR_it, | ||
| 369 | }, | ||
| 370 | { | ||
| 371 | .flags = 0, | ||
| 372 | .tag = 0, | ||
| 373 | .offset = offsetof(CMS_SignedData, encapContentInfo), | ||
| 374 | .field_name = "encapContentInfo", | ||
| 375 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 376 | }, | ||
| 377 | { | ||
| 378 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 379 | .tag = 0, | ||
| 380 | .offset = offsetof(CMS_SignedData, certificates), | ||
| 381 | .field_name = "certificates", | ||
| 382 | .item = &CMS_CertificateChoices_it, | ||
| 383 | }, | ||
| 384 | { | ||
| 385 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 386 | .tag = 1, | ||
| 387 | .offset = offsetof(CMS_SignedData, crls), | ||
| 388 | .field_name = "crls", | ||
| 389 | .item = &CMS_RevocationInfoChoice_it, | ||
| 390 | }, | ||
| 391 | { | ||
| 392 | .flags = ASN1_TFLG_SET_OF, | ||
| 393 | .tag = 0, | ||
| 394 | .offset = offsetof(CMS_SignedData, signerInfos), | ||
| 395 | .field_name = "signerInfos", | ||
| 396 | .item = &CMS_SignerInfo_it, | ||
| 397 | }, | ||
| 398 | }; | ||
| 399 | |||
| 400 | const ASN1_ITEM CMS_SignedData_it = { | ||
| 401 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 402 | .utype = V_ASN1_SEQUENCE, | ||
| 403 | .templates = CMS_SignedData_seq_tt, | ||
| 404 | .tcount = sizeof(CMS_SignedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 405 | .funcs = NULL, | ||
| 406 | .size = sizeof(CMS_SignedData), | ||
| 407 | .sname = "CMS_SignedData", | ||
| 408 | }; | ||
| 409 | |||
| 410 | static const ASN1_TEMPLATE CMS_OriginatorInfo_seq_tt[] = { | ||
| 411 | { | ||
| 412 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 413 | .tag = 0, | ||
| 414 | .offset = offsetof(CMS_OriginatorInfo, certificates), | ||
| 415 | .field_name = "certificates", | ||
| 416 | .item = &CMS_CertificateChoices_it, | ||
| 417 | }, | ||
| 418 | { | ||
| 419 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 420 | .tag = 1, | ||
| 421 | .offset = offsetof(CMS_OriginatorInfo, crls), | ||
| 422 | .field_name = "crls", | ||
| 423 | .item = &CMS_RevocationInfoChoice_it, | ||
| 424 | }, | ||
| 425 | }; | ||
| 426 | |||
| 427 | static const ASN1_ITEM CMS_OriginatorInfo_it = { | ||
| 428 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 429 | .utype = V_ASN1_SEQUENCE, | ||
| 430 | .templates = CMS_OriginatorInfo_seq_tt, | ||
| 431 | .tcount = sizeof(CMS_OriginatorInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 432 | .funcs = NULL, | ||
| 433 | .size = sizeof(CMS_OriginatorInfo), | ||
| 434 | .sname = "CMS_OriginatorInfo", | ||
| 435 | }; | ||
| 436 | |||
| 437 | static const ASN1_TEMPLATE CMS_EncryptedContentInfo_seq_tt[] = { | ||
| 438 | { | ||
| 439 | .flags = 0, | ||
| 440 | .tag = 0, | ||
| 441 | .offset = offsetof(CMS_EncryptedContentInfo, contentType), | ||
| 442 | .field_name = "contentType", | ||
| 443 | .item = &ASN1_OBJECT_it, | ||
| 444 | }, | ||
| 445 | { | ||
| 446 | .flags = 0, | ||
| 447 | .tag = 0, | ||
| 448 | .offset = offsetof(CMS_EncryptedContentInfo, contentEncryptionAlgorithm), | ||
| 449 | .field_name = "contentEncryptionAlgorithm", | ||
| 450 | .item = &X509_ALGOR_it, | ||
| 451 | }, | ||
| 452 | { | ||
| 453 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 454 | .tag = 0, | ||
| 455 | .offset = offsetof(CMS_EncryptedContentInfo, encryptedContent), | ||
| 456 | .field_name = "encryptedContent", | ||
| 457 | .item = &ASN1_OCTET_STRING_NDEF_it, | ||
| 458 | }, | ||
| 459 | }; | ||
| 460 | |||
| 461 | static const ASN1_ITEM CMS_EncryptedContentInfo_it = { | ||
| 462 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 463 | .utype = V_ASN1_SEQUENCE, | ||
| 464 | .templates = CMS_EncryptedContentInfo_seq_tt, | ||
| 465 | .tcount = sizeof(CMS_EncryptedContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 466 | .funcs = NULL, | ||
| 467 | .size = sizeof(CMS_EncryptedContentInfo), | ||
| 468 | .sname = "CMS_EncryptedContentInfo", | ||
| 469 | }; | ||
| 470 | |||
| 471 | static const ASN1_TEMPLATE CMS_KeyTransRecipientInfo_seq_tt[] = { | ||
| 472 | { | ||
| 473 | .flags = 0, | ||
| 474 | .tag = 0, | ||
| 475 | .offset = offsetof(CMS_KeyTransRecipientInfo, version), | ||
| 476 | .field_name = "version", | ||
| 477 | .item = &INT32_it, | ||
| 478 | }, | ||
| 479 | { | ||
| 480 | .flags = 0, | ||
| 481 | .tag = 0, | ||
| 482 | .offset = offsetof(CMS_KeyTransRecipientInfo, rid), | ||
| 483 | .field_name = "rid", | ||
| 484 | .item = &CMS_SignerIdentifier_it, | ||
| 485 | }, | ||
| 486 | { | ||
| 487 | .flags = 0, | ||
| 488 | .tag = 0, | ||
| 489 | .offset = offsetof(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm), | ||
| 490 | .field_name = "keyEncryptionAlgorithm", | ||
| 491 | .item = &X509_ALGOR_it, | ||
| 492 | }, | ||
| 493 | { | ||
| 494 | .flags = 0, | ||
| 495 | .tag = 0, | ||
| 496 | .offset = offsetof(CMS_KeyTransRecipientInfo, encryptedKey), | ||
| 497 | .field_name = "encryptedKey", | ||
| 498 | .item = &ASN1_OCTET_STRING_it, | ||
| 499 | }, | ||
| 500 | }; | ||
| 501 | |||
| 502 | const ASN1_ITEM CMS_KeyTransRecipientInfo_it = { | ||
| 503 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 504 | .utype = V_ASN1_SEQUENCE, | ||
| 505 | .templates = CMS_KeyTransRecipientInfo_seq_tt, | ||
| 506 | .tcount = sizeof(CMS_KeyTransRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 507 | .funcs = NULL, | ||
| 508 | .size = sizeof(CMS_KeyTransRecipientInfo), | ||
| 509 | .sname = "CMS_KeyTransRecipientInfo", | ||
| 510 | }; | ||
| 511 | |||
| 512 | static const ASN1_TEMPLATE CMS_OtherKeyAttribute_seq_tt[] = { | ||
| 513 | { | ||
| 514 | .flags = 0, | ||
| 515 | .tag = 0, | ||
| 516 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttrId), | ||
| 517 | .field_name = "keyAttrId", | ||
| 518 | .item = &ASN1_OBJECT_it, | ||
| 519 | }, | ||
| 520 | { | ||
| 521 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 522 | .tag = 0, | ||
| 523 | .offset = offsetof(CMS_OtherKeyAttribute, keyAttr), | ||
| 524 | .field_name = "keyAttr", | ||
| 525 | .item = &ASN1_ANY_it, | ||
| 526 | }, | ||
| 527 | }; | ||
| 528 | |||
| 529 | const ASN1_ITEM CMS_OtherKeyAttribute_it = { | ||
| 530 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 531 | .utype = V_ASN1_SEQUENCE, | ||
| 532 | .templates = CMS_OtherKeyAttribute_seq_tt, | ||
| 533 | .tcount = sizeof(CMS_OtherKeyAttribute_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 534 | .funcs = NULL, | ||
| 535 | .size = sizeof(CMS_OtherKeyAttribute), | ||
| 536 | .sname = "CMS_OtherKeyAttribute", | ||
| 537 | }; | ||
| 538 | |||
| 539 | static const ASN1_TEMPLATE CMS_RecipientKeyIdentifier_seq_tt[] = { | ||
| 540 | { | ||
| 541 | .flags = 0, | ||
| 542 | .tag = 0, | ||
| 543 | .offset = offsetof(CMS_RecipientKeyIdentifier, subjectKeyIdentifier), | ||
| 544 | .field_name = "subjectKeyIdentifier", | ||
| 545 | .item = &ASN1_OCTET_STRING_it, | ||
| 546 | }, | ||
| 547 | { | ||
| 548 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 549 | .tag = 0, | ||
| 550 | .offset = offsetof(CMS_RecipientKeyIdentifier, date), | ||
| 551 | .field_name = "date", | ||
| 552 | .item = &ASN1_GENERALIZEDTIME_it, | ||
| 553 | }, | ||
| 554 | { | ||
| 555 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 556 | .tag = 0, | ||
| 557 | .offset = offsetof(CMS_RecipientKeyIdentifier, other), | ||
| 558 | .field_name = "other", | ||
| 559 | .item = &CMS_OtherKeyAttribute_it, | ||
| 560 | }, | ||
| 561 | }; | ||
| 562 | |||
| 563 | const ASN1_ITEM CMS_RecipientKeyIdentifier_it = { | ||
| 564 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 565 | .utype = V_ASN1_SEQUENCE, | ||
| 566 | .templates = CMS_RecipientKeyIdentifier_seq_tt, | ||
| 567 | .tcount = sizeof(CMS_RecipientKeyIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 568 | .funcs = NULL, | ||
| 569 | .size = sizeof(CMS_RecipientKeyIdentifier), | ||
| 570 | .sname = "CMS_RecipientKeyIdentifier", | ||
| 571 | }; | ||
| 572 | |||
| 573 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientIdentifier_ch_tt[] = { | ||
| 574 | { | ||
| 575 | .flags = 0, | ||
| 576 | .tag = 0, | ||
| 577 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber), | ||
| 578 | .field_name = "d.issuerAndSerialNumber", | ||
| 579 | .item = &CMS_IssuerAndSerialNumber_it, | ||
| 580 | }, | ||
| 581 | { | ||
| 582 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 583 | .tag = 0, | ||
| 584 | .offset = offsetof(CMS_KeyAgreeRecipientIdentifier, d.rKeyId), | ||
| 585 | .field_name = "d.rKeyId", | ||
| 586 | .item = &CMS_RecipientKeyIdentifier_it, | ||
| 587 | }, | ||
| 588 | }; | ||
| 589 | |||
| 590 | static const ASN1_ITEM CMS_KeyAgreeRecipientIdentifier_it = { | ||
| 591 | .itype = ASN1_ITYPE_CHOICE, | ||
| 592 | .utype = offsetof(CMS_KeyAgreeRecipientIdentifier, type), | ||
| 593 | .templates = CMS_KeyAgreeRecipientIdentifier_ch_tt, | ||
| 594 | .tcount = sizeof(CMS_KeyAgreeRecipientIdentifier_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 595 | .funcs = NULL, | ||
| 596 | .size = sizeof(CMS_KeyAgreeRecipientIdentifier), | ||
| 597 | .sname = "CMS_KeyAgreeRecipientIdentifier", | ||
| 598 | }; | ||
| 165 | 599 | ||
| 166 | static int | 600 | static int |
| 167 | cms_rek_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | 601 | cms_rek_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
| @@ -173,21 +607,101 @@ cms_rek_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 173 | return 1; | 607 | return 1; |
| 174 | } | 608 | } |
| 175 | 609 | ||
| 176 | ASN1_SEQUENCE_cb(CMS_RecipientEncryptedKey, cms_rek_cb) = { | 610 | static const ASN1_AUX CMS_RecipientEncryptedKey_aux = { |
| 177 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, rid, CMS_KeyAgreeRecipientIdentifier), | 611 | .app_data = NULL, |
| 178 | ASN1_SIMPLE(CMS_RecipientEncryptedKey, encryptedKey, ASN1_OCTET_STRING) | 612 | .flags = 0, |
| 179 | } ASN1_SEQUENCE_END_cb(CMS_RecipientEncryptedKey, CMS_RecipientEncryptedKey) | 613 | .ref_offset = 0, |
| 614 | .ref_lock = 0, | ||
| 615 | .asn1_cb = cms_rek_cb, | ||
| 616 | .enc_offset = 0, | ||
| 617 | }; | ||
| 618 | static const ASN1_TEMPLATE CMS_RecipientEncryptedKey_seq_tt[] = { | ||
| 619 | { | ||
| 620 | .flags = 0, | ||
| 621 | .tag = 0, | ||
| 622 | .offset = offsetof(CMS_RecipientEncryptedKey, rid), | ||
| 623 | .field_name = "rid", | ||
| 624 | .item = &CMS_KeyAgreeRecipientIdentifier_it, | ||
| 625 | }, | ||
| 626 | { | ||
| 627 | .flags = 0, | ||
| 628 | .tag = 0, | ||
| 629 | .offset = offsetof(CMS_RecipientEncryptedKey, encryptedKey), | ||
| 630 | .field_name = "encryptedKey", | ||
| 631 | .item = &ASN1_OCTET_STRING_it, | ||
| 632 | }, | ||
| 633 | }; | ||
| 634 | |||
| 635 | const ASN1_ITEM CMS_RecipientEncryptedKey_it = { | ||
| 636 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 637 | .utype = V_ASN1_SEQUENCE, | ||
| 638 | .templates = CMS_RecipientEncryptedKey_seq_tt, | ||
| 639 | .tcount = sizeof(CMS_RecipientEncryptedKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 640 | .funcs = &CMS_RecipientEncryptedKey_aux, | ||
| 641 | .size = sizeof(CMS_RecipientEncryptedKey), | ||
| 642 | .sname = "CMS_RecipientEncryptedKey", | ||
| 643 | }; | ||
| 644 | |||
| 645 | static const ASN1_TEMPLATE CMS_OriginatorPublicKey_seq_tt[] = { | ||
| 646 | { | ||
| 647 | .flags = 0, | ||
| 648 | .tag = 0, | ||
| 649 | .offset = offsetof(CMS_OriginatorPublicKey, algorithm), | ||
| 650 | .field_name = "algorithm", | ||
| 651 | .item = &X509_ALGOR_it, | ||
| 652 | }, | ||
| 653 | { | ||
| 654 | .flags = 0, | ||
| 655 | .tag = 0, | ||
| 656 | .offset = offsetof(CMS_OriginatorPublicKey, publicKey), | ||
| 657 | .field_name = "publicKey", | ||
| 658 | .item = &ASN1_BIT_STRING_it, | ||
| 659 | }, | ||
| 660 | }; | ||
| 180 | 661 | ||
| 181 | ASN1_SEQUENCE(CMS_OriginatorPublicKey) = { | 662 | const ASN1_ITEM CMS_OriginatorPublicKey_it = { |
| 182 | ASN1_SIMPLE(CMS_OriginatorPublicKey, algorithm, X509_ALGOR), | 663 | .itype = ASN1_ITYPE_SEQUENCE, |
| 183 | ASN1_SIMPLE(CMS_OriginatorPublicKey, publicKey, ASN1_BIT_STRING) | 664 | .utype = V_ASN1_SEQUENCE, |
| 184 | } ASN1_SEQUENCE_END(CMS_OriginatorPublicKey) | 665 | .templates = CMS_OriginatorPublicKey_seq_tt, |
| 666 | .tcount = sizeof(CMS_OriginatorPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 667 | .funcs = NULL, | ||
| 668 | .size = sizeof(CMS_OriginatorPublicKey), | ||
| 669 | .sname = "CMS_OriginatorPublicKey", | ||
| 670 | }; | ||
| 185 | 671 | ||
| 186 | ASN1_CHOICE(CMS_OriginatorIdentifierOrKey) = { | 672 | static const ASN1_TEMPLATE CMS_OriginatorIdentifierOrKey_ch_tt[] = { |
| 187 | ASN1_SIMPLE(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber), | 673 | { |
| 188 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0), | 674 | .flags = 0, |
| 189 | ASN1_IMP(CMS_OriginatorIdentifierOrKey, d.originatorKey, CMS_OriginatorPublicKey, 1) | 675 | .tag = 0, |
| 190 | } static_ASN1_CHOICE_END(CMS_OriginatorIdentifierOrKey) | 676 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.issuerAndSerialNumber), |
| 677 | .field_name = "d.issuerAndSerialNumber", | ||
| 678 | .item = &CMS_IssuerAndSerialNumber_it, | ||
| 679 | }, | ||
| 680 | { | ||
| 681 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 682 | .tag = 0, | ||
| 683 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.subjectKeyIdentifier), | ||
| 684 | .field_name = "d.subjectKeyIdentifier", | ||
| 685 | .item = &ASN1_OCTET_STRING_it, | ||
| 686 | }, | ||
| 687 | { | ||
| 688 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 689 | .tag = 1, | ||
| 690 | .offset = offsetof(CMS_OriginatorIdentifierOrKey, d.originatorKey), | ||
| 691 | .field_name = "d.originatorKey", | ||
| 692 | .item = &CMS_OriginatorPublicKey_it, | ||
| 693 | }, | ||
| 694 | }; | ||
| 695 | |||
| 696 | static const ASN1_ITEM CMS_OriginatorIdentifierOrKey_it = { | ||
| 697 | .itype = ASN1_ITYPE_CHOICE, | ||
| 698 | .utype = offsetof(CMS_OriginatorIdentifierOrKey, type), | ||
| 699 | .templates = CMS_OriginatorIdentifierOrKey_ch_tt, | ||
| 700 | .tcount = sizeof(CMS_OriginatorIdentifierOrKey_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 701 | .funcs = NULL, | ||
| 702 | .size = sizeof(CMS_OriginatorIdentifierOrKey), | ||
| 703 | .sname = "CMS_OriginatorIdentifierOrKey", | ||
| 704 | }; | ||
| 191 | 705 | ||
| 192 | static int | 706 | static int |
| 193 | cms_kari_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | 707 | cms_kari_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
| @@ -206,38 +720,204 @@ cms_kari_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 206 | return 1; | 720 | return 1; |
| 207 | } | 721 | } |
| 208 | 722 | ||
| 209 | ASN1_SEQUENCE_cb(CMS_KeyAgreeRecipientInfo, cms_kari_cb) = { | 723 | static const ASN1_AUX CMS_KeyAgreeRecipientInfo_aux = { |
| 210 | ASN1_EMBED(CMS_KeyAgreeRecipientInfo, version, INT32), | 724 | .app_data = NULL, |
| 211 | ASN1_EXP(CMS_KeyAgreeRecipientInfo, originator, CMS_OriginatorIdentifierOrKey, 0), | 725 | .flags = 0, |
| 212 | ASN1_EXP_OPT(CMS_KeyAgreeRecipientInfo, ukm, ASN1_OCTET_STRING, 1), | 726 | .ref_offset = 0, |
| 213 | ASN1_SIMPLE(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 727 | .ref_lock = 0, |
| 214 | ASN1_SEQUENCE_OF(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys, CMS_RecipientEncryptedKey) | 728 | .asn1_cb = cms_kari_cb, |
| 215 | } ASN1_SEQUENCE_END_cb(CMS_KeyAgreeRecipientInfo, CMS_KeyAgreeRecipientInfo) | 729 | .enc_offset = 0, |
| 216 | 730 | }; | |
| 217 | ASN1_SEQUENCE(CMS_KEKIdentifier) = { | 731 | static const ASN1_TEMPLATE CMS_KeyAgreeRecipientInfo_seq_tt[] = { |
| 218 | ASN1_SIMPLE(CMS_KEKIdentifier, keyIdentifier, ASN1_OCTET_STRING), | 732 | { |
| 219 | ASN1_OPT(CMS_KEKIdentifier, date, ASN1_GENERALIZEDTIME), | 733 | .flags = 0, |
| 220 | ASN1_OPT(CMS_KEKIdentifier, other, CMS_OtherKeyAttribute) | 734 | .tag = 0, |
| 221 | } static_ASN1_SEQUENCE_END(CMS_KEKIdentifier) | 735 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, version), |
| 222 | 736 | .field_name = "version", | |
| 223 | ASN1_SEQUENCE(CMS_KEKRecipientInfo) = { | 737 | .item = &INT32_it, |
| 224 | ASN1_EMBED(CMS_KEKRecipientInfo, version, INT32), | 738 | }, |
| 225 | ASN1_SIMPLE(CMS_KEKRecipientInfo, kekid, CMS_KEKIdentifier), | 739 | { |
| 226 | ASN1_SIMPLE(CMS_KEKRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 740 | .flags = ASN1_TFLG_EXPLICIT, |
| 227 | ASN1_SIMPLE(CMS_KEKRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 741 | .tag = 0, |
| 228 | } ASN1_SEQUENCE_END(CMS_KEKRecipientInfo) | 742 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, originator), |
| 229 | 743 | .field_name = "originator", | |
| 230 | ASN1_SEQUENCE(CMS_PasswordRecipientInfo) = { | 744 | .item = &CMS_OriginatorIdentifierOrKey_it, |
| 231 | ASN1_EMBED(CMS_PasswordRecipientInfo, version, INT32), | 745 | }, |
| 232 | ASN1_IMP_OPT(CMS_PasswordRecipientInfo, keyDerivationAlgorithm, X509_ALGOR, 0), | 746 | { |
| 233 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR), | 747 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, |
| 234 | ASN1_SIMPLE(CMS_PasswordRecipientInfo, encryptedKey, ASN1_OCTET_STRING) | 748 | .tag = 1, |
| 235 | } ASN1_SEQUENCE_END(CMS_PasswordRecipientInfo) | 749 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, ukm), |
| 236 | 750 | .field_name = "ukm", | |
| 237 | ASN1_SEQUENCE(CMS_OtherRecipientInfo) = { | 751 | .item = &ASN1_OCTET_STRING_it, |
| 238 | ASN1_SIMPLE(CMS_OtherRecipientInfo, oriType, ASN1_OBJECT), | 752 | }, |
| 239 | ASN1_OPT(CMS_OtherRecipientInfo, oriValue, ASN1_ANY) | 753 | { |
| 240 | } static_ASN1_SEQUENCE_END(CMS_OtherRecipientInfo) | 754 | .flags = 0, |
| 755 | .tag = 0, | ||
| 756 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, keyEncryptionAlgorithm), | ||
| 757 | .field_name = "keyEncryptionAlgorithm", | ||
| 758 | .item = &X509_ALGOR_it, | ||
| 759 | }, | ||
| 760 | { | ||
| 761 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
| 762 | .tag = 0, | ||
| 763 | .offset = offsetof(CMS_KeyAgreeRecipientInfo, recipientEncryptedKeys), | ||
| 764 | .field_name = "recipientEncryptedKeys", | ||
| 765 | .item = &CMS_RecipientEncryptedKey_it, | ||
| 766 | }, | ||
| 767 | }; | ||
| 768 | |||
| 769 | const ASN1_ITEM CMS_KeyAgreeRecipientInfo_it = { | ||
| 770 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 771 | .utype = V_ASN1_SEQUENCE, | ||
| 772 | .templates = CMS_KeyAgreeRecipientInfo_seq_tt, | ||
| 773 | .tcount = sizeof(CMS_KeyAgreeRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 774 | .funcs = &CMS_KeyAgreeRecipientInfo_aux, | ||
| 775 | .size = sizeof(CMS_KeyAgreeRecipientInfo), | ||
| 776 | .sname = "CMS_KeyAgreeRecipientInfo", | ||
| 777 | }; | ||
| 778 | |||
| 779 | static const ASN1_TEMPLATE CMS_KEKIdentifier_seq_tt[] = { | ||
| 780 | { | ||
| 781 | .flags = 0, | ||
| 782 | .tag = 0, | ||
| 783 | .offset = offsetof(CMS_KEKIdentifier, keyIdentifier), | ||
| 784 | .field_name = "keyIdentifier", | ||
| 785 | .item = &ASN1_OCTET_STRING_it, | ||
| 786 | }, | ||
| 787 | { | ||
| 788 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 789 | .tag = 0, | ||
| 790 | .offset = offsetof(CMS_KEKIdentifier, date), | ||
| 791 | .field_name = "date", | ||
| 792 | .item = &ASN1_GENERALIZEDTIME_it, | ||
| 793 | }, | ||
| 794 | { | ||
| 795 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 796 | .tag = 0, | ||
| 797 | .offset = offsetof(CMS_KEKIdentifier, other), | ||
| 798 | .field_name = "other", | ||
| 799 | .item = &CMS_OtherKeyAttribute_it, | ||
| 800 | }, | ||
| 801 | }; | ||
| 802 | |||
| 803 | static const ASN1_ITEM CMS_KEKIdentifier_it = { | ||
| 804 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 805 | .utype = V_ASN1_SEQUENCE, | ||
| 806 | .templates = CMS_KEKIdentifier_seq_tt, | ||
| 807 | .tcount = sizeof(CMS_KEKIdentifier_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 808 | .funcs = NULL, | ||
| 809 | .size = sizeof(CMS_KEKIdentifier), | ||
| 810 | .sname = "CMS_KEKIdentifier", | ||
| 811 | }; | ||
| 812 | |||
| 813 | static const ASN1_TEMPLATE CMS_KEKRecipientInfo_seq_tt[] = { | ||
| 814 | { | ||
| 815 | .flags = 0, | ||
| 816 | .tag = 0, | ||
| 817 | .offset = offsetof(CMS_KEKRecipientInfo, version), | ||
| 818 | .field_name = "version", | ||
| 819 | .item = &INT32_it, | ||
| 820 | }, | ||
| 821 | { | ||
| 822 | .flags = 0, | ||
| 823 | .tag = 0, | ||
| 824 | .offset = offsetof(CMS_KEKRecipientInfo, kekid), | ||
| 825 | .field_name = "kekid", | ||
| 826 | .item = &CMS_KEKIdentifier_it, | ||
| 827 | }, | ||
| 828 | { | ||
| 829 | .flags = 0, | ||
| 830 | .tag = 0, | ||
| 831 | .offset = offsetof(CMS_KEKRecipientInfo, keyEncryptionAlgorithm), | ||
| 832 | .field_name = "keyEncryptionAlgorithm", | ||
| 833 | .item = &X509_ALGOR_it, | ||
| 834 | }, | ||
| 835 | { | ||
| 836 | .flags = 0, | ||
| 837 | .tag = 0, | ||
| 838 | .offset = offsetof(CMS_KEKRecipientInfo, encryptedKey), | ||
| 839 | .field_name = "encryptedKey", | ||
| 840 | .item = &ASN1_OCTET_STRING_it, | ||
| 841 | }, | ||
| 842 | }; | ||
| 843 | |||
| 844 | const ASN1_ITEM CMS_KEKRecipientInfo_it = { | ||
| 845 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 846 | .utype = V_ASN1_SEQUENCE, | ||
| 847 | .templates = CMS_KEKRecipientInfo_seq_tt, | ||
| 848 | .tcount = sizeof(CMS_KEKRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 849 | .funcs = NULL, | ||
| 850 | .size = sizeof(CMS_KEKRecipientInfo), | ||
| 851 | .sname = "CMS_KEKRecipientInfo", | ||
| 852 | }; | ||
| 853 | |||
| 854 | static const ASN1_TEMPLATE CMS_PasswordRecipientInfo_seq_tt[] = { | ||
| 855 | { | ||
| 856 | .flags = 0, | ||
| 857 | .tag = 0, | ||
| 858 | .offset = offsetof(CMS_PasswordRecipientInfo, version), | ||
| 859 | .field_name = "version", | ||
| 860 | .item = &INT32_it, | ||
| 861 | }, | ||
| 862 | { | ||
| 863 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 864 | .tag = 0, | ||
| 865 | .offset = offsetof(CMS_PasswordRecipientInfo, keyDerivationAlgorithm), | ||
| 866 | .field_name = "keyDerivationAlgorithm", | ||
| 867 | .item = &X509_ALGOR_it, | ||
| 868 | }, | ||
| 869 | { | ||
| 870 | .flags = 0, | ||
| 871 | .tag = 0, | ||
| 872 | .offset = offsetof(CMS_PasswordRecipientInfo, keyEncryptionAlgorithm), | ||
| 873 | .field_name = "keyEncryptionAlgorithm", | ||
| 874 | .item = &X509_ALGOR_it, | ||
| 875 | }, | ||
| 876 | { | ||
| 877 | .flags = 0, | ||
| 878 | .tag = 0, | ||
| 879 | .offset = offsetof(CMS_PasswordRecipientInfo, encryptedKey), | ||
| 880 | .field_name = "encryptedKey", | ||
| 881 | .item = &ASN1_OCTET_STRING_it, | ||
| 882 | }, | ||
| 883 | }; | ||
| 884 | |||
| 885 | const ASN1_ITEM CMS_PasswordRecipientInfo_it = { | ||
| 886 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 887 | .utype = V_ASN1_SEQUENCE, | ||
| 888 | .templates = CMS_PasswordRecipientInfo_seq_tt, | ||
| 889 | .tcount = sizeof(CMS_PasswordRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 890 | .funcs = NULL, | ||
| 891 | .size = sizeof(CMS_PasswordRecipientInfo), | ||
| 892 | .sname = "CMS_PasswordRecipientInfo", | ||
| 893 | }; | ||
| 894 | |||
| 895 | static const ASN1_TEMPLATE CMS_OtherRecipientInfo_seq_tt[] = { | ||
| 896 | { | ||
| 897 | .flags = 0, | ||
| 898 | .tag = 0, | ||
| 899 | .offset = offsetof(CMS_OtherRecipientInfo, oriType), | ||
| 900 | .field_name = "oriType", | ||
| 901 | .item = &ASN1_OBJECT_it, | ||
| 902 | }, | ||
| 903 | { | ||
| 904 | .flags = ASN1_TFLG_OPTIONAL, | ||
| 905 | .tag = 0, | ||
| 906 | .offset = offsetof(CMS_OtherRecipientInfo, oriValue), | ||
| 907 | .field_name = "oriValue", | ||
| 908 | .item = &ASN1_ANY_it, | ||
| 909 | }, | ||
| 910 | }; | ||
| 911 | |||
| 912 | static const ASN1_ITEM CMS_OtherRecipientInfo_it = { | ||
| 913 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 914 | .utype = V_ASN1_SEQUENCE, | ||
| 915 | .templates = CMS_OtherRecipientInfo_seq_tt, | ||
| 916 | .tcount = sizeof(CMS_OtherRecipientInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 917 | .funcs = NULL, | ||
| 918 | .size = sizeof(CMS_OtherRecipientInfo), | ||
| 919 | .sname = "CMS_OtherRecipientInfo", | ||
| 920 | }; | ||
| 241 | 921 | ||
| 242 | /* Free up RecipientInfo additional data */ | 922 | /* Free up RecipientInfo additional data */ |
| 243 | static int | 923 | static int |
| @@ -261,66 +941,394 @@ cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 261 | return 1; | 941 | return 1; |
| 262 | } | 942 | } |
| 263 | 943 | ||
| 264 | ASN1_CHOICE_cb(CMS_RecipientInfo, cms_ri_cb) = { | 944 | static const ASN1_AUX CMS_RecipientInfo_aux = { |
| 265 | ASN1_SIMPLE(CMS_RecipientInfo, d.ktri, CMS_KeyTransRecipientInfo), | 945 | .app_data = NULL, |
| 266 | ASN1_IMP(CMS_RecipientInfo, d.kari, CMS_KeyAgreeRecipientInfo, 1), | 946 | .flags = 0, |
| 267 | ASN1_IMP(CMS_RecipientInfo, d.kekri, CMS_KEKRecipientInfo, 2), | 947 | .ref_offset = 0, |
| 268 | ASN1_IMP(CMS_RecipientInfo, d.pwri, CMS_PasswordRecipientInfo, 3), | 948 | .ref_lock = 0, |
| 269 | ASN1_IMP(CMS_RecipientInfo, d.ori, CMS_OtherRecipientInfo, 4) | 949 | .asn1_cb = cms_ri_cb, |
| 270 | } ASN1_CHOICE_END_cb(CMS_RecipientInfo, CMS_RecipientInfo, type) | 950 | .enc_offset = 0, |
| 271 | 951 | }; | |
| 272 | ASN1_NDEF_SEQUENCE(CMS_EnvelopedData) = { | 952 | static const ASN1_TEMPLATE CMS_RecipientInfo_ch_tt[] = { |
| 273 | ASN1_EMBED(CMS_EnvelopedData, version, INT32), | 953 | { |
| 274 | ASN1_IMP_OPT(CMS_EnvelopedData, originatorInfo, CMS_OriginatorInfo, 0), | 954 | .flags = 0, |
| 275 | ASN1_SET_OF(CMS_EnvelopedData, recipientInfos, CMS_RecipientInfo), | 955 | .tag = 0, |
| 276 | ASN1_SIMPLE(CMS_EnvelopedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 956 | .offset = offsetof(CMS_RecipientInfo, d.ktri), |
| 277 | ASN1_IMP_SET_OF_OPT(CMS_EnvelopedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 957 | .field_name = "d.ktri", |
| 278 | } ASN1_NDEF_SEQUENCE_END(CMS_EnvelopedData) | 958 | .item = &CMS_KeyTransRecipientInfo_it, |
| 279 | 959 | }, | |
| 280 | ASN1_NDEF_SEQUENCE(CMS_DigestedData) = { | 960 | { |
| 281 | ASN1_EMBED(CMS_DigestedData, version, INT32), | 961 | .flags = ASN1_TFLG_IMPLICIT, |
| 282 | ASN1_SIMPLE(CMS_DigestedData, digestAlgorithm, X509_ALGOR), | 962 | .tag = 1, |
| 283 | ASN1_SIMPLE(CMS_DigestedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 963 | .offset = offsetof(CMS_RecipientInfo, d.kari), |
| 284 | ASN1_SIMPLE(CMS_DigestedData, digest, ASN1_OCTET_STRING) | 964 | .field_name = "d.kari", |
| 285 | } ASN1_NDEF_SEQUENCE_END(CMS_DigestedData) | 965 | .item = &CMS_KeyAgreeRecipientInfo_it, |
| 286 | 966 | }, | |
| 287 | ASN1_NDEF_SEQUENCE(CMS_EncryptedData) = { | 967 | { |
| 288 | ASN1_EMBED(CMS_EncryptedData, version, INT32), | 968 | .flags = ASN1_TFLG_IMPLICIT, |
| 289 | ASN1_SIMPLE(CMS_EncryptedData, encryptedContentInfo, CMS_EncryptedContentInfo), | 969 | .tag = 2, |
| 290 | ASN1_IMP_SET_OF_OPT(CMS_EncryptedData, unprotectedAttrs, X509_ATTRIBUTE, 1) | 970 | .offset = offsetof(CMS_RecipientInfo, d.kekri), |
| 291 | } ASN1_NDEF_SEQUENCE_END(CMS_EncryptedData) | 971 | .field_name = "d.kekri", |
| 292 | 972 | .item = &CMS_KEKRecipientInfo_it, | |
| 293 | ASN1_NDEF_SEQUENCE(CMS_AuthenticatedData) = { | 973 | }, |
| 294 | ASN1_EMBED(CMS_AuthenticatedData, version, INT32), | 974 | { |
| 295 | ASN1_IMP_OPT(CMS_AuthenticatedData, originatorInfo, CMS_OriginatorInfo, 0), | 975 | .flags = ASN1_TFLG_IMPLICIT, |
| 296 | ASN1_SET_OF(CMS_AuthenticatedData, recipientInfos, CMS_RecipientInfo), | 976 | .tag = 3, |
| 297 | ASN1_SIMPLE(CMS_AuthenticatedData, macAlgorithm, X509_ALGOR), | 977 | .offset = offsetof(CMS_RecipientInfo, d.pwri), |
| 298 | ASN1_IMP(CMS_AuthenticatedData, digestAlgorithm, X509_ALGOR, 1), | 978 | .field_name = "d.pwri", |
| 299 | ASN1_SIMPLE(CMS_AuthenticatedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 979 | .item = &CMS_PasswordRecipientInfo_it, |
| 300 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, authAttrs, X509_ALGOR, 2), | 980 | }, |
| 301 | ASN1_SIMPLE(CMS_AuthenticatedData, mac, ASN1_OCTET_STRING), | 981 | { |
| 302 | ASN1_IMP_SET_OF_OPT(CMS_AuthenticatedData, unauthAttrs, X509_ALGOR, 3) | 982 | .flags = ASN1_TFLG_IMPLICIT, |
| 303 | } static_ASN1_NDEF_SEQUENCE_END(CMS_AuthenticatedData) | 983 | .tag = 4, |
| 304 | 984 | .offset = offsetof(CMS_RecipientInfo, d.ori), | |
| 305 | ASN1_NDEF_SEQUENCE(CMS_CompressedData) = { | 985 | .field_name = "d.ori", |
| 306 | ASN1_EMBED(CMS_CompressedData, version, INT32), | 986 | .item = &CMS_OtherRecipientInfo_it, |
| 307 | ASN1_SIMPLE(CMS_CompressedData, compressionAlgorithm, X509_ALGOR), | 987 | }, |
| 308 | ASN1_SIMPLE(CMS_CompressedData, encapContentInfo, CMS_EncapsulatedContentInfo), | 988 | }; |
| 309 | } ASN1_NDEF_SEQUENCE_END(CMS_CompressedData) | 989 | |
| 990 | const ASN1_ITEM CMS_RecipientInfo_it = { | ||
| 991 | .itype = ASN1_ITYPE_CHOICE, | ||
| 992 | .utype = offsetof(CMS_RecipientInfo, type), | ||
| 993 | .templates = CMS_RecipientInfo_ch_tt, | ||
| 994 | .tcount = sizeof(CMS_RecipientInfo_ch_tt) / sizeof(ASN1_TEMPLATE), | ||
| 995 | .funcs = &CMS_RecipientInfo_aux, | ||
| 996 | .size = sizeof(CMS_RecipientInfo), | ||
| 997 | .sname = "CMS_RecipientInfo", | ||
| 998 | }; | ||
| 999 | |||
| 1000 | static const ASN1_TEMPLATE CMS_EnvelopedData_seq_tt[] = { | ||
| 1001 | { | ||
| 1002 | .flags = 0, | ||
| 1003 | .tag = 0, | ||
| 1004 | .offset = offsetof(CMS_EnvelopedData, version), | ||
| 1005 | .field_name = "version", | ||
| 1006 | .item = &INT32_it, | ||
| 1007 | }, | ||
| 1008 | { | ||
| 1009 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 1010 | .tag = 0, | ||
| 1011 | .offset = offsetof(CMS_EnvelopedData, originatorInfo), | ||
| 1012 | .field_name = "originatorInfo", | ||
| 1013 | .item = &CMS_OriginatorInfo_it, | ||
| 1014 | }, | ||
| 1015 | { | ||
| 1016 | .flags = ASN1_TFLG_SET_OF, | ||
| 1017 | .tag = 0, | ||
| 1018 | .offset = offsetof(CMS_EnvelopedData, recipientInfos), | ||
| 1019 | .field_name = "recipientInfos", | ||
| 1020 | .item = &CMS_RecipientInfo_it, | ||
| 1021 | }, | ||
| 1022 | { | ||
| 1023 | .flags = 0, | ||
| 1024 | .tag = 0, | ||
| 1025 | .offset = offsetof(CMS_EnvelopedData, encryptedContentInfo), | ||
| 1026 | .field_name = "encryptedContentInfo", | ||
| 1027 | .item = &CMS_EncryptedContentInfo_it, | ||
| 1028 | }, | ||
| 1029 | { | ||
| 1030 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1031 | .tag = 1, | ||
| 1032 | .offset = offsetof(CMS_EnvelopedData, unprotectedAttrs), | ||
| 1033 | .field_name = "unprotectedAttrs", | ||
| 1034 | .item = &X509_ATTRIBUTE_it, | ||
| 1035 | }, | ||
| 1036 | }; | ||
| 1037 | |||
| 1038 | const ASN1_ITEM CMS_EnvelopedData_it = { | ||
| 1039 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1040 | .utype = V_ASN1_SEQUENCE, | ||
| 1041 | .templates = CMS_EnvelopedData_seq_tt, | ||
| 1042 | .tcount = sizeof(CMS_EnvelopedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1043 | .funcs = NULL, | ||
| 1044 | .size = sizeof(CMS_EnvelopedData), | ||
| 1045 | .sname = "CMS_EnvelopedData", | ||
| 1046 | }; | ||
| 1047 | |||
| 1048 | static const ASN1_TEMPLATE CMS_DigestedData_seq_tt[] = { | ||
| 1049 | { | ||
| 1050 | .flags = 0, | ||
| 1051 | .tag = 0, | ||
| 1052 | .offset = offsetof(CMS_DigestedData, version), | ||
| 1053 | .field_name = "version", | ||
| 1054 | .item = &INT32_it, | ||
| 1055 | }, | ||
| 1056 | { | ||
| 1057 | .flags = 0, | ||
| 1058 | .tag = 0, | ||
| 1059 | .offset = offsetof(CMS_DigestedData, digestAlgorithm), | ||
| 1060 | .field_name = "digestAlgorithm", | ||
| 1061 | .item = &X509_ALGOR_it, | ||
| 1062 | }, | ||
| 1063 | { | ||
| 1064 | .flags = 0, | ||
| 1065 | .tag = 0, | ||
| 1066 | .offset = offsetof(CMS_DigestedData, encapContentInfo), | ||
| 1067 | .field_name = "encapContentInfo", | ||
| 1068 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1069 | }, | ||
| 1070 | { | ||
| 1071 | .flags = 0, | ||
| 1072 | .tag = 0, | ||
| 1073 | .offset = offsetof(CMS_DigestedData, digest), | ||
| 1074 | .field_name = "digest", | ||
| 1075 | .item = &ASN1_OCTET_STRING_it, | ||
| 1076 | }, | ||
| 1077 | }; | ||
| 1078 | |||
| 1079 | const ASN1_ITEM CMS_DigestedData_it = { | ||
| 1080 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1081 | .utype = V_ASN1_SEQUENCE, | ||
| 1082 | .templates = CMS_DigestedData_seq_tt, | ||
| 1083 | .tcount = sizeof(CMS_DigestedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1084 | .funcs = NULL, | ||
| 1085 | .size = sizeof(CMS_DigestedData), | ||
| 1086 | .sname = "CMS_DigestedData", | ||
| 1087 | }; | ||
| 1088 | |||
| 1089 | static const ASN1_TEMPLATE CMS_EncryptedData_seq_tt[] = { | ||
| 1090 | { | ||
| 1091 | .flags = 0, | ||
| 1092 | .tag = 0, | ||
| 1093 | .offset = offsetof(CMS_EncryptedData, version), | ||
| 1094 | .field_name = "version", | ||
| 1095 | .item = &INT32_it, | ||
| 1096 | }, | ||
| 1097 | { | ||
| 1098 | .flags = 0, | ||
| 1099 | .tag = 0, | ||
| 1100 | .offset = offsetof(CMS_EncryptedData, encryptedContentInfo), | ||
| 1101 | .field_name = "encryptedContentInfo", | ||
| 1102 | .item = &CMS_EncryptedContentInfo_it, | ||
| 1103 | }, | ||
| 1104 | { | ||
| 1105 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1106 | .tag = 1, | ||
| 1107 | .offset = offsetof(CMS_EncryptedData, unprotectedAttrs), | ||
| 1108 | .field_name = "unprotectedAttrs", | ||
| 1109 | .item = &X509_ATTRIBUTE_it, | ||
| 1110 | }, | ||
| 1111 | }; | ||
| 1112 | |||
| 1113 | const ASN1_ITEM CMS_EncryptedData_it = { | ||
| 1114 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1115 | .utype = V_ASN1_SEQUENCE, | ||
| 1116 | .templates = CMS_EncryptedData_seq_tt, | ||
| 1117 | .tcount = sizeof(CMS_EncryptedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1118 | .funcs = NULL, | ||
| 1119 | .size = sizeof(CMS_EncryptedData), | ||
| 1120 | .sname = "CMS_EncryptedData", | ||
| 1121 | }; | ||
| 1122 | |||
| 1123 | static const ASN1_TEMPLATE CMS_AuthenticatedData_seq_tt[] = { | ||
| 1124 | { | ||
| 1125 | .flags = 0, | ||
| 1126 | .tag = 0, | ||
| 1127 | .offset = offsetof(CMS_AuthenticatedData, version), | ||
| 1128 | .field_name = "version", | ||
| 1129 | .item = &INT32_it, | ||
| 1130 | }, | ||
| 1131 | { | ||
| 1132 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 1133 | .tag = 0, | ||
| 1134 | .offset = offsetof(CMS_AuthenticatedData, originatorInfo), | ||
| 1135 | .field_name = "originatorInfo", | ||
| 1136 | .item = &CMS_OriginatorInfo_it, | ||
| 1137 | }, | ||
| 1138 | { | ||
| 1139 | .flags = ASN1_TFLG_SET_OF, | ||
| 1140 | .tag = 0, | ||
| 1141 | .offset = offsetof(CMS_AuthenticatedData, recipientInfos), | ||
| 1142 | .field_name = "recipientInfos", | ||
| 1143 | .item = &CMS_RecipientInfo_it, | ||
| 1144 | }, | ||
| 1145 | { | ||
| 1146 | .flags = 0, | ||
| 1147 | .tag = 0, | ||
| 1148 | .offset = offsetof(CMS_AuthenticatedData, macAlgorithm), | ||
| 1149 | .field_name = "macAlgorithm", | ||
| 1150 | .item = &X509_ALGOR_it, | ||
| 1151 | }, | ||
| 1152 | { | ||
| 1153 | .flags = ASN1_TFLG_IMPLICIT, | ||
| 1154 | .tag = 1, | ||
| 1155 | .offset = offsetof(CMS_AuthenticatedData, digestAlgorithm), | ||
| 1156 | .field_name = "digestAlgorithm", | ||
| 1157 | .item = &X509_ALGOR_it, | ||
| 1158 | }, | ||
| 1159 | { | ||
| 1160 | .flags = 0, | ||
| 1161 | .tag = 0, | ||
| 1162 | .offset = offsetof(CMS_AuthenticatedData, encapContentInfo), | ||
| 1163 | .field_name = "encapContentInfo", | ||
| 1164 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1165 | }, | ||
| 1166 | { | ||
| 1167 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1168 | .tag = 2, | ||
| 1169 | .offset = offsetof(CMS_AuthenticatedData, authAttrs), | ||
| 1170 | .field_name = "authAttrs", | ||
| 1171 | .item = &X509_ALGOR_it, | ||
| 1172 | }, | ||
| 1173 | { | ||
| 1174 | .flags = 0, | ||
| 1175 | .tag = 0, | ||
| 1176 | .offset = offsetof(CMS_AuthenticatedData, mac), | ||
| 1177 | .field_name = "mac", | ||
| 1178 | .item = &ASN1_OCTET_STRING_it, | ||
| 1179 | }, | ||
| 1180 | { | ||
| 1181 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, | ||
| 1182 | .tag = 3, | ||
| 1183 | .offset = offsetof(CMS_AuthenticatedData, unauthAttrs), | ||
| 1184 | .field_name = "unauthAttrs", | ||
| 1185 | .item = &X509_ALGOR_it, | ||
| 1186 | }, | ||
| 1187 | }; | ||
| 1188 | |||
| 1189 | static const ASN1_ITEM CMS_AuthenticatedData_it = { | ||
| 1190 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1191 | .utype = V_ASN1_SEQUENCE, | ||
| 1192 | .templates = CMS_AuthenticatedData_seq_tt, | ||
| 1193 | .tcount = sizeof(CMS_AuthenticatedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1194 | .funcs = NULL, | ||
| 1195 | .size = sizeof(CMS_AuthenticatedData), | ||
| 1196 | .sname = "CMS_AuthenticatedData", | ||
| 1197 | }; | ||
| 1198 | |||
| 1199 | static const ASN1_TEMPLATE CMS_CompressedData_seq_tt[] = { | ||
| 1200 | { | ||
| 1201 | .flags = 0, | ||
| 1202 | .tag = 0, | ||
| 1203 | .offset = offsetof(CMS_CompressedData, version), | ||
| 1204 | .field_name = "version", | ||
| 1205 | .item = &INT32_it, | ||
| 1206 | }, | ||
| 1207 | { | ||
| 1208 | .flags = 0, | ||
| 1209 | .tag = 0, | ||
| 1210 | .offset = offsetof(CMS_CompressedData, compressionAlgorithm), | ||
| 1211 | .field_name = "compressionAlgorithm", | ||
| 1212 | .item = &X509_ALGOR_it, | ||
| 1213 | }, | ||
| 1214 | { | ||
| 1215 | .flags = 0, | ||
| 1216 | .tag = 0, | ||
| 1217 | .offset = offsetof(CMS_CompressedData, encapContentInfo), | ||
| 1218 | .field_name = "encapContentInfo", | ||
| 1219 | .item = &CMS_EncapsulatedContentInfo_it, | ||
| 1220 | }, | ||
| 1221 | }; | ||
| 1222 | |||
| 1223 | const ASN1_ITEM CMS_CompressedData_it = { | ||
| 1224 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1225 | .utype = V_ASN1_SEQUENCE, | ||
| 1226 | .templates = CMS_CompressedData_seq_tt, | ||
| 1227 | .tcount = sizeof(CMS_CompressedData_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1228 | .funcs = NULL, | ||
| 1229 | .size = sizeof(CMS_CompressedData), | ||
| 1230 | .sname = "CMS_CompressedData", | ||
| 1231 | }; | ||
| 310 | 1232 | ||
| 311 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ | 1233 | /* This is the ANY DEFINED BY table for the top level ContentInfo structure */ |
| 312 | 1234 | ||
| 313 | ASN1_ADB_TEMPLATE(cms_default) = ASN1_EXP(CMS_ContentInfo, d.other, ASN1_ANY, 0); | 1235 | static const ASN1_TEMPLATE cms_default_tt = { |
| 1236 | .flags = ASN1_TFLG_EXPLICIT, | ||
| 1237 | .tag = 0, | ||
| 1238 | .offset = offsetof(CMS_ContentInfo, d.other), | ||
| 1239 | .field_name = "d.other", | ||
| 1240 | .item = &ASN1_ANY_it, | ||
| 1241 | }; | ||
| 314 | 1242 | ||
| 315 | ASN1_ADB(CMS_ContentInfo) = { | 1243 | static const ASN1_ADB_TABLE CMS_ContentInfo_adbtbl[] = { |
| 316 | ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP(CMS_ContentInfo, d.data, ASN1_OCTET_STRING_NDEF, 0)), | 1244 | { |
| 317 | ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP(CMS_ContentInfo, d.signedData, CMS_SignedData, 0)), | 1245 | .value = NID_pkcs7_data, |
| 318 | ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP(CMS_ContentInfo, d.envelopedData, CMS_EnvelopedData, 0)), | 1246 | .tt = { |
| 319 | ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP(CMS_ContentInfo, d.digestedData, CMS_DigestedData, 0)), | 1247 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, |
| 320 | ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP(CMS_ContentInfo, d.encryptedData, CMS_EncryptedData, 0)), | 1248 | .tag = 0, |
| 321 | ADB_ENTRY(NID_id_smime_ct_authData, ASN1_NDEF_EXP(CMS_ContentInfo, d.authenticatedData, CMS_AuthenticatedData, 0)), | 1249 | .offset = offsetof(CMS_ContentInfo, d.data), |
| 322 | ADB_ENTRY(NID_id_smime_ct_compressedData, ASN1_NDEF_EXP(CMS_ContentInfo, d.compressedData, CMS_CompressedData, 0)), | 1250 | .field_name = "d.data", |
| 323 | } ASN1_ADB_END(CMS_ContentInfo, 0, contentType, 0, &cms_default_tt, NULL); | 1251 | .item = &ASN1_OCTET_STRING_NDEF_it, |
| 1252 | }, | ||
| 1253 | |||
| 1254 | }, | ||
| 1255 | { | ||
| 1256 | .value = NID_pkcs7_signed, | ||
| 1257 | .tt = { | ||
| 1258 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1259 | .tag = 0, | ||
| 1260 | .offset = offsetof(CMS_ContentInfo, d.signedData), | ||
| 1261 | .field_name = "d.signedData", | ||
| 1262 | .item = &CMS_SignedData_it, | ||
| 1263 | }, | ||
| 1264 | |||
| 1265 | }, | ||
| 1266 | { | ||
| 1267 | .value = NID_pkcs7_enveloped, | ||
| 1268 | .tt = { | ||
| 1269 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1270 | .tag = 0, | ||
| 1271 | .offset = offsetof(CMS_ContentInfo, d.envelopedData), | ||
| 1272 | .field_name = "d.envelopedData", | ||
| 1273 | .item = &CMS_EnvelopedData_it, | ||
| 1274 | }, | ||
| 1275 | |||
| 1276 | }, | ||
| 1277 | { | ||
| 1278 | .value = NID_pkcs7_digest, | ||
| 1279 | .tt = { | ||
| 1280 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1281 | .tag = 0, | ||
| 1282 | .offset = offsetof(CMS_ContentInfo, d.digestedData), | ||
| 1283 | .field_name = "d.digestedData", | ||
| 1284 | .item = &CMS_DigestedData_it, | ||
| 1285 | }, | ||
| 1286 | |||
| 1287 | }, | ||
| 1288 | { | ||
| 1289 | .value = NID_pkcs7_encrypted, | ||
| 1290 | .tt = { | ||
| 1291 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1292 | .tag = 0, | ||
| 1293 | .offset = offsetof(CMS_ContentInfo, d.encryptedData), | ||
| 1294 | .field_name = "d.encryptedData", | ||
| 1295 | .item = &CMS_EncryptedData_it, | ||
| 1296 | }, | ||
| 1297 | |||
| 1298 | }, | ||
| 1299 | { | ||
| 1300 | .value = NID_id_smime_ct_authData, | ||
| 1301 | .tt = { | ||
| 1302 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1303 | .tag = 0, | ||
| 1304 | .offset = offsetof(CMS_ContentInfo, d.authenticatedData), | ||
| 1305 | .field_name = "d.authenticatedData", | ||
| 1306 | .item = &CMS_AuthenticatedData_it, | ||
| 1307 | }, | ||
| 1308 | |||
| 1309 | }, | ||
| 1310 | { | ||
| 1311 | .value = NID_id_smime_ct_compressedData, | ||
| 1312 | .tt = { | ||
| 1313 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_NDEF, | ||
| 1314 | .tag = 0, | ||
| 1315 | .offset = offsetof(CMS_ContentInfo, d.compressedData), | ||
| 1316 | .field_name = "d.compressedData", | ||
| 1317 | .item = &CMS_CompressedData_it, | ||
| 1318 | }, | ||
| 1319 | |||
| 1320 | }, | ||
| 1321 | }; | ||
| 1322 | |||
| 1323 | static const ASN1_ADB CMS_ContentInfo_adb = { | ||
| 1324 | .flags = 0, | ||
| 1325 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
| 1326 | .app_items = 0, | ||
| 1327 | .tbl = CMS_ContentInfo_adbtbl, | ||
| 1328 | .tblcount = sizeof(CMS_ContentInfo_adbtbl) / sizeof(ASN1_ADB_TABLE), | ||
| 1329 | .default_tt = &cms_default_tt, | ||
| 1330 | .null_tt = NULL, | ||
| 1331 | }; | ||
| 324 | 1332 | ||
| 325 | /* CMS streaming support */ | 1333 | /* CMS streaming support */ |
| 326 | static int | 1334 | static int |
| @@ -354,10 +1362,40 @@ cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
| 354 | return 1; | 1362 | return 1; |
| 355 | } | 1363 | } |
| 356 | 1364 | ||
| 357 | ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | 1365 | static const ASN1_AUX CMS_ContentInfo_aux = { |
| 358 | ASN1_SIMPLE(CMS_ContentInfo, contentType, ASN1_OBJECT), | 1366 | .app_data = NULL, |
| 359 | ASN1_ADB_OBJECT(CMS_ContentInfo) | 1367 | .flags = 0, |
| 360 | } ASN1_NDEF_SEQUENCE_END_cb(CMS_ContentInfo, CMS_ContentInfo) | 1368 | .ref_offset = 0, |
| 1369 | .ref_lock = 0, | ||
| 1370 | .asn1_cb = cms_cb, | ||
| 1371 | .enc_offset = 0, | ||
| 1372 | }; | ||
| 1373 | static const ASN1_TEMPLATE CMS_ContentInfo_seq_tt[] = { | ||
| 1374 | { | ||
| 1375 | .flags = 0, | ||
| 1376 | .tag = 0, | ||
| 1377 | .offset = offsetof(CMS_ContentInfo, contentType), | ||
| 1378 | .field_name = "contentType", | ||
| 1379 | .item = &ASN1_OBJECT_it, | ||
| 1380 | }, | ||
| 1381 | { | ||
| 1382 | .flags = ASN1_TFLG_ADB_OID, | ||
| 1383 | .tag = -1, | ||
| 1384 | .offset = 0, | ||
| 1385 | .field_name = "CMS_ContentInfo", | ||
| 1386 | .item = (const ASN1_ITEM *)&CMS_ContentInfo_adb, | ||
| 1387 | }, | ||
| 1388 | }; | ||
| 1389 | |||
| 1390 | const ASN1_ITEM CMS_ContentInfo_it = { | ||
| 1391 | .itype = ASN1_ITYPE_NDEF_SEQUENCE, | ||
| 1392 | .utype = V_ASN1_SEQUENCE, | ||
| 1393 | .templates = CMS_ContentInfo_seq_tt, | ||
| 1394 | .tcount = sizeof(CMS_ContentInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1395 | .funcs = &CMS_ContentInfo_aux, | ||
| 1396 | .size = sizeof(CMS_ContentInfo), | ||
| 1397 | .sname = "CMS_ContentInfo", | ||
| 1398 | }; | ||
| 361 | 1399 | ||
| 362 | /* Specials for signed attributes */ | 1400 | /* Specials for signed attributes */ |
| 363 | 1401 | ||
| @@ -366,38 +1404,144 @@ ASN1_NDEF_SEQUENCE_cb(CMS_ContentInfo, cms_cb) = { | |||
| 366 | * encoding. | 1404 | * encoding. |
| 367 | */ | 1405 | */ |
| 368 | 1406 | ||
| 369 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Sign) = | 1407 | static const ASN1_TEMPLATE CMS_Attributes_Sign_item_tt = { |
| 370 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1408 | .flags = ASN1_TFLG_SET_ORDER, |
| 371 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Sign) | 1409 | .tag = 0, |
| 1410 | .offset = 0, | ||
| 1411 | .field_name = "CMS_ATTRIBUTES", | ||
| 1412 | .item = &X509_ATTRIBUTE_it, | ||
| 1413 | }; | ||
| 1414 | |||
| 1415 | const ASN1_ITEM CMS_Attributes_Sign_it = { | ||
| 1416 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
| 1417 | .utype = -1, | ||
| 1418 | .templates = &CMS_Attributes_Sign_item_tt, | ||
| 1419 | .tcount = 0, | ||
| 1420 | .funcs = NULL, | ||
| 1421 | .size = 0, | ||
| 1422 | .sname = "CMS_Attributes_Sign", | ||
| 1423 | }; | ||
| 372 | 1424 | ||
| 373 | /* | 1425 | /* |
| 374 | * When verifying attributes we need to use the received order. So we use | 1426 | * When verifying attributes we need to use the received order. So we use |
| 375 | * SEQUENCE OF and tag it to SET OF | 1427 | * SEQUENCE OF and tag it to SET OF |
| 376 | */ | 1428 | */ |
| 377 | 1429 | ||
| 378 | ASN1_ITEM_TEMPLATE(CMS_Attributes_Verify) = | 1430 | static const ASN1_TEMPLATE CMS_Attributes_Verify_item_tt = { |
| 379 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, V_ASN1_SET, CMS_ATTRIBUTES, X509_ATTRIBUTE) | 1431 | .flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, |
| 380 | ASN1_ITEM_TEMPLATE_END(CMS_Attributes_Verify) | 1432 | .tag = V_ASN1_SET, |
| 1433 | .offset = 0, | ||
| 1434 | .field_name = "CMS_ATTRIBUTES", | ||
| 1435 | .item = &X509_ATTRIBUTE_it, | ||
| 1436 | }; | ||
| 381 | 1437 | ||
| 1438 | const ASN1_ITEM CMS_Attributes_Verify_it = { | ||
| 1439 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
| 1440 | .utype = -1, | ||
| 1441 | .templates = &CMS_Attributes_Verify_item_tt, | ||
| 1442 | .tcount = 0, | ||
| 1443 | .funcs = NULL, | ||
| 1444 | .size = 0, | ||
| 1445 | .sname = "CMS_Attributes_Verify", | ||
| 1446 | }; | ||
| 382 | 1447 | ||
| 383 | 1448 | ||
| 384 | ASN1_CHOICE(CMS_ReceiptsFrom) = { | 1449 | |
| 1450 | static const ASN1_TEMPLATE CMS_ReceiptsFrom_ch_tt[] = { | ||
| 385 | ASN1_IMP_EMBED(CMS_ReceiptsFrom, d.allOrFirstTier, INT32, 0), | 1451 | ASN1_IMP_EMBED(CMS_ReceiptsFrom, d.allOrFirstTier, INT32, 0), |
| 386 | ASN1_IMP_SEQUENCE_OF(CMS_ReceiptsFrom, d.receiptList, GENERAL_NAMES, 1) | 1452 | { |
| 387 | } static_ASN1_CHOICE_END(CMS_ReceiptsFrom) | 1453 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF, |
| 388 | 1454 | .tag = 1, | |
| 389 | ASN1_SEQUENCE(CMS_ReceiptRequest) = { | 1455 | .offset = offsetof(CMS_ReceiptsFrom, d.receiptList), |
| 390 | ASN1_SIMPLE(CMS_ReceiptRequest, signedContentIdentifier, ASN1_OCTET_STRING), | 1456 | .field_name = "d.receiptList", |
| 391 | ASN1_SIMPLE(CMS_ReceiptRequest, receiptsFrom, CMS_ReceiptsFrom), | 1457 | .item = &GENERAL_NAMES_it, |
| 392 | ASN1_SEQUENCE_OF(CMS_ReceiptRequest, receiptsTo, GENERAL_NAMES) | 1458 | }, |
| 393 | } ASN1_SEQUENCE_END(CMS_ReceiptRequest) | 1459 | }; |
| 394 | 1460 | ||
| 395 | ASN1_SEQUENCE(CMS_Receipt) = { | 1461 | static const ASN1_ITEM CMS_ReceiptsFrom_it = { |
| 396 | ASN1_EMBED(CMS_Receipt, version, INT32), | 1462 | .itype = ASN1_ITYPE_CHOICE, |
| 397 | ASN1_SIMPLE(CMS_Receipt, contentType, ASN1_OBJECT), | 1463 | .utype = offsetof(CMS_ReceiptsFrom, type), |
| 398 | ASN1_SIMPLE(CMS_Receipt, signedContentIdentifier, ASN1_OCTET_STRING), | 1464 | .templates = CMS_ReceiptsFrom_ch_tt, |
| 399 | ASN1_SIMPLE(CMS_Receipt, originatorSignatureValue, ASN1_OCTET_STRING) | 1465 | .tcount = sizeof(CMS_ReceiptsFrom_ch_tt) / sizeof(ASN1_TEMPLATE), |
| 400 | } ASN1_SEQUENCE_END(CMS_Receipt) | 1466 | .funcs = NULL, |
| 1467 | .size = sizeof(CMS_ReceiptsFrom), | ||
| 1468 | .sname = "CMS_ReceiptsFrom", | ||
| 1469 | }; | ||
| 1470 | |||
| 1471 | static const ASN1_TEMPLATE CMS_ReceiptRequest_seq_tt[] = { | ||
| 1472 | { | ||
| 1473 | .flags = 0, | ||
| 1474 | .tag = 0, | ||
| 1475 | .offset = offsetof(CMS_ReceiptRequest, signedContentIdentifier), | ||
| 1476 | .field_name = "signedContentIdentifier", | ||
| 1477 | .item = &ASN1_OCTET_STRING_it, | ||
| 1478 | }, | ||
| 1479 | { | ||
| 1480 | .flags = 0, | ||
| 1481 | .tag = 0, | ||
| 1482 | .offset = offsetof(CMS_ReceiptRequest, receiptsFrom), | ||
| 1483 | .field_name = "receiptsFrom", | ||
| 1484 | .item = &CMS_ReceiptsFrom_it, | ||
| 1485 | }, | ||
| 1486 | { | ||
| 1487 | .flags = ASN1_TFLG_SEQUENCE_OF, | ||
| 1488 | .tag = 0, | ||
| 1489 | .offset = offsetof(CMS_ReceiptRequest, receiptsTo), | ||
| 1490 | .field_name = "receiptsTo", | ||
| 1491 | .item = &GENERAL_NAMES_it, | ||
| 1492 | }, | ||
| 1493 | }; | ||
| 1494 | |||
| 1495 | const ASN1_ITEM CMS_ReceiptRequest_it = { | ||
| 1496 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 1497 | .utype = V_ASN1_SEQUENCE, | ||
| 1498 | .templates = CMS_ReceiptRequest_seq_tt, | ||
| 1499 | .tcount = sizeof(CMS_ReceiptRequest_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1500 | .funcs = NULL, | ||
| 1501 | .size = sizeof(CMS_ReceiptRequest), | ||
| 1502 | .sname = "CMS_ReceiptRequest", | ||
| 1503 | }; | ||
| 1504 | |||
| 1505 | static const ASN1_TEMPLATE CMS_Receipt_seq_tt[] = { | ||
| 1506 | { | ||
| 1507 | .flags = 0, | ||
| 1508 | .tag = 0, | ||
| 1509 | .offset = offsetof(CMS_Receipt, version), | ||
| 1510 | .field_name = "version", | ||
| 1511 | .item = &INT32_it, | ||
| 1512 | }, | ||
| 1513 | { | ||
| 1514 | .flags = 0, | ||
| 1515 | .tag = 0, | ||
| 1516 | .offset = offsetof(CMS_Receipt, contentType), | ||
| 1517 | .field_name = "contentType", | ||
| 1518 | .item = &ASN1_OBJECT_it, | ||
| 1519 | }, | ||
| 1520 | { | ||
| 1521 | .flags = 0, | ||
| 1522 | .tag = 0, | ||
| 1523 | .offset = offsetof(CMS_Receipt, signedContentIdentifier), | ||
| 1524 | .field_name = "signedContentIdentifier", | ||
| 1525 | .item = &ASN1_OCTET_STRING_it, | ||
| 1526 | }, | ||
| 1527 | { | ||
| 1528 | .flags = 0, | ||
| 1529 | .tag = 0, | ||
| 1530 | .offset = offsetof(CMS_Receipt, originatorSignatureValue), | ||
| 1531 | .field_name = "originatorSignatureValue", | ||
| 1532 | .item = &ASN1_OCTET_STRING_it, | ||
| 1533 | }, | ||
| 1534 | }; | ||
| 1535 | |||
| 1536 | const ASN1_ITEM CMS_Receipt_it = { | ||
| 1537 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 1538 | .utype = V_ASN1_SEQUENCE, | ||
| 1539 | .templates = CMS_Receipt_seq_tt, | ||
| 1540 | .tcount = sizeof(CMS_Receipt_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1541 | .funcs = NULL, | ||
| 1542 | .size = sizeof(CMS_Receipt), | ||
| 1543 | .sname = "CMS_Receipt", | ||
| 1544 | }; | ||
| 401 | 1545 | ||
| 402 | /* | 1546 | /* |
| 403 | * Utilities to encode the CMS_SharedInfo structure used during key | 1547 | * Utilities to encode the CMS_SharedInfo structure used during key |
| @@ -410,11 +1554,39 @@ typedef struct { | |||
| 410 | ASN1_OCTET_STRING *suppPubInfo; | 1554 | ASN1_OCTET_STRING *suppPubInfo; |
| 411 | } CMS_SharedInfo; | 1555 | } CMS_SharedInfo; |
| 412 | 1556 | ||
| 413 | ASN1_SEQUENCE(CMS_SharedInfo) = { | 1557 | static const ASN1_TEMPLATE CMS_SharedInfo_seq_tt[] = { |
| 414 | ASN1_SIMPLE(CMS_SharedInfo, keyInfo, X509_ALGOR), | 1558 | { |
| 415 | ASN1_EXP_OPT(CMS_SharedInfo, entityUInfo, ASN1_OCTET_STRING, 0), | 1559 | .flags = 0, |
| 416 | ASN1_EXP_OPT(CMS_SharedInfo, suppPubInfo, ASN1_OCTET_STRING, 2), | 1560 | .tag = 0, |
| 417 | } static_ASN1_SEQUENCE_END(CMS_SharedInfo) | 1561 | .offset = offsetof(CMS_SharedInfo, keyInfo), |
| 1562 | .field_name = "keyInfo", | ||
| 1563 | .item = &X509_ALGOR_it, | ||
| 1564 | }, | ||
| 1565 | { | ||
| 1566 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 1567 | .tag = 0, | ||
| 1568 | .offset = offsetof(CMS_SharedInfo, entityUInfo), | ||
| 1569 | .field_name = "entityUInfo", | ||
| 1570 | .item = &ASN1_OCTET_STRING_it, | ||
| 1571 | }, | ||
| 1572 | { | ||
| 1573 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
| 1574 | .tag = 2, | ||
| 1575 | .offset = offsetof(CMS_SharedInfo, suppPubInfo), | ||
| 1576 | .field_name = "suppPubInfo", | ||
| 1577 | .item = &ASN1_OCTET_STRING_it, | ||
| 1578 | }, | ||
| 1579 | }; | ||
| 1580 | |||
| 1581 | static const ASN1_ITEM CMS_SharedInfo_it = { | ||
| 1582 | .itype = ASN1_ITYPE_SEQUENCE, | ||
| 1583 | .utype = V_ASN1_SEQUENCE, | ||
| 1584 | .templates = CMS_SharedInfo_seq_tt, | ||
| 1585 | .tcount = sizeof(CMS_SharedInfo_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
| 1586 | .funcs = NULL, | ||
| 1587 | .size = sizeof(CMS_SharedInfo), | ||
| 1588 | .sname = "CMS_SharedInfo", | ||
| 1589 | }; | ||
| 418 | 1590 | ||
| 419 | int | 1591 | int |
| 420 | CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, | 1592 | CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, |
| @@ -445,5 +1617,5 @@ CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, | |||
| 445 | ecsi.suppPubInfo = &oklen; | 1617 | ecsi.suppPubInfo = &oklen; |
| 446 | intsi.pecsi = &ecsi; | 1618 | intsi.pecsi = &ecsi; |
| 447 | 1619 | ||
| 448 | return ASN1_item_i2d(intsi.a, pder, ASN1_ITEM_rptr(CMS_SharedInfo)); | 1620 | return ASN1_item_i2d(intsi.a, pder, &CMS_SharedInfo_it); |
| 449 | } | 1621 | } |
diff --git a/src/lib/libcrypto/cms/cms_ess.c b/src/lib/libcrypto/cms/cms_ess.c index abfd170bb4..5f0ab4995b 100644 --- a/src/lib/libcrypto/cms/cms_ess.c +++ b/src/lib/libcrypto/cms/cms_ess.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_ess.c,v 1.14 2019/08/10 18:15:52 jsing Exp $ */ | 1 | /* $OpenBSD: cms_ess.c,v 1.15 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -61,7 +61,31 @@ | |||
| 61 | #include <openssl/cms.h> | 61 | #include <openssl/cms.h> |
| 62 | #include "cms_lcl.h" | 62 | #include "cms_lcl.h" |
| 63 | 63 | ||
| 64 | IMPLEMENT_ASN1_FUNCTIONS(CMS_ReceiptRequest) | 64 | |
| 65 | CMS_ReceiptRequest * | ||
| 66 | d2i_CMS_ReceiptRequest(CMS_ReceiptRequest **a, const unsigned char **in, long len) | ||
| 67 | { | ||
| 68 | return (CMS_ReceiptRequest *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 69 | &CMS_ReceiptRequest_it); | ||
| 70 | } | ||
| 71 | |||
| 72 | int | ||
| 73 | i2d_CMS_ReceiptRequest(CMS_ReceiptRequest *a, unsigned char **out) | ||
| 74 | { | ||
| 75 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &CMS_ReceiptRequest_it); | ||
| 76 | } | ||
| 77 | |||
| 78 | CMS_ReceiptRequest * | ||
| 79 | CMS_ReceiptRequest_new(void) | ||
| 80 | { | ||
| 81 | return (CMS_ReceiptRequest *)ASN1_item_new(&CMS_ReceiptRequest_it); | ||
| 82 | } | ||
| 83 | |||
| 84 | void | ||
| 85 | CMS_ReceiptRequest_free(CMS_ReceiptRequest *a) | ||
| 86 | { | ||
| 87 | ASN1_item_free((ASN1_VALUE *)a, &CMS_ReceiptRequest_it); | ||
| 88 | } | ||
| 65 | 89 | ||
| 66 | /* ESS services: for now just Signed Receipt related */ | 90 | /* ESS services: for now just Signed Receipt related */ |
| 67 | 91 | ||
| @@ -78,7 +102,7 @@ CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr) | |||
| 78 | if (!str) | 102 | if (!str) |
| 79 | return 0; | 103 | return 0; |
| 80 | 104 | ||
| 81 | rr = ASN1_item_unpack(str, ASN1_ITEM_rptr(CMS_ReceiptRequest)); | 105 | rr = ASN1_item_unpack(str, &CMS_ReceiptRequest_it); |
| 82 | if (!rr) | 106 | if (!rr) |
| 83 | return -1; | 107 | return -1; |
| 84 | if (prr) | 108 | if (prr) |
| @@ -185,7 +209,7 @@ cms_msgSigDigest(CMS_SignerInfo *si, unsigned char *dig, unsigned int *diglen) | |||
| 185 | md = EVP_get_digestbyobj(si->digestAlgorithm->algorithm); | 209 | md = EVP_get_digestbyobj(si->digestAlgorithm->algorithm); |
| 186 | if (md == NULL) | 210 | if (md == NULL) |
| 187 | return 0; | 211 | return 0; |
| 188 | if (!ASN1_item_digest(ASN1_ITEM_rptr(CMS_Attributes_Verify), md, | 212 | if (!ASN1_item_digest(&CMS_Attributes_Verify_it, md, |
| 189 | si->signedAttrs, dig, diglen)) | 213 | si->signedAttrs, dig, diglen)) |
| 190 | return 0; | 214 | return 0; |
| 191 | 215 | ||
| @@ -252,7 +276,7 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) | |||
| 252 | goto err; | 276 | goto err; |
| 253 | } | 277 | } |
| 254 | 278 | ||
| 255 | rct = ASN1_item_unpack(*pcont, ASN1_ITEM_rptr(CMS_Receipt)); | 279 | rct = ASN1_item_unpack(*pcont, &CMS_Receipt_it); |
| 256 | 280 | ||
| 257 | if (!rct) { | 281 | if (!rct) { |
| 258 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_RECEIPT_DECODE_ERROR); | 282 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_RECEIPT_DECODE_ERROR); |
| @@ -373,7 +397,7 @@ cms_encode_Receipt(CMS_SignerInfo *si) | |||
| 373 | rct.signedContentIdentifier = rr->signedContentIdentifier; | 397 | rct.signedContentIdentifier = rr->signedContentIdentifier; |
| 374 | rct.originatorSignatureValue = si->signature; | 398 | rct.originatorSignatureValue = si->signature; |
| 375 | 399 | ||
| 376 | os = ASN1_item_pack(&rct, ASN1_ITEM_rptr(CMS_Receipt), NULL); | 400 | os = ASN1_item_pack(&rct, &CMS_Receipt_it, NULL); |
| 377 | 401 | ||
| 378 | err: | 402 | err: |
| 379 | CMS_ReceiptRequest_free(rr); | 403 | CMS_ReceiptRequest_free(rr); |
diff --git a/src/lib/libcrypto/cms/cms_io.c b/src/lib/libcrypto/cms/cms_io.c index 5528ca04be..6eba856867 100644 --- a/src/lib/libcrypto/cms/cms_io.c +++ b/src/lib/libcrypto/cms/cms_io.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_io.c,v 1.9 2019/08/10 18:15:52 jsing Exp $ */ | 1 | /* $OpenBSD: cms_io.c,v 1.10 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -82,22 +82,49 @@ CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) | |||
| 82 | CMS_ContentInfo * | 82 | CMS_ContentInfo * |
| 83 | d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) | 83 | d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) |
| 84 | { | 84 | { |
| 85 | return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); | 85 | return ASN1_item_d2i_bio(&CMS_ContentInfo_it, bp, cms); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | int | 88 | int |
| 89 | i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) | 89 | i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) |
| 90 | { | 90 | { |
| 91 | return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); | 91 | return ASN1_item_i2d_bio(&CMS_ContentInfo_it, bp, cms); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo) | 94 | |
| 95 | CMS_ContentInfo * | ||
| 96 | PEM_read_bio_CMS(BIO *bp, CMS_ContentInfo **x, pem_password_cb *cb, void *u) | ||
| 97 | { | ||
| 98 | return PEM_ASN1_read_bio((d2i_of_void *)d2i_CMS_ContentInfo, PEM_STRING_CMS, bp, | ||
| 99 | (void **)x, cb, u); | ||
| 100 | } | ||
| 101 | |||
| 102 | CMS_ContentInfo * | ||
| 103 | PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, pem_password_cb *cb, void *u) | ||
| 104 | { | ||
| 105 | return PEM_ASN1_read((d2i_of_void *)d2i_CMS_ContentInfo, PEM_STRING_CMS, fp, | ||
| 106 | (void **)x, cb, u); | ||
| 107 | } | ||
| 108 | |||
| 109 | int | ||
| 110 | PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x) | ||
| 111 | { | ||
| 112 | return PEM_ASN1_write_bio((i2d_of_void *)i2d_CMS_ContentInfo, PEM_STRING_CMS, bp, | ||
| 113 | (void *)x, NULL, NULL, 0, NULL, NULL); | ||
| 114 | } | ||
| 115 | |||
| 116 | int | ||
| 117 | PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x) | ||
| 118 | { | ||
| 119 | return PEM_ASN1_write((i2d_of_void *)i2d_CMS_ContentInfo, PEM_STRING_CMS, fp, | ||
| 120 | (void *)x, NULL, NULL, 0, NULL, NULL); | ||
| 121 | } | ||
| 95 | 122 | ||
| 96 | BIO * | 123 | BIO * |
| 97 | BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) | 124 | BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) |
| 98 | { | 125 | { |
| 99 | return BIO_new_NDEF(out, (ASN1_VALUE *)cms, | 126 | return BIO_new_NDEF(out, (ASN1_VALUE *)cms, |
| 100 | ASN1_ITEM_rptr(CMS_ContentInfo)); | 127 | &CMS_ContentInfo_it); |
| 101 | } | 128 | } |
| 102 | 129 | ||
| 103 | /* CMS wrappers round generalised stream and MIME routines */ | 130 | /* CMS wrappers round generalised stream and MIME routines */ |
| @@ -105,14 +132,14 @@ BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) | |||
| 105 | int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) | 132 | int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) |
| 106 | { | 133 | { |
| 107 | return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, | 134 | return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, |
| 108 | ASN1_ITEM_rptr(CMS_ContentInfo)); | 135 | &CMS_ContentInfo_it); |
| 109 | } | 136 | } |
| 110 | 137 | ||
| 111 | int | 138 | int |
| 112 | PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) | 139 | PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) |
| 113 | { | 140 | { |
| 114 | return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, | 141 | return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, |
| 115 | "CMS", ASN1_ITEM_rptr(CMS_ContentInfo)); | 142 | "CMS", &CMS_ContentInfo_it); |
| 116 | } | 143 | } |
| 117 | 144 | ||
| 118 | int | 145 | int |
| @@ -128,12 +155,12 @@ SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags) | |||
| 128 | mdalgs = NULL; | 155 | mdalgs = NULL; |
| 129 | 156 | ||
| 130 | return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, | 157 | return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, |
| 131 | econt_nid, mdalgs, ASN1_ITEM_rptr(CMS_ContentInfo)); | 158 | econt_nid, mdalgs, &CMS_ContentInfo_it); |
| 132 | } | 159 | } |
| 133 | 160 | ||
| 134 | CMS_ContentInfo * | 161 | CMS_ContentInfo * |
| 135 | SMIME_read_CMS(BIO *bio, BIO **bcont) | 162 | SMIME_read_CMS(BIO *bio, BIO **bcont) |
| 136 | { | 163 | { |
| 137 | return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, | 164 | return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, |
| 138 | ASN1_ITEM_rptr(CMS_ContentInfo)); | 165 | &CMS_ContentInfo_it); |
| 139 | } | 166 | } |
diff --git a/src/lib/libcrypto/cms/cms_lcl.h b/src/lib/libcrypto/cms/cms_lcl.h index 6504ee31a1..b46290af3e 100644 --- a/src/lib/libcrypto/cms/cms_lcl.h +++ b/src/lib/libcrypto/cms/cms_lcl.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_lcl.h,v 1.9 2019/08/11 08:15:27 jsing Exp $ */ | 1 | /* $OpenBSD: cms_lcl.h,v 1.10 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -386,14 +386,19 @@ struct CMS_Receipt_st { | |||
| 386 | ASN1_OCTET_STRING *originatorSignatureValue; | 386 | ASN1_OCTET_STRING *originatorSignatureValue; |
| 387 | }; | 387 | }; |
| 388 | 388 | ||
| 389 | DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) | 389 | CMS_ContentInfo *CMS_ContentInfo_new(void); |
| 390 | DECLARE_ASN1_ITEM(CMS_SignerInfo) | 390 | void CMS_ContentInfo_free(CMS_ContentInfo *a); |
| 391 | DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) | 391 | CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a, const unsigned char **in, long len); |
| 392 | DECLARE_ASN1_ITEM(CMS_Attributes_Sign) | 392 | int i2d_CMS_ContentInfo(CMS_ContentInfo *a, unsigned char **out); |
| 393 | DECLARE_ASN1_ITEM(CMS_Attributes_Verify) | 393 | extern const ASN1_ITEM CMS_ContentInfo_it; |
| 394 | DECLARE_ASN1_ITEM(CMS_RecipientInfo) | 394 | extern const ASN1_ITEM CMS_SignerInfo_it; |
| 395 | DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo) | 395 | extern const ASN1_ITEM CMS_IssuerAndSerialNumber_it; |
| 396 | DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber) | 396 | extern const ASN1_ITEM CMS_Attributes_Sign_it; |
| 397 | extern const ASN1_ITEM CMS_Attributes_Verify_it; | ||
| 398 | extern const ASN1_ITEM CMS_RecipientInfo_it; | ||
| 399 | extern const ASN1_ITEM CMS_PasswordRecipientInfo_it; | ||
| 400 | CMS_IssuerAndSerialNumber *CMS_IssuerAndSerialNumber_new(void); | ||
| 401 | void CMS_IssuerAndSerialNumber_free(CMS_IssuerAndSerialNumber *a); | ||
| 397 | 402 | ||
| 398 | #define CMS_SIGNERINFO_ISSUER_SERIAL 0 | 403 | #define CMS_SIGNERINFO_ISSUER_SERIAL 0 |
| 399 | #define CMS_SIGNERINFO_KEYIDENTIFIER 1 | 404 | #define CMS_SIGNERINFO_KEYIDENTIFIER 1 |
| @@ -457,21 +462,21 @@ int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); | |||
| 457 | int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, | 462 | int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, |
| 458 | int en_de); | 463 | int en_de); |
| 459 | 464 | ||
| 460 | DECLARE_ASN1_ITEM(CMS_CertificateChoices) | 465 | extern const ASN1_ITEM CMS_CertificateChoices_it; |
| 461 | DECLARE_ASN1_ITEM(CMS_DigestedData) | 466 | extern const ASN1_ITEM CMS_DigestedData_it; |
| 462 | DECLARE_ASN1_ITEM(CMS_EncryptedData) | 467 | extern const ASN1_ITEM CMS_EncryptedData_it; |
| 463 | DECLARE_ASN1_ITEM(CMS_EnvelopedData) | 468 | extern const ASN1_ITEM CMS_EnvelopedData_it; |
| 464 | DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo) | 469 | extern const ASN1_ITEM CMS_KEKRecipientInfo_it; |
| 465 | DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo) | 470 | extern const ASN1_ITEM CMS_KeyAgreeRecipientInfo_it; |
| 466 | DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo) | 471 | extern const ASN1_ITEM CMS_KeyTransRecipientInfo_it; |
| 467 | DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey) | 472 | extern const ASN1_ITEM CMS_OriginatorPublicKey_it; |
| 468 | DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute) | 473 | extern const ASN1_ITEM CMS_OtherKeyAttribute_it; |
| 469 | DECLARE_ASN1_ITEM(CMS_Receipt) | 474 | extern const ASN1_ITEM CMS_Receipt_it; |
| 470 | DECLARE_ASN1_ITEM(CMS_ReceiptRequest) | 475 | extern const ASN1_ITEM CMS_ReceiptRequest_it; |
| 471 | DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey) | 476 | extern const ASN1_ITEM CMS_RecipientEncryptedKey_it; |
| 472 | DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier) | 477 | extern const ASN1_ITEM CMS_RecipientKeyIdentifier_it; |
| 473 | DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) | 478 | extern const ASN1_ITEM CMS_RevocationInfoChoice_it; |
| 474 | DECLARE_ASN1_ITEM(CMS_SignedData) | 479 | extern const ASN1_ITEM CMS_SignedData_it; |
| 475 | DECLARE_ASN1_ITEM(CMS_CompressedData) | 480 | extern const ASN1_ITEM CMS_CompressedData_it; |
| 476 | 481 | ||
| 477 | #endif | 482 | #endif |
diff --git a/src/lib/libcrypto/cms/cms_lib.c b/src/lib/libcrypto/cms/cms_lib.c index 71c6796dbb..7f02d6daae 100644 --- a/src/lib/libcrypto/cms/cms_lib.c +++ b/src/lib/libcrypto/cms/cms_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_lib.c,v 1.10 2019/08/10 18:15:52 jsing Exp $ */ | 1 | /* $OpenBSD: cms_lib.c,v 1.11 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -61,8 +61,38 @@ | |||
| 61 | #include <openssl/cms.h> | 61 | #include <openssl/cms.h> |
| 62 | #include "cms_lcl.h" | 62 | #include "cms_lcl.h" |
| 63 | 63 | ||
| 64 | IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo) | 64 | |
| 65 | IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo) | 65 | CMS_ContentInfo * |
| 66 | d2i_CMS_ContentInfo(CMS_ContentInfo **a, const unsigned char **in, long len) | ||
| 67 | { | ||
| 68 | return (CMS_ContentInfo *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 69 | &CMS_ContentInfo_it); | ||
| 70 | } | ||
| 71 | |||
| 72 | int | ||
| 73 | i2d_CMS_ContentInfo(CMS_ContentInfo *a, unsigned char **out) | ||
| 74 | { | ||
| 75 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &CMS_ContentInfo_it); | ||
| 76 | } | ||
| 77 | |||
| 78 | CMS_ContentInfo * | ||
| 79 | CMS_ContentInfo_new(void) | ||
| 80 | { | ||
| 81 | return (CMS_ContentInfo *)ASN1_item_new(&CMS_ContentInfo_it); | ||
| 82 | } | ||
| 83 | |||
| 84 | void | ||
| 85 | CMS_ContentInfo_free(CMS_ContentInfo *a) | ||
| 86 | { | ||
| 87 | ASN1_item_free((ASN1_VALUE *)a, &CMS_ContentInfo_it); | ||
| 88 | } | ||
| 89 | |||
| 90 | int | ||
| 91 | CMS_ContentInfo_print_ctx(BIO *out, CMS_ContentInfo *x, int indent, const ASN1_PCTX *pctx) | ||
| 92 | { | ||
| 93 | return ASN1_item_print(out, (ASN1_VALUE *)x, indent, | ||
| 94 | &CMS_ContentInfo_it, pctx); | ||
| 95 | } | ||
| 66 | 96 | ||
| 67 | const ASN1_OBJECT * | 97 | const ASN1_OBJECT * |
| 68 | CMS_get0_type(const CMS_ContentInfo *cms) | 98 | CMS_get0_type(const CMS_ContentInfo *cms) |
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index bbad379dff..a3251f58b7 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_pwri.c,v 1.18 2019/08/11 06:47:18 jsing Exp $ */ | 1 | /* $OpenBSD: cms_pwri.c,v 1.19 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -179,7 +179,7 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, | |||
| 179 | if (pwri->keyEncryptionAlgorithm->parameter == NULL) | 179 | if (pwri->keyEncryptionAlgorithm->parameter == NULL) |
| 180 | goto merr; | 180 | goto merr; |
| 181 | 181 | ||
| 182 | if (!ASN1_item_pack(encalg, ASN1_ITEM_rptr(X509_ALGOR), | 182 | if (!ASN1_item_pack(encalg, &X509_ALGOR_it, |
| 183 | &pwri->keyEncryptionAlgorithm->parameter->value.sequence)) | 183 | &pwri->keyEncryptionAlgorithm->parameter->value.sequence)) |
| 184 | goto merr; | 184 | goto merr; |
| 185 | pwri->keyEncryptionAlgorithm->parameter->type = V_ASN1_SEQUENCE; | 185 | pwri->keyEncryptionAlgorithm->parameter->type = V_ASN1_SEQUENCE; |
| @@ -350,7 +350,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, | |||
| 350 | return 0; | 350 | return 0; |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | kekalg = ASN1_TYPE_unpack_sequence(ASN1_ITEM_rptr(X509_ALGOR), | 353 | kekalg = ASN1_TYPE_unpack_sequence(&X509_ALGOR_it, |
| 354 | algtmp->parameter); | 354 | algtmp->parameter); |
| 355 | 355 | ||
| 356 | if (kekalg == NULL) { | 356 | if (kekalg == NULL) { |
diff --git a/src/lib/libcrypto/cms/cms_sd.c b/src/lib/libcrypto/cms/cms_sd.c index 6c65844c93..2289c7e8a3 100644 --- a/src/lib/libcrypto/cms/cms_sd.c +++ b/src/lib/libcrypto/cms/cms_sd.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_sd.c,v 1.17 2019/08/10 18:15:52 jsing Exp $ */ | 1 | /* $OpenBSD: cms_sd.c,v 1.18 2019/08/11 10:15:30 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -741,7 +741,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si) | |||
| 741 | } | 741 | } |
| 742 | 742 | ||
| 743 | alen = ASN1_item_i2d((ASN1_VALUE *)si->signedAttrs, &abuf, | 743 | alen = ASN1_item_i2d((ASN1_VALUE *)si->signedAttrs, &abuf, |
| 744 | ASN1_ITEM_rptr(CMS_Attributes_Sign)); | 744 | &CMS_Attributes_Sign_it); |
| 745 | if (!abuf) | 745 | if (!abuf) |
| 746 | goto err; | 746 | goto err; |
| 747 | if (EVP_DigestSignUpdate(mctx, abuf, alen) <= 0) | 747 | if (EVP_DigestSignUpdate(mctx, abuf, alen) <= 0) |
| @@ -802,7 +802,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si) | |||
| 802 | goto err; | 802 | goto err; |
| 803 | 803 | ||
| 804 | alen = ASN1_item_i2d((ASN1_VALUE *)si->signedAttrs, &abuf, | 804 | alen = ASN1_item_i2d((ASN1_VALUE *)si->signedAttrs, &abuf, |
| 805 | ASN1_ITEM_rptr(CMS_Attributes_Verify)); | 805 | &CMS_Attributes_Verify_it); |
| 806 | if (!abuf) | 806 | if (!abuf) |
| 807 | goto err; | 807 | goto err; |
| 808 | r = EVP_DigestVerifyUpdate(mctx, abuf, alen); | 808 | r = EVP_DigestVerifyUpdate(mctx, abuf, alen); |
