digest-kangarootwelve 0.0.2 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +71 -37
  3. data/Rakefile +7 -9
  4. data/digest-kangarootwelve.gemspec +323 -14
  5. data/ext/digest/kangarootwelve/ext.c +228 -177
  6. data/ext/digest/kangarootwelve/extconf.rb +15 -1
  7. data/ext/digest/kangarootwelve/keccak/armv6m/KangarooTwelve.link.c +1 -0
  8. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakDuplexWidth1600.link.c +1 -0
  9. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-SnP.h +36 -0
  10. data/ext/digest/kangarootwelve/{KeccakP-1600-times2-SnP.h → keccak/armv6m/KeccakP-1600-times2-SnP.h} +10 -10
  11. data/ext/digest/kangarootwelve/{KeccakP-1600-times2-on1.c → keccak/armv6m/KeccakP-1600-times2-on1.c} +13 -7
  12. data/ext/digest/kangarootwelve/{KeccakP-1600-times4-SnP.h → keccak/armv6m/KeccakP-1600-times4-SnP.h} +10 -10
  13. data/ext/digest/kangarootwelve/{KeccakP-1600-times4-on1.c → keccak/armv6m/KeccakP-1600-times4-on1.c} +13 -7
  14. data/ext/digest/kangarootwelve/{KeccakP-1600-times8-SnP.h → keccak/armv6m/KeccakP-1600-times8-SnP.h} +10 -10
  15. data/ext/digest/kangarootwelve/{KeccakP-1600-times8-on1.c → keccak/armv6m/KeccakP-1600-times8-on1.c} +13 -7
  16. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +1334 -0
  17. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakSpongeWidth1600.link.c +1 -0
  18. data/ext/digest/kangarootwelve/{PlSnP-Fallback.inc → keccak/armv6m/PlSnP-Fallback.inc} +11 -7
  19. data/ext/digest/kangarootwelve/keccak/armv6m/ext.link.c +1 -0
  20. data/ext/digest/kangarootwelve/keccak/armv7a/KangarooTwelve.link.c +1 -0
  21. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakDuplexWidth1600.link.c +1 -0
  22. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-SnP.h +37 -0
  23. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-armv7a-le-neon-gcc.s +826 -0
  24. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +1245 -0
  25. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times2-SnP.h +38 -0
  26. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-SnP.h +45 -0
  27. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-on2.c +38 -0
  28. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-SnP.h +45 -0
  29. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-on2.c +38 -0
  30. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakSpongeWidth1600.link.c +1 -0
  31. data/ext/digest/kangarootwelve/keccak/armv7a/PlSnP-Fallback.inc +287 -0
  32. data/ext/digest/kangarootwelve/keccak/armv7a/ext.link.c +1 -0
  33. data/ext/digest/kangarootwelve/keccak/armv7m/KangarooTwelve.link.c +1 -0
  34. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakDuplexWidth1600.link.c +1 -0
  35. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-SnP.h +36 -0
  36. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +1170 -0
  37. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-SnP.h +45 -0
  38. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-on1.c +37 -0
  39. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-SnP.h +45 -0
  40. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-on1.c +37 -0
  41. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-SnP.h +45 -0
  42. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-on1.c +37 -0
  43. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakSpongeWidth1600.link.c +1 -0
  44. data/ext/digest/kangarootwelve/keccak/armv7m/PlSnP-Fallback.inc +287 -0
  45. data/ext/digest/kangarootwelve/keccak/armv7m/ext.link.c +1 -0
  46. data/ext/digest/kangarootwelve/keccak/armv8a/KangarooTwelve.link.c +1 -0
  47. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakDuplexWidth1600.link.c +1 -0
  48. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-SnP.h +28 -0
  49. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-armv8a-neon.s +537 -0
  50. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-SnP.h +45 -0
  51. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-on1.c +37 -0
  52. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-SnP.h +45 -0
  53. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-on1.c +37 -0
  54. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-SnP.h +45 -0
  55. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-on1.c +37 -0
  56. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakSpongeWidth1600.link.c +1 -0
  57. data/ext/digest/kangarootwelve/keccak/armv8a/PlSnP-Fallback.inc +287 -0
  58. data/ext/digest/kangarootwelve/keccak/armv8a/ext.link.c +1 -0
  59. data/ext/digest/kangarootwelve/keccak/asmx86-64/KangarooTwelve.link.c +1 -0
  60. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakDuplexWidth1600.link.c +1 -0
  61. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-SnP.h +37 -0
  62. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-SnP.h +45 -0
  63. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-on1.c +37 -0
  64. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-SnP.h +45 -0
  65. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-on1.c +37 -0
  66. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-SnP.h +45 -0
  67. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-on1.c +37 -0
  68. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-x86-64-gas.s +1190 -0
  69. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakSpongeWidth1600.link.c +1 -0
  70. data/ext/digest/kangarootwelve/keccak/asmx86-64/PlSnP-Fallback.inc +287 -0
  71. data/ext/digest/kangarootwelve/keccak/asmx86-64/ext.link.c +1 -0
  72. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KangarooTwelve.link.c +1 -0
  73. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakDuplexWidth1600.link.c +1 -0
  74. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-SnP.h +37 -0
  75. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-SnP.h +45 -0
  76. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-on1.c +37 -0
  77. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-SnP.h +45 -0
  78. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-on1.c +37 -0
  79. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-SnP.h +45 -0
  80. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-on1.c +37 -0
  81. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-x86-64-shld-gas.s +1190 -0
  82. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakSpongeWidth1600.link.c +1 -0
  83. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/PlSnP-Fallback.inc +287 -0
  84. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/ext.link.c +1 -0
  85. data/ext/digest/kangarootwelve/keccak/avr8/KangarooTwelve.link.c +1 -0
  86. data/ext/digest/kangarootwelve/keccak/avr8/KeccakDuplexWidth1600.link.c +1 -0
  87. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-SnP.h +37 -0
  88. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-avr8-fast.s +1116 -0
  89. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-SnP.h +45 -0
  90. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-on1.c +37 -0
  91. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-SnP.h +45 -0
  92. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-on1.c +37 -0
  93. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-SnP.h +45 -0
  94. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-on1.c +37 -0
  95. data/ext/digest/kangarootwelve/keccak/avr8/KeccakSpongeWidth1600.link.c +1 -0
  96. data/ext/digest/kangarootwelve/keccak/avr8/PlSnP-Fallback.inc +287 -0
  97. data/ext/digest/kangarootwelve/keccak/avr8/ext.link.c +1 -0
  98. data/ext/digest/kangarootwelve/keccak/bulldozer/KangarooTwelve.link.c +1 -0
  99. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakDuplexWidth1600.link.c +1 -0
  100. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-SnP.h +39 -0
  101. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP-config.h +6 -0
  102. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP.c +473 -0
  103. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SIMD128.c +954 -0
  104. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SnP.h +47 -0
  105. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-SnP.h +45 -0
  106. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-on2.c +38 -0
  107. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-SnP.h +45 -0
  108. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-on2.c +38 -0
  109. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-unrolling.macros +302 -0
  110. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakSpongeWidth1600.link.c +1 -0
  111. data/ext/digest/kangarootwelve/keccak/bulldozer/PlSnP-Fallback.inc +287 -0
  112. data/ext/digest/kangarootwelve/keccak/bulldozer/SIMD128-config.h +9 -0
  113. data/ext/digest/kangarootwelve/{SnP-Relaned.h → keccak/bulldozer/SnP-Relaned.h} +13 -7
  114. data/ext/digest/kangarootwelve/keccak/bulldozer/ext.link.c +1 -0
  115. data/ext/digest/kangarootwelve/{KangarooTwelve.c → keccak/common/KangarooTwelve.c} +6 -10
  116. data/ext/digest/kangarootwelve/{KangarooTwelve.h → keccak/common/KangarooTwelve.h} +3 -7
  117. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex-common.h +37 -0
  118. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex.inc +192 -0
  119. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.c +34 -0
  120. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.h +25 -0
  121. data/ext/digest/kangarootwelve/{KeccakSponge-common.h → keccak/common/KeccakSponge-common.h} +5 -7
  122. data/ext/digest/kangarootwelve/{KeccakSponge.inc → keccak/common/KeccakSponge.inc} +6 -8
  123. data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.c → keccak/common/KeccakSpongeWidth1600.c} +6 -8
  124. data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.h → keccak/common/KeccakSpongeWidth1600.h} +5 -7
  125. data/ext/digest/kangarootwelve/{Phases.h → keccak/common/Phases.h} +3 -7
  126. data/ext/digest/kangarootwelve/{align.h → keccak/common/align.h} +5 -7
  127. data/ext/digest/kangarootwelve/{brg_endian.h → keccak/common/brg_endian.h} +0 -0
  128. data/ext/digest/kangarootwelve/keccak/compact/KangarooTwelve.link.c +1 -0
  129. data/ext/digest/kangarootwelve/keccak/compact/KeccakDuplexWidth1600.link.c +1 -0
  130. data/ext/digest/kangarootwelve/{KeccakP-1600-SnP.h → keccak/compact/KeccakP-1600-SnP.h} +7 -10
  131. data/ext/digest/kangarootwelve/{KeccakP-1600-compact64.c → keccak/compact/KeccakP-1600-compact64.c} +11 -7
  132. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-SnP.h +45 -0
  133. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-on1.c +37 -0
  134. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-SnP.h +45 -0
  135. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-on1.c +37 -0
  136. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-SnP.h +45 -0
  137. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-on1.c +37 -0
  138. data/ext/digest/kangarootwelve/keccak/compact/KeccakSpongeWidth1600.link.c +1 -0
  139. data/ext/digest/kangarootwelve/keccak/compact/PlSnP-Fallback.inc +287 -0
  140. data/ext/digest/kangarootwelve/keccak/compact/SnP-Relaned.h +140 -0
  141. data/ext/digest/kangarootwelve/keccak/compact/ext.link.c +1 -0
  142. data/ext/digest/kangarootwelve/keccak/generic32/KangarooTwelve.link.c +1 -0
  143. data/ext/digest/kangarootwelve/keccak/generic32/KeccakDuplexWidth1600.link.c +1 -0
  144. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-SnP.h +38 -0
  145. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-inplace32BI.c +1162 -0
  146. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-SnP.h +45 -0
  147. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-on1.c +37 -0
  148. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-SnP.h +45 -0
  149. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-on1.c +37 -0
  150. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-SnP.h +45 -0
  151. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-on1.c +37 -0
  152. data/ext/digest/kangarootwelve/keccak/generic32/KeccakSpongeWidth1600.link.c +1 -0
  153. data/ext/digest/kangarootwelve/keccak/generic32/PlSnP-Fallback.inc +287 -0
  154. data/ext/digest/kangarootwelve/keccak/generic32/SnP-Relaned.h +140 -0
  155. data/ext/digest/kangarootwelve/keccak/generic32/ext.link.c +1 -0
  156. data/ext/digest/kangarootwelve/keccak/generic32lc/KangarooTwelve.link.c +1 -0
  157. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakDuplexWidth1600.link.c +1 -0
  158. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-SnP.h +38 -0
  159. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-inplace32BI.c +1162 -0
  160. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-SnP.h +45 -0
  161. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-on1.c +37 -0
  162. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-SnP.h +45 -0
  163. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-on1.c +37 -0
  164. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-SnP.h +45 -0
  165. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-on1.c +37 -0
  166. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakSpongeWidth1600.link.c +1 -0
  167. data/ext/digest/kangarootwelve/keccak/generic32lc/PlSnP-Fallback.inc +287 -0
  168. data/ext/digest/kangarootwelve/keccak/generic32lc/SnP-Relaned.h +140 -0
  169. data/ext/digest/kangarootwelve/keccak/generic32lc/ext.link.c +1 -0
  170. data/ext/digest/kangarootwelve/keccak/generic64/KangarooTwelve.link.c +1 -0
  171. data/ext/digest/kangarootwelve/keccak/generic64/KeccakDuplexWidth1600.link.c +1 -0
  172. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-64.macros +2195 -0
  173. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-SnP.h +49 -0
  174. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64-config.h +6 -0
  175. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64.c +541 -0
  176. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-SnP.h +45 -0
  177. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-on1.c +37 -0
  178. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-SnP.h +45 -0
  179. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-on1.c +37 -0
  180. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-SnP.h +45 -0
  181. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-on1.c +37 -0
  182. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-unrolling.macros +302 -0
  183. data/ext/digest/kangarootwelve/keccak/generic64/KeccakSpongeWidth1600.link.c +1 -0
  184. data/ext/digest/kangarootwelve/keccak/generic64/PlSnP-Fallback.inc +287 -0
  185. data/ext/digest/kangarootwelve/keccak/generic64/SnP-Relaned.h +140 -0
  186. data/ext/digest/kangarootwelve/keccak/generic64/ext.link.c +1 -0
  187. data/ext/digest/kangarootwelve/keccak/generic64lc/KangarooTwelve.link.c +1 -0
  188. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakDuplexWidth1600.link.c +1 -0
  189. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-64.macros +2195 -0
  190. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-SnP.h +49 -0
  191. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64-config.h +7 -0
  192. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64.c +541 -0
  193. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-SnP.h +45 -0
  194. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-on1.c +37 -0
  195. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-SnP.h +45 -0
  196. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-on1.c +37 -0
  197. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-SnP.h +45 -0
  198. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-on1.c +37 -0
  199. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-unrolling.macros +302 -0
  200. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakSpongeWidth1600.link.c +1 -0
  201. data/ext/digest/kangarootwelve/keccak/generic64lc/PlSnP-Fallback.inc +287 -0
  202. data/ext/digest/kangarootwelve/keccak/generic64lc/SnP-Relaned.h +140 -0
  203. data/ext/digest/kangarootwelve/keccak/generic64lc/ext.link.c +1 -0
  204. data/ext/digest/kangarootwelve/keccak/haswell/KangarooTwelve.link.c +1 -0
  205. data/ext/digest/kangarootwelve/keccak/haswell/KeccakDuplexWidth1600.link.c +1 -0
  206. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-AVX2.s +993 -0
  207. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-SnP.h +41 -0
  208. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SIMD128.c +954 -0
  209. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SnP.h +47 -0
  210. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SIMD256.c +1303 -0
  211. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SnP.h +53 -0
  212. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-SnP.h +45 -0
  213. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-on4.c +38 -0
  214. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-unrolling.macros +302 -0
  215. data/ext/digest/kangarootwelve/keccak/haswell/KeccakSpongeWidth1600.link.c +1 -0
  216. data/ext/digest/kangarootwelve/keccak/haswell/PlSnP-Fallback.inc +287 -0
  217. data/ext/digest/kangarootwelve/keccak/haswell/SIMD128-config.h +8 -0
  218. data/ext/digest/kangarootwelve/keccak/haswell/SIMD256-config.h +7 -0
  219. data/ext/digest/kangarootwelve/keccak/haswell/ext.link.c +1 -0
  220. data/ext/digest/kangarootwelve/keccak/nehalem/KangarooTwelve.link.c +1 -0
  221. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakDuplexWidth1600.link.c +1 -0
  222. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-64.macros +2195 -0
  223. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-SnP.h +49 -0
  224. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64-config.h +7 -0
  225. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64.c +541 -0
  226. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SIMD128.c +954 -0
  227. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SnP.h +47 -0
  228. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-SnP.h +45 -0
  229. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-on2.c +38 -0
  230. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-SnP.h +45 -0
  231. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-on2.c +38 -0
  232. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-unrolling.macros +302 -0
  233. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakSpongeWidth1600.link.c +1 -0
  234. data/ext/digest/kangarootwelve/keccak/nehalem/PlSnP-Fallback.inc +287 -0
  235. data/ext/digest/kangarootwelve/keccak/nehalem/SIMD128-config.h +8 -0
  236. data/ext/digest/kangarootwelve/keccak/nehalem/SnP-Relaned.h +140 -0
  237. data/ext/digest/kangarootwelve/keccak/nehalem/ext.link.c +1 -0
  238. data/ext/digest/kangarootwelve/keccak/reference/KangarooTwelve.link.c +1 -0
  239. data/ext/digest/kangarootwelve/keccak/reference/KeccakDuplexWidth1600.link.c +1 -0
  240. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-SnP.h +41 -0
  241. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.c +424 -0
  242. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.h +20 -0
  243. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-SnP.h +45 -0
  244. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-on1.c +37 -0
  245. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-SnP.h +45 -0
  246. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-on1.c +37 -0
  247. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-SnP.h +45 -0
  248. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-on1.c +37 -0
  249. data/ext/digest/kangarootwelve/keccak/reference/KeccakSpongeWidth1600.link.c +1 -0
  250. data/ext/digest/kangarootwelve/keccak/reference/PlSnP-Fallback.inc +287 -0
  251. data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.c +176 -0
  252. data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.h +29 -0
  253. data/ext/digest/kangarootwelve/keccak/reference/ext.link.c +1 -0
  254. data/ext/digest/kangarootwelve/keccak/reference32bits/KangarooTwelve.link.c +1 -0
  255. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakDuplexWidth1600.link.c +1 -0
  256. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-SnP.h +41 -0
  257. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference.h +20 -0
  258. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference32BI.c +612 -0
  259. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-SnP.h +45 -0
  260. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-on1.c +37 -0
  261. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-SnP.h +45 -0
  262. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-on1.c +37 -0
  263. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-SnP.h +45 -0
  264. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-on1.c +37 -0
  265. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakSpongeWidth1600.link.c +1 -0
  266. data/ext/digest/kangarootwelve/keccak/reference32bits/PlSnP-Fallback.inc +287 -0
  267. data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.c +176 -0
  268. data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.h +29 -0
  269. data/ext/digest/kangarootwelve/keccak/reference32bits/ext.link.c +1 -0
  270. data/ext/digest/kangarootwelve/keccak/sandybridge/KangarooTwelve.link.c +1 -0
  271. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakDuplexWidth1600.link.c +1 -0
  272. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-64.macros +2195 -0
  273. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-SnP.h +49 -0
  274. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64-config.h +8 -0
  275. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64.c +541 -0
  276. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SIMD128.c +954 -0
  277. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SnP.h +47 -0
  278. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-SnP.h +45 -0
  279. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-on2.c +38 -0
  280. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-SnP.h +45 -0
  281. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-on2.c +38 -0
  282. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-unrolling.macros +302 -0
  283. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakSpongeWidth1600.link.c +1 -0
  284. data/ext/digest/kangarootwelve/keccak/sandybridge/PlSnP-Fallback.inc +287 -0
  285. data/ext/digest/kangarootwelve/keccak/sandybridge/SIMD128-config.h +8 -0
  286. data/ext/digest/kangarootwelve/keccak/sandybridge/SnP-Relaned.h +140 -0
  287. data/ext/digest/kangarootwelve/keccak/sandybridge/ext.link.c +1 -0
  288. data/ext/digest/kangarootwelve/keccak/skylakex/KangarooTwelve.link.c +1 -0
  289. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakDuplexWidth1600.link.c +1 -0
  290. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512-config.h +6 -0
  291. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512.c +621 -0
  292. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-SnP.h +42 -0
  293. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SIMD512.c +852 -0
  294. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SnP.h +49 -0
  295. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SIMD512.c +883 -0
  296. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SnP.h +49 -0
  297. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SIMD512.c +1473 -0
  298. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SnP.h +53 -0
  299. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakSpongeWidth1600.link.c +1 -0
  300. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-2-config.h +7 -0
  301. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-4-config.h +7 -0
  302. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-config.h +7 -0
  303. data/ext/digest/kangarootwelve/keccak/skylakex/ext.link.c +1 -0
  304. data/ext/digest/kangarootwelve/utils.h +101 -0
  305. data/lib/digest/kangarootwelve/version.rb +2 -2
  306. data/test/test.rb +68 -31
  307. metadata +305 -27
