[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Feb 1 01:03:44 UTC 2017


The branch master has been updated
       via  383e9ade2b0e8333c8a5907fe4ca73d38f9ca465 (commit)
       via  24dc7fe0c008f1261cd34522f7fa2c23a2dedbe9 (commit)
       via  ceac1975357f9a716e4c7f0fee61511bd1bf7034 (commit)
       via  26141babcfad85469383c3919dcff5713fecad16 (commit)
      from  773053386656ab1198e5692b9a63d21942f3adfb (commit)


- Log -----------------------------------------------------------------
commit 383e9ade2b0e8333c8a5907fe4ca73d38f9ca465
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Feb 1 00:48:38 2017 +0100

    bntests.txt: add a couple of checks of possibly negative zero
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/2335)

commit 24dc7fe0c008f1261cd34522f7fa2c23a2dedbe9
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Feb 1 00:47:30 2017 +0100

    bntest: do not stop on first fautl encountered
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/2335)

commit ceac1975357f9a716e4c7f0fee61511bd1bf7034
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Feb 1 00:46:58 2017 +0100

    bntest: make sure file_rshift tests BN_rshift1 as well when appropriate
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/2335)

commit 26141babcfad85469383c3919dcff5713fecad16
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Feb 1 00:46:09 2017 +0100

    bntest: make sure that equalBN takes note of negative zero
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/2335)

-----------------------------------------------------------------------

Summary of changes:
 test/bntest.c    | 36 +++++++++++++++++++++++-------------
 test/bntests.txt |  9 +++++++++
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/test/bntest.c b/test/bntest.c
index f9e3686..0c15a12 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -146,8 +146,14 @@ static int equalBN(const char *op, const BIGNUM *expected, const BIGNUM *actual)
     if (BN_cmp(expected, actual) == 0)
         return 1;
 
-    exstr = BN_bn2hex(expected);
-    actstr = BN_bn2hex(actual);
+    if (BN_is_zero(expected) && BN_is_negative(expected))
+        exstr = OPENSSL_strdup("-0");
+    else
+        exstr = BN_bn2hex(expected);
+    if (BN_is_zero(actual) && BN_is_negative(actual))
+        actstr = OPENSSL_strdup("-0");
+    else
+        actstr = BN_bn2hex(actual);
     if (exstr == NULL || actstr == NULL)
         goto err;
 
@@ -1149,21 +1155,28 @@ static int file_rshift(STANZA *s)
     BIGNUM *rshift = getBN(s, "RShift");
     BIGNUM *ret = BN_new();
     int n = 0;
-    int st = 0;
+    int errcnt = 1;
 
     if (a == NULL || rshift == NULL || ret == NULL || !getint(s, &n, "N"))
         goto err;
 
+    errcnt = 0;
     if (!BN_rshift(ret, a, n)
             || !equalBN("A >> N", rshift, ret))
-        goto err;
+        errcnt++;
+
+    /* If N == 1, try with rshift1 as well */
+    if (n == 1) {
+        if (!BN_rshift1(ret, a)
+                || !equalBN("A >> 1 (rshift1)", rshift, ret))
+            errcnt++;
+    }
 
-    st = 1;
 err:
     BN_free(a);
     BN_free(rshift);
     BN_free(ret);
-    return st;
+    return errcnt == 0;
 }
 
 static int file_square(STANZA *s)
@@ -2182,7 +2195,7 @@ static int file_test_run(STANZA *s)
 static int file_tests()
 {
     STANZA s;
-    int linesread = 0, result = 0;
+    int linesread = 0, errcnt = 0;
 
     /* Read test file. */
     memset(&s, 0, sizeof(s));
@@ -2190,17 +2203,14 @@ static int file_tests()
         if (s.numpairs == 0)
             continue;
         if (!file_test_run(&s)) {
-            if (result == 0)
-                fprintf(stderr, "Test at %d failed\n", s.start);
-            goto err;
+            fprintf(stderr, "Test at %d failed\n", s.start);
+            errcnt++;
         }
         clearstanza(&s);
         s.start = linesread;
     }
-    result = 1;
 
-err:
-    return result;
+    return errcnt == 0;
 }
 
 int test_main(int argc, char *argv[])
diff --git a/test/bntests.txt b/test/bntests.txt
index 9603f00..c1ffb2d 100644
--- a/test/bntests.txt
+++ b/test/bntests.txt
@@ -4643,6 +4643,10 @@ N = 64
 #
 # These test vectors satisfy A / 2^N = RShift, rounding towards zero.
 
+Rshift = 0
+A = -1
+N = 1
+
 RShift = 6ce746ffa7979ce10b751cd2308402a95d00d596cd97b36380
 A = d9ce8dff4f2f39c216ea39a461080552ba01ab2d9b2f66c701
 N = 1
@@ -5967,6 +5971,11 @@ B = -542fb814f45924aa09a16f2a6
 # These test vectors satisfy Quotient = A / B, rounded towards zero, and
 # Remainder = A - B * Quotient.
 
+Quotient = 0
+Remainder = -1
+A = -1
+B = 2
+
 Quotient = 1
 Remainder = 0
 A = 8cdaaa7c422f3c2bb0ace2da7d7ff151e5bdefb23e6426cf3e6b21491e6e80e977bfa6c65931a8dee31fc7992c0c801d5d7c


More information about the openssl-commits mailing list