ID: 30757 Updated by: [EMAIL PROTECTED] Reported By: pigo at ms5 dot url dot com dot tw -Status: Open +Status: Bogus Bug Type: OpenSSL related Operating System: RedHat 8.0 Kernel 2.4.20 PHP Version: 4.3.9 New Comment:
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. Previous Comments: ------------------------------------------------------------------------ [2004-11-11 07:35:08] 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() ); } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30757&edit=1