]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg: BaseCryptLib: Update Salt length requirement for RSA-PSS scheme.
authorAgrawal, Sachin <sachin.agrawal@intel.com>
Mon, 14 Jun 2021 15:30:43 +0000 (23:30 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 23 Jun 2021 15:19:44 +0000 (15:19 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3455

Enforce salt length to be equal to digest length for RSA-PSS
encoding scheme.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Sachin Agrawal <sachin.agrawal@intel.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
CryptoPkg/Include/Library/BaseCryptLib.h
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaPss.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaPssNull.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaPssSign.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaPssSignNull.c
CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaPssNull.c
CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaPssSignNull.c
CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c
CryptoPkg/Private/Protocol/Crypto.h

index 8c7d5922ef96ce6b55943af3586e3396aea805ce..630ccb5e75002d4834861729edea20d7831031c8 100644 (file)
@@ -1376,7 +1376,7 @@ RsaPkcs1Verify (
   If Message is NULL, then return FALSE.\r
   If MsgSize is zero or > INT_MAX, then return FALSE.\r
   If DigestLen is NOT 32, 48 or 64, return FALSE.\r
-  If SaltLen is < DigestLen, then return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
   If this interface is not supported, then return FALSE.\r
 \r
@@ -1411,7 +1411,7 @@ RsaPssSign (
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r
index 0b2960f06c4ce37c365405cad07c1ea26c58fc80..37075ea65a0dc7cf388b3453fd4337af2b8045a1 100644 (file)
@@ -50,7 +50,7 @@ GetEvpMD (
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r
@@ -97,7 +97,7 @@ RsaPssVerify (
   if (Signature == NULL || SigSize == 0 || SigSize > INT_MAX) {\r
     return FALSE;\r
   }\r
-  if (SaltLen < DigestLen) {\r
+  if (SaltLen != DigestLen) {\r
     return FALSE;\r
   }\r
 \r
index 69c6889fbc4b1d922bbcbc6942bdf3184382a0b6..cc325c92911cc799e85c5f49b21d69d5fcc234d6 100644 (file)
@@ -15,7 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r
index ece765f9ae0a1479ba3b9902dd7f30a535b7a030..06187ff4baa72788629901a4d215acd215fbaa38 100644 (file)
@@ -59,7 +59,7 @@ GetEvpMD (
   If Message is NULL, then return FALSE.\r
   If MsgSize is zero or > INT_MAX, then return FALSE.\r
   If DigestLen is NOT 32, 48 or 64, return FALSE.\r
-  If SaltLen is < DigestLen, then return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
   If this interface is not supported, then return FALSE.\r
 \r
@@ -120,7 +120,7 @@ RsaPssSign (
     return FALSE;\r
   }\r
 \r
-  if (SaltLen < DigestLen) {\r
+  if (SaltLen != DigestLen) {\r
     return FALSE;\r
   }\r
 \r
index 4ed2dfce992aedba1bcb426315d08d8781d7d99f..911b972521822089efabb2ea51fc6df86bc6012e 100644 (file)
@@ -24,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
   If Message is NULL, then return FALSE.\r
   If MsgSize is zero or > INT_MAX, then return FALSE.\r
   If DigestLen is NOT 32, 48 or 64, return FALSE.\r
-  If SaltLen is < DigestLen, then return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
   If this interface is not supported, then return FALSE.\r
 \r
index 69c6889fbc4b1d922bbcbc6942bdf3184382a0b6..cc325c92911cc799e85c5f49b21d69d5fcc234d6 100644 (file)
@@ -15,7 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r
index 4ed2dfce992aedba1bcb426315d08d8781d7d99f..911b972521822089efabb2ea51fc6df86bc6012e 100644 (file)
@@ -24,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
   If Message is NULL, then return FALSE.\r
   If MsgSize is zero or > INT_MAX, then return FALSE.\r
   If DigestLen is NOT 32, 48 or 64, return FALSE.\r
-  If SaltLen is < DigestLen, then return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
   If this interface is not supported, then return FALSE.\r
 \r
index af99ed7f5b427a751215883ef43b744d873227e3..fcb59137805b1d924e2483ef52650c0d1554b37c 100644 (file)
@@ -1556,7 +1556,7 @@ RsaPkcs1Verify (
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r
@@ -1592,6 +1592,14 @@ RsaPssVerify (
   If the Signature buffer is too small to hold the contents of signature, FALSE\r
   is returned and SigSize is set to the required buffer size to obtain the signature.\r
 \r
+  If RsaContext is NULL, then return FALSE.\r
+  If Message is NULL, then return FALSE.\r
+  If MsgSize is zero or > INT_MAX, then return FALSE.\r
+  If DigestLen is NOT 32, 48 or 64, return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
+  If SigSize is large enough but Signature is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]      RsaContext   Pointer to RSA context for signature generation.\r
   @param[in]      Message      Pointer to octet message to be signed.\r
   @param[in]      MsgSize      Size of the message in bytes.\r
index e304302c9445289e85fd672d6a52411706bd2a9a..498f8e387dba31c0a6676cdb030be3e3d961b2d2 100644 (file)
@@ -3421,7 +3421,7 @@ EFI_STATUS
   If Message is NULL, then return FALSE.\r
   If MsgSize is zero or > INT_MAX, then return FALSE.\r
   If DigestLen is NOT 32, 48 or 64, return FALSE.\r
-  If SaltLen is < DigestLen, then return FALSE.\r
+  If SaltLen is not equal to DigestLen, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
   If this interface is not supported, then return FALSE.\r
 \r
@@ -3456,7 +3456,7 @@ BOOLEAN
   Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r
   Implementation determines salt length automatically from the signature encoding.\r
   Mask generation function is the same as the message digest algorithm.\r
-  Salt length should atleast be equal to digest length.\r
+  Salt length should be equal to digest length.\r
 \r
   @param[in]  RsaContext      Pointer to RSA context for signature verification.\r
   @param[in]  Message         Pointer to octet message to be verified.\r