ID:               25614
 Updated by:       [EMAIL PROTECTED]
 Reported By:      six at t0x dot net
-Status:           Open
+Status:           Suspended
 Bug Type:         OpenSSL related
 Operating System: Linux 2.4
 PHP Version:      4.3.3
 New Comment:

The documentation for openssl_pkey_new() is incorrect.
It doesn't generate a pair of keys at all.

openssl_pkey_get_public() was also slightly broken, in
that it didn't detect that it couldn't get the public key
from the private key.  You can use it to get the public key out of an
x509 certificate though (yeah, it sounds weird).

I've added a "fix" for this problem to the CVS that will now warn you
about not being able to get the public key from a private key.  This
fix will be in 4.3.4.

This stuff is a little bit messy, and its been a while since anyone did
any real work on the openssl extension.

The openssl stuff could probably benefit from a review, but this won't
happen for PHP 4.3.x, so I'm going to suspend this report until PHP 5
or PHP 5.1 when I get more time.


Previous Comments:
------------------------------------------------------------------------

[2003-09-20 12:27:26] six at t0x dot net

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 this bug report at http://bugs.php.net/?id=25614&edit=1

Reply via email to