summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-05-31 11:38:52 +0100
committerMatt Caswell <matt@openssl.org>2016-06-07 21:55:31 +0100
commitf44310e9ce2cdab64a9269ad8014be978e333db6 (patch)
treef43676e844900f43e8ddc345d9933a4c06e6a793 /test
parent37258dadaa9e36db4b96a3aa54aa6c67136160cc (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>
Diffstat (limited to 'test')
-rw-r--r--test/bntest.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/bntest.c b/test/bntest.c
index 804406c94d..763a8c29f9 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -504,7 +504,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;
a = BN_new();
@@ -518,8 +518,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);