You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

  1. #ifndef XMSS_COMMONS_H
  2. #define XMSS_COMMONS_H
  3. #include <stdint.h>
  4. #include "params.h"
  5. /**
  6. * Converts the value of 'in' to 'len' bytes in big-endian byte order.
  7. */
  8. void ull_to_bytes(unsigned char *output, unsigned long long in, uint32_t bytes);
  9. /**
  10. * Computes the leaf at a given address. First generates the WOTS key pair,
  11. * then computes leaf using l_tree. As this happens position independent, we
  12. * only require that addr encodes the right ltree-address.
  13. */
  14. void gen_leaf_wots(const xmss_params *params, unsigned char *leaf,
  15. const unsigned char *sk_seed, const unsigned char *pub_seed,
  16. uint32_t ltree_addr[8], uint32_t ots_addr[8]);
  17. /**
  18. * Used for pseudo-random key generation.
  19. * Generates the seed for the WOTS key pair at address 'addr'.
  20. *
  21. * Takes n-byte sk_seed and returns n-byte seed using 32 byte address 'addr'.
  22. */
  23. void get_seed(const xmss_params *params, unsigned char *seed,
  24. const unsigned char *sk_seed, uint32_t addr[8]);
  25. /**
  26. * Computes a leaf node from a WOTS public key using an L-tree.
  27. * Note that the WOTS public key is destroyed.
  28. */
  29. void l_tree(const xmss_params *params,
  30. unsigned char *leaf, unsigned char *wots_pk,
  31. const unsigned char *pub_seed, uint32_t addr[8]);
  32. /**
  33. * Verifies a given message signature pair under a given public key.
  34. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  35. */
  36. int xmss_core_sign_open(const xmss_params *params,
  37. unsigned char *m, unsigned long long *mlen,
  38. const unsigned char *sm, unsigned long long smlen,
  39. const unsigned char *pk);
  40. /**
  41. * Verifies a given message signature pair under a given public key.
  42. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  43. */
  44. int xmssmt_core_sign_open(const xmss_params *params,
  45. unsigned char *m, unsigned long long *mlen,
  46. const unsigned char *sm, unsigned long long smlen,
  47. const unsigned char *pk);
  48. #endif