/src/nss/lib/freebl/Hacl_Hash_SHA2_shim.h
Line | Count | Source |
1 | | #include "blapi.h" |
2 | | #include "../pqg.h" |
3 | | |
4 | | static inline void |
5 | | sha512_pre_msg(uint8_t *hash, uint8_t *prefix, uint32_t len, uint8_t *input) |
6 | 0 | { |
7 | 0 | SHA512Context *ctx = SHA512_NewContext(); |
8 | 0 | uint32_t l = SHA512_LENGTH; |
9 | 0 | SHA512_Begin(ctx); |
10 | 0 | SHA512_Update(ctx, prefix, 32); |
11 | 0 | SHA512_Update(ctx, input, len); |
12 | 0 | SHA512_End(ctx, hash, &l, SHA512_LENGTH); |
13 | 0 | SHA512_DestroyContext(ctx, PR_TRUE); |
14 | 0 | } |
15 | | |
16 | | static inline void |
17 | | sha512_pre_pre2_msg( |
18 | | uint8_t *hash, |
19 | | uint8_t *prefix, |
20 | | uint8_t *prefix2, |
21 | | uint32_t len, |
22 | | uint8_t *input) |
23 | 0 | { |
24 | 0 | SHA512Context *ctx = SHA512_NewContext(); |
25 | 0 | uint32_t l = SHA512_LENGTH; |
26 | 0 | SHA512_Begin(ctx); |
27 | 0 | SHA512_Update(ctx, prefix, 32); |
28 | 0 | SHA512_Update(ctx, prefix2, 32); |
29 | 0 | SHA512_Update(ctx, input, len); |
30 | 0 | SHA512_End(ctx, hash, &l, SHA512_LENGTH); |
31 | 0 | SHA512_DestroyContext(ctx, PR_TRUE); |
32 | 0 | } |
33 | | |
34 | | static void |
35 | | Hacl_Streaming_SHA2_hash_512(uint8_t *secret, uint32_t len, uint8_t *expanded) |
36 | 26 | { |
37 | 26 | SHA512_HashBuf(expanded, secret, len); |
38 | 26 | } |