aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWycheproof Team <noreply@google.com>2023-07-16 23:35:26 -0700
committerCopybara-Service <copybara-worker@google.com>2023-07-16 23:36:09 -0700
commit011fcc38ed95209494d05fcc3a38501bffb9d918 (patch)
treebba4522ed6a0b2bba8170eff9f1a1238ce3a35da
parent6ff0cb25830e8e71e0921f90bc11b43d02a10a0d (diff)
downloadwycheproof-011fcc38ed95209494d05fcc3a38501bffb9d918.tar.gz
Add a better error message to the DhTest.
A typical error message with the new JDK looks like this: java.lang.AssertionError: X expected to have bit length 1504, but has value 92958950218418996462987643843877938499735925222249647906188789799246291415800, which has bit length 256 NOKEYCHECK=True PiperOrigin-RevId: 548591594
-rw-r--r--java/com/google/security/wycheproof/testcases/DhTest.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/java/com/google/security/wycheproof/testcases/DhTest.java b/java/com/google/security/wycheproof/testcases/DhTest.java
index 933e137..7e23b58 100644
--- a/java/com/google/security/wycheproof/testcases/DhTest.java
+++ b/java/com/google/security/wycheproof/testcases/DhTest.java
@@ -277,7 +277,14 @@ public class DhTest {
// should be chosen to prevent attacks.
int minPrivateKeyBits = keySize / 2;
BigInteger x = priv.getX();
- assertTrue(x.bitLength() >= minPrivateKeyBits - 32);
+ assertTrue(
+ "X expected to have bit length at least "
+ + (minPrivateKeyBits - 32)
+ + ", but has value "
+ + x
+ + ", which has bit length "
+ + x.bitLength(),
+ x.bitLength() >= minPrivateKeyBits - 32);
// TODO(bleichen): add tests for weak random number generators.
// Verify the DH parameters.