Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / October 2007

Tip: Looking for answers? Try searching our database.

IllegalBlockSizeException thrown from .NET dll

Thread view: 
swetha - 24 Oct 2007 09:24 GMT
Hello all

I had posted this query a few days back on the
comp.java.lang.programmer group and after trying a few things I still
am facing the problem of IllegalBlockSizeException being thrown from
the .NET dll that I have compiled with the message - "1 trailing
bytes".

Following is the link to the earlier post:

http://groups.google.co.in/group/comp.lang.java.programmer/browse_thread/thread/
dfa5d6d5bd7cd5fe?hl=en


Since then I have changed my key to an 8 byte array just in case the
conversion from the String and the adding of parity bits was causing
problems and hence my code now is:

Cipher ecipher = Cipher.getInstance("DES");
byte[] raw = {0x0051, 0x0041, 0x003C, 0x003A, 0x0041, 0x0050, 0x0033,
0x003D};

SecretKey mySpec = new SecretKeySpec(result, "DES");
ecipher.init(Cipher.ENCRYPT_MODE, mySpec);

byte[] utf8 = "encryptThis".getBytes("UTF8");
byte[] enc = ecipher.doFinal(utf8); // IllegalBlockSizeException here

However, I still get the same IllegalBlockSizeException error with the
message - "1 trailing bytes" and I would like to know if there is a
workaround to this solution as I am now stuck and cannot think of
anything else that I can do. Any ideas will be appreciated.

Thanks
Swetha
swetha - 24 Oct 2007 12:03 GMT
Apparently, changing

Cipher ecipher = Cipher.getInstance("DES");

to

Cipher ecipher = Cipher.getInstance("DES/ECB/PKCS5Padding");

works.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.