Commit Graph
4384 Commits
Author SHA1 Message Date
Frank Denis 701aa826b9 Update for zig-current
Keep compat with previous version for now

Fixes #1551
2026-07-31 17:25:40 +02:00
Frank Denis 2ce4d906a6 Always use STORE32_LE for unaligned stores, even when it's a noop 2026-07-12 14:37:05 +02:00
Frank Denis 77a422c85a Regen 2026-07-08 22:16:49 +02:00
Frank Denis a0b565b81b Include unistd.h unconditionally on !windows 2026-07-08 22:13:25 +02:00
Frank Denis 962bda2168 wasmer syntax for volumes seems to have changed 2026-07-08 22:13:15 +02:00
Frank Denis 83ee4408b7 Add a compile-time option to set the max webassembly memory 2026-06-23 18:23:10 +02:00
Frank Denis 8dd5c75499 Update for zig-current 2026-06-11 15:50:06 +02:00
Frank Denis a0859f2a6c CI: trigger CodeQL properly
Reported by Nicolas IOOSS - Thanks!

Fixes #1539
2026-06-11 15:28:27 +02:00
Frank Denis b934a541f7 Replace softaes with a bitsliced implementation 2026-06-11 15:28:22 +02:00
Frank Denis 7c1ea609f4 SipHash: help the compiler a little bit 2026-06-11 15:27:51 +02:00
Frank Denis 6871630041 Improve Keccak performance 2026-06-11 15:27:39 +02:00
Frank Denis 33cc75ab15 Fix: sodium_misuse() callback runs under global lock and can deadlock
SUMMARY
`src/libsodium/sodium/core.c` invokes the process-global misuse callback from `sodium_misuse()` while still holding the library-wide critical section. If the application-installed callback re-enters any API path that acquires the same lock, including `sodium_set_misuse_handler()`, execution deadlocks before `abort()` is reached. This breaks the intended fail-stop behavior of misuse handling.

