sha3-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +7 -0
  6. data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact.vcproj +207 -0
  7. data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact8.vcproj +207 -0
  8. data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace.vcproj +203 -0
  9. data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace32BI.vcproj +201 -0
  10. data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized32.vcproj +267 -0
  11. data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized64.vcproj +267 -0
  12. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference.vcproj +243 -0
  13. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference32BI.vcproj +243 -0
  14. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReferenceAndOptimized.sln +62 -0
  15. data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple.vcproj +203 -0
  16. data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple32BI.vcproj +201 -0
  17. data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.h +27 -0
  18. data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.s +285 -0
  19. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-settings.h +2 -0
  20. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-test.c +142 -0
  21. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.h +15 -0
  22. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.s +119 -0
  23. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.c +184 -0
  24. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.h +25 -0
  25. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-settings.h +3 -0
  26. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-test.c +317 -0
  27. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.c +341 -0
  28. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.h +50 -0
  29. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-settings.h +2 -0
  30. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-test.c +192 -0
  31. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.c +375 -0
  32. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.h +47 -0
  33. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +406 -0
  34. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-minimal-test.c +231 -0
  35. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-settings.h +3 -0
  36. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-test.c +221 -0
  37. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace.c +445 -0
  38. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv6M.s +844 -0
  39. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7A.s +687 -0
  40. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7M.s +687 -0
  41. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI.c +849 -0
  42. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-settings.h +3 -0
  43. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-test.c +221 -0
  44. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple.c +403 -0
  45. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple32BI.c +673 -0
  46. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.c +68 -0
  47. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.h +59 -0
  48. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-rvk.macros +555 -0
  49. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s1.macros +1187 -0
  50. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s2.macros +1187 -0
  51. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32.macros +26 -0
  52. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-64.macros +728 -0
  53. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-arm.c +123 -0
  54. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armcc.s +653 -0
  55. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armgcc.s +686 -0
  56. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8.c +163 -0
  57. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-compact.s +647 -0
  58. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-fast.s +934 -0
  59. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-inplace-armgcc-ARMv7A-NEON.s +446 -0
  60. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-int-set.h +6 -0
  61. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-interface.h +46 -0
  62. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32-settings.h +4 -0
  63. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32.c +524 -0
  64. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64-settings.h +7 -0
  65. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64.c +504 -0
  66. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.c +300 -0
  67. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.h +20 -0
  68. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.o +0 -0
  69. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference32BI.c +371 -0
  70. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd128.macros +651 -0
  71. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd64.macros +517 -0
  72. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-unrolling.macros +124 -0
  73. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-asm.c +62 -0
  74. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-gas.s +766 -0
  75. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-shld-gas.s +766 -0
  76. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-xop.macros +573 -0
  77. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.c +81 -0
  78. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.h +70 -0
  79. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.o +0 -0
  80. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.c +266 -0
  81. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.h +76 -0
  82. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.o +0 -0
  83. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc1024-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +296 -0
  84. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc512-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +429 -0
  85. data/ext/sha3/KeccakReferenceAndOptimized/Sources/brg_endian.h +142 -0
  86. data/ext/sha3/KeccakReferenceAndOptimized/Sources/crypto_hash.h +0 -0
  87. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.c +117 -0
  88. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.h +29 -0
  89. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.o +0 -0
  90. data/ext/sha3/KeccakReferenceAndOptimized/Sources/genKAT.c +692 -0
  91. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainARM.c +88 -0
  92. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainOptimized.c +23 -0
  93. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainReference.c +381 -0
  94. data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.c +436 -0
  95. data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.h +13 -0
  96. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation-config.h +2 -0
  97. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.c +572 -0
  98. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.h +38 -0
  99. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/KeccakF-1600-unrolling.macros +124 -0
  100. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.c +81 -0
  101. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.h +18 -0
  102. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.c +81 -0
  103. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.h +18 -0
  104. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/crypto_hash.h +0 -0
  105. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/mainOptimized.c +112 -0
  106. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.c +225 -0
  107. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.h +20 -0
  108. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/makefile +68 -0
  109. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakCompact +0 -0
  110. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized32 +0 -0
  111. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized64 +0 -0
  112. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference +0 -0
  113. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference32BI +0 -0
  114. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple +0 -0
  115. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple32BI +0 -0
  116. data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact-test.o +0 -0
  117. data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact.o +0 -0
  118. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakDuplex.o +0 -0
  119. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakF-1600-opt32.o +0 -0
  120. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakNISTInterface.o +0 -0
  121. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakSponge.o +0 -0
  122. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/genKAT.o +0 -0
  123. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/mainOptimized.o +0 -0
  124. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/timing.o +0 -0
  125. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakDuplex.o +0 -0
  126. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakF-1600-opt64.o +0 -0
  127. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakNISTInterface.o +0 -0
  128. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakSponge.o +0 -0
  129. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/genKAT.o +0 -0
  130. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/mainOptimized.o +0 -0
  131. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/timing.o +0 -0
  132. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakDuplex.o +0 -0
  133. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakF-1600-reference.o +0 -0
  134. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakNISTInterface.o +0 -0
  135. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakSponge.o +0 -0
  136. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/displayIntermediateValues.o +0 -0
  137. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/genKAT.o +0 -0
  138. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/mainReference.o +0 -0
  139. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakDuplex.o +0 -0
  140. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakF-1600-reference32BI.o +0 -0
  141. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakNISTInterface.o +0 -0
  142. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakSponge.o +0 -0
  143. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/displayIntermediateValues.o +0 -0
  144. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/genKAT.o +0 -0
  145. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/mainReference.o +0 -0
  146. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple-test.o +0 -0
  147. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple.o +0 -0
  148. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple-test.o +0 -0
  149. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple32BI.o +0 -0
  150. data/ext/sha3/KeccakReferenceAndOptimized/compile64.bat +1 -0
  151. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccak +1 -0
  152. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc1024 +1 -0
  153. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256 +1 -0
  154. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256treed2 +1 -0
  155. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc448 +1 -0
  156. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512 +1 -0
  157. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512treed2 +1 -0
  158. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc768 +1 -0
  159. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccak.c +11 -0
  160. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc1024.c +11 -0
  161. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc256.c +11 -0
  162. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc448.c +11 -0
  163. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc512.c +11 -0
  164. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc768.c +11 -0
  165. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccak.h +1 -0
  166. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc1024.h +1 -0
  167. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc256.h +1 -0
  168. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc448.h +1 -0
  169. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc512.h +1 -0
  170. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc768.h +1 -0
  171. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/populate.py +506 -0
  172. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccak.h +2 -0
  173. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc1024.h +2 -0
  174. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc256.h +2 -0
  175. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc448.h +2 -0
  176. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc512.h +2 -0
  177. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc768.h +2 -0
  178. data/ext/sha3/KeccakReferenceAndOptimized/makefile +327 -0
  179. data/ext/sha3/Makefile +240 -0
  180. data/ext/sha3/depend +28 -0
  181. data/ext/sha3/extconf.rb +21 -0
  182. data/ext/sha3/sha3.c +95 -0
  183. data/lib/sha3-ruby.rb +27 -0
  184. data/lib/sha3-ruby/version.rb +5 -0
  185. data/sha3-ruby.gemspec +21 -0
  186. metadata +233 -0
