Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

73 строки
2.7 KiB

  1. #ifndef XMSS_CORE_H
  2. #define XMSS_CORE_H
  3. #include "params.h"
  4. /**
  5. * Given a set of parameters, this function returns the size of the secret key.
  6. * This is implementation specific, as varying choices in tree traversal will
  7. * result in varying requirements for state storage.
  8. */
  9. unsigned long long xmss_core_sk_bytes(const xmss_params *params);
  10. /*
  11. * Generates a XMSS key pair for a given parameter set.
  12. * Format sk: [(32bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
  13. * Format pk: [root || PUB_SEED], omitting algorithm OID.
  14. */
  15. int xmss_core_keypair(const xmss_params *params,
  16. unsigned char *pk, unsigned char *sk);
  17. /**
  18. * Signs a message. Returns an array containing the signature followed by the
  19. * message and an updated secret key.
  20. */
  21. int xmss_core_sign(const xmss_params *params,
  22. unsigned char *sk,
  23. unsigned char *sm, unsigned long long *smlen,
  24. const unsigned char *m, unsigned long long mlen);
  25. /**
  26. * Verifies a given message signature pair under a given public key.
  27. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  28. */
  29. int xmss_core_sign_open(const xmss_params *params,
  30. unsigned char *m, unsigned long long *mlen,
  31. const unsigned char *sm, unsigned long long smlen,
  32. const unsigned char *pk);
  33. /**
  34. * Given a set of parameters, this function returns the size of the secret key.
  35. * This is implementation specific, as varying choices in tree traversal will
  36. * result in varying requirements for state storage.
  37. */
  38. unsigned long long xmssmt_core_sk_bytes(const xmss_params *params);
  39. /*
  40. * Generates a XMSSMT key pair for a given parameter set.
  41. * Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || PUB_SEED]
  42. * Format pk: [root || PUB_SEED] omitting algorithm OID.
  43. */
  44. int xmssmt_core_keypair(const xmss_params *params,
  45. unsigned char *pk, unsigned char *sk);
  46. /**
  47. * Signs a message. Returns an array containing the signature followed by the
  48. * message and an updated secret key.
  49. */
  50. int xmssmt_core_sign(const xmss_params *params,
  51. unsigned char *sk,
  52. unsigned char *sm, unsigned long long *smlen,
  53. const unsigned char *m, unsigned long long mlen);
  54. /**
  55. * Verifies a given message signature pair under a given public key.
  56. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  57. */
  58. int xmssmt_core_sign_open(const xmss_params *params,
  59. unsigned char *m, unsigned long long *mlen,
  60. const unsigned char *sm, unsigned long long smlen,
  61. const unsigned char *pk);
  62. #endif