php-src/ext/openssl/tests/openssl_cipher_key_length_error.phpt
Jakub Zelenka 35e2a25d83
Add openssl_cipher_key_length function
This function works in exactly the same way as openssl_cipher_iv_length
but for a key length. This is especially useful to make sure that the
right key length is provided to openssl_encrypt and openssl_decrypt.

In addtion the change also updates implementation of
openssl_cipher_iv_length and adds a test for it.
2022-08-28 12:27:16 +01:00

22 lines
430 B
PHP

--TEST--
openssl_cipher_key_length() error test
--EXTENSIONS--
openssl
--FILE--
<?php
var_dump(openssl_cipher_key_length('unknown'));
try {
var_dump(openssl_cipher_key_length(''));
} catch (ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
Warning: openssl_cipher_key_length(): Unknown cipher algorithm in %s on line %d
bool(false)
openssl_cipher_key_length(): Argument #1 ($cipher_algo) cannot be empty