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

AW: [iaik-jce]



Hello,

PKCS#1 1.5 requires a padding string of at least 8 bytes plus 3 other
formatting bytes. In this way the data has to be 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 keys.
If you want to use disable padding (not recommended) you may use
Cipher.getInstance("RSA/ECB/NoPadding").
Cipher.getInstance("RSA") is equivalent to
Cipher.getInstance("RSA/ECB/PKCS1Padding") and automatically will select
right padding type (2 for public key encryption/ private key decryption, 1
for private key encryption/ public key decryption).

Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von ravi
Gesendet: Freitag, 25. August 2000 08:35
An: 'iaik-jce@iaik.tu-graz.ac.at'
Betreff: [iaik-jce]


Hai,
I am facing some problems in using RSA Cipher. I am getting BadPadding
Exception . How do I adjust the block sizes
 using PKCS1Padding ?? Any help??
Thank you
ravi

ERRORS
======
javax.crypto.BadPaddingException:PKCS#1 requires data at least 11 bytes
shorter than the modulus!

at iaik.pkcs.pkcs1.RSACipher.b<Unknown Source>
at iaik.pkcs.pkcs1.RSACipher.enginedoFinal<Unknown Source>
at javax.crypto.Cipher.doFinal<Unknown Source>
at EnRSA.main(EnRSA.java.89>

EnRSA.java
==========

Cipher rsa=Cipher.getInstance("RSA/ECB/PKCS1Padding","IAIK");

	rsa.init(Cipher.ENCRYPT_MODE,rsa_priv_key);


	byte[] msg = "Hello Test is my test regergb is test tera jadu ti to
me raj ".getBytes();



	byte[] encrypted = rsa.doFinal(msg);
	String str = new String(encrypted);
	System.out.println("RAJA");
	System.out.println(str);

	rsa.init(Cipher.DECRYPT_MODE, rsa_pub_key);
        byte[] decrypted = rsa.doFinal(encrypted);
        String str1=new String(decrypted);
        System.out.println(str1);

///////////////////////////////////////////////////
Ravi Sankar Veerubhotla
Research Fellow, IDRBT,
Castle Hills, Road No. 1
Masab Tank,
Hyderabad, (A.P.) 500 057.
INDIA.
Ph: +91-40-3534981 to 84 Ext. 2152
Fax: +91-40-3535157
Email: ravi@idrbt.ernet.in
///////////////////////////////////////////////////////

--
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