@@ -0,0 +1 @@
1
+ #include "../../ext.c"
@@ -0,0 +1 @@
1
+ #include "../common/KangarooTwelve.c"
@@ -0,0 +1 @@
1
+ #include "../common/KeccakDuplexWidth1600.c"
@@ -0,0 +1,36 @@
1
+ /*
2
+ Implementation by Ronny Van Keer, hereby denoted as "the implementer".
3
+
4
+ For more information, feedback or questions, please refer to our website:
5
+ https://keccak.team/
6
+
7
+ To the extent possible under law, the implementer has waived all copyright
8
+ and related or neighboring rights to the source code in this file.
9
+ http://creativecommons.org/publicdomain/zero/1.0/
10
+
11
+ ---
12
+
13
+ Please refer to SnP-documentation.h for more details.
14
+ */
15
+
16
+ #ifndef _KeccakP_1600_SnP_h_
17
+ #define _KeccakP_1600_SnP_h_
18
+
19
+ #define KeccakP1600_implementation "32-bit bit-interleaved optimized ARM assembler implementation"
20
+ #define KeccakP1600_stateSizeInBytes 200
21
+ #define KeccakP1600_stateAlignment 4
22
+
23
+ /* void KeccakP1600_StaticInitialize( void ); */
24
+ #define KeccakP1600_StaticInitialize()
25
+ void KeccakP1600_Initialize(void *state);
26
+ void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
27
+ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
28
+ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
29
+ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
30
+ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
31
+ void KeccakP1600_Permute_12rounds(void *state);
32
+ void KeccakP1600_Permute_24rounds(void *state);
33
+ void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
34
+ void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
35
+
36
+ #endif
@@ -0,0 +1,1170 @@
1
+ @
2
+ @ Implementation by Ronny Van Keer, hereby denoted as "the implementer".
3
+ @
4
+ @ For more information, feedback or questions, please refer to our website:
5
+ @ https://keccak.team/
6
+ @
7
+ @ To the extent possible under law, the implementer has waived all copyright
8
+ @ and related or neighboring rights to the source code in this file.
9
+ @ http://creativecommons.org/publicdomain/zero/1.0/
10
+ @
11
+ @ ---
12
+ @
13
+ @ This file implements Keccak-p[1600] in a SnP-compatible way.
14
+ @ Please refer to SnP-documentation.h for more details.
15
+ @
16
+ @ This implementation comes with KeccakP-1600-SnP.h in the same folder.
17
+ @ Please refer to LowLevel.build for the exact list of other files it must be combined with.
18
+ @
19
+
20
+ @ WARNING: This implementation assumes a little endian CPU with ARMv7M architecture (e.g., Cortex-M3) and the GCC compiler.
21
+
22
+
23
+ .thumb
24
+ .syntax unified
25
+ .text
26
+
27
+ @ Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002
28
+ .macro toBitInterleaving x0,x1,s0,s1,t,over
29
+
30
+ and \t,\x0,#0x55555555
31
+ orr \t,\t,\t, LSR #1
32
+ and \t,\t,#0x33333333
33
+ orr \t,\t,\t, LSR #2
34
+ and \t,\t,#0x0F0F0F0F
35
+ orr \t,\t,\t, LSR #4
36
+ and \t,\t,#0x00FF00FF
37
+ bfi \t,\t,#8, #8
38
+ .if \over != 0
39
+ lsr \s0,\t, #8
40
+ .else
41
+ eor \s0,\s0,\t, LSR #8
42
+ .endif
43
+
44
+ and \t,\x1,#0x55555555
45
+ orr \t,\t,\t, LSR #1
46
+ and \t,\t,#0x33333333
47
+ orr \t,\t,\t, LSR #2
48
+ and \t,\t,#0x0F0F0F0F
49
+ orr \t,\t,\t, LSR #4
50
+ and \t,\t,#0x00FF00FF
51
+ orr \t,\t,\t, LSR #8
52
+ eor \s0,\s0,\t, LSL #16
53
+
54
+ and \t,\x0,#0xAAAAAAAA
55
+ orr \t,\t,\t, LSL #1
56
+ and \t,\t,#0xCCCCCCCC
57
+ orr \t,\t,\t, LSL #2
58
+ and \t,\t,#0xF0F0F0F0
59
+ orr \t,\t,\t, LSL #4
60
+ and \t,\t,#0xFF00FF00
61
+ orr \t,\t,\t, LSL #8
62
+ .if \over != 0
63
+ lsr \s1,\t, #16
64
+ .else
65
+ eor \s1,\s1,\t, LSR #16
66
+ .endif
67
+
68
+ and \t,\x1,#0xAAAAAAAA
69
+ orr \t,\t,\t, LSL #1
70
+ and \t,\t,#0xCCCCCCCC
71
+ orr \t,\t,\t, LSL #2
72
+ and \t,\t,#0xF0F0F0F0
73
+ orr \t,\t,\t, LSL #4
74
+ and \t,\t,#0xFF00FF00
75
+ orr \t,\t,\t, LSL #8
76
+ bfc \t, #0, #16
77
+ eors \s1,\s1,\t
78
+ .endm
79
+
80
+ @ Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002
81
+ .macro fromBitInterleaving x0, x1, t
82
+
83
+ movs \t, \x0 @ t = x0@
84
+ bfi \x0, \x1, #16, #16 @ x0 = (x0 & 0x0000FFFF) | (x1 << 16)@
85
+ bfc \x1, #0, #16 @ x1 = (t >> 16) | (x1 & 0xFFFF0000)@
86
+ orr \x1, \x1, \t, LSR #16
87
+
88
+ eor \t, \x0, \x0, LSR #8 @ t = (x0 ^ (x0 >> 8)) & 0x0000FF00UL@ x0 = x0 ^ t ^ (t << 8)@
89
+ and \t, #0x0000FF00
90
+ eors \x0, \x0, \t
91
+ eor \x0, \x0, \t, LSL #8
92
+
93
+ eor \t, \x0, \x0, LSR #4 @ t = (x0 ^ (x0 >> 4)) & 0x00F000F0UL@ x0 = x0 ^ t ^ (t << 4)@
94
+ and \t, #0x00F000F0
95
+ eors \x0, \x0, \t
96
+ eor \x0, \x0, \t, LSL #4
97
+
98
+ eor \t, \x0, \x0, LSR #2 @ t = (x0 ^ (x0 >> 2)) & 0x0C0C0C0CUL@ x0 = x0 ^ t ^ (t << 2)@
99
+ and \t, #0x0C0C0C0C
100
+ eors \x0, \x0, \t
101
+ eor \x0, \x0, \t, LSL #2
102
+
103
+ eor \t, \x0, \x0, LSR #1 @ t = (x0 ^ (x0 >> 1)) & 0x22222222UL@ x0 = x0 ^ t ^ (t << 1)@
104
+ and \t, #0x22222222
105
+ eors \x0, \x0, \t
106
+ eor \x0, \x0, \t, LSL #1
107
+
108
+ eor \t, \x1, \x1, LSR #8 @ t = (x1 ^ (x1 >> 8)) & 0x0000FF00UL@ x1 = x1 ^ t ^ (t << 8)@
109
+ and \t, #0x0000FF00
110
+ eors \x1, \x1, \t
111
+ eor \x1, \x1, \t, LSL #8
112
+
113
+ eor \t, \x1, \x1, LSR #4 @ t = (x1 ^ (x1 >> 4)) & 0x00F000F0UL@ x1 = x1 ^ t ^ (t << 4)@
114
+ and \t, #0x00F000F0
115
+ eors \x1, \x1, \t
116
+ eor \x1, \x1, \t, LSL #4
117
+
118
+ eor \t, \x1, \x1, LSR #2 @ t = (x1 ^ (x1 >> 2)) & 0x0C0C0C0CUL@ x1 = x1 ^ t ^ (t << 2)@
119
+ and \t, #0x0C0C0C0C
120
+ eors \x1, \x1, \t
121
+ eor \x1, \x1, \t, LSL #2
122
+
123
+ eor \t, \x1, \x1, LSR #1 @ t = (x1 ^ (x1 >> 1)) & 0x22222222UL@ x1 = x1 ^ t ^ (t << 1)@
124
+ and \t, #0x22222222
125
+ eors \x1, \x1, \t
126
+ eor \x1, \x1, \t, LSL #1
127
+ .endm
128
+
129
+ @ --- offsets in state
130
+ .equ Aba0 , 0*4
131
+ .equ Aba1 , 1*4
132
+ .equ Abe0 , 2*4
133
+ .equ Abe1 , 3*4
134
+ .equ Abi0 , 4*4
135
+ .equ Abi1 , 5*4
136
+ .equ Abo0 , 6*4
137
+ .equ Abo1 , 7*4
138
+ .equ Abu0 , 8*4
139
+ .equ Abu1 , 9*4
140
+ .equ Aga0 , 10*4
141
+ .equ Aga1 , 11*4
142
+ .equ Age0 , 12*4
143
+ .equ Age1 , 13*4
144
+ .equ Agi0 , 14*4
145
+ .equ Agi1 , 15*4
146
+ .equ Ago0 , 16*4
147
+ .equ Ago1 , 17*4
148
+ .equ Agu0 , 18*4
149
+ .equ Agu1 , 19*4
150
+ .equ Aka0 , 20*4
151
+ .equ Aka1 , 21*4
152
+ .equ Ake0 , 22*4
153
+ .equ Ake1 , 23*4
154
+ .equ Aki0 , 24*4
155
+ .equ Aki1 , 25*4
156
+ .equ Ako0 , 26*4
157
+ .equ Ako1 , 27*4
158
+ .equ Aku0 , 28*4
159
+ .equ Aku1 , 29*4
160
+ .equ Ama0 , 30*4
161
+ .equ Ama1 , 31*4
162
+ .equ Ame0 , 32*4
163
+ .equ Ame1 , 33*4
164
+ .equ Ami0 , 34*4
165
+ .equ Ami1 , 35*4
166
+ .equ Amo0 , 36*4
167
+ .equ Amo1 , 37*4
168
+ .equ Amu0 , 38*4
169
+ .equ Amu1 , 39*4
170
+ .equ Asa0 , 40*4
171
+ .equ Asa1 , 41*4
172
+ .equ Ase0 , 42*4
173
+ .equ Ase1 , 43*4
174
+ .equ Asi0 , 44*4
175
+ .equ Asi1 , 45*4
176
+ .equ Aso0 , 46*4
177
+ .equ Aso1 , 47*4
178
+ .equ Asu0 , 48*4
179
+ .equ Asu1 , 49*4
180
+
181
+ @ --- offsets on stack
182
+ .equ mDa0 , 0*4
183
+ .equ mDa1 , 1*4
184
+ .equ mDo0 , 2*4
185
+ .equ mDo1 , 3*4
186
+ .equ mDi0 , 4*4
187
+ .equ mRC , 5*4
188
+ .equ mSize , 6*4
189
+
190
+
191
+ .macro xor5 result,b,g,k,m,s
192
+
193
+ ldr \result, [r0, #\b]
194
+ ldr r1, [r0, #\g]
195
+ eors \result, \result, r1
196
+ ldr r1, [r0, #\k]
197
+ eors \result, \result, r1
198
+ ldr r1, [r0, #\m]
199
+ eors \result, \result, r1
200
+ ldr r1, [r0, #\s]
201
+ eors \result, \result, r1
202
+ .endm
203
+
204
+ .macro xorrol result, aa, bb
205
+
206
+ eor \result, \aa, \bb, ROR #31
207
+ .endm
208
+
209
+ .macro xandnot resofs, aa, bb, cc
210
+
211
+ bic r1, \cc, \bb
212
+ eors r1, r1, \aa
213
+ str r1, [r0, #\resofs]
214
+ .endm
215
+
216
+ .macro KeccakThetaRhoPiChiIota aA1, aDax, aA2, aDex, rot2, aA3, aDix, rot3, aA4, aDox, rot4, aA5, aDux, rot5, offset, last
217
+ ldr r3, [r0, #\aA1]
218
+ ldr r4, [r0, #\aA2]
219
+ ldr r5, [r0, #\aA3]
220
+ ldr r6, [r0, #\aA4]
221
+ ldr r7, [r0, #\aA5]
222
+ eors r3, r3, \aDax
223
+ eors r5, r5, \aDix
224
+ eors r4, r4, \aDex
225
+ eors r6, r6, \aDox
226
+ eors r7, r7, \aDux
227
+ rors r4, #32-\rot2
228
+ rors r5, #32-\rot3
229
+ rors r6, #32-\rot4
230
+ rors r7, #32-\rot5
231
+ xandnot \aA2, r4, r5, r6
232
+ xandnot \aA3, r5, r6, r7
233
+ xandnot \aA4, r6, r7, r3
234
+ xandnot \aA5, r7, r3, r4
235
+ ldr r1, [sp, #mRC]
236
+ bics r5, r5, r4
237
+ ldr r4, [r1, #\offset]
238
+ eors r3, r3, r5
239
+ eors r3, r3, r4
240
+ .if \last == 1
241
+ ldr r4, [r1, #32]!
242
+ str r1, [sp, #mRC]
243
+ cmp r4, #0xFF
244
+ .endif
245
+ str r3, [r0, #\aA1]
246
+ .endm
247
+
248
+ .macro KeccakThetaRhoPiChi aB1, aA1, aDax, rot1, aB2, aA2, aDex, rot2, aB3, aA3, aDix, rot3, aB4, aA4, aDox, rot4, aB5, aA5, aDux, rot5
249
+ ldr \aB1, [r0, #\aA1]
250
+ ldr \aB2, [r0, #\aA2]
251
+ ldr \aB3, [r0, #\aA3]
252
+ ldr \aB4, [r0, #\aA4]
253
+ ldr \aB5, [r0, #\aA5]
254
+ eors \aB1, \aB1, \aDax
255
+ eors \aB3, \aB3, \aDix
256
+ eors \aB2, \aB2, \aDex
257
+ eors \aB4, \aB4, \aDox
258
+ eors \aB5, \aB5, \aDux
259
+ rors \aB1, #32-\rot1
260
+ .if \rot2 > 0
261
+ rors \aB2, #32-\rot2
262
+ .endif
263
+ rors \aB3, #32-\rot3
264
+ rors \aB4, #32-\rot4
265
+ rors \aB5, #32-\rot5
266
+ xandnot \aA1, r3, r4, r5
267
+ xandnot \aA2, r4, r5, r6
268
+ xandnot \aA3, r5, r6, r7
269
+ xandnot \aA4, r6, r7, r3
270
+ xandnot \aA5, r7, r3, r4
271
+ .endm
272
+
273
+ .macro KeccakRound0
274
+
275
+ xor5 r3, Abu0, Agu0, Aku0, Amu0, Asu0
276
+ xor5 r7, Abe1, Age1, Ake1, Ame1, Ase1
277
+ xorrol r6, r3, r7
278
+ str r6, [sp, #mDa0]
279
+ xor5 r6, Abu1, Agu1, Aku1, Amu1, Asu1
280
+ xor5 lr, Abe0, Age0, Ake0, Ame0, Ase0
281
+ eors r8, r6, lr
282
+ str r8, [sp, #mDa1]
283
+
284
+ xor5 r5, Abi0, Agi0, Aki0, Ami0, Asi0
285
+ xorrol r9, r5, r6
286
+ str r9, [sp, #mDo0]
287
+ xor5 r4, Abi1, Agi1, Aki1, Ami1, Asi1
288
+ eors r3, r3, r4
289
+ str r3, [sp, #mDo1]
290
+
291
+ xor5 r3, Aba0, Aga0, Aka0, Ama0, Asa0
292
+ xorrol r10, r3, r4
293
+ xor5 r6, Aba1, Aga1, Aka1, Ama1, Asa1
294
+ eors r11, r6, r5
295
+
296
+ xor5 r4, Abo1, Ago1, Ako1, Amo1, Aso1
297
+ xorrol r5, lr, r4
298
+ str r5, [sp, #mDi0]
299
+ xor5 r5, Abo0, Ago0, Ako0, Amo0, Aso0
300
+ eors r2, r7, r5
301
+
302
+ xorrol r12, r5, r6
303
+ eors lr, r4, r3
304
+
305
+ KeccakThetaRhoPiChi r5, Aka1, r8, 2, r6, Ame1, r11, 23, r7, Asi1, r2, 31, r3, Abo0, r9, 14, r4, Agu0, r12, 10
306
+ KeccakThetaRhoPiChi r7, Asa1, r8, 9, r3, Abe0, r10, 0, r4, Agi1, r2, 3, r5, Ako0, r9, 12, r6, Amu1, lr, 4
307
+ ldr r8, [sp, #mDa0]
308
+ KeccakThetaRhoPiChi r4, Aga0, r8, 18, r5, Ake0, r10, 5, r6, Ami1, r2, 8, r7, Aso0, r9, 28, r3, Abu1, lr, 14
309
+ KeccakThetaRhoPiChi r6, Ama0, r8, 20, r7, Ase1, r11, 1, r3, Abi1, r2, 31, r4, Ago0, r9, 27, r5, Aku0, r12, 19
310
+ ldr r9, [sp, #mDo1]
311
+ KeccakThetaRhoPiChiIota Aba0, r8, Age0, r10, 22, Aki1, r2, 22, Amo1, r9, 11, Asu0, r12, 7, 0, 0
312
+
313
+ ldr r2, [sp, #mDi0]
314
+ KeccakThetaRhoPiChi r5, Aka0, r8, 1, r6, Ame0, r10, 22, r7, Asi0, r2, 30, r3, Abo1, r9, 14, r4, Agu1, lr, 10
315
+ KeccakThetaRhoPiChi r7, Asa0, r8, 9, r3, Abe1, r11, 1, r4, Agi0, r2, 3, r5, Ako1, r9, 13, r6, Amu0, r12, 4
316
+ ldr r8, [sp, #mDa1]
317
+ KeccakThetaRhoPiChi r4, Aga1, r8, 18, r5, Ake1, r11, 5, r6, Ami0, r2, 7, r7, Aso1, r9, 28, r3, Abu0, r12, 13
318
+ KeccakThetaRhoPiChi r6, Ama1, r8, 21, r7, Ase0, r10, 1, r3, Abi0, r2, 31, r4, Ago1, r9, 28, r5, Aku1, lr, 20
319
+ ldr r9, [sp, #mDo0]
320
+ KeccakThetaRhoPiChiIota Aba1, r8, Age1, r11, 22, Aki0, r2, 21, Amo0, r9, 10, Asu1, lr, 7, 4, 0
321
+ .endm
322
+
323
+ .macro KeccakRound1
324
+
325
+ xor5 r3, Asu0, Agu0, Amu0, Abu1, Aku1
326
+ xor5 r7, Age1, Ame0, Abe0, Ake1, Ase1
327
+ xorrol r6, r3, r7
328
+ str r6, [sp, #mDa0]
329
+ xor5 r6, Asu1, Agu1, Amu1, Abu0, Aku0
330
+ xor5 lr, Age0, Ame1, Abe1, Ake0, Ase0
331
+ eors r8, r6, lr
332
+ str r8, [sp, #mDa1]
333
+
334
+ xor5 r5, Aki1, Asi1, Agi0, Ami1, Abi0
335
+ xorrol r9, r5, r6
336
+ str r9, [sp, #mDo0]
337
+ xor5 r4, Aki0, Asi0, Agi1, Ami0, Abi1
338
+ eors r3, r3, r4
339
+ str r3, [sp, #mDo1]
340
+
341
+ xor5 r3, Aba0, Aka1, Asa0, Aga0, Ama1
342
+ xorrol r10, r3, r4
343
+ xor5 r6, Aba1, Aka0, Asa1, Aga1, Ama0
344
+ eors r11, r6, r5
345
+
346
+ xor5 r4, Amo0, Abo1, Ako0, Aso1, Ago0
347
+ xorrol r5, lr, r4
348
+ str r5, [sp, #mDi0]
349
+ xor5 r5, Amo1, Abo0, Ako1, Aso0, Ago1
350
+ eors r2, r7, r5
351
+
352
+ xorrol r12, r5, r6
353
+ eors lr, r4, r3
354
+
355
+ KeccakThetaRhoPiChi r5, Asa1, r8, 2, r6, Ake1, r11, 23, r7, Abi1, r2, 31, r3, Amo1, r9, 14, r4, Agu0, r12, 10
356
+ KeccakThetaRhoPiChi r7, Ama0, r8, 9, r3, Age0, r10, 0, r4, Asi0, r2, 3, r5, Ako1, r9, 12, r6, Abu0, lr, 4
357
+ ldr r8, [sp, #mDa0]
358
+ KeccakThetaRhoPiChi r4, Aka1, r8, 18, r5, Abe1, r10, 5, r6, Ami0, r2, 8, r7, Ago1, r9, 28, r3, Asu1, lr, 14
359
+ KeccakThetaRhoPiChi r6, Aga0, r8, 20, r7, Ase1, r11, 1, r3, Aki0, r2, 31, r4, Abo0, r9, 27, r5, Amu0, r12, 19
360
+ ldr r9, [sp, #mDo1]
361
+ KeccakThetaRhoPiChiIota Aba0, r8, Ame1, r10, 22, Agi1, r2, 22, Aso1, r9, 11, Aku1, r12, 7, 8, 0
362
+
363
+ ldr r2, [sp, #mDi0]
364
+ KeccakThetaRhoPiChi r5, Asa0, r8, 1, r6, Ake0, r10, 22, r7, Abi0, r2, 30, r3, Amo0, r9, 14, r4, Agu1, lr, 10
365
+ KeccakThetaRhoPiChi r7, Ama1, r8, 9, r3, Age1, r11, 1, r4, Asi1, r2, 3, r5, Ako0, r9, 13, r6, Abu1, r12, 4
366
+ ldr r8, [sp, #mDa1]
367
+ KeccakThetaRhoPiChi r4, Aka0, r8, 18, r5, Abe0, r11, 5, r6, Ami1, r2, 7, r7, Ago0, r9, 28, r3, Asu0, r12, 13
368
+ KeccakThetaRhoPiChi r6, Aga1, r8, 21, r7, Ase0, r10, 1, r3, Aki1, r2, 31, r4, Abo1, r9, 28, r5, Amu1, lr, 20
369
+ ldr r9, [sp, #mDo0]
370
+ KeccakThetaRhoPiChiIota Aba1, r8, Ame0, r11, 22, Agi0, r2, 21, Aso0, r9, 10, Aku0, lr, 7, 12, 0
371
+ .endm
372
+
373
+ .macro KeccakRound2
374
+
375
+ xor5 r3, Aku1, Agu0, Abu1, Asu1, Amu1
376
+ xor5 r7, Ame0, Ake0, Age0, Abe0, Ase1
377
+ xorrol r6, r3, r7
378
+ str r6, [sp, #mDa0]
379
+ xor5 r6, Aku0, Agu1, Abu0, Asu0, Amu0
380
+ xor5 lr, Ame1, Ake1, Age1, Abe1, Ase0
381
+ eors r8, r6, lr
382
+ str r8, [sp, #mDa1]
383
+
384
+ xor5 r5, Agi1, Abi1, Asi1, Ami0, Aki1
385
+ xorrol r9, r5, r6
386
+ str r9, [sp, #mDo0]
387
+ xor5 r4, Agi0, Abi0, Asi0, Ami1, Aki0
388
+ eors r3, r3, r4
389
+ str r3, [sp, #mDo1]
390
+
391
+ xor5 r3, Aba0, Asa1, Ama1, Aka1, Aga1
392
+ xorrol r10, r3, r4
393
+ xor5 r6, Aba1, Asa0, Ama0, Aka0, Aga0
394
+ eors r11, r6, r5
395
+
396
+ xor5 r4, Aso0, Amo0, Ako1, Ago0, Abo0
397
+ xorrol r5, lr, r4
398
+ str r5, [sp, #mDi0]
399
+ xor5 r5, Aso1, Amo1, Ako0, Ago1, Abo1
400
+ eors r2, r7, r5
401
+
402
+ xorrol r12, r5, r6
403
+ eors lr, r4, r3
404
+
405
+ KeccakThetaRhoPiChi r5, Ama0, r8, 2, r6, Abe0, r11, 23, r7, Aki0, r2, 31, r3, Aso1, r9, 14, r4, Agu0, r12, 10
406
+ KeccakThetaRhoPiChi r7, Aga0, r8, 9, r3, Ame1, r10, 0, r4, Abi0, r2, 3, r5, Ako0, r9, 12, r6, Asu0, lr, 4
407
+ ldr r8, [sp, #mDa0]
408
+ KeccakThetaRhoPiChi r4, Asa1, r8, 18, r5, Age1, r10, 5, r6, Ami1, r2, 8, r7, Abo1, r9, 28, r3, Aku0, lr, 14
409
+ KeccakThetaRhoPiChi r6, Aka1, r8, 20, r7, Ase1, r11, 1, r3, Agi0, r2, 31, r4, Amo1, r9, 27, r5, Abu1, r12, 19
410
+ ldr r9, [sp, #mDo1]
411
+ KeccakThetaRhoPiChiIota Aba0, r8, Ake1, r10, 22, Asi0, r2, 22, Ago0, r9, 11, Amu1, r12, 7, 16, 0
412
+
413
+ ldr r2, [sp, #mDi0]
414
+ KeccakThetaRhoPiChi r5, Ama1, r8, 1, r6, Abe1, r10, 22, r7, Aki1, r2, 30, r3, Aso0, r9, 14, r4, Agu1, lr, 10
415
+ KeccakThetaRhoPiChi r7, Aga1, r8, 9, r3, Ame0, r11, 1, r4, Abi1, r2, 3, r5, Ako1, r9, 13, r6, Asu1, r12, 4
416
+ ldr r8, [sp, #mDa1]
417
+ KeccakThetaRhoPiChi r4, Asa0, r8, 18, r5, Age0, r11, 5, r6, Ami0, r2, 7, r7, Abo0, r9, 28, r3, Aku1, r12, 13
418
+ KeccakThetaRhoPiChi r6, Aka0, r8, 21, r7, Ase0, r10, 1, r3, Agi1, r2, 31, r4, Amo0, r9, 28, r5, Abu0, lr, 20
419
+ ldr r9, [sp, #mDo0]
420
+ KeccakThetaRhoPiChiIota Aba1, r8, Ake0, r11, 22, Asi1, r2, 21, Ago1, r9, 10, Amu0, lr, 7, 20, 0
421
+ .endm
422
+
423
+ .macro KeccakRound3
424
+
425
+ xor5 r3, Amu1, Agu0, Asu1, Aku0, Abu0
426
+ xor5 r7, Ake0, Abe1, Ame1, Age0, Ase1
427
+ xorrol r6, r3, r7
428
+ str r6, [sp, #mDa0]
429
+ xor5 r6, Amu0, Agu1, Asu0, Aku1, Abu1
430
+ xor5 lr, Ake1, Abe0, Ame0, Age1, Ase0
431
+ eors r8, r6, lr
432
+ str r8, [sp, #mDa1]
433
+
434
+ xor5 r5, Asi0, Aki0, Abi1, Ami1, Agi1
435
+ xorrol r9, r5, r6
436
+ str r9, [sp, #mDo0]
437
+ xor5 r4, Asi1, Aki1, Abi0, Ami0, Agi0
438
+ eors r3, r3, r4
439
+ str r3, [sp, #mDo1]
440
+
441
+ xor5 r3, Aba0, Ama0, Aga1, Asa1, Aka0
442
+ xorrol r10, r3, r4
443
+ xor5 r6, Aba1, Ama1, Aga0, Asa0, Aka1
444
+ eors r11, r6, r5
445
+
446
+ xor5 r4, Ago1, Aso0, Ako0, Abo0, Amo1
447
+ xorrol r5, lr, r4
448
+ str r5, [sp, #mDi0]
449
+ xor5 r5, Ago0, Aso1, Ako1, Abo1, Amo0
450
+ eors r2, r7, r5
451
+
452
+ xorrol r12, r5, r6
453
+ eors lr, r4, r3
454
+
455
+ KeccakThetaRhoPiChi r5, Aga0, r8, 2, r6, Age0, r11, 23, r7, Agi0, r2, 31, r3, Ago0, r9, 14, r4, Agu0, r12, 10
456
+ KeccakThetaRhoPiChi r7, Aka1, r8, 9, r3, Ake1, r10, 0, r4, Aki1, r2, 3, r5, Ako1, r9, 12, r6, Aku1, lr, 4
457
+ ldr r8, [sp, #mDa0]
458
+ KeccakThetaRhoPiChi r4, Ama0, r8, 18, r5, Ame0, r10, 5, r6, Ami0, r2, 8, r7, Amo0, r9, 28, r3, Amu0, lr, 14
459
+ KeccakThetaRhoPiChi r6, Asa1, r8, 20, r7, Ase1, r11, 1, r3, Asi1, r2, 31, r4, Aso1, r9, 27, r5, Asu1, r12, 19
460
+ ldr r9, [sp, #mDo1]
461
+ KeccakThetaRhoPiChiIota Aba0, r8, Abe0, r10, 22, Abi0, r2, 22, Abo0, r9, 11, Abu0, r12, 7, 24, 0
462
+
463
+ ldr r2, [sp, #mDi0]
464
+ KeccakThetaRhoPiChi r5, Aga1, r8, 1, r6, Age1, r10, 22, r7, Agi1, r2, 30, r3, Ago1, r9, 14, r4, Agu1, lr, 10
465
+ KeccakThetaRhoPiChi r7, Aka0, r8, 9, r3, Ake0, r11, 1, r4, Aki0, r2, 3, r5, Ako0, r9, 13, r6, Aku0, r12, 4
466
+ ldr r8, [sp, #mDa1]
467
+ KeccakThetaRhoPiChi r4, Ama1, r8, 18, r5, Ame1, r11, 5, r6, Ami1, r2, 7, r7, Amo1, r9, 28, r3, Amu1, r12, 13
468
+ KeccakThetaRhoPiChi r6, Asa0, r8, 21, r7, Ase0, r10, 1, r3, Asi0, r2, 31, r4, Aso0, r9, 28, r5, Asu0, lr, 20
469
+ ldr r9, [sp, #mDo0]
470
+ KeccakThetaRhoPiChiIota Aba1, r8, Abe1, r11, 22, Abi1, r2, 21, Abo1, r9, 10, Abu1, lr, 7, 28, 1
471
+ .endm
472
+
473
+
474
+ @----------------------------------------------------------------------------
475
+ @
476
+ @ void KeccakP1600_StaticInitialize( void )
477
+ @
478
+ .align 8
479
+ .global KeccakP1600_StaticInitialize
480
+ .type KeccakP1600_StaticInitialize, %function;
481
+ KeccakP1600_StaticInitialize:
482
+ bx lr
483
+
484
+
485
+ @----------------------------------------------------------------------------
486
+ @
487
+ @ void KeccakP1600_Initialize(void *state)
488
+ @
489
+ .align 8
490
+ .global KeccakP1600_Initialize
491
+ .type KeccakP1600_Initialize, %function;
492
+ KeccakP1600_Initialize:
493
+ push {r4 - r5}
494
+ movs r1, #0
495
+ movs r2, #0
496
+ movs r3, #0
497
+ movs r4, #0
498
+ movs r5, #0
499
+ stmia r0!, { r1 - r5 }
500
+ stmia r0!, { r1 - r5 }
501
+ stmia r0!, { r1 - r5 }
502
+ stmia r0!, { r1 - r5 }
503
+ stmia r0!, { r1 - r5 }
504
+ stmia r0!, { r1 - r5 }
505
+ stmia r0!, { r1 - r5 }
506
+ stmia r0!, { r1 - r5 }
507
+ stmia r0!, { r1 - r5 }
508
+ stmia r0!, { r1 - r5 }
509
+ pop {r4 - r5}
510
+ bx lr
511
+
512
+
513
+ @ ----------------------------------------------------------------------------
514
+ @
515
+ @ void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset)
516
+ @
517
+ .align 8
518
+ .global KeccakP1600_AddByte
519
+ .type KeccakP1600_AddByte, %function;
520
+ KeccakP1600_AddByte:
521
+ push {r4 - r7}
522
+ bic r3, r2, #7 @ r3 = offset & ~7
523
+ adds r0, r0, r3 @ state += r3
524
+ ands r2, r2, #7 @ offset &= 7 (part not lane aligned)
525
+
526
+ movs r4, #0
527
+ movs r5, #0
528
+ push { r4 - r5 }
529
+ add r2, r2, sp
530
+ strb r1, [r2]
531
+ pop { r4 - r5 }
532
+ ldrd r6, r7, [r0]
533
+ toBitInterleaving r4, r5, r6, r7, r3, 0
534
+ strd r6, r7, [r0]
535
+ pop {r4 - r7}
536
+ bx lr
537
+
538
+
539
+ @----------------------------------------------------------------------------
540
+ @
541
+ @ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
542
+ @
543
+ .align 8
544
+ .global KeccakP1600_AddBytes
545
+ .type KeccakP1600_AddBytes, %function;
546
+ KeccakP1600_AddBytes:
547
+ cbz r3, KeccakP1600_AddBytes_Exit1
548
+ push {r4 - r8, lr} @ then
549
+ bic r4, r2, #7 @ offset &= ~7
550
+ adds r0, r0, r4 @ add whole lane offset to state pointer
551
+ ands r2, r2, #7 @ offset &= 7 (part not lane aligned)
552
+ beq KeccakP1600_AddBytes_CheckLanes @ .if offset != 0
553
+ movs r4, r3 @ then, do remaining bytes in first lane
554
+ rsb r5, r2, #8 @ max size in lane = 8 - offset
555
+ cmp r4, r5
556
+ ble KeccakP1600_AddBytes_BytesAlign
557
+ movs r4, r5
558
+ KeccakP1600_AddBytes_BytesAlign:
559
+ sub r8, r3, r4 @ size left
560
+ movs r3, r4
561
+ bl __KeccakP1600_AddBytesInLane
562
+ mov r3, r8
563
+ KeccakP1600_AddBytes_CheckLanes:
564
+ lsrs r2, r3, #3 @ .if length >= 8
565
+ beq KeccakP1600_AddBytes_Bytes
566
+ mov r8, r3
567
+ bl __KeccakP1600_AddLanes
568
+ and r3, r8, #7
569
+ KeccakP1600_AddBytes_Bytes:
570
+ cbz r3, KeccakP1600_AddBytes_Exit
571
+ movs r2, #0
572
+ bl __KeccakP1600_AddBytesInLane
573
+ KeccakP1600_AddBytes_Exit:
574
+ pop {r4 - r8, pc}
575
+ KeccakP1600_AddBytes_Exit1:
576
+ bx lr
577
+
578
+
579
+ @----------------------------------------------------------------------------
580
+ @
581
+ @ __KeccakP1600_AddLanes
582
+ @
583
+ @ Input:
584
+ @ r0 state pointer
585
+ @ r1 data pointer
586
+ @ r2 laneCount
587
+ @
588
+ @ Output:
589
+ @ r0 state pointer next lane
590
+ @ r1 data pointer next byte to input
591
+ @
592
+ @ Changed: r2-r7
593
+ @
594
+ .align 8
595
+ __KeccakP1600_AddLanes:
596
+ __KeccakP1600_AddLanes_LoopAligned:
597
+ ldr r4, [r1], #4
598
+ ldr r5, [r1], #4
599
+ ldrd r6, r7, [r0]
600
+ toBitInterleaving r4, r5, r6, r7, r3, 0
601
+ strd r6, r7, [r0], #8
602
+ subs r2, r2, #1
603
+ bne __KeccakP1600_AddLanes_LoopAligned
604
+ bx lr
605
+
606
+
607
+ @----------------------------------------------------------------------------
608
+ @
609
+ @ __KeccakP1600_AddBytesInLane
610
+ @
611
+ @ Input:
612
+ @ r0 state pointer
613
+ @ r1 data pointer
614
+ @ r2 offset in lane
615
+ @ r3 length
616
+ @
617
+ @ Output:
618
+ @ r0 state pointer next lane
619
+ @ r1 data pointer next byte to input
620
+ @
621
+ @ Changed: r2-r7
622
+ @
623
+ .align 8
624
+ __KeccakP1600_AddBytesInLane:
625
+ movs r4, #0
626
+ movs r5, #0
627
+ push { r4 - r5 }
628
+ add r2, r2, sp
629
+ __KeccakP1600_AddBytesInLane_Loop:
630
+ ldrb r5, [r1], #1
631
+ strb r5, [r2], #1
632
+ subs r3, r3, #1
633
+ bne __KeccakP1600_AddBytesInLane_Loop
634
+ pop { r4 - r5 }
635
+ ldrd r6, r7, [r0]
636
+ toBitInterleaving r4, r5, r6, r7, r3, 0
637
+ strd r6, r7, [r0], #8
638
+ bx lr
639
+
640
+
641
+ @----------------------------------------------------------------------------
642
+ @
643
+ @ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
644
+ @
645
+ .align 8
646
+ .global KeccakP1600_OverwriteBytes
647
+ .type KeccakP1600_OverwriteBytes, %function;
648
+ KeccakP1600_OverwriteBytes:
649
+ cbz r3, KeccakP1600_OverwriteBytes_Exit1 @ .if length != 0
650
+ push {r4 - r8, lr} @ then
651
+ bic r4, r2, #7 @ offset &= ~7
652
+ adds r0, r0, r4 @ add whole lane offset to state pointer
653
+ ands r2, r2, #7 @ offset &= 7 (part not lane aligned)
654
+ beq KeccakP1600_OverwriteBytes_CheckLanes @ .if offset != 0
655
+ movs r4, r3 @ then, do remaining bytes in first lane
656
+ rsb r5, r2, #8 @ max size in lane = 8 - offset
657
+ cmp r4, r5
658
+ ble KeccakP1600_OverwriteBytes_BytesAlign
659
+ movs r4, r5
660
+ KeccakP1600_OverwriteBytes_BytesAlign:
661
+ sub r8, r3, r4 @ size left
662
+ movs r3, r4
663
+ bl __KeccakP1600_OverwriteBytesInLane
664
+ mov r3, r8
665
+ KeccakP1600_OverwriteBytes_CheckLanes:
666
+ lsrs r2, r3, #3 @ .if length >= 8
667
+ beq KeccakP1600_OverwriteBytes_Bytes
668
+ mov r8, r3
669
+ bl __KeccakP1600_OverwriteLanes
670
+ and r3, r8, #7
671
+ KeccakP1600_OverwriteBytes_Bytes:
672
+ cbz r3, KeccakP1600_OverwriteBytes_Exit
673
+ movs r2, #0
674
+ bl __KeccakP1600_OverwriteBytesInLane
675
+ KeccakP1600_OverwriteBytes_Exit:
676
+ pop {r4 - r8, pc}
677
+ KeccakP1600_OverwriteBytes_Exit1:
678
+ bx lr
679
+
680
+
681
+ @----------------------------------------------------------------------------
682
+ @
683
+ @ __KeccakP1600_OverwriteLanes
684
+ @
685
+ @ Input:
686
+ @ r0 state pointer
687
+ @ r1 data pointer
688
+ @ r2 laneCount
689
+ @
690
+ @ Output:
691
+ @ r0 state pointer next lane
692
+ @ r1 data pointer next byte to input
693
+ @
694
+ @ Changed: r2-r7
695
+ @
696
+ .align 8
697
+ __KeccakP1600_OverwriteLanes:
698
+ __KeccakP1600_OverwriteLanes_LoopAligned:
699
+ ldr r4, [r1], #4
700
+ ldr r5, [r1], #4
701
+ ldrd r6, r7, [r0]
702
+ toBitInterleaving r4, r5, r6, r7, r3, 1
703
+ strd r6, r7, [r0], #8
704
+ subs r2, r2, #1
705
+ bne __KeccakP1600_OverwriteLanes_LoopAligned
706
+ bx lr
707
+
708
+
709
+ @----------------------------------------------------------------------------
710
+ @
711
+ @ __KeccakP1600_OverwriteBytesInLane
712
+ @
713
+ @ Input:
714
+ @ r0 state pointer
715
+ @ r1 data pointer
716
+ @ r2 offset in lane
717
+ @ r3 length
718
+ @
719
+ @ Output:
720
+ @ r0 state pointer next lane
721
+ @ r1 data pointer next byte to input
722
+ @
723
+ @ Changed: r2-r7
724
+ @
725
+ .align 8
726
+ __KeccakP1600_OverwriteBytesInLane:
727
+ movs r4, #0
728
+ movs r5, #0
729
+ push { r4 - r5 }
730
+ lsl r7, r2, #2
731
+ add r2, r2, sp
732
+ movs r6, #0x0F @r6 mask to wipe nibbles(bit interleaved bytes) in state
733
+ lsls r6, r6, r7
734
+ movs r7, r6
735
+ KeccakP1600_OverwriteBytesInLane_Loop:
736
+ orrs r6, r6, r7
737
+ lsls r7, r7, #4
738
+ ldrb r5, [r1], #1
739
+ subs r3, r3, #1
740
+ strb r5, [r2], #1
741
+ bne KeccakP1600_OverwriteBytesInLane_Loop
742
+ pop { r4 - r5 }
743
+ toBitInterleaving r4, r5, r2, r3, r7, 1
744
+ ldrd r4, r5, [r0]
745
+ bics r4, r4, r6
746
+ bics r5, r5, r6
747
+ orrs r2, r2, r4
748
+ orrs r3, r3, r5
749
+ strd r2, r3, [r0], #8
750
+ bx lr
751
+
752
+
753
+ @----------------------------------------------------------------------------
754
+ @
755
+ @ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
756
+ @
757
+ .align 8
758
+ .global KeccakP1600_OverwriteWithZeroes
759
+ .type KeccakP1600_OverwriteWithZeroes, %function;
760
+ KeccakP1600_OverwriteWithZeroes:
761
+ push {r4 - r5}
762
+ lsrs r2, r1, #3
763
+ beq KeccakP1600_OverwriteWithZeroes_Bytes
764
+ movs r4, #0
765
+ movs r5, #0
766
+ KeccakP1600_OverwriteWithZeroes_LoopLanes:
767
+ strd r4, r5, [r0], #8
768
+ subs r2, r2, #1
769
+ bne KeccakP1600_OverwriteWithZeroes_LoopLanes
770
+ KeccakP1600_OverwriteWithZeroes_Bytes:
771
+ ands r1, #7
772
+ beq KeccakP1600_OverwriteWithZeroes_Exit
773
+ movs r3, #0x0F @r2 already zero, r3 = mask to wipe nibbles(bit interleaved bytes) in state
774
+ KeccakP1600_OverwriteWithZeroes_LoopBytes:
775
+ orrs r2, r2, r3
776
+ lsls r3, r3, #4
777
+ subs r1, r1, #1
778
+ bne KeccakP1600_OverwriteWithZeroes_LoopBytes
779
+ ldrd r4, r5, [r0]
780
+ bics r4, r4, r2
781
+ bics r5, r5, r2
782
+ strd r4, r5, [r0], #8
783
+ KeccakP1600_OverwriteWithZeroes_Exit:
784
+ pop {r4 - r5}
785
+ bx lr
786
+
787
+
788
+ @----------------------------------------------------------------------------
789
+ @
790
+ @ void KeccakP1600_ExtractBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
791
+ @
792
+ .align 8
793
+ .global KeccakP1600_ExtractBytes
794
+ .type KeccakP1600_ExtractBytes, %function;
795
+ KeccakP1600_ExtractBytes:
796
+ cbz r3, KeccakP1600_ExtractBytes_Exit1 @ .if length != 0
797
+ push {r4 - r8, lr} @ then
798
+ bic r4, r2, #7 @ offset &= ~7
799
+ adds r0, r0, r4 @ add whole lane offset to state pointer
800
+ ands r2, r2, #7 @ offset &= 7 (part not lane aligned)
801
+ beq KeccakP1600_ExtractBytes_CheckLanes @ .if offset != 0
802
+ movs r4, r3 @ then, do remaining bytes in first lane
803
+ rsb r5, r2, #8 @ max size in lane = 8 - offset
804
+ cmp r4, r5
805
+ ble KeccakP1600_ExtractBytes_BytesAlign
806
+ movs r4, r5
807
+ KeccakP1600_ExtractBytes_BytesAlign:
808
+ sub r8, r3, r4 @ size left
809
+ movs r3, r4
810
+ bl __KeccakP1600_ExtractBytesInLane
811
+ mov r3, r8
812
+ KeccakP1600_ExtractBytes_CheckLanes:
813
+ lsrs r2, r3, #3 @ .if length >= 8
814
+ beq KeccakP1600_ExtractBytes_Bytes
815
+ mov r8, r3
816
+ bl __KeccakP1600_ExtractLanes
817
+ and r3, r8, #7
818
+ KeccakP1600_ExtractBytes_Bytes:
819
+ cbz r3, KeccakP1600_ExtractBytes_Exit
820
+ movs r2, #0
821
+ bl __KeccakP1600_ExtractBytesInLane
822
+ KeccakP1600_ExtractBytes_Exit:
823
+ pop {r4 - r8, pc}
824
+ KeccakP1600_ExtractBytes_Exit1:
825
+ bx lr
826
+
827
+
828
+ @----------------------------------------------------------------------------
829
+ @
830
+ @ __KeccakP1600_ExtractLanes
831
+ @
832
+ @ Input:
833
+ @ r0 state pointer
834
+ @ r1 data pointer
835
+ @ r2 laneCount
836
+ @
837
+ @ Output:
838
+ @ r0 state pointer next lane
839
+ @ r1 data pointer next byte to input
840
+ @
841
+ @ Changed: r2-r5
842
+ @
843
+ .align 8
844
+ __KeccakP1600_ExtractLanes:
845
+ __KeccakP1600_ExtractLanes_LoopAligned:
846
+ ldrd r4, r5, [r0], #8
847
+ fromBitInterleaving r4, r5, r3
848
+ str r4, [r1], #4
849
+ subs r2, r2, #1
850
+ str r5, [r1], #4
851
+ bne __KeccakP1600_ExtractLanes_LoopAligned
852
+ bx lr
853
+
854
+
855
+ @----------------------------------------------------------------------------
856
+ @
857
+ @ __KeccakP1600_ExtractBytesInLane
858
+ @
859
+ @ Input:
860
+ @ r0 state pointer
861
+ @ r1 data pointer
862
+ @ r2 offset in lane
863
+ @ r3 length
864
+ @
865
+ @ Output:
866
+ @ r0 state pointer next lane
867
+ @ r1 data pointer next byte to input
868
+ @
869
+ @ Changed: r2-r6
870
+ @
871
+ .align 8
872
+ __KeccakP1600_ExtractBytesInLane:
873
+ ldrd r4, r5, [r0], #8
874
+ fromBitInterleaving r4, r5, r6
875
+ push {r4, r5}
876
+ add r2, sp, r2
877
+ __KeccakP1600_ExtractBytesInLane_Loop:
878
+ ldrb r4, [r2], #1
879
+ subs r3, r3, #1
880
+ strb r4, [r1], #1
881
+ bne __KeccakP1600_ExtractBytesInLane_Loop
882
+ add sp, #8
883
+ bx lr
884
+
885
+
886
+ @----------------------------------------------------------------------------
887
+ @
888
+ @ void KeccakP1600_ExtractAndAddBytes(void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
889
+ @
890
+ .align 8
891
+ .global KeccakP1600_ExtractAndAddBytes
892
+ .type KeccakP1600_ExtractAndAddBytes, %function;
893
+ KeccakP1600_ExtractAndAddBytes:
894
+ push {r4 - r10, lr}
895
+ mov r9, r2
896
+ mov r2, r3
897
+ ldr r3, [sp, #8*4]
898
+ cbz r3, KeccakP1600_ExtractAndAddBytes_Exit @ .if length != 0
899
+ bic r4, r2, #7 @ then, offset &= ~7
900
+ adds r0, r0, r4 @ add whole lane offset to state pointer
901
+ ands r2, r2, #7 @ offset &= 7 (part not lane aligned)
902
+ beq KeccakP1600_ExtractAndAddBytes_CheckLanes @ .if offset != 0
903
+ movs r4, r3 @ then, do remaining bytes in first lane
904
+ rsb r5, r2, #8 @ max size in lane = 8 - offset
905
+ cmp r4, r5
906
+ ble KeccakP1600_ExtractAndAddBytes_BytesAlign
907
+ movs r4, r5
908
+ KeccakP1600_ExtractAndAddBytes_BytesAlign:
909
+ sub r8, r3, r4 @ size left
910
+ movs r3, r4
911
+ bl __KeccakP1600_ExtractAndAddBytesInLane
912
+ mov r3, r8
913
+ KeccakP1600_ExtractAndAddBytes_CheckLanes:
914
+ lsrs r2, r3, #3 @ .if length >= 8
915
+ beq KeccakP1600_ExtractAndAddBytes_Bytes
916
+ mov r8, r3
917
+ bl __KeccakP1600_ExtractAndAddLanes
918
+ and r3, r8, #7
919
+ KeccakP1600_ExtractAndAddBytes_Bytes:
920
+ cbz r3, KeccakP1600_ExtractAndAddBytes_Exit
921
+ movs r2, #0
922
+ bl __KeccakP1600_ExtractAndAddBytesInLane
923
+ KeccakP1600_ExtractAndAddBytes_Exit:
924
+ pop {r4 - r10, pc}
925
+
926
+
927
+ @----------------------------------------------------------------------------
928
+ @
929
+ @ __KeccakP1600_ExtractAndAddLanes
930
+ @
931
+ @ Input:
932
+ @ r0 state pointer
933
+ @ r1 input pointer
934
+ @ r9 output pointer
935
+ @ r2 laneCount
936
+ @
937
+ @ Output:
938
+ @ r0 state pointer next lane
939
+ @ r1 input pointer next 32-bit word
940
+ @ r9 output pointer next 32-bit word
941
+ @
942
+ @ Changed: r2-r5
943
+ @
944
+ .align 8
945
+ __KeccakP1600_ExtractAndAddLanes:
946
+ __KeccakP1600_ExtractAndAddLanes_LoopAligned:
947
+ ldrd r4, r5, [r0], #8
948
+ fromBitInterleaving r4, r5, r3
949
+ ldr r3, [r1], #4
950
+ eors r4, r4, r3
951
+ str r4, [r9], #4
952
+ ldr r3, [r1], #4
953
+ eors r5, r5, r3
954
+ subs r2, r2, #1
955
+ str r5, [r9], #4
956
+ bne __KeccakP1600_ExtractAndAddLanes_LoopAligned
957
+ bx lr
958
+
959
+
960
+ @----------------------------------------------------------------------------
961
+ @
962
+ @ __KeccakP1600_ExtractAndAddBytesInLane
963
+ @
964
+ @ Input:
965
+ @ r0 state pointer
966
+ @ r1 input pointer
967
+ @ r9 output pointer
968
+ @ r2 offset in lane
969
+ @ r3 length
970
+ @
971
+ @ Output:
972
+ @ r0 state pointer next lane
973
+ @ r1 input pointer next byte
974
+ @ r9 output pointer next byte
975
+ @
976
+ @ Changed: r2-r6
977
+ @
978
+ .align 8
979
+ __KeccakP1600_ExtractAndAddBytesInLane:
980
+ ldrd r4, r5, [r0], #8
981
+ fromBitInterleaving r4, r5, r6
982
+ push {r4, r5}
983
+ add r2, sp, r2
984
+ __KeccakP1600_ExtractAndAddBytesInLane_Loop:
985
+ ldrb r4, [r2], #1
986
+ ldrb r5, [r1], #1
987
+ eors r4, r4, r5
988
+ subs r3, r3, #1
989
+ strb r4, [r9], #1
990
+ bne __KeccakP1600_ExtractAndAddBytesInLane_Loop
991
+ add sp, #8
992
+ bx lr
993
+
994
+
995
+ .macro SwapPI13 in0,in1,in2,in3,eo0,eo1,eo2,eo3
996
+ ldr r3, [r0, #\in0+0]
997
+ ldr r4, [r0, #\in0+4]
998
+ ldr r2, [r0, #\in1+0]
999
+ ldr r1, [r0, #\in1+4]
1000
+ str r2, [r0, #\in0+\eo0*4]
1001
+ str r1, [r0, #\in0+(\eo0^1)*4]
1002
+ ldr r2, [r0, #\in2+0]
1003
+ ldr r1, [r0, #\in2+4]
1004
+ str r2, [r0, #\in1+\eo1*4]
1005
+ str r1, [r0, #\in1+(\eo1^1)*4]
1006
+ ldr r2, [r0, #\in3+0]
1007
+ ldr r1, [r0, #\in3+4]
1008
+ str r2, [r0, #\in2+\eo2*4]
1009
+ str r1, [r0, #\in2+(\eo2^1)*4]
1010
+ str r3, [r0, #\in3+\eo3*4]
1011
+ str r4, [r0, #\in3+(\eo3^1)*4]
1012
+ .endm
1013
+
1014
+ .macro SwapPI2 in0,in1,in2,in3
1015
+ ldr r3, [r0, #\in0+0]
1016
+ ldr r4, [r0, #\in0+4]
1017
+ ldr r2, [r0, #\in1+0]
1018
+ ldr r1, [r0, #\in1+4]
1019
+ str r2, [r0, #\in0+4]
1020
+ str r1, [r0, #\in0+0]
1021
+ str r3, [r0, #\in1+4]
1022
+ str r4, [r0, #\in1+0]
1023
+ ldr r3, [r0, #\in2+0]
1024
+ ldr r4, [r0, #\in2+4]
1025
+ ldr r2, [r0, #\in3+0]
1026
+ ldr r1, [r0, #\in3+4]
1027
+ str r2, [r0, #\in2+4]
1028
+ str r1, [r0, #\in2+0]
1029
+ str r3, [r0, #\in3+4]
1030
+ str r4, [r0, #\in3+0]
1031
+ .endm
1032
+
1033
+ .macro SwapEO even,odd
1034
+ ldr r3, [r0, #\even]
1035
+ ldr r4, [r0, #\odd]
1036
+ str r3, [r0, #\odd]
1037
+ str r4, [r0, #\even]
1038
+ .endm
1039
+
1040
+ @ ----------------------------------------------------------------------------
1041
+ @
1042
+ @ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds)
1043
+ @
1044
+ .align 8
1045
+ .global KeccakP1600_Permute_Nrounds
1046
+ .type KeccakP1600_Permute_Nrounds, %function;
1047
+ KeccakP1600_Permute_Nrounds:
1048
+ lsls r3, r1, #30
1049
+ bne KeccakP1600_Permute_NroundsNotMultiple4
1050
+ lsls r2, r1, #3
1051
+ adr r1, KeccakP1600_Permute_RoundConstants0Mod4
1052
+ subs r1, r1, r2
1053
+ b KeccakP1600_Permute
1054
+ KeccakP1600_Permute_NroundsNotMultiple4: @ nrounds not multiple of 4
1055
+ push { r4 - r12, lr }
1056
+ sub sp, #mSize
1057
+ lsrs r2, r1, #2
1058
+ lsls r2, r2, #3+2
1059
+ adr r1, KeccakP1600_Permute_RoundConstants0
1060
+ subs r1, r1, r2
1061
+ str r1, [sp, #mRC]
1062
+ lsls r3, r3, #1
1063
+ bcs KeccakP1600_Permute_Nrounds23Mod4
1064
+ KeccakP1600_Permute_Nrounds1Mod4:
1065
+ SwapPI13 Aga0, Aka0, Asa0, Ama0, 1, 0, 1, 0
1066
+ SwapPI13 Abe0, Age0, Ame0, Ake0, 0, 1, 0, 1
1067
+ SwapPI13 Abi0, Aki0, Agi0, Asi0, 1, 0, 1, 0
1068
+ SwapEO Ami0, Ami1
1069
+ SwapPI13 Abo0, Amo0, Aso0, Ago0, 1, 0, 1, 0
1070
+ SwapEO Ako0, Ako1
1071
+ SwapPI13 Abu0, Asu0, Aku0, Amu0, 0, 1, 0, 1
1072
+ b.w KeccakP1600_Permute_Round1Mod4
1073
+ KeccakP1600_Permute_Nrounds23Mod4:
1074
+ bpl KeccakP1600_Permute_Nrounds2Mod4
1075
+ KeccakP1600_Permute_Nrounds3Mod4:
1076
+ SwapPI13 Aga0, Ama0, Asa0, Aka0, 0, 1, 0, 1
1077
+ SwapPI13 Abe0, Ake0, Ame0, Age0, 1, 0, 1, 0
1078
+ SwapPI13 Abi0, Asi0, Agi0, Aki0, 0, 1, 0, 1
1079
+ SwapEO Ami0, Ami1
1080
+ SwapPI13 Abo0, Ago0, Aso0, Amo0, 0, 1, 0, 1
1081
+ SwapEO Ako0, Ako1
1082
+ SwapPI13 Abu0, Amu0, Aku0, Asu0, 1, 0, 1, 0
1083
+ b.w KeccakP1600_Permute_Round3Mod4
1084
+ KeccakP1600_Permute_Nrounds2Mod4:
1085
+ SwapPI2 Aga0, Asa0, Aka0, Ama0
1086
+ SwapPI2 Abe0, Ame0, Age0, Ake0
1087
+ SwapPI2 Abi0, Agi0, Aki0, Asi0
1088
+ SwapPI2 Abo0, Aso0, Ago0, Amo0
1089
+ SwapPI2 Abu0, Aku0, Amu0, Asu0
1090
+ b.w KeccakP1600_Permute_Round2Mod4
1091
+
1092
+
1093
+ @ ----------------------------------------------------------------------------
1094
+ @
1095
+ @ void KeccakP1600_Permute_12rounds( void *state )
1096
+ @
1097
+ .align 8
1098
+ .global KeccakP1600_Permute_12rounds
1099
+ .type KeccakP1600_Permute_12rounds, %function;
1100
+ KeccakP1600_Permute_12rounds:
1101
+ adr r1, KeccakP1600_Permute_RoundConstants12
1102
+ b KeccakP1600_Permute
1103
+
1104
+
1105
+ @ ----------------------------------------------------------------------------
1106
+ @
1107
+ @ void KeccakP1600_Permute_24rounds( void *state )
1108
+ @
1109
+ .align 8
1110
+ .global KeccakP1600_Permute_24rounds
1111
+ .type KeccakP1600_Permute_24rounds, %function;
1112
+ KeccakP1600_Permute_24rounds:
1113
+ adr r1, KeccakP1600_Permute_RoundConstants24
1114
+ b KeccakP1600_Permute
1115
+
1116
+
1117
+ .align 8
1118
+ KeccakP1600_Permute_RoundConstants24:
1119
+ @ 0 1
1120
+ .long 0x00000001, 0x00000000
1121
+ .long 0x00000000, 0x00000089
1122
+ .long 0x00000000, 0x8000008b
1123
+ .long 0x00000000, 0x80008080
1124
+ .long 0x00000001, 0x0000008b
1125
+ .long 0x00000001, 0x00008000
1126
+ .long 0x00000001, 0x80008088
1127
+ .long 0x00000001, 0x80000082
1128
+ .long 0x00000000, 0x0000000b
1129
+ .long 0x00000000, 0x0000000a
1130
+ .long 0x00000001, 0x00008082
1131
+ .long 0x00000000, 0x00008003
1132
+ KeccakP1600_Permute_RoundConstants12:
1133
+ .long 0x00000001, 0x0000808b
1134
+ .long 0x00000001, 0x8000000b
1135
+ .long 0x00000001, 0x8000008a
1136
+ .long 0x00000001, 0x80000081
1137
+ .long 0x00000000, 0x80000081
1138
+ .long 0x00000000, 0x80000008
1139
+ .long 0x00000000, 0x00000083
1140
+ .long 0x00000000, 0x80008003
1141
+ KeccakP1600_Permute_RoundConstants0:
1142
+ .long 0x00000001, 0x80008088
1143
+ .long 0x00000000, 0x80000088
1144
+ .long 0x00000001, 0x00008000
1145
+ .long 0x00000000, 0x80008082
1146
+ KeccakP1600_Permute_RoundConstants0Mod4:
1147
+ .long 0x000000FF @terminator
1148
+
1149
+ @----------------------------------------------------------------------------
1150
+ @
1151
+ @ void KeccakP1600_Permute( void *state, void * rc )
1152
+ @
1153
+ .align 8
1154
+ KeccakP1600_Permute:
1155
+ push { r4 - r12, lr }
1156
+ sub sp, #mSize
1157
+ str r1, [sp, #mRC]
1158
+ KeccakP1600_Permute_RoundLoop:
1159
+ KeccakRound0
1160
+ KeccakP1600_Permute_Round3Mod4:
1161
+ KeccakRound1
1162
+ KeccakP1600_Permute_Round2Mod4:
1163
+ KeccakRound2
1164
+ KeccakP1600_Permute_Round1Mod4:
1165
+ KeccakRound3
1166
+ bne KeccakP1600_Permute_RoundLoop
1167
+ add sp, #mSize
1168
+ pop { r4 - r12, pc }
1169
+
1170
+