PROVENANCE
Verified from the provided finding, reproduced locally from the committed control flow, and documented for Swival Security Scanner (https://swival.dev).

PRECONDITIONS
- A caller installs a misuse handler via `sodium_set_misuse_handler()`.
- The handler re-enters an API path that takes the same global critical section, including `sodium_set_misuse_handler()`.

PROOF
1. `sodium_set_misuse_handler()` writes the global `_misuse_handler` under `sodium_crit_enter()` / `sodium_crit_leave()` in `src/libsodium/sodium/core.c:170` and `src/libsodium/sodium/core.c:174`.
2. `sodium_misuse()` acquires that same critical section, copies `_misuse_handler`, and invokes `handler()` before releasing the lock in `src/libsodium/sodium/core.c:155` and `src/libsodium/sodium/core.c:160`.
3. The pthread-backed critical section in this file is non-recursive (`src/libsodium/sodium/core.c:89`), so a callback that calls `sodium_set_misuse_handler()` blocks in `sodium_crit_enter()` waiting on the lock already held by `sodium_misuse()`.
4. Because `sodium_misuse()` is waiting for the callback to return, it never reaches `abort()`, converting a fail-stop misuse path into a hang.
5. Reproduction confirmed this with a minimal pthread harness: the handler printed `handler: before reentry` and then hung until terminated by `timeout`.

WHY THIS IS A REAL BUG
The callback target is application-controlled through an exported setter, and `sodium_misuse()` calls it on a misuse path without enforcing any non-reentrancy contract. On pthread targets, a handler that performs a supported API call can permanently block process termination. That is a reachable behavioral failure, not a theoretical lock-order concern.

FIX REQUIREMENT
Load `_misuse_handler` while holding the lock, release the critical section, and only then invoke the callback. This removes lock-dependent behavior from arbitrary user code while preserving synchronized access to the global handler pointer.
2026-04-16 16:51:18 +02:00
Frank Denis 77e1ce5d6d Add code comments about why variable-time is fine for public inputs 1.0.22-RELEASE 1.0.22 2026-04-09 23:00:06 +02:00
Frank Denis d57f757b52 Update ChangeLog 2026-04-09 23:00:06 +02:00
Frank Denis c213b0808b Regen emscripten symbols 2026-04-09 23:00:05 +02:00
Frank Denis d022f2d637 State wipe 2026-04-09 23:00:05 +02:00
Frank Denis 758bb4a4de ML-KEM: wipe ephemeral seeds and harden invalid-pk test 2026-04-09 23:00:05 +02:00
Frank Denis bf8cf449ea sha3: make post-final misuse safe and deterministic 2026-04-09 23:00:05 +02:00
Frank Denis 3ab195644f Add .swival/ and tmp/ to .gitignore 2026-04-09 23:00:05 +02:00
Frank Denis 57c6200865 Regen 2026-04-09 23:00:05 +02:00
Frank Denis 9a16e6b79a Add SHA-3 and KEM symbols to emscripten exports 2026-04-09 23:00:05 +02:00
Frank Denis 30a18ae407 Add a high-level crypto_kem API mapping to xwing 2026-04-09 23:00:05 +02:00
Frank Denis 3fa3eac209 Add X-Wing 2026-04-09 23:00:05 +02:00
Frank Denis bca64e0982 Add ML-KEM768 2026-04-09 23:00:05 +02:00
Frank Denis 350313ec20 Add support for SHA3 2026-04-09 23:00:05 +02:00
Frank Denis 2f8a60ae82 Update ChangeLog 2026-04-09 23:00:05 +02:00
Frank Denis a09f7ed21a Add some coverage exclusions 2026-04-09 23:00:05 +02:00
Frank Denis 8490eeb0d5 Add a couple more tests 2026-04-09 23:00:04 +02:00
Frank Denis b0d658a856 Add a couple more tests 2026-04-09 23:00:04 +02:00
Frank Denis dc213c8e8e Add some additional tests for HKDF and Salsa20/12 2026-04-09 23:00:04 +02:00
Frank Denis bb1894c528 Prepare for 1.0.22 2026-04-09 23:00:04 +02:00
Frank Denis 98e1f0dba7 SHAKE: in case update is called right after squeezing, permute
Calling update after squeezing is undocumented and non standard,
but if an application still decides to do it, permute the state
before absorbing so that it's still safe to do so.

We can easily do it since we keep track of the state.

Still return an error as this is not the expected usage of SHAKE,
and zeroing the state is another thing we could do.
2026-04-09 23:00:04 +02:00
Frank Denis a338eaaa02 apple-xcframework: move headers into a Clibsodium subdirectory
The generated Clibsodium.xcframework will have headers at
Headers/Clibsodium/ instead of Headers/

This prevents the module.modulemap collision when used alongside
other xcframeworks.
2026-04-09 23:00:04 +02:00
Frank Denis db920a146c Add NEON optimizations for Argon2 2026-04-09 23:00:04 +02:00
Frank Denis 3e7548c62f Update GitHub actions 1.0.21-FINAL 2026-04-09 22:59:47 +02:00
Frank Denis 4defa543c4 Relax crypto_auth_hmacsha{256,512}_init to accept NULL pointers 2026-04-09 22:20:32 +02:00
Frank Denis d2f922522b Regen 2026-04-09 23:00:19 +02:00
Frank Denis 45b5cae00a Include <core.h> to get sodium_misuse 2026-04-09 22:18:52 +02:00
Frank Denis d6820320e8 Allow NULL pointers (with length=0) with shorthash 2026-04-09 22:18:47 +02:00
Frank Denis c1fe2af601 Reject impossible lengths in crypto_box 2026-04-09 22:18:41 +02:00
Frank Denis c7fb97c2bf Add some zeroing 2026-04-09 22:18:35 +02:00
Frank Denis 874c12a3ae Add some message size guards in AEGIS, for consistency 2026-04-09 22:18:29 +02:00
Frank Denis 0a23c7b3f0 Update msys2 2026-04-09 22:18:22 +02:00
Frank Denis a77b7e7bbf Add Visual Studio quirks back 2026-04-09 00:42:34 +02:00
Frank Denis 4fe02571dd Fix compilation on ARM with very old gcc versions 2026-04-09 00:28:22 +02:00
Frank Denis d4bc6fb5fe Unify AES key expansion code on ARM 2026-04-09 00:28:18 +02:00
Frank Denis 829426cd1d More fixes for MSVC/aarch64 2026-04-09 00:28:13 +02:00
Frank Denis 2d949f8330 Add support for MSVC to aes256gcm 2026-04-09 00:28:09 +02:00
Frank Denis 168e60a217 Add casts for aarch64+gcc 2026-04-09 00:28:06 +02:00
Frank Denis 00ff370f84 Try to enable aes256-gcm even on non-clang compilers 2026-04-09 00:28:03 +02:00