ReactOS 0.4.17-dev-1005-g171e1de
hmacsha256.c
Go to the documentation of this file.
1//
2// HmacSha256.c
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7#include "precomp.h"
8
9#define ALG SHA256
10#define Alg Sha256
11#define SET_DATALENGTH( state, len ) {state.dataLengthL = len;}
12#include "hmac_pattern.c"
13#undef SET_DATALENGTH
14#undef Alg
15#undef ALG
16
27};
28
30
31static const BYTE hmacSha256Kat[32] = {
32 0xd6, 0x01, 0xcc, 0x17, 0x75, 0x59, 0xb0, 0x24,
33 0x84, 0x59, 0x78, 0x7f, 0x7e, 0x80, 0x4e, 0xd7,
34 0xf2, 0x76, 0x89, 0xb5, 0x99, 0x5c, 0x59, 0xb6,
35 0x61, 0x80, 0x2d, 0x96, 0x82, 0xfd, 0xf8, 0xd2,
36};
37
38
39VOID
42{
45
48
49 SymCryptInjectError( res, sizeof( res ) );
50
51 if( memcmp( res, hmacSha256Kat, sizeof( res ) ) != 0 )
52 {
53 SymCryptFatal( 'hsh2' );
54 }
55
56 //
57 // Normally we would wipe the expanded key structure here,
58 // but as this is a selftest with known data this is not needed.
59 //
60}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLuint res
Definition: glext.h:9613
const PCSYMCRYPT_MAC SymCryptHmacSha256Algorithm
Definition: hmacsha256.c:29
static const BYTE hmacSha256Kat[32]
Definition: hmacsha256.c:31
VOID SYMCRYPT_CALL SymCryptHmacSha256Selftest(void)
Definition: hmacsha256.c:41
const SYMCRYPT_MAC SymCryptHmacSha256Algorithm_default
Definition: hmacsha256.c:17
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
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptHmacSha256ExpandKey(_Out_ PSYMCRYPT_HMAC_SHA256_EXPANDED_KEY pExpandedKey, _In_reads_opt_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
const PCSYMCRYPT_HASH SymCryptSha256Algorithm
Definition: sha256.c:46
#define SYMCRYPT_HMAC_SHA256_RESULT_SIZE
Definition: symcrypt.h:2856
VOID SYMCRYPT_CALL SymCryptHmacSha256(_In_ PCSYMCRYPT_HMAC_SHA256_EXPANDED_KEY pExpandedKey, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData, _Out_writes_(SYMCRYPT_HMAC_SHA256_RESULT_SIZE) PBYTE pbResult)
VOID SYMCRYPT_CALL SymCryptHmacSha256Result(_Inout_ PSYMCRYPT_HMAC_SHA256_STATE pState, _Out_writes_(SYMCRYPT_HMAC_SHA256_RESULT_SIZE) PBYTE pbResult)
VOID SYMCRYPT_CALL SymCryptHmacSha256Init(_Out_ PSYMCRYPT_HMAC_SHA256_STATE pState, _In_ PCSYMCRYPT_HMAC_SHA256_EXPANDED_KEY pExpandedKey)
VOID SYMCRYPT_CALL SymCryptHmacSha256Append(_Inout_ PSYMCRYPT_HMAC_SHA256_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
#define SYMCRYPT_CALL
SYMCRYPT_MD5_CHAINING_STATE outerState
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA256_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA256_EXPANDED_KEY
#define SYMCRYPT_FIELD_OFFSET(type, field)
unsigned char BYTE
Definition: xxhash.c:193