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,47 @@
1
+ /*
2
+ The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3
+ Michaël Peeters and Gilles Van Assche. For more information, feedback or
4
+ questions, please refer to our website: http://keccak.noekeon.org/
5
+
6
+ Implementation by Ronny Van Keer,
7
+ hereby denoted as "the implementer".
8
+
9
+ To the extent possible under law, the implementer has waived all copyright
10
+ and related or neighboring rights to the source code in this file.
11
+ http://creativecommons.org/publicdomain/zero/1.0/
12
+ */
13
+
14
+ #ifndef _Keccak_compact_h_
15
+ #define _Keccak_compact_h_
16
+
17
+ #include "Keccak-compact8-settings.h"
18
+
19
+ /* Only Keccak-F1600 is supported */
20
+ #define cKeccakB 1600
21
+
22
+
23
+ int crypto_hash( unsigned char *out, const unsigned char *in, unsigned long long inlen );
24
+
25
+ /*
26
+ ** API with a message queue
27
+ */
28
+
29
+ typedef unsigned char BitSequence;
30
+ typedef unsigned long long DataLength;
31
+ typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
32
+
33
+ typedef struct hashStateStruct
34
+ {
35
+ unsigned char state[cKeccakB / 8];
36
+ unsigned char bytesInQueue;
37
+ unsigned char trailingBitsInQueue;
38
+ } hashState;
39
+
40
+
41
+ HashReturn Init(hashState *state);
42
+
43
+ HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen);
44
+
45
+ HashReturn Final(hashState *state, BitSequence *hashval, int hashbytelen);
46
+
47
+ #endif
@@ -0,0 +1,406 @@
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
+ @// --- defines
19
+ .equ cKeccakLaneSizeInBytes, 8
20
+ .equ cKeccakR_SizeInBytes , 1024/8
21
+ .equ crypto_hash_BYTES , cKeccakR_SizeInBytes
22
+
23
+ @// --- offsets in state
24
+ .equ Aba, 0*8
25
+ .equ Aga, 1*8
26
+ .equ Aka, 2*8
27
+ .equ Ama, 3*8
28
+ .equ Asa, 4*8
29
+
30
+
31
+ @// --- code
32
+
33
+ .align 8
34
+
35
+ .global KeccakF_armv7a_neon_asm
36
+
37
+ @//int crypto_hash( unsigned char *out, const unsigned char *in, unsigned long long inlen )
38
+ .global crypto_hash_keccak_inplace_armv7a_neon
39
+
40
+ crypto_hash_keccak_inplace_armv7a_neon: @
41
+
42
+ push {r4-r6,lr}
43
+ mov r5, r0
44
+ vpush {q4-q7}
45
+
46
+ @//allocate and clear state
47
+ pld [sp, #-5*8] @//preload state data
48
+ vmov.i64 q6, #0
49
+ vpush {d12}
50
+ vmov.i64 q7, #0
51
+ vmov.i64 q8, #0
52
+ vpush {d12}
53
+ vmov.i64 q9, #0
54
+ vmov.i64 q10, #0
55
+ vpush {d12}
56
+ vmov.i64 q11, #0
57
+ vmov.i64 q12, #0
58
+ vpush {d12}
59
+ vmov.i64 q13, #0
60
+ vmov.i64 q14, #0
61
+ vpush {d12}
62
+ vmov.i64 q15, #0
63
+
64
+ subs r2, r2, #cKeccakR_SizeInBytes
65
+ bcc crypto_hash_LoopEnd
66
+ pld [r1] @//preload in data
67
+
68
+ @// Complete rate loop
69
+ crypto_hash_Loop:
70
+
71
+ vldr d7, [sp, #Aba] @get 5 lanes from stack
72
+ vldm r1!, { d0-d1 }
73
+ veor.64 d7, d0
74
+ vldm r1!, { d2-d3 }
75
+ veor.64 d12, d1
76
+ vldm r1!, { d0-d1 }
77
+ veor.64 d17, d2
78
+ vldr d8, [sp, #Aga]
79
+ veor.64 d22, d3
80
+ vldm r1!, { d2-d3 }
81
+ veor.64 d27, d0
82
+ vstr d7, [sp, #Aba]
83
+ veor.64 d8, d1
84
+ vldm r1!, { d0-d1 }
85
+ veor.64 d13, d2
86
+ vldr d9, [sp, #Aka]
87
+ veor.64 d18, d3
88
+ vldm r1!, { d2-d3 }
89
+ veor.64 d23, d0
90
+ vldr d10, [sp, #Ama]
91
+ veor.64 d28, d1
92
+ vldm r1!, { d0-d1 }
93
+ veor.64 d9, d2
94
+ vstr d8, [sp, #Aga]
95
+ veor.64 d14, d3
96
+ vldm r1!, { d2-d3 }
97
+ veor.64 d19, d0
98
+ vldr d11, [sp, #Asa]
99
+ veor.64 d24, d1
100
+ vstr d9, [sp, #Aka]
101
+ veor.64 d29, d2
102
+ veor.64 d10, d3
103
+ veor.64 q4, q5
104
+ vstr d10, [sp, #Ama]
105
+ veor.64 d5, d8, d9
106
+ veor.64 d5, d5, d7
107
+
108
+ bl KeccakF_armv7a_neon_asm
109
+ subs r2, r2, #cKeccakR_SizeInBytes
110
+ bcs crypto_hash_Loop
111
+ crypto_hash_LoopEnd:
112
+
113
+ adds r2, r2, #cKeccakR_SizeInBytes
114
+ vldm sp, { d7-d11 } @get 5 lanes from stack
115
+ cmp r2, #8
116
+ blo crypto_hash_IncompleteLane
117
+
118
+ @ Absorb last complete lanes
119
+ cmp r2, #8*8
120
+ bhs crypto_hash_8LanesOrMore
121
+
122
+ @less than 8 lanes left
123
+ cmp r2, #4*8
124
+ bhs crypto_hash_4LanesOrMore
125
+
126
+ @1 to 3 lanes left
127
+ vld1.64 d0, [r1]!
128
+ cmp r2, #2*8
129
+ veor.64 d7, d0
130
+ blo crypto_hash_FinalizeCompleteLanes
131
+ vld1.64 d0, [r1]!
132
+ cmp r2, #3*8
133
+ veor.64 d12, d0
134
+ blo crypto_hash_FinalizeCompleteLanes
135
+ vld1.64 d0, [r1]!
136
+ veor.64 d17, d0
137
+ b crypto_hash_FinalizeCompleteLanes
138
+
139
+ crypto_hash_4LanesOrMore:
140
+ vldm r1!, { d0-d1 }
141
+ veor.64 d7, d0
142
+ vldm r1!, { d2-d3 }
143
+ veor.64 d12, d1
144
+ veor.64 d17, d2
145
+ veor.64 d22, d3
146
+
147
+ cmp r2, #5*8
148
+ blo crypto_hash_FinalizeCompleteLanes
149
+ vld1.64 d0, [r1]!
150
+ cmp r2, #6*8
151
+ veor.64 d27, d0
152
+ blo crypto_hash_FinalizeCompleteLanes
153
+ vld1.64 d0, [r1]!
154
+ cmp r2, #7*8
155
+ veor.64 d8, d0
156
+ blo crypto_hash_FinalizeCompleteLanes
157
+ vld1.64 d0, [r1]!
158
+ veor.64 d13, d0
159
+ b crypto_hash_FinalizeCompleteLanes
160
+
161
+ crypto_hash_8LanesOrMore:
162
+ vldm r1!, { d0-d1 }
163
+ veor.64 d7, d0
164
+ vldm r1!, { d2-d3 }
165
+ veor.64 d12, d1
166
+ vldm r1!, { d0-d1 }
167
+ veor.64 d17, d2
168
+ veor.64 d22, d3
169
+ vldm r1!, { d2-d3 }
170
+ veor.64 d27, d0
171
+ veor.64 d8, d1
172
+ veor.64 d13, d2
173
+ veor.64 d18, d3
174
+
175
+ cmp r2, #12*8
176
+ bhs crypto_hash_12LanesOrMore
177
+
178
+ @8 to 11 lanes left
179
+ cmp r2, #9*8
180
+ blo crypto_hash_FinalizeCompleteLanes
181
+ vld1.64 d0, [r1]!
182
+ cmp r2, #10*8
183
+ veor.64 d23, d0
184
+ blo crypto_hash_FinalizeCompleteLanes
185
+ vld1.64 d0, [r1]!
186
+ cmp r2, #11*8
187
+ veor.64 d28, d0
188
+ blo crypto_hash_FinalizeCompleteLanes
189
+ vld1.64 d0, [r1]!
190
+ veor.64 d9, d0
191
+ b crypto_hash_FinalizeCompleteLanes
192
+
193
+ crypto_hash_12LanesOrMore:
194
+ vldm r1!, { d0-d1 }
195
+ veor.64 d23, d0
196
+ vldm r1!, { d2-d3 }
197
+ veor.64 d28, d1
198
+ veor.64 d9, d2
199
+ veor.64 d14, d3
200
+
201
+ @12 to 15 lanes left
202
+ cmp r2, #13*8
203
+ blo crypto_hash_FinalizeCompleteLanes
204
+ vld1.64 d0, [r1]!
205
+ cmp r2, #14*8
206
+ veor.64 d19, d0
207
+ blo crypto_hash_FinalizeCompleteLanes
208
+ vld1.64 d0, [r1]!
209
+ cmp r2, #15*8
210
+ veor.64 d24, d0
211
+ blo crypto_hash_FinalizeCompleteLanes
212
+ vld1.64 d0, [r1]!
213
+ veor.64 d29, d0
214
+
215
+ crypto_hash_FinalizeCompleteLanes:
216
+
217
+
218
+ crypto_hash_IncompleteLane:
219
+ and r0, r2, #cKeccakLaneSizeInBytes-1
220
+ vmov.i8 d0, #0xFF @padding
221
+ lsr r2, r2, #3 @//number of lanes left
222
+
223
+ vshr.u64 d0, #63 @padding
224
+ adr r3, crypto_hash_IncompleteLaneTable
225
+ ldr pc, [r3, r0, LSL #2]
226
+
227
+ crypto_hash_IncompleteLaneTable:
228
+ .long crypto_hash_IncompleteDone @0 left
229
+ .long crypto_hash_1left
230
+ .long crypto_hash_2left
231
+ .long crypto_hash_3left
232
+ .long crypto_hash_4left
233
+ .long crypto_hash_5left
234
+ .long crypto_hash_6left
235
+ .long crypto_hash_7left
236
+
237
+ crypto_hash_1left:
238
+ vshl.u64 d0, d0, #8
239
+ vld1.8 d0[0], [r1]!
240
+ b crypto_hash_IncompleteDone
241
+
242
+ crypto_hash_2left:
243
+ vshl.u64 d0, d0, #16
244
+ vld1.16 d0[0], [r1]!
245
+ b crypto_hash_IncompleteDone
246
+
247
+ crypto_hash_3left:
248
+ vshl.u64 d0, d0, #24
249
+ vld1.16 d0[0], [r1]!
250
+ vld1.8 d0[2], [r1]!
251
+ b crypto_hash_IncompleteDone
252
+
253
+ crypto_hash_4left:
254
+ vshl.u64 d0, d0, #32
255
+ vld1.32 d0[0], [r1]!
256
+ b crypto_hash_IncompleteDone
257
+
258
+ crypto_hash_5left:
259
+ vshl.u64 d0, d0, #40
260
+ vld1.32 d0[0], [r1]!
261
+ vld1.8 d0[4], [r1]!
262
+ b crypto_hash_IncompleteDone
263
+
264
+ crypto_hash_6left:
265
+ vshl.u64 d0, d0, #48
266
+ vld1.32 d0[0], [r1]!
267
+ vld1.16 d0[2], [r1]!
268
+ b crypto_hash_IncompleteDone
269
+
270
+ crypto_hash_7left:
271
+ vshl.u64 d0, d0, #56
272
+ vld1.32 d0[0], [r1]!
273
+ vld1.16 d0[2], [r1]!
274
+ vld1.8 d0[6], [r1]!
275
+
276
+ crypto_hash_IncompleteDone:
277
+ adr r3, crypto_hash_xorlastLaneTable
278
+ ldr pc, [r3, r2, LSL #2]
279
+
280
+ crypto_hash_xorlastLaneTable:
281
+ .long crypto_hash_xorLane1
282
+ .long crypto_hash_xorLane2
283
+ .long crypto_hash_xorLane3
284
+ .long crypto_hash_xorLane4
285
+ .long crypto_hash_xorLane5
286
+ .long crypto_hash_xorLane6
287
+ .long crypto_hash_xorLane7
288
+ .long crypto_hash_xorLane8
289
+ .long crypto_hash_xorLane9
290
+ .long crypto_hash_xorLane10
291
+ .long crypto_hash_xorLane11
292
+ .long crypto_hash_xorLane12
293
+ .long crypto_hash_xorLane13
294
+ .long crypto_hash_xorLane14
295
+ .long crypto_hash_xorLane15
296
+ .long crypto_hash_xorLane16
297
+
298
+ crypto_hash_xorLane1:
299
+ veor.64 d7, d0
300
+ b crypto_hash_xorLastBitOfRate
301
+
302
+ crypto_hash_xorLane2:
303
+ veor.64 d12, d0
304
+ b crypto_hash_xorLastBitOfRate
305
+
306
+ crypto_hash_xorLane3:
307
+ veor.64 d17, d0
308
+ b crypto_hash_xorLastBitOfRate
309
+
310
+ crypto_hash_xorLane4:
311
+ veor.64 d22, d0
312
+ b crypto_hash_xorLastBitOfRate
313
+
314
+ crypto_hash_xorLane5:
315
+ veor.64 d27, d0
316
+ b crypto_hash_xorLastBitOfRate
317
+
318
+ crypto_hash_xorLane6:
319
+ veor.64 d8, d0
320
+ b crypto_hash_xorLastBitOfRate
321
+
322
+ crypto_hash_xorLane7:
323
+ veor.64 d13, d0
324
+ b crypto_hash_xorLastBitOfRate
325
+
326
+ crypto_hash_xorLane8:
327
+ veor.64 d18, d0
328
+ b crypto_hash_xorLastBitOfRate
329
+
330
+ crypto_hash_xorLane9:
331
+ veor.64 d23, d0
332
+ b crypto_hash_xorLastBitOfRate
333
+
334
+ crypto_hash_xorLane10:
335
+ veor.64 d28, d0
336
+ b crypto_hash_xorLastBitOfRate
337
+
338
+ crypto_hash_xorLane11:
339
+ veor.64 d9, d0
340
+ b crypto_hash_xorLastBitOfRate
341
+
342
+ crypto_hash_xorLane12:
343
+ veor.64 d14, d0
344
+ b crypto_hash_xorLastBitOfRate
345
+
346
+ crypto_hash_xorLane13:
347
+ veor.64 d19, d0
348
+ b crypto_hash_xorLastBitOfRate
349
+
350
+ crypto_hash_xorLane14:
351
+ veor.64 d24, d0
352
+ b crypto_hash_xorLastBitOfRate
353
+
354
+ crypto_hash_xorLane15:
355
+ veor.64 d29, d0
356
+ b crypto_hash_xorLastBitOfRate
357
+
358
+ crypto_hash_xorLane16:
359
+ veor.64 d10, d0
360
+
361
+
362
+ crypto_hash_xorLastBitOfRate:
363
+ vmov.i8 d3, #0xFF
364
+ vshl.u64 d3, d3, #63
365
+ veor.64 d10, d10, d3
366
+
367
+ vstm sp, { d7-d10 } @put 4 lanes back on stack (last one not modified)
368
+
369
+ veor.64 q4, q5
370
+ veor.64 d5, d8, d9
371
+ veor.64 d5, d5, d7
372
+
373
+ bl KeccakF_armv7a_neon_asm
374
+
375
+ pld [r5] @//preload out data for write
376
+
377
+ vpop { d0-d1 }
378
+ vst1.64 d0, [r5]!
379
+ vst1.64 d12, [r5]!
380
+ vst1.64 d17, [r5]!
381
+ vst1.64 d22, [r5]!
382
+ vst1.64 d27, [r5]!
383
+
384
+ vpop { d2-d3 }
385
+ vst1.64 d1, [r5]!
386
+ vst1.64 d13, [r5]!
387
+ vst1.64 d18, [r5]!
388
+ vst1.64 d23, [r5]!
389
+ vst1.64 d28, [r5]!
390
+
391
+ vst1.64 d2, [r5]!
392
+ vst1.64 d14, [r5]!
393
+ vst1.64 d19, [r5]!
394
+ vst1.64 d24, [r5]!
395
+ vst1.64 d29, [r5]!
396
+
397
+ adds sp, sp, #8 @no need of last stacked lane in output
398
+ vst1.64 d3, [r5]!
399
+
400
+ vpop {q4-q7}
401
+ movs r0, #0
402
+ pop {r4-r6,pc}
403
+
404
+ @
405
+ .align 8
406
+