Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

utils.h 2.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_UTILS_H
  2. #define PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_UTILS_H
  3. #include "hash_state.h"
  4. #include "params.h"
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. /**
  8. * Converts the value of 'in' to 'outlen' bytes in big-endian byte order.
  9. */
  10. void PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_ull_to_bytes(
  11. unsigned char *out, size_t outlen, unsigned long long in);
  12. /**
  13. * Converts the inlen bytes in 'in' from big-endian byte order to an integer.
  14. */
  15. unsigned long long PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_bytes_to_ull(
  16. const unsigned char *in, size_t inlen);
  17. /**
  18. * Computes a root node given a leaf and an auth path.
  19. * Expects address to be complete other than the tree_height and tree_index.
  20. */
  21. void PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_compute_root(
  22. unsigned char *root, const unsigned char *leaf,
  23. uint32_t leaf_idx, uint32_t idx_offset,
  24. const unsigned char *auth_path, uint32_t tree_height,
  25. const unsigned char *pub_seed, uint32_t addr[8],
  26. const hash_state *hash_state_seeded);
  27. /**
  28. * For a given leaf index, computes the authentication path and the resulting
  29. * root node using Merkle's TreeHash algorithm.
  30. * Expects the layer and tree parts of the tree_addr to be set, as well as the
  31. * tree type (i.e. PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_ADDR_TYPE_HASHTREE or PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_ADDR_TYPE_FORSTREE).
  32. * Applies the offset idx_offset to indices before building addresses, so that
  33. * it is possible to continue counting indices across trees.
  34. */
  35. void PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_treehash_FORS_HEIGHT(
  36. unsigned char *root, unsigned char *auth_path,
  37. const unsigned char *sk_seed, const unsigned char *pub_seed,
  38. uint32_t leaf_idx, uint32_t idx_offset,
  39. void (*gen_leaf)(
  40. unsigned char * /* leaf */,
  41. const unsigned char * /* sk_seed */,
  42. const unsigned char * /* pub_seed */,
  43. uint32_t /* addr_idx */, const uint32_t[8] /* tree_addr */,
  44. const hash_state * /* hash_state_seeded */),
  45. uint32_t tree_addr[8], const hash_state *hash_state_seeded);
  46. void PQCLEAN_SPHINCSHARAKA192SROBUST_AESNI_treehash_TREE_HEIGHT(
  47. unsigned char *root, unsigned char *auth_path,
  48. const unsigned char *sk_seed, const unsigned char *pub_seed,
  49. uint32_t leaf_idx, uint32_t idx_offset,
  50. void (*gen_leaf)(
  51. unsigned char * /* leaf */,
  52. const unsigned char * /* sk_seed */,
  53. const unsigned char * /* pub_seed */,
  54. uint32_t /* addr_idx */, const uint32_t[8] /* tree_addr */,
  55. const hash_state * /* hash_state_seeded */),
  56. uint32_t tree_addr[8], const hash_state *hash_state_seeded);
  57. #endif