com php-src: Test and fix encrypting empty IV for AEAD mode: ext/openssl/openssl.c ext/openssl/tests/openssl_encrypt_gcm .phpt
| From: | Jakub Zelenka | Date: | Thu, 31 Dec 2015 16:33:57 +0000 |
| Subject: | com php-src: Test and fix encrypting empty IV for AEAD mode: ext/openssl/openssl.c ext/openssl/tests/openssl_encrypt_gcm .phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92479@lists.php.net to get a copy of this message | ||
Commit: 52ffdf9fc3a97f52760b10bc15d825a1c12986e5
Author: Jakub Zelenka <bukka@php.net> Thu, 31 Dec 2015 16:33:57 +0000
Parents: 74f2998212fee8bac7f50e9dfbbfab4d0941fa27
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=52ffdf9fc3a97f52760b10bc15d825a1c12986e5
Log:
Test and fix encrypting empty IV for AEAD mode
Changed paths:
M ext/openssl/openssl.c
M ext/openssl/tests/openssl_encrypt_gcm.phpt
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index c2ea6e2..63293b8 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5315,7 +5315,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
}
max_iv_len = EVP_CIPHER_iv_length(cipher_type);
- if (enc && *piv_len == 0 && max_iv_len > 0) {
+ if (enc && *piv_len == 0 && max_iv_len > 0 && !mode->is_aead) {
php_error_docref(NULL, E_WARNING,
"Using an empty Initialization Vector (iv) is potentially insecure and not
recommended");
}
diff --git a/ext/openssl/tests/openssl_encrypt_gcm.phpt b/ext/openssl/tests/openssl_encrypt_gcm.phpt
index 9ef8d19..79dad7b 100644
--- a/ext/openssl/tests/openssl_encrypt_gcm.phpt
+++ b/ext/openssl/tests/openssl_encrypt_gcm.phpt
@@ -21,8 +21,10 @@ foreach ($tests as $idx => $test) {
var_dump($test['tag'] === $tag);
}
+echo "ERROR: IV\n";
+var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag,
''));
?>
---EXPECT--
+--EXPECTF--
TEST 0
bool(true)
bool(true)
@@ -41,3 +43,7 @@ bool(true)
TEST 5
bool(true)
bool(true)
+ERROR: IV
+
+Warning: openssl_encrypt(): Setting of IV length for AEAD mode failed, the expected length is 12
bytes in %s on line %d
+bool(false)