ReactOS 0.4.17-dev-1005-g171e1de
hmacsha3_256.c
Go to the documentation of this file.
1//
2// HmacSha3_256.c
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7#include "precomp.h"
8
15{
17}
18
19VOID
24{
25 SymCryptHmacKeyCopy(&pSrc->generic, &pDst->generic);
26}
27
28VOID
35{
37}
38
39VOID
45{
46 SymCryptHmacStateCopy(&pSrc->generic, pExpandedKey == NULL ? NULL : &pExpandedKey->generic, &pDst->generic);
47}
48
49VOID
54{
55 SymCryptHmacInit(&pState->generic, &pExpandedKey->generic);
56}
57
58VOID
64{
66}
67
68VOID
73{
75}
76
77
88};
89
91
92
93static const BYTE hmacSha3_256Kat[32] =
94{
95 0x18, 0xe8, 0x2e, 0xa4, 0x5a, 0x94, 0x07, 0xcc,
96 0xb7, 0x87, 0x29, 0x16, 0x80, 0x99, 0xd6, 0xc6,
97 0x73, 0x1b, 0x56, 0x2e, 0x0d, 0x16, 0x67, 0x5a,
98 0x1f, 0xe2, 0xe3, 0xd6, 0x81, 0x56, 0x52, 0x77
99};
100
101VOID
104{
107
110
111 SymCryptInjectError( res, sizeof( res ) );
112
113 if( memcmp( res, hmacSha3_256Kat, sizeof( res ) ) != 0 )
114 {
115 SymCryptFatal( 'hsh3' );
116 }
117
118 //
119 // Normally we would wipe the expanded key structure here,
120 // but as this is a selftest with known data this is not needed.
121 //
122}
#define NULL
Definition: types.h:112
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLuint res
Definition: glext.h:9613
VOID SYMCRYPT_CALL SymCryptHmacSha3_256(_In_ PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pExpandedKey, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData, _Out_writes_(SYMCRYPT_HMAC_SHA3_256_RESULT_SIZE) PBYTE pbResult)
Definition: hmacsha3_256.c:30
VOID SYMCRYPT_CALL SymCryptHmacSha3_256StateCopy(_In_ PCSYMCRYPT_HMAC_SHA3_256_STATE pSrc, _In_opt_ PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pExpandedKey, _Out_ PSYMCRYPT_HMAC_SHA3_256_STATE pDst)
Definition: hmacsha3_256.c:41
const SYMCRYPT_MAC SymCryptHmacSha3_256Algorithm_default
Definition: hmacsha3_256.c:78
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptHmacSha3_256ExpandKey(_Out_ PSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pExpandedKey, _In_reads_opt_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: hmacsha3_256.c:11
VOID SYMCRYPT_CALL SymCryptHmacSha3_256Result(_Inout_ PSYMCRYPT_HMAC_SHA3_256_STATE pState, _Out_writes_(SYMCRYPT_HMAC_SHA3_256_RESULT_SIZE) PBYTE pbResult)
Definition: hmacsha3_256.c:70
VOID SYMCRYPT_CALL SymCryptHmacSha3_256Init(_Out_ PSYMCRYPT_HMAC_SHA3_256_STATE pState, _In_ PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pExpandedKey)
Definition: hmacsha3_256.c:51
VOID SYMCRYPT_CALL SymCryptHmacSha3_256Append(_Inout_ PSYMCRYPT_HMAC_SHA3_256_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
Definition: hmacsha3_256.c:60
VOID SYMCRYPT_CALL SymCryptHmacSha3_256Selftest(void)
Definition: hmacsha3_256.c:103
VOID SYMCRYPT_CALL SymCryptHmacSha3_256KeyCopy(_In_ PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pSrc, _Out_ PSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY pDst)
Definition: hmacsha3_256.c:21
static const BYTE hmacSha3_256Kat[32]
Definition: hmacsha3_256.c:93
const PCSYMCRYPT_MAC SymCryptHmacSha3_256Algorithm
Definition: hmacsha3_256.c:90
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _Inout_
Definition: no_sal2.h:162
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_reads_opt_(s)
Definition: no_sal2.h:222
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
@ generic
Definition: optimize.h:97
BYTE * PBYTE
Definition: pedump.c:66
VOID SYMCRYPT_CALL SymCryptInjectError(PBYTE pbData, SIZE_T cbData)
const BYTE SymCryptTestKey32[32]
Definition: selftest.c:10
const BYTE SymCryptTestMsg3[3]
Definition: selftest.c:8
static const BYTE pbResult[]
#define SYMCRYPT_HMAC_SHA3_256_RESULT_SIZE
Definition: symcrypt.h:3246
SYMCRYPT_NOINLINE VOID SYMCRYPT_CALL SymCryptHmacResult(_Inout_ PSYMCRYPT_HMAC_STATE pState, _Out_writes_(pState->pKey->pHash->resultSize) PBYTE pbResult)
Definition: hmac.c:141
VOID SYMCRYPT_CALL SymCryptHmacKeyCopy(_In_ PCSYMCRYPT_HMAC_EXPANDED_KEY pSrc, _Out_ PSYMCRYPT_HMAC_EXPANDED_KEY pDst)
Definition: hmac.c:36
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
const PCSYMCRYPT_HASH SymCryptSha3_256Algorithm
Definition: sha3_256.c:27
VOID SYMCRYPT_CALL SymCryptHmacAppend(_Inout_ PSYMCRYPT_HMAC_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
Definition: hmac.c:130
VOID SYMCRYPT_CALL SymCryptHmacStateCopy(_In_ PCSYMCRYPT_HMAC_STATE pSrc, _In_opt_ PCSYMCRYPT_HMAC_EXPANDED_KEY pExpandedKey, _Out_ PSYMCRYPT_HMAC_STATE pDst)
Definition: hmac.c:10
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptHmacExpandKey(_In_ PCSYMCRYPT_HASH pHash, _Out_ PSYMCRYPT_HMAC_EXPANDED_KEY pExpandedKey, _In_reads_opt_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: hmac.c:53
SYMCRYPT_NOINLINE VOID SYMCRYPT_CALL SymCryptHmacInit(_Out_ PSYMCRYPT_HMAC_STATE pState, _In_ PCSYMCRYPT_HMAC_EXPANDED_KEY pExpandedKey)
Definition: hmac.c:115
SYMCRYPT_NOINLINE VOID SYMCRYPT_CALL SymCryptHmac(_In_ PCSYMCRYPT_HMAC_EXPANDED_KEY pExpandedKey, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData, _Out_writes_(pExpandedKey->pHash->resultSize) PBYTE pbResult)
Definition: hmac.c:184
SYMCRYPT_ERROR
Definition: symcrypt.h:227
#define SYMCRYPT_CALL
PCBYTE pbKey
SYMCRYPT_HMAC_SHA3_256_STATE
PCBYTE SIZE_T cbKey
const SYMCRYPT_HMAC_SHA3_256_STATE * PCSYMCRYPT_HMAC_SHA3_256_STATE
PCBYTE PBYTE SIZE_T cbData
const SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
#define SYMCRYPT_FIELD_OFFSET(type, field)
* PSYMCRYPT_HMAC_SHA3_256_STATE
PSYMCRYPT_COMMON_HASH_STATE pState
const BYTE * PCBYTE
PCBYTE pbData
SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
* PSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
PCVOID pExpandedKey
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193