-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
None
-
b96
-
sparc
-
solaris_9
Keys generated using DiffieHellman algorithm return "DH", instead of
the full name "DiffieHellman" used by KeyPairGenerator,
when Key.getAlgorithm() is called.
import java.security.*;
public class GetAlgorithmTest {
public static void main(String[] args) throws Exception {
String[] algorithm = {"RSA", "DiffieHellman", "RSA"};
String[] provider = {"SunJSSE", "SunJCE", "SunRsaSign"};
for (int i = 0; i < 3; i++) {
System.out.println("Algorithm: " + algorithm[i] + ", Provider: " + provider[i]);
KeyPairGenerator generator = KeyPairGenerator.getInstance(algorithm[i], provider[i]);
KeyPair keys = generator.genKeyPair();
PublicKey k1 = keys.getPublic();
PrivateKey k2 = keys.getPrivate();
String alg1 = k1.getAlgorithm();
String alg2 = k2.getAlgorithm();
String format1 = k1.getFormat();
String format2 = k2.getFormat();
if (!alg1.equals(algorithm[i])) {
System.out.println("getAlgorithm() on public key returns " + alg1);
System.out.println("expected is " + algorithm[i]);
}
if (!alg2.equals(algorithm[i])) {
System.out.println("getAlgorithm() on public key returns " + alg2);
System.out.println("expected is " + algorithm[i]);
}
if (!format1.equals("X.509")) {
System.out.println("getFormat() on public key returns " + format1);
System.out.println("X.509 expected");
}
if (!format2.equals("PKCS#8")) {
System.out.println("getFormat() on private key returns " + format2);
System.out.println("PKCS#8 expected");
}
System.out.println();
}
}
}
Output:
Algorithm: RSA, Provider: SunJSSE
Algorithm: DiffieHellman, Provider: SunJCE
getAlgorithm() on public key returns DH
expected is DiffieHellman
getAlgorithm() on public key returns DH
expected is DiffieHellman
Algorithm: RSA, Provider: SunRsaSign
This problem does not occur on DSA or RSA algorithm.
###@###.### 2004-12-15 19:40:35 GMT
the full name "DiffieHellman" used by KeyPairGenerator,
when Key.getAlgorithm() is called.
import java.security.*;
public class GetAlgorithmTest {
public static void main(String[] args) throws Exception {
String[] algorithm = {"RSA", "DiffieHellman", "RSA"};
String[] provider = {"SunJSSE", "SunJCE", "SunRsaSign"};
for (int i = 0; i < 3; i++) {
System.out.println("Algorithm: " + algorithm[i] + ", Provider: " + provider[i]);
KeyPairGenerator generator = KeyPairGenerator.getInstance(algorithm[i], provider[i]);
KeyPair keys = generator.genKeyPair();
PublicKey k1 = keys.getPublic();
PrivateKey k2 = keys.getPrivate();
String alg1 = k1.getAlgorithm();
String alg2 = k2.getAlgorithm();
String format1 = k1.getFormat();
String format2 = k2.getFormat();
if (!alg1.equals(algorithm[i])) {
System.out.println("getAlgorithm() on public key returns " + alg1);
System.out.println("expected is " + algorithm[i]);
}
if (!alg2.equals(algorithm[i])) {
System.out.println("getAlgorithm() on public key returns " + alg2);
System.out.println("expected is " + algorithm[i]);
}
if (!format1.equals("X.509")) {
System.out.println("getFormat() on public key returns " + format1);
System.out.println("X.509 expected");
}
if (!format2.equals("PKCS#8")) {
System.out.println("getFormat() on private key returns " + format2);
System.out.println("PKCS#8 expected");
}
System.out.println();
}
}
}
Output:
Algorithm: RSA, Provider: SunJSSE
Algorithm: DiffieHellman, Provider: SunJCE
getAlgorithm() on public key returns DH
expected is DiffieHellman
getAlgorithm() on public key returns DH
expected is DiffieHellman
Algorithm: RSA, Provider: SunRsaSign
This problem does not occur on DSA or RSA algorithm.
###@###.### 2004-12-15 19:40:35 GMT