Fill in missing check_bn_tests.go features.
Change-Id: Ic0421b628212521d673cb7053b0fb278c827ebf5
Reviewed-on: https://boringssl-review.googlesource.com/26064
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/fipsmodule/bn/check_bn_tests.go b/crypto/fipsmodule/bn/check_bn_tests.go
index 34cefbb..967f84b 100644
--- a/crypto/fipsmodule/bn/check_bn_tests.go
+++ b/crypto/fipsmodule/bn/check_bn_tests.go
@@ -252,6 +252,18 @@
r := new(big.Int).ModInverse(test.Values["A"], test.Values["M"])
checkResult(test, "A ^ -1 (mod M)", "ModInv", r)
}
+ case "ModSquare":
+ if checkKeys(test, "A", "M", "ModSquare") {
+ r := new(big.Int).Mul(test.Values["A"], test.Values["A"])
+ r = r.Mod(r, test.Values["M"])
+ checkResult(test, "A * A (mod M)", "ModSquare", r)
+ }
+ case "NotModSquare":
+ if checkKeys(test, "P", "NotModSquare") {
+ if new(big.Int).ModSqrt(test.Values["NotModSquare"], test.Values["P"]) != nil {
+ fmt.Fprintf(os.Stderr, "Line %d: value was a square.\n", test.LineNumber)
+ }
+ }
default:
fmt.Fprintf(os.Stderr, "Line %d: unknown test type %q.\n", test.LineNumber, test.Type)
}