Bug #73833 [NEW]: null character not allowed in openssl_pkey_get_private

From: Date: Thu, 29 Dec 2016 15:33:29 +0000
Subject: Bug #73833 [NEW]: null character not allowed in openssl_pkey_get_private
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206223@lists.php.net to get a copy of this message
From: mfaust at usinternet dot com Operating system: Linux PHP version: 5.6.29 Package: OpenSSL related Bug Type: Bug Bug description:null character not allowed in openssl_pkey_get_private Description: ------------ When encrypting a private key for export you are allowed to have a null character as part of the password key, but when decrypting with openssl_pkey_get_private it fails to decrypt with the same key. PHP is compiled against OpenSSL 1.0.1e-fips 11 Feb 2013 Test script: --------------- //This will fail to decrypt using the first password due to the null byte (\x00) $passwords = ["abc\x00defghijkl", "abcdefghikjl"]; foreach($passwords as $password){ $key = openssl_pkey_new(); if(openssl_pkey_export($key, $privatePEM, $password) === FALSE){ echo "Failed to encrypt.\n"; }else{ echo "Encrypted!\n"; } //This will throw a warning and fail to decrypt. if(openssl_pkey_get_private($privatePEM, $password) === FALSE){ echo "Failed to decrypt.\n"; }else{ echo "Decrypted!\n"; } -- Edit bug report at https://bugs.php.net/bug.php?id=73833&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73833&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73833&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73833&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73833&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73833&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73833&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73833&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73833&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73833&r=support Expected behavior: https://bugs.php.net/fix.php?id=73833&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73833&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73833&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73833&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73833&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73833&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73833&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73833&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73833&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73833&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73833&r=mysqlcfg

« previous php.bugs (#206223) next »