Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2016-07-03 03:14:30 +0300
committerDavid Benjamin <davidben@google.com>2016-07-07 02:11:53 +0300
commite8317a5530d976ff0043f16cb08fa2bfc3657163 (patch)
tree53967e5d32e788605d6d8e7f5d10cfe526d4055b /crypto
parent7819409e132133b4196a7566c03fc4cb280e777a (diff)
Add tests for BN_nnmod.
Change-Id: Ic72e00bb01d254408671b3f8d036be3cd4c06086 Reviewed-on: https://boringssl-review.googlesource.com/8606 Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/bn/bn_test.cc14
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;
}