Bug #74116 [Fbk->Opn]: AES-256-GCM not working

From: Date: Fri, 17 Feb 2017 12:22:28 +0000
Subject: Bug #74116 [Fbk->Opn]: AES-256-GCM not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207427@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74116&edit=1 ID: 74116 User updated by: er dot haridarshan at gmail dot com Reported by: er dot haridarshan at gmail dot com Summary: AES-256-GCM not working -Status: Feedback +Status: Open Type: Bug Package: OpenSSL related Operating System: Fedora 24 PHP Version: 7.1Git-2017-02-17 (snap) Block user comment: N Private report: N New Comment: Yeah lowercase works. openssl_get_cipher_methods(); returns values algorithm names in capital as well as lower-case but not of aes-256-gcm and few others. Here is the sample output [16] => AES-256-CBC [17] => AES-256-CBC-HMAC-SHA1 [18] => AES-256-CFB [19] => AES-256-CFB1 [20] => AES-256-CFB8 [21] => AES-256-CTR [22] => AES-256-ECB [23] => AES-256-OFB [24] => AES-256-XTS --------------------------------- [101] => aes-256-cbc [102] => aes-256-cbc-hmac-sha1 [103] => aes-256-ccm [104] => aes-256-cfb [105] => aes-256-cfb1 [106] => aes-256-cfb8 [107] => aes-256-ctr [108] => aes-256-ecb [109] => aes-256-gcm [110] => aes-256-ofb [111] => aes-256-xts As you can see aes-256-cbc is returned both in lower-case and upper-case then why not AES-256-GCM Previous Comments: ------------------------------------------------------------------------ [2017-02-17 08:28:53] requinix@php.net I assume using a lowercase name works, then? Does openssl_get_cipher_methods() also return the uppercase version? ------------------------------------------------------------------------ [2017-02-17 06:21:10] er dot haridarshan at gmail dot com Sorry didn't noticed algorithm names are case-sensitive. But aren't they supposed to case-insensitive? ------------------------------------------------------------------------ [2017-02-17 06:15:27] er dot haridarshan at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=74116&edit=1

« previous php.bugs (#207427) next »