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

[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