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 B4188740032 for ; Tue, 12 Dec 2023 03:52:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ATvIDhUqtf8Sxd8Vf6OUgnIrLP6oHv+WHNB2MImRYc4=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Message-ID:Date:User-Agent:Subject:To:Cc:References:From:In-Reply-To:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702353136; v=1; b=N/IkKvO0LqiUvMmasceTfTKQIpFhahp6360XLtTml9oXsC7v99p/VM2O672WYaNfWgPy3OFu UgscjxIXyAf0ENNBOFgZSL+G6JYUTpM5hvW5onbS14dojPjz8R9L2fHEQ06N2q6dS4PdxL5RSbe xvQTTNrkOEhGcBIJbnL/j814= X-Received: by 127.0.0.2 with SMTP id JPv2YY7687511xl072N9OKH6; Mon, 11 Dec 2023 19:52:16 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.58]) by mx.groups.io with SMTP id smtpd.web11.5509.1702353135310452527 for ; Mon, 11 Dec 2023 19:52:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TyFBGqBQtGT7WIQ55kSFSB3CfgRmmICEr3WhZW7IQeEH/x3VvKoWf3YGdcEkHDfJiHYpvbEnvE9ZSzXTEKaSd8tldXJl0+gCLjj5TXLRpElpdJQOc34F6tY62qic5W/vsX+y0c9V2uBveeDh0l29s65RIsPgvOrGFO04TAyRt3CE7VJMx3NFR8ju/BJ4SGXzKCiBBg0BEuI1wCNA5mJmOBdHPXNyPD8cQUHqjmZ6MDwRMSzBR5sgB15HuzMlP/GBszQkLizecs7/jx3WQJau6mAHEXr4bXa7tVWKos3BqxCW33nv7D/ZmOLI04KGVGcFW5a3ar7GI6a7jDXP474etQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TnBcviLnMmtAjZh92oAc2w59QrYnlAhG3C5T7SJzjYw=; b=W9/9Z0x86gv3lxe1ye3urKQbCPsn0tLjfI3Z5DsUkI24BmbYPhk36gs7ffIXzJ42TtwWBYru7pIc5E/37UyI8DaSB5QnVwoPx9qBraXpxbKwnP793tz0BJuoXdgaJ3DAHinpReLDbF80Fo1ncHhDVCRQCCs90Yho19q7BzEa6UhNEeEQlBURQsDEkYehNvoxtvo6UB3FXarR2iBcD7j4CLX8a9rHU80RSaoday/GZr7pqAxH/cq8PLzWDxvDeDTw/7OSllNL04uQv/GkBVNUGhnjkNAPg45T7P7x8d7o/GcTYuB9GLrxZYFyVfwXEBdX2fiz+PcVkylbTMwa+3RmOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from CH3PR12MB9194.namprd12.prod.outlook.com (2603:10b6:610:19f::7) by CH3PR12MB7668.namprd12.prod.outlook.com (2603:10b6:610:14d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Tue, 12 Dec 2023 03:52:11 +0000 X-Received: from CH3PR12MB9194.namprd12.prod.outlook.com ([fe80::3112:5f54:2e51:cf89]) by CH3PR12MB9194.namprd12.prod.outlook.com ([fe80::3112:5f54:2e51:cf89%5]) with mapi id 15.20.7068.033; Tue, 12 Dec 2023 03:52:11 +0000 Message-ID: <1849bef7-bbb4-487d-b374-f09a7afc9e7f@amd.com> Date: Tue, 12 Dec 2023 14:52:02 +1100 User-Agent: Mozilla Thunderbird Beta Subject: Re: [edk2-devel] [PATCH v3 06/11] CryptoPkg: Add all .inf files for BaseCryptLibMbedTls To: devel@edk2.groups.io, wenxing.hou@intel.com Cc: Jiewen Yao , Yi Li , Xiaoyu Lu , Guomin Jiang References: <20230928153416.537-1-wenxing.hou@intel.com> <20230928153416.537-7-wenxing.hou@intel.com> From: "Alexey Kardashevskiy via groups.io" In-Reply-To: <20230928153416.537-7-wenxing.hou@intel.com> X-ClientProxiedBy: SYAPR01CA0011.ausprd01.prod.outlook.com (2603:10c6:1::23) To CH3PR12MB9194.namprd12.prod.outlook.com (2603:10b6:610:19f::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB9194:EE_|CH3PR12MB7668:EE_ X-MS-Office365-Filtering-Correlation-Id: 232a49c4-cb56-41b9-0aac-08dbfac5b7f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: hyQ8GI4+nEAC8PBb8bldVYRde/E1wAc1hxDeIOw8sYbVjxHje9c/f4mJDdzT7ZCBpcNR6dEjIC+rwaa4BukOWSPpwbrqsIaSY6heZVzT1myaEMlDUyBv+r69YMpmvnCF5xGTmOS7po5rcC++cCPg7Yq/hDmHbU5JSmj7sNB/37Eklj3yR4ydN+29Fay0EDjoIil5Jxygg0xX5NqmaY8cWyT0lMxsDRi7nllei6AN8ZXHEK2KFoNOA9cgwWvjdHMk305VrMZim911esahesicC+tvFp4iV7k3SspV5L+Xm4kZ5qseJZNPmynefaTadbkjZfXypVmGapdlZQcbzOPVYwVTV0WU/4hjb265uTA3oQzLTkP/urmqaEGs8IPO9JSvVdbq5notI9yscPzOKPXdIWTicb9szCitjBG83UWguDcMj5cC11M74wIZHsLxJYbiVkgJ/YMEe8P/3NgSlt8r1oqAqYMeAHRfSGDeKRqMCmeyICK39igy8gTX7KGs3EPXVAJ6GWzru67SSE3qx4lxnLWf4tWkxa8sGy+P/3pTgusO/AN1GR19jqowpERbfqkusPKrWB8KAEXVRFEeoTPBaYBqtYP9k+rdzgAg1Yiy+pMazGqmOrV1xu4chflFpHBhqIn4wUVZnwBpwXwpgeZxelo8Bv7/oWdlwL4ok4a4YHHrjCPJ+3V7n1PRv6JOMx+lnk7PR/561lvT2YvvE/ttoW5f3RK7NfDWB7ZifM0GOKVaIE5Af5HK82awaKnCxXmj X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L3RYUEZUNzc1S2FBclY0K2Nmd2NYbUdkTk9pei9DK05QVFZzcXFpQkkyRjVJ?= =?utf-8?B?VDdURW5GNzBpMkVkTHowRHhLUU83TURic1NvVUNwS1VBWkZkMjFOSENyeUl0?= =?utf-8?B?WjRyNUE3WlNsSHQ4Y00za3dVdGV5U2xIYzJKS0pkWFhzL0JJUmVFRW8wR2JH?= =?utf-8?B?L0kwcTNGVGk3eXJJMFVYYkJxdHNPdzdpSS9UOWhBMlpSTE5vWHIvSmRRNDFx?= =?utf-8?B?M3VTUjd1N2RGSXRDekNDcmw1ZnJWMmhyeTF0MHljd1VZWnJLeFpxUmFYMHpF?= =?utf-8?B?c2ptcmkvUkZuNWhyVW1wZDJsQm1WSlFEM3VhTWh3aHQra1BzVXYxWE9od2NR?= =?utf-8?B?SlgyNDMwb2tscXpvckpBcjNDWW5TejM5V1Y4UXFCTUhzYWMveFd4ZWcvTW1Y?= =?utf-8?B?VUY1NDV0Q0JvdE92NmlwSXNMQnFPMDUwYjZvK1JpVzRoMDhyalBPczZSbVln?= =?utf-8?B?OENWYUdkVTZVdVVTcnhtcUR4d3B2R2xSVGE3NnhRTk0zUHRvaGU0OHM3eGRQ?= =?utf-8?B?bmxIbXU1YTNpZlhieG91NFltUmNtb0lGTmdSUVZVK2p2M09WTTZHVWs1aW5z?= =?utf-8?B?OVhnT2kxVkxNRkIxRW5nKzhsZEF0dlpFQkRBVHdCakZUdEMrNCtUMk5TUGps?= =?utf-8?B?NEZaV2NIc3ZFTGVodTFuWks3bWd2Q0dicnVYeGlkV3A1TzMxbm1JbUJjaVM1?= =?utf-8?B?bUQ5Vk5tY0Z5MlcyaWhYRUl0aGZOUFJJK2NHTSt4THJSZGRlcVF2ZUpEckRv?= =?utf-8?B?SFZlWURSc3pKdUVsaHg3b2c2V040Z0l5cmZmRTkvc1ZoUWlaYysyVnc2eXZT?= =?utf-8?B?UTBGSmIxTlROLy9GcGRCUTczeTJoeGJFcys5d0I0elJjOFBNQllzTTlLbElV?= =?utf-8?B?b25HZFQ1a0diY2gySHM1SVJxVWhGZDFDTmFFeFVJdUZKeFU0UW9xR1FXOWNU?= =?utf-8?B?dEFiUUZNTEJKYmREeXpRS1N2MU5IL3JpT0ROdXVsaVJieDU5OGVvTVZXOEZu?= =?utf-8?B?b0JjcGhNRG1oUVlSckRJa0NLYVVIK2NqUmVsd1dtUkw1c2k4L3hsMGlPM0xF?= =?utf-8?B?dXFHYng4L2JMMk11Z0ZqT0M4NlpldW9nRDkwOCtIYXZCOXNXZUUzNzByM3R0?= =?utf-8?B?RnFBaXRoQTdlZmxTdjJORnpBSUlOVVBOWm1HWVRIZXgxVVZVNmVuMUdTMTMx?= =?utf-8?B?NTZDTnIrekFXMDlsZTMyb29LeE1NemlpdGZodTI1d0ZmWmJTU3AyNUlrQk1x?= =?utf-8?B?dzVzUVl6U3pGWVJ6aHRzZFA3Zm14b2pvcVpnM2N4VmhsNHV4TDRXK3VyK0ln?= =?utf-8?B?UitkNXJ0ZjNBUEJ5ek5hTDJGMEwxWWpmdnVVN2FTdEVTdy93ajRTbnk3aDgz?= =?utf-8?B?YWJ4UWhERDBOTy9ZbnhSSnZSVW1Yd1RyL2Y2b0RpNU5kazg4K2tyV0ladGc0?= =?utf-8?B?cHpuRXJSeXVzdjFpTGl3d3orNWpDSlhybk0xTXh4RVg3c1BXV1RnZThVVFZE?= =?utf-8?B?SSs5cVNacnBOWDAwejdQNjRXcjhLd2d1RnJ5RlZVMEtzbWZhRk0xWEN3UjVy?= =?utf-8?B?cFRtNzNHUHUzVndwRmNUbW0zbldCSm0vRHE5U1ZGY3hUaE5DMnZzU2ltSHFM?= =?utf-8?B?V0ZHTVk1K0cwbllsaFpIV2hYKy9uYXZ2dlh6UXluQ1NUNXZCWXhHZG1YbkRK?= =?utf-8?B?SGVabHBHOFhEV3B1VVVsNHNtVVZBbWY5d3NDMkE5MWYrdDBSbi9iemVWMWs0?= =?utf-8?B?YXNzN2J1d1lNcHprbERKM2xVUFlxYTdHYmp1VHZPRUM3SE1jZEVEQVBTMnk1?= =?utf-8?B?K3VGUnEybFV6S250RG9wL2lSaE5GMUNXR3dGdXczL3FYOG54dFpTeTlsK1lO?= =?utf-8?B?L09Ic2NBcXBQbUpuc3lCZnk4N24rWWduWGtFV2VlRGlTT3hLT2lBMS9lT2dG?= =?utf-8?B?SVVib1lobzk5TGVBcnc1Q1g4TlViZG9NcmR4Y0VHMlVRS3hBMUI5REtsQ01C?= =?utf-8?B?WHFkbURrUDBscHlXSVhLN1hvVlFwZHBPcGFyVVJWT3FLYlI0U3JmaXVOeTJw?= =?utf-8?B?ckpzTVFnb3RtYThIRHNNem1VcWM5S2hjTlhlbkRYalJDV1ZIc29JUVR1MGVO?= =?utf-8?Q?AdPVrHGNWGYIXpe6IdeuI46Kn?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 232a49c4-cb56-41b9-0aac-08dbfac5b7f6 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB9194.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 03:52:10.9847 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SMl8DyHDhRB4AiSg4fReGaBjNF+l06dOdIzaKftTXTt8tbL8J+TfRoDHk0A0kg3D8e9cSkx9u5h694zfttqBWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7668 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 Reply-To: devel@edk2.groups.io,aik@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: srWW7MR7pnoWj7h1H0ZN22B5x7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="N/IkKvO0"; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi, This broke build: nice build -q --cmd-len=3D64436 -n 20 -t GCC5 -a X64 -p OvmfPkg/OvmfPkgX64.= dsc build.py... /home/aik/p/o-snp/CryptoPkg/CryptoPkg.dec(32): error 000E:=20 File/directory not found in workspace /home/aik/p/o-snp/CryptoPkg/Library/MbedTlsLib/mbedtls/include What am I missing? Thanks, On 29/9/23 01:34, Wenxing Hou via groups.io wrote: > Add .inf files and other support files. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4177 >=20 > Cc: Jiewen Yao > Cc: Yi Li > Cc: Xiaoyu Lu > Cc: Guomin Jiang > Signed-off-by: Wenxing Hou > --- > CryptoPkg/CryptoPkg.dec | 4 + > CryptoPkg/CryptoPkgMbedTls.dsc | 280 +++++++++++ > .../BaseCryptLibMbedTls/BaseCryptLib.inf | 81 +++ > .../BaseCryptLibMbedTls/PeiCryptLib.inf | 101 ++++ > .../BaseCryptLibMbedTls/PeiCryptLib.uni | 25 + > .../BaseCryptLibMbedTls/RuntimeCryptLib.inf | 92 ++++ > .../BaseCryptLibMbedTls/RuntimeCryptLib.uni | 22 + > .../BaseCryptLibMbedTls/SecCryptLib.inf | 84 ++++ > .../BaseCryptLibMbedTls/SecCryptLib.uni | 17 + > .../BaseCryptLibMbedTls/SmmCryptLib.inf | 92 ++++ > .../BaseCryptLibMbedTls/SmmCryptLib.uni | 22 + > .../SysCall/ConstantTimeClock.c | 75 +++ > .../BaseCryptLibMbedTls/SysCall/CrtWrapper.c | 58 +++ > .../SysCall/RuntimeMemAllocation.c | 462 ++++++++++++++++++ > .../SysCall/TimerWrapper.c | 198 ++++++++ > .../BaseCryptLibMbedTls/TestBaseCryptLib.inf | 76 +++ > CryptoPkg/Library/Include/stdint.h | 19 + > CryptoPkg/Library/Include/stubs-32.h | 9 + > CryptoPkg/Library/MbedTlsLib/EcSm2Null.c | 2 +- > 19 files changed, 1718 insertions(+), 1 deletion(-) > create mode 100644 CryptoPkg/CryptoPkgMbedTls.dsc > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.i= nf > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.in= f > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.un= i > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLi= b.inf > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLi= b.uni > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.in= f > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.un= i > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.in= f > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.un= i > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/Consta= ntTimeClock.c > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWra= pper.c > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/Runtim= eMemAllocation.c > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerW= rapper.c > create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptL= ib.inf > create mode 100644 CryptoPkg/Library/Include/stdint.h > create mode 100644 CryptoPkg/Library/Include/stubs-32.h >=20 > diff --git a/CryptoPkg/CryptoPkg.dec b/CryptoPkg/CryptoPkg.dec > index 0c7d16109b..a5fa81a338 100644 > --- a/CryptoPkg/CryptoPkg.dec > +++ b/CryptoPkg/CryptoPkg.dec > @@ -27,6 +27,10 @@ > Library/OpensslLib/openssl/providers/implementations/include > Library/OpensslLib/OpensslGen/include > Library/OpensslLib/OpensslGen/providers/common/include > + Library/MbedTlsLib/Include > + Library/MbedTlsLib/mbedtls > + Library/MbedTlsLib/mbedtls/include > + Library/MbedTlsLib/mbedtls/include/mbedtls > =20 > [LibraryClasses] > ## @libraryclass Provides basic library functions for cryptographic= primitives. > diff --git a/CryptoPkg/CryptoPkgMbedTls.dsc b/CryptoPkg/CryptoPkgMbedTls.= dsc > new file mode 100644 > index 0000000000..5d0ae6ff3f > --- /dev/null > +++ b/CryptoPkg/CryptoPkgMbedTls.dsc > @@ -0,0 +1,280 @@ > +## @file > +# Cryptographic Library Package for UEFI Security Implementation. > +# PEIM, DXE Driver, and SMM Driver with all crypto services enabled. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +########################################################################= ######## > +# > +# Defines Section - statements that will be processed to create a Makefi= le. > +# > +########################################################################= ######## > +[Defines] > + PLATFORM_NAME =3D CryptoPkg > + PLATFORM_GUID =3D E1063286-6C8C-4c25-AEF0-67A9A5B6E6B= 6 > + PLATFORM_VERSION =3D 0.98 > + DSC_SPECIFICATION =3D 0x00010005 > + OUTPUT_DIRECTORY =3D Build/CryptoPkgMbed > + SUPPORTED_ARCHITECTURES =3D IA32|X64|ARM|AARCH64|RISCV64 > + BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT > + SKUID_IDENTIFIER =3D DEFAULT > + > +!ifndef CRYPTO_IMG_TYPE > + DEFINE CRYPTO_IMG_TYPE =3D DXE_SMM > +!endif > + > +!if $(CRYPTO_IMG_TYPE) IN "PEI_DEFAULT PEI_PREMEM DXE_SMM" > +!else > + !error CRYPTO_IMG_TYPE must be set to one of PEI_DEFAULT PEI_PREMEM DX= E_SMM. > +!endif > + > +########################################################################= ######## > +# > +# Library Class section - list of all Library Classes needed by this Pla= tform. > +# > +########################################################################= ######## > + > +!include MdePkg/MdeLibs.dsc.inc > +[LibraryClasses] > + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf > + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiB= ootServicesTableLib.inf > + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEnt= ryPoint.inf > + BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf > + TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf > + HashApiLib|CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.inf > + RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf > + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroni= zationLib.inf > + > +[LibraryClasses.ARM, LibraryClasses.AARCH64] > + # > + # It is not possible to prevent the ARM compiler for generic intrinsic= functions. > + # This library provides the instrinsic functions generate by a given c= ompiler. > + # [LibraryClasses.ARM, LibraryClasses.AARCH64] and NULL mean link this= library > + # into all ARM and AARCH64 images. > + # > + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf > + > + # Add support for stack protector > + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf > + > +[LibraryClasses.common.PEIM] > + PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAll= ocationLib.inf > + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/P= eiServicesTablePointerLib.inf > + PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf > + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf > + > +[LibraryClasses.common.DXE_SMM_DRIVER] > + SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTabl= eLib.inf > + MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAll= ocationLib.inf > + MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLi= b.inf > + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroni= zationLib.inf > + > +[LibraryClasses] > + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryA= llocationLib.inf > + DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDeb= ugLibReportStatusCode.inf > + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Bas= eDebugPrintErrorLevelLib.inf > + OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/Oem= HookStatusCodeLibNull.inf > + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf > + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf > + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf > + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTempl= ate.inf > + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib= /UefiRuntimeServicesTableLib.inf > + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > + MbedTlsLib|CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf > + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf > + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > + > +[LibraryClasses.ARM] > + ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf > + > +[LibraryClasses.common.PEIM] > + PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf > + ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRep= ortStatusCodeLib.inf > + BaseCryptLib|CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf > + TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf > + > +[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM] > + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibId= t/PeiServicesTablePointerLibIdt.inf > + > +[LibraryClasses.ARM.PEIM, LibraryClasses.AARCH64.PEIM] > + PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/P= eiServicesTablePointerLib.inf > + > +[LibraryClasses.common.DXE_DRIVER] > + ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeRep= ortStatusCodeLib.inf > + BaseCryptLib|CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf > + TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf > + > +[LibraryClasses.common.DXE_SMM_DRIVER] > + ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmRep= ortStatusCodeLib.inf > + BaseCryptLib|CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf > + TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf > + > +########################################################################= ######## > +# > +# Pcd Section - list of all EDK II PCD Entries defined by this Platform > +# > +########################################################################= ######## > +[PcdsFixedAtBuild] > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f > + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000 > + gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06 > + > +!if $(CRYPTO_IMG_TYPE) IN "DXE_SMM" > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacMd5.Famil= y | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Fami= ly | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Fa= mily | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md4.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Random.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.X509.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tdes.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Arc4.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Hkdf.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tls.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsSet.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsGet.Family= | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.ParallelHash.= Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > +!endif > + > +!if $(CRYPTO_IMG_TYPE) IN "PEI_DEFAULT" > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Family = | PCD_CRYPTO_SERVICE_ENABLE_FAMILY > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.= Pkcs1Verify | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.= New | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.= SetKey | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.= Free | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Services= .GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Services= .Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Services= .Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Services= .Final | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Final | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Final | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.HashAll | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= Final | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= HashAll | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Services.= Duplicate | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.New | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.Free | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.SetKey | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.Duplicate | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Se= rvices.Final | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Hkdf.Services= .Sha256ExtractAndExpand | TRUE > +!endif > + > +!if $(CRYPTO_IMG_TYPE) IN "PEI_PREMEM" > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Servic= es.Final | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.Final | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Servic= es.HashAll | TRUE > + > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Servic= es.GetContextSize | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Servic= es.Init | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Servic= es.Update | TRUE > + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Servic= es.Final | TRUE > +!endif > + > +########################################################################= ########################### > +# > +# Components Section - list of the modules and components that will be p= rocessed by compilation > +# tools and the EDK II tools to generate PE32/PE32+= /Coff image files. > +# > +# Note: The EDK II DSC file is not used to specify how compiled binary i= mages get placed > +# into firmware volume images. This section is just a list of modu= les to compile from > +# source into UEFI-compliant binaries. > +# It is the FDF file that contains information on combining binary= files into firmware > +# volume images, whose concept is beyond UEFI and is described in = PI specification. > +# Binary modules do not need to be listed in this section, as they= should be > +# specified in the FDF file. For example: Shell binary (Shell_Full= .efi), FAT binary (Fat.efi), > +# Logo (Logo.bmp), and etc. > +# There may also be modules listed in this section that are not re= quired in the FDF file, > +# When a module listed here is excluded from FDF file, then UEFI-c= ompliant binary will be > +# generated for it, but the binary will not be put into any firmwa= re volume. > +# > +########################################################################= ########################### > + > +!if $(CRYPTO_IMG_TYPE) IN "PEI_DEFAULT PEI_PREMEM" > +[Components.IA32, Components.X64, Components.ARM, Components.AARCH64] > + CryptoPkg/Driver/CryptoPei.inf { > + > + !if "$(CRYPTO_SERVICES)" =3D=3D "ALL" > + FILE_GUID =3D 8DF53C2E-3380-495F-A8B7-370CFE28E1C6 > + !elseif "$(CRYPTO_SERVICES)" =3D=3D "NONE" > + FILE_GUID =3D E5A97EE3-71CC-407F-9DA9-6BE0C8A6C7DF > + !elseif "$(CRYPTO_SERVICES)" =3D=3D "MIN_PEI" > + FILE_GUID =3D 0F5827A9-35FD-4F41-8D38-9BAFCE594D31 > + !endif > + } > +!endif > + > +!if $(CRYPTO_IMG_TYPE) IN "DXE_SMM" > +[Components.IA32, Components.X64, Components.AARCH64] > + CryptoPkg/Driver/CryptoDxe.inf { > + > + !if "$(CRYPTO_SERVICES)" =3D=3D "ALL" > + FILE_GUID =3D D9444B06-060D-42C5-9344-F04707BE0169 > + !elseif "$(CRYPTO_SERVICES)" =3D=3D "NONE" > + FILE_GUID =3D C7A340F4-A6CC-4F95-A2DA-42BEA4C3944A > + !elseif "$(CRYPTO_SERVICES)" =3D=3D MIN_DXE_MIN_SMM > + FILE_GUID =3D DDF5BE9E-159A-4B77-B6D7-82B84B5763A2 > + !endif > + } > + > +[Components.IA32, Components.X64] > + CryptoPkg/Driver/CryptoSmm.inf { > + > + !if "$(CRYPTO_SERVICES)" =3D=3D "ALL" > + FILE_GUID =3D A3542CE8-77F7-49DC-A834-45D37D2EC1FA > + !elseif "$(CRYPTO_SERVICES)" =3D=3D "NONE" > + FILE_GUID =3D 6DCB3127-01E7-4131-A487-DC77A965A541 > + !elseif "$(CRYPTO_SERVICES)" =3D=3D MIN_DXE_MIN_SMM > + FILE_GUID =3D 85F7EA15-3A2B-474A-8875-180542CD6BF3 > + !endif > + } > +!endif > + > +[BuildOptions] > + *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES > + MSFT:*_*_*_CC_FLAGS =3D /D ENABLE_MD5_DEPRECATED_INTERFACES > + INTEL:*_*_*_CC_FLAGS =3D /D ENABLE_MD5_DEPRECATED_INTERFACES > + GCC:*_*_*_CC_FLAGS =3D -D ENABLE_MD5_DEPRECATED_INTERFACES > + RVCT:*_*_*_CC_FLAGS =3D -DENABLE_MD5_DEPRECATED_INTERFACES > +!if $(CRYPTO_IMG_TYPE) IN "DXE_SMM" > + MSFT:*_*_*_DLINK_FLAGS =3D /ALIGN:4096 > + GCC:*_GCC*_*_DLINK_FLAGS =3D -z common-page-size=3D0x1000 > +!endif > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf b/Cry= ptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf > new file mode 100644 > index 0000000000..16def792c5 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf > @@ -0,0 +1,81 @@ > +## @file > +# Cryptographic Library Instance for DXE_DRIVER. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D BaseCryptLib > + FILE_GUID =3D 693C5308-AF95-4CE5-ADE9-CA011C2FC64= 2 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BaseCryptLib|DXE_DRIVER DXE_CORE UE= FI_APPLICATION UEFI_DRIVER > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + InternalCryptLib.h > + Cipher/CryptAeadAesGcmNull.c > + Cipher/CryptAes.c > + Hash/CryptSha256.c > + Hash/CryptSha512.c > + Hash/CryptParallelHashNull.c > + Hash/CryptSm3Null.c > + Hash/CryptMd5.c > + Hash/CryptSha1.c > + Hmac/CryptHmac.c > + Kdf/CryptHkdf.c > + Pk/CryptRsaBasic.c > + Pk/CryptRsaExtNull.c > + Pk/CryptRsaPss.c > + Pk/CryptRsaPssSignNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + SysCall/TimerWrapper.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + MemoryAllocationLib > + UefiRuntimeServicesTableLib > + DebugLib > + MbedTlsLib > + PrintLib > + IntrinsicLib > + RngLib > + SynchronizationLib > +[Protocols] > + gEfiMpServiceProtocolGuid > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + MSFT:*_*_*_CC_FLAGS =3D /GL- > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf b/Cryp= toPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf > new file mode 100644 > index 0000000000..72b22a24e8 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf > @@ -0,0 +1,101 @@ > +## @file > +# Cryptographic Library Instance for PEIM. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Note: > +# HMAC-SHA256 functions, AES functions, RSA external > +# functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions= , X.509 > +# certificate handler functions, authenticode signature verification fu= nctions, > +# PEM handler functions, and pseudorandom number generator functions ar= e not > +# supported in this instance. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D PeiCryptLib > + MODULE_UNI_FILE =3D PeiCryptLib.uni > + FILE_GUID =3D 91E0A3C3-37A7-4AEE-8689-C5B0AD2C8E6= 3 > + MODULE_TYPE =3D PEIM > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BaseCryptLib|PEIM PEI_CORE > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + InternalCryptLib.h > + Hash/CryptMd5.c > + Hash/CryptSha1.c > + Hash/CryptSha256.c > + Hash/CryptSm3Null.c > + Hash/CryptSha512.c > + Hash/CryptParallelHashNull.c > + Hmac/CryptHmac.c > + Kdf/CryptHkdf.c > + Cipher/CryptAes.c > + Cipher/CryptAeadAesGcmNull.c > + Pk/CryptRsaBasic.c > + Pk/CryptRsaExtNull.c > + Pk/CryptRsaPss.c > + Pk/CryptRsaPssSignNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + SysCall/ConstantTimeClock.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + MemoryAllocationLib > + DebugLib > + MbedTlsLib > + IntrinsicLib > + PrintLib > + PeiServicesTablePointerLib > + PeiServicesLib > + SynchronizationLib > + > +[Ppis] > + gEfiPeiMpServicesPpiGuid > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + # > + # suppress the following warnings so we do not break the build with wa= rnings-as-errors: > + # C4090: 'function' : different 'const' qualifiers > + # C4718: 'function call' : recursive call has no side effects, deletin= g > + # > + MSFT:*_*_*_CC_FLAGS =3D /wd4090 /wd4718 > + > + GCC:*_CLANG35_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANG38_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANGPDB_*_CC_FLAGS =3D -std=3Dc99 -Wno-error=3Dincompatible-poi= nter-types > + > + XCODE:*_*_*_CC_FLAGS =3D -std=3Dc99 > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.uni b/Cryp= toPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.uni > new file mode 100644 > index 0000000000..3a6845642d > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.uni > @@ -0,0 +1,25 @@ > +// /** @file > +// Cryptographic Library Instance for PEIM. > +// > +// Caution: This module requires additional review when modified. > +// This library will have external input - signature. > +// This external input must be validated carefully to avoid security iss= ues such as > +// buffer overflow or integer overflow. > +// > +// Note: AES > +// functions, RSA external functions, PKCS#7 SignedData sign functions, > +// Diffie-Hellman functions, X.509 certificate handler functions, authen= ticode > +// signature verification functions, PEM handler functions, and pseudora= ndom number > +// generator functions are not supported in this instance. > +// > +// Copyright (c) 2023, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > + > +#string STR_MODULE_ABSTRACT #language en-US "Cryptographic L= ibrary Instance for PEIM" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Caution: This m= odule requires additional review when modified. This library will have exte= rnal input - signature. This external input must be validated carefully to = avoid security issues such as buffer overflow or integer overflow. Note: AE= S functions, RSA external functions, PKCS#7 SignedData sign functions, Diff= ie-Hellman functions, X.509 certificate handler functions, authenticode sig= nature verification functions, PEM handler functions, and pseudorandom numb= er generator functions are not supported in this instance." > + > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf b/= CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf > new file mode 100644 > index 0000000000..9f17ef00bf > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf > @@ -0,0 +1,92 @@ > +## @file > +# Cryptographic Library Instance for DXE_RUNTIME_DRIVER. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Note: SHA-384 Digest functions, SHA-512 Digest functions, > +# HMAC-SHA256 functions, AES functions, RSA external > +# functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions= , and > +# authenticode signature verification functions are not supported in th= is instance. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D RuntimeCryptLib > + MODULE_UNI_FILE =3D RuntimeCryptLib.uni > + FILE_GUID =3D D263B580-D9FC-4DC4-B445-578AAEFF530= E > + MODULE_TYPE =3D DXE_RUNTIME_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BaseCryptLib|DXE_RUNTIME_DRIVER > + CONSTRUCTOR =3D RuntimeCryptLibConstructor > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + InternalCryptLib.h > + Hash/CryptMd5.c > + Hash/CryptSha1.c > + Hash/CryptSha256.c > + Hash/CryptSm3Null.c > + Hash/CryptSha512.c > + Hash/CryptParallelHashNull.c > + Hmac/CryptHmac.c > + Kdf/CryptHkdf.c > + Cipher/CryptAes.c > + Cipher/CryptAeadAesGcmNull.c > + Pk/CryptRsaBasic.c > + Pk/CryptRsaExtNull.c > + Pk/CryptRsaPssNull.c > + Pk/CryptRsaPssSignNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + SysCall/TimerWrapper.c > + SysCall/RuntimeMemAllocation.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + UefiRuntimeServicesTableLib > + DebugLib > + MbedTlsLib > + IntrinsicLib > + PrintLib > + > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + # > + # suppress the following warnings so we do not break the build with wa= rnings-as-errors: > + # > + GCC:*_CLANG35_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANG38_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANGPDB_*_CC_FLAGS =3D -std=3Dc99 -Wno-error=3Dincompatible-poi= nter-types > + > + XCODE:*_*_*_CC_FLAGS =3D -std=3Dc99 > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.uni b/= CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.uni > new file mode 100644 > index 0000000000..b2a2f5ff21 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.uni > @@ -0,0 +1,22 @@ > +// /** @file > +// Cryptographic Library Instance for DXE_RUNTIME_DRIVER. > +// > +// Caution: This module requires additional review when modified. > +// This library will have external input - signature. > +// This external input must be validated carefully to avoid security iss= ues such as > +// buffer overflow or integer overflow. > +// > +// Note: AES > +// functions, RSA external functions, PKCS#7 SignedData sign functions, > +// Diffie-Hellman functions, and authenticode signature verification fun= ctions are > +// not supported in this instance. > +// > +// Copyright (c) 2023, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > +#string STR_MODULE_ABSTRACT #language en-US "Cryptographic L= ibrary Instance for DXE_RUNTIME_DRIVER" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Caution: This m= odule requires additional review when modified. This library will have exte= rnal input - signature. This external input must be validated carefully to = avoid security issues such as buffer overflow or integer overflow. Note: AE= S functions, RSA external functions, PKCS#7 SignedData sign functions, Diff= ie-Hellman functions, and authenticode signature verification functions are= not supported in this instance." > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.inf b/Cryp= toPkg/Library/BaseCryptLibMbedTls/SecCryptLib.inf > new file mode 100644 > index 0000000000..6fc073aac6 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.inf > @@ -0,0 +1,84 @@ > +## @file > +# Cryptographic Library Instance for SEC. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D SecCryptLib > + MODULE_UNI_FILE =3D SecCryptLib.uni > + FILE_GUID =3D 894C367F-254A-4563-8624-798D46EAD79= 6 > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BaseCryptLib|SEC > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + InternalCryptLib.h > + Hash/CryptSha512.c > + > + Hash/CryptMd5Null.c > + Hash/CryptSha1Null.c > + Hash/CryptSha256Null.c > + Hash/CryptSm3Null.c > + Hash/CryptParallelHashNull.c > + Hmac/CryptHmacNull.c > + Kdf/CryptHkdfNull.c > + Cipher/CryptAesNull.c > + Cipher/CryptAeadAesGcmNull.c > + Pk/CryptRsaBasicNull.c > + Pk/CryptRsaExtNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + SysCall/ConstantTimeClock.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + MemoryAllocationLib > + DebugLib > + MbedTlsLib > + IntrinsicLib > + PrintLib > + > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + # > + # suppress the following warnings so we do not break the build with wa= rnings-as-errors: > + # > + GCC:*_CLANG35_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANG38_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANGPDB_*_CC_FLAGS =3D -std=3Dc99 -Wno-error=3Dincompatible-poi= nter-types > + > + XCODE:*_*_*_CC_FLAGS =3D -std=3Dc99 > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.uni b/Cryp= toPkg/Library/BaseCryptLibMbedTls/SecCryptLib.uni > new file mode 100644 > index 0000000000..be2fc4067f > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.uni > @@ -0,0 +1,17 @@ > +// /** @file > +// Cryptographic Library Instance for SEC driver. > +// > +// Caution: This module requires additional review when modified. > +// This library will have external input - signature. > +// This external input must be validated carefully to avoid security iss= ues such as > +// buffer overflow or integer overflow. > +// > +// Copyright (c) 2023, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > +#string STR_MODULE_ABSTRACT #language en-US "Cryptographic L= ibrary Instance for SEC driver" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Caution: This m= odule requires additional review when modified. This library will have exte= rnal input - signature. This external input must be validated carefully to = avoid security issues such as buffer overflow or integer overflow. Note: AE= S functions, RSA external functions, PKCS#7 SignedData sign functions, Diff= ie-Hellman functions, and authenticode signature verification functions are= not supported in this instance." > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf b/Cryp= toPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf > new file mode 100644 > index 0000000000..40c56d1b7d > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf > @@ -0,0 +1,92 @@ > +## @file > +# Cryptographic Library Instance for SMM driver. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Note: SHA-384 Digest functions, SHA-512 Digest functions, > +# RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hell= man functions, and > +# authenticode signature verification functions are not supported in th= is instance. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D SmmCryptLib > + MODULE_UNI_FILE =3D SmmCryptLib.uni > + FILE_GUID =3D CF104633-9901-4504-AD7A-91690926A25= 3 > + MODULE_TYPE =3D DXE_SMM_DRIVER > + VERSION_STRING =3D 1.0 > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + LIBRARY_CLASS =3D BaseCryptLib|DXE_SMM_DRIVER SMM_COR= E MM_STANDALONE > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + InternalCryptLib.h > + Hash/CryptMd5.c > + Hash/CryptSha1.c > + Hash/CryptSha256.c > + Hash/CryptSm3Null.c > + Hash/CryptSha512.c > + Hash/CryptParallelHashNull.c > + Hmac/CryptHmac.c > + Kdf/CryptHkdf.c > + Cipher/CryptAes.c > + Cipher/CryptAeadAesGcmNull.c > + Pk/CryptRsaBasic.c > + Pk/CryptRsaExtNull.c > + Pk/CryptRsaPss.c > + Pk/CryptRsaPssSignNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + SysCall/ConstantTimeClock.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + MemoryAllocationLib > + MbedTlsLib > + IntrinsicLib > + PrintLib > + MmServicesTableLib > + SynchronizationLib > + > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + # > + # suppress the following warnings so we do not break the build with wa= rnings-as-errors: > + # > + > + XCODE:*_*_*_CC_FLAGS =3D -mmmx -msse -std=3Dc99 > + > + GCC:*_CLANG35_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANG38_*_CC_FLAGS =3D -std=3Dc99 > + GCC:*_CLANGPDB_*_CC_FLAGS =3D -std=3Dc99 -Wno-error=3Dincompatible-poi= nter-types > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.uni b/Cryp= toPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.uni > new file mode 100644 > index 0000000000..13948c2f3d > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.uni > @@ -0,0 +1,22 @@ > +// /** @file > +// Cryptographic Library Instance for SMM driver. > +// > +// Caution: This module requires additional review when modified. > +// This library will have external input - signature. > +// This external input must be validated carefully to avoid security iss= ues such as > +// buffer overflow or integer overflow. > +// > +// Note: AES > +// functions, RSA external functions, PKCS#7 SignedData sign functions, > +// Diffie-Hellman functions, and authenticode signature verification fun= ctions are > +// not supported in this instance. > +// > +// Copyright (c) 2023, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > +#string STR_MODULE_ABSTRACT #language en-US "Cryptographic L= ibrary Instance for SMM driver" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Caution: This m= odule requires additional review when modified. This library will have exte= rnal input - signature. This external input must be validated carefully to = avoid security issues such as buffer overflow or integer overflow. Note: AE= S functions, RSA external functions, PKCS#7 SignedData sign functions, Diff= ie-Hellman functions, and authenticode signature verification functions are= not supported in this instance." > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeCl= ock.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c > new file mode 100644 > index 0000000000..2ec13ef9d0 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c > @@ -0,0 +1,75 @@ > +/** @file > + C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementa= tion > + for MbedTLS-based Cryptographic Library. > + > + This C file implements constant time value for time() and NULL for gmt= ime() > + thus should not be used in library instances which require functionali= ty > + of following APIs which need system time support: > + 1) RsaGenerateKey > + 2) RsaCheckKey > + 3) RsaPkcs1Sign > + 4) Pkcs7Sign > + 5) DhGenerateParameter > + 6) DhGenerateKey > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > + > +typedef int time_t; > + > +// > +// Structures Definitions > +// > +struct tm { > + int tm_sec; /* seconds after the minute [0-60] */ > + int tm_min; /* minutes after the hour [0-59] */ > + int tm_hour; /* hours since midnight [0-23] */ > + int tm_mday; /* day of the month [1-31] */ > + int tm_mon; /* months since January [0-11] */ > + int tm_year; /* years since 1900 */ > + int tm_wday; /* days since Sunday [0-6] */ > + int tm_yday; /* days since January 1 [0-365] */ > + int tm_isdst; /* Daylight Savings Time flag */ > + long tm_gmtoff; /* offset from CUT in seconds */ > + char *tm_zone; /* timezone abbreviation */ > +}; > + > +// > +// -- Time Management Routines -- > +// > + > +/**time function. **/ > +time_t > +time ( > + time_t *timer > + ) > +{ > + if (timer !=3D NULL) { > + *timer =3D 0; > + } > + > + return 0; > +} > + > +/**gmtime function. **/ > +struct tm * > +gmtime ( > + const time_t *timer > + ) > +{ > + return NULL; > +} > + > +/**_time64 function. **/ > +time_t > +_time64 ( > + time_t *t > + ) > +{ > + return time (t); > +} > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c b= /CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c > new file mode 100644 > index 0000000000..f1d9b9c35c > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c > @@ -0,0 +1,58 @@ > +/** @file > + C Run-Time Libraries (CRT) Wrapper Implementation for MbedTLS-based > + Cryptographic Library. > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > + > +/**dummy mbedtls_printf function. **/ > +int > +mbedtls_printf ( > + char const *fmt, > + ... > + ) > +{ > + ASSERT (FALSE); > + return 0; > +} > + > +/**dummy mbedtls_vsnprintf function. **/ > +int > +mbedtls_vsnprintf ( > + char *str, > + size_t size, > + const char *format, > + ... > + ) > +{ > + ASSERT (FALSE); > + return 0; > +} > + > +/**strchr function. **/ > +char * > +strchr ( > + const char *str, > + int ch > + ) > +{ > + return ScanMem8 (str, AsciiStrSize (str), (char)ch); > +} > + > +/**strcmp function. **/ > +int > +strcmp ( > + const char *s1, > + const char *s2 > + ) > +{ > + return (int)AsciiStrCmp (s1, s2); > +} > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/RuntimeMemAllo= cation.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/RuntimeMemAllocati= on.c > new file mode 100644 > index 0000000000..51992029a8 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/RuntimeMemAllocation.= c > @@ -0,0 +1,462 @@ > +/** @file > + Light-weight Memory Management Routines for MbedTLS-based Crypto > + Library at Runtime Phase. > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > + > +// ---------------------------------------------------------------- > +// Initial version. Needs further optimizations. > +// ---------------------------------------------------------------- > + > +// > +// Definitions for Runtime Memory Operations > +// > +#define RT_PAGE_SIZE 0x200 > +#define RT_PAGE_MASK 0x1FF > +#define RT_PAGE_SHIFT 9 > + > +#define RT_SIZE_TO_PAGES(a) (((a) >> RT_PAGE_SHIFT) + (((a) & RT_PAGE_M= ASK) ? 1 : 0)) > +#define RT_PAGES_TO_SIZE(a) ((a) << RT_PAGE_SHIFT) > + > +// > +// Page Flag Definitions > +// > +#define RT_PAGE_FREE 0x00000000 > +#define RT_PAGE_USED 0x00000001 > + > +#define MIN_REQUIRED_BLOCKS 600 > + > +// > +// Memory Page Table > +// > +typedef struct { > + UINTN StartPageOffset; // Offset of the starting page allocated= . > + // Only available for USED pages. > + UINT32 PageFlag; // Page Attributes. > +} RT_MEMORY_PAGE_ENTRY; > + > +typedef struct { > + UINTN PageCount; > + UINTN LastEmptyPageOffset; > + UINT8 *DataAreaBase; // Pointer to data Area. > + RT_MEMORY_PAGE_ENTRY Pages[1]; // Page Table Entries. > +} RT_MEMORY_PAGE_TABLE; > + > +// > +// Global Page Table for Runtime Cryptographic Provider. > +// > +RT_MEMORY_PAGE_TABLE *mRTPageTable =3D NULL; > + > +// > +// Event for Runtime Address Conversion. > +// > +STATIC EFI_EVENT mVirtualAddressChangeEvent; > + > +/** > + Initializes pre-allocated memory pointed by ScratchBuffer for subseque= nt > + runtime use. > + > + @param[in, out] ScratchBuffer Pointer to user-supplied memory bu= ffer. > + @param[in] ScratchBufferSize Size of supplied buffer in bytes. > + > + @retval EFI_SUCCESS Successful initialization. > + > +**/ > +EFI_STATUS > +InitializeScratchMemory ( > + IN OUT UINT8 *ScratchBuffer, > + IN UINTN ScratchBufferSize > + ) > +{ > + UINTN Index; > + UINTN MemorySize; > + > + // > + // Parameters Checking > + // > + if (ScratchBuffer =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (ScratchBufferSize < MIN_REQUIRED_BLOCKS * 1024) { > + return EFI_BUFFER_TOO_SMALL; > + } > + > + mRTPageTable =3D (RT_MEMORY_PAGE_TABLE *)ScratchBuffer; > + > + // > + // Initialize Internal Page Table for Memory Management > + // > + SetMem (mRTPageTable, ScratchBufferSize, 0xFF); > + MemorySize =3D ScratchBufferSize - sizeof (RT_MEMORY_PAGE_TABLE) + siz= eof (RT_MEMORY_PAGE_ENTRY); > + > + mRTPageTable->PageCount =3D MemorySize / (RT_PAGE_SIZE + siz= eof (RT_MEMORY_PAGE_ENTRY)); > + mRTPageTable->LastEmptyPageOffset =3D 0x0; > + > + for (Index =3D 0; Index < mRTPageTable->PageCount; Index++) { > + mRTPageTable->Pages[Index].PageFlag =3D RT_PAGE_FREE; > + mRTPageTable->Pages[Index].StartPageOffset =3D 0; > + } > + > + mRTPageTable->DataAreaBase =3D ScratchBuffer + sizeof (RT_MEMORY_PAGE_= TABLE) + > + (mRTPageTable->PageCount - 1) * sizeof (R= T_MEMORY_PAGE_ENTRY); > + > + return EFI_SUCCESS; > +} > + > +/** > + Look-up Free memory Region for object allocation. > + > + @param[in] AllocationSize Bytes to be allocated. > + > + @return Return available page offset for object allocation. > + > +**/ > +UINTN > +LookupFreeMemRegion ( > + IN UINTN AllocationSize > + ) > +{ > + UINTN StartPageIndex; > + UINTN Index; > + UINTN SubIndex; > + UINTN ReqPages; > + > + StartPageIndex =3D RT_SIZE_TO_PAGES (mRTPageTable->LastEmptyPageOffset= ); > + ReqPages =3D RT_SIZE_TO_PAGES (AllocationSize); > + if (ReqPages > mRTPageTable->PageCount) { > + // > + // No enough region for object allocation. > + // > + return (UINTN)(-1); > + } > + > + // > + // Look up the free memory region with in current memory map table. > + // > + for (Index =3D StartPageIndex; Index <=3D (mRTPageTable->PageCount - R= eqPages); ) { > + // > + // Check consecutive ReqPages pages. > + // > + for (SubIndex =3D 0; SubIndex < ReqPages; SubIndex++) { > + if ((mRTPageTable->Pages[SubIndex + Index].PageFlag & RT_PAGE_USED= ) !=3D 0) { > + break; > + } > + } > + > + if (SubIndex =3D=3D ReqPages) { > + // > + // Succeed! Return the Starting Offset. > + // > + return RT_PAGES_TO_SIZE (Index); > + } > + > + // > + // Failed! Skip current free memory pages and adjacent Used pages > + // > + while ((mRTPageTable->Pages[SubIndex + Index].PageFlag & RT_PAGE_USE= D) !=3D 0) { > + SubIndex++; > + } > + > + Index +=3D SubIndex; > + } > + > + // > + // Look up the free memory region from the beginning of the memory tab= le > + // until the StartCursorOffset > + // > + if (ReqPages > StartPageIndex) { > + // > + // No enough region for object allocation. > + // > + return (UINTN)(-1); > + } > + > + for (Index =3D 0; Index < (StartPageIndex - ReqPages); ) { > + // > + // Check Consecutive ReqPages Pages. > + // > + for (SubIndex =3D 0; SubIndex < ReqPages; SubIndex++) { > + if ((mRTPageTable->Pages[SubIndex + Index].PageFlag & RT_PAGE_USED= ) !=3D 0) { > + break; > + } > + } > + > + if (SubIndex =3D=3D ReqPages) { > + // > + // Succeed! Return the Starting Offset. > + // > + return RT_PAGES_TO_SIZE (Index); > + } > + > + // > + // Failed! Skip current adjacent Used pages > + // > + while ((SubIndex < (StartPageIndex - ReqPages)) && > + ((mRTPageTable->Pages[SubIndex + Index].PageFlag & RT_PAGE_US= ED) !=3D 0)) > + { > + SubIndex++; > + } > + > + Index +=3D SubIndex; > + } > + > + // > + // No available region for object allocation! > + // > + return (UINTN)(-1); > +} > + > +/** > + Allocates a buffer at runtime phase. > + > + @param[in] AllocationSize Bytes to be allocated. > + > + @return A pointer to the allocated buffer or NULL if allocation fails= . > + > +**/ > +VOID * > +RuntimeAllocateMem ( > + IN UINTN AllocationSize > + ) > +{ > + UINT8 *AllocPtr; > + UINTN ReqPages; > + UINTN Index; > + UINTN StartPage; > + UINTN AllocOffset; > + > + AllocPtr =3D NULL; > + ReqPages =3D 0; > + > + // > + // Look for available consecutive memory region starting from LastEmpt= yPageOffset. > + // If no proper memory region found, look up from the beginning. > + // If still not found, return NULL to indicate failed allocation. > + // > + AllocOffset =3D LookupFreeMemRegion (AllocationSize); > + if (AllocOffset =3D=3D (UINTN)(-1)) { > + return NULL; > + } > + > + // > + // Allocates consecutive memory pages with length of Size. Update the = page > + // table status. Returns the starting address. > + // > + ReqPages =3D RT_SIZE_TO_PAGES (AllocationSize); > + AllocPtr =3D mRTPageTable->DataAreaBase + AllocOffset; > + StartPage =3D RT_SIZE_TO_PAGES (AllocOffset); > + Index =3D 0; > + while (Index < ReqPages) { > + mRTPageTable->Pages[StartPage + Index].PageFlag |=3D RT_PAGE_U= SED; > + mRTPageTable->Pages[StartPage + Index].StartPageOffset =3D AllocOffs= et; > + > + Index++; > + } > + > + mRTPageTable->LastEmptyPageOffset =3D AllocOffset + RT_PAGES_TO_SIZE (= ReqPages); > + > + ZeroMem (AllocPtr, AllocationSize); > + > + // > + // Returns a VOID pointer to the allocated space > + // > + return AllocPtr; > +} > + > +/** > + Frees a buffer that was previously allocated at runtime phase. > + > + @param[in] Buffer Pointer to the buffer to free. > + > +**/ > +VOID > +RuntimeFreeMem ( > + IN VOID *Buffer > + ) > +{ > + UINTN StartOffset; > + UINTN StartPageIndex; > + > + StartOffset =3D (UINTN)Buffer - (UINTN)mRTPageTable->DataAreaBase; > + StartPageIndex =3D RT_SIZE_TO_PAGES (mRTPageTable->Pages[RT_SIZE_TO_PA= GES (StartOffset)].StartPageOffset); > + > + while (StartPageIndex < mRTPageTable->PageCount) { > + if (((mRTPageTable->Pages[StartPageIndex].PageFlag & RT_PAGE_USED) != =3D 0) && > + (mRTPageTable->Pages[StartPageIndex].StartPageOffset =3D=3D Star= tOffset)) > + { > + // > + // Free this page > + // > + mRTPageTable->Pages[StartPageIndex].PageFlag &=3D ~RT_PAGE_U= SED; > + mRTPageTable->Pages[StartPageIndex].PageFlag |=3D RT_PAGE_FR= EE; > + mRTPageTable->Pages[StartPageIndex].StartPageOffset =3D 0; > + > + StartPageIndex++; > + } else { > + break; > + } > + } > + > + return; > +} > + > +/** > + Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. > + > + This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRE= SS_CHANGE > + event. It converts a pointer to a new virtual address. > + > + @param[in] Event The event whose notification function is being = invoked. > + @param[in] Context The pointer to the notification function's cont= ext. > + > +**/ > +VOID > +EFIAPI > +RuntimeCryptLibAddressChangeEvent ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + // > + // Converts a pointer for runtime memory management to a new virtual a= ddress. > + // > + EfiConvertPointer (0x0, (VOID **)&mRTPageTable->DataAreaBase); > + EfiConvertPointer (0x0, (VOID **)&mRTPageTable); > +} > + > +/** > + Constructor routine for runtime crypt library instance. > + > + The constructor function pre-allocates space for runtime cryptographic= operation. > + > + @param ImageHandle The firmware allocated handle for the EFI image. > + @param SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The construction succeeded. > + @retval EFI_OUT_OF_RESOURCE Failed to allocate memory. > + > +**/ > +EFI_STATUS > +EFIAPI > +RuntimeCryptLibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + VOID *Buffer; > + > + // > + // Pre-allocates runtime space for possible cryptographic operations > + // > + Buffer =3D AllocateRuntimePool (MIN_REQUIRED_BLOCKS * 1024); > + Status =3D InitializeScratchMemory (Buffer, MIN_REQUIRED_BLOCKS * 1024= ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Create address change event > + // > + Status =3D gBS->CreateEventEx ( > + EVT_NOTIFY_SIGNAL, > + TPL_NOTIFY, > + RuntimeCryptLibAddressChangeEvent, > + NULL, > + &gEfiEventVirtualAddressChangeGuid, > + &mVirtualAddressChangeEvent > + ); > + ASSERT_EFI_ERROR (Status); > + > + return Status; > +} > + > +// > +// -- Memory-Allocation Routines Wrapper for UEFI-MbedTLS Library -- > +// > + > +/** Allocates memory blocks. **/ > +VOID * > +malloc ( > + size_t size > + ) > +{ > + return RuntimeAllocateMem ((UINTN)size); > +} > + > +/** Reallocate memory blocks. **/ > +VOID * > +realloc ( > + VOID *ptr, > + size_t size > + ) > +{ > + VOID *NewPtr; > + UINTN StartOffset; > + UINTN StartPageIndex; > + UINTN PageCount; > + > + if (ptr =3D=3D NULL) { > + return malloc (size); > + } > + > + // > + // Get Original Size of ptr > + // > + StartOffset =3D (UINTN)ptr - (UINTN)mRTPageTable->DataAreaBase; > + StartPageIndex =3D RT_SIZE_TO_PAGES (mRTPageTable->Pages[RT_SIZE_TO_PA= GES (StartOffset)].StartPageOffset); > + PageCount =3D 0; > + while (StartPageIndex < mRTPageTable->PageCount) { > + if (((mRTPageTable->Pages[StartPageIndex].PageFlag & RT_PAGE_USED) != =3D 0) && > + (mRTPageTable->Pages[StartPageIndex].StartPageOffset =3D=3D Star= tOffset)) > + { > + StartPageIndex++; > + PageCount++; > + } else { > + break; > + } > + } > + > + if (size <=3D RT_PAGES_TO_SIZE (PageCount)) { > + // > + // Return the original pointer, if Caller try to reduce region size; > + // > + return ptr; > + } > + > + NewPtr =3D RuntimeAllocateMem ((UINTN)size); > + if (NewPtr =3D=3D NULL) { > + return NULL; > + } > + > + CopyMem (NewPtr, ptr, RT_PAGES_TO_SIZE (PageCount)); > + > + RuntimeFreeMem (ptr); > + > + return NewPtr; > +} > + > +/** Deallocates or frees a memory block. **/ > +VOID > +free ( > + VOID *ptr > + ) > +{ > + // > + // In Standard C, free() handles a null pointer argument transparently= . This > + // is not true of RuntimeFreeMem() below, so protect it. > + // > + if (ptr !=3D NULL) { > + RuntimeFreeMem (ptr); > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c= b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c > new file mode 100644 > index 0000000000..b7cd4d3181 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c > @@ -0,0 +1,198 @@ > +/** @file > + C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementa= tion > + for MbedTLS-based Cryptographic Library (used in DXE & RUNTIME). > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > + > +typedef int time_t; > + > +// > +// Structures Definitions > +// > +struct tm { > + int tm_sec; /* seconds after the minute [0-60] */ > + int tm_min; /* minutes after the hour [0-59] */ > + int tm_hour; /* hours since midnight [0-23] */ > + int tm_mday; /* day of the month [1-31] */ > + int tm_mon; /* months since January [0-11] */ > + int tm_year; /* years since 1900 */ > + int tm_wday; /* days since Sunday [0-6] */ > + int tm_yday; /* days since January 1 [0-365] */ > + int tm_isdst; /* Daylight Savings Time flag */ > + long tm_gmtoff; /* offset from CUT in seconds */ > + char *tm_zone; /* timezone abbreviation */ > +}; > + > +// > +// -- Time Management Routines -- > +// > + > +#define IsLeap(y) (((y) % 4) =3D=3D 0 && (((y) % 100) !=3D 0 || ((y) % = 400) =3D=3D 0)) > +#define SECSPERMIN (60) > +#define SECSPERHOUR (60 * 60) > +#define SECSPERDAY (24 * SECSPERHOUR) > + > +// > +// The arrays give the cumulative number of days up to the first of the > +// month number used as the index (1 -> 12) for regular and leap years. > +// The value at index 13 is for the whole year. > +// > +UINTN CumulativeDays[2][14] =3D { > + { > + 0, > + 0, > + 31, > + 31 + 28, > + 31 + 28 + 31, > + 31 + 28 + 31 + 30, > + 31 + 28 + 31 + 30 + 31, > + 31 + 28 + 31 + 30 + 31 + 30, > + 31 + 28 + 31 + 30 + 31 + 30 + 31, > + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, > + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, > + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, > + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, > + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 > + }, > + { > + 0, > + 0, > + 31, > + 31 + 29, > + 31 + 29 + 31, > + 31 + 29 + 31 + 30, > + 31 + 29 + 31 + 30 + 31, > + 31 + 29 + 31 + 30 + 31 + 30, > + 31 + 29 + 31 + 30 + 31 + 30 + 31, > + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31, > + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30, > + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, > + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, > + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 > + } > +}; > + > +/** Get the system time as seconds elapsed since midnight, January 1, 19= 70. **/ > +time_t > +time ( > + time_t *timer > + ) > +{ > + EFI_STATUS Status; > + EFI_TIME Time; > + time_t CalTime; > + UINTN Year; > + > + // > + // Get the current time and date information > + // > + Status =3D gRT->GetTime (&Time, NULL); > + if (EFI_ERROR (Status) || (Time.Year < 1970)) { > + return 0; > + } > + > + // > + // Years Handling > + // UTime should now be set to 00:00:00 on Jan 1 of the current year. > + // > + for (Year =3D 1970, CalTime =3D 0; Year !=3D Time.Year; Year++) { > + CalTime =3D CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * S= ECSPERDAY); > + } > + > + // > + // Add in number of seconds for current Month, Day, Hour, Minute, Seco= nds, and TimeZone adjustment > + // > + CalTime =3D CalTime + > + (time_t)((Time.TimeZone !=3D EFI_UNSPECIFIED_TIMEZONE) ? (Ti= me.TimeZone * 60) : 0) + > + (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SE= CSPERDAY) + > + (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) + > + (time_t)(Time.Hour * SECSPERHOUR) + > + (time_t)(Time.Minute * 60) + > + (time_t)Time.Second; > + > + if (timer !=3D NULL) { > + *timer =3D CalTime; > + } > + > + return CalTime; > +} > + > +/** Convert a time value from type time_t to struct tm. **/ > +struct tm * > +gmtime ( > + const time_t *timer > + ) > +{ > + struct tm *GmTime; > + UINT16 DayNo; > + UINT16 DayRemainder; > + time_t Year; > + time_t YearNo; > + UINT16 TotalDays; > + UINT16 MonthNo; > + > + if (timer =3D=3D NULL) { > + return NULL; > + } > + > + GmTime =3D AllocateZeroPool (sizeof (struct tm)); > + if (GmTime =3D=3D NULL) { > + return NULL; > + } > + > + ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm)); > + > + DayNo =3D (UINT16)(*timer / SECSPERDAY); > + DayRemainder =3D (UINT16)(*timer % SECSPERDAY); > + > + GmTime->tm_sec =3D (int)(DayRemainder % SECSPERMIN); > + GmTime->tm_min =3D (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN); > + GmTime->tm_hour =3D (int)(DayRemainder / SECSPERHOUR); > + GmTime->tm_wday =3D (int)((DayNo + 4) % 7); > + > + for (Year =3D 1970, YearNo =3D 0; DayNo > 0; Year++) { > + TotalDays =3D (UINT16)(IsLeap (Year) ? 366 : 365); > + if (DayNo >=3D TotalDays) { > + DayNo =3D (UINT16)(DayNo - TotalDays); > + YearNo++; > + } else { > + break; > + } > + } > + > + GmTime->tm_year =3D (int)(YearNo + (1970 - 1900)); > + GmTime->tm_yday =3D (int)DayNo; > + > + for (MonthNo =3D 12; MonthNo > 1; MonthNo--) { > + if (DayNo >=3D CumulativeDays[IsLeap (Year)][MonthNo]) { > + DayNo =3D (UINT16)(DayNo - (UINT16)(CumulativeDays[IsLeap (Year)][= MonthNo])); > + break; > + } > + } > + > + GmTime->tm_mon =3D (int)MonthNo - 1; > + GmTime->tm_mday =3D (int)DayNo + 1; > + > + GmTime->tm_isdst =3D 0; > + GmTime->tm_gmtoff =3D 0; > + GmTime->tm_zone =3D NULL; > + > + return GmTime; > +} > + > +/**_time64 function. **/ > +time_t > +_time64 ( > + time_t *t > + ) > +{ > + return time (t); > +} > diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf b= /CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf > new file mode 100644 > index 0000000000..def990b996 > --- /dev/null > +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf > @@ -0,0 +1,76 @@ > +## @file > +# Cryptographic Library Instance for DXE_DRIVER. > +# > +# Caution: This module requires additional review when modified. > +# This library will have external input - signature. > +# This external input must be validated carefully to avoid security iss= ues such as > +# buffer overflow or integer overflow. > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D BaseCryptLib > + FILE_GUID =3D 9DD60CFE-9D05-41E2-8B9E-958E2A4C191= 3 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BaseCryptLib|DXE_DRIVER DXE_CORE UE= FI_APPLICATION UEFI_DRIVER > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + InternalCryptLib.h > + Cipher/CryptAeadAesGcmNull.c > + Cipher/CryptAes.c > + Hash/CryptSha256.c > + Hash/CryptSha512.c > + Hash/CryptSm3Null.c > + Hash/CryptMd5.c > + Hash/CryptSha1.c > + Hmac/CryptHmac.c > + Kdf/CryptHkdf.c > + Pk/CryptRsaBasic.c > + Pk/CryptRsaExtNull.c > + Pk/CryptRsaPss.c > + Pk/CryptRsaPssSignNull.c > + Bn/CryptBnNull.c > + Pem/CryptPemNull.c > + Pk/CryptDhNull.c > + Pk/CryptEcNull.c > + Pk/CryptPkcs1OaepNull.c > + Pk/CryptPkcs5Pbkdf2Null.c > + Pk/CryptPkcs7SignNull.c > + Pk/CryptPkcs7VerifyNull.c > + Pk/CryptPkcs7VerifyEkuNull.c > + Pk/CryptX509Null.c > + Pk/CryptAuthenticodeNull.c > + Pk/CryptTsNull.c > + Rand/CryptRandNull.c > + SysCall/CrtWrapper.c > + > +[Packages] > + MdePkg/MdePkg.dec > + CryptoPkg/CryptoPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + MemoryAllocationLib > + UefiRuntimeServicesTableLib > + DebugLib > + MbedTlsLib > + PrintLib > + RngLib > + > +# > +# Remove these [BuildOptions] after this library is cleaned up > +# > +[BuildOptions] > + MSFT:*_*_*_CC_FLAGS =3D /GL- > diff --git a/CryptoPkg/Library/Include/stdint.h b/CryptoPkg/Library/Inclu= de/stdint.h > new file mode 100644 > index 0000000000..17b8c767d7 > --- /dev/null > +++ b/CryptoPkg/Library/Include/stdint.h > @@ -0,0 +1,19 @@ > +/** @file > + Include file to support building the third-party cryptographic library= . > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +typedef INT8 int8_t; > +typedef UINT8 uint8_t; > +typedef INT16 int16_t; > +typedef UINT16 uint16_t; > +typedef INT32 int32_t; > +typedef UINT32 uint32_t; > +typedef INT64 int64_t; > +typedef UINT64 uint64_t; > +typedef UINTN uintptr_t; > diff --git a/CryptoPkg/Library/Include/stubs-32.h b/CryptoPkg/Library/Inc= lude/stubs-32.h > new file mode 100644 > index 0000000000..786d57e8d5 > --- /dev/null > +++ b/CryptoPkg/Library/Include/stubs-32.h > @@ -0,0 +1,9 @@ > +/** @file > + Include file to support building the third-party cryptographic library= . > + > +Copyright (c) 2023, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > diff --git a/CryptoPkg/Library/MbedTlsLib/EcSm2Null.c b/CryptoPkg/Library= /MbedTlsLib/EcSm2Null.c > index c7d5c393a1..1c9cd72b70 100644 > --- a/CryptoPkg/Library/MbedTlsLib/EcSm2Null.c > +++ b/CryptoPkg/Library/MbedTlsLib/EcSm2Null.c > @@ -12,7 +12,7 @@ > #include > #include > #include > -#include > +#include > =20 > /* > * Get the curve info for the internal identifier --=20 Alexey -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112356): https://edk2.groups.io/g/devel/message/112356 Mute This Topic: https://groups.io/mt/101639981/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-