From: hanbsd at 163 dot com
Operating system: Centos 5.0
PHP version: 5.2.6
PHP Bug Type: OpenSSL related
Bug description: openssl_sign() can't generate the signature where sign DSA
Private key
Description:
------------
I create private key with
$configargs = array(
"digest_alg" => "sha1",
"private_key_bits" => 1024,
"private_key_type" => OPENSSL_KEYTYPE_DSA,
"encrypt_key" => false
);
But I can not get signature by openssl_sign($data, $signature, $key).
Then I use openssl in shell
#openssl dgst -dss1 -sign id_dsa foo.sha1 > sigfile.bin
openssl create a signature file : sigfile.bin
#openssl dgst -dss1 -verify id_dsa.pub -signature sigfile.bin foo.sha1
openssl print: "Verified OK"
It looks something bug of PHP function openssl_sign()
Reproduce code:
---------------
$data = "sfsdfsdfs";
$fp = fopen("/home/id_dsa", "r");
$pkey = fread($fp, 8192);
fclose($fp);
$key = openssl_get_privatekey($pkey);
openssl_sign($data, $signature, $key);
openssl_free_key($key);
echo $signature;
Expected result:
----------------
openssl_sign() can create signature
Actual result:
--------------
openssl_sign() can not create signature , $signature is empty
--
Edit bug report at http://bugs.php.net/?id=46149&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46149&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46149&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46149&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46149&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46149&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46149&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46149&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46149&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46149&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46149&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46149&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46149&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46149&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46149&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46149&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46149&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46149&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46149&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46149&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46149&r=mysqlcfg