Coverage Report

Created: 2024-11-21 07:03

/src/SymCrypt/lib/hmacmd5.c
Line
Count
Source (jump to first uncovered line)
1
//
2
// HmacMd5.c
3
//
4
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5
//
6
7
#include "precomp.h"
8
9
#define ALG MD5
10
#define Alg Md5
11
22.7k
#define SET_DATALENGTH( state, len )    {state.dataLengthL = len;}
12
#include "hmac_pattern.c"
13
#undef SET_DATALENGTH
14
#undef Alg
15
#undef ALG
16
17
const SYMCRYPT_MAC SymCryptHmacMd5Algorithm_default = {
18
    SymCryptHmacMd5ExpandKey,
19
    SymCryptHmacMd5Init,
20
    SymCryptHmacMd5Append,
21
    SymCryptHmacMd5Result,
22
    sizeof(SYMCRYPT_HMAC_MD5_EXPANDED_KEY),
23
    sizeof(SYMCRYPT_HMAC_MD5_STATE),
24
    SYMCRYPT_HMAC_MD5_RESULT_SIZE,
25
    &SymCryptMd5Algorithm,
26
    0,
27
};
28
29
const PCSYMCRYPT_MAC SymCryptHmacMd5Algorithm = &SymCryptHmacMd5Algorithm_default;
30
31
static const BYTE hmacMd5Kat[16] = {
32
    0x77, 0x33, 0x69, 0x79, 0x9e, 0x54, 0xeb, 0x49, 0xff, 0x21, 0xe6, 0xf9, 0x63, 0xe5, 0xbb, 0x49,
33
};
34
35
VOID
36
SYMCRYPT_CALL
37
SymCryptHmacMd5Selftest(void)
38
0
{
39
0
    SYMCRYPT_HMAC_MD5_EXPANDED_KEY xKey;
40
0
    BYTE res[SYMCRYPT_HMAC_MD5_RESULT_SIZE];
41
42
0
    SymCryptHmacMd5ExpandKey( &xKey, SymCryptTestKey32, 16 );
43
0
    SymCryptHmacMd5( &xKey, SymCryptTestMsg3, sizeof( SymCryptTestMsg3 ), res );
44
45
0
    SymCryptInjectError( res, sizeof( res ) );
46
47
0
    if( memcmp( res, hmacMd5Kat, sizeof( res ) ) != 0 ) 
48
0
    {
49
0
        SymCryptFatal( 'hmd5');
50
0
    }
51
52
    //
53
    // Normally we would wipe the expanded key structure here,
54
    // but as this is a selftest with known data this is not needed.
55
    //
56
0
}
57