From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8E471D81112 for ; Sat, 30 Mar 2024 22:00:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=r+/IwEbwFqlFZie/jYEhhcuMT9mo1KG8Suv4jZMRYXM=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Feedback-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1711836010; v=1; b=R2aIT7nQ7hgL6DaDxahI9hVzDszrGwGWkt25oZzfbfRWtSkxDq563tNL6m3k6ojJ9RwWxGBb whiJcz5VKf/6+I2cmRbWLlQp6KNofwYNMqqQH0Xah5rXYilwE95qWScKpn9MrDahXtctVHgQVqy Lm2vXNtJxXKv4OOzkmyoM1gp3Km05zODwpNFYI5ShE8TFo2Ucf8A9lff0Gb67ReadA2j1Y7A1I1 9PPvYfnlyqEvuDWBo5GyQYmiO2N+ze5Q0rN0ROnkuaDZ0zrv4fxbKjcHkT7XHkVpH8Tz/VjcsnU qMAi9w8lIZl0dpyaX+0M195UUHPFgqY4Q5xXTKyIXJoMg== X-Received: by 127.0.0.2 with SMTP id YNo5YY7687511xABQ1c3Ifjd; Sat, 30 Mar 2024 15:00:10 -0700 X-Received: from a2i971.smtp2go.com (a2i971.smtp2go.com [103.47.207.203]) by mx.groups.io with SMTP id smtpd.web11.6642.1711836008102805732 for ; Sat, 30 Mar 2024 15:00:08 -0700 X-Received: from [10.66.228.43] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1rqgkB-gL4SIh-BF; Sat, 30 Mar 2024 22:00:07 +0000 X-Received: from [10.90.237.184] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96.1-S2G) (envelope-from ) id 1rqgkA-wSPEb9-2Z; Sat, 30 Mar 2024 22:00:07 +0000 From: "Chris Ruffin via groups.io" To: devel@edk2.groups.io Cc: Chris Ruffin , Chris Ruffin , Jiewen Yao , Yi Li , Wenxing Hou Subject: [edk2-devel] [PATCH v2 3/3] CryptoPkg/BaseCryptLibUnitTest: add unit test functions Date: Sat, 30 Mar 2024 17:59:45 -0400 Message-ID: <4ff5b34536e13e7006ece14de970132bb40f03cc.1711833672.git.v-chruffin@microsoft.com> In-Reply-To: References: <20240318215205.1339-1-cruffin@millcore.com> MIME-Version: 1.0 X-Smtpcorp-Track: 1rqgkjwSeEP92Z.CEtnDpSO6PA26 Feedback-ID: 401384m:401384aZcXcRg:401384sWE3wrW2r9 X-Report-Abuse: Please forward a copy of this message, including all headers, to Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Sat, 30 Mar 2024 15:00:08 -0700 Reply-To: devel@edk2.groups.io,cruffin@millcore.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pE0LK6EkX6HZxinDHXaN6UOYx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=R2aIT7nQ; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io From: Chris Ruffin Add unit test functions: TestVerifyPkcs1v2EncryptInterface() TestVerifyRsaOaepEncryptInterface() TestVerifyEncrypt() TestVerifyDecrypt() TestVerifyEncryptDecrypt() Signed-off-by: Chris Ruffin Cc: Chris Ruffin Cc: Jiewen Yao Cc: Yi Li Cc: Wenxing Hou --- .../Library/BaseCryptLib/OaepEncryptTests.c | 758 ++++++++++++++++-- 1 file changed, 687 insertions(+), 71 deletions(-) diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/OaepEncryptTests.= c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/OaepEncryptTests.c index 22a4ea7e46..b4ecb4aff0 100644 --- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/OaepEncryptTests.c +++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/OaepEncryptTests.c @@ -1,20 +1,21 @@ /** @file=0D - This is a unit test for RSA OAEP encrypt.=0D + This is a unit test for RSA OAEP encrypt/decrypt.=0D =0D Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D + Copyright (c) Microsoft Corporation. All rights reserved.=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D **/=0D =0D #include "TestBaseCryptLib.h"=0D =0D -CONST UINT8 RandSeed[] =3D "This is the random seed for PRNG verificatio= n.";=0D +STATIC CONST UINT8 RandSeed[] =3D "This is the random seed for PRNG veri= fication.";=0D =0D //=0D // Self signed X509 certificate=0D // CN =3D ca.self=0D // O =3D Intel=0D //=0D -GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 SelfTestCert[] =3D {=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 SelfTestCert[] =3D {=0D 0x30, 0x82, 0x03, 0x90, 0x30, 0x82, 0x02, 0x78, 0x02, 0x09, 0x00, 0xE4, = 0xDF, 0x47, 0x80, 0xEF,=0D 0x4B, 0x3C, 0x6D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, = 0x0D, 0x01, 0x01, 0x0B,=0D 0x05, 0x00, 0x30, 0x81, 0x89, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, = 0x04, 0x06, 0x13, 0x02,=0D @@ -75,7 +76,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 SelfTestCert[]= =3D { 0x5B, 0x64, 0x81, 0x13,=0D };=0D =0D -GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 PrivateKey[] =3D {=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 PrivateKey[] =3D {=0D 0x30, 0x82, 0x04, 0xA4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, = 0xBC, 0xE4, 0x67, 0xDC,=0D 0xC7, 0xEA, 0x6F, 0x8A, 0xA7, 0xCC, 0xB2, 0x54, 0x47, 0x48, 0x6A, 0xE2, = 0x39, 0xFF, 0xC2, 0x48,=0D 0x58, 0x34, 0x07, 0x03, 0x6D, 0x39, 0xB3, 0x67, 0x46, 0x4C, 0xBC, 0xA0, = 0xFA, 0x4E, 0x64, 0x23,=0D @@ -153,52 +154,310 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 PrivateKe= y[] =3D { 0x86, 0x10, 0x09, 0x88, 0x6C, 0x35, 0x60, 0xF2,=0D };=0D =0D -UNIT_TEST_STATUS=0D +// The following RSA key componets were extracted from the above private k= ey with openssl.=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 RsaN[] =3D {=0D + 0x00,=0D + 0xbc,0xe4, 0x67, 0xdc, 0xc7, 0xea, 0x6f, 0x8a, 0xa7, 0xcc, 0xb2, 0x54, = 0x47, 0x48, 0x6a, 0xe2,=0D + 0x39,0xff, 0xc2, 0x48, 0x58, 0x34, 0x07, 0x03, 0x6d, 0x39, 0xb3, 0x67, = 0x46, 0x4c, 0xbc, 0xa0,=0D + 0xfa,0x4e, 0x64, 0x23, 0x56, 0x47, 0x7b, 0xc9, 0x1a, 0x2a, 0x55, 0x42, = 0x54, 0x10, 0x18, 0x30,=0D + 0x92,0x60, 0x30, 0x5b, 0x9e, 0xc0, 0x65, 0xd2, 0xd4, 0x05, 0x4a, 0xa6, = 0x10, 0x66, 0x04, 0xa9,=0D + 0x54,0x4e, 0xee, 0x49, 0x39, 0x43, 0x65, 0x1e, 0x2e, 0x28, 0xde, 0x79, = 0x24, 0xa9, 0x7e, 0xd8,=0D + 0x5b,0xbc, 0x2f, 0x46, 0x6a, 0xb7, 0xb6, 0x0d, 0x17, 0x88, 0x37, 0x52, = 0x5c, 0xfe, 0x93, 0xc0,=0D + 0xe2,0xfd, 0x6a, 0x08, 0x1b, 0xfb, 0xd1, 0x87, 0xbd, 0xbd, 0x58, 0x57, = 0x2c, 0x06, 0x5d, 0xd2,=0D + 0x7d,0x52, 0xe2, 0x49, 0x8e, 0xdc, 0xe5, 0x26, 0xbd, 0x92, 0x60, 0xb0, = 0x3f, 0x58, 0x5e, 0x52,=0D + 0xd7,0x91, 0xda, 0x93, 0x62, 0x8d, 0x71, 0x80, 0x53, 0xba, 0x15, 0xc4, = 0x1f, 0xf3, 0xbd, 0xe0,=0D + 0xc5,0xa4, 0xb8, 0xd3, 0x64, 0x12, 0x14, 0x1b, 0x11, 0x6b, 0x7b, 0xc2, = 0x92, 0xc7, 0xe2, 0x94,=0D + 0x0b,0xb8, 0x67, 0x38, 0x48, 0x63, 0x11, 0x74, 0x25, 0x7c, 0x37, 0xc3, = 0xb2, 0xae, 0xd9, 0xa7,=0D + 0x17,0x9c, 0x4b, 0x9d, 0x6c, 0x27, 0xb0, 0x87, 0x16, 0x6b, 0xf2, 0x96, = 0xe5, 0x1d, 0x37, 0x27,=0D + 0xde,0xf2, 0x98, 0xb7, 0x81, 0x08, 0xd9, 0x7a, 0xba, 0x84, 0x14, 0x61, = 0x60, 0x48, 0xce, 0xce,=0D + 0x51,0x73, 0xf4, 0xdb, 0xf1, 0x5f, 0x7a, 0x17, 0x71, 0x4f, 0xc1, 0x0b, = 0xce, 0xc7, 0x31, 0xc1,=0D + 0x4e,0xa3, 0xee, 0x6f, 0x72, 0x97, 0x90, 0xfb, 0x8b, 0x54, 0x9f, 0x82, = 0x5b, 0x48, 0x5a, 0xf1,=0D + 0xad,0x8b, 0x3a, 0xcd, 0xca, 0xb2, 0x8b, 0x7a, 0x53, 0xd4, 0xf7, 0x71, = 0x16, 0x75, 0xa7, 0x35,=0D +};=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 RsaE[] =3D {=0D + 0x01, 0x00, 0x01=0D +};=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 RsaD[] =3D {=0D + 0x13, 0xf7, 0xd1, 0x42, 0xf5, 0x9f, 0x42, 0xcb, 0x55, 0x91, 0xbe, 0x08, = 0x4a, 0xc0, 0xcd, 0x0b,=0D + 0xbd, 0x35, 0xdc, 0x43, 0xe9, 0x8f, 0x16, 0x6e, 0xb6, 0x4d, 0x33, 0x39, = 0xe7, 0xa4, 0x95, 0x0c,=0D + 0x2f, 0x69, 0xba, 0x0c, 0x42, 0x42, 0xac, 0x43, 0x46, 0x10, 0xd3, 0x92, = 0x7f, 0x70, 0x74, 0x1e,=0D + 0x2e, 0x5b, 0x1c, 0xc1, 0x92, 0xb6, 0xa4, 0x0c, 0xf5, 0x7c, 0xd9, 0xb7, = 0x54, 0x64, 0x74, 0x79,=0D + 0xb1, 0xff, 0xe6, 0x10, 0xb7, 0x8c, 0xf8, 0x53, 0x88, 0x6d, 0xa9, 0x97, = 0x04, 0xd9, 0x26, 0x1f,=0D + 0x99, 0x12, 0xfb, 0xac, 0x65, 0xfb, 0xa5, 0xb3, 0x1c, 0x99, 0xb9, 0xbf, = 0x6b, 0x35, 0x3e, 0x49,=0D + 0x55, 0xb5, 0x94, 0x4f, 0xe7, 0x25, 0x67, 0xb1, 0x01, 0xcd, 0xd2, 0x58, = 0xe4, 0xbe, 0x87, 0x8c,=0D + 0x88, 0xd3, 0x0a, 0x38, 0xdc, 0x71, 0x5d, 0x88, 0x0a, 0xe2, 0x3e, 0x76, = 0x63, 0x3b, 0xe4, 0x3c,=0D + 0x8f, 0x2f, 0x29, 0x1d, 0xd1, 0x66, 0x8d, 0xc0, 0x4a, 0x68, 0x15, 0x90, = 0x4c, 0x95, 0x61, 0xf4,=0D + 0xfd, 0xe8, 0xfa, 0x9c, 0x6c, 0x00, 0x22, 0x23, 0xd5, 0x17, 0x6e, 0xee, = 0xa8, 0xd8, 0x70, 0xc5,=0D + 0x74, 0xea, 0x09, 0x13, 0x7f, 0x0c, 0x37, 0x4d, 0x50, 0xcd, 0xe9, 0x16, = 0xc2, 0xd5, 0xde, 0x5e,=0D + 0xc3, 0xfc, 0x46, 0x08, 0xf1, 0x99, 0xc0, 0xb4, 0x28, 0xfd, 0x2b, 0x29, = 0xef, 0x76, 0xd7, 0x04,=0D + 0x4f, 0x02, 0x54, 0x16, 0x54, 0x55, 0x20, 0xec, 0xbc, 0xbf, 0x85, 0x5f, = 0x12, 0xcc, 0xfc, 0x0d,=0D + 0xf2, 0xef, 0xfc, 0x4d, 0x3e, 0xa2, 0x5e, 0x97, 0xfe, 0x35, 0x10, 0x0f, = 0x53, 0x1f, 0x80, 0xd5,=0D + 0xc0, 0xb4, 0xe9, 0xe9, 0x31, 0x4c, 0x89, 0x14, 0x72, 0x39, 0x65, 0x89, = 0xef, 0x7a, 0x51, 0x4a,=0D + 0xb9, 0xa9, 0xcc, 0x1b, 0x52, 0xb0, 0x02, 0x52, 0x65, 0x2f, 0x0b, 0x89, = 0x41, 0x70, 0x1e, 0x01,=0D +};=0D +=0D +// test case =3D "123\0"=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 Msg1230[] =3D {=0D + 0x31, 0x32, 0x33, 0x00=0D +};=0D +=0D +// Ciphertext of the test case using RSAES-OAEP2048 with SHA1 MD/BGF1 crea= ted with openssl.=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 Ct1230RsaesOaepMdSha1Mgf= 1Sha1[] =3D {=0D + 0x88, 0x5d, 0xf3, 0x00, 0x66, 0x77, 0x91, 0x94, 0x5c, 0x8d, 0x45, 0xb6, = 0xb2, 0x24, 0x26, 0x26,=0D + 0x37, 0xbe, 0xe0, 0x87, 0x4f, 0x50, 0xbf, 0x88, 0xde, 0x5d, 0xe9, 0xe0, = 0xb2, 0x7e, 0x66, 0xfa,=0D + 0x6c, 0xfd, 0x0d, 0x19, 0x48, 0x41, 0xfe, 0x7a, 0x86, 0xa8, 0x28, 0xc2, = 0x01, 0xcf, 0x76, 0xd7,=0D + 0xea, 0xab, 0x6d, 0xc3, 0x5e, 0x2c, 0x36, 0x04, 0xc0, 0x54, 0xc2, 0x68, = 0x67, 0xe7, 0x04, 0x27,=0D + 0x56, 0xbe, 0x53, 0xb5, 0x80, 0x94, 0xd8, 0xde, 0x8c, 0x75, 0x69, 0x42, = 0xba, 0x55, 0xd6, 0x2c,=0D + 0xda, 0x22, 0xe6, 0x09, 0xf6, 0x90, 0x27, 0x4b, 0x10, 0x54, 0x40, 0xa0, = 0x74, 0x31, 0xdb, 0x5f,=0D + 0x80, 0x06, 0xc7, 0x67, 0x96, 0xe8, 0x45, 0xea, 0x7f, 0x72, 0x18, 0x24, = 0xe8, 0x0d, 0x46, 0xc2,=0D + 0xa0, 0x83, 0xca, 0x71, 0xca, 0x91, 0x4b, 0x89, 0x80, 0x61, 0x01, 0x8e, = 0xcf, 0xa1, 0x68, 0x81,=0D + 0x2d, 0xf2, 0x08, 0xd2, 0x02, 0x9e, 0xc0, 0xa4, 0x91, 0x71, 0x90, 0x84, = 0x2f, 0x4e, 0x18, 0x37,=0D + 0x9b, 0x61, 0x0b, 0xf5, 0x88, 0xf7, 0x6b, 0x87, 0xb9, 0x4e, 0x31, 0xda, = 0xf3, 0xb5, 0xe2, 0x60,=0D + 0x4d, 0xd9, 0x52, 0x99, 0x6b, 0x19, 0x98, 0xa2, 0x28, 0xaa, 0xeb, 0x5a, = 0x33, 0xef, 0xf1, 0x4e,=0D + 0x29, 0x86, 0xbf, 0x70, 0x08, 0xfd, 0x34, 0x8a, 0x8c, 0x6d, 0xef, 0xc4, = 0xa1, 0xfe, 0xdf, 0x4d,=0D + 0xeb, 0xf0, 0x2c, 0x4c, 0xf5, 0xb3, 0xe8, 0xf8, 0xc3, 0x45, 0xc7, 0x6b, = 0x59, 0x1c, 0x9b, 0xd9,=0D + 0x52, 0xdf, 0x65, 0x87, 0x18, 0xd2, 0x6d, 0xff, 0x8b, 0x98, 0x2a, 0x97, = 0xeb, 0x93, 0xea, 0x6a,=0D + 0x23, 0x23, 0xc6, 0x32, 0xf5, 0xea, 0x45, 0xe3, 0x99, 0xa0, 0x4d, 0x4b, = 0x8f, 0xf8, 0x1d, 0xad,=0D + 0xa9, 0x97, 0xa2, 0xd6, 0xaf, 0x5e, 0x11, 0xf7, 0x5f, 0x28, 0xfb, 0x38, = 0x80, 0x38, 0x50, 0xc4,=0D +};=0D +=0D +// Ciphertext of the test case using RSAES-OAEP2048 with SHA256 MD/BGF1 cr= eated with openssl.=0D +GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT8 Ct1230RsaesOaep2048MdSha= 256Mgf1Sha256[] =3D {=0D + 0xa7, 0x20, 0xa9, 0x31, 0xb5, 0xad, 0x83, 0x0a, 0x07, 0xee, 0x36, 0x46, = 0xa5, 0x78, 0x3a, 0xda,=0D + 0x9d, 0xdf, 0xe6, 0x05, 0x0f, 0x7c, 0x46, 0xfe, 0x5f, 0xd6, 0x58, 0x16, = 0xb6, 0xaa, 0x82, 0x7c,=0D + 0x58, 0x8a, 0x52, 0x14, 0x12, 0x29, 0x6f, 0x62, 0x80, 0xa7, 0x61, 0xfe, = 0x29, 0x72, 0x6f, 0x73,=0D + 0xf6, 0x2f, 0x54, 0x38, 0x58, 0x7b, 0xbd, 0xa1, 0x2f, 0x9d, 0x12, 0x83, = 0x72, 0xbc, 0x3d, 0x29,=0D + 0x65, 0x39, 0xcb, 0x93, 0x95, 0x3e, 0x73, 0xc9, 0x6f, 0xb9, 0xe8, 0xd5, = 0x8b, 0x91, 0x0d, 0x87,=0D + 0x7e, 0x22, 0xb5, 0x93, 0x3d, 0xa8, 0x4a, 0xd9, 0x1a, 0x13, 0xf7, 0xf4, = 0x7f, 0x16, 0x42, 0xfe,=0D + 0x63, 0x10, 0x7e, 0xa1, 0xe5, 0x04, 0xcf, 0xed, 0x93, 0x2d, 0x16, 0x3b, = 0x79, 0x1f, 0x53, 0x41,=0D + 0xe3, 0xca, 0x69, 0x18, 0x6a, 0xe5, 0xec, 0x9a, 0xce, 0xbc, 0x47, 0xf6, = 0x77, 0x9a, 0x5c, 0xea,=0D + 0xac, 0x7e, 0x28, 0xeb, 0x1e, 0xfe, 0x75, 0xa6, 0xbf, 0x1e, 0xfd, 0x1c, = 0x63, 0x69, 0x47, 0x04,=0D + 0xaf, 0x69, 0x7e, 0x1c, 0xa1, 0x7f, 0x00, 0xcf, 0xec, 0x16, 0x34, 0xd9, = 0xde, 0x91, 0x0e, 0x0f,=0D + 0x0b, 0x1e, 0x66, 0xc3, 0x41, 0x88, 0x43, 0xbe, 0xa3, 0x2a, 0x7c, 0x87, = 0xff, 0xc0, 0x67, 0xdc,=0D + 0xc7, 0xeb, 0x28, 0x07, 0x00, 0x72, 0x85, 0x17, 0xca, 0x05, 0x9f, 0x29, = 0x6b, 0xad, 0xc6, 0xae,=0D + 0x1c, 0x4a, 0xf2, 0xfe, 0x97, 0xc7, 0x6e, 0x4b, 0xbf, 0xfd, 0x46, 0xbe, = 0xf8, 0x76, 0xc9, 0x70,=0D + 0x58, 0x3a, 0x73, 0xcc, 0x34, 0xda, 0xfe, 0x5b, 0x6d, 0x98, 0x74, 0x95, = 0x85, 0xc7, 0xc9, 0x84,=0D + 0x02, 0xa8, 0x97, 0x13, 0xa3, 0x83, 0xcb, 0x28, 0x3d, 0xbb, 0x2b, 0x3b, = 0x45, 0xf1, 0x6e, 0xc5,=0D + 0x37, 0x23, 0x21, 0xe6, 0x74, 0x2d, 0x48, 0x19, 0x97, 0xaf, 0xee, 0x3d, = 0x9b, 0xd0, 0x05, 0xc7=0D +};=0D +=0D +typedef struct _OAEP_ENC_DEC_TEST_CONTEXT OAEP_ENC_DEC_TEST_CONTEXT;=0D +typedef=0D +BOOLEAN=0D +(EFIAPI *OAEP_TEST_ENCRYPT)(=0D + IN OAEP_ENC_DEC_TEST_CONTEXT *TestContext,=0D + IN CONST UINT8 *ClearText,=0D + IN UINTN ClearTextSize,=0D + IN CONST UINT8 *PrngSeed,=0D + IN UINTN PrngSeedSize,=0D + IN UINT16 DigestLen,=0D + OUT UINT8 **CipherText,=0D + OUT UINTN *CipherTextSize=0D + );=0D +=0D +typedef=0D +BOOLEAN=0D +(EFIAPI *OAEP_TEST_DECRYPT)(=0D + IN OAEP_ENC_DEC_TEST_CONTEXT *TestContext,=0D + IN CONST UINT8 *CipherText,=0D + IN UINTN CipherTextSize,=0D + IN UINT16 DigestLen,=0D + OUT UINT8 **ClearText,=0D + OUT UINTN *ClearTextSize=0D + );=0D +=0D +typedef struct _OAEP_ENC_DEC_TEST_CONTEXT {=0D + CONST UINT8 *SelfTestCert;=0D + UINTN SelfTestCertSize;=0D + CONST UINT8 *PrivateKey;=0D + UINTN PrivateKeySize;=0D + CONST UINT8 *RsaN;=0D + UINTN RsaNSize;=0D + CONST UINT8 *RsaE;=0D + UINTN RsaESize;=0D + CONST UINT8 *RsaD;=0D + UINTN RsaDSize;=0D + CONST UINT8 *PrngSeed;=0D + UINTN PrngSeedSize;=0D + CONST UINT8 *ClearText;=0D + UINTN ClearTextSize;=0D + CONST UINT8 *CipherText;=0D + UINTN CipherTextSize;=0D + UINT16 DigestLen;=0D + OAEP_TEST_ENCRYPT Encrypt;=0D + OAEP_TEST_DECRYPT Decrypt;=0D + UNIT_TEST_STATUS Expect;=0D +} OAEP_ENC_DEC_TEST_CONTEXT;=0D +=0D +BOOLEAN=0D EFIAPI=0D -TestVerifyOaepEncrypt (=0D - IN UNIT_TEST_CONTEXT Context=0D +CallPkcs1v2Encrypt (=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx,=0D + CONST UINT8 *ClearText,=0D + UINTN ClearTextSize,=0D + CONST UINT8 *PrngSeed,=0D + UINTN PrngSeedSize,=0D + UINT16 DigestLen,=0D + UINT8 **CipherText,=0D + UINTN *CipherTextSize=0D )=0D {=0D BOOLEAN Status;=0D - UINT8 File[4];=0D - UINT8 *OutBuffer;=0D - UINTN OutBufferSize;=0D - UINT8 *OutBuffer2;=0D - UINTN OutBuffer2Size;=0D =0D - // Create a file and add content '123' in it=0D - File[0] =3D '1';=0D - File[1] =3D '2';=0D - File[2] =3D '3';=0D - File[3] =3D 0;=0D + Status =3D Pkcs1v2Encrypt (=0D + TestCtx->SelfTestCert,=0D + TestCtx->SelfTestCertSize,=0D + (UINT8 *)ClearText,=0D + ClearTextSize,=0D + PrngSeed,=0D + PrngSeedSize,=0D + CipherText,=0D + CipherTextSize=0D + );=0D =0D - OutBuffer =3D NULL;=0D - OutBufferSize =3D 0;=0D - OutBuffer2 =3D NULL;=0D - OutBuffer2Size =3D 0;=0D + return Status;=0D +}=0D =0D - Status =3D Pkcs1v2Encrypt (=0D - SelfTestCert,=0D - (UINTN)sizeof (SelfTestCert),=0D - File,=0D - (UINTN)sizeof (File),=0D - NULL,=0D - 0,=0D - &OutBuffer,=0D - (UINTN *)&OutBufferSize=0D +BOOLEAN=0D +EFIAPI=0D +CallPkcs1v2Decrypt (=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx,=0D + CONST UINT8 *CipherText,=0D + UINTN CipherTextSize,=0D + UINT16 DigestLen,=0D + UINT8 **ClearText,=0D + UINTN *ClearTextSize=0D + )=0D +{=0D + BOOLEAN Status;=0D +=0D + Status =3D Pkcs1v2Decrypt (=0D + TestCtx->PrivateKey,=0D + TestCtx->PrivateKeySize,=0D + (UINT8 *)CipherText,=0D + CipherTextSize,=0D + ClearText,=0D + ClearTextSize=0D );=0D + return Status;=0D +}=0D +=0D +BOOLEAN=0D +EFIAPI=0D +CallRsaOaepEncrypt (=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx,=0D + CONST UINT8 *ClearText,=0D + UINTN ClearTextSize,=0D + CONST UINT8 *RandSeedIn,=0D + UINTN RandSeedSizeIn,=0D + UINT16 DigestLen,=0D + UINT8 **CipherText,=0D + UINTN *CipherTextSize=0D + )=0D +{=0D + VOID *RsaContext =3D NULL;=0D + BOOLEAN Status;=0D +=0D + RsaContext =3D RsaNew ();=0D + UT_ASSERT_FALSE (RsaContext =3D=3D NULL);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyN, TestCtx->RsaN, TestCtx->RsaNS= ize);=0D UT_ASSERT_TRUE (Status);=0D =0D - Status =3D Pkcs1v2Encrypt (=0D - SelfTestCert,=0D - (UINTN)sizeof (SelfTestCert),=0D - File,=0D - (UINTN)4,=0D - NULL,=0D - 0,=0D - &OutBuffer2,=0D - (UINTN *)&OutBuffer2Size=0D + Status =3D RsaSetKey (RsaContext, RsaKeyE, TestCtx->RsaE, TestCtx->RsaES= ize);=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaOaepEncrypt (=0D + RsaContext,=0D + (UINT8 *)ClearText,=0D + ClearTextSize,=0D + RandSeedIn,=0D + RandSeedSizeIn,=0D + DigestLen,=0D + CipherText,=0D + CipherTextSize=0D );=0D +=0D + return Status;=0D +}=0D +=0D +BOOLEAN=0D +EFIAPI=0D +CallRsaOaepDecrypt (=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx,=0D + CONST UINT8 *CipherText,=0D + UINTN CipherTextSize,=0D + UINT16 DigestLen,=0D + UINT8 **ClearText,=0D + UINTN *ClearTextSize=0D + )=0D +{=0D + VOID *RsaContext =3D NULL;=0D + BOOLEAN Status;=0D +=0D + RsaContext =3D RsaNew ();=0D + UT_ASSERT_FALSE (RsaContext =3D=3D NULL);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyN, TestCtx->RsaN, TestCtx->RsaNS= ize);=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyE, TestCtx->RsaE, TestCtx->RsaES= ize);=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyD, TestCtx->RsaD, TestCtx->RsaDS= ize);=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaOaepDecrypt (=0D + RsaContext,=0D + (UINT8 *)CipherText,=0D + CipherTextSize,=0D + DigestLen,=0D + ClearText,=0D + ClearTextSize=0D + );=0D +=0D + return Status;=0D +}=0D +=0D +UNIT_TEST_STATUS=0D +EFIAPI=0D +TestVerifyEncrypt (=0D + IN UNIT_TEST_CONTEXT Context=0D + )=0D +{=0D + BOOLEAN Status;=0D + UINT8 *OutBuffer =3D NULL;=0D + UINTN OutBufferSize =3D 0;=0D + UINT8 *OutBuffer2 =3D NULL;=0D + UINTN OutBuffer2Size =3D 0;=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx;=0D +=0D + TestCtx =3D (OAEP_ENC_DEC_TEST_CONTEXT *)Context;=0D +=0D + Status =3D TestCtx->Encrypt (=0D + TestCtx,=0D + TestCtx->ClearText,=0D + TestCtx->ClearTextSize,=0D + TestCtx->PrngSeed,=0D + TestCtx->PrngSeedSize,=0D + TestCtx->DigestLen,=0D + &OutBuffer,=0D + &OutBufferSize=0D + );=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D TestCtx->Encrypt (=0D + TestCtx,=0D + TestCtx->ClearText,=0D + TestCtx->ClearTextSize,=0D + TestCtx->PrngSeed,=0D + TestCtx->PrngSeedSize,=0D + TestCtx->DigestLen,=0D + &OutBuffer2,=0D + &OutBuffer2Size=0D + );=0D UT_ASSERT_TRUE (Status);=0D =0D // TRUE - the two OutBuffers are indentical. That means the Oaep encrypt= result is incorrect.=0D @@ -217,33 +476,34 @@ TestVerifyOaepEncrypt ( OutBuffer2Size =3D 0;=0D }=0D =0D - Status =3D Pkcs1v2Encrypt (=0D - SelfTestCert,=0D - (UINTN)sizeof (SelfTestCert),=0D - File,=0D - (UINTN)4,=0D - RandSeed,=0D - (UINTN)sizeof (RandSeed),=0D - &OutBuffer,=0D - (UINTN *)&OutBufferSize=0D - );=0D - UT_ASSERT_TRUE (Status);=0D + return UNIT_TEST_PASSED;=0D +}=0D =0D - Status =3D Pkcs1v2Encrypt (=0D - SelfTestCert,=0D - (UINTN)sizeof (SelfTestCert),=0D - File,=0D - (UINTN)4,=0D - RandSeed,=0D - (UINTN)sizeof (RandSeed),=0D - &OutBuffer2,=0D - (UINTN *)&OutBuffer2Size=0D - );=0D +UNIT_TEST_STATUS=0D +EFIAPI=0D +TestVerifyDecrypt (=0D + IN UNIT_TEST_CONTEXT Context=0D + )=0D +{=0D + BOOLEAN Status;=0D + UINT8 *OutBuffer =3D NULL;=0D + UINTN OutBufferSize =3D 0;=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx;=0D +=0D + TestCtx =3D Context;=0D +=0D + Status =3D TestCtx->Decrypt (=0D + TestCtx,=0D + TestCtx->CipherText,=0D + TestCtx->CipherTextSize,=0D + TestCtx->DigestLen,=0D + &OutBuffer,=0D + &OutBufferSize=0D + );=0D UT_ASSERT_TRUE (Status);=0D =0D - // TRUE - the two OutBuffers are indentical. That means the Oaep encrypt= result is incorrect.=0D - Status =3D (CompareMem (OutBuffer, OutBuffer2, OutBufferSize >=3D OutBuf= fer2Size ? OutBufferSize : OutBuffer2Size) =3D=3D 0);=0D - UT_ASSERT_FALSE (Status);=0D + UT_ASSERT_TRUE (CompareMem (OutBuffer, TestCtx->ClearText, OutBufferSize= >=3D TestCtx->ClearTextSize ? OutBufferSize : TestCtx->ClearTextSize) =3D= =3D 0);=0D + UT_ASSERT_TRUE (OutBufferSize =3D=3D TestCtx->ClearTextSize);=0D =0D if (OutBuffer) {=0D FreePool (OutBuffer);=0D @@ -251,16 +511,85 @@ TestVerifyOaepEncrypt ( OutBufferSize =3D 0;=0D }=0D =0D - if (OutBuffer2) {=0D - FreePool (OutBuffer2);=0D - OutBuffer2 =3D NULL;=0D - OutBuffer2Size =3D 0;=0D + return UNIT_TEST_PASSED;=0D +}=0D +=0D +UNIT_TEST_STATUS=0D +EFIAPI=0D +TestVerifyEncryptDecrypt (=0D + IN UNIT_TEST_CONTEXT Context=0D + )=0D +{=0D + BOOLEAN Status;=0D + UINT8 *ClearText =3D NULL;=0D + UINTN ClearTextSize =3D 0;=0D + UINT8 *CipherText =3D NULL;=0D + UINTN CipherTextSize =3D 0;=0D + OAEP_ENC_DEC_TEST_CONTEXT *TestCtx;=0D +=0D + TestCtx =3D Context;=0D +=0D + Status =3D TestCtx->Encrypt (=0D + TestCtx,=0D + TestCtx->ClearText,=0D + TestCtx->ClearTextSize,=0D + TestCtx->PrngSeed,=0D + TestCtx->PrngSeedSize,=0D + TestCtx->DigestLen,=0D + &CipherText,=0D + &CipherTextSize=0D + );=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D TestCtx->Decrypt (=0D + TestCtx,=0D + CipherText,=0D + CipherTextSize,=0D + TestCtx->DigestLen,=0D + &ClearText,=0D + &ClearTextSize=0D + );=0D +=0D + if (TestCtx->Expect =3D=3D UNIT_TEST_PASSED) {=0D + UT_ASSERT_TRUE (Status);=0D + } else {=0D + UT_ASSERT_FALSE (Status);=0D }=0D =0D + if (TestCtx->Expect =3D=3D UNIT_TEST_PASSED) {=0D + UT_ASSERT_TRUE (CompareMem (ClearText, TestCtx->ClearText, ClearTextSi= ze >=3D TestCtx->ClearTextSize ? ClearTextSize : TestCtx->ClearTextSize) = =3D=3D 0);=0D + UT_ASSERT_TRUE (ClearTextSize =3D=3D TestCtx->ClearTextSize);=0D + }=0D +=0D + if (CipherText) {=0D + FreePool (CipherText);=0D + CipherText =3D NULL;=0D + CipherTextSize =3D 0;=0D + }=0D +=0D + if (ClearText) {=0D + FreePool (ClearText);=0D + ClearText =3D NULL;=0D + ClearTextSize =3D 0;=0D + }=0D +=0D + return UNIT_TEST_PASSED;=0D +}=0D +=0D +UNIT_TEST_STATUS=0D +EFIAPI=0D +TestVerifyPkcs1v2EncryptInterface (=0D + IN UNIT_TEST_CONTEXT Context=0D + )=0D +{=0D + BOOLEAN Status;=0D + UINT8 *OutBuffer;=0D + UINTN OutBufferSize;=0D +=0D Status =3D Pkcs1v2Encrypt (=0D NULL,=0D (UINTN)sizeof (SelfTestCert),=0D - File,=0D + (UINT8 *)Msg1230,=0D (UINTN)4,=0D NULL,=0D 0,=0D @@ -272,7 +601,7 @@ TestVerifyOaepEncrypt ( Status =3D Pkcs1v2Encrypt (=0D SelfTestCert,=0D (UINTN)sizeof (SelfTestCert),=0D - File,=0D + (UINT8 *)Msg1230,=0D (UINTN)4,=0D NULL,=0D 0,=0D @@ -284,7 +613,7 @@ TestVerifyOaepEncrypt ( Status =3D Pkcs1v2Encrypt (=0D SelfTestCert,=0D (UINTN)sizeof (SelfTestCert),=0D - File,=0D + (UINT8 *)Msg1230,=0D (UINTN)4,=0D NULL,=0D 0,=0D @@ -296,11 +625,298 @@ TestVerifyOaepEncrypt ( return UNIT_TEST_PASSED;=0D }=0D =0D +UNIT_TEST_STATUS=0D +EFIAPI=0D +TestVerifyRsaOaepEncryptInterface (=0D + IN UNIT_TEST_CONTEXT Context=0D + )=0D +{=0D + VOID *RsaContext =3D NULL;=0D + BOOLEAN Status;=0D + UINT8 *OutBuffer;=0D + UINTN OutBufferSize;=0D +=0D + RsaContext =3D RsaNew ();=0D + UT_ASSERT_FALSE (RsaContext =3D=3D NULL);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyN, RsaN, sizeof (RsaN));=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaSetKey (RsaContext, RsaKeyE, RsaE, sizeof (RsaE));=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D RsaOaepEncrypt (=0D + NULL,=0D + (UINT8 *)Msg1230,=0D + (UINTN)4,=0D + NULL,=0D + 0,=0D + 0,=0D + &OutBuffer,=0D + (UINTN *)&OutBufferSize=0D + );=0D + UT_ASSERT_FALSE (Status);=0D +=0D + Status =3D RsaOaepEncrypt (=0D + RsaContext,=0D + (UINT8 *)Msg1230,=0D + (UINTN)4,=0D + NULL,=0D + 0,=0D + 0,=0D + (UINT8 **)NULL,=0D + (UINTN *)&OutBufferSize=0D + );=0D + UT_ASSERT_FALSE (Status);=0D +=0D + Status =3D RsaOaepEncrypt (=0D + RsaContext,=0D + (UINT8 *)Msg1230,=0D + (UINTN)4,=0D + NULL,=0D + 0,=0D + 0,=0D + &OutBuffer,=0D + (UINTN *)NULL=0D + );=0D + UT_ASSERT_FALSE (Status);=0D +=0D + return UNIT_TEST_PASSED;=0D +}=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyPkcs1v2Msg1230 =3D {=0D + .SelfTestCert =3D SelfTestCert,=0D + .SelfTestCertSize =3D sizeof (SelfTestCert),=0D + .PrivateKey =3D PrivateKey,=0D + .PrivateKeySize =3D sizeof (PrivateKey),=0D + .RsaN =3D NULL,=0D + .RsaNSize =3D 0,=0D + .RsaE =3D NULL,=0D + .RsaESize =3D 0,=0D + .RsaD =3D NULL,=0D + .RsaDSize =3D 0,=0D + .PrngSeed =3D NULL,=0D + .PrngSeedSize =3D 0,=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallPkcs1v2Encrypt,=0D + .Decrypt =3D CallPkcs1v2Decrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyPkcs1v2Msg1230PrngSeed =3D {=0D + .SelfTestCert =3D SelfTestCert,=0D + .SelfTestCertSize =3D sizeof (SelfTestCert),=0D + .PrivateKey =3D PrivateKey,=0D + .PrivateKeySize =3D sizeof (PrivateKey),=0D + .RsaN =3D NULL,=0D + .RsaNSize =3D 0,=0D + .RsaE =3D NULL,=0D + .RsaESize =3D 0,=0D + .RsaD =3D NULL,=0D + .RsaDSize =3D 0,=0D + .PrngSeed =3D RandSeed,=0D + .PrngSeedSize =3D sizeof (RandSeed),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallPkcs1v2Encrypt,=0D + .Decrypt =3D CallPkcs1v2Decrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaOaepMsg1230 =3D {=0D + .SelfTestCert =3D NULL,=0D + .SelfTestCertSize =3D 0,=0D + .PrivateKey =3D NULL,=0D + .PrivateKeySize =3D 0,=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .PrngSeed =3D NULL,=0D + .PrngSeedSize =3D 0,=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaOaepMsg1230PrngSeed =3D {=0D + .SelfTestCert =3D NULL,=0D + .SelfTestCertSize =3D 0,=0D + .PrivateKey =3D NULL,=0D + .PrivateKeySize =3D 0,=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .PrngSeed =3D RandSeed,=0D + .PrngSeedSize =3D sizeof (RandSeed),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyPkcs1v2EncryptRsaOaepDecrypt =3D {=0D + .SelfTestCert =3D SelfTestCert,=0D + .SelfTestCertSize =3D sizeof (SelfTestCert),=0D + .PrivateKey =3D PrivateKey,=0D + .PrivateKeySize =3D sizeof (PrivateKey),=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallPkcs1v2Encrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaOaepEncryptPkcs1v2Decrypt =3D {=0D + .SelfTestCert =3D SelfTestCert,=0D + .SelfTestCertSize =3D sizeof (SelfTestCert),=0D + .PrivateKey =3D PrivateKey,=0D + .PrivateKeySize =3D sizeof (PrivateKey),=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallPkcs1v2Decrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaesOaep2048MdDefaultBgf1Default = =3D {=0D + .SelfTestCert =3D NULL,=0D + .SelfTestCertSize =3D 0,=0D + .PrivateKey =3D NULL,=0D + .PrivateKeySize =3D 0,=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D 0,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaesOaep2048MdSha1Mgf1Sha1 =3D {=0D + .SelfTestCert =3D NULL,=0D + .SelfTestCertSize =3D 0,=0D + .PrivateKey =3D NULL,=0D + .PrivateKeySize =3D 0,=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaepMdSha1Mgf1Sha1,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaepMdSha1Mgf1Sha1),=0D + .DigestLen =3D SHA1_DIGEST_SIZE,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D +OAEP_ENC_DEC_TEST_CONTEXT mTestVerifyRsaesOaep2048MdSha256Mgf1Sha256 =3D = {=0D + .SelfTestCert =3D NULL,=0D + .SelfTestCertSize =3D 0,=0D + .PrivateKey =3D NULL,=0D + .PrivateKeySize =3D 0,=0D + .RsaN =3D RsaN,=0D + .RsaNSize =3D sizeof (RsaN),=0D + .RsaE =3D RsaE,=0D + .RsaESize =3D sizeof (RsaE),=0D + .RsaD =3D RsaD,=0D + .RsaDSize =3D sizeof (RsaD),=0D + .ClearText =3D Msg1230,=0D + .ClearTextSize =3D sizeof (Msg1230),=0D + .CipherText =3D Ct1230RsaesOaep2048MdSha256Mgf1Sha256,=0D + .CipherTextSize =3D sizeof (Ct1230RsaesOaep2048MdSha256Mgf1Sha256),=0D + .DigestLen =3D SHA256_DIGEST_SIZE,=0D + .Encrypt =3D CallRsaOaepEncrypt,=0D + .Decrypt =3D CallRsaOaepDecrypt,=0D + .Expect =3D UNIT_TEST_PASSED=0D +};=0D +=0D TEST_DESC mOaepTest[] =3D {=0D //=0D // -----Description--------------------------------------Class----------= ------------Function-----------------Pre---Post--Context=0D //=0D - { "TestVerifyOaepEncrypt()", "CryptoPkg.BaseCryptLib.Pkcs1v2Encrypt", Te= stVerifyOaepEncrypt, NULL, NULL, NULL },=0D + // Pkcs1v2Encrypt / Decrypt=0D + { "Pkcs1v2Encrypt (Interface)", "CryptoPkg.BaseCryptLi= b.Pkcs1v2Encrypt.Interface", TestVerifyPkcs1v2EncryptInte= rface, NULL, NULL, &mTestVerifyPkcs1v2Msg1230 },=0D + { "Pkcs1v2Encrypt (NoSeed)", "CryptoPkg.BaseCryptLi= b.Pkcs1v2Encrypt.NoSeed", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyPkcs1v2Msg1230 },=0D + { "Pkcs1v2Encrypt (Seeded)", "CryptoPkg.BaseCryptLi= b.Pkcs1v2Encrypt.Seeded", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyPkcs1v2Msg1230PrngSeed },=0D + { "Pkcs1v2Decrypt", "CryptoPkg.BaseCryptLi= b.Pkcs1v2Decrypt", TestVerifyDecrypt, = NULL, NULL, &mTestVerifyPkcs1v2Msg1230 },=0D + { "Pkcs1v2EncryptDecrypt", "CryptoPkg.BaseCryptLi= b.Pkcs1v2EncryptDecrypt", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyPkcs1v2Msg1230 },=0D +=0D + // RsaOaepEncrypt / Decrypt=0D + { "RsaOaepEncrypt (Interface)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.Interface", TestVerifyRsaOaepEncryptInte= rface, NULL, NULL, &mTestVerifyRsaOaepMsg1230 },=0D + { "RsaOaepEncrypt (NoSeed)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.NoSeed", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyRsaOaepMsg1230 },=0D + { "RsaOaepEncrypt (Seeded)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.Seeded", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyRsaOaepMsg1230PrngSeed },=0D + { "RsaOaepDecrypt", "CryptoPkg.BaseCryptLi= b.RsaOaepDecrypt", TestVerifyDecrypt, = NULL, NULL, &mTestVerifyRsaOaepMsg1230 },=0D + { "RsaOaepEncryptDecrypt", "CryptoPkg.BaseCryptLi= b.RsaOaepEncryptDecrypt", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyRsaOaepMsg1230 },=0D +=0D + // Mix interfaces=0D + { "RsaOaepEncryptPkcs1v2Decrypt", "CryptoPkg.BaseCryptLi= b.RsaOaepEncryptPkcs1v2Decrypt", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyRsaOaepEncryptPkcs1v2Decrypt },=0D + { "Pkcs1v2EncryptRsaOaepDecrypt", "CryptoPkg.BaseCryptLi= b.Pkcs1v2EncryptRsaOaepDecrypt", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyPkcs1v2EncryptRsaOaepDecrypt },=0D +=0D + // Message digest default / MGF1 default (SHA1)=0D + { "RsaOaepEncrypt (MdDefaultMgf1Default)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.MdDefaultMgf1Default", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdDefaultBgf1Default },=0D + { "RsaOaepDecrypt (MdDefaultMgf1Default)", "CryptoPkg.BaseCryptLi= b.RsaOaepDecrypt.MdDefaultMgf1Default", TestVerifyDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdDefaultBgf1Default },=0D + { "RsaOaepEncryptDecrypt (MdDefaultMgf1Default)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncryptDecrypt.MdDefaultMgf1Default", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdDefaultBgf1Default },=0D +=0D + // Message digest SHA1 / MGF1 SHA1=0D + { "RsaOaepEncrypt (MdSha1Bgf1Sha1", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.MdSha1Bgf1Sha1", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha1Mgf1Sha1 },=0D + { "RsaOaepDecrypt (MdSha1Bgf1Sha1)", "CryptoPkg.BaseCryptLi= b.RsaOaepDecrypt.MdSha1Bgf1Sha1", TestVerifyDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha1Mgf1Sha1 },=0D + { "RsaOaepEncryptDecrypt (MdSha1Bgf1Sha1)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncryptDecrypt.MdSha1Bgf1Sha1", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha1Mgf1Sha1 },=0D +=0D + // Message digest SHA256 / MGF1 SHA256=0D + { "RsaOaepEncrypt (MdSha256Bgf1Sha256)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncrypt.MdSha256Bgf1Sha256", TestVerifyEncrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha256Mgf1Sha256 },=0D + { "RsaOaepDecrypt (MdSha256Bgf1Sha256)", "CryptoPkg.BaseCryptLi= b.RsaOaepDecrypt.MdSha256Bgf1Sha256", TestVerifyDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha256Mgf1Sha256 },=0D + { "RsaOaepEncryptDecrypt (MdSha256Bgf1Sha256)", "CryptoPkg.BaseCryptLi= b.RsaOaepEncryptDecryptMdSha256Bgf1Sha256", TestVerifyEncryptDecrypt, = NULL, NULL, &mTestVerifyRsaesOaep2048MdSha256Mgf1Sha256 },=0D };=0D =0D UINTN mOaepTestNum =3D ARRAY_SIZE (mOaepTest);=0D --=20 2.44.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117252): https://edk2.groups.io/g/devel/message/117252 Mute This Topic: https://groups.io/mt/105239225/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-