@@ -0,0 +1,446 @@
1
+ @ The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
2
+ @ Michaël Peeters and Gilles Van Assche. For more information, feedback or
3
+ @ questions, please refer to our website: http://keccak.noekeon.org/
4
+ @
5
+ @ Implementation by Ronny Van Keer, hereby denoted as "the implementer".
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
+ @ This file was created from a .asm file
12
+ @ using the ads2gas.pl script.
13
+ .equ DO1STROUNDING, 0
14
+
15
+ @ PRESERVE8
16
+ .text
17
+
18
+ @// --- offsets in state
19
+ .equ Aba, 0*8
20
+ .equ Aga, 1*8
21
+ .equ Aka, 2*8
22
+ .equ Ama, 3*8
23
+ .equ Asa, 4*8
24
+
25
+ @// --- macros
26
+
27
+ .macro KeccakThetaRhoPiChiIota argA1, argA2, argA3, argA4, argA5
28
+
29
+ @Prepare Theta
30
+ @Ca = Aba^Aga^Aka^Ama^Asa@
31
+ @Ce = Abe^Age^Ake^Ame^Ase@
32
+ @Ci = Abi^Agi^Aki^Ami^Asi@
33
+ @Co = Abo^Ago^Ako^Amo^Aso@
34
+ @Cu = Abu^Agu^Aku^Amu^Asu@
35
+ @De = Ca^ROL64(Ci, 1)@
36
+ @Di = Ce^ROL64(Co, 1)@
37
+ @Do = Ci^ROL64(Cu, 1)@
38
+ @Du = Co^ROL64(Ca, 1)@
39
+ @Da = Cu^ROL64(Ce, 1)@
40
+
41
+ veor.64 q4, q6, q7
42
+ veor.64 q5, q9, q10
43
+ veor.64 d8, d8, d9
44
+ veor.64 d10, d10, d11
45
+ veor.64 d1, d8, d16
46
+ veor.64 d2, d10, d17
47
+
48
+ veor.64 q4, q11, q12
49
+ veor.64 q5, q14, q15
50
+ veor.64 d8, d8, d9
51
+ veor.64 d10, d10, d11
52
+ veor.64 d3, d8, d26
53
+
54
+ vadd.u64 q4, q1, q1
55
+ veor.64 d4, d10, d27
56
+ vmov.64 d0, d5
57
+ vsri.64 q4, q1, #63
58
+
59
+ vadd.u64 q5, q2, q2
60
+ veor.64 q4, q4, q0
61
+ vsri.64 q5, q2, #63
62
+ vadd.u64 d7, d1, d1
63
+ veor.64 \argA2, \argA2, d8
64
+ veor.64 q5, q5, q1
65
+
66
+ vsri.64 d7, d1, #63
67
+ vshl.u64 d1, \argA2, #44
68
+ veor.64 \argA3, \argA3, d9
69
+ veor.64 d7, d7, d4
70
+
71
+ @Ba = argA1^Da@
72
+ @Be = ROL64((argA2^De), 44)@
73
+ @Bi = ROL64((argA3^Di), 43)@
74
+ @Bo = ROL64((argA4^Do), 21)@
75
+ @Bu = ROL64((argA5^Du), 14)@
76
+ @argA2 = Be ^((~Bi)& Bo )@
77
+ @argA3 = Bi ^((~Bo)& Bu )@
78
+ @argA4 = Bo ^((~Bu)& Ba )@
79
+ @argA5 = Bu ^((~Ba)& Be )@
80
+ @argA1 = Ba ^((~Be)& Bi )@ argA1 ^= KeccakF1600RoundConstants[i+round]@
81
+ vsri.64 d1, \argA2, #64-44
82
+ vshl.u64 d2, \argA3, #43
83
+ vldr.64 d0, [sp, #\argA1]
84
+ veor.64 \argA4, \argA4, d10
85
+ vsri.64 d2, \argA3, #64-43
86
+ vshl.u64 d3, \argA4, #21
87
+ veor.64 \argA5, \argA5, d11
88
+ veor.64 d0, d0, d7
89
+ vsri.64 d3, \argA4, #64-21
90
+ vbic.64 d5, d2, d1
91
+ vshl.u64 d4, \argA5, #14
92
+ vbic.64 \argA2, d3, d2
93
+ vld1.64 d6, [r3]!
94
+ veor.64 d5, d0
95
+ vsri.64 d4, \argA5, #64-14
96
+ veor.64 d5, d6
97
+ vbic.64 \argA5, d1, d0
98
+ vbic.64 \argA3, d4, d3
99
+ vbic.64 \argA4, d0, d4
100
+ veor.64 \argA2, d1
101
+ vstr.64 d5, [sp, #\argA1]
102
+ veor.64 \argA3, d2
103
+ veor.64 \argA4, d3
104
+ veor.64 \argA5, d4
105
+
106
+ .endm
107
+
108
+ .macro KeccakThetaRhoPiChi1 argA1, argA2, argA3, argA4, argA5
109
+
110
+ @d2 = ROL64((argA1^Da), 3)@
111
+ @d3 = ROL64((argA2^De), 45)@
112
+ @d4 = ROL64((argA3^Di), 61)@
113
+ @d0 = ROL64((argA4^Do), 28)@
114
+ @d1 = ROL64((argA5^Du), 20)@
115
+ @argA1 = Ba ^((~Be)& Bi )@ Ca ^= argA1@
116
+ @argA2 = Be ^((~Bi)& Bo )@
117
+ @argA3 = Bi ^((~Bo)& Bu )@
118
+ @argA4 = Bo ^((~Bu)& Ba )@
119
+ @argA5 = Bu ^((~Ba)& Be )@
120
+
121
+ veor.64 \argA2, \argA2, d8
122
+ veor.64 \argA3, \argA3, d9
123
+ vshl.u64 d3, \argA2, #45
124
+ vldr.64 d6, [sp, #\argA1]
125
+ vshl.u64 d4, \argA3, #61
126
+ veor.64 \argA4, \argA4, d10
127
+ vsri.64 d3, \argA2, #64-45
128
+ veor.64 \argA5, \argA5, d11
129
+ vsri.64 d4, \argA3, #64-61
130
+ vshl.u64 d0, \argA4, #28
131
+ veor.64 d6, d6, d7
132
+ vshl.u64 d1, \argA5, #20
133
+ vbic.64 \argA3, d4, d3
134
+ vsri.64 d0, \argA4, #64-28
135
+ vbic.64 \argA4, d0, d4
136
+ vshl.u64 d2, d6, #3
137
+ vsri.64 d1, \argA5, #64-20
138
+ veor.64 \argA4, d3
139
+ vsri.64 d2, d6, #64-3
140
+ vbic.64 \argA5, d1, d0
141
+ vbic.64 d6, d2, d1
142
+ vbic.64 \argA2, d3, d2
143
+ veor.64 d6, d0
144
+ veor.64 \argA2, d1
145
+ vstr.64 d6, [sp, #\argA1]
146
+ veor.64 \argA3, d2
147
+ veor.64 d5, d6
148
+ veor.64 \argA5, d4
149
+
150
+ .endm
151
+
152
+ .macro KeccakThetaRhoPiChi2 argA1, argA2, argA3, argA4, argA5
153
+
154
+ @d4 = ROL64((argA1^Da), 18)@
155
+ @d0 = ROL64((argA2^De), 1)@
156
+ @d1 = ROL64((argA3^Di), 6)@
157
+ @d2 = ROL64((argA4^Do), 25)@
158
+ @d3 = ROL64((argA5^Du), 8)@
159
+ @argA1 = Ba ^((~Be)& Bi )@ Ca ^= argA1@
160
+ @argA2 = Be ^((~Bi)& Bo )@
161
+ @argA3 = Bi ^((~Bo)& Bu )@
162
+ @argA4 = Bo ^((~Bu)& Ba )@
163
+ @argA5 = Bu ^((~Ba)& Be )@
164
+
165
+ veor.64 \argA3, \argA3, d9
166
+ veor.64 \argA4, \argA4, d10
167
+ vshl.u64 d1, \argA3, #6
168
+ vldr.64 d6, [sp, #\argA1]
169
+ vshl.u64 d2, \argA4, #25
170
+ veor.64 \argA5, \argA5, d11
171
+ vsri.64 d1, \argA3, #64-6
172
+ veor.64 \argA2, \argA2, d8
173
+ vsri.64 d2, \argA4, #64-25
174
+ vext.8 d3, \argA5, \argA5, #7
175
+ veor.64 d6, d6, d7
176
+ vbic.64 \argA3, d2, d1
177
+ vadd.u64 d0, \argA2, \argA2
178
+ vbic.64 \argA4, d3, d2
179
+ vsri.64 d0, \argA2, #64-1
180
+ vshl.u64 d4, d6, #18
181
+ veor.64 \argA2, d1, \argA4
182
+ veor.64 \argA3, d0
183
+ vsri.64 d4, d6, #64-18
184
+ vstr.64 \argA3, [sp, #\argA1]
185
+ veor.64 d5, \argA3
186
+ vbic.64 \argA5, d1, d0
187
+ vbic.64 \argA3, d4, d3
188
+ vbic.64 \argA4, d0, d4
189
+ veor.64 \argA3, d2
190
+ veor.64 \argA4, d3
191
+ veor.64 \argA5, d4
192
+
193
+ .endm
194
+
195
+ .macro KeccakThetaRhoPiChi3 argA1, argA2, argA3, argA4, argA5
196
+
197
+ @d1 = ROL64((argA1^Da), 36)@
198
+ @d2 = ROL64((argA2^De), 10)@
199
+ @d3 = ROL64((argA3^Di), 15)@
200
+ @d4 = ROL64((argA4^Do), 56)@
201
+ @d0 = ROL64((argA5^Du), 27)@
202
+ @argA1 = Ba ^((~Be)& Bi )@ Ca ^= argA1@
203
+ @argA2 = Be ^((~Bi)& Bo )@
204
+ @argA3 = Bi ^((~Bo)& Bu )@
205
+ @argA4 = Bo ^((~Bu)& Ba )@
206
+ @argA5 = Bu ^((~Ba)& Be )@
207
+
208
+ veor.64 \argA2, \argA2, d8
209
+ veor.64 \argA3, \argA3, d9
210
+ vshl.u64 d2, \argA2, #10
211
+ vldr.64 d6, [sp, #\argA1]
212
+ vshl.u64 d3, \argA3, #15
213
+ veor.64 \argA4, \argA4, d10
214
+ vsri.64 d2, \argA2, #64-10
215
+ vsri.64 d3, \argA3, #64-15
216
+ veor.64 \argA5, \argA5, d11
217
+ vext.8 d4, \argA4, \argA4, #1
218
+ vbic.64 \argA2, d3, d2
219
+ vshl.u64 d0, \argA5, #27
220
+ veor.64 d6, d6, d7
221
+ vbic.64 \argA3, d4, d3
222
+ vsri.64 d0, \argA5, #64-27
223
+ vshl.u64 d1, d6, #36
224
+ veor.64 \argA3, d2
225
+ vbic.64 \argA4, d0, d4
226
+ vsri.64 d1, d6, #64-36
227
+
228
+ veor.64 \argA4, d3
229
+ vbic.64 d6, d2, d1
230
+ vbic.64 \argA5, d1, d0
231
+ veor.64 d6, d0
232
+ veor.64 \argA2, d1
233
+ vstr.64 d6, [sp, #\argA1]
234
+ veor.64 d5, d6
235
+ veor.64 \argA5, d4
236
+
237
+ .endm
238
+
239
+ .macro KeccakThetaRhoPiChi4 argA1, argA2, argA3, argA4, argA5
240
+
241
+ @d3 = ROL64((argA1^Da), 41)@
242
+ @d4 = ROL64((argA2^De), 2)@
243
+ @d0 = ROL64((argA3^Di), 62)@
244
+ @d1 = ROL64((argA4^Do), 55)@
245
+ @d2 = ROL64((argA5^Du), 39)@
246
+ @argA1 = Ba ^((~Be)& Bi )@ Ca ^= argA1@
247
+ @argA2 = Be ^((~Bi)& Bo )@
248
+ @argA3 = Bi ^((~Bo)& Bu )@
249
+ @argA4 = Bo ^((~Bu)& Ba )@
250
+ @argA5 = Bu ^((~Ba)& Be )@
251
+
252
+ veor.64 \argA2, \argA2, d8
253
+ veor.64 \argA3, \argA3, d9
254
+ vshl.u64 d4, \argA2, #2
255
+ veor.64 \argA5, \argA5, d11
256
+ vshl.u64 d0, \argA3, #62
257
+ vldr.64 d6, [sp, #\argA1]
258
+ vsri.64 d4, \argA2, #64-2
259
+ veor.64 \argA4, \argA4, d10
260
+ vsri.64 d0, \argA3, #64-62
261
+
262
+ vshl.u64 d1, \argA4, #55
263
+ veor.64 d6, d6, d7
264
+ vshl.u64 d2, \argA5, #39
265
+ vsri.64 d1, \argA4, #64-55
266
+ vbic.64 \argA4, d0, d4
267
+ vsri.64 d2, \argA5, #64-39
268
+ vbic.64 \argA2, d1, d0
269
+ vshl.u64 d3, d6, #41
270
+ veor.64 \argA5, d4, \argA2
271
+ vbic.64 \argA2, d2, d1
272
+ vsri.64 d3, d6, #64-41
273
+ veor.64 d6, d0, \argA2
274
+
275
+ vbic.64 \argA2, d3, d2
276
+ vbic.64 \argA3, d4, d3
277
+ veor.64 \argA2, d1
278
+ vstr.64 d6, [sp, #\argA1]
279
+ veor.64 d5, d6
280
+ veor.64 \argA3, d2
281
+ veor.64 \argA4, d3
282
+
283
+ .endm
284
+
285
+ @// --- constants
286
+
287
+
288
+ .align 8
289
+ .ltorg
290
+ KeccakF1600RoundConstantsWithTerminator:
291
+ .quad 0x0000000000000001
292
+ .quad 0x0000000000008082
293
+ .quad 0x800000000000808a
294
+ .quad 0x8000000080008000
295
+ .quad 0x000000000000808b
296
+ .quad 0x0000000080000001
297
+ .quad 0x8000000080008081
298
+ .quad 0x8000000000008009
299
+ .quad 0x000000000000008a
300
+ .quad 0x0000000000000088
301
+ .quad 0x0000000080008009
302
+ .quad 0x000000008000000a
303
+ .quad 0x000000008000808b
304
+ .quad 0x800000000000008b
305
+ .quad 0x8000000000008089
306
+ .quad 0x8000000000008003
307
+ .quad 0x8000000000008002
308
+ .quad 0x8000000000000080
309
+ .quad 0x000000000000800a
310
+ .quad 0x800000008000000a
311
+ .quad 0x8000000080008081
312
+ .quad 0x8000000000008080
313
+ .quad 0x0000000080000001
314
+ .quad 0x8000000080008008
315
+ .quad 0xFFFFFFFFFFFFFFFF @//terminator
316
+
317
+ .align 8
318
+
319
+ @// --- code
320
+
321
+ @not callable from C!
322
+ .global KeccakF_armv7a_neon_asm
323
+ KeccakF_armv7a_neon_asm: @
324
+
325
+ adr r3, KeccakF1600RoundConstantsWithTerminator
326
+ roundLoop:
327
+
328
+ KeccakThetaRhoPiChiIota Aba, d13, d19, d25, d31
329
+ KeccakThetaRhoPiChi1 Aka, d15, d21, d22, d28
330
+ KeccakThetaRhoPiChi2 Asa, d12, d18, d24, d30
331
+ KeccakThetaRhoPiChi3 Aga, d14, d20, d26, d27
332
+ KeccakThetaRhoPiChi4 Ama, d16, d17, d23, d29
333
+
334
+ KeccakThetaRhoPiChiIota Aba, d15, d18, d26, d29
335
+ KeccakThetaRhoPiChi1 Asa, d14, d17, d25, d28
336
+ KeccakThetaRhoPiChi2 Ama, d13, d21, d24, d27
337
+ KeccakThetaRhoPiChi3 Aka, d12, d20, d23, d31
338
+ KeccakThetaRhoPiChi4 Aga, d16, d19, d22, d30
339
+
340
+ KeccakThetaRhoPiChiIota Aba, d14, d21, d23, d30
341
+ KeccakThetaRhoPiChi1 Ama, d12, d19, d26, d28
342
+ KeccakThetaRhoPiChi2 Aga, d15, d17, d24, d31
343
+ KeccakThetaRhoPiChi3 Asa, d13, d20, d22, d29
344
+ KeccakThetaRhoPiChi4 Aka, d16, d18, d25, d27
345
+
346
+ KeccakThetaRhoPiChiIota Aba, d12, d17, d22, d27
347
+ KeccakThetaRhoPiChi1 Aga, d13, d18, d23, d28
348
+ KeccakThetaRhoPiChi2 Aka, d14, d19, d24, d29
349
+ ldr r0, [r3]
350
+ KeccakThetaRhoPiChi3 Ama, d15, d20, d25, d30
351
+ cmp r0, #0xFFFFFFFF
352
+ KeccakThetaRhoPiChi4 Asa, d16, d21, d26, d31
353
+
354
+ bne roundLoop
355
+ bx lr
356
+
357
+ @
358
+ .align 8
359
+
360
+ @//void KeccakF_armv7a( tKeccakLane * state ) callable from C
361
+ .global KeccakF_armv7a_neon
362
+ KeccakF_armv7a_neon: @
363
+
364
+ vpush {q4-q7}
365
+ sub sp,sp, #5*8
366
+
367
+ vldr.64 d0, [r0, #0*8]
368
+ vldr.64 d12, [r0, #1*8]
369
+ vldr.64 d17, [r0, #2*8]
370
+ vldr.64 d22, [r0, #3*8]
371
+ vldr.64 d27, [r0, #4*8]
372
+
373
+ vldr.64 d1, [r0, #5*8]
374
+ vldr.64 d13, [r0, #6*8]
375
+ vldr.64 d18, [r0, #7*8]
376
+ vldr.64 d23, [r0, #8*8]
377
+ vldr.64 d28, [r0, #9*8]
378
+
379
+ vldr.64 d2, [r0, #10*8]
380
+ vldr.64 d14, [r0, #11*8]
381
+ vldr.64 d19, [r0, #12*8]
382
+ vldr.64 d24, [r0, #13*8]
383
+ vldr.64 d29, [r0, #14*8]
384
+
385
+ vldr.64 d3, [r0, #15*8]
386
+ vldr.64 d15, [r0, #16*8]
387
+ vldr.64 d20, [r0, #17*8]
388
+ vldr.64 d25, [r0, #18*8]
389
+ vldr.64 d30, [r0, #19*8]
390
+
391
+ vldr.64 d4, [r0, #20*8]
392
+ vldr.64 d16, [r0, #21*8]
393
+ vldr.64 d21, [r0, #22*8]
394
+ vldr.64 d26, [r0, #23*8]
395
+ vldr.64 d31, [r0, #24*8]
396
+
397
+ vstr.64 d0, [sp, #Aba]
398
+ mov r2, lr
399
+ vstr.64 d1, [sp, #Aga]
400
+ veor.64 q0, q0, q1
401
+ vstr.64 d2, [sp, #Aka]
402
+ veor.64 d5, d0, d1
403
+ vstr.64 d3, [sp, #Ama]
404
+ mov r1, r0
405
+ vstr.64 d4, [sp, #Asa]
406
+ veor.64 d5, d5, d4
407
+
408
+ bl KeccakF_armv7a_neon_asm
409
+
410
+ vpop.64 { d0- d4 }
411
+
412
+ vstr.64 d0, [r1, #0*8]
413
+ vstr.64 d12, [r1, #1*8]
414
+ vstr.64 d17, [r1, #2*8]
415
+ vstr.64 d22, [r1, #3*8]
416
+ vstr.64 d27, [r1, #4*8]
417
+
418
+ vstr.64 d1, [r1, #5*8]
419
+ vstr.64 d13, [r1, #6*8]
420
+ vstr.64 d18, [r1, #7*8]
421
+ vstr.64 d23, [r1, #8*8]
422
+ vstr.64 d28, [r1, #9*8]
423
+
424
+ vstr.64 d2, [r1, #10*8]
425
+ vstr.64 d14, [r1, #11*8]
426
+ vstr.64 d19, [r1, #12*8]
427
+ vstr.64 d24, [r1, #13*8]
428
+ vstr.64 d29, [r1, #14*8]
429
+
430
+ vstr.64 d3, [r1, #15*8]
431
+ vstr.64 d15, [r1, #16*8]
432
+ vstr.64 d20, [r1, #17*8]
433
+ vstr.64 d25, [r1, #18*8]
434
+ vstr.64 d30, [r1, #19*8]
435
+
436
+ vstr.64 d4, [r1, #20*8]
437
+ vstr.64 d16, [r1, #21*8]
438
+ vstr.64 d21, [r1, #22*8]
439
+ vstr.64 d26, [r1, #23*8]
440
+ vstr.64 d31, [r1, #24*8]
441
+
442
+ vpop {q4-q7}
443
+ bx r2
444
+
445
+ @
446
+
@@ -0,0 +1,6 @@
1
+ #define ProvideFast576
2
+ #define ProvideFast832
3
+ #define ProvideFast1024
4
+ #define ProvideFast1088
5
+ #define ProvideFast1152
6
+ #define ProvideFast1344