diff --git a/crypto/fipsmodule/bn/check_bn_tests.go b/crypto/fipsmodule/bn/check_bn_tests.go index 34cefbb3..967f84bc 100644 --- a/crypto/fipsmodule/bn/check_bn_tests.go +++ b/crypto/fipsmodule/bn/check_bn_tests.go @@ -252,6 +252,18 @@ func main() { 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) }