ReactOS 0.4.17-dev-1005-g171e1de
ssh_kdf_sha512.c
Go to the documentation of this file.
1//
2// ssh_kdf_sha512.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, 0x80, 0x57, 0x53, 0x08, 0xca, 0x39, 0x57, 0x98, 0xbb, 0x21, 0xec, 0x54, 0x38,
14 0xc4, 0x6a, 0x88, 0xff, 0xa3, 0xf7, 0xf7, 0x67, 0x1c, 0x06, 0xf9, 0x24, 0xab, 0xf7, 0xc3, 0xcf,
15 0xb4, 0x6c, 0x78, 0xc0, 0x25, 0x59, 0x6e, 0x4a, 0xba, 0x50, 0xc3, 0x27, 0x10, 0x89, 0x18, 0x4a,
16 0x44, 0x7a, 0x57, 0x1a, 0xbb, 0x7f, 0x4a, 0x1b, 0x1c, 0x41, 0xf5, 0xd5, 0xca, 0x80, 0x62, 0x94,
17 0x0d, 0x43, 0x69, 0x77, 0x85, 0x89, 0xfd, 0xe8, 0x1a, 0x71, 0xb2, 0x22, 0x8f, 0x01, 0x8c, 0x4c,
18 0x83, 0x6c, 0xf3, 0x89, 0xf8, 0x54, 0xf8, 0x6d, 0xe7, 0x1a, 0x68, 0xb1, 0x69, 0x3f, 0xe8, 0xff,
19 0xa1, 0xc5, 0x9c, 0xe7, 0xe9, 0xf9, 0x22, 0x3d, 0xeb, 0xad, 0xa2, 0x56, 0x6d, 0x2b, 0x0e, 0x56,
20 0x78, 0xa4, 0x8b, 0xfb, 0x53, 0x0e, 0x7b, 0xee, 0x42, 0xbd, 0x2a, 0xc7, 0x30, 0x4a, 0x0a, 0x5a,
21 0xe3, 0x39, 0xa2, 0xcd
22};
23
24static const BYTE pbHash[] =
25{
26 0xa4, 0x12, 0x5a, 0xa9, 0x89, 0x80, 0x92, 0xca, 0x50, 0xc3, 0xc1, 0x63, 0x1c, 0x03, 0xdc, 0xbc,
27 0x9d, 0xf9, 0x5c, 0xeb, 0xb4, 0x09, 0x88, 0x1e, 0x58, 0x01, 0x08, 0xb6, 0xcc, 0x47, 0x04, 0xb7,
28 0x6c, 0xc7, 0x7b, 0x87, 0x95, 0xfd, 0x59, 0x40, 0x56, 0x1e, 0x32, 0x24, 0xcc, 0x75, 0x84, 0x85,
29 0x18, 0x99, 0x2b, 0xd8, 0xd9, 0xb7, 0x0f, 0xe0, 0xfc, 0x97, 0x7a, 0x47, 0x60, 0x63, 0xc8, 0xbf
30};
31
32static const BYTE pbSessionId[] =
33{
34 0xa4, 0x12, 0x5a, 0xa9, 0x89, 0x80, 0x92, 0xca, 0x50, 0xc3, 0xc1, 0x63, 0x1c, 0x03, 0xdc, 0xbc,
35 0x9d, 0xf9, 0x5c, 0xeb, 0xb4, 0x09, 0x88, 0x1e, 0x58, 0x01, 0x08, 0xb6, 0xcc, 0x47, 0x04, 0xb7,
36 0x6c, 0xc7, 0x7b, 0x87, 0x95, 0xfd, 0x59, 0x40, 0x56, 0x1e, 0x32, 0x24, 0xcc, 0x75, 0x84, 0x85,
37 0x18, 0x99, 0x2b, 0xd8, 0xd9, 0xb7, 0x0f, 0xe0, 0xfc, 0x97, 0x7a, 0x47, 0x60, 0x63, 0xc8, 0xbf
38};
39
41
42static const BYTE pbResult[] =
43{
44 0x7e, 0x4a, 0x72, 0x1f, 0xb7, 0x37, 0x9e, 0xbb, 0x42, 0x33, 0x06, 0x46, 0x4d, 0x57, 0xdb, 0x46,
45 0xaf, 0xa3, 0xcc, 0xa1, 0x0a, 0x1d, 0x7f, 0xeb
46};
47
48VOID
51{
53 SYMCRYPT_ALIGN BYTE rbResult[sizeof(pbResult)];
54
56
57 SymCryptSshKdfDerive(&expandedKey,
58 pbHash, sizeof(pbHash),
59 label,
60 pbSessionId, sizeof(pbSessionId),
61 rbResult, sizeof(rbResult)
62 );
63
64 SymCryptInjectError(rbResult, sizeof(rbResult));
65
66 if (memcmp(rbResult, pbResult, sizeof(pbResult)) != 0)
67 {
68 SymCryptFatal('sshk');
69 }
70}
_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 SymCryptSshKdfSha512SelfTest(void)
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
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
const PCSYMCRYPT_HASH SymCryptSha512Algorithm
Definition: sha512.c:170
#define SYMCRYPT_ALIGN
#define SYMCRYPT_CALL
PCBYTE pbKey
unsigned char BYTE
Definition: xxhash.c:193