ReactOS 0.4.17-dev-1005-g171e1de
kmac.c File Reference
#include "precomp.h"
#include "kmac_pattern.c"
Include dependency graph for kmac.c:

Go to the source code of this file.

Macros

#define Alg   Kmac128
 
#define ALG   KMAC128
 
#define SYMCRYPT_CSHAKEXXX_INIT   SymCryptCShake128Init
 
#define SYMCRYPT_CSHAKEXXX_STATE   SYMCRYPT_CSHAKE128_STATE
 
#define SYMCRYPT_KMACXXX_RESULT_SIZE   SYMCRYPT_KMAC128_RESULT_SIZE
 
#define Alg   Kmac256
 
#define ALG   KMAC256
 
#define SYMCRYPT_CSHAKEXXX_INIT   SymCryptCShake256Init
 
#define SYMCRYPT_CSHAKEXXX_STATE   SYMCRYPT_CSHAKE256_STATE
 
#define SYMCRYPT_KMACXXX_RESULT_SIZE   SYMCRYPT_KMAC256_RESULT_SIZE
 

Functions

VOID SYMCRYPT_CALL SymCryptKmac128Selftest (void)
 
VOID SYMCRYPT_CALL SymCryptKmac256Selftest (void)
 

Variables

const SYMCRYPT_MAC SymCryptKmac128Algorithm_Default
 
const PCSYMCRYPT_MAC SymCryptKmac128Algorithm = &SymCryptKmac128Algorithm_Default
 
static const BYTE kmac128KATAnswer [SYMCRYPT_KMAC128_RESULT_SIZE]
 
const SYMCRYPT_MAC SymCryptKmac256Algorithm_Default
 
const PCSYMCRYPT_MAC SymCryptKmac256Algorithm = &SymCryptKmac256Algorithm_Default
 
static const BYTE kmac256KATAnswer [SYMCRYPT_KMAC256_RESULT_SIZE]
 

Macro Definition Documentation

◆ Alg [1/2]

#define Alg   Kmac128

Definition at line 71 of file kmac.c.

◆ ALG [1/2]

#define ALG   KMAC128

Definition at line 72 of file kmac.c.

◆ Alg [2/2]

#define Alg   Kmac256

Definition at line 71 of file kmac.c.

◆ ALG [2/2]

#define ALG   KMAC256

Definition at line 72 of file kmac.c.

◆ SYMCRYPT_CSHAKEXXX_INIT [1/2]

#define SYMCRYPT_CSHAKEXXX_INIT   SymCryptCShake128Init

Definition at line 73 of file kmac.c.

◆ SYMCRYPT_CSHAKEXXX_INIT [2/2]

#define SYMCRYPT_CSHAKEXXX_INIT   SymCryptCShake256Init

Definition at line 73 of file kmac.c.

◆ SYMCRYPT_CSHAKEXXX_STATE [1/2]

#define SYMCRYPT_CSHAKEXXX_STATE   SYMCRYPT_CSHAKE128_STATE

Definition at line 74 of file kmac.c.

◆ SYMCRYPT_CSHAKEXXX_STATE [2/2]

#define SYMCRYPT_CSHAKEXXX_STATE   SYMCRYPT_CSHAKE256_STATE

Definition at line 74 of file kmac.c.

◆ SYMCRYPT_KMACXXX_RESULT_SIZE [1/2]

#define SYMCRYPT_KMACXXX_RESULT_SIZE   SYMCRYPT_KMAC128_RESULT_SIZE

Definition at line 75 of file kmac.c.

◆ SYMCRYPT_KMACXXX_RESULT_SIZE [2/2]

#define SYMCRYPT_KMACXXX_RESULT_SIZE   SYMCRYPT_KMAC256_RESULT_SIZE

Definition at line 75 of file kmac.c.

Function Documentation

◆ SymCryptKmac128Selftest()

VOID SYMCRYPT_CALL SymCryptKmac128Selftest ( void  )

Definition at line 49 of file kmac.c.

50{
52 static const unsigned char Sstr[] = { 'S' };
54
55 SymCryptKmac128ExpandKeyEx(&expandedKey, SymCryptTestKey32, 16, Sstr, sizeof(Sstr));
56
58
60
61 if (memcmp(result, kmac128KATAnswer, sizeof(result)) != 0)
62 {
63 SymCryptFatal('kmac');
64 }
65}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLuint64EXT * result
Definition: glext.h:11304
static const BYTE kmac128KATAnswer[SYMCRYPT_KMAC128_RESULT_SIZE]
Definition: kmac.c:40
const BYTE SymCryptTestMsg16[16]
Definition: selftest.c:15
VOID SYMCRYPT_CALL SymCryptInjectError(PBYTE pbData, SIZE_T cbData)
const BYTE SymCryptTestKey32[32]
Definition: selftest.c:10
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
#define SYMCRYPT_KMAC128_RESULT_SIZE
Definition: symcrypt.h:3674
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptKmac128ExpandKeyEx(_Out_ PSYMCRYPT_KMAC128_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbKey) PCBYTE pbKey, SIZE_T cbKey, _In_reads_bytes_(cbCustomizationString) PCBYTE pbCustomizationString, SIZE_T cbCustomizationString)
VOID SYMCRYPT_CALL SymCryptKmac128(_In_ PCSYMCRYPT_KMAC128_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbInput) PCBYTE pbInput, SIZE_T cbInput, _Out_writes_bytes_(SYMCRYPT_KMAC128_RESULT_SIZE) PBYTE pbResult)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC128_EXPANDED_KEY
unsigned char BYTE
Definition: xxhash.c:193

◆ SymCryptKmac256Selftest()

