Path: blob/main/sys/contrib/edk2/Include/Guid/ImageAuthentication.h
96339 views
/** @file1Image signature database are defined for the signed image validation.23Copyright (c) 2009 - 2024, Intel Corporation. All rights reserved.<BR>4SPDX-License-Identifier: BSD-2-Clause-Patent56@par Revision Reference:7GUIDs defined in UEFI 2.5 spec.8**/910#ifndef __IMAGE_AUTHTICATION_H__11#define __IMAGE_AUTHTICATION_H__1213#include <Guid/GlobalVariable.h>14#include <Protocol/Hash.h>1516#define EFI_IMAGE_SECURITY_DATABASE_GUID \17{ \180xd719b2cb, 0x3d3a, 0x4596, { 0xa3, 0xbc, 0xda, 0xd0, 0xe, 0x67, 0x65, 0x6f } \19}2021///22/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID23/// for the authorized signature database.24///25#define EFI_IMAGE_SECURITY_DATABASE L"db"26///27/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID28/// for the forbidden signature database.29///30#define EFI_IMAGE_SECURITY_DATABASE1 L"dbx"31///32/// Variable name with guid EFI_IMAGE_SECURITY_DATABASE_GUID33/// for the timestamp signature database.34///35#define EFI_IMAGE_SECURITY_DATABASE2 L"dbt"3637#define SECURE_BOOT_MODE_ENABLE 138#define SECURE_BOOT_MODE_DISABLE 03940#define SETUP_MODE 141#define USER_MODE 04243#define DEVICE_AUTH_BOOT_MODE_ENABLE 144#define DEVICE_AUTH_BOOT_MODE_DISABLE 04546// ***********************************************************************47// Signature Database48// ***********************************************************************49///50/// The format of a signature database.51///52#pragma pack(1)5354typedef struct {55///56/// An identifier which identifies the agent which added the signature to the list.57///58EFI_GUID SignatureOwner;59///60/// The format of the signature is defined by the SignatureType.61///62UINT8 SignatureData[1];63} EFI_SIGNATURE_DATA;6465typedef struct {66///67/// Type of the signature. GUID signature types are defined in below.68///69EFI_GUID SignatureType;70///71/// Total size of the signature list, including this header.72///73UINT32 SignatureListSize;74///75/// Size of the signature header which precedes the array of signatures.76///77UINT32 SignatureHeaderSize;78///79/// Size of each signature.80///81UINT32 SignatureSize;82///83/// Header before the array of signatures. The format of this header is specified84/// by the SignatureType.85/// UINT8 SignatureHeader[SignatureHeaderSize];86///87/// An array of signatures. Each signature is SignatureSize bytes in length.88/// EFI_SIGNATURE_DATA Signatures[][SignatureSize];89///90} EFI_SIGNATURE_LIST;9192typedef struct {93///94/// The SHA256 hash of an X.509 certificate's To-Be-Signed contents.95///96EFI_SHA256_HASH ToBeSignedHash;97///98/// The time that the certificate shall be considered to be revoked.99///100EFI_TIME TimeOfRevocation;101} EFI_CERT_X509_SHA256;102103typedef struct {104///105/// The SHA384 hash of an X.509 certificate's To-Be-Signed contents.106///107EFI_SHA384_HASH ToBeSignedHash;108///109/// The time that the certificate shall be considered to be revoked.110///111EFI_TIME TimeOfRevocation;112} EFI_CERT_X509_SHA384;113114typedef struct {115///116/// The SHA512 hash of an X.509 certificate's To-Be-Signed contents.117///118EFI_SHA512_HASH ToBeSignedHash;119///120/// The time that the certificate shall be considered to be revoked.121///122EFI_TIME TimeOfRevocation;123} EFI_CERT_X509_SHA512;124125typedef UINT8 EFI_SM3_HASH[32];126127typedef struct {128///129/// The SM3 hash of an X.509 certificate's To-Be-Signed contents.130///131EFI_SM3_HASH ToBeSignedHash;132///133/// The time that the certificate shall be considered to be revoked.134///135EFI_TIME TimeOfRevocation;136} EFI_CERT_X509_SM3;137138#pragma pack()139140///141/// This identifies a signature containing a SHA-256 hash. The SignatureHeader size shall142/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +143/// 32 bytes.144///145#define EFI_CERT_SHA256_GUID \146{ \1470xc1c41626, 0x504c, 0x4092, {0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28} \148}149150///151/// This identifies a signature containing an RSA-2048 key. The key (only the modulus152/// since the public key exponent is known to be 0x10001) shall be stored in big-endian153/// order.154/// The SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size155/// of SignatureOwner component) + 256 bytes.156///157#define EFI_CERT_RSA2048_GUID \158{ \1590x3c5766e8, 0x269c, 0x4e34, {0xaa, 0x14, 0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6} \160}161162///163/// This identifies a signature containing a RSA-2048 signature of a SHA-256 hash. The164/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of165/// SignatureOwner component) + 256 bytes.166///167#define EFI_CERT_RSA2048_SHA256_GUID \168{ \1690xe2b36190, 0x879b, 0x4a3d, {0xad, 0x8d, 0xf2, 0xe7, 0xbb, 0xa3, 0x27, 0x84} \170}171172///173/// This identifies a signature containing a SHA-1 hash. The SignatureSize shall always174/// be 16 (size of SignatureOwner component) + 20 bytes.175///176#define EFI_CERT_SHA1_GUID \177{ \1780x826ca512, 0xcf10, 0x4ac9, {0xb1, 0x87, 0xbe, 0x1, 0x49, 0x66, 0x31, 0xbd} \179}180181///182/// This identifies a signature containing a SM3 hash. The SignatureSize shall always183/// be 16 (size of SignatureOwner component) + 32 bytes.184///185#define EFI_CERT_SM3_GUID \186{ \1870x57347f87, 0x7a9b, 0x403a, { 0xb9, 0x3c, 0xdc, 0x4a, 0xfb, 0x7a, 0xe, 0xbc } \188}189190///191/// TThis identifies a signature containing a RSA-2048 signature of a SHA-1 hash. The192/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of193/// SignatureOwner component) + 256 bytes.194///195#define EFI_CERT_RSA2048_SHA1_GUID \196{ \1970x67f8444f, 0x8743, 0x48f1, {0xa3, 0x28, 0x1e, 0xaa, 0xb8, 0x73, 0x60, 0x80} \198}199200///201/// This identifies a signature based on an X.509 certificate. If the signature is an X.509202/// certificate then verification of the signature of an image should validate the public203/// key certificate in the image using certificate path verification, up to this X.509204/// certificate as a trusted root. The SignatureHeader size shall always be 0. The205/// SignatureSize may vary but shall always be 16 (size of the SignatureOwner component) +206/// the size of the certificate itself.207/// Note: This means that each certificate will normally be in a separate EFI_SIGNATURE_LIST.208///209#define EFI_CERT_X509_GUID \210{ \2110xa5c059a1, 0x94e4, 0x4aa7, {0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72} \212}213214///215/// This identifies a signature containing the SM3 hash of an X.509 certificate's To-Be-Signed216/// contents, and a time of revocation. The SignatureHeader size shall always be 0. The217/// SignatureSize shall always be 16 (size of the SignatureOwner component) + 32 bytes for218/// an EFI_CERT_X509_SM3 structure. If the TimeOfRevocation is non-zero, the certificate should219/// be considered to be revoked from that time and onwards, and otherwise the certificate shall220/// be considered to always be revoked.221///222#define EFI_CERT_X509_SM3_GUID \223{ \2240x60d807e5, 0x10b4, 0x49a9, {0x93, 0x31, 0xe4, 0x4, 0x37, 0x88, 0x8d, 0x37 } \225}226227///228/// This identifies a signature containing a SHA-224 hash. The SignatureHeader size shall229/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +230/// 28 bytes.231///232#define EFI_CERT_SHA224_GUID \233{ \2340xb6e5233, 0xa65c, 0x44c9, {0x94, 0x7, 0xd9, 0xab, 0x83, 0xbf, 0xc8, 0xbd} \235}236237///238/// This identifies a signature containing a SHA-384 hash. The SignatureHeader size shall239/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +240/// 48 bytes.241///242#define EFI_CERT_SHA384_GUID \243{ \2440xff3e5307, 0x9fd0, 0x48c9, {0x85, 0xf1, 0x8a, 0xd5, 0x6c, 0x70, 0x1e, 0x1} \245}246247///248/// This identifies a signature containing a SHA-512 hash. The SignatureHeader size shall249/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +250/// 64 bytes.251///252#define EFI_CERT_SHA512_GUID \253{ \2540x93e0fae, 0xa6c4, 0x4f50, {0x9f, 0x1b, 0xd4, 0x1e, 0x2b, 0x89, 0xc1, 0x9a} \255}256257///258/// This identifies a signature containing the SHA256 hash of an X.509 certificate's259/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall260/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)261/// + 48 bytes for an EFI_CERT_X509_SHA256 structure. If the TimeOfRevocation is non-zero,262/// the certificate should be considered to be revoked from that time and onwards, and263/// otherwise the certificate shall be considered to always be revoked.264///265#define EFI_CERT_X509_SHA256_GUID \266{ \2670x3bd2a492, 0x96c0, 0x4079, {0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed } \268}269270///271/// This identifies a signature containing the SHA384 hash of an X.509 certificate's272/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall273/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)274/// + 64 bytes for an EFI_CERT_X509_SHA384 structure. If the TimeOfRevocation is non-zero,275/// the certificate should be considered to be revoked from that time and onwards, and276/// otherwise the certificate shall be considered to always be revoked.277///278#define EFI_CERT_X509_SHA384_GUID \279{ \2800x7076876e, 0x80c2, 0x4ee6, {0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b } \281}282283///284/// This identifies a signature containing the SHA512 hash of an X.509 certificate's285/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall286/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)287/// + 80 bytes for an EFI_CERT_X509_SHA512 structure. If the TimeOfRevocation is non-zero,288/// the certificate should be considered to be revoked from that time and onwards, and289/// otherwise the certificate shall be considered to always be revoked.290///291#define EFI_CERT_X509_SHA512_GUID \292{ \2930x446dbf63, 0x2502, 0x4cda, {0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d } \294}295296///297/// This identifies a signature containing a DER-encoded PKCS #7 version 1.5 [RFC2315]298/// SignedData value.299///300#define EFI_CERT_TYPE_PKCS7_GUID \301{ \3020x4aafd29d, 0x68df, 0x49ee, {0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7} \303}304305// ***********************************************************************306// Image Execution Information Table Definition307// ***********************************************************************308typedef UINT32 EFI_IMAGE_EXECUTION_ACTION;309310#define EFI_IMAGE_EXECUTION_AUTHENTICATION 0x00000007311#define EFI_IMAGE_EXECUTION_AUTH_UNTESTED 0x00000000312#define EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED 0x00000001313#define EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED 0x00000002314#define EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND 0x00000003315#define EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND 0x00000004316#define EFI_IMAGE_EXECUTION_POLICY_FAILED 0x00000005317#define EFI_IMAGE_EXECUTION_INITIALIZED 0x00000008318319//320// EFI_IMAGE_EXECUTION_INFO is added to EFI System Configuration Table321// and assigned the GUID EFI_IMAGE_SECURITY_DATABASE_GUID.322//323typedef struct {324///325/// Describes the action taken by the firmware regarding this image.326///327EFI_IMAGE_EXECUTION_ACTION Action;328///329/// Size of all of the entire structure.330///331UINT32 InfoSize;332///333/// If this image was a UEFI device driver (for option ROM, for example) this is the334/// null-terminated, user-friendly name for the device. If the image was for an application,335/// then this is the name of the application. If this cannot be determined, then a simple336/// NULL character should be put in this position.337/// CHAR16 Name[];338///339340///341/// For device drivers, this is the device path of the device for which this device driver342/// was intended. In some cases, the driver itself may be stored as part of the system343/// firmware, but this field should record the device's path, not the firmware path. For344/// applications, this is the device path of the application. If this cannot be determined,345/// a simple end-of-path device node should be put in this position.346/// EFI_DEVICE_PATH_PROTOCOL DevicePath;347///348349///350/// Zero or more image signatures. If the image contained no signatures,351/// then this field is empty.352/// EFI_SIGNATURE_LIST Signature;353///354} EFI_IMAGE_EXECUTION_INFO;355356typedef struct {357///358/// Number of EFI_IMAGE_EXECUTION_INFO structures.359///360UINTN NumberOfImages;361///362/// Number of image instances of EFI_IMAGE_EXECUTION_INFO structures.363///364// EFI_IMAGE_EXECUTION_INFO InformationInfo[]365} EFI_IMAGE_EXECUTION_INFO_TABLE;366367extern EFI_GUID gEfiImageSecurityDatabaseGuid;368extern EFI_GUID gEfiCertSha256Guid;369extern EFI_GUID gEfiCertRsa2048Guid;370extern EFI_GUID gEfiCertRsa2048Sha256Guid;371extern EFI_GUID gEfiCertSha1Guid;372extern EFI_GUID gEfiCertRsa2048Sha1Guid;373extern EFI_GUID gEfiCertX509Guid;374extern EFI_GUID gEfiCertSha224Guid;375extern EFI_GUID gEfiCertSha384Guid;376extern EFI_GUID gEfiCertSha512Guid;377extern EFI_GUID gEfiCertX509Sha256Guid;378extern EFI_GUID gEfiCertX509Sha384Guid;379extern EFI_GUID gEfiCertX509Sha512Guid;380extern EFI_GUID gEfiCertPkcs7Guid;381extern EFI_GUID gEfiCertSm3Guid;382extern EFI_GUID gEfiCertX509Sm3Guid;383384#endif385386387