added lookup table for OIDs with specific names.
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.PSSParameterSpec;
+import java.util.HashMap;
+import java.util.Map;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.edec.EdECObjectIdentifiers;
+import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.RSASSAPSSparams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
class X509SignatureUtil
{
+ private static final Map<ASN1ObjectIdentifier, String> algNames = new HashMap<ASN1ObjectIdentifier, String>();
+
+ static
+ {
+ algNames.put(EdECObjectIdentifiers.id_Ed25519, "Ed25519");
+ algNames.put(EdECObjectIdentifiers.id_Ed448, "Ed448");
+ algNames.put(OIWObjectIdentifiers.dsaWithSHA1, "SHA1withDSA");
+ algNames.put(X9ObjectIdentifiers.id_dsa_with_sha1, "SHA1withDSA");
+ }
+
private static final ASN1Null derNull = DERNull.INSTANCE;
static void setSignatureParameters(
@@ -81,14 +94,11 @@ static String getSignatureName(
}
}
- // to avoid OCD for those who love correct case...
- if (sigAlgId.getAlgorithm().equals(EdECObjectIdentifiers.id_Ed25519))
- {
- return "Ed25519";
- }
- if (sigAlgId.getAlgorithm().equals(EdECObjectIdentifiers.id_Ed448))
+ // deal with the "weird" ones.
+ String algName = algNames.get(sigAlgId.getAlgorithm());
+ if (algName != null)
{
- return "Ed448";
+ return algName;
}
return findAlgName(sigAlgId.getAlgorithm());
