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!

javax.crypto.BadPaddingException: Given final block not properly padded

843811Sep 18 2006 — edited Oct 18 2009
Folks:
I am getting the error (subject line) - when I try to decrypt on Solaris 10 OS. It works fine on Windows 2003 and Linux and also on Solaris 9.0. Any clues about this.

The stack trace is:

javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)
at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA12275)
at javax.crypto.Cipher.doFinal(DashoA12275)
at com.powerup.configmgr.util.commandline.credentials.CryptoHelper.decrypt(CryptoHelper.java:123)


The line number 123 is the line below correspoinding to doFinal method call.
    public static synchronized byte[] decrypt(byte[] input) 
        throws Exception
    {
    	byte[] ret = null;
//    	System.out.println("ENCRYPTED INPUT= "+input);
        Cipher c = getCipher();
        c.init(Cipher.DECRYPT_MODE,getSecretKey(),getSalt());
        if(input != null)
        	 ret = c.doFinal(input);
        else
        	ret = new byte[0];
//        System.out.println("DECRYPTED INPUT="+ret);
        return ret;
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2009
Added on Sep 18 2006
22 comments
36,742 views