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

From: Date: Fri, 17 Feb 2017 08:28:57 +0000
Subject: Bug #74116 [Opn->Fbk]: AES-256-GCM not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207422@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 Updated by: requinix@php.net Reported by: er dot haridarshan at gmail dot com Summary: AES-256-GCM not working -Status: Open +Status: Feedback 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: I assume using a lowercase name works, then? Does openssl_get_cipher_methods() also return the uppercase version? Previous Comments: ------------------------------------------------------------------------ [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 (#207422) next »