blob: 37625ce833b348c438120919c89980b9d3a77e72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* Copyright (c) 2013-2017 IDRIX
* Governed by the Apache License 2.0 the full text of which is contained
* in the file License.txt included in VeraCrypt binary and source
* code distribution packages.
*/
#ifndef _SHA2_H
#define _SHA2_H
#include "Common/Tcdefs.h"
#include "Common/Endian.h"
#include "Crypto/config.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define SHA256_DIGEST_SIZE 32
#define SHA256_BLOCK_SIZE 64
#define SHA512_DIGEST_SIZE 64
#define SHA512_BLOCK_SIZE 128
#if CRYPTOPP_BOOL_X64
#define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(32)
#else
#define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(16)
#endif
typedef struct
{ uint_64t count[2];
SHA2_ALIGN uint_64t hash[8];
SHA2_ALIGN uint_64t wbuf[16];
} sha512_ctx;
typedef struct
{ uint_32t count[2];
SHA2_ALIGN uint_32t hash[8];
SHA2_ALIGN uint_32t wbuf[16];
} sha256_ctx;
void sha512_begin(sha512_ctx* ctx);
void sha512_hash(const unsigned char * source, uint_64t sourceLen, sha512_ctx *ctx);
void sha512_end(unsigned char * result, sha512_ctx* ctx);
void sha512(unsigned char * result, const unsigned char* source, uint_64t sourceLen);
void sha256_begin(sha256_ctx* ctx);
void sha256_hash(const unsigned char * source, uint_32t sourceLen, sha256_ctx *ctx);
void sha256_end(unsigned char * result, sha256_ctx* ctx);
void sha256(unsigned char * result, const unsigned char* source, uint_32t sourceLen);
#if defined(__cplusplus)
}
#endif
#endif
|