From 7022d9b9032794330cd2d753f077670db95d33d4 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 7 Oct 2020 15:59:28 +0100 Subject: Remove CMS recipient info information out of the algorithm implementations Low level algorithm implementations have no business knowing about details of the higher level CMS concept. This knowledge is therefore moved into the CMS layer. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/13088) --- crypto/cms/cms_env.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crypto/cms') diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index 84d9e5b948..8f3e2db339 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -1303,6 +1303,20 @@ err: */ int cms_pkey_get_ri_type(EVP_PKEY *pk) { + /* Check types that we know about */ + if (EVP_PKEY_is_a(pk, "DH")) + return CMS_RECIPINFO_AGREE; + else if (EVP_PKEY_is_a(pk, "DSA")) + return CMS_RECIPINFO_NONE; + else if (EVP_PKEY_is_a(pk, "EC")) + return CMS_RECIPINFO_AGREE; + else if (EVP_PKEY_is_a(pk, "RSA")) + return CMS_RECIPINFO_TRANS; + + /* + * Otherwise this might ben an engine implementation, so see if we can get + * the type from the ameth. + */ if (pk->ameth && pk->ameth->pkey_ctrl) { int i, r; i = pk->ameth->pkey_ctrl(pk, ASN1_PKEY_CTRL_CMS_RI_TYPE, 0, &r); -- cgit v1.2.3