Special handling for NULL parameters
keep a table of affected alg OIDs
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bouncycastle.jcajce.util.JcaJceHelper;
import org.bouncycastle.jsse.java.security.BCAlgorithmConstraints;
import org.bouncycastle.jsse.java.security.BCCryptoPrimitive;
+import org.bouncycastle.util.Arrays;
class ProvAlgorithmChecker
extends PKIXCertPathChecker
static final int KU_KEY_AGREEMENT = 4;
private static final Map<String, String> sigAlgNames = createSigAlgNames();
+ private static final Set<String> sigAlgNoParams = createSigAlgNoParams();
+
+ private static final byte[] DER_NULL_ENCODING = new byte[]{ 0x05, 0x00 };
private static Map<String, String> createSigAlgNames()
{
return Collections.unmodifiableMap(names);
}
+ private static Set<String> createSigAlgNoParams()
+ {
+ Set<String> noParams = new HashSet<String>();
+
+ noParams.add(OIWObjectIdentifiers.dsaWithSHA1.getId());
+ noParams.add(X9ObjectIdentifiers.id_dsa_with_sha1.getId());
+
+ return Collections.unmodifiableSet(noParams);
+ }
+
private final JcaJceHelper helper;
private final BCAlgorithmConstraints algorithmConstraints;
@@ -278,10 +293,16 @@ private static AlgorithmParameters getSigAlgParams(JcaJceHelper helper, X509Cert
return null;
}
+ String sigAlgOID = cert.getSigAlgOID();
+ if (sigAlgNoParams.contains(sigAlgOID) && Arrays.areEqual(DER_NULL_ENCODING, encoded))
+ {
+ return null;
+ }
+
AlgorithmParameters sigAlgParams;
try
{
- sigAlgParams = helper.createAlgorithmParameters(cert.getSigAlgOID());
+ sigAlgParams = helper.createAlgorithmParameters(sigAlgOID);
}
catch (GeneralSecurityException e)
{
