Bug #68962 [NEW]: openssl_decrypt aes 128 GCM fails
| From: | php-mark at zedwood dot com | Date: | Fri, 30 Jan 2015 17:04:45 +0000 |
| Subject: | Bug #68962 [NEW]: openssl_decrypt aes 128 GCM fails | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-190354@lists.php.net to get a copy of this message | ||
From: php-mark at zedwood dot com
Operating system: ubuntu 14.04
PHP version: 5.6.5
Package: OpenSSL related
Bug Type: Bug
Bug description:openssl_decrypt aes 128 GCM fails
Description:
------------
When I use:
$method = 'id-aes128-GCM';
the openssl_decrypt returns false.
However, when I use a different cipher method like 'AES-128-CBC' (like
used in 011.phpt) it returns the input string (correct behavior).
So I want to use aes128-GCM because GCM mode is recommended for
authenticated encryption.
Test script:
---------------
<?php
error_reporting(E_ALL);
$data = '1234567890ABCDEF';
$method = 'id-aes128-GCM';
$password = 'dCoD........Eu39';
$iv_size = openssl_cipher_iv_length($method);
$iv = openssl_random_pseudo_bytes($iv_size);
$encrypted = openssl_encrypt($data, $method, $password, $options = 0,
$iv);
$output = openssl_decrypt($encrypted, $method, $password, $options = 0,
$iv);
echo in_array($method, openssl_get_cipher_methods()) ? $method."\n" :
"";
echo var_dump($encrypted);
echo var_dump($output);
exit(0);
Expected result:
----------------
id-aes128-GCM
string(24) "lIn8CH5BBWWR/q1WdSf7Pw=="
string(16) "1234567890ABCDEF"
Actual result:
--------------
id-aes128-GCM
string(24) "lIn8CH5BBWWR/q1WdSf7Pw=="
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=68962&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68962&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68962&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68962&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68962&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68962&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68962&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68962&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68962&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68962&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68962&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68962&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68962&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68962&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68962&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68962&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68962&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68962&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68962&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68962&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68962&r=mysqlcfg