1 | #ifndef BASE_HASH_CTXT_H |
2 | #define BASE_HASH_CTXT_H |
3 | |
4 | #include "hash.h" |
5 | #include <cstdint> |
6 | |
7 | #if defined(CONF_OPENSSL) |
8 | #include <openssl/md5.h> |
9 | #include <openssl/sha.h> |
10 | #else |
11 | #include <engine/external/md5/md5.h> |
12 | #endif |
13 | |
14 | #if defined(CONF_OPENSSL) |
15 | // SHA256_CTX is defined in <openssl/sha.h> |
16 | #else |
17 | struct SHA256_CTX |
18 | { |
19 | uint64_t length; |
20 | uint32_t state[8]; |
21 | uint32_t curlen; |
22 | unsigned char buf[64]; |
23 | }; |
24 | typedef md5_state_t MD5_CTX; |
25 | #endif |
26 | |
27 | void sha256_init(SHA256_CTX *ctxt); |
28 | void sha256_update(SHA256_CTX *ctxt, const void *data, size_t data_len); |
29 | SHA256_DIGEST sha256_finish(SHA256_CTX *ctxt); |
30 | |
31 | void md5_init(MD5_CTX *ctxt); |
32 | void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len); |
33 | MD5_DIGEST md5_finish(MD5_CTX *ctxt); |
34 | |
35 | #endif // BASE_HASH_CTXT_H |
36 | |