Commit Graph
1844 Commits
Author SHA1 Message Date
Frank Denis ebcc2a6636 pwhash: fill output buffer with junk prior to running the actual KDF
These functions are a little bit special, because unlike everything
else, they do dynamic memory allocations, and are more likely to fail.

Applications are expected to check the return code, and these functions
are tagged with ((warn_unused_result)) but applications may still
ignore these.

This is also an issue with JavaScript, when total memory hasn't been
properly configured.

To be safe, fill the buffer with non-deterministic bytes, that are
unlikely to ever verify later.
2023-02-16 18:22:19 +01:00
Frank Denis 4acf8befe0 Mention that mlock() failing is not a hard error for sodium_malloc() 2022-12-19 12:12:29 +01:00
Frank Denis a5ea347381 Sync the AESNI aes_gcm_decrypt_generic() impl with the ARM one 2022-12-11 23:48:30 +01:00
Frank Denis dab102d404 On stable, on failed decryption, fill buffer with 0x00
Not with 0xd0, to keep the previous behavior. NSec expicitly checked
for that value.
2022-12-11 21:07:42 +01:00
Frank Denis 1cfba584db Support memset_explicit() if available
NetBSD has explicit_memset(), but C23 decided to implement the
same thing but call it memset_explicit() instead. Go figure.
2022-11-21 15:29:25 +01:00
Frank Denis d0c73fcefc Backport the new AES-GCM implementation to -stable 2022-11-17 23:07:10 +01:00
Frank Denis 12023defc8 salsa20: initialize partial block
A compiler trying to be too smart could notice that we are shifting
ununitialized data (even though we then discard it), and apply
unwanted optimizations.
2022-11-16 13:43:43 +01:00
Frank Denis fd5cbe9e69 Indent 2022-10-21 17:54:59 +02:00
Frank Denis 69821eba93 Win32: SecureZeroMemory may not be available 2022-10-20 14:41:59 +02:00
Frank Denis 2a2fe56189 scalarmult(): don't use the output as a temporary buffer
So that application can use the same pointer for the public key
and the shared secret.
2022-10-11 14:04:50 +02:00
Steve Thomas d69a2342bc Clear decrypted block from stack (#1190) 2022-06-18 20:32:53 +02:00
Frank Denis 3f3d350387 sodium_compare(): cast operands to unsigned int
This matches the Zig implementation and
fixes #1184
2022-06-05 14:31:35 +02:00
Frank Denis fd4b6edc0f Simplify scrypt blkcpy()/blkxor() 2022-05-11 18:12:45 +02:00
Frank Denis 7389bf7f29 libtool update 2022-04-03 00:03:17 +02:00
Frank Denis 0e88616f87 edwards25519: faster recovery of the X coordinate 2022-02-15 14:13:36 +01:00
Jørgen P. TjernøandFrank Denis 100ccb452d Portability improvements (#1105)
* Move `raise` code to be behind an autoconf check

This moves the call to `raise` behind a `HAVE_RAISE` autoconf check,
in addition to `__wasm__`. This is intended to help porting to
other platforms that don't support `raise` (e.g. modern game consoles).

* Add autoconf check for `sysconf`

Only try to invoke `sysconf` if the target platform supports it, and
don't warn about unknown page size if `PAGE_SIZE` was defined. Add an
include for `sys/param.h` to increase likelihood of finding `PAGE_SIZE`.
This is intended to help porting to other platforms that don't support
`sysconf` (e.g. modern game consoles) that have a fixed hardware page
size.

* Don't try to use raise & sysconf in a WASI environment

Co-authored-by: Frank Denis <124872+jedisct1@users.noreply.github.com>
2021-10-09 18:39:02 +02:00
infinitydev 7d300e4c19 Fix build on z/OS using XLC (#1089)
Handle the Sun and the IBM compilers separately
2021-07-09 15:48:34 +02:00
Frank Denis 95673e5b51 Use assignement + case instead of memcpy() 2021-06-17 20:56:54 +02:00
Frank Denis 94daa0e15a Include private/sse2_64_32.h only where SSE2 is required
Fixes #1074
2021-06-13 21:46:08 +02:00
Alcaro 1e46e98d83 core.c: Make _sodium_crit_init static (#1073) 2021-06-13 18:22:57 +02:00
Frank Denis b5b62722b7 Autoconf update & regen 2021-05-22 12:21:15 +02:00
Frank Denis 8aedf47338 Fix comment in ristretto255_elligator (#1052) 2021-04-21 16:47:07 +02:00
Frank Denis 7168944f16 Update some autoconf definitions 2021-04-08 10:57:21 +02:00
Frank Denis 0389b96972 Regen autoconf files 2021-04-08 10:12:12 +02:00
Frank Denis 9e625a0b2a Fix typos in comments
Backport from #1032
2021-02-12 17:19:07 +01:00
Frank Denis 04b44a4df4 Automake update 2020-11-24 22:55:50 +01:00
Frank Denis df83ed9235 pwhash never supported "in-place" operation - return EINVAL 2020-11-24 22:53:16 +01:00
David CARLIER 9e2f4d0ba8 DragonFlyBSD supports getrandom too since 5.7 2020-11-08 16:06:39 +01:00
Tim Gates ddce81d103 docs: fix simple typo, interoperatibility -> interoperability (#1002)
There is a small typo in src/libsodium/include/sodium/crypto_hash.h, src/libsodium/include/sodium/crypto_hash_sha256.h, src/libsodium/include/sodium/crypto_hash_sha512.h.

Should read `interoperability` rather than `interoperatibility`.
2020-10-12 11:51:50 +02:00
Frank Denis f5f8efbc81 comment 2020-08-16 11:41:54 +02:00
Frank Denis 3b9cbcf60d argon2 - copy raw hash after possible encoding, not before
(irrelevant in libsodium)
2020-08-16 11:39:31 +02:00
Frank Denis 4a75300b45 Validate argon2 lanes before memory cost 2020-08-16 11:39:26 +02:00
Frank Denis 899149f988 Shorten 2020-08-05 16:34:53 +02:00
Frank Denis e6d0a57061 Elligator - Faster Chi function 2020-06-15 10:41:59 +02:00
Frank Denis 2ea21b96e0 Don't even include signal.h on WASI
Since version 11, wasi-sysroot doesn't ignore it but spits out
an error instead.
2020-06-04 10:53:49 +02:00
Frank Denis c94c477f24 Faster sc25519 inversion, with one less squaring 2020-05-26 14:05:10 +02:00
Frank Denis c35437c2e5 Add extra box_seal() tests 2020-05-21 18:38:34 +02:00
Frank Denis 81a2655233 crypto_box_seal(): copy the key after encryption to support in-place encryption
Fixes #961
2020-05-21 18:25:27 +02:00
Frank Denis 5a300d6480 Remove unused code 2020-05-14 18:46:16 +02:00
Frank Denis be00e8d72b ristretto255_is_canonical(): sync with wasm-crypto
Reject string with the top bit set.
2020-04-25 12:18:19 +02:00
Frank Denis 8fbe4ceb64 Fix argument order 2020-04-23 15:40:50 +02:00
Frank Denis 9786e40501 Rename fe25519_scalar_product, use it for all multiplications by A 2020-04-23 11:16:05 +02:00
Frank Denis f931f37bb4 Replace deprecated function in test 2020-03-30 19:08:05 +02:00
Frank Denis 57e753130e Remove useless self inclusion 2020-03-28 20:38:54 +01:00
Frank Denis 3b689a6ab4 New automake version 2020-03-22 22:56:19 +01:00
Frank Denis d0ea7b549e Remove XOP stub
XOP is dead
2020-03-14 17:16:54 +01:00
Frank Denis a89940d4aa Reformat comments 2020-03-14 17:16:48 +01:00
Frank Denis a4e127567f Simplify integerify()
Make offsets 64 bit in the SSE scrypt impl
2020-03-14 17:16:37 +01:00
Loup Vaillant f1652acba2 Avoid memmove() call when buffers are already the same. (#935)
This completes the work started in commit
fbe3eb265f
2020-03-14 17:15:42 +01:00
Frank Denis 182415cb69 Remove sandy2x fixed base scalar multiplication
Thanks to precomputation, the generic implementation is faster.

Don't even define a .mult_base placeholder for sandy2x

Avoid two indirections for fixed base multiplication until another
implementation possibly exists.
2020-02-06 00:54:39 +01:00