ReactOS 0.4.17-dev-1005-g171e1de
ssh_kdf_sha256.c
Go to the documentation of this file.
1//
2// ssh_kdf_sha256.c
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7#include "precomp.h"
8
9
10
11static const BYTE pbKey[] =
12{
13 0x00, 0x00, 0x00, 0x81, 0x00, 0x87, 0x5c, 0x55, 0x1c, 0xef, 0x52, 0x6a, 0x4a, 0x8b, 0xe1, 0xa7,
14 0xdf, 0x27, 0xe9, 0xed, 0x35, 0x4b, 0xac, 0x9a, 0xfb, 0x71, 0xf5, 0x3d, 0xba, 0xe9, 0x05, 0x67,
15 0x9d, 0x14, 0xf9, 0xfa, 0xf2, 0x46, 0x9c, 0x53, 0x45, 0x7c, 0xf8, 0x0a, 0x36, 0x6b, 0xe2, 0x78,
16 0x96, 0x5b, 0xa6, 0x25, 0x52, 0x76, 0xca, 0x2d, 0x9f, 0x4a, 0x97, 0xd2, 0x71, 0xf7, 0x1e, 0x50,
17 0xd8, 0xa9, 0xec, 0x46, 0x25, 0x3a, 0x6a, 0x90, 0x6a, 0xc2, 0xc5, 0xe4, 0xf4, 0x8b, 0x27, 0xa6,
18 0x3c, 0xe0, 0x8d, 0x80, 0x39, 0x0a, 0x49, 0x2a, 0xa4, 0x3b, 0xad, 0x9d, 0x88, 0x2c, 0xca, 0xc2,
19 0x3d, 0xac, 0x88, 0xbc, 0xad, 0xa4, 0xb4, 0xd4, 0x26, 0xa3, 0x62, 0x08, 0x3d, 0xab, 0x65, 0x69,
20 0xc5, 0x4c, 0x22, 0x4d, 0xd2, 0xd8, 0x76, 0x43, 0xaa, 0x22, 0x76, 0x93, 0xe1, 0x41, 0xad, 0x16,
21 0x30, 0xce, 0x13, 0x14, 0x4e
22};
23
24static const BYTE pbHash[] =
25{
26 0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23, 0xb2, 0x74, 0x5e, 0xbc,
27 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7, 0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
28};
29
30static const BYTE pbSessionId[] =
31{
32 0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23, 0xb2, 0x74, 0x5e, 0xbc,
33 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7, 0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
34};
35
37
38static const BYTE pbResult[] =
39{
40 0x4a, 0x63, 0x14, 0xd2, 0xf7, 0x51, 0x1b, 0xf8, 0x8f, 0xad, 0x39, 0xfb, 0x68, 0x92, 0xf3, 0xf2, 0x18, 0xca, 0xfd, 0x53, 0x0e, 0x72, 0xfe, 0x43
41};
42
43VOID
46{
48 SYMCRYPT_ALIGN BYTE rbResult[sizeof(pbResult)];
49
51
52 SymCryptSshKdfDerive(&expandedKey,
53 pbHash, sizeof(pbHash),
54 label,
55 pbSessionId, sizeof(pbSessionId),
56 rbResult, sizeof(rbResult)
57 );
58
59 SymCryptInjectError(rbResult, sizeof(rbResult));
60
61 if (memcmp(rbResult, pbResult, sizeof(pbResult)) != 0)
62 {
63 SymCryptFatal('sshk');
64 }
65}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
VOID SYMCRYPT_CALL SymCryptInjectError(PBYTE pbData, SIZE_T cbData)
static const BYTE label
static const BYTE pbHash[]
static const BYTE pbSessionId[]
static const BYTE pbResult[]
VOID SYMCRYPT_CALL SymCryptSshKdfSha256SelfTest(void)
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
const PCSYMCRYPT_HASH SymCryptSha256Algorithm
Definition: sha256.c:46
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSshKdfExpandKey(_Out_ PSYMCRYPT_SSHKDF_EXPANDED_KEY pExpandedKey, _In_ PCSYMCRYPT_HASH pHashFunc, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: ssh_kdf.c:17
#define SYMCRYPT_SSHKDF_ENCRYPTION_KEY_CLIENT_TO_SERVER
Definition: symcrypt.h:5759
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSshKdfDerive(_In_ PCSYMCRYPT_SSHKDF_EXPANDED_KEY pExpandedKey, _In_reads_(cbHashValue) PCBYTE pbHashValue, SIZE_T cbHashValue, BYTE label, _In_reads_(cbSessionId) PCBYTE pbSessionId, SIZE_T cbSessionId, _Inout_updates_(cbOutput) PBYTE pbOutput, SIZE_T cbOutput)
Definition: ssh_kdf.c:33
#define SYMCRYPT_ALIGN
#define SYMCRYPT_CALL
PCBYTE pbKey
unsigned char BYTE
Definition: xxhash.c:193