rbnacl-libsodium 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +23 -0
- data/CHANGES.md +5 -0
- data/Gemfile +5 -2
- data/Rakefile +5 -0
- data/ext/rbnacl/extconf.rb +2 -1
- data/lib/rbnacl/libsodium.rb +8 -2
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +14 -0
- data/vendor/libsodium/ChangeLog +26 -0
- data/vendor/libsodium/LICENSE +1 -1
- data/vendor/libsodium/Makefile.am +1 -0
- data/vendor/libsodium/Makefile.in +9 -0
- data/vendor/libsodium/README.markdown +7 -0
- data/vendor/libsodium/aclocal.m4 +1 -0
- data/vendor/libsodium/appveyor.yml +25 -0
- data/vendor/libsodium/autom4te.cache/output.1 +640 -126
- data/vendor/libsodium/autom4te.cache/output.6 +19049 -0
- data/vendor/libsodium/autom4te.cache/requests +1151 -914
- data/vendor/libsodium/autom4te.cache/traces.1 +472 -426
- data/vendor/libsodium/autom4te.cache/traces.6 +3193 -0
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +50 -79
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +208 -166
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +50 -79
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +52 -81
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/builds/msvc/vs2015/libsodium.sln +52 -81
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/configure +639 -125
- data/vendor/libsodium/configure.ac +94 -16
- data/vendor/libsodium/dist-build/Makefile.in +9 -0
- data/vendor/libsodium/dist-build/emscripten-symbols.def +370 -0
- data/vendor/libsodium/dist-build/emscripten.sh +9 -3
- data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +43 -0
- data/vendor/libsodium/libsodium-uninstalled.pc.in +1 -1
- data/vendor/libsodium/libsodium.pc.in +1 -1
- data/vendor/libsodium/libsodium.vcxproj +70 -66
- data/vendor/libsodium/libsodium.vcxproj.filters +204 -192
- data/vendor/libsodium/m4/ax_valgrind_check.m4 +190 -0
- data/vendor/libsodium/msvc-scripts/Makefile.in +9 -0
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/Makefile.in +9 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +31 -6
- data/vendor/libsodium/src/libsodium/Makefile.in +238 -42
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +234 -38
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +208 -118
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +1 -4
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1799 -1790
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.h +39 -39
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +86 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +28 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +38 -46
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -89
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +50 -141
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +45 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +123 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/{blake2b-round.h → blake2b-compress-sse41.h} +2 -28
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +2 -4
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +97 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +339 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +29 -18
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +4 -43
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +3 -32
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -20
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +22 -41
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +12 -39
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +2 -4
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -20
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +570 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +198 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +444 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +32 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +229 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +222 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +40 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +238 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +251 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +80 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +38 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +117 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +164 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +106 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +186 -186
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +33 -33
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +253 -254
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +16 -17
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +11 -11
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +3 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +5 -3
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +41 -41
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +10 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +31 -32
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +2 -6
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +8 -28
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +6 -6
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +1 -18
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +20 -20
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +6 -6
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +56 -77
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +1 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +1 -5
- data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.in +19 -8
- data/vendor/libsodium/src/libsodium/include/sodium.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +50 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +94 -22
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +6 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hchacha20.h +35 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +89 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +86 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +6 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +0 -11
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -0
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +5 -1
- data/vendor/libsodium/src/libsodium/sodium/common.h +150 -0
- data/vendor/libsodium/src/libsodium/sodium/core.c +3 -1
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +37 -19
- data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -9
- data/vendor/libsodium/test/Makefile.in +9 -0
- data/vendor/libsodium/test/default/Makefile.am +10 -0
- data/vendor/libsodium/test/default/Makefile.in +53 -20
- data/vendor/libsodium/test/default/aead_aes256gcm.c +43 -17
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +179 -86
- data/vendor/libsodium/test/default/auth7.c +5 -5
- data/vendor/libsodium/test/default/box.c +4 -4
- data/vendor/libsodium/test/default/box2.c +1 -1
- data/vendor/libsodium/test/default/core6.c +1 -1
- data/vendor/libsodium/test/default/generichash.c +12 -1
- data/vendor/libsodium/test/default/generichash2.c +2 -2
- data/vendor/libsodium/test/default/generichash3.c +21 -0
- data/vendor/libsodium/test/default/pwhash.c +186 -168
- data/vendor/libsodium/test/default/pwhash.exp +11 -30
- data/vendor/libsodium/test/default/pwhash_scrypt.c +349 -0
- data/vendor/libsodium/test/default/pwhash_scrypt.exp +31 -0
- data/vendor/libsodium/test/default/secretbox.c +1 -1
- data/vendor/libsodium/test/default/secretbox2.c +1 -1
- data/vendor/libsodium/test/default/sign.c +15 -0
- data/vendor/libsodium/test/default/sodium_utils2.c +8 -3
- data/vendor/libsodium/test/default/sodium_utils3.c +4 -2
- data/vendor/libsodium/test/default/verify1.c +0 -4
- data/vendor/libsodium/test/quirks/quirks.h +3 -0
- metadata +37 -22
- data/vendor/libsodium/builds/msvc/vs2010/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2012/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2013/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2015/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2015/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +0 -146
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +0 -64
@@ -19,6 +19,7 @@
|
|
19
19
|
#include "blake2.h"
|
20
20
|
#include "blake2-impl.h"
|
21
21
|
#include "runtime.h"
|
22
|
+
#include "../../sodium/common.h"
|
22
23
|
|
23
24
|
#ifdef HAVE_TI_MODE
|
24
25
|
# if defined(__SIZEOF_INT128__)
|
@@ -83,7 +84,7 @@ static inline int blake2b_increment_counter( blake2b_state *S, const uint64_t in
|
|
83
84
|
return 0;
|
84
85
|
}
|
85
86
|
|
86
|
-
|
87
|
+
/* Parameter-related functions */
|
87
88
|
#if 0
|
88
89
|
static inline int blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
89
90
|
{
|
@@ -105,13 +106,13 @@ static inline int blake2b_param_set_max_depth( blake2b_param *P, const uint8_t d
|
|
105
106
|
|
106
107
|
static inline int blake2b_param_set_leaf_length( blake2b_param *P, const uint32_t leaf_length )
|
107
108
|
{
|
108
|
-
|
109
|
+
STORE32_LE( P->leaf_length, leaf_length );
|
109
110
|
return 0;
|
110
111
|
}
|
111
112
|
|
112
113
|
static inline int blake2b_param_set_node_offset( blake2b_param *P, const uint64_t node_offset )
|
113
114
|
{
|
114
|
-
|
115
|
+
STORE64_LE( P->node_offset, node_offset );
|
115
116
|
return 0;
|
116
117
|
}
|
117
118
|
|
@@ -155,12 +156,13 @@ int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
|
155
156
|
size_t i;
|
156
157
|
const uint8_t *p;
|
157
158
|
|
159
|
+
(void) sizeof(int[sizeof *P == 64 ? 1 : -1]);
|
158
160
|
blake2b_init0( S );
|
159
161
|
p = ( const uint8_t * )( P );
|
160
162
|
|
161
163
|
/* IV XOR ParamBlock */
|
162
164
|
for( i = 0; i < 8; ++i )
|
163
|
-
S->h[i] ^=
|
165
|
+
S->h[i] ^= LOAD64_LE( p + sizeof( S->h[i] ) * i );
|
164
166
|
|
165
167
|
return 0;
|
166
168
|
}
|
@@ -175,8 +177,8 @@ int blake2b_init( blake2b_state *S, const uint8_t outlen )
|
|
175
177
|
P->key_length = 0;
|
176
178
|
P->fanout = 1;
|
177
179
|
P->depth = 1;
|
178
|
-
|
179
|
-
|
180
|
+
STORE32_LE( P->leaf_length, 0 );
|
181
|
+
STORE64_LE( P->node_offset, 0 );
|
180
182
|
P->node_depth = 0;
|
181
183
|
P->inner_length = 0;
|
182
184
|
memset( P->reserved, 0, sizeof( P->reserved ) );
|
@@ -196,8 +198,8 @@ int blake2b_init_salt_personal( blake2b_state *S, const uint8_t outlen,
|
|
196
198
|
P->key_length = 0;
|
197
199
|
P->fanout = 1;
|
198
200
|
P->depth = 1;
|
199
|
-
|
200
|
-
|
201
|
+
STORE32_LE( P->leaf_length, 0 );
|
202
|
+
STORE64_LE( P->node_offset, 0 );
|
201
203
|
P->node_depth = 0;
|
202
204
|
P->inner_length = 0;
|
203
205
|
memset( P->reserved, 0, sizeof( P->reserved ) );
|
@@ -226,8 +228,8 @@ int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, c
|
|
226
228
|
P->key_length = keylen;
|
227
229
|
P->fanout = 1;
|
228
230
|
P->depth = 1;
|
229
|
-
|
230
|
-
|
231
|
+
STORE32_LE( P->leaf_length, 0 );
|
232
|
+
STORE64_LE( P->node_offset, 0 );
|
231
233
|
P->node_depth = 0;
|
232
234
|
P->inner_length = 0;
|
233
235
|
memset( P->reserved, 0, sizeof( P->reserved ) );
|
@@ -259,8 +261,8 @@ int blake2b_init_key_salt_personal( blake2b_state *S, const uint8_t outlen, cons
|
|
259
261
|
P->key_length = keylen;
|
260
262
|
P->fanout = 1;
|
261
263
|
P->depth = 1;
|
262
|
-
|
263
|
-
|
264
|
+
STORE32_LE( P->leaf_length, 0 );
|
265
|
+
STORE64_LE( P->node_offset, 0 );
|
264
266
|
P->node_depth = 0;
|
265
267
|
P->inner_length = 0;
|
266
268
|
memset( P->reserved, 0, sizeof( P->reserved ) );
|
@@ -297,19 +299,19 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
|
|
297
299
|
|
298
300
|
if( inlen > fill )
|
299
301
|
{
|
300
|
-
memcpy( S->buf + left, in, fill );
|
302
|
+
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
301
303
|
S->buflen += fill;
|
302
304
|
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
303
|
-
blake2b_compress( S, S->buf );
|
304
|
-
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES );
|
305
|
+
blake2b_compress( S, S->buf ); /* Compress */
|
306
|
+
memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); /* Shift buffer left */
|
305
307
|
S->buflen -= BLAKE2B_BLOCKBYTES;
|
306
308
|
in += fill;
|
307
309
|
inlen -= fill;
|
308
310
|
}
|
309
|
-
else
|
311
|
+
else /* inlen <= fill */
|
310
312
|
{
|
311
313
|
memcpy( S->buf + left, in, inlen );
|
312
|
-
S->buflen += inlen;
|
314
|
+
S->buflen += inlen; /* Be lazy, do not compress */
|
313
315
|
in += inlen;
|
314
316
|
inlen -= inlen;
|
315
317
|
}
|
@@ -345,7 +347,7 @@ int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
|
|
345
347
|
int i;
|
346
348
|
|
347
349
|
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
348
|
-
|
350
|
+
STORE64_LE( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
349
351
|
memcpy( out, buffer, outlen );
|
350
352
|
}
|
351
353
|
#endif
|
@@ -415,6 +417,14 @@ int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const
|
|
415
417
|
int
|
416
418
|
blake2b_pick_best_implementation(void)
|
417
419
|
{
|
420
|
+
/* LCOV_EXCL_START */
|
421
|
+
#if (defined(HAVE_AVX2INTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)) || \
|
422
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64)))
|
423
|
+
if (sodium_runtime_has_avx2()) {
|
424
|
+
blake2b_compress = blake2b_compress_avx2;
|
425
|
+
return 0;
|
426
|
+
}
|
427
|
+
#endif
|
418
428
|
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)) || \
|
419
429
|
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
420
430
|
if (sodium_runtime_has_sse41()) {
|
@@ -432,4 +442,5 @@ blake2b_pick_best_implementation(void)
|
|
432
442
|
blake2b_compress = blake2b_compress_ref;
|
433
443
|
|
434
444
|
return 0;
|
445
|
+
/* LCOV_EXCL_STOP */
|
435
446
|
}
|
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
#include "crypto_hash_sha256.h"
|
30
30
|
#include "utils.h"
|
31
|
+
#include "../../../sodium/common.h"
|
31
32
|
|
32
33
|
#include <sys/types.h>
|
33
34
|
|
@@ -36,53 +37,13 @@
|
|
36
37
|
#include <stdlib.h>
|
37
38
|
#include <string.h>
|
38
39
|
|
39
|
-
/* Avoid namespace collisions with BSD <sys/endian.h>. */
|
40
|
-
#define be32dec _sha256_be32dec
|
41
|
-
#define be32enc _sha256_be32enc
|
42
|
-
#define be64enc _sha256_be64enc
|
43
|
-
|
44
|
-
static inline uint32_t
|
45
|
-
be32dec(const void *pp)
|
46
|
-
{
|
47
|
-
const uint8_t *p = (uint8_t const *)pp;
|
48
|
-
|
49
|
-
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
50
|
-
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
51
|
-
}
|
52
|
-
|
53
|
-
static inline void
|
54
|
-
be32enc(void *pp, uint32_t x)
|
55
|
-
{
|
56
|
-
uint8_t *p = (uint8_t *)pp;
|
57
|
-
|
58
|
-
p[3] = x & 0xff;
|
59
|
-
p[2] = (x >> 8) & 0xff;
|
60
|
-
p[1] = (x >> 16) & 0xff;
|
61
|
-
p[0] = (x >> 24) & 0xff;
|
62
|
-
}
|
63
|
-
|
64
|
-
static inline void
|
65
|
-
be64enc(void * pp, uint64_t x)
|
66
|
-
{
|
67
|
-
uint8_t * p = (uint8_t *)pp;
|
68
|
-
|
69
|
-
p[7] = x & 0xff;
|
70
|
-
p[6] = (x >> 8) & 0xff;
|
71
|
-
p[5] = (x >> 16) & 0xff;
|
72
|
-
p[4] = (x >> 24) & 0xff;
|
73
|
-
p[3] = (x >> 32) & 0xff;
|
74
|
-
p[2] = (x >> 40) & 0xff;
|
75
|
-
p[1] = (x >> 48) & 0xff;
|
76
|
-
p[0] = (x >> 56) & 0xff;
|
77
|
-
}
|
78
|
-
|
79
40
|
static void
|
80
41
|
be32enc_vect(unsigned char *dst, const uint32_t *src, size_t len)
|
81
42
|
{
|
82
43
|
size_t i;
|
83
44
|
|
84
45
|
for (i = 0; i < len / 4; i++) {
|
85
|
-
|
46
|
+
STORE32_BE(dst + i * 4, src[i]);
|
86
47
|
}
|
87
48
|
}
|
88
49
|
|
@@ -92,7 +53,7 @@ be32dec_vect(uint32_t *dst, const unsigned char *src, size_t len)
|
|
92
53
|
size_t i;
|
93
54
|
|
94
55
|
for (i = 0; i < len / 4; i++) {
|
95
|
-
dst[i] =
|
56
|
+
dst[i] = LOAD32_BE(src + i * 4);
|
96
57
|
}
|
97
58
|
}
|
98
59
|
|
@@ -221,7 +182,7 @@ SHA256_Pad(crypto_hash_sha256_state *state)
|
|
221
182
|
unsigned char len[8];
|
222
183
|
uint32_t r, plen;
|
223
184
|
|
224
|
-
|
185
|
+
STORE64_BE(len, state->count);
|
225
186
|
|
226
187
|
r = (state->count >> 3) & 0x3f;
|
227
188
|
plen = (r < 56) ? (56 - r) : (120 - r);
|
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
#include "crypto_hash_sha512.h"
|
30
30
|
#include "utils.h"
|
31
|
+
#include "../../../sodium/common.h"
|
31
32
|
|
32
33
|
#include <sys/types.h>
|
33
34
|
|
@@ -36,43 +37,13 @@
|
|
36
37
|
#include <stdlib.h>
|
37
38
|
#include <string.h>
|
38
39
|
|
39
|
-
/* Avoid namespace collisions with BSD <sys/endian.h>. */
|
40
|
-
#define be64dec _sha512_be64dec
|
41
|
-
#define be64enc _sha512_be64enc
|
42
|
-
|
43
|
-
static inline uint64_t
|
44
|
-
be64dec(const void *pp)
|
45
|
-
{
|
46
|
-
const uint8_t *p = (uint8_t const *)pp;
|
47
|
-
|
48
|
-
return ((uint64_t)(p[7]) + ((uint64_t)(p[6]) << 8) +
|
49
|
-
((uint64_t)(p[5]) << 16) + ((uint64_t)(p[4]) << 24) +
|
50
|
-
((uint64_t)(p[3]) << 32) + ((uint64_t)(p[2]) << 40) +
|
51
|
-
((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56));
|
52
|
-
}
|
53
|
-
|
54
|
-
static inline void
|
55
|
-
be64enc(void *pp, uint64_t x)
|
56
|
-
{
|
57
|
-
uint8_t *p = (uint8_t *)pp;
|
58
|
-
|
59
|
-
p[7] = x & 0xff;
|
60
|
-
p[6] = (x >> 8) & 0xff;
|
61
|
-
p[5] = (x >> 16) & 0xff;
|
62
|
-
p[4] = (x >> 24) & 0xff;
|
63
|
-
p[3] = (x >> 32) & 0xff;
|
64
|
-
p[2] = (x >> 40) & 0xff;
|
65
|
-
p[1] = (x >> 48) & 0xff;
|
66
|
-
p[0] = (x >> 56) & 0xff;
|
67
|
-
}
|
68
|
-
|
69
40
|
static void
|
70
41
|
be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len)
|
71
42
|
{
|
72
43
|
size_t i;
|
73
44
|
|
74
45
|
for (i = 0; i < len / 8; i++) {
|
75
|
-
|
46
|
+
STORE64_BE(dst + i * 8, src[i]);
|
76
47
|
}
|
77
48
|
}
|
78
49
|
|
@@ -82,7 +53,7 @@ be64dec_vect(uint64_t *dst, const unsigned char *src, size_t len)
|
|
82
53
|
size_t i;
|
83
54
|
|
84
55
|
for (i = 0; i < len / 8; i++) {
|
85
|
-
dst[i] =
|
56
|
+
dst[i] = LOAD64_BE(src + i * 8);
|
86
57
|
}
|
87
58
|
}
|
88
59
|
|
@@ -4,28 +4,9 @@
|
|
4
4
|
#include <stddef.h>
|
5
5
|
|
6
6
|
#include "crypto_onetimeauth_poly1305.h"
|
7
|
+
#include "../onetimeauth_poly1305.h"
|
7
8
|
|
8
9
|
extern struct crypto_onetimeauth_poly1305_implementation
|
9
10
|
crypto_onetimeauth_poly1305_donna_implementation;
|
10
11
|
|
11
|
-
static int crypto_onetimeauth_poly1305_donna(unsigned char *out,
|
12
|
-
const unsigned char *in,
|
13
|
-
unsigned long long inlen,
|
14
|
-
const unsigned char *k);
|
15
|
-
|
16
|
-
static int crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
|
17
|
-
const unsigned char *in,
|
18
|
-
unsigned long long inlen,
|
19
|
-
const unsigned char *k);
|
20
|
-
|
21
|
-
static int crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
|
22
|
-
const unsigned char *key);
|
23
|
-
|
24
|
-
static int crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
|
25
|
-
const unsigned char *in,
|
26
|
-
unsigned long long inlen);
|
27
|
-
|
28
|
-
static int crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
|
29
|
-
unsigned char *out);
|
30
|
-
|
31
12
|
#endif /* poly1305_donna_H */
|
@@ -10,6 +10,8 @@
|
|
10
10
|
# define POLY1305_NOINLINE
|
11
11
|
#endif
|
12
12
|
|
13
|
+
#include "../../../sodium/common.h"
|
14
|
+
|
13
15
|
#define poly1305_block_size 16
|
14
16
|
|
15
17
|
/* 17 + sizeof(unsigned long long) + 14*sizeof(unsigned long) */
|
@@ -22,36 +24,15 @@ typedef struct poly1305_state_internal_t {
|
|
22
24
|
unsigned char final;
|
23
25
|
} poly1305_state_internal_t;
|
24
26
|
|
25
|
-
/* interpret four 8 bit unsigned integers as a 32 bit unsigned integer in little endian */
|
26
|
-
static unsigned long
|
27
|
-
U8TO32(const unsigned char *p)
|
28
|
-
{
|
29
|
-
return
|
30
|
-
(((unsigned long)(p[0] & 0xff) ) |
|
31
|
-
((unsigned long)(p[1] & 0xff) << 8) |
|
32
|
-
((unsigned long)(p[2] & 0xff) << 16) |
|
33
|
-
((unsigned long)(p[3] & 0xff) << 24));
|
34
|
-
}
|
35
|
-
|
36
|
-
/* store a 32 bit unsigned integer as four 8 bit unsigned integers in little endian */
|
37
|
-
static void
|
38
|
-
U32TO8(unsigned char *p, unsigned long v)
|
39
|
-
{
|
40
|
-
p[0] = (v ) & 0xff;
|
41
|
-
p[1] = (v >> 8) & 0xff;
|
42
|
-
p[2] = (v >> 16) & 0xff;
|
43
|
-
p[3] = (v >> 24) & 0xff;
|
44
|
-
}
|
45
|
-
|
46
27
|
static void
|
47
28
|
poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
48
29
|
{
|
49
30
|
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
50
|
-
st->r[0] = (
|
51
|
-
st->r[1] = (
|
52
|
-
st->r[2] = (
|
53
|
-
st->r[3] = (
|
54
|
-
st->r[4] = (
|
31
|
+
st->r[0] = (LOAD32_LE(&key[ 0]) ) & 0x3ffffff;
|
32
|
+
st->r[1] = (LOAD32_LE(&key[ 3]) >> 2) & 0x3ffff03;
|
33
|
+
st->r[2] = (LOAD32_LE(&key[ 6]) >> 4) & 0x3ffc0ff;
|
34
|
+
st->r[3] = (LOAD32_LE(&key[ 9]) >> 6) & 0x3f03fff;
|
35
|
+
st->r[4] = (LOAD32_LE(&key[12]) >> 8) & 0x00fffff;
|
55
36
|
|
56
37
|
/* h = 0 */
|
57
38
|
st->h[0] = 0;
|
@@ -61,10 +42,10 @@ poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
|
61
42
|
st->h[4] = 0;
|
62
43
|
|
63
44
|
/* save pad for later */
|
64
|
-
st->pad[0] =
|
65
|
-
st->pad[1] =
|
66
|
-
st->pad[2] =
|
67
|
-
st->pad[3] =
|
45
|
+
st->pad[0] = LOAD32_LE(&key[16]);
|
46
|
+
st->pad[1] = LOAD32_LE(&key[20]);
|
47
|
+
st->pad[2] = LOAD32_LE(&key[24]);
|
48
|
+
st->pad[3] = LOAD32_LE(&key[28]);
|
68
49
|
|
69
50
|
st->leftover = 0;
|
70
51
|
st->final = 0;
|
@@ -73,7 +54,7 @@ poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
|
73
54
|
static void
|
74
55
|
poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned long long bytes)
|
75
56
|
{
|
76
|
-
const unsigned long hibit = (st->final) ?
|
57
|
+
const unsigned long hibit = (st->final) ? 0UL : (1UL << 24); /* 1 << 128 */
|
77
58
|
unsigned long r0,r1,r2,r3,r4;
|
78
59
|
unsigned long s1,s2,s3,s4;
|
79
60
|
unsigned long h0,h1,h2,h3,h4;
|
@@ -99,11 +80,11 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
|
|
99
80
|
|
100
81
|
while (bytes >= poly1305_block_size) {
|
101
82
|
/* h += m[i] */
|
102
|
-
h0 += (
|
103
|
-
h1 += (
|
104
|
-
h2 += (
|
105
|
-
h3 += (
|
106
|
-
h4 += (
|
83
|
+
h0 += (LOAD32_LE(m+ 0) ) & 0x3ffffff;
|
84
|
+
h1 += (LOAD32_LE(m+ 3) >> 2) & 0x3ffffff;
|
85
|
+
h2 += (LOAD32_LE(m+ 6) >> 4) & 0x3ffffff;
|
86
|
+
h3 += (LOAD32_LE(m+ 9) >> 6) & 0x3ffffff;
|
87
|
+
h4 += (LOAD32_LE(m+12) >> 8) | hibit;
|
107
88
|
|
108
89
|
/* h *= r */
|
109
90
|
d0 = ((unsigned long long)h0 * r0) + ((unsigned long long)h1 * s4) + ((unsigned long long)h2 * s3) + ((unsigned long long)h3 * s2) + ((unsigned long long)h4 * s1);
|
@@ -169,7 +150,7 @@ poly1305_finish(poly1305_state_internal_t *st, unsigned char mac[16])
|
|
169
150
|
g1 = h1 + c; c = g1 >> 26; g1 &= 0x3ffffff;
|
170
151
|
g2 = h2 + c; c = g2 >> 26; g2 &= 0x3ffffff;
|
171
152
|
g3 = h3 + c; c = g3 >> 26; g3 &= 0x3ffffff;
|
172
|
-
g4 = h4 + c - (
|
153
|
+
g4 = h4 + c - (1UL << 26);
|
173
154
|
|
174
155
|
/* select h if h < p, or h + -p if h >= p */
|
175
156
|
mask = (g4 >> ((sizeof(unsigned long) * 8) - 1)) - 1;
|
@@ -197,10 +178,10 @@ poly1305_finish(poly1305_state_internal_t *st, unsigned char mac[16])
|
|
197
178
|
f = (unsigned long long)h2 + st->pad[2] + (f >> 32); h2 = (unsigned long)f;
|
198
179
|
f = (unsigned long long)h3 + st->pad[3] + (f >> 32); h3 = (unsigned long)f;
|
199
180
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
181
|
+
STORE32_LE(mac + 0, h0);
|
182
|
+
STORE32_LE(mac + 4, h1);
|
183
|
+
STORE32_LE(mac + 8, h2);
|
184
|
+
STORE32_LE(mac + 12, h3);
|
204
185
|
|
205
186
|
/* zero out the state */
|
206
187
|
sodium_memzero((void *)st, sizeof *st);
|
@@ -22,6 +22,8 @@ typedef unsigned uint128_t __attribute__ ((mode(TI)));
|
|
22
22
|
# define POLY1305_NOINLINE
|
23
23
|
#endif
|
24
24
|
|
25
|
+
#include "../../../sodium/common.h"
|
26
|
+
|
25
27
|
#define poly1305_block_size 16
|
26
28
|
|
27
29
|
/* 17 + sizeof(unsigned long long) + 8*sizeof(unsigned long long) */
|
@@ -34,43 +36,14 @@ typedef struct poly1305_state_internal_t {
|
|
34
36
|
unsigned char final;
|
35
37
|
} poly1305_state_internal_t;
|
36
38
|
|
37
|
-
/* interpret eight 8 bit unsigned integers as a 64 bit unsigned integer in little endian */
|
38
|
-
static unsigned long long
|
39
|
-
U8TO64(const unsigned char *p)
|
40
|
-
{
|
41
|
-
return
|
42
|
-
(((unsigned long long)(p[0] & 0xff) ) |
|
43
|
-
((unsigned long long)(p[1] & 0xff) << 8) |
|
44
|
-
((unsigned long long)(p[2] & 0xff) << 16) |
|
45
|
-
((unsigned long long)(p[3] & 0xff) << 24) |
|
46
|
-
((unsigned long long)(p[4] & 0xff) << 32) |
|
47
|
-
((unsigned long long)(p[5] & 0xff) << 40) |
|
48
|
-
((unsigned long long)(p[6] & 0xff) << 48) |
|
49
|
-
((unsigned long long)(p[7] & 0xff) << 56));
|
50
|
-
}
|
51
|
-
|
52
|
-
/* store a 64 bit unsigned integer as eight 8 bit unsigned integers in little endian */
|
53
|
-
static void
|
54
|
-
U64TO8(unsigned char *p, unsigned long long v)
|
55
|
-
{
|
56
|
-
p[0] = (v ) & 0xff;
|
57
|
-
p[1] = (v >> 8) & 0xff;
|
58
|
-
p[2] = (v >> 16) & 0xff;
|
59
|
-
p[3] = (v >> 24) & 0xff;
|
60
|
-
p[4] = (v >> 32) & 0xff;
|
61
|
-
p[5] = (v >> 40) & 0xff;
|
62
|
-
p[6] = (v >> 48) & 0xff;
|
63
|
-
p[7] = (v >> 56) & 0xff;
|
64
|
-
}
|
65
|
-
|
66
39
|
static void
|
67
40
|
poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
68
41
|
{
|
69
42
|
unsigned long long t0,t1;
|
70
43
|
|
71
44
|
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
72
|
-
t0 =
|
73
|
-
t1 =
|
45
|
+
t0 = LOAD64_LE(&key[0]);
|
46
|
+
t1 = LOAD64_LE(&key[8]);
|
74
47
|
|
75
48
|
st->r[0] = ( t0 ) & 0xffc0fffffff;
|
76
49
|
st->r[1] = ((t0 >> 44) | (t1 << 20)) & 0xfffffc0ffff;
|
@@ -82,8 +55,8 @@ poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
|
82
55
|
st->h[2] = 0;
|
83
56
|
|
84
57
|
/* save pad for later */
|
85
|
-
st->pad[0] =
|
86
|
-
st->pad[1] =
|
58
|
+
st->pad[0] = LOAD64_LE(&key[16]);
|
59
|
+
st->pad[1] = LOAD64_LE(&key[24]);
|
87
60
|
|
88
61
|
st->leftover = 0;
|
89
62
|
st->final = 0;
|
@@ -92,7 +65,7 @@ poly1305_init(poly1305_state_internal_t *st, const unsigned char key[32])
|
|
92
65
|
static void
|
93
66
|
poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned long long bytes)
|
94
67
|
{
|
95
|
-
const unsigned long long hibit = (st->final) ?
|
68
|
+
const unsigned long long hibit = (st->final) ? 0ULL : (1ULL << 40); /* 1 << 128 */
|
96
69
|
unsigned long long r0,r1,r2;
|
97
70
|
unsigned long long s1,s2;
|
98
71
|
unsigned long long h0,h1,h2;
|
@@ -114,8 +87,8 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
|
|
114
87
|
unsigned long long t0,t1;
|
115
88
|
|
116
89
|
/* h += m[i] */
|
117
|
-
t0 =
|
118
|
-
t1 =
|
90
|
+
t0 = LOAD64_LE(&m[0]);
|
91
|
+
t1 = LOAD64_LE(&m[8]);
|
119
92
|
|
120
93
|
h0 += (( t0 ) & 0xfffffffffff);
|
121
94
|
h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
|
@@ -176,7 +149,7 @@ poly1305_finish(poly1305_state_internal_t *st, unsigned char mac[16])
|
|
176
149
|
/* compute h + -p */
|
177
150
|
g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff;
|
178
151
|
g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff;
|
179
|
-
g2 = h2 + c - (
|
152
|
+
g2 = h2 + c - (1ULL << 42);
|
180
153
|
|
181
154
|
/* select h if h < p, or h + -p if h >= p */
|
182
155
|
c = (g2 >> ((sizeof(unsigned long long) * 8) - 1)) - 1;
|
@@ -200,8 +173,8 @@ poly1305_finish(poly1305_state_internal_t *st, unsigned char mac[16])
|
|
200
173
|
h0 = ((h0 ) | (h1 << 44));
|
201
174
|
h1 = ((h1 >> 20) | (h2 << 24));
|
202
175
|
|
203
|
-
|
204
|
-
|
176
|
+
STORE64_LE(&mac[0], h0);
|
177
|
+
STORE64_LE(&mac[8], h1);
|
205
178
|
|
206
179
|
/* zero out the state */
|
207
180
|
sodium_memzero((void *)st, sizeof *st);
|