e8ef2e3622ed592faa6c3bdb4991b0cc4950b4e6
[trex.git] /
1 #ifndef crypto_hash_sha512_H
2 #define crypto_hash_sha512_H
3
4 /*
5  * WARNING: Unless you absolutely need to use SHA512 for interoperatibility,
6  * purposes, you might want to consider crypto_generichash() instead.
7  * Unlike SHA512, crypto_generichash() is not vulnerable to length
8  * extension attacks.
9  */
10
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <stdlib.h>
14
15 #include "export.h"
16
17 #ifdef __cplusplus
18 # if __GNUC__
19 #  pragma GCC diagnostic ignored "-Wlong-long"
20 # endif
21 extern "C" {
22 #endif
23
24 typedef struct crypto_hash_sha512_state {
25     uint64_t      state[8];
26     uint64_t      count[2];
27     unsigned char buf[128];
28 } crypto_hash_sha512_state;
29
30 #define crypto_hash_sha512_BYTES 64U
31 SODIUM_EXPORT
32 size_t crypto_hash_sha512_bytes(void);
33
34 SODIUM_EXPORT
35 int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
36                        unsigned long long inlen);
37
38 SODIUM_EXPORT
39 int crypto_hash_sha512_init(crypto_hash_sha512_state *state);
40
41 SODIUM_EXPORT
42 int crypto_hash_sha512_update(crypto_hash_sha512_state *state,
43                               const unsigned char *in,
44                               unsigned long long inlen);
45
46 SODIUM_EXPORT
47 int crypto_hash_sha512_final(crypto_hash_sha512_state *state,
48                              unsigned char *out);
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54 #endif