diff options
| author | tb <> | 2023-07-28 10:28:02 +0000 |
|---|---|---|
| committer | tb <> | 2023-07-28 10:28:02 +0000 |
| commit | 3c8d1e1cf9bb15a3ea986b0fa3f53d33663d6c55 (patch) | |
| tree | 4805fc669f5e6c6056eecb84f7c45e854cea9dd8 /src | |
| parent | 2bca7fcf4242f1f10d0b696c606387ec84d6ccd0 (diff) | |
| download | openbsd-3c8d1e1cf9bb15a3ea986b0fa3f53d33663d6c55.tar.gz openbsd-3c8d1e1cf9bb15a3ea986b0fa3f53d33663d6c55.tar.bz2 openbsd-3c8d1e1cf9bb15a3ea986b0fa3f53d33663d6c55.zip | |
Provide CMS{,_SignerInfo}_get_version
Add accessors for the syntax versions of ContentInfo and SignerInfo.
These will be used soon in rpki-client for some more compliance checks.
ok job jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/Symbols.list | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms.h | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/cms/cms_lib.c | 45 | ||||
| -rw-r--r-- | src/lib/libcrypto/hidden/openssl/cms.h | 4 |
4 files changed, 53 insertions, 3 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index b9ce49b277..f9f1b10c22 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
| @@ -557,6 +557,7 @@ CMS_SignerInfo_get0_md_ctx | |||
| 557 | CMS_SignerInfo_get0_pkey_ctx | 557 | CMS_SignerInfo_get0_pkey_ctx |
| 558 | CMS_SignerInfo_get0_signature | 558 | CMS_SignerInfo_get0_signature |
| 559 | CMS_SignerInfo_get0_signer_id | 559 | CMS_SignerInfo_get0_signer_id |
| 560 | CMS_SignerInfo_get_version | ||
| 560 | CMS_SignerInfo_set1_signer_cert | 561 | CMS_SignerInfo_set1_signer_cert |
| 561 | CMS_SignerInfo_sign | 562 | CMS_SignerInfo_sign |
| 562 | CMS_SignerInfo_verify | 563 | CMS_SignerInfo_verify |
| @@ -597,6 +598,7 @@ CMS_get0_type | |||
| 597 | CMS_get1_ReceiptRequest | 598 | CMS_get1_ReceiptRequest |
| 598 | CMS_get1_certs | 599 | CMS_get1_certs |
| 599 | CMS_get1_crls | 600 | CMS_get1_crls |
| 601 | CMS_get_version | ||
| 600 | CMS_is_detached | 602 | CMS_is_detached |
| 601 | CMS_set1_eContentType | 603 | CMS_set1_eContentType |
| 602 | CMS_set1_signers_certs | 604 | CMS_set1_signers_certs |
diff --git a/src/lib/libcrypto/cms/cms.h b/src/lib/libcrypto/cms/cms.h index 3c92be34f7..76672af097 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.15 2019/08/11 10:15:30 jsing Exp $ */ | 1 | /* $OpenBSD: cms.h,v 1.16 2023/07/28 10:28:02 tb 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. |
| @@ -128,6 +128,9 @@ int CMS_ContentInfo_print_ctx(BIO *out, CMS_ContentInfo *x, int indent, const AS | |||
| 128 | 128 | ||
| 129 | const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); | 129 | const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); |
| 130 | 130 | ||
| 131 | int CMS_get_version(const CMS_ContentInfo *cms, long *version); | ||
| 132 | int CMS_SignerInfo_get_version(const CMS_SignerInfo *si, long *version); | ||
| 133 | |||
| 131 | BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont); | 134 | BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont); |
| 132 | int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio); | 135 | int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio); |
| 133 | 136 | ||
diff --git a/src/lib/libcrypto/cms/cms_lib.c b/src/lib/libcrypto/cms/cms_lib.c index fa62e61e96..37a11ba007 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.18 2023/07/08 08:26:26 beck Exp $ */ | 1 | /* $OpenBSD: cms_lib.c,v 1.19 2023/07/28 10:28:02 tb 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. |
| @@ -237,6 +237,49 @@ CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio) | |||
| 237 | } | 237 | } |
| 238 | LCRYPTO_ALIAS(CMS_dataFinal); | 238 | LCRYPTO_ALIAS(CMS_dataFinal); |
| 239 | 239 | ||
| 240 | int | ||
| 241 | CMS_get_version(const CMS_ContentInfo *cms, long *version) | ||
| 242 | { | ||
| 243 | switch (OBJ_obj2nid(cms->contentType)) { | ||
| 244 | case NID_pkcs7_signed: | ||
| 245 | *version = cms->d.signedData->version; | ||
| 246 | return 1; | ||
| 247 | |||
| 248 | case NID_pkcs7_enveloped: | ||
| 249 | *version = cms->d.envelopedData->version; | ||
| 250 | return 1; | ||
| 251 | |||
| 252 | case NID_pkcs7_digest: | ||
| 253 | *version = cms->d.digestedData->version; | ||
| 254 | return 1; | ||
| 255 | |||
| 256 | case NID_pkcs7_encrypted: | ||
| 257 | *version = cms->d.encryptedData->version; | ||
| 258 | return 1; | ||
| 259 | |||
| 260 | case NID_id_smime_ct_authData: | ||
| 261 | *version = cms->d.authenticatedData->version; | ||
| 262 | return 1; | ||
| 263 | |||
| 264 | case NID_id_smime_ct_compressedData: | ||
| 265 | *version = cms->d.compressedData->version; | ||
| 266 | return 1; | ||
| 267 | |||
| 268 | default: | ||
| 269 | CMSerror(CMS_R_UNSUPPORTED_TYPE); | ||
| 270 | return 0; | ||
| 271 | } | ||
| 272 | } | ||
| 273 | LCRYPTO_ALIAS(CMS_get_version); | ||
| 274 | |||
| 275 | int | ||
| 276 | CMS_SignerInfo_get_version(const CMS_SignerInfo *si, long *version) | ||
| 277 | { | ||
| 278 | *version = si->version; | ||
| 279 | return 1; | ||
| 280 | } | ||
| 281 | LCRYPTO_ALIAS(CMS_SignerInfo_get_version); | ||
| 282 | |||
| 240 | /* | 283 | /* |
| 241 | * Return an OCTET STRING pointer to content. This allows it to be accessed | 284 | * Return an OCTET STRING pointer to content. This allows it to be accessed |
| 242 | * or set later. | 285 | * or set later. |
diff --git a/src/lib/libcrypto/hidden/openssl/cms.h b/src/lib/libcrypto/hidden/openssl/cms.h index c777e857d8..0f450e603c 100644 --- a/src/lib/libcrypto/hidden/openssl/cms.h +++ b/src/lib/libcrypto/hidden/openssl/cms.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms.h,v 1.1 2023/07/08 08:26:26 beck Exp $ */ | 1 | /* $OpenBSD: cms.h,v 1.2 2023/07/28 10:28:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -35,6 +35,8 @@ LCRYPTO_USED(d2i_CMS_ReceiptRequest); | |||
| 35 | LCRYPTO_USED(i2d_CMS_ReceiptRequest); | 35 | LCRYPTO_USED(i2d_CMS_ReceiptRequest); |
| 36 | LCRYPTO_USED(CMS_ContentInfo_print_ctx); | 36 | LCRYPTO_USED(CMS_ContentInfo_print_ctx); |
| 37 | LCRYPTO_USED(CMS_get0_type); | 37 | LCRYPTO_USED(CMS_get0_type); |
| 38 | LCRYPTO_USED(CMS_get_version); | ||
| 39 | LCRYPTO_USED(CMS_SignerInfo_get_version); | ||
| 38 | LCRYPTO_USED(CMS_dataInit); | 40 | LCRYPTO_USED(CMS_dataInit); |
| 39 | LCRYPTO_USED(CMS_dataFinal); | 41 | LCRYPTO_USED(CMS_dataFinal); |
| 40 | LCRYPTO_USED(CMS_is_detached); | 42 | LCRYPTO_USED(CMS_is_detached); |
