Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

86 rindas
2.7 KiB

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