[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] BadPaddingException in RecipientInfo.decryptKey()


I am using a PKCS12 file with password that contains a private key and
user public cert.  I encrypt a data file into an EnvelopedDataStream
with one recipient and then decrypt to extract the data file.

My code works fine when I use a PKCS12 file created from keys I create
myself using
KeyPairGenerator gen = KeyPairGenerator.getInstance(alg) and

However, when I use a PKCS12 file exported from Netscape for a Verisign
keypair, I get the following exception in my decrypt logic at the step
RecipientInfo recipientInfo = ...;
PrivateKey privateKey = recipientInfo.decryptKey ():
BadPaddingException: Encryption block has wrong block type!

In addition, when I use a PKCS12 file from the RSA CA, I get the
following exception at the same step of the logic:
BadPaddingException: Encrypted message has not k OCTETS!

How can I handle keys from these CAs?

Thanks in advance,

Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-jce