php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32772 error under openssl_private_encrypt and openssl_public_decrypt
Submitted: 2005-04-19 17:38 UTC Modified: 2005-04-20 19:49 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ivan at mishanin dot ru Assigned:
Status: Not a bug Package: OpenSSL related
PHP Version: 5.0.4 OS: Windows XP, Windows 2000 Server
Private report: No CVE-ID: None
 [2005-04-19 17:38 UTC] ivan at mishanin dot ru
Description:
------------
When i try to encrypt big string it return null. If i try to use big key to encrypt - it help my, but if i use a big sting (300 000 signs) - it isn't work. 
i try encrypt big string by part, it's ok, but then i try to decrypt it - openssl_public_decrypt make a null decrypt text...

certificate is OK - under MS BizTolk server it's work right.


Reproduce code:
---------------
prkeyid = openssl_pkey_get_private("file://c:/cert/CAkey.pem", '1234');
$pubkeyid = openssl_pkey_get_public("file://c:/cert/CAcert.pem");

openssl_private_encrypt($res,$crypttext,$prkeyid);
$fp = fopen ("c:/file.xml", "w+");
// for test
fwrite ($fp, $crypttext);
fclose ($fp);

openssl_public_decrypt($crypttext, $ext_data, $pubkeyid);
$fp = fopen ("c:/file2.xml", "w+");
fwrite ($fp, $ext_data);
fclose ($fp);

Actual result:
--------------
null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-19 23:59 UTC] sniper@php.net
Try using openssl_error_string(); after those functions and you'll get more detailed information WHY they fail.


 [2005-04-20 19:49 UTC] ivan at mishanin dot ru
after openssl_private_encrypt($res,$crypttext,$prkeyid);
openssl_error_string(); return null.
but sometimes it openssl_error_string(); return error:0406C06E:rsa routines:RSA_padding_add_PKCS1_type_1:data too large for key size
i use just one key and use just one text, i don't understand why it sometime return error:0406C06E:rsa routines:RSA_padding_add_PKCS1_type_1:data too large for key size and sometime return null, null is return more often.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 04:01:30 2024 UTC