Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

84 rader
1.6 KiB

  1. /*
  2. hash.c version 20160210
  3. Andreas Hülsing
  4. Joost Rijneveld
  5. Public domain.
  6. */
  7. /*
  8. * Used in hash.c
  9. */
  10. #define SET_BLOCK_BIT(a, b) (a[15] = (a[15] & 1) | ((b << 1) & 2))
  11. #define SET_KEY_BIT(a, b) (a[15] = (a[15] & 2) | (b & 1))
  12. #define WOTS_SELECT_KEY(a) (a[15] = 1)
  13. #define WOTS_SELECT_BLOCK(a) (a[15] = 0)
  14. /*
  15. * Used in wots.c
  16. */
  17. #define SET_HASH_ADDRESS(a, v) {\
  18. a[14] = (v & 255);}
  19. #define SET_CHAIN_ADDRESS(a, v) {\
  20. a[13] = (v & 255);\
  21. a[12] = ((v >> 8) & 255);}
  22. /*
  23. * Used in xmss_fast.c and xmss.c
  24. */
  25. #define SET_LAYER_ADDRESS(a, v) {\
  26. a[0] = (v & 255);}
  27. #define SET_TREE_ADDRESS(a, v) {\
  28. a[5] = (v & 255);\
  29. a[4] = (v >> 8) & 255;\
  30. a[3] = (v >> 16) & 255;\
  31. a[2] = (v >> 24) & 255;\
  32. a[1] = (v >> 32) & 255;}
  33. #define SET_OTS_BIT(a, b) {\
  34. a[6] = (b & 1);\
  35. a[7] = 0;\
  36. a[8] = 0;}
  37. #define SET_OTS_ADDRESS(a, v) {\
  38. a[11] = (v & 255);\
  39. a[10] = (v >> 8) & 255;\
  40. a[9] = (v >> 16) & 255;}
  41. #define ZEROISE_OTS_ADDR(a) {\
  42. a[12] = 0;\
  43. a[13] = 0;\
  44. a[14] = 0;\
  45. a[15] = 0;}
  46. #define SET_LTREE_BIT(a, b) {\
  47. a[7] = (a[7] & 0) | (b & 1);}
  48. #define SET_LTREE_ADDRESS(a, v) {\
  49. a[10] = v & 255;\
  50. a[9] = (v >> 8) & 255;\
  51. a[8] = (v >> 16) & 255;}
  52. #define SET_LTREE_TREE_HEIGHT(a, v) {\
  53. a[11] = (v & 255);}
  54. #define SET_LTREE_TREE_INDEX(a, v) {\
  55. a[14] = (v & 255);\
  56. a[13] = (v >> 8) & 255;\
  57. a[12] = (v >> 16) & 3;}
  58. #define SET_NODE_PADDING(a) {\
  59. a[8] = 0;\
  60. a[9] = 0;\
  61. a[10] = 0;}
  62. #define SET_NODE_TREE_HEIGHT(a, v) {\
  63. a[11] = (v & 255);}
  64. #define SET_NODE_TREE_INDEX(a, v) {\
  65. a[14] = v & 255;\
  66. a[13] = (v >> 8) & 255;\
  67. a[12] = (v >> 16) & 255;}