2 The runtime cryptographic protocol.
3 Only limited crypto primitives (SHA-256 and RSA) are provided for runtime
4 authenticated variable service.
6 Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef __EFI_RUNTIME_CRYPT_PROTOCOL_H__
18 #define __EFI_RUNTIME_CRYPT_PROTOCOL_H__
20 #include <Library/BaseCryptLib.h>
23 /// Runtime Cryptographic Protocol GUID.
25 #define EFI_RUNTIME_CRYPT_PROTOCOL_GUID \
27 0xe1475e0c, 0x1746, 0x4802, { 0x86, 0x2e, 0x1, 0x1c, 0x2c, 0x2d, 0x9d, 0x86 } \
31 Retrieves the size, in bytes, of the context buffer required for SHA-256 operations.
33 @return The size, in bytes, of the context buffer required for SHA-256 operations.
38 (EFIAPI
*EFI_RUNTIME_CRYPT_SHA256_GET_CONTEXT_SIZE
) (
44 Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
47 If Sha256Context is NULL, then return FALSE.
49 @param[in, out] Sha256Context Pointer to SHA-256 Context being initialized.
51 @retval TRUE SHA-256 context initialization succeeded.
52 @retval FALSE SHA-256 context initialization failed.
57 (EFIAPI
*EFI_RUNTIME_CRYPT_SHA256_INIT
) (
58 IN OUT VOID
*Sha256Context
63 Performs SHA-256 digest on a data buffer of the specified length. This function can
64 be called multiple times to compute the digest of long or discontinuous data streams.
66 If Sha256Context is NULL, then return FALSE.
68 @param[in, out] Sha256Context Pointer to the SHA-256 context.
69 @param[in] Data Pointer to the buffer containing the data to be hashed.
70 @param[in] DataLength Length of Data buffer in bytes.
72 @retval TRUE SHA-256 data digest succeeded.
73 @retval FALSE Invalid SHA-256 context. After Sha256Final function has been called, the
74 SHA-256 context cannot be reused.
79 (EFIAPI
*EFI_RUNTIME_CRYPT_SHA256_UPDATE
) (
80 IN OUT VOID
*Sha256Context
,
87 Completes SHA-256 hash computation and retrieves the digest value into the specified
88 memory. After this function has been called, the SHA-256 context cannot be used again.
90 If Sha256Context is NULL, then return FALSE.
91 If HashValue is NULL, then return FALSE.
93 @param[in, out] Sha256Context Pointer to SHA-256 context
94 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
97 @retval TRUE SHA-256 digest computation succeeded.
98 @retval FALSE SHA-256 digest computation failed.
103 (EFIAPI
*EFI_RUNTIME_CRYPT_SHA256_FINAL
) (
104 IN OUT VOID
*Sha256Context
,
110 Allocates and Initializes one RSA Context for subsequent use.
112 @return Pointer to the RSA Context that has been initialized.
113 If the allocations fails, RsaNew() returns NULL.
118 (EFIAPI
*EFI_RUNTIME_CRYPT_RSA_NEW
) (
123 Release the specified RSA Context.
125 @param[in] RsaContext Pointer to the RSA context to be released.
130 (EFIAPI
*EFI_RUNTIME_CRYPT_RSA_FREE
) (
135 Sets the tag-designated RSA key component into the established RSA context from
136 the user-specified nonnegative integer (octet string format represented in RSA
139 If RsaContext is NULL, then return FALSE.
141 @param[in, out] RsaContext Pointer to RSA context being set.
142 @param[in] KeyTag Tag of RSA key component being set.
143 @param[in] BigNumber Pointer to octet integer buffer.
144 @param[in] BnLength Length of big number buffer in bytes.
146 @return TRUE RSA key component was set successfully.
147 @return FALSE Invalid RSA key component tag.
152 (EFIAPI
*EFI_RUNTIME_CRYPT_RSA_SET_KEY
) (
153 IN OUT VOID
*RsaContext
,
154 IN RSA_KEY_TAG KeyTag
,
155 IN CONST UINT8
*BigNumber
,
160 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
163 If RsaContext is NULL, then return FALSE.
164 If MessageHash is NULL, then return FALSE.
165 If Signature is NULL, then return FALSE.
166 If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
168 @param[in] RsaContext Pointer to RSA context for signature verification.
169 @param[in] MessageHash Pointer to octet message hash to be checked.
170 @param[in] HashLength Length of the message hash in bytes.
171 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
172 @param[in] SigLength Length of signature in bytes.
174 @return TRUE Valid signature encoded in PKCS1-v1_5.
175 @return FALSE Invalid signature or invalid RSA context.
180 (EFIAPI
*EFI_RUNTIME_CRYPT_RSA_PKCS1_VERIFY
) (
182 IN CONST UINT8
*MessageHash
,
184 IN CONST UINT8
*Signature
,
189 /// Runtime Cryptographic Protocol Structure.
192 EFI_RUNTIME_CRYPT_SHA256_GET_CONTEXT_SIZE Sha256GetContextSize
;
193 EFI_RUNTIME_CRYPT_SHA256_INIT Sha256Init
;
194 EFI_RUNTIME_CRYPT_SHA256_UPDATE Sha256Update
;
195 EFI_RUNTIME_CRYPT_SHA256_FINAL Sha256Final
;
196 EFI_RUNTIME_CRYPT_RSA_NEW RsaNew
;
197 EFI_RUNTIME_CRYPT_RSA_FREE RsaFree
;
198 EFI_RUNTIME_CRYPT_RSA_SET_KEY RsaSetKey
;
199 EFI_RUNTIME_CRYPT_RSA_PKCS1_VERIFY RsaPkcs1Verify
;
200 } EFI_RUNTIME_CRYPT_PROTOCOL
;
202 extern EFI_GUID gEfiRuntimeCryptProtocolGuid
;