Skip to content

Commit 2e02579

Browse files
committed
Fix bug #78079 (openssl_encrypt_ccm.phpt fails with OpenSSL 1.1.1c)
It also fixes invalid setting of tag length
1 parent 59b0b38 commit 2e02579

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug #77956 (When mysqli.allow_local_infile = Off, use a meaningful
1515
error message). (Sjon Hortensius)
1616

17+
- OpenSSL:
18+
. Fixed bug #78079 (openssl_encrypt_ccm.phpt fails with OpenSSL 1.1.1c).
19+
(Jakub Zelenka)
20+
1721
- Sockets:
1822
. Fixed bug #78038 (Socket_select fails when resource array contains
1923
references). (Nikita)

ext/openssl/openssl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6444,7 +6444,10 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
64446444
return FAILURE;
64456445
}
64466446
if (mode->is_single_run_aead && enc) {
6447-
EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL);
6447+
if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) {
6448+
php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed");
6449+
return FAILURE;
6450+
}
64486451
} else if (!enc && tag && tag_len > 0) {
64496452
if (!mode->is_aead) {
64506453
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");

ext/openssl/tests/openssl_encrypt_ccm.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ foreach ($tests as $idx => $test) {
2424
// Empty IV error
2525
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
2626

27-
// Test setting different IV length and unlimeted tag
28-
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 1024));
27+
// Test setting different IV length and tag length
28+
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 14));
2929
var_dump(strlen($tag));
30+
31+
// Test setting invalid tag length
32+
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 16), $tag, '', 1024));
3033
?>
3134
--EXPECTF--
3235
TEST 0
@@ -36,4 +39,7 @@ bool(true)
3639
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
3740
bool(false)
3841
string(8) "p/lvgA=="
39-
int(1024)
42+
int(14)
43+
44+
Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed in %s on line %d
45+
bool(false)

0 commit comments

Comments
 (0)