sl_sha3_5.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* sl_sha3_5.h :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2018/09/26 20:13:19 by bchanot #+# #+# */
  9. /* Updated: 2018/10/10 12:57:18 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef SL_SHA3_5_H
  13. # define SL_SHA3_5_H
  14. # define EP0_SHA3_5(x) (ROR64(x, 28) ^ ROR64(x, 34) ^ ROR64(x, 39))
  15. # define EP1_SHA3_5(x) (ROR64(x, 14) ^ ROR64(x, 18) ^ ROR64(x, 41))
  16. # define SIG0_SHA3_5(x) (ROR64(x, 1) ^ ROR64(x, 8) ^ ((x) >> 7))
  17. # define SIG1_SHA3_5(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ ((x) >> 6))
  18. # define SHA384 0
  19. # define SHA512 1
  20. typedef struct s_sha3_5
  21. {
  22. t_uint8 buff[128];
  23. t_uint64 state[8];
  24. t_uint64 count[4];
  25. } t_sha3_5;
  26. typedef struct s_process_sha3_5
  27. {
  28. t_uint64 a;
  29. t_uint64 b;
  30. t_uint64 c;
  31. t_uint64 d;
  32. t_uint64 e;
  33. t_uint64 f;
  34. t_uint64 g;
  35. t_uint64 h;
  36. } t_process_sha3_5;
  37. void sl_sha3_5_get_registers(t_uint64 *m, t_process_sha3_5 *t, \
  38. size_t i);
  39. void sl_sha3_5_process_init_add(t_sha3_5 *ctx, t_process_sha3_5 *t, \
  40. t_bool init);
  41. void sl_sha3_5_init(t_sha3_5 *ctx, t_uint8 sha);
  42. void sl_sha3_5_update(t_sha3_5 *ctx, const t_uint8 *data, \
  43. size_t len);
  44. void sl_sha3_5_final(t_sha3_5 *ctx);
  45. void sl_sha3_5_get_hash(t_sha3_5 *ctx, t_uint8 *hash);
  46. #endif