TianoCore EDK2 master
Loading...
Searching...
No Matches
HashTests.c File Reference
#include "TestBaseCryptLib.h"

Go to the source code of this file.

Data Structures

struct  HASH_TEST_CONTEXT
 

Macros

#define MAX_DIGEST_SIZE   64
 

Typedefs

typedef UINTN(EFIAPI * EFI_HASH_GET_CONTEXT_SIZE) (VOID)
 
typedef BOOLEAN(EFIAPI * EFI_HASH_INIT) (OUT VOID *HashContext)
 
typedef BOOLEAN(EFIAPI * EFI_HASH_UPDATE) (IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize)
 
typedef BOOLEAN(EFIAPI * EFI_HASH_DUP) (IN CONST VOID *HashContext, OUT VOID *NewHashContext)
 
typedef BOOLEAN(EFIAPI * EFI_HASH_FINAL) (IN OUT VOID *HashContext, OUT UINT8 *HashValue)
 
typedef BOOLEAN(EFIAPI * EFI_HASH_ALL) (IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
 

Functions

UNIT_TEST_STATUS EFIAPI TestVerifyHashPreReq (UNIT_TEST_CONTEXT Context)
 
VOID EFIAPI TestVerifyHashCleanUp (UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestVerifyHash (IN UNIT_TEST_CONTEXT Context)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * HashData = "abc"
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha1Digest [SHA1_DIGEST_SIZE]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha256Digest [SHA256_DIGEST_SIZE]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha384Digest [SHA384_DIGEST_SIZE]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha512Digest [SHA512_DIGEST_SIZE]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sm3Digest [SM3_256_DIGEST_SIZE]
 
HASH_TEST_CONTEXT mSha1TestCtx = { SHA1_DIGEST_SIZE, Sha1GetContextSize, Sha1Init, Sha1Update, Sha1Duplicate, Sha1Final, Sha1HashAll, Sha1Digest }
 
HASH_TEST_CONTEXT mSha256TestCtx = { SHA256_DIGEST_SIZE, Sha256GetContextSize, Sha256Init, Sha256Update, Sha256Duplicate, Sha256Final, Sha256HashAll, Sha256Digest }
 
HASH_TEST_CONTEXT mSha384TestCtx = { SHA384_DIGEST_SIZE, Sha384GetContextSize, Sha384Init, Sha384Update, Sha384Duplicate, Sha384Final, Sha384HashAll, Sha384Digest }
 
HASH_TEST_CONTEXT mSha512TestCtx = { SHA512_DIGEST_SIZE, Sha512GetContextSize, Sha512Init, Sha512Update, Sha512Duplicate, Sha512Final, Sha512HashAll, Sha512Digest }
 
HASH_TEST_CONTEXT mSm3TestCtx = { SM3_256_DIGEST_SIZE, Sm3GetContextSize, Sm3Init, Sm3Update, Sm3Duplicate, Sm3Final, Sm3HashAll, Sm3Digest }
 
TEST_DESC mHashTest []
 
UINTN mHashTestNum = ARRAY_SIZE (mHashTest)
 

Detailed Description

Application for Hash Primitives Validation.

Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file HashTests.c.

Macro Definition Documentation

◆ MAX_DIGEST_SIZE

#define MAX_DIGEST_SIZE   64

Definition at line 14 of file HashTests.c.

Typedef Documentation

◆ EFI_HASH_ALL

typedef BOOLEAN(EFIAPI * EFI_HASH_ALL) (IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)

Definition at line 109 of file HashTests.c.

◆ EFI_HASH_DUP

typedef BOOLEAN(EFIAPI * EFI_HASH_DUP) (IN CONST VOID *HashContext, OUT VOID *NewHashContext)

Definition at line 95 of file HashTests.c.

◆ EFI_HASH_FINAL

typedef BOOLEAN(EFIAPI * EFI_HASH_FINAL) (IN OUT VOID *HashContext, OUT UINT8 *HashValue)

Definition at line 102 of file HashTests.c.

◆ EFI_HASH_GET_CONTEXT_SIZE

typedef UINTN(EFIAPI * EFI_HASH_GET_CONTEXT_SIZE) (VOID)

Definition at line 75 of file HashTests.c.

◆ EFI_HASH_INIT

typedef BOOLEAN(EFIAPI * EFI_HASH_INIT) (OUT VOID *HashContext)

Definition at line 81 of file HashTests.c.

◆ EFI_HASH_UPDATE

typedef BOOLEAN(EFIAPI * EFI_HASH_UPDATE) (IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize)

Definition at line 87 of file HashTests.c.

Function Documentation

◆ TestVerifyHash()

UNIT_TEST_STATUS EFIAPI TestVerifyHash ( IN UNIT_TEST_CONTEXT  Context)

Definition at line 172 of file HashTests.c.

◆ TestVerifyHashCleanUp()

VOID EFIAPI TestVerifyHashCleanUp ( UNIT_TEST_CONTEXT  Context)

Definition at line 158 of file HashTests.c.

◆ TestVerifyHashPreReq()

UNIT_TEST_STATUS EFIAPI TestVerifyHashPreReq ( UNIT_TEST_CONTEXT  Context)

Definition at line 139 of file HashTests.c.

Variable Documentation

◆ HashData

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8* HashData = "abc"

Definition at line 19 of file HashTests.c.

◆ mHashTest

TEST_DESC mHashTest[]
Initial value:
= {
{ "TestVerifySha1()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha1TestCtx },
{ "TestVerifySha256()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha256TestCtx },
{ "TestVerifySha384()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha384TestCtx },
{ "TestVerifySha512()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha512TestCtx },
{ "TestVerifySm3()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSm3TestCtx },
}

Definition at line 222 of file HashTests.c.

◆ mHashTestNum

UINTN mHashTestNum = ARRAY_SIZE (mHashTest)

Definition at line 236 of file HashTests.c.

◆ mSha1TestCtx

◆ mSha256TestCtx

◆ mSha384TestCtx

◆ mSha512TestCtx

◆ mSm3TestCtx

◆ Sha1Digest

Initial value:
= {
0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c,
0x9c, 0xd0, 0xd8, 0x9d
}

Definition at line 33 of file HashTests.c.

◆ Sha256Digest

Initial value:
= {
0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
}

Definition at line 41 of file HashTests.c.

◆ Sha384Digest

Initial value:
= {
0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7
}

Definition at line 49 of file HashTests.c.

◆ Sha512Digest

Initial value:
= {
0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f
}

Definition at line 58 of file HashTests.c.

◆ Sm3Digest

Initial value:
= {
0x66, 0xc7, 0xf0, 0xf4, 0x62, 0xee, 0xed, 0xd9, 0xd1, 0xf2, 0xd4, 0x6b, 0xdc, 0x10, 0xe4, 0xe2,
0x41, 0x67, 0xc4, 0x87, 0x5c, 0xf2, 0xf7, 0xa2, 0x29, 0x7d, 0xa0, 0x2b, 0x8f, 0x4b, 0xa8, 0xe0
}

Definition at line 69 of file HashTests.c.