xref: /freebsd/sys/contrib/libsodium/src/libsodium/include/sodium/crypto_generichash.h (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1 #ifndef crypto_generichash_H
2 #define crypto_generichash_H
3 
4 #include <stddef.h>
5 
6 #include "crypto_generichash_blake2b.h"
7 #include "export.h"
8 
9 #ifdef __cplusplus
10 # ifdef __GNUC__
11 #  pragma GCC diagnostic ignored "-Wlong-long"
12 # endif
13 extern "C" {
14 #endif
15 
16 #define crypto_generichash_BYTES_MIN crypto_generichash_blake2b_BYTES_MIN
17 SODIUM_EXPORT
18 size_t  crypto_generichash_bytes_min(void);
19 
20 #define crypto_generichash_BYTES_MAX crypto_generichash_blake2b_BYTES_MAX
21 SODIUM_EXPORT
22 size_t  crypto_generichash_bytes_max(void);
23 
24 #define crypto_generichash_BYTES crypto_generichash_blake2b_BYTES
25 SODIUM_EXPORT
26 size_t  crypto_generichash_bytes(void);
27 
28 #define crypto_generichash_KEYBYTES_MIN crypto_generichash_blake2b_KEYBYTES_MIN
29 SODIUM_EXPORT
30 size_t  crypto_generichash_keybytes_min(void);
31 
32 #define crypto_generichash_KEYBYTES_MAX crypto_generichash_blake2b_KEYBYTES_MAX
33 SODIUM_EXPORT
34 size_t  crypto_generichash_keybytes_max(void);
35 
36 #define crypto_generichash_KEYBYTES crypto_generichash_blake2b_KEYBYTES
37 SODIUM_EXPORT
38 size_t  crypto_generichash_keybytes(void);
39 
40 #define crypto_generichash_PRIMITIVE "blake2b"
41 SODIUM_EXPORT
42 const char *crypto_generichash_primitive(void);
43 
44 /*
45  * Important when writing bindings for other programming languages:
46  * the state address *must* be 64-bytes aligned.
47  */
48 typedef crypto_generichash_blake2b_state crypto_generichash_state;
49 
50 SODIUM_EXPORT
51 size_t  crypto_generichash_statebytes(void);
52 
53 SODIUM_EXPORT
54 int crypto_generichash(unsigned char *out, size_t outlen,
55                        const unsigned char *in, unsigned long long inlen,
56                        const unsigned char *key, size_t keylen);
57 
58 SODIUM_EXPORT
59 int crypto_generichash_init(crypto_generichash_state *state,
60                             const unsigned char *key,
61                             const size_t keylen, const size_t outlen);
62 
63 SODIUM_EXPORT
64 int crypto_generichash_update(crypto_generichash_state *state,
65                               const unsigned char *in,
66                               unsigned long long inlen);
67 
68 SODIUM_EXPORT
69 int crypto_generichash_final(crypto_generichash_state *state,
70                              unsigned char *out, const size_t outlen);
71 
72 SODIUM_EXPORT
73 void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif
80