VOID SYMCRYPT_CALL SymCryptKmac256Selftest ( void  )

Definition at line 107 of file kmac.c.

108{
110 static const unsigned char Sstr[] = { 'S' };
112
113 SymCryptKmac256ExpandKeyEx(&expandedKey, SymCryptTestKey32, 32, Sstr, sizeof(Sstr));
114
116
118
119 if (memcmp(result, kmac256KATAnswer, sizeof(result)) != 0)
120 {
121 SymCryptFatal('kmac');
122 }
123}
static const BYTE kmac256KATAnswer[SYMCRYPT_KMAC256_RESULT_SIZE]
Definition: kmac.c:98
#define SYMCRYPT_KMAC256_RESULT_SIZE
Definition: symcrypt.h:3762
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptKmac256ExpandKeyEx(_Out_ PSYMCRYPT_KMAC256_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbKey) PCBYTE pbKey, SIZE_T cbKey, _In_reads_bytes_(cbCustomizationString) PCBYTE pbCustomizationString, SIZE_T cbCustomizationString)
VOID SYMCRYPT_CALL SymCryptKmac256(_In_ PCSYMCRYPT_KMAC256_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbInput) PCBYTE pbInput, SIZE_T cbInput, _Out_writes_bytes_(SYMCRYPT_KMAC256_RESULT_SIZE) PBYTE pbResult)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC256_EXPANDED_KEY

Variable Documentation

◆ kmac128KATAnswer

const BYTE kmac128KATAnswer[SYMCRYPT_KMAC128_RESULT_SIZE]
static
Initial value:
= {
0xea, 0xe9, 0xde, 0xd3, 0xee, 0x2f, 0x34, 0x8a,
0xd6, 0xd2, 0xcb, 0x70, 0x4b, 0xba, 0xd4, 0x47,
0x15, 0x32, 0x46, 0x82, 0x8e, 0x41, 0x3a, 0xf5,
0xf5, 0x62, 0x96, 0x1a, 0xf7, 0x67, 0x48, 0xc1
}

Definition at line 40 of file kmac.c.

Referenced by SymCryptKmac128Selftest().

◆ kmac256KATAnswer

const BYTE kmac256KATAnswer[SYMCRYPT_KMAC256_RESULT_SIZE]
static
Initial value:
= {
0xa9, 0x1d, 0x09, 0x00, 0x71, 0x0c, 0x63, 0xc5, 0x0f, 0xb6, 0x4d, 0xfa, 0xd8, 0x75, 0x4d, 0x78,
0x2d, 0xc0, 0x82, 0x4b, 0x87, 0x97, 0xda, 0xf2, 0x36, 0xde, 0xe9, 0x35, 0x69, 0x2e, 0x50, 0x81,
0x0a, 0xea, 0x3b, 0x05, 0xaf, 0x1b, 0x82, 0x3b, 0xc8, 0xa1, 0x9e, 0xe9, 0x9c, 0x5f, 0xd5, 0x5a,
0x20, 0x92, 0x89, 0x46, 0xa4, 0xe4, 0x1a, 0xdd, 0x3d, 0xb6, 0x47, 0x4d, 0xf2, 0xa5, 0xfc, 0x73
}

Definition at line 98 of file kmac.c.

Referenced by SymCryptKmac256Selftest().

◆ SymCryptKmac128Algorithm

Definition at line 38 of file kmac.c.

Referenced by SymCryptSskdfMacDerive(), and SymCryptSskdfMacExpandSalt().

◆ SymCryptKmac128Algorithm_Default

const SYMCRYPT_MAC SymCryptKmac128Algorithm_Default
Initial value:
= {
NULL,
0,
}
#define NULL
Definition: types.h:112
VOID SYMCRYPT_CALL SymCryptKmac128Init(_Out_ PSYMCRYPT_KMAC128_STATE pState, _In_ PCSYMCRYPT_KMAC128_EXPANDED_KEY pExpandedKey)
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptKmac128ExpandKey(_Out_ PSYMCRYPT_KMAC128_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
VOID SYMCRYPT_CALL SymCryptKmac128Result(_Inout_ PSYMCRYPT_KMAC128_STATE pState, _Out_writes_(SYMCRYPT_KMAC128_RESULT_SIZE) PBYTE pbResult)
VOID SYMCRYPT_CALL SymCryptKmac128Append(_Inout_ PSYMCRYPT_KMAC128_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC128_STATE

Definition at line 26 of file kmac.c.

◆ SymCryptKmac256Algorithm

Definition at line 96 of file kmac.c.

Referenced by SymCryptSskdfMacDerive(), and SymCryptSskdfMacExpandSalt().

◆ SymCryptKmac256Algorithm_Default

const SYMCRYPT_MAC SymCryptKmac256Algorithm_Default
Initial value:
= {
NULL,
0,
}
VOID SYMCRYPT_CALL SymCryptKmac256Append(_Inout_ PSYMCRYPT_KMAC256_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptKmac256ExpandKey(_Out_ PSYMCRYPT_KMAC256_EXPANDED_KEY pExpandedKey, _In_reads_bytes_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
VOID SYMCRYPT_CALL SymCryptKmac256Init(_Out_ PSYMCRYPT_KMAC256_STATE pState, _In_ PCSYMCRYPT_KMAC256_EXPANDED_KEY pExpandedKey)
VOID SYMCRYPT_CALL SymCryptKmac256Result(_Inout_ PSYMCRYPT_KMAC256_STATE pState, _Out_writes_(SYMCRYPT_KMAC256_RESULT_SIZE) PBYTE pbResult)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC256_STATE

Definition at line 84 of file kmac.c.