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,123 @@
|
|
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_round_H
|
15
|
+
#define blake2b_round_H
|
16
|
+
|
17
|
+
#ifndef BLAKE2_USE_SSSE3
|
18
|
+
# error BLAKE2_USE_SSSE3 must be defined in order to use this file
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#define LOADU(p) _mm_loadu_si128( (const __m128i *)(const void *)(p) )
|
22
|
+
#define STOREU(p,r) _mm_storeu_si128((__m128i *)(void *)(p), r)
|
23
|
+
|
24
|
+
#define TOF(reg) _mm_castsi128_ps((reg))
|
25
|
+
#define TOI(reg) _mm_castps_si128((reg))
|
26
|
+
|
27
|
+
|
28
|
+
/* Microarchitecture-specific macros */
|
29
|
+
#define _mm_roti_epi64(x, c) \
|
30
|
+
(-(c) == 32) ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2,3,0,1)) \
|
31
|
+
: (-(c) == 24) ? _mm_shuffle_epi8((x), r24) \
|
32
|
+
: (-(c) == 16) ? _mm_shuffle_epi8((x), r16) \
|
33
|
+
: (-(c) == 63) ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_add_epi64((x), (x))) \
|
34
|
+
: _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_slli_epi64((x), 64-(-(c))))
|
35
|
+
|
36
|
+
|
37
|
+
#define G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \
|
38
|
+
row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \
|
39
|
+
row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \
|
40
|
+
\
|
41
|
+
row4l = _mm_xor_si128(row4l, row1l); \
|
42
|
+
row4h = _mm_xor_si128(row4h, row1h); \
|
43
|
+
\
|
44
|
+
row4l = _mm_roti_epi64(row4l, -32); \
|
45
|
+
row4h = _mm_roti_epi64(row4h, -32); \
|
46
|
+
\
|
47
|
+
row3l = _mm_add_epi64(row3l, row4l); \
|
48
|
+
row3h = _mm_add_epi64(row3h, row4h); \
|
49
|
+
\
|
50
|
+
row2l = _mm_xor_si128(row2l, row3l); \
|
51
|
+
row2h = _mm_xor_si128(row2h, row3h); \
|
52
|
+
\
|
53
|
+
row2l = _mm_roti_epi64(row2l, -24); \
|
54
|
+
row2h = _mm_roti_epi64(row2h, -24); \
|
55
|
+
|
56
|
+
#define G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \
|
57
|
+
row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \
|
58
|
+
row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \
|
59
|
+
\
|
60
|
+
row4l = _mm_xor_si128(row4l, row1l); \
|
61
|
+
row4h = _mm_xor_si128(row4h, row1h); \
|
62
|
+
\
|
63
|
+
row4l = _mm_roti_epi64(row4l, -16); \
|
64
|
+
row4h = _mm_roti_epi64(row4h, -16); \
|
65
|
+
\
|
66
|
+
row3l = _mm_add_epi64(row3l, row4l); \
|
67
|
+
row3h = _mm_add_epi64(row3h, row4h); \
|
68
|
+
\
|
69
|
+
row2l = _mm_xor_si128(row2l, row3l); \
|
70
|
+
row2h = _mm_xor_si128(row2h, row3h); \
|
71
|
+
\
|
72
|
+
row2l = _mm_roti_epi64(row2l, -63); \
|
73
|
+
row2h = _mm_roti_epi64(row2h, -63); \
|
74
|
+
|
75
|
+
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
76
|
+
t0 = _mm_alignr_epi8(row2h, row2l, 8); \
|
77
|
+
t1 = _mm_alignr_epi8(row2l, row2h, 8); \
|
78
|
+
row2l = t0; \
|
79
|
+
row2h = t1; \
|
80
|
+
\
|
81
|
+
t0 = row3l; \
|
82
|
+
row3l = row3h; \
|
83
|
+
row3h = t0; \
|
84
|
+
\
|
85
|
+
t0 = _mm_alignr_epi8(row4h, row4l, 8); \
|
86
|
+
t1 = _mm_alignr_epi8(row4l, row4h, 8); \
|
87
|
+
row4l = t1; \
|
88
|
+
row4h = t0;
|
89
|
+
|
90
|
+
#define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
91
|
+
t0 = _mm_alignr_epi8(row2l, row2h, 8); \
|
92
|
+
t1 = _mm_alignr_epi8(row2h, row2l, 8); \
|
93
|
+
row2l = t0; \
|
94
|
+
row2h = t1; \
|
95
|
+
\
|
96
|
+
t0 = row3l; \
|
97
|
+
row3l = row3h; \
|
98
|
+
row3h = t0; \
|
99
|
+
\
|
100
|
+
t0 = _mm_alignr_epi8(row4l, row4h, 8); \
|
101
|
+
t1 = _mm_alignr_epi8(row4h, row4l, 8); \
|
102
|
+
row4l = t1; \
|
103
|
+
row4h = t0;
|
104
|
+
|
105
|
+
#if defined(BLAKE2_USE_SSE41)
|
106
|
+
#include "blake2b-load-sse41.h"
|
107
|
+
#else
|
108
|
+
#include "blake2b-load-sse2.h"
|
109
|
+
#endif
|
110
|
+
|
111
|
+
#define ROUND(r) \
|
112
|
+
LOAD_MSG_ ##r ##_1(b0, b1); \
|
113
|
+
G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
114
|
+
LOAD_MSG_ ##r ##_2(b0, b1); \
|
115
|
+
G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
116
|
+
DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \
|
117
|
+
LOAD_MSG_ ##r ##_3(b0, b1); \
|
118
|
+
G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
119
|
+
LOAD_MSG_ ##r ##_4(b0, b1); \
|
120
|
+
G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \
|
121
|
+
UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h);
|
122
|
+
|
123
|
+
#endif
|
@@ -106,3 +106,9 @@ crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state,
|
|
106
106
|
assert(outlen <= UINT8_MAX);
|
107
107
|
return blake2b_final(state, (uint8_t *) out, (uint8_t) outlen);
|
108
108
|
}
|
109
|
+
|
110
|
+
int
|
111
|
+
_crypto_generichash_blake2b_pick_best_implementation(void)
|
112
|
+
{
|
113
|
+
return blake2b_pick_best_implementation();
|
114
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
#include "crypto_verify_16.h"
|
2
3
|
#include "utils.h"
|
3
4
|
#include "poly1305_donna.h"
|
4
5
|
#ifdef HAVE_TI_MODE
|
@@ -6,6 +7,7 @@
|
|
6
7
|
#else
|
7
8
|
# include "poly1305_donna32.h"
|
8
9
|
#endif
|
10
|
+
#include "../onetimeauth_poly1305.h"
|
9
11
|
|
10
12
|
static void
|
11
13
|
poly1305_update(poly1305_context *ctx, const unsigned char *m,
|
@@ -45,7 +47,7 @@ poly1305_update(poly1305_context *ctx, const unsigned char *m,
|
|
45
47
|
}
|
46
48
|
}
|
47
49
|
|
48
|
-
int
|
50
|
+
static int
|
49
51
|
crypto_onetimeauth_poly1305_donna(unsigned char *out, const unsigned char *m,
|
50
52
|
unsigned long long inlen,
|
51
53
|
const unsigned char *key)
|
@@ -58,7 +60,7 @@ crypto_onetimeauth_poly1305_donna(unsigned char *out, const unsigned char *m,
|
|
58
60
|
return 0;
|
59
61
|
}
|
60
62
|
|
61
|
-
int
|
63
|
+
static int
|
62
64
|
crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
|
63
65
|
const unsigned char *key)
|
64
66
|
{
|
@@ -67,7 +69,7 @@ crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
|
|
67
69
|
return 0;
|
68
70
|
}
|
69
71
|
|
70
|
-
int
|
72
|
+
static int
|
71
73
|
crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
|
72
74
|
const unsigned char *in,
|
73
75
|
unsigned long long inlen)
|
@@ -77,7 +79,7 @@ crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *stat
|
|
77
79
|
return 0;
|
78
80
|
}
|
79
81
|
|
80
|
-
int
|
82
|
+
static int
|
81
83
|
crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
|
82
84
|
unsigned char *out)
|
83
85
|
{
|
@@ -86,17 +88,20 @@ crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state
|
|
86
88
|
return 0;
|
87
89
|
}
|
88
90
|
|
89
|
-
|
90
|
-
const char *
|
91
|
-
|
91
|
+
static int
|
92
|
+
crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
|
93
|
+
const unsigned char *in,
|
94
|
+
unsigned long long inlen,
|
95
|
+
const unsigned char *k)
|
92
96
|
{
|
93
|
-
|
97
|
+
unsigned char correct[16];
|
98
|
+
|
99
|
+
crypto_onetimeauth_poly1305_donna(correct,in,inlen,k);
|
100
|
+
return crypto_verify_16(h,correct);
|
94
101
|
}
|
95
|
-
/* LCOV_EXCL_STOP */
|
96
102
|
|
97
103
|
struct crypto_onetimeauth_poly1305_implementation
|
98
104
|
crypto_onetimeauth_poly1305_donna_implementation = {
|
99
|
-
SODIUM_C99(.implementation_name =) crypto_onetimeauth_poly1305_donna_implementation_name,
|
100
105
|
SODIUM_C99(.onetimeauth =) crypto_onetimeauth_poly1305_donna,
|
101
106
|
SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_poly1305_donna_verify,
|
102
107
|
SODIUM_C99(.onetimeauth_init =) crypto_onetimeauth_poly1305_donna_init,
|
@@ -10,26 +10,26 @@ typedef crypto_onetimeauth_poly1305_state poly1305_context;
|
|
10
10
|
extern struct crypto_onetimeauth_poly1305_implementation
|
11
11
|
crypto_onetimeauth_poly1305_donna_implementation;
|
12
12
|
|
13
|
-
const char *crypto_onetimeauth_poly1305_donna_implementation_name(void);
|
13
|
+
static const char *crypto_onetimeauth_poly1305_donna_implementation_name(void);
|
14
14
|
|
15
|
-
int crypto_onetimeauth_poly1305_donna(unsigned char *out,
|
16
|
-
const unsigned char *in,
|
17
|
-
unsigned long long inlen,
|
18
|
-
const unsigned char *k);
|
19
|
-
|
20
|
-
int crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
|
15
|
+
static int crypto_onetimeauth_poly1305_donna(unsigned char *out,
|
21
16
|
const unsigned char *in,
|
22
17
|
unsigned long long inlen,
|
23
18
|
const unsigned char *k);
|
24
19
|
|
25
|
-
int
|
26
|
-
|
20
|
+
static int crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
|
21
|
+
const unsigned char *in,
|
22
|
+
unsigned long long inlen,
|
23
|
+
const unsigned char *k);
|
27
24
|
|
28
|
-
int
|
29
|
-
|
30
|
-
|
25
|
+
static int crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
|
26
|
+
const unsigned char *key);
|
27
|
+
|
28
|
+
static int crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
|
29
|
+
const unsigned char *in,
|
30
|
+
unsigned long long inlen);
|
31
31
|
|
32
|
-
int crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
|
33
|
-
|
32
|
+
static int crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
|
33
|
+
unsigned char *out);
|
34
34
|
|
35
35
|
#endif /* __POLY1305_DONNA_H__ */
|
@@ -1,26 +1,11 @@
|
|
1
1
|
|
2
2
|
#include "crypto_onetimeauth_poly1305.h"
|
3
3
|
#include "donna/poly1305_donna.h"
|
4
|
+
#include "onetimeauth_poly1305.h"
|
4
5
|
|
5
|
-
/* LCOV_EXCL_START */
|
6
6
|
static const crypto_onetimeauth_poly1305_implementation *implementation =
|
7
7
|
&crypto_onetimeauth_poly1305_donna_implementation;
|
8
8
|
|
9
|
-
int
|
10
|
-
crypto_onetimeauth_poly1305_set_implementation(crypto_onetimeauth_poly1305_implementation *impl)
|
11
|
-
{
|
12
|
-
implementation = impl;
|
13
|
-
|
14
|
-
return 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
const char *
|
18
|
-
crypto_onetimeauth_poly1305_implementation_name(void)
|
19
|
-
{
|
20
|
-
return implementation->implementation_name();
|
21
|
-
}
|
22
|
-
/* LCOV_EXCL_STOP */
|
23
|
-
|
24
9
|
int
|
25
10
|
crypto_onetimeauth_poly1305(unsigned char *out, const unsigned char *in,
|
26
11
|
unsigned long long inlen, const unsigned char *k)
|
@@ -58,3 +43,20 @@ crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
|
|
58
43
|
{
|
59
44
|
return implementation->onetimeauth_final(state, out);
|
60
45
|
}
|
46
|
+
|
47
|
+
size_t
|
48
|
+
crypto_onetimeauth_poly1305_bytes(void) {
|
49
|
+
return crypto_onetimeauth_poly1305_BYTES;
|
50
|
+
}
|
51
|
+
|
52
|
+
size_t
|
53
|
+
crypto_onetimeauth_poly1305_keybytes(void) {
|
54
|
+
return crypto_onetimeauth_poly1305_KEYBYTES;
|
55
|
+
}
|
56
|
+
|
57
|
+
int
|
58
|
+
_crypto_onetimeauth_poly1305_pick_best_implementation(void)
|
59
|
+
{
|
60
|
+
implementation = &crypto_onetimeauth_poly1305_donna_implementation;
|
61
|
+
return 0;
|
62
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
#ifndef onetimeauth_poly1305_H
|
3
|
+
#define onetimeauth_poly1305_H
|
4
|
+
|
5
|
+
typedef struct crypto_onetimeauth_poly1305_implementation {
|
6
|
+
int (*onetimeauth)(unsigned char *out,
|
7
|
+
const unsigned char *in,
|
8
|
+
unsigned long long inlen,
|
9
|
+
const unsigned char *k);
|
10
|
+
int (*onetimeauth_verify)(const unsigned char *h,
|
11
|
+
const unsigned char *in,
|
12
|
+
unsigned long long inlen,
|
13
|
+
const unsigned char *k);
|
14
|
+
int (*onetimeauth_init)(crypto_onetimeauth_poly1305_state *state,
|
15
|
+
const unsigned char *key);
|
16
|
+
int (*onetimeauth_update)(crypto_onetimeauth_poly1305_state *state,
|
17
|
+
const unsigned char *in,
|
18
|
+
unsigned long long inlen);
|
19
|
+
int (*onetimeauth_final)(crypto_onetimeauth_poly1305_state *state,
|
20
|
+
unsigned char *out);
|
21
|
+
} crypto_onetimeauth_poly1305_implementation;
|
22
|
+
|
23
|
+
#endif
|
@@ -24,10 +24,10 @@
|
|
24
24
|
* SUCH DAMAGE.
|
25
25
|
*/
|
26
26
|
|
27
|
+
#include <stdlib.h>
|
27
28
|
#include <sys/types.h>
|
28
29
|
|
29
30
|
#include <stdint.h>
|
30
|
-
#include <stdlib.h>
|
31
31
|
#include <string.h>
|
32
32
|
|
33
33
|
#include "crypto_auth_hmacsha256.h"
|
@@ -53,7 +53,7 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
|
53
53
|
int k;
|
54
54
|
size_t clen;
|
55
55
|
|
56
|
-
if (dkLen >
|
56
|
+
if (dkLen > 0x1fffffffe0ULL) {
|
57
57
|
abort();
|
58
58
|
}
|
59
59
|
crypto_auth_hmacsha256_init(&PShctx, passwd, passwdlen);
|
@@ -1,9 +1,6 @@
|
|
1
1
|
|
2
2
|
#include "crypto_scalarmult_curve25519.h"
|
3
3
|
|
4
|
-
#define crypto_scalarmult_curve25519_implementation_name \
|
5
|
-
crypto_scalarmult_curve25519_donna_c64_implementation_name
|
6
|
-
|
7
4
|
#define crypto_scalarmult crypto_scalarmult_curve25519
|
8
5
|
#define crypto_scalarmult_base crypto_scalarmult_curve25519_base
|
9
6
|
|
@@ -52,7 +52,9 @@ crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
|
|
52
52
|
crypto_onetimeauth_poly1305_KEYBYTES ? 1 : -1]);
|
53
53
|
crypto_onetimeauth_poly1305_init(&state, block0);
|
54
54
|
|
55
|
-
|
55
|
+
for (i = 0U; i < mlen0; i++) {
|
56
|
+
c[i] = block0[crypto_secretbox_ZEROBYTES + i];
|
57
|
+
}
|
56
58
|
sodium_memzero(block0, sizeof block0);
|
57
59
|
if (mlen > mlen0) {
|
58
60
|
crypto_stream_salsa20_xor_ic(c + mlen0, m + mlen0, mlen - mlen0,
|
@@ -109,7 +111,9 @@ crypto_secretbox_open_detached(unsigned char *m, const unsigned char *c,
|
|
109
111
|
if (mlen0 > 64U - crypto_secretbox_ZEROBYTES) {
|
110
112
|
mlen0 = 64U - crypto_secretbox_ZEROBYTES;
|
111
113
|
}
|
112
|
-
|
114
|
+
for (i = 0U; i < mlen0; i++) {
|
115
|
+
block0[crypto_secretbox_ZEROBYTES + i] = c[i];
|
116
|
+
}
|
113
117
|
crypto_stream_salsa20_xor(block0, block0,
|
114
118
|
crypto_secretbox_ZEROBYTES + mlen0,
|
115
119
|
n + 16, subkey);
|
@@ -8,6 +8,7 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
#include <stdint.h>
|
11
|
+
#include <stdlib.h>
|
11
12
|
#include <string.h>
|
12
13
|
|
13
14
|
#include "api.h"
|
@@ -131,6 +132,7 @@ chacha_encrypt_bytes(chacha_ctx *x, const u8 *m, u8 *c, unsigned long long bytes
|
|
131
132
|
|
132
133
|
for (;;) {
|
133
134
|
if (bytes < 64) {
|
135
|
+
memset(tmp, 0, 64);
|
134
136
|
for (i = 0; i < bytes; ++i) {
|
135
137
|
tmp[i] = m[i];
|
136
138
|
}
|
@@ -266,6 +268,9 @@ crypto_stream_chacha20_ietf_ref(unsigned char *c, unsigned long long clen,
|
|
266
268
|
if (!clen) {
|
267
269
|
return 0;
|
268
270
|
}
|
271
|
+
if (clen > 64ULL * (1ULL << 32) - 64ULL) {
|
272
|
+
abort();
|
273
|
+
}
|
269
274
|
(void) sizeof(int[crypto_stream_chacha20_KEYBYTES == 256 / 8 ? 1 : -1]);
|
270
275
|
chacha_keysetup(&ctx, k);
|
271
276
|
chacha_ietf_ivsetup(&ctx, n, NULL);
|
@@ -231,7 +231,7 @@ CFLAGS_MMX = @CFLAGS_MMX@
|
|
231
231
|
CFLAGS_PCLMUL = @CFLAGS_PCLMUL@
|
232
232
|
CFLAGS_SSE2 = @CFLAGS_SSE2@
|
233
233
|
CFLAGS_SSE3 = @CFLAGS_SSE3@
|
234
|
-
|
234
|
+
CFLAGS_SSE41 = @CFLAGS_SSE41@
|
235
235
|
CFLAGS_SSSE3 = @CFLAGS_SSSE3@
|
236
236
|
CPP = @CPP@
|
237
237
|
CPPFLAGS = @CPPFLAGS@
|