From 20333c6d566748d7c78c1b546ba8f37c6d253dea Mon Sep 17 00:00:00 2001 From: Qin Long Date: Fri, 14 Nov 2014 08:41:12 +0000 Subject: UEFI 2.4 X509 Certificate Hash and RFC3161 Timestamp Verification support for Secure Boot Main ChangeLogs includes: 1. Introduce the new GUID and structure definitions for certificate hash and timestamp support; 2. Update Image Verification Library to support DBT signature checking; 3. Update the related SecureBoot Configuration Pages; Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long Reviewed-by: Guo Dong Reviewed-by: Siyuan Fu git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16380 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Guid/ImageAuthentication.h | 159 ++++++++++++++++++++++-------- MdePkg/MdePkg.dec | 33 ++++--- 2 files changed, 139 insertions(+), 53 deletions(-) (limited to 'MdePkg') diff --git a/MdePkg/Include/Guid/ImageAuthentication.h b/MdePkg/Include/Guid/ImageAuthentication.h index 8b46e7356b..427a7d47bb 100644 --- a/MdePkg/Include/Guid/ImageAuthentication.h +++ b/MdePkg/Include/Guid/ImageAuthentication.h @@ -1,23 +1,24 @@ /** @file Image signature database are defined for the signed image validation. - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php + Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @par Revision Reference: - GUIDs defined in UEFI 2.3.1 spec. + GUIDs defined in UEFI 2.4 spec. **/ #ifndef __IMAGE_AUTHTICATION_H__ #define __IMAGE_AUTHTICATION_H__ #include +#include #define EFI_IMAGE_SECURITY_DATABASE_GUID \ { \ @@ -25,15 +26,20 @@ } /// -/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID /// for the authorized signature database. /// #define EFI_IMAGE_SECURITY_DATABASE L"db" /// -/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID /// for the forbidden signature database. /// #define EFI_IMAGE_SECURITY_DATABASE1 L"dbx" +/// +/// Variable name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// for the timestamp signature database. +/// +#define EFI_IMAGE_SECURITY_DATABASE2 L"dbt" #define SECURE_BOOT_MODE_ENABLE 1 #define SECURE_BOOT_MODE_DISABLE 0 @@ -45,7 +51,7 @@ // Signature Database //*********************************************************************** /// -/// The format of a signature database. +/// The format of a signature database. /// #pragma pack(1) @@ -76,17 +82,50 @@ typedef struct { /// /// Size of each signature. /// - UINT32 SignatureSize; + UINT32 SignatureSize; /// - /// Header before the array of signatures. The format of this header is specified + /// Header before the array of signatures. The format of this header is specified /// by the SignatureType. /// UINT8 SignatureHeader[SignatureHeaderSize]; /// - /// An array of signatures. Each signature is SignatureSize bytes in length. + /// An array of signatures. Each signature is SignatureSize bytes in length. /// EFI_SIGNATURE_DATA Signatures[][SignatureSize]; /// } EFI_SIGNATURE_LIST; +typedef struct { + /// + /// The SHA256 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA256_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA256; + +typedef struct { + /// + /// The SHA384 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA384_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA384; + +typedef struct { + /// + /// The SHA512 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA512_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA512; + #pragma pack() /// @@ -103,7 +142,7 @@ typedef struct { /// This identifies a signature containing an RSA-2048 key. The key (only the modulus /// since the public key exponent is known to be 0x10001) shall be stored in big-endian /// order. -/// The SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size +/// The SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size /// of SignatureOwner component) + 256 bytes. /// #define EFI_CERT_RSA2048_GUID \ @@ -112,8 +151,8 @@ typedef struct { } /// -/// This identifies a signature containing a RSA-2048 signature of a SHA-256 hash. The -/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of +/// This identifies a signature containing a RSA-2048 signature of a SHA-256 hash. The +/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of /// SignatureOwner component) + 256 bytes. /// #define EFI_CERT_RSA2048_SHA256_GUID \ @@ -131,8 +170,8 @@ typedef struct { } /// -/// TThis identifies a signature containing a RSA-2048 signature of a SHA-1 hash. The -/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of +/// TThis identifies a signature containing a RSA-2048 signature of a SHA-1 hash. The +/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of /// SignatureOwner component) + 256 bytes. /// #define EFI_CERT_RSA2048_SHA1_GUID \ @@ -142,11 +181,11 @@ typedef struct { /// /// This identifies a signature based on an X.509 certificate. If the signature is an X.509 -/// certificate then verification of the signature of an image should validate the public -/// key certificate in the image using certificate path verification, up to this X.509 +/// certificate then verification of the signature of an image should validate the public +/// key certificate in the image using certificate path verification, up to this X.509 /// certificate as a trusted root. The SignatureHeader size shall always be 0. The -/// SignatureSize may vary but shall always be 16 (size of the SignatureOwner component) + -/// the size of the certificate itself. +/// SignatureSize may vary but shall always be 16 (size of the SignatureOwner component) + +/// the size of the certificate itself. /// Note: This means that each certificate will normally be in a separate EFI_SIGNATURE_LIST. /// #define EFI_CERT_X509_GUID \ @@ -172,7 +211,7 @@ typedef struct { #define EFI_CERT_SHA384_GUID \ { \ 0xff3e5307, 0x9fd0, 0x48c9, {0x85, 0xf1, 0x8a, 0xd5, 0x6c, 0x70, 0x1e, 0x1} \ - } + } /// /// This identifies a signature containing a SHA-512 hash. The SignatureHeader size shall @@ -184,6 +223,45 @@ typedef struct { 0x93e0fae, 0xa6c4, 0x4f50, {0x9f, 0x1b, 0xd4, 0x1e, 0x2b, 0x89, 0xc1, 0x9a} \ } +/// +/// This identifies a signature containing the SHA256 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 48 bytes for an EFI_CERT_X509_SHA256 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA256_GUID \ + { \ + 0x3bd2a492, 0x96c0, 0x4079, {0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed } \ + } + +/// +/// This identifies a signature containing the SHA384 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 64 bytes for an EFI_CERT_X509_SHA384 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA384_GUID \ + { \ + 0x7076876e, 0x80c2, 0x4ee6, {0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b } \ + } + +/// +/// This identifies a signature containing the SHA512 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 80 bytes for an EFI_CERT_X509_SHA512 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA512_GUID \ + { \ + 0x446dbf63, 0x2502, 0x4cda, {0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d } \ + } + /// /// This identifies a signature containing a DER-encoded PKCS #7 version 1.5 [RFC2315] /// SignedData value. @@ -192,13 +270,13 @@ typedef struct { { \ 0x4aafd29d, 0x68df, 0x49ee, {0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7} \ } - + //*********************************************************************** // Image Execution Information Table Definition //*********************************************************************** typedef UINT32 EFI_IMAGE_EXECUTION_ACTION; -#define EFI_IMAGE_EXECUTION_AUTHENTICATION 0x00000007 +#define EFI_IMAGE_EXECUTION_AUTHENTICATION 0x00000007 #define EFI_IMAGE_EXECUTION_AUTH_UNTESTED 0x00000000 #define EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED 0x00000001 #define EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED 0x00000002 @@ -208,7 +286,7 @@ typedef UINT32 EFI_IMAGE_EXECUTION_ACTION; #define EFI_IMAGE_EXECUTION_INITIALIZED 0x00000008 // -// EFI_IMAGE_EXECUTION_INFO is added to EFI System Configuration Table +// EFI_IMAGE_EXECUTION_INFO is added to EFI System Configuration Table // and assigned the GUID EFI_IMAGE_SECURITY_DATABASE_GUID. // typedef struct { @@ -221,24 +299,24 @@ typedef struct { /// UINT32 InfoSize; /// - /// If this image was a UEFI device driver (for option ROM, for example) this is the - /// null-terminated, user-friendly name for the device. If the image was for an application, - /// then this is the name of the application. If this cannot be determined, then a simple + /// If this image was a UEFI device driver (for option ROM, for example) this is the + /// null-terminated, user-friendly name for the device. If the image was for an application, + /// then this is the name of the application. If this cannot be determined, then a simple /// NULL character should be put in this position. /// CHAR16 Name[]; /// /// - /// For device drivers, this is the device path of the device for which this device driver - /// was intended. In some cases, the driver itself may be stored as part of the system - /// firmware, but this field should record the device's path, not the firmware path. For - /// applications, this is the device path of the application. If this cannot be determined, + /// For device drivers, this is the device path of the device for which this device driver + /// was intended. In some cases, the driver itself may be stored as part of the system + /// firmware, but this field should record the device's path, not the firmware path. For + /// applications, this is the device path of the application. If this cannot be determined, /// a simple end-of-path device node should be put in this position. /// EFI_DEVICE_PATH_PROTOCOL DevicePath; /// /// - /// Zero or more image signatures. If the image contained no signatures, + /// Zero or more image signatures. If the image contained no signatures, /// then this field is empty. /// EFI_SIGNATURE_LIST Signature; @@ -249,16 +327,16 @@ typedef struct { /// /// Number of EFI_IMAGE_EXECUTION_INFO structures. /// - UINTN NumberOfImages; + UINTN NumberOfImages; /// /// Number of image instances of EFI_IMAGE_EXECUTION_INFO structures. /// - // EFI_IMAGE_EXECUTION_INFO InformationInfo[] + // EFI_IMAGE_EXECUTION_INFO InformationInfo[] } EFI_IMAGE_EXECUTION_INFO_TABLE; extern EFI_GUID gEfiImageSecurityDatabaseGuid; extern EFI_GUID gEfiCertSha256Guid; -extern EFI_GUID gEfiCertRsa2048Guid; +extern EFI_GUID gEfiCertRsa2048Guid; extern EFI_GUID gEfiCertRsa2048Sha256Guid; extern EFI_GUID gEfiCertSha1Guid; extern EFI_GUID gEfiCertRsa2048Sha1Guid; @@ -266,6 +344,9 @@ extern EFI_GUID gEfiCertX509Guid; extern EFI_GUID gEfiCertSha224Guid; extern EFI_GUID gEfiCertSha384Guid; extern EFI_GUID gEfiCertSha512Guid; +extern EFI_GUID gEfiCertX509Sha256Guid; +extern EFI_GUID gEfiCertX509Sha384Guid; +extern EFI_GUID gEfiCertX509Sha512Guid; extern EFI_GUID gEfiCertPkcs7Guid; -#endif +#endif \ No newline at end of file diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f9e0c8f031..6dc696e5d9 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -201,7 +201,7 @@ # Script Opcodes. These OpCode will be restored by S3 # related modules. S3BootScriptLib|Include/Library/S3BootScriptLib.h - + ## @libraryclass I/O and MMIO Library Services that do I/O and also enable # the I/O operatation to be replayed during an S3 resume. # This library class maps directly on top of the IoLib class. @@ -222,7 +222,7 @@ # operatation to be replayed during an S3 resume. This # library class maps directly on top of the Timer class. S3StallLib|Include/Library/S3StallLib.h - + ## @libraryclass Defines library APIs used by modules to get/set print error level. DebugPrintErrorLevelLib|Include/Library/DebugPrintErrorLevelLib.h @@ -238,7 +238,7 @@ ## @libraryclass Provides services to enable/disable periodic SMI handlers. # SmmPeriodicSmiLib|Include/Library/SmmPeriodicSmiLib.h - + [LibraryClasses.IPF] ## @libraryclass The SAL Library provides a service to make a SAL CALL. SalLib|Include/Library/SalLib.h @@ -248,7 +248,7 @@ ## @libraryclass Provides library services to make Extended SAL Calls. ExtendedSalLib|Include/Library/ExtendedSalLib.h - + [Guids] # # GUID defined in UEFI2.1/UEFI2.0/EFI1.1 @@ -523,6 +523,11 @@ ## Include/Guid/FmpCapsule.h gEfiFmpCapsuleGuid = { 0x6dcbd5ed, 0xe82d, 0x4c44, {0xbd, 0xa1, 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a }} + ## Include/Guid/ImageAuthentication.h + gEfiCertX509Sha256Guid = { 0x3bd2a492, 0x96c0, 0x4079, {0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed }} + gEfiCertX509Sha384Guid = { 0x7076876e, 0x80c2, 0x4ee6, {0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b }} + gEfiCertX509Sha512Guid = { 0x446dbf63, 0x2502, 0x4cda, {0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d }} + ## Include/Protocol/Rng.h gEfiRngAlgorithmSp80090Hash256Guid = { 0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96 }} gEfiRngAlgorithmSp80090Hmac256Guid = { 0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7 }} @@ -535,7 +540,7 @@ gEfiAdapterInfoMediaStateGuid = { 0xD7C74207, 0xA831, 0x4A26, {0xB1, 0xF5, 0xD1, 0x93, 0x06, 0x5C, 0xE8, 0xB6 }} gEfiAdapterInfoNetworkBootGuid = { 0x1FBD2960, 0x4130, 0x41E5, {0x94, 0xAC, 0xD2, 0xCF, 0x03, 0x7F, 0xB3, 0x7C }} gEfiAdapterInfoSanMacAddressGuid = { 0x114da5ef, 0x2cf1, 0x4e12, {0x9b, 0xbb, 0xc4, 0x70, 0xb5, 0x52, 0x5, 0xd9 }} - + # # GUID defined in PI1.0 # @@ -611,7 +616,7 @@ # ## Include/Guid/EventGroup.h gEfiEndOfDxeEventGroupGuid = { 0x2ce967a, 0xdd7e, 0x4ffc, { 0x9e, 0xe7, 0x81, 0xc, 0xf0, 0x47, 0x8, 0x80 }} - + ## Include/Guid/FirmwareContentsSigned.h gEfiFirmwareContentsSignedGuid = { 0xf9d89e8, 0x9259, 0x4f76, { 0xa5, 0xaf, 0xc, 0x89, 0xe3, 0x40, 0x23, 0xdf }} @@ -629,7 +634,7 @@ gEfiIa32X64ErrorTypeBusCheckGuid = { 0x1CF3F8B3, 0xC5B1, 0x49a2, { 0xAA, 0x59, 0x5E, 0xEF, 0x92, 0xFF, 0xA6, 0x3C }} ## Include/Guid/Cper.h - gEfiIa32X64ErrorTypeMsCheckGuid = { 0x48AB7F57, 0xDC34, 0x4f6c, { 0xA7, 0xD3, 0xB0, 0xB5, 0xB0, 0xA7, 0x43, 0x14 }} + gEfiIa32X64ErrorTypeMsCheckGuid = { 0x48AB7F57, 0xDC34, 0x4f6c, { 0xA7, 0xD3, 0xB0, 0xB5, 0xB0, 0xA7, 0x43, 0x14 }} [Ppis] ## Include/Ppi/MasterBootMode.h @@ -733,7 +738,7 @@ # # PPIs defined in PI 1.3. # - + ## Include/Ppi/I2cMaster.h gEfiPeiI2cMasterPpiGuid = { 0xb3bfab9b, 0x9f9c, 0x4e8b, { 0xad, 0x37, 0x7f, 0x8c, 0x51, 0xfc, 0x62, 0x80 }} @@ -924,16 +929,16 @@ ## Include/Protocol/PiPcd.h gEfiPcdProtocolGuid = { 0x13a3f0f6, 0x264a, 0x3ef0, { 0xf2, 0xe0, 0xde, 0xc5, 0x12, 0x34, 0x2f, 0x34 } } - + ## Include/Protocol/FirmwareVolumeBlock.h gEfiFirmwareVolumeBlock2ProtocolGuid = { 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } } ## Include/Protocol/CpuIo2.h gEfiCpuIo2ProtocolGuid = {0xad61f191, 0xae5f, 0x4c0e, {0xb9, 0xfa, 0xe8, 0x69, 0xd2, 0x88, 0xc6, 0x4f } } - + ## Include/Protocol/LegacyRegion2.h gEfiLegacyRegion2ProtocolGuid = {0x70101eaf, 0x85, 0x440c, {0xb3, 0x56, 0x8e, 0xe3, 0x6f, 0xef, 0x24, 0xf0 } } - + ## Include/Protocol/McaInitPmi.h gEfiSalMcaInitPmiProtocolGuid = { 0xb60dc6e8, 0x3b6f, 0x11d5, {0xaf, 0x9, 0x0, 0xa0, 0xc9, 0x44, 0xa0, 0x5b } } @@ -1331,7 +1336,7 @@ ## Include/Protocol/IpSec.h gEfiIpSecProtocolGuid = { 0xdfb386f7, 0xe100, 0x43ad, {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }} - + ## Include/Protocol/IpSec.h gEfiIpSec2ProtocolGuid = { 0xa3979e64, 0xace8, 0x4ddc, {0xbc, 0x7, 0x4d, 0x66, 0xb8, 0xfd, 0x9, 0x77 }} @@ -1361,7 +1366,7 @@ ## Include/Protocol/Rng.h gEfiRngProtocolGuid = { 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 }} - + ## Include/Protocol/AdapterInformation.h gEfiAdapterInformationProtocolGuid = { 0xE5DD1403, 0xD622, 0xC24E, {0x84, 0x88, 0xC7, 0x1B, 0x17, 0xF5, 0xE8, 0x02 }} @@ -1780,4 +1785,4 @@ gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|0|UINT8|0x00000024 [UserExtensions.TianoCore."ExtraFiles"] - MdePkgExtra.uni + MdePkgExtra.uni \ No newline at end of file -- cgit v1.2.3