Coverage Report

Created: 2024-11-21 07:03

/src/SymCrypt/lib/hmacsha384.c
Line
Count
Source (jump to first uncovered line)
1
//
2
// HmacSha512.c
3
//
4
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5
//
6
7
#include "precomp.h"
8
9
446
#define SymCryptSha384AppendBlocks  SymCryptSha512AppendBlocks
10
11
#define ALG SHA384
12
#define Alg Sha384
13
12.1k
#define SET_DATALENGTH( state, len )    {state.dataLengthL = len; state.dataLengthH = 0;}
14
#include "hmac_pattern.c"
15
#undef SET_DATALENGTH
16
#undef Alg
17
#undef ALG
18
19
const SYMCRYPT_MAC SymCryptHmacSha384Algorithm_default = {
20
    SymCryptHmacSha384ExpandKey,
21
    SymCryptHmacSha384Init,
22
    SymCryptHmacSha384Append,
23
    SymCryptHmacSha384Result,
24
    sizeof(SYMCRYPT_HMAC_SHA384_EXPANDED_KEY),
25
    sizeof(SYMCRYPT_HMAC_SHA384_STATE),
26
    SYMCRYPT_HMAC_SHA384_RESULT_SIZE,
27
    &SymCryptSha384Algorithm,
28
    SYMCRYPT_FIELD_OFFSET( SYMCRYPT_HMAC_SHA384_EXPANDED_KEY, outerState ),
29
};
30
31
const PCSYMCRYPT_MAC SymCryptHmacSha384Algorithm = &SymCryptHmacSha384Algorithm_default;
32
33
static const BYTE hmacSha384Kat[48] = {
34
    0x67, 0xdb, 0x9d, 0x4d, 0x66, 0xed, 0xf2, 0xe7, 0x2b, 0x88, 0xb8, 0x50, 0x55, 0x68, 0xa0, 0x00,
35
    0xa9, 0x83, 0x2b, 0xa3, 0x5e, 0x4f, 0xde, 0xcf, 0xe5, 0x38, 0x9a, 0x5d, 0x92, 0x79, 0x81, 0x53, 
36
    0x6d, 0xdb, 0x94, 0xc0, 0xf6, 0xc0, 0xbd, 0x94, 0xc4, 0x18, 0x96, 0x4b, 0xbe, 0x4b, 0x6c, 0xf2, 
37
};
38
39
VOID
40
SYMCRYPT_CALL
41
SymCryptHmacSha384Selftest(void)
42
0
{
43
0
    SYMCRYPT_HMAC_SHA384_EXPANDED_KEY xKey;
44
0
    BYTE res[SYMCRYPT_HMAC_SHA384_RESULT_SIZE];
45
46
0
    SymCryptHmacSha384ExpandKey( &xKey, SymCryptTestKey32, 16 );
47
0
    SymCryptHmacSha384( &xKey, SymCryptTestMsg3, sizeof( SymCryptTestMsg3 ), res );
48
49
0
    SymCryptInjectError( res, sizeof( res ) );
50
0
    if( memcmp( res, hmacSha384Kat, sizeof( res ) ) != 0 ) 
51
0
    {
52
0
        SymCryptFatal( 'hsh3' );
53
0
    }
54
55
    //
56
    // Normally we would wipe the expanded key structure here,
57
    // but as this is a selftest with known data this is not needed.
58
    //
59
0
}
60