ReactOS 0.4.17-dev-1005-g171e1de
sha3_512.c
Go to the documentation of this file.
1//
2// Sha3_512.c
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7#include "precomp.h"
8
9//
10// See the symcrypt.h file for documentation on what the various functions do.
11//
12
13
18 NULL, // AppendBlocks function is not implemented for SHA-3
25};
26
28
29
30//
31// SymCryptSha3_512
32//
33#define ALG SHA3_512
34#define Alg Sha3_512
35#include "hash_pattern.c"
36#undef ALG
37#undef Alg
38
39
40//
41// SymCryptSha3_512Init
42//
43VOID
46{
50
52}
53
54
55//
56// SymCryptSha3_512Append
57//
58VOID
64{
66}
67
68
69//
70// SymCryptSha3_512Result
71//
72VOID
77{
79}
80
81
82//
83// SymCryptSha3_512StateExport
84//
85VOID
90{
93}
94
95//
96// SymCryptSha3_512StateExport
97//
103{
105
106 if (scError == SYMCRYPT_NO_ERROR)
107 {
109 }
110
111 return scError;
112}
113
114
115//
116// Simple test vector for FIPS module testing
117//
118
119static const BYTE sha3_512KATAnswer[64] = {
120 0xb7, 0x51, 0x85, 0x0b, 0x1a, 0x57, 0x16, 0x8a,
121 0x56, 0x93, 0xcd, 0x92, 0x4b, 0x6b, 0x09, 0x6e,
122 0x08, 0xf6, 0x21, 0x82, 0x74, 0x44, 0xf7, 0x0d,
123 0x88, 0x4f, 0x5d, 0x02, 0x40, 0xd2, 0x71, 0x2e,
124 0x10, 0xe1, 0x16, 0xe9, 0x19, 0x2a, 0xf3, 0xc9,
125 0x1a, 0x7e, 0xc5, 0x76, 0x47, 0xe3, 0x93, 0x40,
126 0x57, 0x34, 0x0b, 0x4c, 0xf4, 0x08, 0xd5, 0xa5,
127 0x65, 0x92, 0xf8, 0x27, 0x4e, 0xec, 0x53, 0xf0
128};
129
130VOID
133{
135
137
139
140 if (memcmp(result, sha3_512KATAnswer, sizeof(result)) != 0)
141 {
142 SymCryptFatal('SHA3');
143 }
144}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLuint64EXT * result
Definition: glext.h:11304
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _Inout_
Definition: no_sal2.h:162
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
BYTE * PBYTE
Definition: pedump.c:66
VOID SYMCRYPT_CALL SymCryptKeccakInit(_Out_ PSYMCRYPT_KECCAK_STATE pState, UINT32 inputBlockSize, UINT8 padding)
Definition: sha3.c:174
@ SymCryptBlobTypeSha3_512State
Definition: sc_lib.h:1070
VOID SYMCRYPT_CALL SymCryptInjectError(PBYTE pbData, SIZE_T cbData)
VOID SYMCRYPT_CALL SymCryptKeccakAppend(_Inout_ PSYMCRYPT_KECCAK_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
Definition: sha3.c:285
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptKeccakStateImport(SYMCRYPT_BLOB_TYPE type, _Out_ PSYMCRYPT_KECCAK_STATE pState, _In_reads_bytes_(SYMCRYPT_KECCAK_STATE_EXPORT_SIZE) PCBYTE pbBlob)
Definition: sha3.c:518
#define SYMCRYPT_SHA3_PADDING_VALUE
Definition: sc_lib.h:1808
const BYTE SymCryptTestMsg3[3]
Definition: selftest.c:8
VOID SYMCRYPT_CALL SymCryptKeccakStateExport(SYMCRYPT_BLOB_TYPE type, _In_ PCSYMCRYPT_KECCAK_STATE pState, _Out_writes_bytes_(SYMCRYPT_KECCAK_STATE_EXPORT_SIZE) PBYTE pbBlob)
Definition: sha3.c:479
VOID SYMCRYPT_CALL SymCryptKeccakExtract(_Inout_ PSYMCRYPT_KECCAK_STATE pState, _Out_writes_(cbResult) PBYTE pbResult, SIZE_T cbResult, BOOLEAN bWipe)
Definition: sha3.c:411
VOID SYMCRYPT_CALL SymCryptSha3_512StateExport(_In_ PCSYMCRYPT_SHA3_512_STATE pState, _Out_writes_bytes_(SYMCRYPT_SHA3_512_STATE_EXPORT_SIZE) PBYTE pbBlob)
Definition: sha3_512.c:87
VOID SYMCRYPT_CALL SymCryptSha3_512Init(_Out_ PSYMCRYPT_SHA3_512_STATE pState)
Definition: sha3_512.c:45
VOID SYMCRYPT_CALL SymCryptSha3_512Append(_Inout_ PSYMCRYPT_SHA3_512_STATE pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
Definition: sha3_512.c:60
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSha3_512StateImport(_Out_ PSYMCRYPT_SHA3_512_STATE pState, _In_reads_bytes_(SYMCRYPT_SHA3_512_STATE_EXPORT_SIZE) PCBYTE pbBlob)
Definition: sha3_512.c:100
static const BYTE sha3_512KATAnswer[64]
Definition: sha3_512.c:119
VOID SYMCRYPT_CALL SymCryptSha3_512Selftest(void)
Definition: sha3_512.c:132
const PCSYMCRYPT_HASH SymCryptSha3_512Algorithm
Definition: sha3_512.c:27
const SYMCRYPT_HASH SymCryptSha3_512Algorithm_default
Definition: sha3_512.c:14
VOID SYMCRYPT_CALL SymCryptSha3_512Result(_Inout_ PSYMCRYPT_SHA3_512_STATE pState, _Out_writes_(SYMCRYPT_SHA3_512_RESULT_SIZE) PBYTE pbResult)
Definition: sha3_512.c:74
static const BYTE pbResult[]
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
#define SYMCRYPT_SHA3_512_RESULT_SIZE
Definition: symcrypt.h:1722
VOID SYMCRYPT_CALL SymCryptSha3_512(_In_reads_(cbData) PCBYTE pbData, SIZE_T cbData, _Out_writes_(SYMCRYPT_SHA3_512_RESULT_SIZE) PBYTE pbResult)
VOID SYMCRYPT_CALL SymCryptSha3_512StateCopy(_In_ PCSYMCRYPT_SHA3_512_STATE pSrc, _Out_ PSYMCRYPT_SHA3_512_STATE pDst)
#define SYMCRYPT_SHA3_512_INPUT_BLOCK_SIZE
Definition: symcrypt.h:1723
SYMCRYPT_ERROR
Definition: symcrypt.h:227
#define SYMCRYPT_SHA3_512_STATE_EXPORT_SIZE
#define SYMCRYPT_CALL
struct _SYMCRYPT_HASH SYMCRYPT_HASH
#define SYMCRYPT_FIELD_SIZE(type, field)
const SYMCRYPT_HASH * PCSYMCRYPT_HASH
PCBYTE PBYTE SIZE_T cbData
#define SYMCRYPT_SET_MAGIC(p)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHA3_512_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHA3_512_STATE
const SYMCRYPT_SHA3_512_STATE * PCSYMCRYPT_SHA3_512_STATE
#define SYMCRYPT_FIELD_OFFSET(type, field)
PSYMCRYPT_COMMON_HASH_STATE pState
const BYTE * PCBYTE
PCBYTE pbData
#define SYMCRYPT_CHECK_MAGIC(p)
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193