ReactOS 0.4.17-dev-1005-g171e1de
hmacsha1.c
Go to the documentation of this file.
1//
2// HmacSha1.c
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7#include "precomp.h"
8
9//
10// This implementation of HMAC uses extensive knowledge of the internal workings of the
11// SHA1 implementation and uses internal routines.
12// This reduces the overhead per HMAC computation by up to 20%, which is significant
13// enough to take on the added complexity.
14//
15
16#define ALG SHA1
17#define Alg Sha1
18#define SET_DATALENGTH( state, len ) {state.dataLengthL = len;}
19#include "hmac_pattern.c"
20#undef SET_DATALENGTH
21#undef Alg
22#undef ALG
23
34};
35
37
38static const BYTE hmacSha1Kat[20] = {
39 0x2a, 0x29, 0x85, 0x40, 0x23, 0xba, 0x2e, 0xf1,
40 0x49, 0x0f, 0x8c, 0xd8, 0x97, 0xa8, 0xcc, 0x6b,
41 0x55, 0x7b, 0x2a, 0x12,
42};
43
44VOID
47{
50
53
54 SymCryptInjectError( res, sizeof( res ) );
55
56 if( memcmp( res, hmacSha1Kat, sizeof( res ) ) != 0 )
57 {
58 SymCryptFatal( 'hSh1' );
59 }
60
61 //
62 // Normally we would wipe the expanded key structure here,
63 // but as this is a selftest with known data this is not needed.
64 //
65}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLuint res
Definition: glext.h:9613
const PCSYMCRYPT_MAC SymCryptHmacSha1Algorithm
Definition: hmacsha1.c:36
VOID SYMCRYPT_CALL SymCryptHmacSha1Selftest(void)
Definition: hmacsha1.c:46
static const BYTE hmacSha1Kat[20]
Definition: hmacsha1.c:38
const SYMCRYPT_MAC SymCryptHmacSha1Algorithm_default
Definition: hmacsha1.c:24
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
VOID SYMCRYPT_CALL SymCryptHmacSha1Result(_Inout_ PSYMCRYPT_HMAC_SHA1_STATE pState, _Out_writes_(SYMCRYPT_HMAC_SHA1_RESULT_SIZE) PBYTE pbResult)
VOID SYMCRYPT_CALL SymCryptHmacSha1Init(_Out_ PSYMCRYPT_HMAC_SHA1_STATE pState, _In_ PCSYMCRYPT_HMAC_SHA1_EXPANDED_KEY pExpandedKey)
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
const PCSYMCRYPT_HASH SymCryptSha1Algorithm
Definition: sha1.c:29
VOID SYMCRYPT_CALL SymCryptHmacSha1(_In_ PCSYMCRYPT_HMAC_SHA1_EXPANDED_KEY pExpandedKey, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData, _Out_writes_(SYMCRYPT_HMAC_SHA1_RESULT_SIZE) PBYTE pbResult)
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptHmacSha1ExpandKey(_Out_ PSYMCRYPT_HMAC_SHA1_EXPANDED_KEY pExpandedKey, _In_reads_opt_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
#define SYMCRYPT_HMAC_SHA1_RESULT_SIZE
Definition: symcrypt.h:2725
VOID SYMCRYPT_CALL SymCryptHmacSha1Append(_Inout_ PSYMCRYPT_HMAC_SHA1_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA1_EXPANDED_KEY
#define SYMCRYPT_CALL
SYMCRYPT_MD5_CHAINING_STATE outerState
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA1_STATE
#define SYMCRYPT_FIELD_OFFSET(type, field)
unsigned char BYTE
Definition: xxhash.c:193