libsodium (1.0.19)
1 #ifndef crypto_auth_hmacsha256_H
2 #define crypto_auth_hmacsha256_H
3
4 #include <stddef.h>
5 #include "crypto_hash_sha256.h"
6 #include "export.h"
7
8 #ifdef __cplusplus
9 # ifdef __GNUC__
10 # pragma GCC diagnostic ignored "-Wlong-long"
11 # endif
12 extern "C" {
13 #endif
14
15 #define crypto_auth_hmacsha256_BYTES 32U
16 SODIUM_EXPORT
17 size_t crypto_auth_hmacsha256_bytes(void);
18
19 #define crypto_auth_hmacsha256_KEYBYTES 32U
20 SODIUM_EXPORT
21 size_t crypto_auth_hmacsha256_keybytes(void);
22
23 SODIUM_EXPORT
24 int crypto_auth_hmacsha256(unsigned char *out,
25 const unsigned char *in,
26 unsigned long long inlen,
27 const unsigned char *k) __attribute__ ((nonnull(1, 4)));
28
29 SODIUM_EXPORT
30 int crypto_auth_hmacsha256_verify(const unsigned char *h,
31 const unsigned char *in,
32 unsigned long long inlen,
33 const unsigned char *k)
34 __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
35
36 /* ------------------------------------------------------------------------- */
37
38 typedef struct crypto_auth_hmacsha256_state {
39 crypto_hash_sha256_state ictx;
40 crypto_hash_sha256_state octx;
41 } crypto_auth_hmacsha256_state;
42
43 SODIUM_EXPORT
44 size_t crypto_auth_hmacsha256_statebytes(void);
45
46 SODIUM_EXPORT
47 int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
48 const unsigned char *key,
49 size_t keylen) __attribute__ ((nonnull));
50
51 SODIUM_EXPORT
52 int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
53 const unsigned char *in,
54 unsigned long long inlen)
55 __attribute__ ((nonnull(1)));
56
57 SODIUM_EXPORT
58 int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
59 unsigned char *out) __attribute__ ((nonnull));
60
61
62 SODIUM_EXPORT
63 void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES])
64 __attribute__ ((nonnull));
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif