25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

params.h 2.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef XMSS_PARAMS_H
  2. #define XMSS_PARAMS_H
  3. #include <stdint.h>
  4. /* These are merely internal identifiers for the supported hash functions. */
  5. #define XMSS_SHA2 0
  6. #define XMSS_SHAKE128 1
  7. #define XMSS_SHAKE256 2
  8. /* This is a result of the OID definitions in the draft; needed for parsing. */
  9. #define XMSS_OID_LEN 4
  10. /* This structure will be populated when calling xmss[mt]_parse_oid. */
  11. typedef struct {
  12. unsigned int func;
  13. unsigned int n;
  14. unsigned int padding_len;
  15. unsigned int wots_w;
  16. unsigned int wots_log_w;
  17. unsigned int wots_len1;
  18. unsigned int wots_len2;
  19. unsigned int wots_len;
  20. unsigned int wots_sig_bytes;
  21. unsigned int full_height;
  22. unsigned int tree_height;
  23. unsigned int d;
  24. unsigned int index_bytes;
  25. unsigned int sig_bytes;
  26. unsigned int pk_bytes;
  27. unsigned long long sk_bytes;
  28. unsigned int bds_k;
  29. } xmss_params;
  30. /**
  31. * Accepts strings such as "XMSS-SHA2_10_256"
  32. * and outputs OIDs such as 0x01000001.
  33. * Returns -1 when the parameter set is not found, 0 otherwise
  34. */
  35. int xmss_str_to_oid(uint32_t *oid, const char *s);
  36. /**
  37. * Accepts takes strings such as "XMSSMT-SHA2_20/2_256"
  38. * and outputs OIDs such as 0x01000001.
  39. * Returns -1 when the parameter set is not found, 0 otherwise
  40. */
  41. int xmssmt_str_to_oid(uint32_t *oid, const char *s);
  42. /**
  43. * Accepts OIDs such as 0x01000001, and configures params accordingly.
  44. * Returns -1 when the OID is not found, 0 otherwise.
  45. */
  46. int xmss_parse_oid(xmss_params *params, const uint32_t oid);
  47. /**
  48. * Accepts OIDs such as 0x01000001, and configures params accordingly.
  49. * Returns -1 when the OID is not found, 0 otherwise.
  50. */
  51. int xmssmt_parse_oid(xmss_params *params, const uint32_t oid);
  52. /* Given a params struct where the following properties have been initialized;
  53. - full_height; the height of the complete (hyper)tree
  54. - n; the number of bytes of hash function output
  55. - d; the number of layers (d > 1 implies XMSSMT)
  56. - func; one of {XMSS_SHA2, XMSS_SHAKE128, XMSS_SHAKE256}
  57. - wots_w; the Winternitz parameter
  58. - optionally, bds_k; the BDS traversal trade-off parameter,
  59. this function initializes the remainder of the params structure. */
  60. int xmss_xmssmt_initialize_params(xmss_params *params);
  61. #endif