Commit 8413eaa6c43 for php
commit 8413eaa6c439f212589be0731fad95d552b8288d
Author: Louis-Arnaud <la.catoire@gmail.com>
Date: Tue Nov 10 12:54:52 2026 +0100
Fix argument number in sodium_crypto_stream_xchacha20_xor_ic() key length error (#25363)
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c
index 57a34d5ec84..7c80de9cbf1 100644
--- a/ext/sodium/libsodium.c
+++ b/ext/sodium/libsodium.c
@@ -1391,7 +1391,7 @@ PHP_FUNCTION(sodium_crypto_stream_xchacha20_xor_ic)
RETURN_THROWS();
}
if (key_len != crypto_stream_xchacha20_KEYBYTES) {
- zend_argument_error(sodium_exception_ce, 3, "must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long");
+ zend_argument_error(sodium_exception_ce, 4, "must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long");
RETURN_THROWS();
}
ciphertext_len = msg_len;
diff --git a/ext/sodium/tests/crypto_stream_xchacha20.phpt b/ext/sodium/tests/crypto_stream_xchacha20.phpt
index 466734853d7..08d81b0ed18 100644
--- a/ext/sodium/tests/crypto_stream_xchacha20.phpt
+++ b/ext/sodium/tests/crypto_stream_xchacha20.phpt
@@ -75,6 +75,11 @@
} catch (SodiumException $ex) {
echo $ex->getMessage(), "\n";
}
+try {
+ sodium_crypto_stream_xchacha20_xor_ic($stream, $nonce, 0, substr($key, 1));
+} catch (Throwable $ex) {
+ echo $ex::class, ': ', $ex->getMessage(), "\n";
+}
?>
--EXPECT--
@@ -94,3 +99,4 @@
sodium_crypto_stream_xchacha20(): Argument #3 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long
sodium_crypto_stream_xchacha20_xor(): Argument #2 ($nonce) must be SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES bytes long
sodium_crypto_stream_xchacha20_xor(): Argument #3 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long
+SodiumException: sodium_crypto_stream_xchacha20_xor_ic(): Argument #4 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long