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
@@ -13,7 +13,8 @@ SODIUM_EXPORT
|
|
13
13
|
size_t crypto_verify_16_bytes(void);
|
14
14
|
|
15
15
|
SODIUM_EXPORT
|
16
|
-
int crypto_verify_16(const unsigned char *x, const unsigned char *y)
|
16
|
+
int crypto_verify_16(const unsigned char *x, const unsigned char *y)
|
17
|
+
__attribute__ ((warn_unused_result));
|
17
18
|
|
18
19
|
#ifdef __cplusplus
|
19
20
|
}
|
@@ -13,7 +13,8 @@ SODIUM_EXPORT
|
|
13
13
|
size_t crypto_verify_32_bytes(void);
|
14
14
|
|
15
15
|
SODIUM_EXPORT
|
16
|
-
int crypto_verify_32(const unsigned char *x, const unsigned char *y)
|
16
|
+
int crypto_verify_32(const unsigned char *x, const unsigned char *y)
|
17
|
+
__attribute__ ((warn_unused_result));
|
17
18
|
|
18
19
|
#ifdef __cplusplus
|
19
20
|
}
|
@@ -13,7 +13,8 @@ SODIUM_EXPORT
|
|
13
13
|
size_t crypto_verify_64_bytes(void);
|
14
14
|
|
15
15
|
SODIUM_EXPORT
|
16
|
-
int crypto_verify_64(const unsigned char *x, const unsigned char *y)
|
16
|
+
int crypto_verify_64(const unsigned char *x, const unsigned char *y)
|
17
|
+
__attribute__ ((warn_unused_result));
|
17
18
|
|
18
19
|
#ifdef __cplusplus
|
19
20
|
}
|
@@ -8,9 +8,6 @@
|
|
8
8
|
extern "C" {
|
9
9
|
#endif
|
10
10
|
|
11
|
-
SODIUM_EXPORT
|
12
|
-
int sodium_runtime_get_cpu_features(void);
|
13
|
-
|
14
11
|
SODIUM_EXPORT
|
15
12
|
int sodium_runtime_has_neon(void);
|
16
13
|
|
@@ -20,12 +17,22 @@ int sodium_runtime_has_sse2(void);
|
|
20
17
|
SODIUM_EXPORT
|
21
18
|
int sodium_runtime_has_sse3(void);
|
22
19
|
|
20
|
+
SODIUM_EXPORT
|
21
|
+
int sodium_runtime_has_ssse3(void);
|
22
|
+
|
23
|
+
SODIUM_EXPORT
|
24
|
+
int sodium_runtime_has_sse41(void);
|
25
|
+
|
23
26
|
SODIUM_EXPORT
|
24
27
|
int sodium_runtime_has_pclmul(void);
|
25
28
|
|
26
29
|
SODIUM_EXPORT
|
27
30
|
int sodium_runtime_has_aesni(void);
|
28
31
|
|
32
|
+
/* ------------------------------------------------------------------------- */
|
33
|
+
|
34
|
+
int _sodium_runtime_get_cpu_features(void);
|
35
|
+
|
29
36
|
#ifdef __cplusplus
|
30
37
|
}
|
31
38
|
#endif
|
@@ -26,7 +26,8 @@ void sodium_memzero(void * const pnt, const size_t len);
|
|
26
26
|
* This function is not designed for lexicographical comparisons.
|
27
27
|
*/
|
28
28
|
SODIUM_EXPORT
|
29
|
-
int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
29
|
+
int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
30
|
+
__attribute__ ((warn_unused_result));
|
30
31
|
|
31
32
|
/*
|
32
33
|
* sodium_compare() returns -1 if b1_ < b2_, 1 if b1_ > b2_ and 0 if b1_ == b2_
|
@@ -36,7 +37,8 @@ int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len);
|
|
36
37
|
*/
|
37
38
|
SODIUM_EXPORT
|
38
39
|
int sodium_compare(const unsigned char *b1_, const unsigned char *b2_,
|
39
|
-
size_t len)
|
40
|
+
size_t len)
|
41
|
+
__attribute__ ((warn_unused_result));
|
40
42
|
|
41
43
|
SODIUM_EXPORT
|
42
44
|
void sodium_increment(unsigned char *n, const size_t nlen);
|
@@ -92,10 +94,12 @@ int sodium_munlock(void * const addr, const size_t len);
|
|
92
94
|
*/
|
93
95
|
|
94
96
|
SODIUM_EXPORT
|
95
|
-
void *sodium_malloc(const size_t size)
|
97
|
+
void *sodium_malloc(const size_t size)
|
98
|
+
__attribute__ ((malloc));
|
96
99
|
|
97
100
|
SODIUM_EXPORT
|
98
|
-
void *sodium_allocarray(size_t count, size_t size)
|
101
|
+
void *sodium_allocarray(size_t count, size_t size)
|
102
|
+
__attribute__ ((malloc));
|
99
103
|
|
100
104
|
SODIUM_EXPORT
|
101
105
|
void sodium_free(void *ptr);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
#include <stdlib.h>
|
2
3
|
#include <sys/types.h>
|
3
4
|
|
4
5
|
#include <assert.h>
|
@@ -106,9 +107,15 @@ randombytes_uniform(const uint32_t upper_bound)
|
|
106
107
|
uint32_t min;
|
107
108
|
uint32_t r;
|
108
109
|
|
110
|
+
#ifdef __EMSCRIPTEN__
|
109
111
|
if (implementation != NULL && implementation->uniform != NULL) {
|
110
112
|
return implementation->uniform(upper_bound);
|
111
113
|
}
|
114
|
+
#else
|
115
|
+
if (implementation->uniform != NULL) {
|
116
|
+
return implementation->uniform(upper_bound);
|
117
|
+
}
|
118
|
+
#endif
|
112
119
|
if (upper_bound < 2) {
|
113
120
|
return 0;
|
114
121
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
#include <stdlib.h>
|
2
3
|
#include <sys/types.h>
|
3
4
|
#ifndef _WIN32
|
4
5
|
# include <sys/stat.h>
|
@@ -13,7 +14,6 @@
|
|
13
14
|
#include <fcntl.h>
|
14
15
|
#include <limits.h>
|
15
16
|
#include <stdint.h>
|
16
|
-
#include <stdlib.h>
|
17
17
|
#include <string.h>
|
18
18
|
#ifndef _MSC_VER
|
19
19
|
# include <unistd.h>
|
@@ -135,7 +135,9 @@ randombytes_salsa20_random_random_dev_open(void)
|
|
135
135
|
fd = open(*device, O_RDONLY);
|
136
136
|
if (fd != -1) {
|
137
137
|
if (fstat(fd, &st) == 0 &&
|
138
|
-
# ifdef
|
138
|
+
# ifdef __COMPCERT__
|
139
|
+
1
|
140
|
+
# elif defined(S_ISNAM)
|
139
141
|
(S_ISNAM(st.st_mode) || S_ISCHR(st.st_mode))
|
140
142
|
# else
|
141
143
|
S_ISCHR(st.st_mode)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
#include <stdlib.h>
|
2
3
|
#include <sys/types.h>
|
3
4
|
#ifndef _WIN32
|
4
5
|
# include <sys/stat.h>
|
@@ -13,7 +14,6 @@
|
|
13
14
|
#include <fcntl.h>
|
14
15
|
#include <limits.h>
|
15
16
|
#include <stdint.h>
|
16
|
-
#include <stdlib.h>
|
17
17
|
#include <string.h>
|
18
18
|
#ifndef _WIN32
|
19
19
|
# include <unistd.h>
|
@@ -120,7 +120,9 @@ randombytes_sysrandom_random_dev_open(void)
|
|
120
120
|
fd = open(*device, O_RDONLY);
|
121
121
|
if (fd != -1) {
|
122
122
|
if (fstat(fd, &st) == 0 &&
|
123
|
-
# ifdef
|
123
|
+
# ifdef __COMPCERT__
|
124
|
+
1
|
125
|
+
# elif defined(S_ISNAM)
|
124
126
|
(S_ISNAM(st.st_mode) || S_ISCHR(st.st_mode))
|
125
127
|
# else
|
126
128
|
S_ISCHR(st.st_mode)
|
@@ -186,14 +188,14 @@ randombytes_sysrandom_init(void)
|
|
186
188
|
|
187
189
|
# ifdef SYS_getrandom
|
188
190
|
{
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
191
|
+
unsigned char fodder[16];
|
192
|
+
|
193
|
+
if (randombytes_linux_getrandom(fodder, sizeof fodder) == 0) {
|
194
|
+
stream.getrandom_available = 1;
|
195
|
+
errno = errno_save;
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
stream.getrandom_available = 0;
|
197
199
|
}
|
198
200
|
# endif
|
199
201
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
#include "core.h"
|
3
|
+
#include "crypto_generichash.h"
|
3
4
|
#include "crypto_onetimeauth.h"
|
4
5
|
#include "randombytes.h"
|
5
6
|
#include "runtime.h"
|
@@ -13,12 +14,11 @@ sodium_init(void)
|
|
13
14
|
if (initialized != 0) {
|
14
15
|
return 1;
|
15
16
|
}
|
16
|
-
|
17
|
-
if (crypto_onetimeauth_pick_best_implementation() == NULL) {
|
18
|
-
return -1; /* LCOV_EXCL_LINE */
|
19
|
-
}
|
17
|
+
_sodium_runtime_get_cpu_features();
|
20
18
|
randombytes_stir();
|
21
19
|
_sodium_alloc_init();
|
20
|
+
_crypto_generichash_blake2b_pick_best_implementation();
|
21
|
+
_crypto_onetimeauth_poly1305_pick_best_implementation();
|
22
22
|
initialized = 1;
|
23
23
|
|
24
24
|
return 0;
|
@@ -10,6 +10,8 @@ typedef struct CPUFeatures_ {
|
|
10
10
|
int has_neon;
|
11
11
|
int has_sse2;
|
12
12
|
int has_sse3;
|
13
|
+
int has_ssse3;
|
14
|
+
int has_sse41;
|
13
15
|
int has_pclmul;
|
14
16
|
int has_aesni;
|
15
17
|
} CPUFeatures;
|
@@ -18,6 +20,8 @@ static CPUFeatures _cpu_features;
|
|
18
20
|
|
19
21
|
#define CPUID_SSE2 0x04000000
|
20
22
|
#define CPUIDECX_SSE3 0x00000001
|
23
|
+
#define CPUIDECX_SSSE3 0x00000200
|
24
|
+
#define CPUIDECX_SSE41 0x00080000
|
21
25
|
#define CPUIDECX_PCLMUL 0x00000002
|
22
26
|
#define CPUIDECX_AESNI 0x02000000
|
23
27
|
|
@@ -108,6 +112,18 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
|
108
112
|
cpu_features->has_sse3 = ((cpu_info[2] & CPUIDECX_SSE3) != 0x0);
|
109
113
|
#endif
|
110
114
|
|
115
|
+
#ifndef HAVE_TMMINTRIN_H
|
116
|
+
cpu_features->has_ssse3 = 0;
|
117
|
+
#else
|
118
|
+
cpu_features->has_ssse3 = ((cpu_info[2] & CPUIDECX_SSSE3) != 0x0);
|
119
|
+
#endif
|
120
|
+
|
121
|
+
#ifndef HAVE_SMMINTRIN_H
|
122
|
+
cpu_features->has_sse41 = 0;
|
123
|
+
#else
|
124
|
+
cpu_features->has_sse41 = ((cpu_info[2] & CPUIDECX_SSE41) != 0x0);
|
125
|
+
#endif
|
126
|
+
|
111
127
|
#ifndef HAVE_WMMINTRIN_H
|
112
128
|
cpu_features->has_pclmul = 0;
|
113
129
|
cpu_features->has_aesni = 0;
|
@@ -120,7 +136,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
|
120
136
|
}
|
121
137
|
|
122
138
|
int
|
123
|
-
|
139
|
+
_sodium_runtime_get_cpu_features(void)
|
124
140
|
{
|
125
141
|
int ret = -1;
|
126
142
|
|
@@ -146,6 +162,16 @@ sodium_runtime_has_sse3(void) {
|
|
146
162
|
return _cpu_features.has_sse3;
|
147
163
|
}
|
148
164
|
|
165
|
+
int
|
166
|
+
sodium_runtime_has_ssse3(void) {
|
167
|
+
return _cpu_features.has_ssse3;
|
168
|
+
}
|
169
|
+
|
170
|
+
int
|
171
|
+
sodium_runtime_has_sse41(void) {
|
172
|
+
return _cpu_features.has_sse41;
|
173
|
+
}
|
174
|
+
|
149
175
|
int
|
150
176
|
sodium_runtime_has_pclmul(void) {
|
151
177
|
return _cpu_features.has_pclmul;
|
@@ -145,7 +145,9 @@ sodium_compare(const unsigned char *b1_, const unsigned char *b2_, size_t len)
|
|
145
145
|
#if HAVE_WEAK_SYMBOLS
|
146
146
|
_sodium_dummy_symbol_to_prevent_compare_lto(b1, b2, len);
|
147
147
|
#endif
|
148
|
-
|
148
|
+
i = len;
|
149
|
+
while (i != 0U) {
|
150
|
+
i--;
|
149
151
|
gt |= ((b2[i] - b1[i]) >> 8) & eq;
|
150
152
|
eq &= ((b2[i] ^ b1[i]) - 1) >> 8;
|
151
153
|
}
|
@@ -391,7 +393,7 @@ _free_aligned(unsigned char * const ptr, const size_t size)
|
|
391
393
|
}
|
392
394
|
|
393
395
|
static unsigned char *
|
394
|
-
_unprotected_ptr_from_user_ptr(
|
396
|
+
_unprotected_ptr_from_user_ptr(void * const ptr)
|
395
397
|
{
|
396
398
|
uintptr_t unprotected_ptr_u;
|
397
399
|
unsigned char *canary_ptr;
|
@@ -204,7 +204,7 @@ CFLAGS_MMX = @CFLAGS_MMX@
|
|
204
204
|
CFLAGS_PCLMUL = @CFLAGS_PCLMUL@
|
205
205
|
CFLAGS_SSE2 = @CFLAGS_SSE2@
|
206
206
|
CFLAGS_SSE3 = @CFLAGS_SSE3@
|
207
|
-
|
207
|
+
CFLAGS_SSE41 = @CFLAGS_SSE41@
|
208
208
|
CFLAGS_SSSE3 = @CFLAGS_SSSE3@
|
209
209
|
CPP = @CPP@
|
210
210
|
CPPFLAGS = @CPPFLAGS@
|
@@ -621,7 +621,7 @@ CFLAGS_MMX = @CFLAGS_MMX@
|
|
621
621
|
CFLAGS_PCLMUL = @CFLAGS_PCLMUL@
|
622
622
|
CFLAGS_SSE2 = @CFLAGS_SSE2@
|
623
623
|
CFLAGS_SSE3 = @CFLAGS_SSE3@
|
624
|
-
|
624
|
+
CFLAGS_SSE41 = @CFLAGS_SSE41@
|
625
625
|
CFLAGS_SSSE3 = @CFLAGS_SSSE3@
|
626
626
|
CPP = @CPP@
|
627
627
|
CPPFLAGS = @CPPFLAGS@
|
@@ -3145,6 +3145,20 @@ tv(void)
|
|
3145
3145
|
sodium_free(hex);
|
3146
3146
|
}
|
3147
3147
|
decrypted = (unsigned char *) sodium_malloc(message_len);
|
3148
|
+
if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
|
3149
|
+
NULL, ciphertext,
|
3150
|
+
randombytes_uniform(ciphertext_len),
|
3151
|
+
ad, ad_len, nonce, key) != -1) {
|
3152
|
+
printf("Verification of test vector #%u after truncation succeeded\n",
|
3153
|
+
(unsigned int) i);
|
3154
|
+
}
|
3155
|
+
if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
|
3156
|
+
NULL, ciphertext,
|
3157
|
+
randombytes_uniform(crypto_aead_aes256gcm_ABYTES),
|
3158
|
+
ad, ad_len, nonce, key) != -1) {
|
3159
|
+
printf("Verification of test vector #%u with a truncated tag failed\n",
|
3160
|
+
(unsigned int) i);
|
3161
|
+
}
|
3148
3162
|
if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
|
3149
3163
|
NULL, ciphertext, ciphertext_len,
|
3150
3164
|
ad, ad_len, nonce, key) != 0) {
|
@@ -68,9 +68,11 @@ int main(void)
|
|
68
68
|
printf("crypto_box_easy_afternm() with a short ciphertext should have failed\n");
|
69
69
|
}
|
70
70
|
crypto_box_easy_afternm(c, m, (unsigned long long) mlen, nonce, k1);
|
71
|
-
crypto_box_open_easy_afternm(m2, c,
|
72
|
-
|
73
|
-
nonce, k2)
|
71
|
+
if (crypto_box_open_easy_afternm(m2, c,
|
72
|
+
(unsigned long long) mlen + crypto_box_MACBYTES,
|
73
|
+
nonce, k2) != 0) {
|
74
|
+
printf("crypto_box_open_easy_afternm() failed\n");
|
75
|
+
}
|
74
76
|
printf("%d\n", memcmp(m, m2, mlen));
|
75
77
|
if (crypto_box_open_easy_afternm(m2, c, crypto_box_MACBYTES - 1U,
|
76
78
|
nonce, k2) == 0) {
|
@@ -79,15 +81,19 @@ int main(void)
|
|
79
81
|
memset(m2, 0, sizeof m2);
|
80
82
|
crypto_box_detached(c, mac, m, (unsigned long long) mlen,
|
81
83
|
nonce, alicepk, bobsk);
|
82
|
-
crypto_box_open_detached(m2, c, mac, (unsigned long long) mlen,
|
83
|
-
|
84
|
+
if (crypto_box_open_detached(m2, c, mac, (unsigned long long) mlen,
|
85
|
+
nonce, bobpk, alicesk) != 0) {
|
86
|
+
printf("crypto_box_open_detached() failed\n");
|
87
|
+
}
|
84
88
|
printf("%d\n", memcmp(m, m2, mlen));
|
85
89
|
|
86
90
|
memset(m2, 0, sizeof m2);
|
87
91
|
crypto_box_detached_afternm(c, mac, m, (unsigned long long) mlen,
|
88
92
|
nonce, k1);
|
89
|
-
crypto_box_open_detached_afternm(m2, c, mac, (unsigned long long) mlen,
|
90
|
-
|
93
|
+
if (crypto_box_open_detached_afternm(m2, c, mac, (unsigned long long) mlen,
|
94
|
+
nonce, k2) != 0) {
|
95
|
+
printf("crypto_box_open_detached_afternm() failed\n");
|
96
|
+
}
|
91
97
|
printf("%d\n", memcmp(m, m2, mlen));
|
92
98
|
|
93
99
|
sodium_free(alicepk);
|
@@ -19,12 +19,16 @@ void tv(void)
|
|
19
19
|
"0100000000000000" },
|
20
20
|
{ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
21
21
|
"0001020304050607" } };
|
22
|
-
unsigned char
|
23
|
-
unsigned char
|
24
|
-
unsigned char
|
25
|
-
char
|
26
|
-
|
27
|
-
|
22
|
+
unsigned char key[crypto_stream_chacha20_KEYBYTES];
|
23
|
+
unsigned char nonce[crypto_stream_chacha20_NONCEBYTES];
|
24
|
+
unsigned char *part;
|
25
|
+
unsigned char out[160];
|
26
|
+
unsigned char zero[160];
|
27
|
+
char out_hex[160 * 2 + 1];
|
28
|
+
size_t i = 0U;
|
29
|
+
size_t plen;
|
30
|
+
|
31
|
+
memset(zero, 0, sizeof zero);
|
28
32
|
do {
|
29
33
|
sodium_hex2bin((unsigned char *)key, sizeof key, tests[i].key_hex,
|
30
34
|
strlen(tests[i].key_hex), NULL, NULL, NULL);
|
@@ -33,6 +37,14 @@ void tv(void)
|
|
33
37
|
crypto_stream_chacha20(out, sizeof out, nonce, key);
|
34
38
|
sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out);
|
35
39
|
printf("[%s]\n", out_hex);
|
40
|
+
for (plen = 1U; plen < sizeof out; plen++) {
|
41
|
+
part = (unsigned char *) sodium_malloc(plen);
|
42
|
+
crypto_stream_chacha20_xor(part, out, plen, nonce, key);
|
43
|
+
if (memcmp(part, zero, plen) != 0) {
|
44
|
+
printf("Failed with length %lu\n", (unsigned long) plen);
|
45
|
+
}
|
46
|
+
sodium_free(part);
|
47
|
+
}
|
36
48
|
} while (++i < (sizeof tests) / (sizeof tests[0]));
|
37
49
|
|
38
50
|
randombytes_buf(out, sizeof out);
|
@@ -85,12 +97,16 @@ void tv_ietf(void)
|
|
85
97
|
{ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
86
98
|
"000000090000004a00000000",
|
87
99
|
1U }};
|
88
|
-
unsigned char
|
89
|
-
unsigned char
|
90
|
-
unsigned char
|
91
|
-
char
|
92
|
-
|
93
|
-
|
100
|
+
unsigned char key[crypto_stream_chacha20_KEYBYTES];
|
101
|
+
unsigned char nonce[crypto_stream_chacha20_IETF_NONCEBYTES];
|
102
|
+
unsigned char *part;
|
103
|
+
unsigned char out[160];
|
104
|
+
unsigned char zero[160];
|
105
|
+
char out_hex[160 * 2 + 1];
|
106
|
+
size_t i = 0U;
|
107
|
+
size_t plen;
|
108
|
+
|
109
|
+
memset(zero, 0, sizeof zero);
|
94
110
|
do {
|
95
111
|
sodium_hex2bin((unsigned char *)key, sizeof key, tests[i].key_hex,
|
96
112
|
strlen(tests[i].key_hex), ": ", NULL, NULL);
|
@@ -100,6 +116,14 @@ void tv_ietf(void)
|
|
100
116
|
crypto_stream_chacha20_ietf_xor_ic(out, out, sizeof out, nonce, tests[i].ic, key);
|
101
117
|
sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out);
|
102
118
|
printf("[%s]\n", out_hex);
|
119
|
+
for (plen = 1U; plen < sizeof out; plen++) {
|
120
|
+
part = (unsigned char *) sodium_malloc(plen);
|
121
|
+
crypto_stream_chacha20_ietf_xor_ic(part, out, plen, nonce, tests[i].ic, key);
|
122
|
+
if (memcmp(part, zero, plen) != 0) {
|
123
|
+
printf("Failed with length %lu\n", (unsigned long) plen);
|
124
|
+
}
|
125
|
+
sodium_free(part);
|
126
|
+
}
|
103
127
|
} while (++i < (sizeof tests) / (sizeof tests[0]));
|
104
128
|
|
105
129
|
randombytes_buf(out, sizeof out);
|