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

Re: [iaik-jce] BadPaddingException when using PKCS1Padding



>Cipher ras = Cipher.getInstance("RSA", "IAIK");
> // that should get RSACipher with pkcs1 padding right?

This automatically will select right padding type (2 for public key
encryption/ private key decryption, 1 for private key encryption/ public key
decryption).

 You yourself may set the block type by calling

Cipher.getInstance("RSA/b/PKCS1Padding")

 with padding type b (0, 1, or 2).


> The message is "Padding String must be at least 8
> octets long!"

This is a security condition for public-key operations to prevent from
recovering data by trying all possible encryption blocks. To fulfill this
condition, the data has to at least 11 bytes shorter than the modulus. This
easily is achieved by typical applications using RSA for encrypting message
digest values or content encryption key.

Dieter Bratko

----- Original Message -----
From: Hu Liang <gnailuh@yahoo.com>
To: <iaik-jce@iaik.tu-graz.ac.at>
Sent: Wednesday, February 23, 2000 3:57 AM
Subject: [iaik-jce] BadPaddingException when using PKCS1Padding


> Hello,
>
> The following code is producing a java crypto
> BadPaddingException:
>
> Cipher ras = Cipher.getInstance("RSA", "IAIK");
> // that should get RSACipher with pkcs1 padding right?
> rsa.init(Cipher.ENCRYPT_MODE, privateKey);
> byte[] sig = rsa.doFinal(enc_digest);
>
> The message is "Padding String must be at least 8
> octets long!"
>
> Simple enough, but what am I doing wrong?
>
> Thanks!
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
> --
> 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
>
>




smime.p7s