I get the following exception when trying to initialize a SecretKeyFactory:
"Algorithm PBEWithMD5AndDES not available"
Here's the code:
import java.security.Security;
import java.security.Provider;
import java.security.GeneralSecurityException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.crypto.SecretKeyFactory;
import javax.crypto.SecretKey;
public class Decrypt {
//----------------------------------------------------------------- CONSTRUCTOR
/**
* Create a new decrypt class
*/
public Decrypt() {
byte[] salt = {(byte)0x01, (byte)0x02, (byte)0x04, (byte)0x08, (byte)0x10, (byte)0x12, (byte)0x20, (byte)0x24};
System.out.println("Decrypt");
Provider sunJce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunJce);
try {
// PBE parameter set
pbeParamSpec = new PBEParameterSpec(salt, 23);
keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
char[] passw = "Password".toCharArray();
pbeKeySpec = new PBEKeySpec(passw);
pbeKey = keyFac.generateSecret(pbeKeySpec);
// PBE Cipher
pbeCipherDecr = Cipher.getInstance("PBEWithMD5AndDES");
}
catch (GeneralSecurityException gse) {
System.out.println("Decrypt(): "+gse.getMessage());
}
}
//-------------------------------------------------------------- PUBLIC METHODS
public static void main(String[] args) {
Decrypt d = new Decrypt();
}
//----------------------------------------------------------- PRIVATE CONSTANTS
//----------------------------------------------------------- PRIVATE VARIABLES
private Cipher pbeCipherDecr;
private Cipher cipherDecr;
private PBEParameterSpec pbeParamSpec;
private PBEKeySpec pbeKeySpec;
private SecretKeyFactory keyFac;
private SecretKey pbeKey;
private SecretKeySpec blKey;
}
When running this class under JRE I get the output 'Decrypt', but when I run the compiled class (compiled with JET) I get the exception.
I'm evaluating JET excelsior and I'm using jdk1.4 which includes the JCE package.
Anybody know the solution??
Best Regards
Andy