crypto_onetimeauth.c 1.7 KB

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