sha3-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact.vcproj +207 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact8.vcproj +207 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace.vcproj +203 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace32BI.vcproj +201 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized32.vcproj +267 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized64.vcproj +267 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference.vcproj +243 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference32BI.vcproj +243 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReferenceAndOptimized.sln +62 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple.vcproj +203 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple32BI.vcproj +201 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.h +27 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.s +285 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-settings.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-test.c +142 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.h +15 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.s +119 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.c +184 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.h +25 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-test.c +317 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.c +341 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.h +50 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-settings.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-test.c +192 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.c +375 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.h +47 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +406 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-minimal-test.c +231 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-test.c +221 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace.c +445 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv6M.s +844 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7A.s +687 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7M.s +687 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI.c +849 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-test.c +221 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple.c +403 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple32BI.c +673 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.c +68 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.h +59 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-rvk.macros +555 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s1.macros +1187 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s2.macros +1187 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32.macros +26 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-64.macros +728 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-arm.c +123 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armcc.s +653 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armgcc.s +686 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8.c +163 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-compact.s +647 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-fast.s +934 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-inplace-armgcc-ARMv7A-NEON.s +446 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-int-set.h +6 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-interface.h +46 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32-settings.h +4 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32.c +524 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64-settings.h +7 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64.c +504 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.c +300 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.h +20 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference32BI.c +371 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd128.macros +651 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd64.macros +517 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-unrolling.macros +124 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-asm.c +62 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-gas.s +766 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-shld-gas.s +766 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-xop.macros +573 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.h +70 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.c +266 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.h +76 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc1024-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +296 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc512-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +429 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/brg_endian.h +142 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/crypto_hash.h +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.c +117 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.h +29 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/genKAT.c +692 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainARM.c +88 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainOptimized.c +23 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainReference.c +381 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.c +436 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.h +13 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation-config.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.c +572 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.h +38 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/KeccakF-1600-unrolling.macros +124 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.h +18 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.h +18 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/crypto_hash.h +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/mainOptimized.c +112 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.c +225 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.h +20 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/makefile +68 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakCompact +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized32 +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized64 +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference32BI +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple32BI +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakF-1600-opt32.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/mainOptimized.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/timing.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakF-1600-opt64.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/mainOptimized.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/timing.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakF-1600-reference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/mainReference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakF-1600-reference32BI.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/mainReference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple32BI.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/compile64.bat +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccak +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc1024 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256treed2 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc448 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512treed2 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc768 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccak.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc1024.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc256.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc448.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc512.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc768.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccak.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc1024.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc256.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc448.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc512.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc768.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/populate.py +506 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccak.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc1024.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc256.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc448.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc512.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc768.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/makefile +327 -0
- data/ext/sha3/Makefile +240 -0
- data/ext/sha3/depend +28 -0
- data/ext/sha3/extconf.rb +21 -0
- data/ext/sha3/sha3.c +95 -0
- data/lib/sha3-ruby.rb +27 -0
- data/lib/sha3-ruby/version.rb +5 -0
- data/sha3-ruby.gemspec +21 -0
- metadata +233 -0
@@ -0,0 +1,687 @@
|
|
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,
|
6
|
+
@ hereby denoted as "the implementer".
|
7
|
+
@
|
8
|
+
@ To the extent possible under law, the implementer has waived all copyright
|
9
|
+
@ and related or neighboring rights to the source code in this file.
|
10
|
+
@ http://creativecommons.org/publicdomain/zero/1.0/
|
11
|
+
|
12
|
+
@ This file was created from a .asm file
|
13
|
+
@ using the ads2gas.pl script.
|
14
|
+
.equ DO1STROUNDING, 0
|
15
|
+
|
16
|
+
@ PRESERVE8
|
17
|
+
@ THUMB
|
18
|
+
.syntax unified
|
19
|
+
.cpu cortex-m3
|
20
|
+
.thumb
|
21
|
+
|
22
|
+
@// --- defines
|
23
|
+
.equ cKeccakLaneSizeInBytes , 8
|
24
|
+
.equ cKeccakR_SizeInBytes , 1024/8 @576/8 1024/8 1088/8 // populate.py, please set cKeccakR_SizeInBytes
|
25
|
+
.equ crypto_hash_BYTES , cKeccakR_SizeInBytes @// populate.py, please set crypto_hash_BYTES
|
26
|
+
|
27
|
+
|
28
|
+
@// --- offsets in state
|
29
|
+
.equ Aba0 , 0*4
|
30
|
+
.equ Aba1 , 1*4
|
31
|
+
.equ Abe0 , 2*4
|
32
|
+
.equ Abe1 , 3*4
|
33
|
+
.equ Abi0 , 4*4
|
34
|
+
.equ Abi1 , 5*4
|
35
|
+
.equ Abo0 , 6*4
|
36
|
+
.equ Abo1 , 7*4
|
37
|
+
.equ Abu0 , 8*4
|
38
|
+
.equ Abu1 , 9*4
|
39
|
+
.equ Aga0 , 10*4
|
40
|
+
.equ Aga1 , 11*4
|
41
|
+
.equ Age0 , 12*4
|
42
|
+
.equ Age1 , 13*4
|
43
|
+
.equ Agi0 , 14*4
|
44
|
+
.equ Agi1 , 15*4
|
45
|
+
.equ Ago0 , 16*4
|
46
|
+
.equ Ago1 , 17*4
|
47
|
+
.equ Agu0 , 18*4
|
48
|
+
.equ Agu1 , 19*4
|
49
|
+
.equ Aka0 , 20*4
|
50
|
+
.equ Aka1 , 21*4
|
51
|
+
.equ Ake0 , 22*4
|
52
|
+
.equ Ake1 , 23*4
|
53
|
+
.equ Aki0 , 24*4
|
54
|
+
.equ Aki1 , 25*4
|
55
|
+
.equ Ako0 , 26*4
|
56
|
+
.equ Ako1 , 27*4
|
57
|
+
.equ Aku0 , 28*4
|
58
|
+
.equ Aku1 , 29*4
|
59
|
+
.equ Ama0 , 30*4
|
60
|
+
.equ Ama1 , 31*4
|
61
|
+
.equ Ame0 , 32*4
|
62
|
+
.equ Ame1 , 33*4
|
63
|
+
.equ Ami0 , 34*4
|
64
|
+
.equ Ami1 , 35*4
|
65
|
+
.equ Amo0 , 36*4
|
66
|
+
.equ Amo1 , 37*4
|
67
|
+
.equ Amu0 , 38*4
|
68
|
+
.equ Amu1 , 39*4
|
69
|
+
.equ Asa0 , 40*4
|
70
|
+
.equ Asa1 , 41*4
|
71
|
+
.equ Ase0 , 42*4
|
72
|
+
.equ Ase1 , 43*4
|
73
|
+
.equ Asi0 , 44*4
|
74
|
+
.equ Asi1 , 45*4
|
75
|
+
.equ Aso0 , 46*4
|
76
|
+
.equ Aso1 , 47*4
|
77
|
+
.equ Asu0 , 48*4
|
78
|
+
.equ Asu1 , 49*4
|
79
|
+
|
80
|
+
@// --- offsets on stack
|
81
|
+
.equ mDo0 , 50*4
|
82
|
+
.equ mDo1 , 51*4
|
83
|
+
.equ mDi0 , 52*4
|
84
|
+
.equ mRC , 53*4
|
85
|
+
.equ mRet , 54*4
|
86
|
+
.equ mIn , 55*4
|
87
|
+
.equ mOut , 56*4
|
88
|
+
.equ mLen , 57*4
|
89
|
+
|
90
|
+
@// --- macros
|
91
|
+
|
92
|
+
@// Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002
|
93
|
+
.macro interleaveLane x0,x1,s0,s1,t
|
94
|
+
|
95
|
+
and \t,\x0,#0x55555555
|
96
|
+
orr \t,\t,\t, LSR #1
|
97
|
+
and \t,\t,#0x33333333
|
98
|
+
orr \t,\t,\t, LSR #2
|
99
|
+
and \t,\t,#0x0F0F0F0F
|
100
|
+
orr \t,\t,\t, LSR #4
|
101
|
+
and \t,\t,#0x00FF00FF
|
102
|
+
bfi \t,\t,#8, #8
|
103
|
+
eor \s0,\s0,\t, LSR #8
|
104
|
+
|
105
|
+
and \t,\x1,#0x55555555
|
106
|
+
orr \t,\t,\t, LSR #1
|
107
|
+
and \t,\t,#0x33333333
|
108
|
+
orr \t,\t,\t, LSR #2
|
109
|
+
and \t,\t,#0x0F0F0F0F
|
110
|
+
orr \t,\t,\t, LSR #4
|
111
|
+
and \t,\t,#0x00FF00FF
|
112
|
+
orr \t,\t,\t, LSR #8
|
113
|
+
eor \s0,\s0,\t, LSL #16
|
114
|
+
|
115
|
+
and \t,\x0,#0xAAAAAAAA
|
116
|
+
orr \t,\t,\t, LSL #1
|
117
|
+
and \t,\t,#0xCCCCCCCC
|
118
|
+
orr \t,\t,\t, LSL #2
|
119
|
+
and \t,\t,#0xF0F0F0F0
|
120
|
+
orr \t,\t,\t, LSL #4
|
121
|
+
and \t,\t,#0xFF00FF00
|
122
|
+
orr \t,\t,\t, LSL #8
|
123
|
+
eor \s1,\s1,\t, LSR #16
|
124
|
+
|
125
|
+
and \t,\x1,#0xAAAAAAAA
|
126
|
+
orr \t,\t,\t, LSL #1
|
127
|
+
and \t,\t,#0xCCCCCCCC
|
128
|
+
orr \t,\t,\t, LSL #2
|
129
|
+
and \t,\t,#0xF0F0F0F0
|
130
|
+
orr \t,\t,\t, LSL #4
|
131
|
+
and \t,\t,#0xFF00FF00
|
132
|
+
orr \t,\t,\t, LSL #8
|
133
|
+
bfc \t, #0, #16
|
134
|
+
eors \s1,\s1,\t
|
135
|
+
.endm
|
136
|
+
|
137
|
+
@// Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002
|
138
|
+
.macro uninterleaveLane x0, x1, t
|
139
|
+
|
140
|
+
movs \t, \x0 @// t = x0@
|
141
|
+
bfi \x0, \x1, #16, #16 @// x0 = (x0 & 0x0000FFFF) | (x1 << 16)@
|
142
|
+
bfc \x1, #0, #16 @// x1 = (t >> 16) | (x1 & 0xFFFF0000)@
|
143
|
+
orr \x1, \x1, \t, LSR #16
|
144
|
+
|
145
|
+
eor \t, \x0, \x0, LSR #8 @// t = (x0 ^ (x0 >> 8)) & 0x0000FF00UL@ x0 = x0 ^ t ^ (t << 8)@
|
146
|
+
and \t, #0x0000FF00
|
147
|
+
eors \x0, \x0, \t
|
148
|
+
eor \x0, \x0, \t, LSL #8
|
149
|
+
|
150
|
+
eor \t, \x0, \x0, LSR #4 @// t = (x0 ^ (x0 >> 4)) & 0x00F000F0UL@ x0 = x0 ^ t ^ (t << 4)@
|
151
|
+
and \t, #0x00F000F0
|
152
|
+
eors \x0, \x0, \t
|
153
|
+
eor \x0, \x0, \t, LSL #4
|
154
|
+
|
155
|
+
eor \t, \x0, \x0, LSR #2 @// t = (x0 ^ (x0 >> 2)) & 0x0C0C0C0CUL@ x0 = x0 ^ t ^ (t << 2)@
|
156
|
+
and \t, #0x0C0C0C0C
|
157
|
+
eors \x0, \x0, \t
|
158
|
+
eor \x0, \x0, \t, LSL #2
|
159
|
+
|
160
|
+
eor \t, \x0, \x0, LSR #1 @// t = (x0 ^ (x0 >> 1)) & 0x22222222UL@ x0 = x0 ^ t ^ (t << 1)@
|
161
|
+
and \t, #0x22222222
|
162
|
+
eors \x0, \x0, \t
|
163
|
+
eor \x0, \x0, \t, LSL #1
|
164
|
+
|
165
|
+
eor \t, \x1, \x1, LSR #8 @// t = (x1 ^ (x1 >> 8)) & 0x0000FF00UL@ x1 = x1 ^ t ^ (t << 8)@
|
166
|
+
and \t, #0x0000FF00
|
167
|
+
eors \x1, \x1, \t
|
168
|
+
eor \x1, \x1, \t, LSL #8
|
169
|
+
|
170
|
+
eor \t, \x1, \x1, LSR #4 @// t = (x1 ^ (x1 >> 4)) & 0x00F000F0UL@ x1 = x1 ^ t ^ (t << 4)@
|
171
|
+
and \t, #0x00F000F0
|
172
|
+
eors \x1, \x1, \t
|
173
|
+
eor \x1, \x1, \t, LSL #4
|
174
|
+
|
175
|
+
eor \t, \x1, \x1, LSR #2 @// t = (x1 ^ (x1 >> 2)) & 0x0C0C0C0CUL@ x1 = x1 ^ t ^ (t << 2)@
|
176
|
+
and \t, #0x0C0C0C0C
|
177
|
+
eors \x1, \x1, \t
|
178
|
+
eor \x1, \x1, \t, LSL #2
|
179
|
+
|
180
|
+
eor \t, \x1, \x1, LSR #1 @// t = (x1 ^ (x1 >> 1)) & 0x22222222UL@ x1 = x1 ^ t ^ (t << 1)@
|
181
|
+
and \t, #0x22222222
|
182
|
+
eors \x1, \x1, \t
|
183
|
+
eor \x1, \x1, \t, LSL #1
|
184
|
+
.endm
|
185
|
+
|
186
|
+
.macro xor5 result,b,g,k,m,s
|
187
|
+
|
188
|
+
ldr \result, [sp, #\b]
|
189
|
+
ldr r1, [sp, #\g]
|
190
|
+
ldr r2, [sp, #\k]
|
191
|
+
eors \result, \result, r1
|
192
|
+
ldr r1, [sp, #\m]
|
193
|
+
eors \result, \result, r2
|
194
|
+
ldr r2, [sp, #\s]
|
195
|
+
eors \result, \result, r1
|
196
|
+
eors \result, \result, r2
|
197
|
+
.endm
|
198
|
+
|
199
|
+
.macro xorrol result, aa, bb
|
200
|
+
|
201
|
+
eor \result, \aa, \bb, ROR #31
|
202
|
+
.endm
|
203
|
+
|
204
|
+
|
205
|
+
.macro xandnot resofs, aa, bb, cc
|
206
|
+
|
207
|
+
bic r1, \cc, \bb
|
208
|
+
eors r1, r1, \aa
|
209
|
+
str r1, [sp, #\resofs]
|
210
|
+
.endm
|
211
|
+
|
212
|
+
.macro KeccakThetaRhoPiChiIota aA1, aDax, aA2, aDex, rot2, aA3, aDix, rot3, aA4, aDox, rot4, aA5, aDux, rot5, offset, last
|
213
|
+
ldr r3, [sp, #\aA1]
|
214
|
+
ldr r4, [sp, #\aA2]
|
215
|
+
ldr r5, [sp, #\aA3]
|
216
|
+
ldr r6, [sp, #\aA4]
|
217
|
+
ldr r7, [sp, #\aA5]
|
218
|
+
eors r3, r3, \aDax
|
219
|
+
eors r5, r5, \aDix
|
220
|
+
eors r4, r4, \aDex
|
221
|
+
eors r6, r6, \aDox
|
222
|
+
eors r7, r7, \aDux
|
223
|
+
rors r4, #32-\rot2
|
224
|
+
rors r5, #32-\rot3
|
225
|
+
rors r6, #32-\rot4
|
226
|
+
rors r7, #32-\rot5
|
227
|
+
xandnot \aA2, r4, r5, r6
|
228
|
+
xandnot \aA3, r5, r6, r7
|
229
|
+
xandnot \aA4, r6, r7, r3
|
230
|
+
xandnot \aA5, r7, r3, r4
|
231
|
+
ldr r1, [sp, #mRC]
|
232
|
+
bics r5, r5, r4
|
233
|
+
ldr r4, [r1, #\offset]
|
234
|
+
eors r3, r3, r5
|
235
|
+
eors r3, r3, r4
|
236
|
+
.if \last == 1
|
237
|
+
ldr r2, [r1, #32]!
|
238
|
+
str r1, [sp, #mRC]
|
239
|
+
cmp r2, #0xFFFFFFFF
|
240
|
+
.endif
|
241
|
+
str r3, [sp, #\aA1]
|
242
|
+
.endm
|
243
|
+
|
244
|
+
.macro KeccakThetaRhoPiChi aB1, aA1, aDax, rot1, aB2, aA2, aDex, rot2, aB3, aA3, aDix, rot3, aB4, aA4, aDox, rot4, aB5, aA5, aDux, rot5
|
245
|
+
ldr \aB1, [sp, #\aA1]
|
246
|
+
ldr \aB2, [sp, #\aA2]
|
247
|
+
ldr \aB3, [sp, #\aA3]
|
248
|
+
ldr \aB4, [sp, #\aA4]
|
249
|
+
ldr \aB5, [sp, #\aA5]
|
250
|
+
eors \aB1, \aB1, \aDax
|
251
|
+
eors \aB3, \aB3, \aDix
|
252
|
+
eors \aB2, \aB2, \aDex
|
253
|
+
eors \aB4, \aB4, \aDox
|
254
|
+
eors \aB5, \aB5, \aDux
|
255
|
+
rors \aB1, #32-\rot1
|
256
|
+
.if \rot2 > 0
|
257
|
+
rors \aB2, #32-\rot2
|
258
|
+
.endif
|
259
|
+
rors \aB3, #32-\rot3
|
260
|
+
rors \aB4, #32-\rot4
|
261
|
+
rors \aB5, #32-\rot5
|
262
|
+
xandnot \aA1, r3, r4, r5
|
263
|
+
xandnot \aA2, r4, r5, r6
|
264
|
+
xandnot \aA3, r5, r6, r7
|
265
|
+
xandnot \aA4, r6, r7, r3
|
266
|
+
xandnot \aA5, r7, r3, r4
|
267
|
+
.endm
|
268
|
+
|
269
|
+
.macro KeccakRound0
|
270
|
+
|
271
|
+
xor5 r3, Abu0, Agu0, Aku0, Amu0, Asu0
|
272
|
+
xor5 r7, Abe1, Age1, Ake1, Ame1, Ase1
|
273
|
+
xorrol r8, r3, r7
|
274
|
+
xor5 r6, Abu1, Agu1, Aku1, Amu1, Asu1
|
275
|
+
xor5 r12, Abe0, Age0, Ake0, Ame0, Ase0
|
276
|
+
eor r9, r6, r12
|
277
|
+
|
278
|
+
xor5 r5, Abi0, Agi0, Aki0, Ami0, Asi0
|
279
|
+
xorrol r0, r5, r6
|
280
|
+
xor5 r4, Abi1, Agi1, Aki1, Ami1, Asi1
|
281
|
+
eor r11, r4, r3
|
282
|
+
str r0, [sp, #mDo0]
|
283
|
+
str r11, [sp, #mDo1]
|
284
|
+
|
285
|
+
xor5 r3, Aba0, Aga0, Aka0, Ama0, Asa0
|
286
|
+
xorrol r10, r3, r4
|
287
|
+
xor5 r6, Aba1, Aga1, Aka1, Ama1, Asa1
|
288
|
+
eor r11, r6, r5
|
289
|
+
|
290
|
+
xor5 r4, Abo1, Ago1, Ako1, Amo1, Aso1
|
291
|
+
xorrol r12, r12, r4
|
292
|
+
xor5 r5, Abo0, Ago0, Ako0, Amo0, Aso0
|
293
|
+
eor r2, r7, r5
|
294
|
+
str r12, [sp, #mDi0]
|
295
|
+
|
296
|
+
xorrol r12, r5, r6
|
297
|
+
eor lr, r4, r3
|
298
|
+
|
299
|
+
KeccakThetaRhoPiChi r5, Aka1, r9, 2, r6, Ame1, r11, 23, r7, Asi1, r2, 31, r3, Abo0, r0, 14, r4, Agu0, r12, 10
|
300
|
+
KeccakThetaRhoPiChi r7, Asa1, r9, 9, r3, Abe0, r10, 0, r4, Agi1, r2, 3, r5, Ako0, r0, 12, r6, Amu1, lr, 4
|
301
|
+
KeccakThetaRhoPiChi r4, Aga0, r8, 18, r5, Ake0, r10, 5, r6, Ami1, r2, 8, r7, Aso0, r0, 28, r3, Abu1, lr, 14
|
302
|
+
KeccakThetaRhoPiChi r6, Ama0, r8, 20, r7, Ase1, r11, 1, r3, Abi1, r2, 31, r4, Ago0, r0, 27, r5, Aku0, r12, 19
|
303
|
+
ldr r0, [sp, #mDo1]
|
304
|
+
KeccakThetaRhoPiChiIota Aba0, r8, Age0, r10, 22, Aki1, r2, 22, Amo1, r0, 11, Asu0, r12, 7, 0, 0
|
305
|
+
|
306
|
+
ldr r2, [sp, #mDi0]
|
307
|
+
KeccakThetaRhoPiChi r5, Aka0, r8, 1, r6, Ame0, r10, 22, r7, Asi0, r2, 30, r3, Abo1, r0, 14, r4, Agu1, lr, 10
|
308
|
+
KeccakThetaRhoPiChi r7, Asa0, r8, 9, r3, Abe1, r11, 1, r4, Agi0, r2, 3, r5, Ako1, r0, 13, r6, Amu0, r12, 4
|
309
|
+
KeccakThetaRhoPiChi r4, Aga1, r9, 18, r5, Ake1, r11, 5, r6, Ami0, r2, 7, r7, Aso1, r0, 28, r3, Abu0, r12, 13
|
310
|
+
KeccakThetaRhoPiChi r6, Ama1, r9, 21, r7, Ase0, r10, 1, r3, Abi0, r2, 31, r4, Ago1, r0, 28, r5, Aku1, lr, 20
|
311
|
+
ldr r0, [sp, #mDo0]
|
312
|
+
KeccakThetaRhoPiChiIota Aba1, r9, Age1, r11, 22, Aki0, r2, 21, Amo0, r0, 10, Asu1, lr, 7, 4, 0
|
313
|
+
.endm
|
314
|
+
|
315
|
+
.macro KeccakRound1
|
316
|
+
|
317
|
+
xor5 r3, Asu0, Agu0, Amu0, Abu1, Aku1
|
318
|
+
xor5 r7, Age1, Ame0, Abe0, Ake1, Ase1
|
319
|
+
xorrol r8, r3, r7
|
320
|
+
xor5 r6, Asu1, Agu1, Amu1, Abu0, Aku0
|
321
|
+
xor5 r12, Age0, Ame1, Abe1, Ake0, Ase0
|
322
|
+
eor r9, r6, r12
|
323
|
+
|
324
|
+
xor5 r5, Aki1, Asi1, Agi0, Ami1, Abi0
|
325
|
+
xorrol r0, r5, r6
|
326
|
+
xor5 r4, Aki0, Asi0, Agi1, Ami0, Abi1
|
327
|
+
eor r11, r4, r3
|
328
|
+
str r0, [sp, #mDo0]
|
329
|
+
str r11, [sp, #mDo1]
|
330
|
+
|
331
|
+
xor5 r3, Aba0, Aka1, Asa0, Aga0, Ama1
|
332
|
+
xorrol r10, r3, r4
|
333
|
+
xor5 r6, Aba1, Aka0, Asa1, Aga1, Ama0
|
334
|
+
eor r11, r6, r5
|
335
|
+
|
336
|
+
xor5 r4, Amo0, Abo1, Ako0, Aso1, Ago0
|
337
|
+
xorrol r12, r12, r4
|
338
|
+
xor5 r5, Amo1, Abo0, Ako1, Aso0, Ago1
|
339
|
+
eor r2, r7, r5
|
340
|
+
str r12, [sp, #mDi0]
|
341
|
+
|
342
|
+
xorrol r12, r5, r6
|
343
|
+
eor lr, r4, r3
|
344
|
+
|
345
|
+
KeccakThetaRhoPiChi r5, Asa1, r9, 2, r6, Ake1, r11, 23, r7, Abi1, r2, 31, r3, Amo1, r0, 14, r4, Agu0, r12, 10
|
346
|
+
KeccakThetaRhoPiChi r7, Ama0, r9, 9, r3, Age0, r10, 0, r4, Asi0, r2, 3, r5, Ako1, r0, 12, r6, Abu0, lr, 4
|
347
|
+
KeccakThetaRhoPiChi r4, Aka1, r8, 18, r5, Abe1, r10, 5, r6, Ami0, r2, 8, r7, Ago1, r0, 28, r3, Asu1, lr, 14
|
348
|
+
KeccakThetaRhoPiChi r6, Aga0, r8, 20, r7, Ase1, r11, 1, r3, Aki0, r2, 31, r4, Abo0, r0, 27, r5, Amu0, r12, 19
|
349
|
+
ldr r0, [sp, #mDo1]
|
350
|
+
KeccakThetaRhoPiChiIota Aba0, r8, Ame1, r10, 22, Agi1, r2, 22, Aso1, r0, 11, Aku1, r12, 7, 8, 0
|
351
|
+
|
352
|
+
ldr r2, [sp, #mDi0]
|
353
|
+
KeccakThetaRhoPiChi r5, Asa0, r8, 1, r6, Ake0, r10, 22, r7, Abi0, r2, 30, r3, Amo0, r0, 14, r4, Agu1, lr, 10
|
354
|
+
KeccakThetaRhoPiChi r7, Ama1, r8, 9, r3, Age1, r11, 1, r4, Asi1, r2, 3, r5, Ako0, r0, 13, r6, Abu1, r12, 4
|
355
|
+
KeccakThetaRhoPiChi r4, Aka0, r9, 18, r5, Abe0, r11, 5, r6, Ami1, r2, 7, r7, Ago0, r0, 28, r3, Asu0, r12, 13
|
356
|
+
KeccakThetaRhoPiChi r6, Aga1, r9, 21, r7, Ase0, r10, 1, r3, Aki1, r2, 31, r4, Abo1, r0, 28, r5, Amu1, lr, 20
|
357
|
+
ldr r0, [sp, #mDo0]
|
358
|
+
KeccakThetaRhoPiChiIota Aba1, r9, Ame0, r11, 22, Agi0, r2, 21, Aso0, r0, 10, Aku0, lr, 7, 12, 0
|
359
|
+
.endm
|
360
|
+
|
361
|
+
.macro KeccakRound2
|
362
|
+
|
363
|
+
xor5 r3, Aku1, Agu0, Abu1, Asu1, Amu1
|
364
|
+
xor5 r7, Ame0, Ake0, Age0, Abe0, Ase1
|
365
|
+
xorrol r8, r3, r7
|
366
|
+
xor5 r6, Aku0, Agu1, Abu0, Asu0, Amu0
|
367
|
+
xor5 r12, Ame1, Ake1, Age1, Abe1, Ase0
|
368
|
+
eor r9, r6, r12
|
369
|
+
|
370
|
+
xor5 r5, Agi1, Abi1, Asi1, Ami0, Aki1
|
371
|
+
xorrol r0, r5, r6
|
372
|
+
xor5 r4, Agi0, Abi0, Asi0, Ami1, Aki0
|
373
|
+
eor r11, r4, r3
|
374
|
+
str r0, [sp, #mDo0]
|
375
|
+
str r11, [sp, #mDo1]
|
376
|
+
|
377
|
+
xor5 r3, Aba0, Asa1, Ama1, Aka1, Aga1
|
378
|
+
xorrol r10, r3, r4
|
379
|
+
xor5 r6, Aba1, Asa0, Ama0, Aka0, Aga0
|
380
|
+
eor r11, r6, r5
|
381
|
+
|
382
|
+
xor5 r4, Aso0, Amo0, Ako1, Ago0, Abo0
|
383
|
+
xorrol r12, r12, r4
|
384
|
+
xor5 r5, Aso1, Amo1, Ako0, Ago1, Abo1
|
385
|
+
eor r2, r7, r5
|
386
|
+
str r12, [sp, #mDi0]
|
387
|
+
|
388
|
+
xorrol r12, r5, r6
|
389
|
+
eor lr, r4, r3
|
390
|
+
|
391
|
+
KeccakThetaRhoPiChi r5, Ama0, r9, 2, r6, Abe0, r11, 23, r7, Aki0, r2, 31, r3, Aso1, r0, 14, r4, Agu0, r12, 10
|
392
|
+
KeccakThetaRhoPiChi r7, Aga0, r9, 9, r3, Ame1, r10, 0, r4, Abi0, r2, 3, r5, Ako0, r0, 12, r6, Asu0, lr, 4
|
393
|
+
KeccakThetaRhoPiChi r4, Asa1, r8, 18, r5, Age1, r10, 5, r6, Ami1, r2, 8, r7, Abo1, r0, 28, r3, Aku0, lr, 14
|
394
|
+
KeccakThetaRhoPiChi r6, Aka1, r8, 20, r7, Ase1, r11, 1, r3, Agi0, r2, 31, r4, Amo1, r0, 27, r5, Abu1, r12, 19
|
395
|
+
ldr r0, [sp, #mDo1]
|
396
|
+
KeccakThetaRhoPiChiIota Aba0, r8, Ake1, r10, 22, Asi0, r2, 22, Ago0, r0, 11, Amu1, r12, 7, 16, 0
|
397
|
+
|
398
|
+
ldr r2, [sp, #mDi0]
|
399
|
+
KeccakThetaRhoPiChi r5, Ama1, r8, 1, r6, Abe1, r10, 22, r7, Aki1, r2, 30, r3, Aso0, r0, 14, r4, Agu1, lr, 10
|
400
|
+
KeccakThetaRhoPiChi r7, Aga1, r8, 9, r3, Ame0, r11, 1, r4, Abi1, r2, 3, r5, Ako1, r0, 13, r6, Asu1, r12, 4
|
401
|
+
KeccakThetaRhoPiChi r4, Asa0, r9, 18, r5, Age0, r11, 5, r6, Ami0, r2, 7, r7, Abo0, r0, 28, r3, Aku1, r12, 13
|
402
|
+
KeccakThetaRhoPiChi r6, Aka0, r9, 21, r7, Ase0, r10, 1, r3, Agi1, r2, 31, r4, Amo0, r0, 28, r5, Abu0, lr, 20
|
403
|
+
ldr r0, [sp, #mDo0]
|
404
|
+
KeccakThetaRhoPiChiIota Aba1, r9, Ake0, r11, 22, Asi1, r2, 21, Ago1, r0, 10, Amu0, lr, 7, 20, 0
|
405
|
+
.endm
|
406
|
+
|
407
|
+
.macro KeccakRound3
|
408
|
+
|
409
|
+
xor5 r3, Amu1, Agu0, Asu1, Aku0, Abu0
|
410
|
+
xor5 r7, Ake0, Abe1, Ame1, Age0, Ase1
|
411
|
+
xorrol r8, r3, r7
|
412
|
+
xor5 r6, Amu0, Agu1, Asu0, Aku1, Abu1
|
413
|
+
xor5 r12, Ake1, Abe0, Ame0, Age1, Ase0
|
414
|
+
eor r9, r6, r12
|
415
|
+
|
416
|
+
xor5 r5, Asi0, Aki0, Abi1, Ami1, Agi1
|
417
|
+
xorrol r0, r5, r6
|
418
|
+
xor5 r4, Asi1, Aki1, Abi0, Ami0, Agi0
|
419
|
+
eor r11, r4, r3
|
420
|
+
str r0, [sp, #mDo0]
|
421
|
+
str r11, [sp, #mDo1]
|
422
|
+
|
423
|
+
xor5 r3, Aba0, Ama0, Aga1, Asa1, Aka0
|
424
|
+
xorrol r10, r3, r4
|
425
|
+
xor5 r6, Aba1, Ama1, Aga0, Asa0, Aka1
|
426
|
+
eor r11, r6, r5
|
427
|
+
|
428
|
+
xor5 r4, Ago1, Aso0, Ako0, Abo0, Amo1
|
429
|
+
xorrol r12, r12, r4
|
430
|
+
xor5 r5, Ago0, Aso1, Ako1, Abo1, Amo0
|
431
|
+
eor r2, r7, r5
|
432
|
+
str r12, [sp, #mDi0]
|
433
|
+
|
434
|
+
xorrol r12, r5, r6
|
435
|
+
eor lr, r4, r3
|
436
|
+
|
437
|
+
KeccakThetaRhoPiChi r5, Aga0, r9, 2, r6, Age0, r11, 23, r7, Agi0, r2, 31, r3, Ago0, r0, 14, r4, Agu0, r12, 10
|
438
|
+
KeccakThetaRhoPiChi r7, Aka1, r9, 9, r3, Ake1, r10, 0, r4, Aki1, r2, 3, r5, Ako1, r0, 12, r6, Aku1, lr, 4
|
439
|
+
KeccakThetaRhoPiChi r4, Ama0, r8, 18, r5, Ame0, r10, 5, r6, Ami0, r2, 8, r7, Amo0, r0, 28, r3, Amu0, lr, 14
|
440
|
+
KeccakThetaRhoPiChi r6, Asa1, r8, 20, r7, Ase1, r11, 1, r3, Asi1, r2, 31, r4, Aso1, r0, 27, r5, Asu1, r12, 19
|
441
|
+
ldr r0, [sp, #mDo1]
|
442
|
+
KeccakThetaRhoPiChiIota Aba0, r8, Abe0, r10, 22, Abi0, r2, 22, Abo0, r0, 11, Abu0, r12, 7, 24, 0
|
443
|
+
|
444
|
+
ldr r2, [sp, #mDi0]
|
445
|
+
KeccakThetaRhoPiChi r5, Aga1, r8, 1, r6, Age1, r10, 22, r7, Agi1, r2, 30, r3, Ago1, r0, 14, r4, Agu1, lr, 10
|
446
|
+
KeccakThetaRhoPiChi r7, Aka0, r8, 9, r3, Ake0, r11, 1, r4, Aki0, r2, 3, r5, Ako0, r0, 13, r6, Aku0, r12, 4
|
447
|
+
KeccakThetaRhoPiChi r4, Ama1, r9, 18, r5, Ame1, r11, 5, r6, Ami1, r2, 7, r7, Amo1, r0, 28, r3, Amu1, r12, 13
|
448
|
+
KeccakThetaRhoPiChi r6, Asa0, r9, 21, r7, Ase0, r10, 1, r3, Asi0, r2, 31, r4, Aso0, r0, 28, r5, Asu0, lr, 20
|
449
|
+
ldr r0, [sp, #mDo0]
|
450
|
+
KeccakThetaRhoPiChiIota Aba1, r9, Abe1, r11, 22, Abi1, r2, 21, Abo1, r0, 10, Abu1, lr, 7, 28, 1
|
451
|
+
.endm
|
452
|
+
|
453
|
+
@// --- code and constants
|
454
|
+
|
455
|
+
@//int crypto_hash( unsigned char *out, const unsigned char *in, unsigned long long inlen )
|
456
|
+
@// .size ???
|
457
|
+
.align 2
|
458
|
+
.global crypto_hash @// populate.py, please update crypto_hash
|
459
|
+
.thumb
|
460
|
+
.thumb_func
|
461
|
+
.type crypto_hash, %function @// populate.py, please update crypto_hash
|
462
|
+
crypto_hash: @ @// populate.py, please update crypto_hash
|
463
|
+
|
464
|
+
push {r4-r12,lr}
|
465
|
+
subs sp, sp, #8*4
|
466
|
+
|
467
|
+
@//allocate and clear state
|
468
|
+
movs r3, #0
|
469
|
+
movs r4, r3
|
470
|
+
movs r5, r3
|
471
|
+
movs r6, r3
|
472
|
+
movs r7, r3
|
473
|
+
push {r3-r7}
|
474
|
+
push {r3-r7}
|
475
|
+
push {r3-r7}
|
476
|
+
push {r3-r7}
|
477
|
+
push {r3-r7}
|
478
|
+
push {r3-r7}
|
479
|
+
push {r3-r7}
|
480
|
+
push {r3-r7}
|
481
|
+
push {r3-r7}
|
482
|
+
push {r3-r7}
|
483
|
+
|
484
|
+
str r0, [sp, #mOut] @// save out pointer
|
485
|
+
str r1, [sp, #mIn] @// save in pointer
|
486
|
+
|
487
|
+
@// Complete rate loop
|
488
|
+
subs r4, r2, #cKeccakR_SizeInBytes
|
489
|
+
bcc crypto_hash_LoopEnd
|
490
|
+
|
491
|
+
ldr r0, =crypto_hash_LoopRet+1
|
492
|
+
str r0, [sp, #mRet] @// save return address
|
493
|
+
crypto_hash_Loop:
|
494
|
+
ldr r0, =KeccakF1600RoundConstantsWithTerminator
|
495
|
+
str r4, [sp, #mLen] @// save inlen (ignore upper 32-bit word, since CPU address space is only 32-bit wide)
|
496
|
+
str r0, [sp, #mRC] @// save Round Constants pointer
|
497
|
+
mov r2, #cKeccakR_SizeInBytes/cKeccakLaneSizeInBytes
|
498
|
+
b KeccakF_FullRate
|
499
|
+
crypto_hash_LoopRet:
|
500
|
+
ldr r2, [sp, #mLen] @// save inlen (ignore upper 32-bit word, since CPU address space is only 32-bit wide)
|
501
|
+
subs r4, r2, #cKeccakR_SizeInBytes
|
502
|
+
bcs crypto_hash_Loop
|
503
|
+
crypto_hash_LoopEnd:
|
504
|
+
|
505
|
+
@// Last incomplete lane and padding
|
506
|
+
mov r4, r2, LSR #3 @// r4 nbrFullLanes = len >> 3@
|
507
|
+
and r6, r2, #7 @// r6 len &= 7@ length last incomplete lane
|
508
|
+
|
509
|
+
movs r0, #1 @// XOR first padding bit into state: state[nbrFullLanes << 1] ^= 1 << (len * 4)@
|
510
|
+
mov r1, r6, LSL #2
|
511
|
+
lsls r0, r0, r1
|
512
|
+
ldr r1, [sp, r4, LSL #3]
|
513
|
+
eors r1, r1, r0
|
514
|
+
str r1, [sp, r4, LSL #3]
|
515
|
+
|
516
|
+
@// XOR last incomplete lane if needed
|
517
|
+
ldr r3, [sp, #mIn] @// get in pointer
|
518
|
+
add r3, r3, r4, LSL #3 @// p = in + nbrFullLanes << 3@
|
519
|
+
tbb [pc, r6]
|
520
|
+
crypto_hash_leftBranchTab:
|
521
|
+
.byte (crypto_hash_0left-crypto_hash_leftBranchTab)/2
|
522
|
+
.byte (crypto_hash_1left-crypto_hash_leftBranchTab)/2
|
523
|
+
.byte (crypto_hash_2left-crypto_hash_leftBranchTab)/2
|
524
|
+
.byte (crypto_hash_3left-crypto_hash_leftBranchTab)/2
|
525
|
+
.byte (crypto_hash_4left-crypto_hash_leftBranchTab)/2
|
526
|
+
.byte (crypto_hash_5left-crypto_hash_leftBranchTab)/2
|
527
|
+
.byte (crypto_hash_6left-crypto_hash_leftBranchTab)/2
|
528
|
+
.byte (crypto_hash_7left-crypto_hash_leftBranchTab)/2
|
529
|
+
|
530
|
+
crypto_hash_0left:
|
531
|
+
b crypto_hash_IncompleteDone
|
532
|
+
crypto_hash_1left:
|
533
|
+
ldrb r0, [r3]
|
534
|
+
movs r1, #0 @// x1 = 0
|
535
|
+
b crypto_hash_Interleave
|
536
|
+
crypto_hash_2left:
|
537
|
+
ldrh r0, [r3]
|
538
|
+
movs r1, #0 @// x1 = 0
|
539
|
+
b crypto_hash_Interleave
|
540
|
+
crypto_hash_3left:
|
541
|
+
ldrh r0, [r3]
|
542
|
+
ldrb r1, [r3, #2]
|
543
|
+
orr r0, r0, r1, LSL #16
|
544
|
+
movs r1, #0 @// x1 = 0
|
545
|
+
b crypto_hash_Interleave
|
546
|
+
crypto_hash_4left:
|
547
|
+
ldr r0, [r3]
|
548
|
+
movs r1, #0 @// x1 = 0
|
549
|
+
b crypto_hash_Interleave
|
550
|
+
crypto_hash_5left:
|
551
|
+
ldr r0, [r3]
|
552
|
+
ldrb r1, [r3, #4]
|
553
|
+
b crypto_hash_Interleave
|
554
|
+
crypto_hash_6left:
|
555
|
+
ldr r0, [r3]
|
556
|
+
ldrh r1, [r3, #4]
|
557
|
+
b crypto_hash_Interleave
|
558
|
+
crypto_hash_7left:
|
559
|
+
ldrh r1, [r3, #4]
|
560
|
+
ldrb r0, [r3, #6]
|
561
|
+
orr r1, r1, r0, LSL #16
|
562
|
+
ldr r0, [r3]
|
563
|
+
|
564
|
+
crypto_hash_Interleave:
|
565
|
+
add r8, sp, r4, LSL #3
|
566
|
+
ldrd r2, r3, [r8]
|
567
|
+
interleaveLane r0, r1, r2, r3, r6
|
568
|
+
strd r2, r3, [r8]
|
569
|
+
crypto_hash_IncompleteDone:
|
570
|
+
ldr r0, [sp, #cKeccakR_SizeInBytes-4] @// XOR second padding bit into state
|
571
|
+
eor r0, #0x80000000
|
572
|
+
str r0, [sp, #cKeccakR_SizeInBytes-4]
|
573
|
+
|
574
|
+
ldr r0, =crypto_hash_SqueezeRet+1
|
575
|
+
str r0, [sp, #mRet] @// save return address
|
576
|
+
ldr r0, =KeccakF1600RoundConstantsWithTerminator
|
577
|
+
str r0, [sp, #mRC] @// save Round Constants pointer
|
578
|
+
movs r2, r4
|
579
|
+
b KeccakF
|
580
|
+
crypto_hash_SqueezeRet:
|
581
|
+
|
582
|
+
ldr r7, [sp, #mOut] @// save return address
|
583
|
+
movs r4, #crypto_hash_BYTES/cKeccakLaneSizeInBytes @len = crypto_hash_BYTES / cKeccakLaneSizeInBytes@
|
584
|
+
mov r3, sp
|
585
|
+
crypto_hash_OutputLoop:
|
586
|
+
ldrd r0, r1, [r3], #8
|
587
|
+
uninterleaveLane r0, r1, r2
|
588
|
+
str r0, [r7], #4
|
589
|
+
str r1, [r7], #4
|
590
|
+
subs r4, r4, #1
|
591
|
+
bne crypto_hash_OutputLoop
|
592
|
+
|
593
|
+
adds sp, sp, #5*5*2*4+8*4
|
594
|
+
movs r0, #0
|
595
|
+
pop {r4-r12,pc}
|
596
|
+
@ nop @// pad for alignment
|
597
|
+
|
598
|
+
@ ALIGN
|
599
|
+
.ltorg
|
600
|
+
KeccakF1600RoundConstantsWithTerminator:
|
601
|
+
.word 0x00000001
|
602
|
+
.word 0x00000000
|
603
|
+
.word 0x00000000
|
604
|
+
.word 0x00000089
|
605
|
+
.word 0x00000000
|
606
|
+
.word 0x8000008b
|
607
|
+
.word 0x00000000
|
608
|
+
.word 0x80008080
|
609
|
+
|
610
|
+
.word 0x00000001
|
611
|
+
.word 0x0000008b
|
612
|
+
.word 0x00000001
|
613
|
+
.word 0x00008000
|
614
|
+
.word 0x00000001
|
615
|
+
.word 0x80008088
|
616
|
+
.word 0x00000001
|
617
|
+
.word 0x80000082
|
618
|
+
|
619
|
+
.word 0x00000000
|
620
|
+
.word 0x0000000b
|
621
|
+
.word 0x00000000
|
622
|
+
.word 0x0000000a
|
623
|
+
.word 0x00000001
|
624
|
+
.word 0x00008082
|
625
|
+
.word 0x00000000
|
626
|
+
.word 0x00008003
|
627
|
+
|
628
|
+
.word 0x00000001
|
629
|
+
.word 0x0000808b
|
630
|
+
.word 0x00000001
|
631
|
+
.word 0x8000000b
|
632
|
+
.word 0x00000001
|
633
|
+
.word 0x8000008a
|
634
|
+
.word 0x00000001
|
635
|
+
.word 0x80000081
|
636
|
+
|
637
|
+
.word 0x00000000
|
638
|
+
.word 0x80000081
|
639
|
+
.word 0x00000000
|
640
|
+
.word 0x80000008
|
641
|
+
.word 0x00000000
|
642
|
+
.word 0x00000083
|
643
|
+
.word 0x00000000
|
644
|
+
.word 0x80008003
|
645
|
+
|
646
|
+
.word 0x00000001
|
647
|
+
.word 0x80008088
|
648
|
+
.word 0x00000000
|
649
|
+
.word 0x80000088
|
650
|
+
.word 0x00000001
|
651
|
+
.word 0x00008000
|
652
|
+
.word 0x00000000
|
653
|
+
.word 0x80008082
|
654
|
+
|
655
|
+
.word 0xFFFFFFFF @//terminator
|
656
|
+
|
657
|
+
@
|
658
|
+
|
659
|
+
@ ALIGN
|
660
|
+
|
661
|
+
KeccakF:
|
662
|
+
cmp r2, #0
|
663
|
+
beq roundLoop
|
664
|
+
KeccakF_FullRate:
|
665
|
+
mov r8, sp
|
666
|
+
ldr r1, [sp, #mIn]
|
667
|
+
interleaveLoop:
|
668
|
+
ldr r4, [r1], #4
|
669
|
+
ldr r5, [r1], #4
|
670
|
+
ldrd r6, r7, [r8]
|
671
|
+
interleaveLane r4, r5, r6, r7, r3
|
672
|
+
strd r6,r7,[r8], #8
|
673
|
+
subs r2, r2, #1
|
674
|
+
bne interleaveLoop
|
675
|
+
str r1, [sp, #mIn]
|
676
|
+
|
677
|
+
roundLoop:
|
678
|
+
KeccakRound0
|
679
|
+
KeccakRound1
|
680
|
+
KeccakRound2
|
681
|
+
KeccakRound3
|
682
|
+
bne roundLoop
|
683
|
+
ldr pc, [sp, #mRet]
|
684
|
+
|
685
|
+
@
|
686
|
+
@ ALIGN
|
687
|
+
|