mirror of
https://github.com/php/php-src.git
synced 2025-08-20 17:34:35 +02:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
29d79dc2e5
2 changed files with 13 additions and 4 deletions
|
@ -6546,7 +6546,10 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
if (mode->is_single_run_aead && enc) {
|
if (mode->is_single_run_aead && enc) {
|
||||||
EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL);
|
if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
} else if (!enc && tag && tag_len > 0) {
|
} else if (!enc && tag && tag_len > 0) {
|
||||||
if (!mode->is_aead) {
|
if (!mode->is_aead) {
|
||||||
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");
|
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");
|
||||||
|
|
|
@ -24,9 +24,12 @@ foreach ($tests as $idx => $test) {
|
||||||
// Empty IV error
|
// Empty IV error
|
||||||
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
|
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
|
||||||
|
|
||||||
// Test setting different IV length and unlimeted tag
|
// Test setting different IV length and tag length
|
||||||
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 1024));
|
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 14));
|
||||||
var_dump(strlen($tag));
|
var_dump(strlen($tag));
|
||||||
|
|
||||||
|
// Test setting invalid tag length
|
||||||
|
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 16), $tag, '', 1024));
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
TEST 0
|
TEST 0
|
||||||
|
@ -36,4 +39,7 @@ bool(true)
|
||||||
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
|
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
string(8) "p/lvgA=="
|
string(8) "p/lvgA=="
|
||||||
int(1024)
|
int(14)
|
||||||
|
|
||||||
|
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue