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
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-04-21 03:46:18 +0300
committerAdam Langley <agl@google.com>2015-05-05 01:41:25 +0300
commit160f4ef14c12d8b846eeac498de10a0633f6d2f4 (patch)
tree08a0b334544bd592168f69958327d32e607ef8f7 /crypto/bn/bn_test.cc
parent8bac8c48ec875341e32889113e8a110dc3fc9803 (diff)
Test BN_mul for negative zero.
Change-Id: I235c59c14ec08c3338c22d080f304bdf2d7adef0 Reviewed-on: https://boringssl-review.googlesource.com/4486 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/bn/bn_test.cc')
-rw-r--r--crypto/bn/bn_test.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/bn/bn_test.cc b/crypto/bn/bn_test.cc
index ab147d15..3c239d3b 100644
--- a/crypto/bn/bn_test.cc
+++ b/crypto/bn/bn_test.cc
@@ -690,6 +690,21 @@ static bool test_mul(FILE *fp) {
return false;
}
}
+
+ // Test that BN_mul never gives negative zero.
+ if (!BN_set_word(a.get(), 1)) {
+ return false;
+ }
+ BN_set_negative(a.get(), 1);
+ BN_zero(b.get());
+ if (!BN_mul(c.get(), a.get(), b.get(), ctx.get())) {
+ return false;
+ }
+ if (!BN_is_zero(c.get()) || BN_is_negative(c.get())) {
+ fprintf(stderr, "Multiplication test failed!\n");
+ return false;
+ }
+
return true;
}