-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
5.0
-
sparc
-
solaris_7
Name: mtR10145 Date: 10/09/2003
The test code below illustrates that
javax.crypto.EncryptedPrivateKeyInfo.getAlgName() method returns
unexpected String (tested with j2se 1.5.0-beta-b22):
=============================== Test2.java ======================
import javax.crypto.EncryptedPrivateKeyInfo;
import java.security.NoSuchAlgorithmException;
public class Test2 {
public static void main( String argv[] ) {
byte [] encryptedData = { 1, 2, 3, 4};
String [] allAlgorithms = {
"MD2", "MD5", "SHA-1", "SHA-256",
"SHA-384", "SHA-512", "DSA", "RSA",
"MD2withRSA", "MD5withRSA", "SHA1withDSA",
"SHA1withRSA", "SHA1PRNG" };
String allowedAlgorithm = null;
for (int i = 0; i < allAlgorithms.length; i++) {
try {
allowedAlgorithm = allAlgorithms[i];
EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(allowedAlgorithm, encryptedData);
if (!epki.getAlgName().equalsIgnoreCase(allowedAlgorithm))
System.out.println("Error: getAlgName returned " + epki.getAlgName() + " when " +
allowedAlgorithm + " expected");
} catch (NoSuchAlgorithmException nsae) {
}
}
}
}
=============== Test output ==========================
Error: getAlgName returned SHA when SHA-1 expected
======================================================
Since several different SHA-based algorithms are available (such as
SHA-1, SHA-256, SHA-384, SHA-512), getAlgName should return exact name
of algorithm which was passed to constructor.
======================================================================
- relates to
-
JDK-4941596 EncryptedPrivateKeyInfo.getAlgName: the spec is incomplete
- Closed