diff options
author | Adam Vartanian <flooey@google.com> | 2019-03-01 10:26:45 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-01 10:26:45 -0800 |
commit | a9b7a58bf113c6df8b02b314acd83b381671d62e (patch) | |
tree | 91198a5622bc505aab914986507f2270a40dcfe6 | |
parent | e544a57c1487013bfce07d9363366c7baa39face (diff) | |
parent | cabf9a8310f3b538786a5c0e3d827b819e2c00b4 (diff) | |
download | bouncycastle-a9b7a58bf113c6df8b02b314acd83b381671d62e.tar.gz |
Merge "Remove DH keygen special case" am: 151ca156c5
am: cabf9a8310
Change-Id: Ia65c29d05e0720bcca4e1c0a3eee914a72a3cf49
2 files changed, 24 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())); } diff --git a/repackaged/bcprov/src/main/java/com/android/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java b/repackaged/bcprov/src/main/java/com/android/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java index cb5f7d88..a208fe16 100644 --- a/repackaged/bcprov/src/main/java/com/android/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java +++ b/repackaged/bcprov/src/main/java/com/android/org/bouncycastle/jcajce/provider/asymmetric/dh/KeyPairGeneratorSpi.java @@ -77,10 +77,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())); } |