Add more regress tests for BN_usub().
authorjsing <jsing@openbsd.org>
Tue, 31 Jan 2023 05:12:16 +0000 (05:12 +0000)
committerjsing <jsing@openbsd.org>
Tue, 31 Jan 2023 05:12:16 +0000 (05:12 +0000)
This adds more tests for BN_usub(), particularly where b > a, which should
be an error condition. One of these currently succeeds and produces
incorrect results.

regress/lib/libcrypto/bn/bn_add_sub.c

index 13af33f..2901dcb 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: bn_add_sub.c,v 1.2 2022/12/02 00:01:06 tb Exp $       */
+/*     $OpenBSD: bn_add_sub.c,v 1.3 2023/01/31 05:12:16 jsing Exp $    */
 /*
  * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
  *
@@ -129,6 +129,13 @@ struct hexinput_st test_bn_usub[] = {
                1,
                1,
        },
+       {
+               "11100000001",
+               "100000000001000000000",
+               "0",
+               0,
+               0,
+       },
        {
                "100000000000000000000",
                "1",
@@ -136,6 +143,20 @@ struct hexinput_st test_bn_usub[] = {
                1,
                1,
        },
+       {
+               "1",
+               "0",
+               "1",
+               1,
+               1,
+       },
+       {
+               "1",
+               "2",
+               "FFFFFFFFFFFFFFFF",
+               0,
+               0,
+       },
        {
                "0",
                "1",