xref: /freebsd/sys/contrib/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1 
2 #include "crypto_onetimeauth.h"
3 #include "randombytes.h"
4 
5 size_t
crypto_onetimeauth_statebytes(void)6 crypto_onetimeauth_statebytes(void)
7 {
8     return sizeof(crypto_onetimeauth_state);
9 }
10 
11 size_t
crypto_onetimeauth_bytes(void)12 crypto_onetimeauth_bytes(void)
13 {
14     return crypto_onetimeauth_BYTES;
15 }
16 
17 size_t
crypto_onetimeauth_keybytes(void)18 crypto_onetimeauth_keybytes(void)
19 {
20     return crypto_onetimeauth_KEYBYTES;
21 }
22 
23 int
crypto_onetimeauth(unsigned char * out,const unsigned char * in,unsigned long long inlen,const unsigned char * k)24 crypto_onetimeauth(unsigned char *out, const unsigned char *in,
25                    unsigned long long inlen, const unsigned char *k)
26 {
27     return crypto_onetimeauth_poly1305(out, in, inlen, k);
28 }
29 
30 int
crypto_onetimeauth_verify(const unsigned char * h,const unsigned char * in,unsigned long long inlen,const unsigned char * k)31 crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in,
32                           unsigned long long inlen, const unsigned char *k)
33 {
34     return crypto_onetimeauth_poly1305_verify(h, in, inlen, k);
35 }
36 
37 int
crypto_onetimeauth_init(crypto_onetimeauth_state * state,const unsigned char * key)38 crypto_onetimeauth_init(crypto_onetimeauth_state *state,
39                         const unsigned char *key)
40 {
41     return crypto_onetimeauth_poly1305_init
42         ((crypto_onetimeauth_poly1305_state *) state, key);
43 }
44 
45 int
crypto_onetimeauth_update(crypto_onetimeauth_state * state,const unsigned char * in,unsigned long long inlen)46 crypto_onetimeauth_update(crypto_onetimeauth_state *state,
47                           const unsigned char *in,
48                           unsigned long long inlen)
49 {
50     return crypto_onetimeauth_poly1305_update
51         ((crypto_onetimeauth_poly1305_state *) state, in, inlen);
52 }
53 
54 int
crypto_onetimeauth_final(crypto_onetimeauth_state * state,unsigned char * out)55 crypto_onetimeauth_final(crypto_onetimeauth_state *state,
56                          unsigned char *out)
57 {
58     return crypto_onetimeauth_poly1305_final
59         ((crypto_onetimeauth_poly1305_state *) state, out);
60 }
61 
62 const char *
crypto_onetimeauth_primitive(void)63 crypto_onetimeauth_primitive(void)
64 {
65     return crypto_onetimeauth_PRIMITIVE;
66 }
67 
crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES])68 void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES])
69 {
70     randombytes_buf(k, crypto_onetimeauth_KEYBYTES);
71 }
72