+++ /dev/null
-/** @file\r
- Header file of Runtime Cryptographic Driver.\r
-\r
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _CRYPT_RUNTIME_H_\r
-#define _CRYPT_RUNTIME_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/RuntimeCrypt.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseCryptLib.h>\r
-\r
-/**\r
- Retrieves the size, in bytes, of the context buffer required for SHA-256 operations.\r
-\r
- @return The size, in bytes, of the context buffer required for SHA-256 operations.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-RuntimeCryptSha256GetContextSize (\r
- VOID\r
- );\r
-\r
-\r
-/**\r
- Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
- subsequent use.\r
-\r
- If Sha256Context is NULL, then return FALSE.\r
-\r
- @param[in, out] Sha256Context Pointer to SHA-256 Context being initialized.\r
-\r
- @retval TRUE SHA-256 context initialization succeeded.\r
- @retval FALSE SHA-256 context initialization failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RuntimeCryptSha256Init (\r
- IN OUT VOID *Sha256Context\r
- );\r
-\r
-\r
-/**\r
- Performs SHA-256 digest on a data buffer of the specified length. This function can\r
- be called multiple times to compute the digest of long or discontinuous data streams.\r
-\r
- If Sha256Context is NULL, then return FALSE.\r
-\r
- @param[in, out] Sha256Context Pointer to the SHA-256 context.\r
- @param[in] Data Pointer to the buffer containing the data to be hashed.\r
- @param[in] DataLength Length of Data buffer in bytes.\r
-\r
- @retval TRUE SHA-256 data digest succeeded.\r
- @retval FALSE Invalid SHA-256 context. After Sha256Final function has been called, the\r
- SHA-256 context cannot be reused.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RuntimeCryptSha256Update (\r
- IN OUT VOID *Sha256Context,\r
- IN CONST VOID *Data,\r
- IN UINTN DataLength\r
- );\r
-\r
-\r
-/**\r
- Completes SHA-256 hash computation and retrieves the digest value into the specified\r
- memory. After this function has been called, the SHA-256 context cannot be used again.\r
-\r
- If Sha256Context is NULL, then return FALSE.\r
- If HashValue is NULL, then return FALSE.\r
-\r
- @param[in, out] Sha256Context Pointer to SHA-256 context\r
- @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r
- value (32 bytes).\r
-\r
- @retval TRUE SHA-256 digest computation succeeded.\r
- @retval FALSE SHA-256 digest computation failed.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RuntimeCryptSha256Final (\r
- IN OUT VOID *Sha256Context,\r
- OUT UINT8 *HashValue\r
- );\r
-\r
-/**\r
- Allocates and Initializes one RSA Context for subsequent use.\r
-\r
- @return Pointer to the RSA Context that has been initialized.\r
- If the allocations fails, RsaNew() returns NULL.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-RuntimeCryptRsaNew (\r
- VOID\r
- );\r
-\r
-\r
-/**\r
- Release the specified RSA Context.\r
-\r
- @param[in] RsaContext Pointer to the RSA context to be released.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-RuntimeCryptRsaFree (\r
- IN VOID *RsaContext\r
- );\r
-\r
-/**\r
- Sets the tag-designated RSA key component into the established RSA context from\r
- the user-specified nonnegative integer (octet string format represented in RSA\r
- PKCS#1).\r
-\r
- If RsaContext is NULL, then return FALSE.\r
-\r
- @param[in, out] RsaContext Pointer to RSA context being set.\r
- @param[in] KeyTag Tag of RSA key component being set.\r
- @param[in] BigNumber Pointer to octet integer buffer.\r
- @param[in] BnLength Length of big number buffer in bytes.\r
-\r
- @return TRUE RSA key component was set successfully.\r
- @return FALSE Invalid RSA key component tag.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RuntimeCryptRsaSetKey (\r
- IN OUT VOID *RsaContext,\r
- IN RSA_KEY_TAG KeyTag,\r
- IN CONST UINT8 *BigNumber,\r
- IN UINTN BnLength\r
- );\r
-\r
-\r
-/**\r
- Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r
- RSA PKCS#1.\r
-\r
- If RsaContext is NULL, then return FALSE.\r
- If MessageHash is NULL, then return FALSE.\r
- If Signature is NULL, then return FALSE.\r
- If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, return FALSE.\r
-\r
- @param[in] RsaContext Pointer to RSA context for signature verification.\r
- @param[in] MessageHash Pointer to octet message hash to be checked.\r
- @param[in] HashLength Length of the message hash in bytes.\r
- @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r
- @param[in] SigLength Length of signature in bytes.\r
-\r
- @return TRUE Valid signature encoded in PKCS1-v1_5.\r
- @return FALSE Invalid signature or invalid RSA context.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RuntimeCryptRsaPkcs1Verify (\r
- IN VOID *RsaContext,\r
- IN CONST UINT8 *MessageHash,\r
- IN UINTN HashLength,\r
- IN CONST UINT8 *Signature,\r
- IN UINTN SigLength\r
- );\r
-\r
-#endif\r