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.

78 lines
2.6 KiB

  1. /*
  2. xmss_fast.h version 20160722
  3. Andreas Hülsing
  4. Joost Rijneveld
  5. Public domain.
  6. */
  7. #include "wots.h"
  8. #ifndef XMSS_H
  9. #define XMSS_H
  10. typedef struct{
  11. unsigned int h;
  12. unsigned int next_idx;
  13. unsigned int stackusage;
  14. unsigned char completed;
  15. unsigned char *node;
  16. } treehash_inst;
  17. typedef struct {
  18. unsigned char *stack;
  19. unsigned int stackoffset;
  20. unsigned char *stacklevels;
  21. unsigned char *auth;
  22. unsigned char *keep;
  23. treehash_inst *treehash;
  24. unsigned char *retain;
  25. unsigned int next_leaf;
  26. } bds_state;
  27. /**
  28. * Initialize BDS state struct
  29. * parameter names are the same as used in the description of the BDS traversal
  30. */
  31. void xmss_set_bds_state(bds_state *state, unsigned char *stack, int stackoffset, unsigned char *stacklevels, unsigned char *auth, unsigned char *keep, treehash_inst *treehash, unsigned char *retain, int next_leaf);
  32. /**
  33. * Generates a XMSS key pair for a given parameter set.
  34. * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  35. * Format pk: [root || PUB_SEED] omitting algo oid.
  36. */
  37. int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state);
  38. /**
  39. * Signs a message.
  40. * Returns
  41. * 1. an array containing the signature followed by the message AND
  42. * 2. an updated secret key!
  43. *
  44. */
  45. int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen);
  46. /**
  47. * Verifies a given message signature pair under a given public key.
  48. *
  49. * Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg).
  50. */
  51. int xmss_sign_open(unsigned char *msg,unsigned long long *msglen, const unsigned char *sig_msg,unsigned long long sig_msg_len, const unsigned char *pk);
  52. /*
  53. * Generates a XMSSMT key pair for a given parameter set.
  54. * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  55. * Format pk: [root || PUB_SEED] omitting algo oid.
  56. */
  57. int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs);
  58. /**
  59. * Signs a message.
  60. * Returns
  61. * 1. an array containing the signature followed by the message AND
  62. * 2. an updated secret key!
  63. *
  64. */
  65. int xmssmt_sign(unsigned char *sk, bds_state *state, unsigned char *wots_sigs, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen);
  66. /**
  67. * Verifies a given message signature pair under a given public key.
  68. */
  69. int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk);
  70. #endif