rbnacl-libsodium 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/ChangeLog +5 -0
- data/vendor/libsodium/README.markdown +4 -1
- data/vendor/libsodium/autogen.sh +0 -5
- data/vendor/libsodium/autom4te.cache/output.1 +14 -14
- data/vendor/libsodium/autom4te.cache/output.5 +14 -14
- data/vendor/libsodium/autom4te.cache/requests +868 -868
- data/vendor/libsodium/autom4te.cache/traces.1 +1 -1
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +10 -72
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +36 -216
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +10 -72
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +34 -214
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +10 -72
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +34 -214
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +10 -72
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +25 -205
- data/vendor/libsodium/configure +14 -14
- data/vendor/libsodium/configure.ac +5 -5
- data/vendor/libsodium/dist-build/msys2-win32.sh +3 -2
- data/vendor/libsodium/dist-build/msys2-win64.sh +3 -2
- data/vendor/libsodium/examples/sign.c +2 -2
- data/vendor/libsodium/examples/utils.h +3 -1
- data/vendor/libsodium/libsodium.vcxproj +7 -53
- data/vendor/libsodium/libsodium.vcxproj.filters +18 -152
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/libsodium/Makefile.am +6 -68
- data/vendor/libsodium/src/libsodium/Makefile.in +49 -724
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +2 -2
- data/vendor/libsodium/src/libsodium/{crypto_sign/ed25519 → crypto_core/curve25519}/ref10/base.h +0 -0
- data/vendor/libsodium/src/libsodium/{crypto_sign/ed25519 → crypto_core/curve25519}/ref10/base2.h +0 -0
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +2233 -0
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.h +160 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +255 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/{curve25519_ref10.h → x25519_ref10.h} +0 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +1 -2
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +2 -4
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +1 -2
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +1 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +16 -9
- data/vendor/libsodium/src/libsodium/include/sodium/export.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +6 -4
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +12 -8
- data/vendor/libsodium/src/libsodium/sodium/core.c +9 -0
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +32 -10
- data/vendor/libsodium/src/libsodium/sodium/utils.c +8 -8
- data/vendor/libsodium/test/default/auth.c +1 -1
- data/vendor/libsodium/test/default/box.c +16 -4
- data/vendor/libsodium/test/default/box2.c +7 -0
- data/vendor/libsodium/test/default/box7.c +18 -10
- data/vendor/libsodium/test/default/box8.c +1 -1
- data/vendor/libsodium/test/default/box_easy2.c +13 -0
- data/vendor/libsodium/test/default/onetimeauth.c +1 -0
- data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +2 -2
- data/vendor/libsodium/test/default/verify1.c +1 -1
- metadata +9 -71
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.c +0 -73
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe.h +0 -44
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_0_curve25519_ref10.c +0 -23
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_1_curve25519_ref10.c +0 -23
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c +0 -61
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c +0 -33
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c +0 -77
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +0 -74
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c +0 -18
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c +0 -74
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c +0 -257
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c +0 -153
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c +0 -61
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c +0 -123
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/montgomery.h +0 -140
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h +0 -160
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d2.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe.h +0 -56
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_0.c +0 -19
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_1.c +0 -19
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c +0 -57
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c +0 -63
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c +0 -29
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +0 -73
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_invert.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnegative.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c +0 -19
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +0 -253
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c +0 -45
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_pow22523.c +0 -13
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +0 -149
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +0 -160
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c +0 -57
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c +0 -119
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +0 -138
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_frombytes.c +0 -50
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.h +0 -88
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.h +0 -88
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p2.c +0 -12
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p3.c +0 -13
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_0.c +0 -8
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.h +0 -73
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_0.c +0 -9
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_dbl.c +0 -12
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_cached.c +0 -17
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_p2.c +0 -12
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_tobytes.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_precomp_0.c +0 -8
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +0 -111
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_tobytes.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +0 -160
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +0 -160
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc.h +0 -15
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c +0 -368
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c +0 -275
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sqrtm1.h +0 -1
@@ -0,0 +1,160 @@
|
|
1
|
+
#ifndef CURVE25519_REF10_H
|
2
|
+
#define CURVE25519_REF10_H
|
3
|
+
|
4
|
+
#include <stddef.h>
|
5
|
+
#include <stdint.h>
|
6
|
+
|
7
|
+
#define fe crypto_core_curve25519_ref10_fe
|
8
|
+
typedef int32_t fe[10];
|
9
|
+
|
10
|
+
/*
|
11
|
+
fe means field element.
|
12
|
+
Here the field is \Z/(2^255-19).
|
13
|
+
An element t, entries t[0]...t[9], represents the integer
|
14
|
+
t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
|
15
|
+
Bounds on each t[i] vary depending on context.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#define fe_frombytes crypto_core_curve25519_ref10_fe_frombytes
|
19
|
+
#define fe_tobytes crypto_core_curve25519_ref10_fe_tobytes
|
20
|
+
#define fe_copy crypto_core_curve25519_ref10_fe_copy
|
21
|
+
#define fe_isnonzero crypto_core_curve25519_ref10_fe_isnonzero
|
22
|
+
#define fe_isnegative crypto_core_curve25519_ref10_fe_isnegative
|
23
|
+
#define fe_0 crypto_core_curve25519_ref10_fe_0
|
24
|
+
#define fe_1 crypto_core_curve25519_ref10_fe_1
|
25
|
+
#define fe_cmov crypto_core_curve25519_ref10_fe_cmov
|
26
|
+
#define fe_add crypto_core_curve25519_ref10_fe_add
|
27
|
+
#define fe_sub crypto_core_curve25519_ref10_fe_sub
|
28
|
+
#define fe_neg crypto_core_curve25519_ref10_fe_neg
|
29
|
+
#define fe_mul crypto_core_curve25519_ref10_fe_mul
|
30
|
+
#define fe_sq crypto_core_curve25519_ref10_fe_sq
|
31
|
+
#define fe_sq2 crypto_core_curve25519_ref10_fe_sq2
|
32
|
+
#define fe_invert crypto_core_curve25519_ref10_fe_invert
|
33
|
+
#define fe_pow22523 crypto_core_curve25519_ref10_fe_pow22523
|
34
|
+
|
35
|
+
extern void fe_frombytes(fe,const unsigned char *);
|
36
|
+
extern void fe_tobytes(unsigned char *,const fe);
|
37
|
+
|
38
|
+
extern void fe_copy(fe,const fe);
|
39
|
+
extern int fe_isnonzero(const fe);
|
40
|
+
extern int fe_isnegative(const fe);
|
41
|
+
extern void fe_0(fe);
|
42
|
+
extern void fe_1(fe);
|
43
|
+
extern void fe_cmov(fe,const fe,unsigned int);
|
44
|
+
extern void fe_add(fe,const fe,const fe);
|
45
|
+
extern void fe_sub(fe,const fe,const fe);
|
46
|
+
extern void fe_neg(fe,const fe);
|
47
|
+
extern void fe_mul(fe,const fe,const fe);
|
48
|
+
extern void fe_sq(fe,const fe);
|
49
|
+
extern void fe_sq2(fe,const fe);
|
50
|
+
extern void fe_invert(fe,const fe);
|
51
|
+
extern void fe_pow22523(fe,const fe);
|
52
|
+
|
53
|
+
/*
|
54
|
+
ge means group element.
|
55
|
+
|
56
|
+
Here the group is the set of pairs (x,y) of field elements (see fe.h)
|
57
|
+
satisfying -x^2 + y^2 = 1 + d x^2y^2
|
58
|
+
where d = -121665/121666.
|
59
|
+
|
60
|
+
Representations:
|
61
|
+
ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
|
62
|
+
ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
|
63
|
+
ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
|
64
|
+
ge_precomp (Duif): (y+x,y-x,2dxy)
|
65
|
+
*/
|
66
|
+
|
67
|
+
#define ge_p2 crypto_core_curve25519_ref10_ge_p2
|
68
|
+
typedef struct {
|
69
|
+
fe X;
|
70
|
+
fe Y;
|
71
|
+
fe Z;
|
72
|
+
} ge_p2;
|
73
|
+
|
74
|
+
#define ge_p3 crypto_core_curve25519_ref10_ge_p3
|
75
|
+
typedef struct {
|
76
|
+
fe X;
|
77
|
+
fe Y;
|
78
|
+
fe Z;
|
79
|
+
fe T;
|
80
|
+
} ge_p3;
|
81
|
+
|
82
|
+
#define ge_p1p1 crypto_core_curve25519_ref10_ge_p1p1
|
83
|
+
typedef struct {
|
84
|
+
fe X;
|
85
|
+
fe Y;
|
86
|
+
fe Z;
|
87
|
+
fe T;
|
88
|
+
} ge_p1p1;
|
89
|
+
|
90
|
+
#define ge_precomp crypto_core_curve25519_ref10_ge_precomp
|
91
|
+
typedef struct {
|
92
|
+
fe yplusx;
|
93
|
+
fe yminusx;
|
94
|
+
fe xy2d;
|
95
|
+
} ge_precomp;
|
96
|
+
|
97
|
+
#define ge_cached crypto_core_curve25519_ref10_ge_cached
|
98
|
+
typedef struct {
|
99
|
+
fe YplusX;
|
100
|
+
fe YminusX;
|
101
|
+
fe Z;
|
102
|
+
fe T2d;
|
103
|
+
} ge_cached;
|
104
|
+
|
105
|
+
#define ge_frombytes_negate_vartime crypto_core_curve25519_ref10_ge_frombytes_negate_vartime
|
106
|
+
#define ge_tobytes crypto_core_curve25519_ref10_ge_tobytes
|
107
|
+
#define ge_p3_tobytes crypto_core_curve25519_ref10_ge_p3_tobytes
|
108
|
+
|
109
|
+
#define ge_p2_0 crypto_core_curve25519_ref10_ge_p2_0
|
110
|
+
#define ge_p3_0 crypto_core_curve25519_ref10_ge_p3_0
|
111
|
+
#define ge_precomp_0 crypto_core_curve25519_ref10_ge_precomp_0
|
112
|
+
#define ge_p3_to_p2 crypto_core_curve25519_ref10_ge_p3_to_p2
|
113
|
+
#define ge_p3_to_cached crypto_core_curve25519_ref10_ge_p3_to_cached
|
114
|
+
#define ge_p1p1_to_p2 crypto_core_curve25519_ref10_ge_p1p1_to_p2
|
115
|
+
#define ge_p1p1_to_p3 crypto_core_curve25519_ref10_ge_p1p1_to_p3
|
116
|
+
#define ge_p2_dbl crypto_core_curve25519_ref10_ge_p2_dbl
|
117
|
+
#define ge_p3_dbl crypto_core_curve25519_ref10_ge_p3_dbl
|
118
|
+
|
119
|
+
#define ge_madd crypto_core_curve25519_ref10_ge_madd
|
120
|
+
#define ge_msub crypto_core_curve25519_ref10_ge_msub
|
121
|
+
#define ge_add crypto_core_curve25519_ref10_ge_add
|
122
|
+
#define ge_sub crypto_core_curve25519_ref10_ge_sub
|
123
|
+
#define ge_scalarmult_base crypto_core_curve25519_ref10_ge_scalarmult_base
|
124
|
+
#define ge_double_scalarmult_vartime crypto_core_curve25519_ref10_ge_double_scalarmult_vartime
|
125
|
+
#define ge_scalarmult_vartime crypto_core_curve25519_ref10_ge_scalarmult_vartime
|
126
|
+
|
127
|
+
extern void ge_tobytes(unsigned char *,const ge_p2 *);
|
128
|
+
extern void ge_p3_tobytes(unsigned char *,const ge_p3 *);
|
129
|
+
extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
|
130
|
+
|
131
|
+
extern void ge_p2_0(ge_p2 *);
|
132
|
+
extern void ge_p3_0(ge_p3 *);
|
133
|
+
extern void ge_precomp_0(ge_precomp *);
|
134
|
+
extern void ge_p3_to_p2(ge_p2 *,const ge_p3 *);
|
135
|
+
extern void ge_p3_to_cached(ge_cached *,const ge_p3 *);
|
136
|
+
extern void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *);
|
137
|
+
extern void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *);
|
138
|
+
extern void ge_p2_dbl(ge_p1p1 *,const ge_p2 *);
|
139
|
+
extern void ge_p3_dbl(ge_p1p1 *,const ge_p3 *);
|
140
|
+
|
141
|
+
extern void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
|
142
|
+
extern void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
|
143
|
+
extern void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *);
|
144
|
+
extern void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *);
|
145
|
+
extern void ge_scalarmult_base(ge_p3 *,const unsigned char *);
|
146
|
+
extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *);
|
147
|
+
extern void ge_scalarmult_vartime(ge_p3 *,const unsigned char *,const ge_p3 *);
|
148
|
+
|
149
|
+
/*
|
150
|
+
The set of scalars is \Z/l
|
151
|
+
where l = 2^252 + 27742317777372353535851937790883648493.
|
152
|
+
*/
|
153
|
+
|
154
|
+
#define sc_reduce crypto_core_curve25519_ref10_sc_reduce
|
155
|
+
#define sc_muladd crypto_core_curve25519_ref10_sc_muladd
|
156
|
+
|
157
|
+
extern void sc_reduce(unsigned char *);
|
158
|
+
extern void sc_muladd(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
|
159
|
+
|
160
|
+
#endif
|
@@ -24,7 +24,7 @@
|
|
24
24
|
# if defined(__SIZEOF_INT128__)
|
25
25
|
typedef unsigned __int128 uint128_t;
|
26
26
|
# else
|
27
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
27
|
+
typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
28
28
|
# endif
|
29
29
|
#endif
|
30
30
|
|
@@ -321,7 +321,7 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
|
321
321
|
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
322
322
|
{
|
323
323
|
if( !outlen || outlen > BLAKE2B_OUTBYTES ) {
|
324
|
-
abort();
|
324
|
+
abort(); /* LCOV_EXCL_LINE */
|
325
325
|
}
|
326
326
|
if( S->buflen > BLAKE2B_BLOCKBYTES )
|
327
327
|
{
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#if defined(__SIZEOF_INT128__)
|
6
6
|
typedef unsigned __int128 uint128_t;
|
7
7
|
#else
|
8
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
8
|
+
typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
9
9
|
#endif
|
10
10
|
|
11
11
|
#define MUL(out, x, y) out = ((uint128_t)x * y)
|
@@ -17,7 +17,7 @@ typedef unsigned uint128_t __attribute__((mode(TI)));
|
|
17
17
|
#if defined(_MSC_VER)
|
18
18
|
# define POLY1305_NOINLINE __declspec(noinline)
|
19
19
|
#elif defined(__GNUC__)
|
20
|
-
# define POLY1305_NOINLINE __attribute__((noinline))
|
20
|
+
# define POLY1305_NOINLINE __attribute__ ((noinline))
|
21
21
|
#else
|
22
22
|
# define POLY1305_NOINLINE
|
23
23
|
#endif
|
@@ -18,13 +18,13 @@ typedef __m128i xmmi;
|
|
18
18
|
#if defined(__SIZEOF_INT128__)
|
19
19
|
typedef unsigned __int128 uint128_t;
|
20
20
|
#else
|
21
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
21
|
+
typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
22
22
|
#endif
|
23
23
|
|
24
24
|
#if defined(_MSC_VER)
|
25
25
|
# define POLY1305_NOINLINE __declspec(noinline)
|
26
26
|
#elif defined(__GNUC__)
|
27
|
-
# define POLY1305_NOINLINE __attribute__((noinline))
|
27
|
+
# define POLY1305_NOINLINE __attribute__ ((noinline))
|
28
28
|
#else
|
29
29
|
# define POLY1305_NOINLINE
|
30
30
|
#endif
|
data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c
CHANGED
@@ -36,7 +36,7 @@ typedef uint64_t limb;
|
|
36
36
|
typedef limb felem[5];
|
37
37
|
// This is a special gcc mode for 128-bit integers. It's implemented on 64-bit
|
38
38
|
// platforms only as far as I know.
|
39
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
39
|
+
typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
40
40
|
|
41
41
|
/* Sum two numbers: output += in */
|
42
42
|
static inline void
|
@@ -0,0 +1,255 @@
|
|
1
|
+
|
2
|
+
#include <stddef.h>
|
3
|
+
#include <stdint.h>
|
4
|
+
|
5
|
+
#ifndef HAVE_TI_MODE
|
6
|
+
|
7
|
+
#include "utils.h"
|
8
|
+
#include "x25519_ref10.h"
|
9
|
+
#include "../scalarmult_curve25519.h"
|
10
|
+
#include "../../../crypto_core/curve25519/ref10/curve25519_ref10.h"
|
11
|
+
|
12
|
+
/*
|
13
|
+
Replace (f,g) with (g,f) if b == 1;
|
14
|
+
replace (f,g) with (f,g) if b == 0.
|
15
|
+
|
16
|
+
Preconditions: b in {0,1}.
|
17
|
+
*/
|
18
|
+
|
19
|
+
static void
|
20
|
+
fe_cswap(fe f,fe g,unsigned int b)
|
21
|
+
{
|
22
|
+
int32_t f0 = f[0];
|
23
|
+
int32_t f1 = f[1];
|
24
|
+
int32_t f2 = f[2];
|
25
|
+
int32_t f3 = f[3];
|
26
|
+
int32_t f4 = f[4];
|
27
|
+
int32_t f5 = f[5];
|
28
|
+
int32_t f6 = f[6];
|
29
|
+
int32_t f7 = f[7];
|
30
|
+
int32_t f8 = f[8];
|
31
|
+
int32_t f9 = f[9];
|
32
|
+
int32_t g0 = g[0];
|
33
|
+
int32_t g1 = g[1];
|
34
|
+
int32_t g2 = g[2];
|
35
|
+
int32_t g3 = g[3];
|
36
|
+
int32_t g4 = g[4];
|
37
|
+
int32_t g5 = g[5];
|
38
|
+
int32_t g6 = g[6];
|
39
|
+
int32_t g7 = g[7];
|
40
|
+
int32_t g8 = g[8];
|
41
|
+
int32_t g9 = g[9];
|
42
|
+
int32_t x0 = f0 ^ g0;
|
43
|
+
int32_t x1 = f1 ^ g1;
|
44
|
+
int32_t x2 = f2 ^ g2;
|
45
|
+
int32_t x3 = f3 ^ g3;
|
46
|
+
int32_t x4 = f4 ^ g4;
|
47
|
+
int32_t x5 = f5 ^ g5;
|
48
|
+
int32_t x6 = f6 ^ g6;
|
49
|
+
int32_t x7 = f7 ^ g7;
|
50
|
+
int32_t x8 = f8 ^ g8;
|
51
|
+
int32_t x9 = f9 ^ g9;
|
52
|
+
b = (unsigned int) (- (int) b);
|
53
|
+
x0 &= b;
|
54
|
+
x1 &= b;
|
55
|
+
x2 &= b;
|
56
|
+
x3 &= b;
|
57
|
+
x4 &= b;
|
58
|
+
x5 &= b;
|
59
|
+
x6 &= b;
|
60
|
+
x7 &= b;
|
61
|
+
x8 &= b;
|
62
|
+
x9 &= b;
|
63
|
+
f[0] = f0 ^ x0;
|
64
|
+
f[1] = f1 ^ x1;
|
65
|
+
f[2] = f2 ^ x2;
|
66
|
+
f[3] = f3 ^ x3;
|
67
|
+
f[4] = f4 ^ x4;
|
68
|
+
f[5] = f5 ^ x5;
|
69
|
+
f[6] = f6 ^ x6;
|
70
|
+
f[7] = f7 ^ x7;
|
71
|
+
f[8] = f8 ^ x8;
|
72
|
+
f[9] = f9 ^ x9;
|
73
|
+
g[0] = g0 ^ x0;
|
74
|
+
g[1] = g1 ^ x1;
|
75
|
+
g[2] = g2 ^ x2;
|
76
|
+
g[3] = g3 ^ x3;
|
77
|
+
g[4] = g4 ^ x4;
|
78
|
+
g[5] = g5 ^ x5;
|
79
|
+
g[6] = g6 ^ x6;
|
80
|
+
g[7] = g7 ^ x7;
|
81
|
+
g[8] = g8 ^ x8;
|
82
|
+
g[9] = g9 ^ x9;
|
83
|
+
}
|
84
|
+
|
85
|
+
/*
|
86
|
+
h = f * 121666
|
87
|
+
Can overlap h with f.
|
88
|
+
|
89
|
+
Preconditions:
|
90
|
+
|f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|
91
|
+
|
92
|
+
Postconditions:
|
93
|
+
|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|
94
|
+
*/
|
95
|
+
|
96
|
+
static void
|
97
|
+
fe_mul121666(fe h,const fe f)
|
98
|
+
{
|
99
|
+
int32_t f0 = f[0];
|
100
|
+
int32_t f1 = f[1];
|
101
|
+
int32_t f2 = f[2];
|
102
|
+
int32_t f3 = f[3];
|
103
|
+
int32_t f4 = f[4];
|
104
|
+
int32_t f5 = f[5];
|
105
|
+
int32_t f6 = f[6];
|
106
|
+
int32_t f7 = f[7];
|
107
|
+
int32_t f8 = f[8];
|
108
|
+
int32_t f9 = f[9];
|
109
|
+
int64_t h0 = f0 * (int64_t) 121666;
|
110
|
+
int64_t h1 = f1 * (int64_t) 121666;
|
111
|
+
int64_t h2 = f2 * (int64_t) 121666;
|
112
|
+
int64_t h3 = f3 * (int64_t) 121666;
|
113
|
+
int64_t h4 = f4 * (int64_t) 121666;
|
114
|
+
int64_t h5 = f5 * (int64_t) 121666;
|
115
|
+
int64_t h6 = f6 * (int64_t) 121666;
|
116
|
+
int64_t h7 = f7 * (int64_t) 121666;
|
117
|
+
int64_t h8 = f8 * (int64_t) 121666;
|
118
|
+
int64_t h9 = f9 * (int64_t) 121666;
|
119
|
+
int64_t carry0;
|
120
|
+
int64_t carry1;
|
121
|
+
int64_t carry2;
|
122
|
+
int64_t carry3;
|
123
|
+
int64_t carry4;
|
124
|
+
int64_t carry5;
|
125
|
+
int64_t carry6;
|
126
|
+
int64_t carry7;
|
127
|
+
int64_t carry8;
|
128
|
+
int64_t carry9;
|
129
|
+
|
130
|
+
carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
|
131
|
+
carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
|
132
|
+
carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
|
133
|
+
carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
|
134
|
+
carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
|
135
|
+
|
136
|
+
carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
|
137
|
+
carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
|
138
|
+
carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
|
139
|
+
carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
|
140
|
+
carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
|
141
|
+
|
142
|
+
h[0] = h0;
|
143
|
+
h[1] = h1;
|
144
|
+
h[2] = h2;
|
145
|
+
h[3] = h3;
|
146
|
+
h[4] = h4;
|
147
|
+
h[5] = h5;
|
148
|
+
h[6] = h6;
|
149
|
+
h[7] = h7;
|
150
|
+
h[8] = h8;
|
151
|
+
h[9] = h9;
|
152
|
+
}
|
153
|
+
|
154
|
+
static int
|
155
|
+
crypto_scalarmult_curve25519_ref10(unsigned char *q,
|
156
|
+
const unsigned char *n,
|
157
|
+
const unsigned char *p)
|
158
|
+
{
|
159
|
+
unsigned char e[32];
|
160
|
+
unsigned int i;
|
161
|
+
fe x1;
|
162
|
+
fe x2;
|
163
|
+
fe z2;
|
164
|
+
fe x3;
|
165
|
+
fe z3;
|
166
|
+
fe tmp0;
|
167
|
+
fe tmp1;
|
168
|
+
int pos;
|
169
|
+
unsigned int swap;
|
170
|
+
unsigned int b;
|
171
|
+
|
172
|
+
for (i = 0;i < 32;++i) e[i] = n[i];
|
173
|
+
e[0] &= 248;
|
174
|
+
e[31] &= 127;
|
175
|
+
e[31] |= 64;
|
176
|
+
fe_frombytes(x1,p);
|
177
|
+
fe_1(x2);
|
178
|
+
fe_0(z2);
|
179
|
+
fe_copy(x3,x1);
|
180
|
+
fe_1(z3);
|
181
|
+
|
182
|
+
swap = 0;
|
183
|
+
for (pos = 254;pos >= 0;--pos) {
|
184
|
+
b = e[pos / 8] >> (pos & 7);
|
185
|
+
b &= 1;
|
186
|
+
swap ^= b;
|
187
|
+
fe_cswap(x2,x3,swap);
|
188
|
+
fe_cswap(z2,z3,swap);
|
189
|
+
swap = b;
|
190
|
+
fe_sub(tmp0,x3,z3);
|
191
|
+
fe_sub(tmp1,x2,z2);
|
192
|
+
fe_add(x2,x2,z2);
|
193
|
+
fe_add(z2,x3,z3);
|
194
|
+
fe_mul(z3,tmp0,x2);
|
195
|
+
fe_mul(z2,z2,tmp1);
|
196
|
+
fe_sq(tmp0,tmp1);
|
197
|
+
fe_sq(tmp1,x2);
|
198
|
+
fe_add(x3,z3,z2);
|
199
|
+
fe_sub(z2,z3,z2);
|
200
|
+
fe_mul(x2,tmp1,tmp0);
|
201
|
+
fe_sub(tmp1,tmp1,tmp0);
|
202
|
+
fe_sq(z2,z2);
|
203
|
+
fe_mul121666(z3,tmp1);
|
204
|
+
fe_sq(x3,x3);
|
205
|
+
fe_add(tmp0,tmp0,z3);
|
206
|
+
fe_mul(z3,x1,z2);
|
207
|
+
fe_mul(z2,tmp1,tmp0);
|
208
|
+
}
|
209
|
+
fe_cswap(x2,x3,swap);
|
210
|
+
fe_cswap(z2,z3,swap);
|
211
|
+
|
212
|
+
fe_invert(z2,z2);
|
213
|
+
fe_mul(x2,x2,z2);
|
214
|
+
fe_tobytes(q,x2);
|
215
|
+
return 0;
|
216
|
+
}
|
217
|
+
|
218
|
+
static void
|
219
|
+
edwards_to_montgomery(fe montgomeryX, const fe edwardsY, const fe edwardsZ)
|
220
|
+
{
|
221
|
+
fe tempX;
|
222
|
+
fe tempZ;
|
223
|
+
|
224
|
+
fe_add(tempX, edwardsZ, edwardsY);
|
225
|
+
fe_sub(tempZ, edwardsZ, edwardsY);
|
226
|
+
fe_invert(tempZ, tempZ);
|
227
|
+
fe_mul(montgomeryX, tempX, tempZ);
|
228
|
+
}
|
229
|
+
|
230
|
+
static int
|
231
|
+
crypto_scalarmult_curve25519_ref10_base(unsigned char *q,
|
232
|
+
const unsigned char *n)
|
233
|
+
{
|
234
|
+
unsigned char e[32];
|
235
|
+
ge_p3 A;
|
236
|
+
fe pk;
|
237
|
+
unsigned int i;
|
238
|
+
|
239
|
+
for (i = 0;i < 32;++i) e[i] = n[i];
|
240
|
+
e[0] &= 248;
|
241
|
+
e[31] &= 127;
|
242
|
+
e[31] |= 64;
|
243
|
+
ge_scalarmult_base(&A, e);
|
244
|
+
edwards_to_montgomery(pk, A.Y, A.Z);
|
245
|
+
fe_tobytes(q, pk);
|
246
|
+
return 0;
|
247
|
+
}
|
248
|
+
|
249
|
+
struct crypto_scalarmult_curve25519_implementation
|
250
|
+
crypto_scalarmult_curve25519_ref10_implementation = {
|
251
|
+
SODIUM_C99(.mult = ) crypto_scalarmult_curve25519_ref10,
|
252
|
+
SODIUM_C99(.mult_base = ) crypto_scalarmult_curve25519_ref10_base
|
253
|
+
};
|
254
|
+
|
255
|
+
#endif
|