Add RSA SHA512 truncated digest support
authorShane Lontis <shane.lontis@oracle.com>
Thu, 30 Apr 2020 03:41:05 +0000 (13:41 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Thu, 7 May 2020 06:00:40 +0000 (16:00 +1000)
Partial Fix for #11648.

Some additional work still needs to be done to support RSA-PSS mode.

RSA legacy digests will be addressed in another PR.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11681)

crypto/rsa/rsa_pmeth.c
include/openssl/core_names.h
providers/common/der/der_rsa.c.in
providers/implementations/signature/rsa.c
test/recipes/30-test_evp_data/evppkey.txt

index 70944c638e1ad41912e772c7158272a8bf2dd9d8..e899fbd6053dee8353e8a334fae22a3beab63c2c 100644 (file)
@@ -382,6 +382,8 @@ static int check_padding_md(const EVP_MD *md, int padding)
         case NID_sha256:
         case NID_sha384:
         case NID_sha512:
+        case NID_sha512_224:
+        case NID_sha512_256:
         case NID_md5:
         case NID_md5_sha1:
         case NID_md2:
index 4bc151c16227a6907e0f2ea51ada81233f386457..6e93738ae0e755c75dde0e3c513645bef5d5ba8b 100644 (file)
@@ -94,6 +94,8 @@ extern "C" {
 #define OSSL_DIGEST_NAME_SHA2_256       "SHA2-256"
 #define OSSL_DIGEST_NAME_SHA2_384       "SHA2-384"
 #define OSSL_DIGEST_NAME_SHA2_512       "SHA2-512"
+#define OSSL_DIGEST_NAME_SHA2_512_224   "SHA2-512/224"
+#define OSSL_DIGEST_NAME_SHA2_512_256   "SHA2-512/256"
 #define OSSL_DIGEST_NAME_MD2            "MD2"
 #define OSSL_DIGEST_NAME_MD4            "MD4"
 #define OSSL_DIGEST_NAME_MDC2           "MDC2"
index cdff7228187b2d183a63bddee2f8693f1a1f6e86..bc7c0095e9923825eeca0f55179cdceceb8800e5 100644 (file)
@@ -62,6 +62,8 @@ int DER_w_algorithmIdentifier_RSA_with(WPACKET *pkt, int tag,
         MD_CASE(sha256);
         MD_CASE(sha384);
         MD_CASE(sha512);
+        MD_CASE(sha512_224);
+        MD_CASE(sha512_256);
         MD_CASE(sha3_224);
         MD_CASE(sha3_256);
         MD_CASE(sha3_384);
index fdcdb56194f5841ebf905c3d3f81e8b949b96e46..06704474807e256a3f48d26d928807151bd13022 100644 (file)
@@ -129,6 +129,8 @@ static int rsa_get_md_nid(const EVP_MD *md)
         { NID_sha256,    OSSL_DIGEST_NAME_SHA2_256  },
         { NID_sha384,    OSSL_DIGEST_NAME_SHA2_384  },
         { NID_sha512,    OSSL_DIGEST_NAME_SHA2_512  },
+        { NID_sha512_224, OSSL_DIGEST_NAME_SHA2_512_224 },
+        { NID_sha512_256, OSSL_DIGEST_NAME_SHA2_512_256 },
         { NID_md5,       OSSL_DIGEST_NAME_MD5       },
         { NID_md5_sha1,  OSSL_DIGEST_NAME_MD5_SHA1  },
         { NID_md2,       OSSL_DIGEST_NAME_MD2       },
index e4b6497b48e7ec21f8489d2c159ac750e266fcb7..1d5274f103b99ab4309b56470a48f90a87eaaa13 100644 (file)
@@ -142,6 +142,19 @@ Ctrl = digest:SHA1
 Input = "0123456789ABCDEF1234"
 Output = c09d402423cbf233d26cae21f954547bc43fe80fd41360a0336cfdbe9aedad05bef6fd2eaee6cd60089a52482d4809a238149520df3bdde4cb9e23d9307b05c0a6f327052325a29adf2cc95b66523be7024e2a585c3d4db15dfbe146efe0ecdc0402e33fe5d40324ee96c5c3edd374a15cdc0f5d84aa243c0f07e188c6518fbfceae158a9943be398e31097da81b62074f626eff738be6160741d5a26957a482b3251fd85d8df78b98148459de10aa93305dbb4a5230aa1da291a9b0e481918f99b7638d72bb687f97661d304ae145d64a474437a4ef39d7b8059332ddeb07e92bf6e0e3acaf8afedc93795e4511737ec1e7aab6d5bc9466afc950c1c17b48ad
 
+# Truncated digest
+Sign = RSA-2048
+Availablein = default
+Ctrl = digest:SHA512-224
+Input = "0123456789ABCDEF123456789ABC"
+Output = 5f720e9488139bb21e1c2f027fd5ce5993e6d31c5a8faaee833487b3a944d66891178868ace8070cad3ee2ffbe54aa4885a15fd1a7cc5166970fe1fd8c0423e72bd3e3b56fc4a53ed80aaaeca42497f0ec3c62113edc05cd006608f5eef7ce3ad4cba1069f68731dd28a524a1f93fcdc5547112d48d45586dd943ba0d443be9635720d8a61697c54c96627f0d85c5fbeaa3b4af86a65cf2fc3800dd5de34c046985f25d0efc0bb6edccc1d08b3a4fb9c8faffe181c7e68b31e374ad1440a4a664eec9ca0dc53a9d2f5bc7d9940d866f64201bcbc63612754df45727ea24b531d7de83d1bb707444859fa35521320c33bf6f4dbeb6fb56e653adbf7af15843f17
+
+Verify = RSA-2048
+Availablein = default
+Ctrl = digest:SHA512-224
+Input = "0123456789ABCDEF123456789ABC"
+Output = 5f720e9488139bb21e1c2f027fd5ce5993e6d31c5a8faaee833487b3a944d66891178868ace8070cad3ee2ffbe54aa4885a15fd1a7cc5166970fe1fd8c0423e72bd3e3b56fc4a53ed80aaaeca42497f0ec3c62113edc05cd006608f5eef7ce3ad4cba1069f68731dd28a524a1f93fcdc5547112d48d45586dd943ba0d443be9635720d8a61697c54c96627f0d85c5fbeaa3b4af86a65cf2fc3800dd5de34c046985f25d0efc0bb6edccc1d08b3a4fb9c8faffe181c7e68b31e374ad1440a4a664eec9ca0dc53a9d2f5bc7d9940d866f64201bcbc63612754df45727ea24b531d7de83d1bb707444859fa35521320c33bf6f4dbeb6fb56e653adbf7af15843f17
+
 VerifyRecover = RSA-2048
 Availablein = default
 Ctrl = digest:SHA1