Bug #74116 [NEW]: AES-256-GCM not working
| From: | er dot haridarshan at gmail dot com | Date: | Fri, 17 Feb 2017 06:15:33 +0000 |
| Subject: | Bug #74116 [NEW]: AES-256-GCM not working | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207418@lists.php.net to get a copy of this message | ||
From: er dot haridarshan at gmail dot com
Operating system: Fedora 24
PHP version: 7.1Git-2017-02-17 (snap)
Package: OpenSSL related
Bug Type: Bug
Bug description:AES-256-GCM not working
Description:
------------
As of 7.1.0, when trying to use AES-256-GCM algorithm with
openssl_cipher_iv_length getting warning as
PHP Warning: openssl_cipher_iv_length(): Unknown cipher algorithm
And as mentioned in changelog of 7.1.0
OpenSSL:
Implemented FR #67304 (Added AEAD support [CCM and GCM modes] to
openssl_encrypt and openssl_decrypt).
this should work but its not working
Test script:
---------------
function encrypt($algo = 'AES-256-GCM')
{
$key = random_bytes(32); // 256 bits
$iv = random_bytes(openssl_cipher_iv_length($algo));
$ciphertext = openssl_encrypt(
random_bytes(1024 * 1024 * 10),
$algo,
$key,
OPENSSL_RAW_DATA,
$iv,
$tag
);
return $ciphertext;
}
$cipherText = encrypt();
Expected result:
----------------
Exepected Result is the cipherText
Actual result:
--------------
PHP Warning: openssl_cipher_iv_length(): Unknown cipher algorithm in
/var/www/test/aes.php on line 13
Warning: openssl_cipher_iv_length(): Unknown cipher algorithm in
/var/www/test/aes.php on line 13
PHP Fatal error: Uncaught Error: Length must be greater than 0 in
/var/www/test/aes.php:13
Stack trace:
#0 /var/www/test/aes.php(13): random_bytes(false)
#1 /var/www/test/aes.php(41): encrypt('Hello')
#2 {main}
thrown in /var/www/test/aes.php on line 13
Fatal error: Uncaught Error: Length must be greater than 0 in
/var/www/test/aes.php:13
Stack trace:
#0 /var/www/test/aes.php(13): random_bytes(false)
#1 /var/www/test/aes.php(41): encrypt('Hello')
#2 {main}
thrown in /var/www/test/aes.php on line 13
--
Edit bug report at https://bugs.php.net/bug.php?id=74116&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74116&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74116&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74116&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74116&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74116&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74116&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74116&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74116&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74116&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74116&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74116&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74116&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74116&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74116&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74116&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74116&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74116&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74116&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74116&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74116&r=mysqlcfg