diff options
-rw-r--r-- | crypto/bn/bn_test.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/bn/bn_test.cc b/crypto/bn/bn_test.cc index 53de2069..e12146eb 100644 --- a/crypto/bn/bn_test.cc +++ b/crypto/bn/bn_test.cc @@ -577,6 +577,20 @@ static bool TestQuotient(FileTest *t, BN_CTX *ctx) { } } + // Test BN_nnmod. + if (!BN_is_negative(b.get())) { + ScopedBIGNUM nnmod(BN_new()); + if (!nnmod || + !BN_copy(nnmod.get(), remainder.get()) || + (BN_is_negative(nnmod.get()) && + !BN_add(nnmod.get(), nnmod.get(), b.get())) || + !BN_nnmod(ret.get(), a.get(), b.get(), ctx) || + !ExpectBIGNUMsEqual(t, "A % B (non-negative)", nnmod.get(), + ret.get())) { + return false; + } + } + return true; } |