mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
35e2a25d83
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.
22 lines
430 B
PHP
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
|