CryptoPkg: Add RSA functions based on Mbedtls

Add RSA APIs.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4177

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yi Li <yi1.li@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
Reviewed-by: Yi Li <yi1.li@intel.com>
This commit is contained in:
Wenxing Hou
2023-08-16 12:39:51 +08:00
committed by mergify[bot]
parent 60222e7eb9
commit 97f51f2e9b
8 changed files with 831 additions and 0 deletions

View File

@@ -194,6 +194,9 @@ TestVerifyRsaGenerateKeyComponents (
BOOLEAN Status;
UINTN KeySize;
UINT8 *KeyBuffer;
UINT8 TestPublicExponent1[] = { 0x03 };
UINT8 TestPublicExponent2[] = { 0x01, 0x01 };
UINT8 TestPublicExponent3[] = { 0x01, 0x00, 0x01 };
//
// Generate RSA Key Components
@@ -202,6 +205,13 @@ TestVerifyRsaGenerateKeyComponents (
Status = RsaGenerateKey (mRsa, RSA_MODULUS_LENGTH, NULL, 0);
UT_ASSERT_TRUE (Status);
Status = RsaGenerateKey (mRsa, RSA_MODULUS_LENGTH, TestPublicExponent1, sizeof (TestPublicExponent1));
UT_ASSERT_TRUE (Status);
Status = RsaGenerateKey (mRsa, RSA_MODULUS_LENGTH, TestPublicExponent2, sizeof (TestPublicExponent2));
UT_ASSERT_TRUE (Status);
Status = RsaGenerateKey (mRsa, RSA_MODULUS_LENGTH, TestPublicExponent3, sizeof (TestPublicExponent3));
UT_ASSERT_TRUE (Status);
KeySize = RSA_MODULUS_LENGTH / 8;
KeyBuffer = AllocatePool (KeySize);
Status = RsaGetKey (mRsa, RsaKeyE, KeyBuffer, &KeySize);