rbnacl-libsodium 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/ChangeLog +25 -0
- data/vendor/libsodium/Makefile.in +1 -1
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +16 -16
- data/vendor/libsodium/autom4te.cache/output.5 +16 -16
- data/vendor/libsodium/autom4te.cache/requests +894 -894
- data/vendor/libsodium/autom4te.cache/traces.1 +4 -4
- data/vendor/libsodium/autom4te.cache/traces.5 +2 -2
- data/vendor/libsodium/builds/msvc/version.h +3 -3
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +7 -3
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +21 -9
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +8 -4
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +21 -9
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +7 -3
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +21 -9
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +7 -3
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +21 -9
- data/vendor/libsodium/configure +16 -16
- data/vendor/libsodium/configure.ac +7 -7
- data/vendor/libsodium/dist-build/Makefile.in +1 -1
- data/vendor/libsodium/libsodium.sln +4 -2
- data/vendor/libsodium/libsodium.vcxproj +17 -13
- data/vendor/libsodium/libsodium.vcxproj.filters +22 -10
- data/vendor/libsodium/msvc-scripts/Makefile.in +1 -1
- data/vendor/libsodium/msvc-scripts/process.bat +3 -3
- data/vendor/libsodium/src/Makefile.in +1 -1
- data/vendor/libsodium/src/libsodium/Makefile.am +19 -7
- data/vendor/libsodium/src/libsodium/Makefile.in +85 -48
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +11 -3
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +20 -18
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +93 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +80 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +89 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +68 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +402 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +58 -102
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-round.h +123 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +15 -10
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +14 -14
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +18 -16
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.h +23 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +0 -3
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +6 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +5 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.in +1 -1
- data/vendor/libsodium/src/libsodium/include/sodium/core.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +5 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +5 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +3 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +15 -7
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +4 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +7 -30
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +8 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +7 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +5 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +6 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +14 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_16.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_32.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_64.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +10 -3
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +8 -4
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +7 -0
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +4 -2
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +12 -10
- data/vendor/libsodium/src/libsodium/sodium/core.c +4 -4
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +27 -1
- data/vendor/libsodium/src/libsodium/sodium/utils.c +4 -2
- data/vendor/libsodium/test/Makefile.in +1 -1
- data/vendor/libsodium/test/default/Makefile.in +1 -1
- data/vendor/libsodium/test/default/aead_aes256gcm.c +14 -0
- data/vendor/libsodium/test/default/box_easy2.c +13 -7
- data/vendor/libsodium/test/default/chacha20.c +36 -12
- data/vendor/libsodium/test/default/ed25519_convert.c +6 -2
- data/vendor/libsodium/test/default/generichash3.exp +1 -1
- data/vendor/libsodium/test/default/secretbox_easy2.c +5 -3
- data/vendor/libsodium/test/default/sodium_core.c +2 -0
- data/vendor/libsodium/test/default/sodium_utils.c +10 -4
- data/vendor/libsodium/test/default/sodium_utils2.c +1 -0
- data/vendor/libsodium/test/default/sodium_utils3.c +1 -0
- metadata +8 -22
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +0 -15
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +0 -13
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_verify/16/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_verify/32/checksum +0 -1
@@ -0,0 +1,402 @@
|
|
1
|
+
/*
|
2
|
+
BLAKE2 reference source code package - optimized C implementations
|
3
|
+
|
4
|
+
Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
|
5
|
+
|
6
|
+
To the extent possible under law, the author(s) have dedicated all copyright
|
7
|
+
and related and neighboring rights to this software to the public domain
|
8
|
+
worldwide. This software is distributed without any warranty.
|
9
|
+
|
10
|
+
You should have received a copy of the CC0 Public Domain Dedication along with
|
11
|
+
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef blake2b_load_sse41_H
|
15
|
+
#define blake2b_load_sse41_H
|
16
|
+
|
17
|
+
#define LOAD_MSG_0_1(b0, b1) \
|
18
|
+
do \
|
19
|
+
{ \
|
20
|
+
b0 = _mm_unpacklo_epi64(m0, m1); \
|
21
|
+
b1 = _mm_unpacklo_epi64(m2, m3); \
|
22
|
+
} while(0)
|
23
|
+
|
24
|
+
|
25
|
+
#define LOAD_MSG_0_2(b0, b1) \
|
26
|
+
do \
|
27
|
+
{ \
|
28
|
+
b0 = _mm_unpackhi_epi64(m0, m1); \
|
29
|
+
b1 = _mm_unpackhi_epi64(m2, m3); \
|
30
|
+
} while(0)
|
31
|
+
|
32
|
+
|
33
|
+
#define LOAD_MSG_0_3(b0, b1) \
|
34
|
+
do \
|
35
|
+
{ \
|
36
|
+
b0 = _mm_unpacklo_epi64(m4, m5); \
|
37
|
+
b1 = _mm_unpacklo_epi64(m6, m7); \
|
38
|
+
} while(0)
|
39
|
+
|
40
|
+
|
41
|
+
#define LOAD_MSG_0_4(b0, b1) \
|
42
|
+
do \
|
43
|
+
{ \
|
44
|
+
b0 = _mm_unpackhi_epi64(m4, m5); \
|
45
|
+
b1 = _mm_unpackhi_epi64(m6, m7); \
|
46
|
+
} while(0)
|
47
|
+
|
48
|
+
|
49
|
+
#define LOAD_MSG_1_1(b0, b1) \
|
50
|
+
do \
|
51
|
+
{ \
|
52
|
+
b0 = _mm_unpacklo_epi64(m7, m2); \
|
53
|
+
b1 = _mm_unpackhi_epi64(m4, m6); \
|
54
|
+
} while(0)
|
55
|
+
|
56
|
+
|
57
|
+
#define LOAD_MSG_1_2(b0, b1) \
|
58
|
+
do \
|
59
|
+
{ \
|
60
|
+
b0 = _mm_unpacklo_epi64(m5, m4); \
|
61
|
+
b1 = _mm_alignr_epi8(m3, m7, 8); \
|
62
|
+
} while(0)
|
63
|
+
|
64
|
+
|
65
|
+
#define LOAD_MSG_1_3(b0, b1) \
|
66
|
+
do \
|
67
|
+
{ \
|
68
|
+
b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \
|
69
|
+
b1 = _mm_unpackhi_epi64(m5, m2); \
|
70
|
+
} while(0)
|
71
|
+
|
72
|
+
|
73
|
+
#define LOAD_MSG_1_4(b0, b1) \
|
74
|
+
do \
|
75
|
+
{ \
|
76
|
+
b0 = _mm_unpacklo_epi64(m6, m1); \
|
77
|
+
b1 = _mm_unpackhi_epi64(m3, m1); \
|
78
|
+
} while(0)
|
79
|
+
|
80
|
+
|
81
|
+
#define LOAD_MSG_2_1(b0, b1) \
|
82
|
+
do \
|
83
|
+
{ \
|
84
|
+
b0 = _mm_alignr_epi8(m6, m5, 8); \
|
85
|
+
b1 = _mm_unpackhi_epi64(m2, m7); \
|
86
|
+
} while(0)
|
87
|
+
|
88
|
+
|
89
|
+
#define LOAD_MSG_2_2(b0, b1) \
|
90
|
+
do \
|
91
|
+
{ \
|
92
|
+
b0 = _mm_unpacklo_epi64(m4, m0); \
|
93
|
+
b1 = _mm_blend_epi16(m1, m6, 0xF0); \
|
94
|
+
} while(0)
|
95
|
+
|
96
|
+
|
97
|
+
#define LOAD_MSG_2_3(b0, b1) \
|
98
|
+
do \
|
99
|
+
{ \
|
100
|
+
b0 = _mm_blend_epi16(m5, m1, 0xF0); \
|
101
|
+
b1 = _mm_unpackhi_epi64(m3, m4); \
|
102
|
+
} while(0)
|
103
|
+
|
104
|
+
|
105
|
+
#define LOAD_MSG_2_4(b0, b1) \
|
106
|
+
do \
|
107
|
+
{ \
|
108
|
+
b0 = _mm_unpacklo_epi64(m7, m3); \
|
109
|
+
b1 = _mm_alignr_epi8(m2, m0, 8); \
|
110
|
+
} while(0)
|
111
|
+
|
112
|
+
|
113
|
+
#define LOAD_MSG_3_1(b0, b1) \
|
114
|
+
do \
|
115
|
+
{ \
|
116
|
+
b0 = _mm_unpackhi_epi64(m3, m1); \
|
117
|
+
b1 = _mm_unpackhi_epi64(m6, m5); \
|
118
|
+
} while(0)
|
119
|
+
|
120
|
+
|
121
|
+
#define LOAD_MSG_3_2(b0, b1) \
|
122
|
+
do \
|
123
|
+
{ \
|
124
|
+
b0 = _mm_unpackhi_epi64(m4, m0); \
|
125
|
+
b1 = _mm_unpacklo_epi64(m6, m7); \
|
126
|
+
} while(0)
|
127
|
+
|
128
|
+
|
129
|
+
#define LOAD_MSG_3_3(b0, b1) \
|
130
|
+
do \
|
131
|
+
{ \
|
132
|
+
b0 = _mm_blend_epi16(m1, m2, 0xF0); \
|
133
|
+
b1 = _mm_blend_epi16(m2, m7, 0xF0); \
|
134
|
+
} while(0)
|
135
|
+
|
136
|
+
|
137
|
+
#define LOAD_MSG_3_4(b0, b1) \
|
138
|
+
do \
|
139
|
+
{ \
|
140
|
+
b0 = _mm_unpacklo_epi64(m3, m5); \
|
141
|
+
b1 = _mm_unpacklo_epi64(m0, m4); \
|
142
|
+
} while(0)
|
143
|
+
|
144
|
+
|
145
|
+
#define LOAD_MSG_4_1(b0, b1) \
|
146
|
+
do \
|
147
|
+
{ \
|
148
|
+
b0 = _mm_unpackhi_epi64(m4, m2); \
|
149
|
+
b1 = _mm_unpacklo_epi64(m1, m5); \
|
150
|
+
} while(0)
|
151
|
+
|
152
|
+
|
153
|
+
#define LOAD_MSG_4_2(b0, b1) \
|
154
|
+
do \
|
155
|
+
{ \
|
156
|
+
b0 = _mm_blend_epi16(m0, m3, 0xF0); \
|
157
|
+
b1 = _mm_blend_epi16(m2, m7, 0xF0); \
|
158
|
+
} while(0)
|
159
|
+
|
160
|
+
|
161
|
+
#define LOAD_MSG_4_3(b0, b1) \
|
162
|
+
do \
|
163
|
+
{ \
|
164
|
+
b0 = _mm_blend_epi16(m7, m5, 0xF0); \
|
165
|
+
b1 = _mm_blend_epi16(m3, m1, 0xF0); \
|
166
|
+
} while(0)
|
167
|
+
|
168
|
+
|
169
|
+
#define LOAD_MSG_4_4(b0, b1) \
|
170
|
+
do \
|
171
|
+
{ \
|
172
|
+
b0 = _mm_alignr_epi8(m6, m0, 8); \
|
173
|
+
b1 = _mm_blend_epi16(m4, m6, 0xF0); \
|
174
|
+
} while(0)
|
175
|
+
|
176
|
+
|
177
|
+
#define LOAD_MSG_5_1(b0, b1) \
|
178
|
+
do \
|
179
|
+
{ \
|
180
|
+
b0 = _mm_unpacklo_epi64(m1, m3); \
|
181
|
+
b1 = _mm_unpacklo_epi64(m0, m4); \
|
182
|
+
} while(0)
|
183
|
+
|
184
|
+
|
185
|
+
#define LOAD_MSG_5_2(b0, b1) \
|
186
|
+
do \
|
187
|
+
{ \
|
188
|
+
b0 = _mm_unpacklo_epi64(m6, m5); \
|
189
|
+
b1 = _mm_unpackhi_epi64(m5, m1); \
|
190
|
+
} while(0)
|
191
|
+
|
192
|
+
|
193
|
+
#define LOAD_MSG_5_3(b0, b1) \
|
194
|
+
do \
|
195
|
+
{ \
|
196
|
+
b0 = _mm_blend_epi16(m2, m3, 0xF0); \
|
197
|
+
b1 = _mm_unpackhi_epi64(m7, m0); \
|
198
|
+
} while(0)
|
199
|
+
|
200
|
+
|
201
|
+
#define LOAD_MSG_5_4(b0, b1) \
|
202
|
+
do \
|
203
|
+
{ \
|
204
|
+
b0 = _mm_unpackhi_epi64(m6, m2); \
|
205
|
+
b1 = _mm_blend_epi16(m7, m4, 0xF0); \
|
206
|
+
} while(0)
|
207
|
+
|
208
|
+
|
209
|
+
#define LOAD_MSG_6_1(b0, b1) \
|
210
|
+
do \
|
211
|
+
{ \
|
212
|
+
b0 = _mm_blend_epi16(m6, m0, 0xF0); \
|
213
|
+
b1 = _mm_unpacklo_epi64(m7, m2); \
|
214
|
+
} while(0)
|
215
|
+
|
216
|
+
|
217
|
+
#define LOAD_MSG_6_2(b0, b1) \
|
218
|
+
do \
|
219
|
+
{ \
|
220
|
+
b0 = _mm_unpackhi_epi64(m2, m7); \
|
221
|
+
b1 = _mm_alignr_epi8(m5, m6, 8); \
|
222
|
+
} while(0)
|
223
|
+
|
224
|
+
|
225
|
+
#define LOAD_MSG_6_3(b0, b1) \
|
226
|
+
do \
|
227
|
+
{ \
|
228
|
+
b0 = _mm_unpacklo_epi64(m0, m3); \
|
229
|
+
b1 = _mm_shuffle_epi32(m4, _MM_SHUFFLE(1,0,3,2)); \
|
230
|
+
} while(0)
|
231
|
+
|
232
|
+
|
233
|
+
#define LOAD_MSG_6_4(b0, b1) \
|
234
|
+
do \
|
235
|
+
{ \
|
236
|
+
b0 = _mm_unpackhi_epi64(m3, m1); \
|
237
|
+
b1 = _mm_blend_epi16(m1, m5, 0xF0); \
|
238
|
+
} while(0)
|
239
|
+
|
240
|
+
|
241
|
+
#define LOAD_MSG_7_1(b0, b1) \
|
242
|
+
do \
|
243
|
+
{ \
|
244
|
+
b0 = _mm_unpackhi_epi64(m6, m3); \
|
245
|
+
b1 = _mm_blend_epi16(m6, m1, 0xF0); \
|
246
|
+
} while(0)
|
247
|
+
|
248
|
+
|
249
|
+
#define LOAD_MSG_7_2(b0, b1) \
|
250
|
+
do \
|
251
|
+
{ \
|
252
|
+
b0 = _mm_alignr_epi8(m7, m5, 8); \
|
253
|
+
b1 = _mm_unpackhi_epi64(m0, m4); \
|
254
|
+
} while(0)
|
255
|
+
|
256
|
+
|
257
|
+
#define LOAD_MSG_7_3(b0, b1) \
|
258
|
+
do \
|
259
|
+
{ \
|
260
|
+
b0 = _mm_unpackhi_epi64(m2, m7); \
|
261
|
+
b1 = _mm_unpacklo_epi64(m4, m1); \
|
262
|
+
} while(0)
|
263
|
+
|
264
|
+
|
265
|
+
#define LOAD_MSG_7_4(b0, b1) \
|
266
|
+
do \
|
267
|
+
{ \
|
268
|
+
b0 = _mm_unpacklo_epi64(m0, m2); \
|
269
|
+
b1 = _mm_unpacklo_epi64(m3, m5); \
|
270
|
+
} while(0)
|
271
|
+
|
272
|
+
|
273
|
+
#define LOAD_MSG_8_1(b0, b1) \
|
274
|
+
do \
|
275
|
+
{ \
|
276
|
+
b0 = _mm_unpacklo_epi64(m3, m7); \
|
277
|
+
b1 = _mm_alignr_epi8(m0, m5, 8); \
|
278
|
+
} while(0)
|
279
|
+
|
280
|
+
|
281
|
+
#define LOAD_MSG_8_2(b0, b1) \
|
282
|
+
do \
|
283
|
+
{ \
|
284
|
+
b0 = _mm_unpackhi_epi64(m7, m4); \
|
285
|
+
b1 = _mm_alignr_epi8(m4, m1, 8); \
|
286
|
+
} while(0)
|
287
|
+
|
288
|
+
|
289
|
+
#define LOAD_MSG_8_3(b0, b1) \
|
290
|
+
do \
|
291
|
+
{ \
|
292
|
+
b0 = m6; \
|
293
|
+
b1 = _mm_alignr_epi8(m5, m0, 8); \
|
294
|
+
} while(0)
|
295
|
+
|
296
|
+
|
297
|
+
#define LOAD_MSG_8_4(b0, b1) \
|
298
|
+
do \
|
299
|
+
{ \
|
300
|
+
b0 = _mm_blend_epi16(m1, m3, 0xF0); \
|
301
|
+
b1 = m2; \
|
302
|
+
} while(0)
|
303
|
+
|
304
|
+
|
305
|
+
#define LOAD_MSG_9_1(b0, b1) \
|
306
|
+
do \
|
307
|
+
{ \
|
308
|
+
b0 = _mm_unpacklo_epi64(m5, m4); \
|
309
|
+
b1 = _mm_unpackhi_epi64(m3, m0); \
|
310
|
+
} while(0)
|
311
|
+
|
312
|
+
|
313
|
+
#define LOAD_MSG_9_2(b0, b1) \
|
314
|
+
do \
|
315
|
+
{ \
|
316
|
+
b0 = _mm_unpacklo_epi64(m1, m2); \
|
317
|
+
b1 = _mm_blend_epi16(m3, m2, 0xF0); \
|
318
|
+
} while(0)
|
319
|
+
|
320
|
+
|
321
|
+
#define LOAD_MSG_9_3(b0, b1) \
|
322
|
+
do \
|
323
|
+
{ \
|
324
|
+
b0 = _mm_unpackhi_epi64(m7, m4); \
|
325
|
+
b1 = _mm_unpackhi_epi64(m1, m6); \
|
326
|
+
} while(0)
|
327
|
+
|
328
|
+
|
329
|
+
#define LOAD_MSG_9_4(b0, b1) \
|
330
|
+
do \
|
331
|
+
{ \
|
332
|
+
b0 = _mm_alignr_epi8(m7, m5, 8); \
|
333
|
+
b1 = _mm_unpacklo_epi64(m6, m0); \
|
334
|
+
} while(0)
|
335
|
+
|
336
|
+
|
337
|
+
#define LOAD_MSG_10_1(b0, b1) \
|
338
|
+
do \
|
339
|
+
{ \
|
340
|
+
b0 = _mm_unpacklo_epi64(m0, m1); \
|
341
|
+
b1 = _mm_unpacklo_epi64(m2, m3); \
|
342
|
+
} while(0)
|
343
|
+
|
344
|
+
|
345
|
+
#define LOAD_MSG_10_2(b0, b1) \
|
346
|
+
do \
|
347
|
+
{ \
|
348
|
+
b0 = _mm_unpackhi_epi64(m0, m1); \
|
349
|
+
b1 = _mm_unpackhi_epi64(m2, m3); \
|
350
|
+
} while(0)
|
351
|
+
|
352
|
+
|
353
|
+
#define LOAD_MSG_10_3(b0, b1) \
|
354
|
+
do \
|
355
|
+
{ \
|
356
|
+
b0 = _mm_unpacklo_epi64(m4, m5); \
|
357
|
+
b1 = _mm_unpacklo_epi64(m6, m7); \
|
358
|
+
} while(0)
|
359
|
+
|
360
|
+
|
361
|
+
#define LOAD_MSG_10_4(b0, b1) \
|
362
|
+
do \
|
363
|
+
{ \
|
364
|
+
b0 = _mm_unpackhi_epi64(m4, m5); \
|
365
|
+
b1 = _mm_unpackhi_epi64(m6, m7); \
|
366
|
+
} while(0)
|
367
|
+
|
368
|
+
|
369
|
+
#define LOAD_MSG_11_1(b0, b1) \
|
370
|
+
do \
|
371
|
+
{ \
|
372
|
+
b0 = _mm_unpacklo_epi64(m7, m2); \
|
373
|
+
b1 = _mm_unpackhi_epi64(m4, m6); \
|
374
|
+
} while(0)
|
375
|
+
|
376
|
+
|
377
|
+
#define LOAD_MSG_11_2(b0, b1) \
|
378
|
+
do \
|
379
|
+
{ \
|
380
|
+
b0 = _mm_unpacklo_epi64(m5, m4); \
|
381
|
+
b1 = _mm_alignr_epi8(m3, m7, 8); \
|
382
|
+
} while(0)
|
383
|
+
|
384
|
+
|
385
|
+
#define LOAD_MSG_11_3(b0, b1) \
|
386
|
+
do \
|
387
|
+
{ \
|
388
|
+
b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \
|
389
|
+
b1 = _mm_unpackhi_epi64(m5, m2); \
|
390
|
+
} while(0)
|
391
|
+
|
392
|
+
|
393
|
+
#define LOAD_MSG_11_4(b0, b1) \
|
394
|
+
do \
|
395
|
+
{ \
|
396
|
+
b0 = _mm_unpacklo_epi64(m6, m1); \
|
397
|
+
b1 = _mm_unpackhi_epi64(m3, m1); \
|
398
|
+
} while(0)
|
399
|
+
|
400
|
+
|
401
|
+
#endif
|
402
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
BLAKE2 reference source code package -
|
2
|
+
BLAKE2 reference source code package - C implementations
|
3
3
|
|
4
4
|
Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
|
5
5
|
|
@@ -12,11 +12,14 @@
|
|
12
12
|
*/
|
13
13
|
|
14
14
|
#include <stdint.h>
|
15
|
+
#include <stdlib.h>
|
15
16
|
#include <string.h>
|
16
|
-
#include <stdio.h>
|
17
17
|
|
18
18
|
#include "blake2.h"
|
19
19
|
#include "blake2-impl.h"
|
20
|
+
#include "runtime.h"
|
21
|
+
|
22
|
+
static blake2b_compress_fn blake2b_compress = blake2b_compress_ref;
|
20
23
|
|
21
24
|
static const uint64_t blake2b_IV[8] =
|
22
25
|
{
|
@@ -26,23 +29,6 @@ static const uint64_t blake2b_IV[8] =
|
|
26
29
|
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
27
30
|
};
|
28
31
|
|
29
|
-
static const uint8_t blake2b_sigma[12][16] =
|
30
|
-
{
|
31
|
-
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
32
|
-
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
33
|
-
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
34
|
-
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
35
|
-
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
36
|
-
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
37
|
-
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
38
|
-
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
39
|
-
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
40
|
-
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
41
|
-
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
42
|
-
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
43
|
-
};
|
44
|
-
|
45
|
-
|
46
32
|
/* LCOV_EXCL_START */
|
47
33
|
static inline int blake2b_set_lastnode( blake2b_state *S )
|
48
34
|
{
|
@@ -57,7 +43,7 @@ static inline int blake2b_clear_lastnode( blake2b_state *S )
|
|
57
43
|
return 0;
|
58
44
|
}
|
59
45
|
#endif
|
60
|
-
|
46
|
+
|
61
47
|
static inline int blake2b_set_lastblock( blake2b_state *S )
|
62
48
|
{
|
63
49
|
if( S->last_node ) blake2b_set_lastnode( S );
|
@@ -76,13 +62,18 @@ static inline int blake2b_clear_lastblock( blake2b_state *S )
|
|
76
62
|
#endif
|
77
63
|
static inline int blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
78
64
|
{
|
65
|
+
#if defined(__x86_64__) && defined(__SIZEOF_INT128__)
|
66
|
+
__uint128_t t = ( ( __uint128_t )S->t[1] << 64 ) | S->t[0];
|
67
|
+
t += inc;
|
68
|
+
S->t[0] = ( uint64_t )( t >> 0 );
|
69
|
+
S->t[1] = ( uint64_t )( t >> 64 );
|
70
|
+
#else
|
79
71
|
S->t[0] += inc;
|
80
72
|
S->t[1] += ( S->t[0] < inc );
|
73
|
+
#endif
|
81
74
|
return 0;
|
82
75
|
}
|
83
76
|
|
84
|
-
|
85
|
-
|
86
77
|
// Parameter-related functions
|
87
78
|
#if 0
|
88
79
|
static inline int blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
@@ -165,8 +156,6 @@ int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
|
165
156
|
return 0;
|
166
157
|
}
|
167
158
|
|
168
|
-
|
169
|
-
|
170
159
|
int blake2b_init( blake2b_state *S, const uint8_t outlen )
|
171
160
|
{
|
172
161
|
blake2b_param P[1];
|
@@ -289,69 +278,6 @@ int blake2b_init_key_salt_personal( blake2b_state *S, const uint8_t outlen, cons
|
|
289
278
|
return 0;
|
290
279
|
}
|
291
280
|
|
292
|
-
static int blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
293
|
-
{
|
294
|
-
uint64_t m[16];
|
295
|
-
uint64_t v[16];
|
296
|
-
int i;
|
297
|
-
|
298
|
-
for( i = 0; i < 16; ++i )
|
299
|
-
m[i] = load64( block + i * sizeof( m[i] ) );
|
300
|
-
|
301
|
-
for( i = 0; i < 8; ++i )
|
302
|
-
v[i] = S->h[i];
|
303
|
-
|
304
|
-
v[ 8] = blake2b_IV[0];
|
305
|
-
v[ 9] = blake2b_IV[1];
|
306
|
-
v[10] = blake2b_IV[2];
|
307
|
-
v[11] = blake2b_IV[3];
|
308
|
-
v[12] = S->t[0] ^ blake2b_IV[4];
|
309
|
-
v[13] = S->t[1] ^ blake2b_IV[5];
|
310
|
-
v[14] = S->f[0] ^ blake2b_IV[6];
|
311
|
-
v[15] = S->f[1] ^ blake2b_IV[7];
|
312
|
-
#define G(r,i,a,b,c,d) \
|
313
|
-
do { \
|
314
|
-
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
315
|
-
d = rotr64(d ^ a, 32); \
|
316
|
-
c = c + d; \
|
317
|
-
b = rotr64(b ^ c, 24); \
|
318
|
-
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
319
|
-
d = rotr64(d ^ a, 16); \
|
320
|
-
c = c + d; \
|
321
|
-
b = rotr64(b ^ c, 63); \
|
322
|
-
} while(0)
|
323
|
-
#define ROUND(r) \
|
324
|
-
do { \
|
325
|
-
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
326
|
-
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
327
|
-
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
328
|
-
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
329
|
-
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
330
|
-
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
331
|
-
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
332
|
-
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
333
|
-
} while(0)
|
334
|
-
ROUND( 0 );
|
335
|
-
ROUND( 1 );
|
336
|
-
ROUND( 2 );
|
337
|
-
ROUND( 3 );
|
338
|
-
ROUND( 4 );
|
339
|
-
ROUND( 5 );
|
340
|
-
ROUND( 6 );
|
341
|
-
ROUND( 7 );
|
342
|
-
ROUND( 8 );
|
343
|
-
ROUND( 9 );
|
344
|
-
ROUND( 10 );
|
345
|
-
ROUND( 11 );
|
346
|
-
|
347
|
-
for( i = 0; i < 8; ++i )
|
348
|
-
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
349
|
-
|
350
|
-
#undef G
|
351
|
-
#undef ROUND
|
352
|
-
return 0;
|
353
|
-
}
|
354
|
-
|
355
281
|
/* inlen now in bytes */
|
356
282
|
int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
357
283
|
{
|
@@ -383,13 +309,9 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
|
383
309
|
return 0;
|
384
310
|
}
|
385
311
|
|
386
|
-
/* Is this correct? */
|
387
312
|
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
388
313
|
{
|
389
|
-
|
390
|
-
int i;
|
391
|
-
|
392
|
-
if( outlen > BLAKE2B_OUTBYTES ) {
|
314
|
+
if( !outlen || outlen > BLAKE2B_OUTBYTES ) {
|
393
315
|
return -1;
|
394
316
|
}
|
395
317
|
if( S->buflen > BLAKE2B_BLOCKBYTES )
|
@@ -405,10 +327,18 @@ int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
|
405
327
|
memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
406
328
|
blake2b_compress( S, S->buf );
|
407
329
|
|
408
|
-
|
409
|
-
|
330
|
+
#ifdef NATIVE_LITTLE_ENDIAN
|
331
|
+
memcpy( out, &S->h[0], outlen );
|
332
|
+
#else
|
333
|
+
{
|
334
|
+
uint8_t buffer[BLAKE2B_OUTBYTES];
|
335
|
+
int i;
|
410
336
|
|
411
|
-
|
337
|
+
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
338
|
+
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
339
|
+
memcpy( out, buffer, outlen );
|
340
|
+
}
|
341
|
+
#endif
|
412
342
|
return 0;
|
413
343
|
}
|
414
344
|
|
@@ -418,14 +348,14 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
|
|
418
348
|
blake2b_state S[1];
|
419
349
|
|
420
350
|
/* Verify parameters */
|
421
|
-
if
|
351
|
+
if( NULL == in && inlen > 0 ) return -1;
|
422
352
|
|
423
|
-
if
|
424
|
-
|
425
|
-
if( NULL == key && keylen > 0 ) return -1;
|
353
|
+
if( NULL == out ) return -1;
|
426
354
|
|
427
355
|
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
428
356
|
|
357
|
+
if( NULL == key && keylen > 0 ) return -1;
|
358
|
+
|
429
359
|
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
430
360
|
|
431
361
|
if( keylen > 0 )
|
@@ -448,11 +378,15 @@ int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const
|
|
448
378
|
blake2b_state S[1];
|
449
379
|
|
450
380
|
/* Verify parameters */
|
451
|
-
if
|
381
|
+
if( NULL == in && inlen > 0 ) return -1;
|
452
382
|
|
453
|
-
if
|
383
|
+
if( NULL == out ) return -1;
|
454
384
|
|
455
|
-
if(
|
385
|
+
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
386
|
+
|
387
|
+
if( NULL == key && keylen > 0 ) return -1;
|
388
|
+
|
389
|
+
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
456
390
|
|
457
391
|
if( keylen > 0 )
|
458
392
|
{
|
@@ -467,3 +401,25 @@ int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const
|
|
467
401
|
blake2b_final( S, out, outlen );
|
468
402
|
return 0;
|
469
403
|
}
|
404
|
+
|
405
|
+
int
|
406
|
+
blake2b_pick_best_implementation(void)
|
407
|
+
{
|
408
|
+
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)) || \
|
409
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
410
|
+
if (sodium_runtime_has_sse41()) {
|
411
|
+
blake2b_compress = blake2b_compress_sse41;
|
412
|
+
return 0;
|
413
|
+
}
|
414
|
+
#endif
|
415
|
+
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H)) || \
|
416
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64)))
|
417
|
+
if (sodium_runtime_has_ssse3()) {
|
418
|
+
blake2b_compress = blake2b_compress_ssse3;
|
419
|
+
return 0;
|
420
|
+
}
|
421
|
+
#endif
|
422
|
+
blake2b_compress = blake2b_compress_ref;
|
423
|
+
|
424
|
+
return 0;
|
425
|
+
}
|