Skip to content

Fix argument number in sodium_crypto_stream_xchacha20_xor_ic() key length error - #25363

Merged
TimWolla merged 2 commits into
php:PHP-8.4from
lacatoire:fix/sodium-xchacha20-xor-ic-argument-key-8.4
Nov 10, 2026
Merged

TimWolla merged 2 commits into
php:PHP-8.4from
lacatoire:fix/sodium-xchacha20-xor-ic-argument-key-8.4

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

The key length check reported argument 3 ($counter) instead of argument 4 ($key). The guard was copied from sodium_crypto_stream_xchacha20_xor(), where the key is argument 3.

$nonce = random_bytes(SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES);
try {
  sodium_crypto_stream_xchacha20_xor_ic('message', $nonce, 0, 'short key');
} catch (Throwable $e) {
  echo $e::class, ': ', $e->getMessage(), "\n";
}

Before: Argument #3 ($counter) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long
After: Argument #4 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long

@TimWolla
TimWolla merged commit 8413eaa into php:PHP-8.4 Nov 10, 2026
17 of 18 checks passed
TimWolla added a commit that referenced this pull request Nov 10, 2026
* PHP-8.4:
  Fix argument number in sodium_crypto_stream_xchacha20_xor_ic() key length error (#25363)
TimWolla added a commit that referenced this pull request Nov 10, 2026
* PHP-8.5:
  Fix argument number in sodium_crypto_stream_xchacha20_xor_ic() key length error (#25363)
TimWolla added a commit that referenced this pull request Nov 10, 2026
* PHP-8.6:
  Fix argument number in sodium_crypto_stream_xchacha20_xor_ic() key length error (#25363)
@lacatoire
lacatoire deleted the fix/sodium-xchacha20-xor-ic-argument-key-8.4 branch November 10, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants