1 | #if defined(CONF_OPENSSL) |
2 | #include "hash_ctxt.h" |
3 | |
4 | #ifdef __GNUC__ |
5 | // EVP requires heap allocations, let's postpone the replacement for now |
6 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
7 | #endif |
8 | |
9 | void sha256_init(SHA256_CTX *ctxt) |
10 | { |
11 | SHA256_Init(c: ctxt); |
12 | } |
13 | |
14 | void sha256_update(SHA256_CTX *ctxt, const void *data, size_t data_len) |
15 | { |
16 | SHA256_Update(c: ctxt, data, len: data_len); |
17 | } |
18 | |
19 | SHA256_DIGEST sha256_finish(SHA256_CTX *ctxt) |
20 | { |
21 | SHA256_DIGEST result; |
22 | SHA256_Final(md: result.data, c: ctxt); |
23 | return result; |
24 | } |
25 | |
26 | void md5_init(MD5_CTX *ctxt) |
27 | { |
28 | MD5_Init(c: ctxt); |
29 | } |
30 | |
31 | void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len) |
32 | { |
33 | MD5_Update(c: ctxt, data, len: data_len); |
34 | } |
35 | |
36 | MD5_DIGEST md5_finish(MD5_CTX *ctxt) |
37 | { |
38 | MD5_DIGEST result; |
39 | MD5_Final(md: result.data, c: ctxt); |
40 | return result; |
41 | } |
42 | #endif |
43 | |