diff options
author | Pauli <paul.dale@oracle.com> | 2017-05-08 04:09:41 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-05-09 21:30:29 +0200 |
commit | dc352c193755525292310c8992e3c9b81a556a31 (patch) | |
tree | 9ff9ee27744faf975cabca0120b05c791cb43ccd /test/srptest.c | |
parent | Add test for no change following an HRR (diff) | |
download | openssl-dc352c193755525292310c8992e3c9b81a556a31.tar.xz openssl-dc352c193755525292310c8992e3c9b81a556a31.zip |
Add BN support to the test infrastructure.
This includes support for:
- comparisions between pairs of BIGNUMs
- comparisions between BIGNUMs and zero
- equality comparison between BIGNUMs and one
- equality comparisons between BIGNUMs and constants
- parity checks for BIGNUMs
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3405)
Diffstat (limited to 'test/srptest.c')
-rw-r--r-- | test/srptest.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/test/srptest.c b/test/srptest.c index d28c3bcafc..8e027b908a 100644 --- a/test/srptest.c +++ b/test/srptest.c @@ -70,7 +70,7 @@ static int run_srp(const char *username, const char *client_pass, /* Server random */ RAND_bytes(rand_tmp, sizeof(rand_tmp)); b = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL); - if (!TEST_false(BN_is_zero(b))) + if (!TEST_BN_ne_zero(b)) goto end; showbn("b", b); @@ -84,7 +84,7 @@ static int run_srp(const char *username, const char *client_pass, /* Client random */ RAND_bytes(rand_tmp, sizeof(rand_tmp)); a = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL); - if (!TEST_false(BN_is_zero(a))) + if (!TEST_BN_ne_zero(a)) goto end; showbn("a", a); @@ -107,7 +107,7 @@ static int run_srp(const char *username, const char *client_pass, Kserver = SRP_Calc_server_key(Apub, v, u, b, GN->N); showbn("Server's key", Kserver); - if (!TEST_int_eq(BN_cmp(Kclient, Kserver), 0)) + if (!TEST_BN_eq(Kclient, Kserver)) goto end; ret = 1; @@ -130,19 +130,16 @@ end: static int check_bn(const char *name, const BIGNUM *bn, const char *hexbn) { BIGNUM *tmp = NULL; + int r; if (!TEST_true(BN_hex2bn(&tmp, hexbn))) return 0; - if (!TEST_int_eq(BN_cmp(bn, tmp), 0)) { - TEST_info("Unexpected %s value", name); - showbn("expecting", tmp); - showbn("received", bn); - BN_free(tmp); - return 0; - } + if (BN_cmp(bn, tmp) != 0) + TEST_error("unexpected %s value", name); + r = TEST_BN_eq(bn, tmp); BN_free(tmp); - return 1; + return r; } /* SRP test vectors from RFC5054 */ |