changeset 9115:4954b2c54bba

8026119: Regression test DHEKeySizing.java failing intermittently Reviewed-by: weijun
author xuelei
date Sun, 13 Oct 2013 21:10:33 -0700
parents 48dc8d3cd950
children 8e302572ae76
files test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java	Thu Feb 02 20:19:52 2017 +0000
+++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java	Sun Oct 13 21:10:33 2013 -0700
@@ -111,7 +111,15 @@
 
 public class DHEKeySizing {
 
-    private static boolean debug = true;
+    private final static boolean debug = true;
+
+    // key length bias because of the stripping of leading zero bytes of
+    // negotiated DH keys.
+    //
+    // This is an effort to mimum intermittent failure when we cannot
+    // estimate what's the exact number of leading zero bytes of
+    // negotiated DH keys.
+    private final static int KEY_LEN_BIAS = 6;
 
     private SSLContext sslc;
     private SSLEngine ssle1;    // client
@@ -269,7 +277,8 @@
         twoToOne.flip();
 
         log("Message length of ServerHello series: " + twoToOne.remaining());
-        if (lenServerKeyEx != twoToOne.remaining()) {
+        if (twoToOne.remaining() < (lenServerKeyEx - KEY_LEN_BIAS) ||
+                twoToOne.remaining() > lenServerKeyEx) {
             throw new Exception(
                 "Expected to generate ServerHello series messages of " +
                 lenServerKeyEx + " bytes, but not " + twoToOne.remaining());
@@ -289,7 +298,8 @@
         oneToTwo.flip();
 
         log("Message length of ClientKeyExchange: " + oneToTwo.remaining());
-        if (lenClientKeyEx != oneToTwo.remaining()) {
+        if (oneToTwo.remaining() < (lenClientKeyEx - KEY_LEN_BIAS) ||
+                oneToTwo.remaining() > lenClientKeyEx) {
             throw new Exception(
                 "Expected to generate ClientKeyExchange message of " +
                 lenClientKeyEx + " bytes, but not " + oneToTwo.remaining());