summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-04-05 11:03:11 +0000
committertb <>2023-04-05 11:03:11 +0000
commitd575d6cc26a8d40373901b5ec211ee30a7d15b2d (patch)
tree28bfb84fd5ec5546679ef9f335ba7f53cc3d12e8
parent6aa452b6cee8c7af30332db2d1c1a7da6a6bb14d (diff)
downloadopenbsd-d575d6cc26a8d40373901b5ec211ee30a7d15b2d.tar.gz
openbsd-d575d6cc26a8d40373901b5ec211ee30a7d15b2d.tar.bz2
openbsd-d575d6cc26a8d40373901b5ec211ee30a7d15b2d.zip
bn_mod_sqrt: Improve a handful of comments and a printf
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mod_sqrt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_sqrt.c b/src/regress/lib/libcrypto/bn/bn_mod_sqrt.c
index 43338297d3..5273aba7c2 100644
--- a/src/regress/lib/libcrypto/bn/bn_mod_sqrt.c
+++ b/src/regress/lib/libcrypto/bn/bn_mod_sqrt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mod_sqrt.c,v 1.7 2023/04/05 10:47:00 tb Exp $ */ 1/* $OpenBSD: bn_mod_sqrt.c,v 1.8 2023/04/05 11:03:11 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org>
@@ -21,7 +21,11 @@
21 21
22#include <openssl/bn.h> 22#include <openssl/bn.h>
23 23
24/* Test that sqrt * sqrt = A (mod p) where p is a prime */ 24/*
25 * Test that .sqrt * .sqrt = .a (mod .p) where .p is a prime. If .sqrt is
26 * omitted, .a does not have a square root and BN_mod_sqrt() fails.
27 */
28
25struct mod_sqrt_test { 29struct mod_sqrt_test {
26 const char *a; 30 const char *a;
27 const char *p; 31 const char *p;
@@ -1455,7 +1459,7 @@ struct mod_sqrt_test {
1455 }, 1459 },
1456 1460
1457 /* 1461 /*
1458 * p = 1 (mod 8), short initial segment of residues 1462 * p = 1 (mod 8), short initial segment of quadratic residues
1459 */ 1463 */
1460 1464
1461 { 1465 {
@@ -2140,7 +2144,7 @@ struct mod_sqrt_test {
2140 }, 2144 },
2141 2145
2142 /* 2146 /*
2143 * p = 1 (mod 8), long initial segment of residues 2147 * p = 1 (mod 8), long initial segment of quadratic residues
2144 */ 2148 */
2145 2149
2146 { 2150 {
@@ -2872,7 +2876,7 @@ mod_sqrt_test(struct mod_sqrt_test *test, BN_CTX *ctx)
2872 if (!BN_is_zero(diff) && !BN_is_zero(sum)) { 2876 if (!BN_is_zero(diff) && !BN_is_zero(sum)) {
2873 fprintf(stderr, "a: %s\n", test->a); 2877 fprintf(stderr, "a: %s\n", test->a);
2874 fprintf(stderr, "p: %s\n", test->p); 2878 fprintf(stderr, "p: %s\n", test->p);
2875 fprintf(stderr, "want: %s:", test->sqrt); 2879 fprintf(stderr, "want: %s\n", test->sqrt);
2876 fprintf(stderr, "got: "); 2880 fprintf(stderr, "got: ");
2877 BN_print_fp(stderr, got); 2881 BN_print_fp(stderr, got);
2878 fprintf(stderr, "\n\n"); 2882 fprintf(stderr, "\n\n");