/src/dropbear/src/sntrup761_compat.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* To be included only by sntrup761.c, provides |
2 | | * random and sha512 implementation from Dropbear. |
3 | | * Partially based on OpenSSH crypto_api.h */ |
4 | | /* |
5 | | * Assembled from generated headers and source files by Markus Friedl. |
6 | | * Placed in the public domain. |
7 | | */ |
8 | | |
9 | | #include "includes.h" |
10 | | #include "dbrandom.h" |
11 | | #include "sntrup761.h" |
12 | | |
13 | | #if DROPBEAR_SNTRUP761 |
14 | | |
15 | | typedef int8_t crypto_int8; |
16 | | typedef uint8_t crypto_uint8; |
17 | | typedef int16_t crypto_int16; |
18 | | typedef uint16_t crypto_uint16; |
19 | | typedef int32_t crypto_int32; |
20 | | typedef uint32_t crypto_uint32; |
21 | | typedef int64_t crypto_int64; |
22 | | typedef uint64_t crypto_uint64; |
23 | | |
24 | 0 | static inline void randombytes(unsigned char* buf, unsigned int len) { |
25 | 0 | genrandom(buf, len); |
26 | 0 | } |
27 | | |
28 | 0 | static inline uint32_t small_random32(void) { |
29 | 0 | uint32_t v; |
30 | 0 | genrandom((unsigned char*)&v, sizeof(v)); |
31 | 0 | return v; |
32 | 0 | } |
33 | | |
34 | | static int crypto_hash_sha512(uint8_t *out, const uint8_t *m, |
35 | | unsigned long long n) |
36 | 0 | { |
37 | 0 | hash_state hs; |
38 | |
|
39 | 0 | sha512_init(&hs); |
40 | 0 | sha512_process(&hs, m, n); |
41 | 0 | return sha512_done(&hs, out); |
42 | 0 | } |
43 | | |
44 | | #endif /* DROPBEAR_SNTRUP761 */ |