Bug #61203 [Opn->Asn]: RSA encryption fails without padding
| From: | pajoye@php.net | Date: | Wed, 29 Feb 2012 09:33:26 +0000 |
| Subject: | Bug #61203 [Opn->Asn]: RSA encryption fails without padding | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167937@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61203&edit=1
ID: 61203
Updated by: pajoye@php.net
Reported by: w3ricardo-php at yahoo dot com
Summary: RSA encryption fails without padding
-Status: Open
+Status: Assigned
Type: Bug
Package: OpenSSL related
Operating System: Windows 7 Professional 32 bits
PHP Version: 5.3.10
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2012-02-28 18:15:18] w3ricardo-php at yahoo dot com
If you provide the data with the correct size, by appending "\0"s for example, the
function works. Now it's obvious, after two days of work. Maybe the documentation should
address that.
------------------------------------------------------------------------
[2012-02-28 16:42:22] w3ricardo-php at yahoo dot com
Description:
------------
openssl_public_encrypt fails with the argument OPENSSL_NO_PADDING. Without it, it works fine.
Test script:
---------------
$configargs = array
("private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
"encrypt_key" => false);
$key = openssl_pkey_new($configargs);
$details = openssl_pkey_get_details($pubkey);
$pubkey = $details['key'];
$r = openssl_public_encrypt("This is a test", $crypted, $pubkey, OPENSSL_NO_PADDING);
if ($r) {
echo "encrypt no padding: true\n";
} else {
echo "encrypt no padding: false\n";
$r = openssl_public_encrypt("This is a test", $crypted, $pubkey);
if ($r) {
echo "encrypt with padding: true\n";
} else {
echo "encrypt with padding: false\n";
}
}
Expected result:
----------------
encrypt no padding: true
Actual result:
--------------
encrypt no padding: false
encrypt with padding: true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61203&edit=1