From: six at t0x dot net Operating system: Linux 2.4 PHP version: 4.3.3 PHP Bug Type: OpenSSL related Bug description: openssl_pkey_get_public() fails when given a private key
Description: ------------ PHP manual states that : "openssl_pkey_new() generates a new private and public key pair. The public component of the key can be obtained using openssl_pkey_get_public()." However, the following script (see "reproduce-code" section) seems to indicate that openssl_pkey_get_public is broken in some way ... it should be noted that the two exports ($ex_k and $ex_p) start (and end) with a "RSA PRIVATE KEY" header line Reproduce code: --------------- <? $k = openssl_pkey_new(); $p = openssl_pkey_get_public($k); echo "php version ".phpversion()."\n\n"; echo "generated private key resource : $k\n"; echo "generated public key resource : $p\n\n"; openssl_pkey_export($k, $ex_k); openssl_pkey_export($p, $ex_p); if ($ex_k == $ex_p) echo "exports match :(\n"; ?> Expected result: ---------------- php version 4.3.3 generated private key resource : Resource id #4 generated public key resource : Resource id #5 Actual result: -------------- php version 4.3.3 generated private key resource : Resource id #4 generated public key resource : Resource id #4 exports match :( -- Edit bug report at http://bugs.php.net/?id=25614&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25614&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25614&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25614&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25614&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25614&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25614&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25614&r=support Expected behavior: http://bugs.php.net/fix.php?id=25614&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25614&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25614&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25614&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25614&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25614&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25614&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25614&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25614&r=float