Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

What's mean "too much data for RSA block"?

843810Jul 12 2003 — edited Jul 14 2003
When I run:
......
Cipher cipher=Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE,pubKey);
fileIn=new BufferedInputStream(new FileInputStream(args[1]));
buf=new byte[100];
for(int size=fileIn.read(buf,0,buf.length);size!=-1;size=fileIn.read(buf,0,buf.length))
cipher.update(buf,0,size);
buf=cipher.doFinal(buf);
BufferedOutputStream fileOut=new BufferedOutputStream(new FileOutputStream(args[2]));
fileOut.write(buf);
fileOut.close();
......

but I get an error:
java.lang.ArrayIndexOutOfBoundsException: too much data for RSA block
at org.bouncycastle.jce.provider.JCERSACipher.engineDoFinal(JCERSACipher.java:275)
at javax.crypto.Cipher.doFinal(DashoA6275)
at PublicEncrypt.main(PublicEncrypt.java:44)

Who can help me?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2003
Added on Jul 12 2003
1 comment
1,876 views