php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30757 This function can't encrypt large data when data length more than key size
Submitted: 2004-11-11 07:35 UTC Modified: 2004-11-11 08:21 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: pigo at ms5 dot url dot com dot tw Assigned:
Status: Not a bug Package: OpenSSL related
PHP Version: 4.3.9 OS: RedHat 8.0 Kernel 2.4.20
Private report: No CVE-ID: None
 [2004-11-11 07:35 UTC] pigo at ms5 dot url dot com dot tw
Description:
------------
This function can't encrypt large data when data length more than key size

I get error :
encrypt error : string(84) "error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size"

Reproduce code:
---------------
        $privkey = openssl_pkey_new();
        $csr = openssl_csr_new($GLOBALS["_CONFIG"]["key_dn"], $privkey);
        $sscert = openssl_csr_sign($csr, null, $privkey, 365);
        openssl_csr_export($csr, $csrout);
        openssl_x509_export($sscert, $public_key ) ;
        openssl_pkey_export($privkey, $private_key);
$log_data="B,1,1,1,1,1234,0001,AAA012,0001,0008,0000,0005,Y,Y,Y,Y,0779,071504,S1,PP01,M01,20040715073,1B,1,1,1,1,1234,0001,AAA012,0001,0007,0000,0006,Y,Y,Y,Y,0679,071504,S1,PP01,M01,200407150843,2B,1,1,1,1,1234,0001,AAA015,0002,0005,0000,0008,Y,Y,Y,Y,0899,071504,S1,PP01,M01,200407150856,3B,1,1,1,1,1234,0001,AAA015,0001,0004,0000,0009,Y,Y,Y,Y,1199,071504,S1,PP01,M01,200407150857,4";
$PK = openssl_get_publickey( $server_public_key );
if(!openssl_public_encrypt($log_data , $crypttext , $PK ))
{
	echo "encrypt error : " ;
	var_dump(openssl_error_string() );
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-11 08:21 UTC] wez@php.net
That's the way that RSA works; you need to create a bigger key to be able to encrypt bigger chunks of data; the error message is quite clear.
Not a PHP bug.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Nov 29 23:03:17 2021 UTC