InvalidKeyException: Parameters missing
843810Jul 13 2001 — edited Aug 26 2004When I try to decrypt data, I get this error. The confusing part to me is that the encryption part works just fine. I built the cipher the same exact way. What am I doing wrong?...
Thanks for any help or insite!
/*************************/
// This works
/************************/
Provider sunJce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunJce);
String algorithm = "Blowfish/CBC/PKCS5Padding";
Cipher cipher = null;
KeyData = "0123456789ABCDEF";
byte[] KeyBytes = KeyData.getBytes();
SecretKeySpec skeySpec = new SecretKeySpec(KeyBytes,"Blowfish");
try
{
cipher = Cipher.getInstance(algorithm);
} catch(Exception ex) {
ex.printStackTrace();
}
try
{
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
brdata = crypt(inData,cipher);
Rdata = new String(brdata);
} catch(InvalidKeyException ex) {
ex.printStackTrace();
}
...
/*************************/
// This Does Not Work
/************************/
Provider sunJce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunJce);
String algorithm = "Blowfish/CBC/PKCS5Padding";
Cipher cipher = null;
byte[] brdata = null;
String Rdata = "";
KeyData = "0123456789ABCDEF";
byte[] KeyBytes = KeyData.getBytes();
SecretKeySpec skeySpec = new SecretKeySpec(KeyBytes,"Blowfish");
try
{
cipher = Cipher.getInstance(algorithm);
} catch(Exception ex) {
ex.printStackTrace();
}
try
{
cipher.init((Cipher.DECRYPT_MODE, skeySpec);
brdata = decrypt(inData,cipher);
Rdata = new String(brdata);
} catch(InvalidKeyException ex) {
System.out.println("InvalidKeyException Thrown! Error: " + ex);
ex.printStackTrace();
}
...
Here is the StackTrace:
java.security.InvalidKeyException: Parameters missing
at com.sun.crypto.provider.BlowfishCipher.engineInit([DashoPro-V1.2-120198])
at javax.crypto.Cipher.init([DashoPro-V1.2-120198])
at cryptographyapplication.Cryptography.DecryptBlowFishData(Cryptography.java:186)
at cryptographyapplication.Cryptography.EncryptBlowFishData(Cryptography.java:84)
at cryptographyapplication.Cryptography_Client_Frame1.MakeConnection(Cryptography_Client_Frame1.java:298)
at cryptographyapplication.Cryptography_Client_Frame1.jButton_SendData_actionPerformed(Cryptography_Client_Frame1.java:242)
at cryptographyapplication.Cryptography_Client_Frame1$1.actionPerformed(Cryptography_Client_Frame1.java:106)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1504)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:216)
at java.awt.Component.processMouseEvent(Component.java:3717)
at java.awt.Component.processEvent(Component.java:3546)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Window.dispatchEventImpl(Window.java:912)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)