JDK-4790690 : PBEWithMD5AndTripleDES not supported by SecretKeyFactory
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Affected Version: 1.2.1,1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,windows_nt
  • CPU: x86
  • Submitted: 2002-12-09
  • Updated: 2002-12-10
  • Resolved: 2002-12-10
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 12/09/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

and:

java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

A DESCRIPTION OF THE PROBLEM :
Creating a javax.crypto.SecretKeyFactory with
SecretKeyFactory.getInstance("PBEWithMD5AndTripleDES")
throws a NoSuchAlgorithmException.

According to the Sun JCE documentation
<http://java.sun.com/products/jce/index-14.html> the Sun JCE
Provider should support PBEWithMD5AndTripleDES.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Compile and run below source code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
The SecretKeyFactory.getInstance() should take the algorithm
"PBEWithMD5AndTripleDES" as an argument.

Instead the following exception was returned:

java.security.NoSuchAlgorithmException: Algorithm
PBEWithMD5AndTripleDES not available
        at javax.crypto.SunJCE_b.a(DashoA6275)
        at javax.crypto.SecretKeyFactory.getInstance(DashoA6275)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.security.NoSuchAlgorithmException: Algorithm PBEWithMD5AndTripleDES not
available
        at javax.crypto.SunJCE_b.a(DashoA6275)
        at javax.crypto.SecretKeyFactory.getInstance(DashoA6275)
        at Test.<init>(Test.java:6)
        at Test.main(Test.java:13)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.crypto.SecretKeyFactory;

public class Test {
    public Test() {
		try {
			SecretKeyFactory keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndTripleDES");
		} catch (Exception e) {
			e.printStackTrace();
		}
    }

    public static void main(String[] args) {
    	new Test();
    }
}
---------- END SOURCE ----------
(Review ID: 159349) 
======================================================================

Name: rmT116609			Date: 12/09/2002


DESCRIPTION OF THE PROBLEM :
http://forum.java.sun.com/thread.jsp?forum=9&thread=15105

with the code:

SecretKeyFactory skf =
SecretKeyFactory.getInstance
("PBEWithMD5AndTripleDES", "SunJCE");

throws the following exception.

java.security.NoSuchAlgorithmException: No such algorithm:
PBEWithMD5AndTripleDES
	at javax.crypto.b.a([DashoPro-V1.2-120198])
	at javax.crypto.b.a([DashoPro-V1.2-120198])


It appears that the SunJCE Cipher class supports
PBEWithMD5AndTripleDES, but the SecretKeyFactory does not.

How can i create a 3Des secrete key Factory for PBE (the source of key material is a password)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.SecretKeyFactory skf = SecretKeyFactory.getInstance
("PBEWithMD5AndTripleDES", "SunJCE");

2. see http://forum.java.sun.com/thread.jsp?forum=9&thread=15105

3.

EXPECTED VERSUS ACTUAL BEHAVIOR :
java.security.NoSuchAlgorithmException: No such algorithm:
PBEWithMD5AndTripleDES
	at javax.crypto.b.a([DashoPro-V1.2-120198])
	at javax.crypto.b.a([DashoPro-V1.2-120198])

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.security.NoSuchAlgorithmException: No such algorithm:
PBEWithMD5AndTripleDES
	at javax.crypto.b.a([DashoPro-V1.2-120198])
	at javax.crypto.b.a([DashoPro-V1.2-120198])

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.security.*;
import java.security.spec.*;

import javax.crypto.*;
import javax.crypto.spec.*;

public final class CELKey
{
   
  public static void main(String args[])
  {

        try
        {
            Class cryptoClass = Class.forName("com.sun.crypto.provider.SunJCE");
            
	   Provider SunCrypto = (Provider)cryptoClass.newInstance();

            Security.insertProviderAt(SunCrypto,1);

            String key = "my key";

	   KeySpec ks = new PBEKeySpec(key.toCharArray());

	SecretKeyFactory skf = SecretKeyFactory.getInstance
("PBEWithMD5AndTripleDES", "SunJCE");
                      
        }
        catch (Exception e)
        {
            e.printStackTrace();

        }
  }
}
---------- END SOURCE ----------
(Review ID: 163865)
======================================================================

Comments
EVALUATION ###@###.### 2002-12-10 This bug has already been reported and fixed. Will close this as a duplicate of 4766100.
10-12-2002

WORK AROUND ###@###.### 2002-12-10 You can use "PBEWithMD5AndDES" SecretKeyFactory to convert a PBEKeySpec into a PBEKey. That PBEKey object can be used for "PBEWithMD5AndDES" and "PBEWithMD5AndTripleDES" ciphers.
10-12-2002