diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-31 11:38:52 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-06-07 21:58:55 +0100 |
commit | e4c4b2766bb97b34ea3479252276ab7c66311809 (patch) | |
tree | 64bfbaefcae5f9164de11c94c8783b47378a83de | |
parent | e82fd1b4574c8908b2c3bb68e1237f057a981820 (diff) |
Add a BN_mod_word test()
The previous commit fixed a bug with BN_mod_word() which would have been
caught if we had a test for it. This commit adds one.
Reviewed-by: Andy Polyakov <appro@openssl.org>
-rw-r--r-- | crypto/bn/bntest.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c index 1e35988022..a327b1a647 100644 --- a/crypto/bn/bntest.c +++ b/crypto/bn/bntest.c @@ -514,7 +514,7 @@ static void print_word(BIO *bp, BN_ULONG w) int test_div_word(BIO *bp) { BIGNUM a, b; - BN_ULONG r, s; + BN_ULONG r, rmod, s; int i; BN_init(&a); @@ -528,8 +528,14 @@ int test_div_word(BIO *bp) s = b.d[0]; BN_copy(&b, &a); + rmod = BN_mod_word(&b, s); r = BN_div_word(&b, s); + if (rmod != r) { + fprintf(stderr, "Mod (word) test failed!\n"); + return 0; + } + if (bp != NULL) { if (!results) { BN_print(bp, &a); |