summaryrefslogtreecommitdiff
path: root/bcprov/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bcprov/src/main/java')
-rw-r--r--bcprov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java b/bcprov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java
index 1e426b12..ce21d3dc 100644
--- a/bcprov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java
+++ b/bcprov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java
@@ -73,10 +73,22 @@ public class KeyPairGeneratorSpi
private DHKeyGenerationParameters convertParams(SecureRandom random, DHParameterSpec dhParams)
{
+ // BEGIN Android-removed: Don't special-case DHDomainParameterSpec
+ // When DHDomainParameterSpec is special-cased here, it supplies a value for q that
+ // ultimately results in a smaller value of x, which runs afoul of the Wycheproof test
+ // com.google.security.wycheproof.DhTest.testKeyPairGenerator(). See the docs in DhTest
+ // for more details of why that requirement is made.
+ //
+ // While we believe this code would be safe (and likely somewhat faster), in the interest
+ // of being conservative we've disabled it to preserve the old behavior that also passes
+ // the Wycheproof test.
+ /*
if (dhParams instanceof DHDomainParameterSpec)
{
return new DHKeyGenerationParameters(random, ((DHDomainParameterSpec)dhParams).getDomainParameters());
}
+ */
+ // END Android-removed: Don't special-case DHDomainParameterSpec
return new DHKeyGenerationParameters(random, new DHParameters(dhParams.getP(), dhParams.getG(), null, dhParams.getL()));
}