My problem is strange , java (private key) talk with php (public key )
in 2 way.
1. java encrypt -> php decrypt=20
2. php encrypt -> java decrypt =20
for (2) operation successfully.
but (1): php decryption get the NULL string
if I change from PKCS1Padding -> NoPadding then php can decypt message.
--------------
Java:
Cipher rsa_cipher =3D
Cipher.getInstance("RSA/ECB/PKCS1Padding");
=09=09 rsa_cipher.init(Cipher.ENCRYPT_MODE,rsaPublicKey);=09// auto sel=
ects
block type 2=20
=09=09 AlgorithmParameters pm =3D rsa_cipher.getParameters();
=09=09 =20
=09=09 byte[] enc_data =3D rsa_cipher.doFinal(ciphertext.getBytes());
=09=09 =20
=09=09 BASE64Encoder based64 =3D new BASE64Encoder();
s_out =3D based64.encode(enc_data); //ciphertext=20
---------------
PHP:
$split_ctext=3Dsubstr($cipher_text,$i,$blocksize);
=09=09$split_ctext=3Dstr_replace( "\r\n", "", $split_ctext );
=09=09$split_ctext=3Dstr_replace( "\n", "", $split_ctext );
=09=09$split_ctext=3Dbase64_decode($split_ctext);
=09=09openssl_public_decrypt( $split_ctext, $tmp, $public_key);=20
------------
if I change to=20
Cipher rsa_cipher =3D
Cipher.getInstance("RSA/ECB/PKCS1Padding");
and
openssl_public_decrypt( $split_ctext, $tmp,
$public_key,OPENSSL_NO_PADDING); =20
Then I can success get plain text
---------------
Plain Text:
tmp =3D
"eitweb123|WEB|20090512104236||cpg_test|23022006145859|3199900071658|100|10=
0|0|7||eitweb123|WEB|20090512104236||cpg_te";
Result:
Fail Case:
[null message]
Success Case:
=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=
=BF=BD=EF=BF=BD=EF=BF=BDeitweb123|WEB|20090512104236||cpg_test|230220061458=
59|3199900071658|100|100|0|7||eitweb123|WEB|20090512104236||cpg_te
--=20
View this message in context: http://www.nabble.com/openssl-cannot-decrypt-=
the-%22RSA-ECB-PKCS1Padding%22-from-java-tp23881221p23881221.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org
I found the problem is my java side using missing code, sorry:-U.
--
View this message in context: http://www.nabble.com/openssl-cannot-decrypt-the-%22RSA-ECB-PKCS1Padding%22-from-java-tp23881221p23885198.html