Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error :RSA_padding_check_PKCS1_type_1:block type is not 01 ..?

Tags:

openssl

rsa

hi can any tell me why this error occurs while decrypt the RSA Private key encrypted message.

i am Verifying the Signature of the message signed by the Java and verifying the Signature using openssl 0.9.8g

like image 273
Balamurugan Avatar asked Oct 05 '11 10:10

Balamurugan


1 Answers

This usually means that the encrypting side and the decrypting side are using different padding scheme. They need to be the same on both sides.

If you use Bouncy Castle in Java, you can specify the padding scheme (in this case, PKCS #1 padding) in the cipher like this:

Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding", "BC");

In openssl, you can specify the padding scheme in the encrypt/decrypt command:

openssl rsautl -pkcs -decrypt ...

Here, option "-pkcs" specifies the PKCS #1 padding scheme.

Hope this helps.

like image 104
Gz Zheng Avatar answered Sep 22 '22 06:09

Gz Zheng