Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/sodium/libsodium.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions ext/sodium/tests/crypto_stream_xchacha20.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ try {
} 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--
Expand All @@ -94,3 +99,4 @@ sodium_crypto_stream_xchacha20(): Argument #2 ($nonce) must be SODIUM_CRYPTO_STR
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
Loading