14#define MAX_DIGEST_SIZE 64
24#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
26 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72
34 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c,
35 0x9c, 0xd0, 0xd8, 0x9d
42 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
43 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
50 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
51 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
52 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7
59 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
60 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
61 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
62 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f
70 0x66, 0xc7, 0xf0, 0xf4, 0x62, 0xee, 0xed, 0xd9, 0xd1, 0xf2, 0xd4, 0x6b, 0xdc, 0x10, 0xe4, 0xe2,
71 0x41, 0x67, 0xc4, 0x87, 0x5c, 0xf2, 0xf7, 0xa2, 0x29, 0x7d, 0xa0, 0x2b, 0x8f, 0x4b, 0xa8, 0xe0
76(EFIAPI *EFI_HASH_GET_CONTEXT_SIZE)(
82(EFIAPI *EFI_HASH_INIT)(
88(EFIAPI *EFI_HASH_UPDATE)(
89 IN OUT VOID *HashContext,
96(EFIAPI *EFI_HASH_DUP)(
98 OUT VOID *NewHashContext
103(EFIAPI *EFI_HASH_FINAL)(
104 IN OUT VOID *HashContext,
110(EFIAPI *EFI_HASH_ALL)(
118 EFI_HASH_GET_CONTEXT_SIZE GetContextSize;
119 EFI_HASH_INIT HashInit;
121 EFI_HASH_DUP HashDup;
122 EFI_HASH_FINAL HashFinal;
123 EFI_HASH_ALL HashAll;
128#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
139TestVerifyHashPreReq (
146 HashTestContext = Context;
147 CtxSize = HashTestContext->GetContextSize ();
149 if (HashTestContext->HashCtx ==
NULL) {
150 return UNIT_TEST_ERROR_TEST_FAILED;
153 return UNIT_TEST_PASSED;
158TestVerifyHashCleanUp (
164 HashTestContext = Context;
165 if (HashTestContext->HashCtx !=
NULL) {
166 FreePool (HashTestContext->HashCtx);
177 UINT8 Digest[MAX_DIGEST_SIZE];
178 UINT8 DigestCopy[MAX_DIGEST_SIZE];
181 VOID *HashCopyContext;
183 HashTestContext = Context;
187 ZeroMem (Digest, MAX_DIGEST_SIZE);
188 ZeroMem (DigestCopy, MAX_DIGEST_SIZE);
190 HashCopyContext =
AllocatePool (HashTestContext->GetContextSize ());
192 Status = HashTestContext->HashInit (HashTestContext->HashCtx);
195 Status = HashTestContext->HashInit (HashCopyContext);
198 Status = HashTestContext->HashUpdate (HashTestContext->HashCtx, HashData, DataSize);
201 Status = HashTestContext->HashDup (HashTestContext->HashCtx, HashCopyContext);
204 Status = HashTestContext->HashFinal (HashTestContext->HashCtx, Digest);
207 Status = HashTestContext->HashFinal (HashCopyContext, DigestCopy);
213 ZeroMem (Digest, MAX_DIGEST_SIZE);
214 Status = HashTestContext->HashAll (HashData, DataSize, Digest);
219 return UNIT_TEST_PASSED;
226 #ifdef ENABLE_MD5_DEPRECATED_INTERFACES
227 {
"TestVerifyMd5()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mMd5TestCtx },
229 {
"TestVerifySha1()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha1TestCtx },
230 {
"TestVerifySha256()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha256TestCtx },
231 {
"TestVerifySha384()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha384TestCtx },
232 {
"TestVerifySha512()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha512TestCtx },
233 {
"TestVerifySm3()",
"CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSm3TestCtx },
UINTN EFIAPI Sha256GetContextSize(VOID)
UINTN EFIAPI Sha384GetContextSize(VOID)
BOOLEAN EFIAPI Sha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sm3Duplicate(IN CONST VOID *Sm3Context, OUT VOID *NewSm3Context)
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha384Duplicate(IN CONST VOID *Sha384Context, OUT VOID *NewSha384Context)
UINTN EFIAPI Sm3GetContextSize(VOID)
UINTN EFIAPI Sha512GetContextSize(VOID)
BOOLEAN EFIAPI Sha1Final(IN OUT VOID *Sha1Context, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sm3Update(IN OUT VOID *Sm3Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Sha512Init(OUT VOID *Sha512Context)
#define SM3_256_DIGEST_SIZE
BOOLEAN EFIAPI Sm3Final(IN OUT VOID *Sm3Context, OUT UINT8 *HashValue)
#define SHA512_DIGEST_SIZE
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context)
BOOLEAN EFIAPI Sha384HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
#define SHA256_DIGEST_SIZE
BOOLEAN EFIAPI Sm3HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Sha256Duplicate(IN CONST VOID *Sha256Context, OUT VOID *NewSha256Context)
BOOLEAN EFIAPI Sm3Init(OUT VOID *Sm3Context)
BOOLEAN EFIAPI Sha1Init(OUT VOID *Sha1Context)
BOOLEAN EFIAPI Sha256HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha512Duplicate(IN CONST VOID *Sha512Context, OUT VOID *NewSha512Context)
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
UINTN EFIAPI Sha1GetContextSize(VOID)
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
BOOLEAN EFIAPI Sha512Update(IN OUT VOID *Sha512Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Sha1Update(IN OUT VOID *Sha1Context, IN CONST VOID *Data, IN UINTN DataSize)
#define SHA384_DIGEST_SIZE
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
BOOLEAN EFIAPI Md5Duplicate(IN CONST VOID *Md5Context, OUT VOID *NewMd5Context)
BOOLEAN EFIAPI Md5Final(IN OUT VOID *Md5Context, OUT UINT8 *HashValue)
BOOLEAN EFIAPI Md5Update(IN OUT VOID *Md5Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI Md5Init(OUT VOID *Md5Context)
BOOLEAN EFIAPI Md5HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
UINTN EFIAPI Md5GetContextSize(VOID)
EFI_STATUS EFIAPI HashUpdate(IN HASH_HANDLE HashHandle, IN VOID *DataToHash, IN UINTN DataToHashLen)
#define ARRAY_SIZE(Array)
#define GLOBAL_REMOVE_IF_UNREFERENCED
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
#define UT_ASSERT_TRUE(Expression)