Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

85 Zeilen
2.6 KiB

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