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.

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