summaryrefslogtreecommitdiff
path: root/bcprov/src/main/java
diff options
context:
space:
mode:
authorAdam Vartanian <flooey@google.com>2019-03-01 13:36:42 +0000
committerAdam Vartanian <flooey@google.com>2019-03-01 13:36:42 +0000
commit68597d6c545b7f94878cce394a633f186a3f1e56 (patch)
tree91198a5622bc505aab914986507f2270a40dcfe6 /bcprov/src/main/java
parente068c5363c2fd4e1b0ed9928628df1a6ca06ce93 (diff)
downloadbouncycastle-68597d6c545b7f94878cce394a633f186a3f1e56.tar.gz
Remove DH keygen special case
BC added an optimization for a BC-specific key generation params class that ultimately causes Wycheproof's DhTest to fail. While I believe it would be safe to include that optimization, in the interest of being conservative, I'm going to disable it to maintain the behavior of previous versions. Bug: 124926190 Test: cts -m CtsLibcoreTestCases Test: cts -m CtsLibcoreWycheproofBCTestCases Change-Id: I6aa9945d1e0f55cc4789d35edd41cc47fe61a3d6
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()));
}