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

Go to the source code of this file.

Data Structures

struct  HMAC_TEST_CONTEXT
 

Macros

#define MAX_DIGEST_SIZE   64
 

Typedefs

typedef VOID *(EFIAPI * EFI_HMAC_NEW) (VOID)
 
typedef VOID(EFIAPI * EFI_HMAC_FREE) (IN VOID *HashContext)
 
typedef BOOLEAN(EFIAPI * EFI_HMAC_INIT) (IN OUT VOID *HashContext, IN CONST UINT8 *Key, IN UINTN KeySize)
 
typedef BOOLEAN(EFIAPI * EFI_HMAC_DUP) (IN CONST VOID *HashContext, OUT VOID *NewHashContext)
 
typedef BOOLEAN(EFIAPI * EFI_HMAC_UPDATE) (IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize)
 
typedef BOOLEAN(EFIAPI * EFI_HMAC_FINAL) (IN OUT VOID *HashContext, OUT UINT8 *HashValue)
 
typedef BOOLEAN(EFIAPI * EFI_HMAC_ALL) (IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HashValue)
 

Functions

UNIT_TEST_STATUS EFIAPI TestVerifyHmacPreReq (UNIT_TEST_CONTEXT Context)
 
VOID EFIAPI TestVerifyHmacCleanUp (UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestVerifyHmac (IN UNIT_TEST_CONTEXT Context)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * HmacData = "Hi There"
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacMd5Key [16]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacMd5Digest []
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha1Key [20]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha1Digest []
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Key [20]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Digest []
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Key [20]
 
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Digest []
 
HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256Free, HmacSha256SetKey, HmacSha256Duplicate, HmacSha256Update, HmacSha256Final, HmacSha256All, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest }
 
HMAC_TEST_CONTEXT mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384Free, HmacSha384SetKey, HmacSha384Duplicate, HmacSha384Update, HmacSha384Final, HmacSha384All, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest }
 
TEST_DESC mHmacTest []
 
UINTN mHmacTestNum = ARRAY_SIZE (mHmacTest)
 

Detailed Description

Application for HMAC Primitives Validation.

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

Definition in file HmacTests.c.

Macro Definition Documentation

◆ MAX_DIGEST_SIZE

#define MAX_DIGEST_SIZE   64

Definition at line 14 of file HmacTests.c.

Typedef Documentation

◆ EFI_HMAC_ALL

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

Definition at line 127 of file HmacTests.c.

◆ EFI_HMAC_DUP

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

Definition at line 105 of file HmacTests.c.

◆ EFI_HMAC_FINAL

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

Definition at line 120 of file HmacTests.c.

◆ EFI_HMAC_FREE

typedef VOID(EFIAPI * EFI_HMAC_FREE) (IN VOID *HashContext)

Definition at line 91 of file HmacTests.c.

◆ EFI_HMAC_INIT

typedef BOOLEAN(EFIAPI * EFI_HMAC_INIT) (IN OUT VOID *HashContext, IN CONST UINT8 *Key, IN UINTN KeySize)

Definition at line 97 of file HmacTests.c.

◆ EFI_HMAC_NEW

typedef VOID *(EFIAPI * EFI_HMAC_NEW) (VOID)

Definition at line 85 of file HmacTests.c.

◆ EFI_HMAC_UPDATE

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

Definition at line 112 of file HmacTests.c.

Function Documentation

◆ TestVerifyHmac()

UNIT_TEST_STATUS EFIAPI TestVerifyHmac ( IN UNIT_TEST_CONTEXT  Context)

Definition at line 187 of file HmacTests.c.

◆ TestVerifyHmacCleanUp()

VOID EFIAPI TestVerifyHmacCleanUp ( UNIT_TEST_CONTEXT  Context)

Definition at line 173 of file HmacTests.c.

◆ TestVerifyHmacPreReq()

UNIT_TEST_STATUS EFIAPI TestVerifyHmacPreReq ( UNIT_TEST_CONTEXT  Context)

Definition at line 156 of file HmacTests.c.

Variable Documentation

◆ HmacData

GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8* HmacData = "Hi There"

Definition at line 19 of file HmacTests.c.

◆ HmacMd5Digest

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacMd5Digest[]
Initial value:
= {
0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d
}

Definition at line 31 of file HmacTests.c.

◆ HmacMd5Key

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacMd5Key[16]
Initial value:
= {
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
}

Definition at line 24 of file HmacTests.c.

◆ HmacSha1Digest

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha1Digest[]
Initial value:
= {
0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
0xf1, 0x46, 0xbe, 0x00
}

Definition at line 46 of file HmacTests.c.

◆ HmacSha1Key

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha1Key[20]
Initial value:
= {
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b
}

Definition at line 38 of file HmacTests.c.

◆ HmacSha256Digest

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Digest[]
Initial value:
= {
0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7
}

Definition at line 62 of file HmacTests.c.

◆ HmacSha256Key

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Key[20]
Initial value:
= {
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b
}

Definition at line 54 of file HmacTests.c.

◆ HmacSha384Digest

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Digest[]
Initial value:
= {
0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6
}

Definition at line 78 of file HmacTests.c.

◆ HmacSha384Key

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Key[20]
Initial value:
= {
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b
}

Definition at line 70 of file HmacTests.c.

◆ mHmacSha256TestCtx

HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256Free, HmacSha256SetKey, HmacSha256Duplicate, HmacSha256Update, HmacSha256Final, HmacSha256All, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest }

Definition at line 151 of file HmacTests.c.

◆ mHmacSha384TestCtx

HMAC_TEST_CONTEXT mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384Free, HmacSha384SetKey, HmacSha384Duplicate, HmacSha384Update, HmacSha384Final, HmacSha384All, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest }

Definition at line 152 of file HmacTests.c.

◆ mHmacTest

TEST_DESC mHmacTest[]
Initial value:
= {
{ "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha256TestCtx },
{ "TestVerifyHmacSha384()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha384TestCtx },
}

Definition at line 234 of file HmacTests.c.

◆ mHmacTestNum

UINTN mHmacTestNum = ARRAY_SIZE (mHmacTest)

Definition at line 242 of file HmacTests.c.