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.

84 lines
2.7 KiB

  1. /*
  2. xmss.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 level;
  12. unsigned long long subtree;
  13. unsigned int subleaf;
  14. } leafaddr;
  15. typedef struct{
  16. wots_params wots_par;
  17. unsigned int n;
  18. unsigned int h;
  19. } xmss_params;
  20. typedef struct{
  21. xmss_params xmss_par;
  22. unsigned int n;
  23. unsigned int h;
  24. unsigned int d;
  25. unsigned int index_len;
  26. } xmssmt_params;
  27. /**
  28. * Initializes parameter set.
  29. * Needed, for any of the other methods.
  30. */
  31. void xmss_set_params(xmss_params *params, int n, int h, int w);
  32. /**
  33. * Initialize xmssmt_params struct
  34. * parameter names are the same as in the draft
  35. *
  36. * Especially h is the total tree height, i.e. the XMSS trees have height h/d
  37. */
  38. void xmssmt_set_params(xmssmt_params *params, int n, int h, int d, int w);
  39. /**
  40. * Generates a XMSS key pair for a given parameter set.
  41. * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  42. * Format pk: [root || PUB_SEED] omitting algo oid.
  43. */
  44. int xmss_keypair(unsigned char *pk, unsigned char *sk, xmss_params *params);
  45. /**
  46. * Signs a message.
  47. * Returns
  48. * 1. an array containing the signature followed by the message AND
  49. * 2. an updated secret key!
  50. *
  51. */
  52. int xmss_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen, const xmss_params *params);
  53. /**
  54. * Verifies a given message signature pair under a given public key.
  55. *
  56. * 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).
  57. */
  58. 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, const xmss_params *params);
  59. /*
  60. * Generates a XMSSMT key pair for a given parameter set.
  61. * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  62. * Format pk: [root || PUB_SEED] omitting algo oid.
  63. */
  64. int xmssmt_keypair(unsigned char *pk, unsigned char *sk, xmssmt_params *params);
  65. /**
  66. * Signs a message.
  67. * Returns
  68. * 1. an array containing the signature followed by the message AND
  69. * 2. an updated secret key!
  70. *
  71. */
  72. int xmssmt_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen, const xmssmt_params *params);
  73. /**
  74. * Verifies a given message signature pair under a given public key.
  75. */
  76. 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, const xmssmt_params *params);
  77. #endif