summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-02-28 18:26:30 +0100
committerMatt Caswell <matt@openssl.org>2022-03-15 13:35:56 +0000
commite73bcbd4748213aeb2e0be1b05a81bee6b24e20d (patch)
treebea5860f0a13f9d39d970d9c3c0c90b66a28e5ea
parenta466912611aa6cbdf550cd10601390e587451246 (diff)
downloadopenssl-new-e73bcbd4748213aeb2e0be1b05a81bee6b24e20d.tar.gz
Add documentation of BN_mod_sqrt()
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 03eccd2663e36f8b95ba3ae8c30a63313a38ec0a)
-rw-r--r--doc/man3/BN_add.pod15
-rw-r--r--util/missingcrypto.txt1
2 files changed, 13 insertions, 3 deletions
diff --git a/doc/man3/BN_add.pod b/doc/man3/BN_add.pod
index 62d3ee7205..cf6c49c0e3 100644
--- a/doc/man3/BN_add.pod
+++ b/doc/man3/BN_add.pod
@@ -3,7 +3,7 @@
=head1 NAME
BN_add, BN_sub, BN_mul, BN_sqr, BN_div, BN_mod, BN_nnmod, BN_mod_add,
-BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_exp, BN_mod_exp, BN_gcd -
+BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_mod_sqrt, BN_exp, BN_mod_exp, BN_gcd -
arithmetic operations on BIGNUMs
=head1 SYNOPSIS
@@ -36,6 +36,8 @@ arithmetic operations on BIGNUMs
int BN_mod_sqr(BIGNUM *r, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
+ BIGNUM *BN_mod_sqrt(BIGNUM *in, BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
+
int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
@@ -87,6 +89,12 @@ L<BN_mod_mul_reciprocal(3)>.
BN_mod_sqr() takes the square of I<a> modulo B<m> and places the
result in I<r>.
+BN_mod_sqrt() returns the modular square root of I<a> such that
+C<in^2 = a (mod p)>. The modulus I<p> must be a
+prime, otherwise an error or an incorrect "result" will be returned.
+The result is stored into I<in> which can be NULL. The result will be
+newly allocated in that case.
+
BN_exp() raises I<a> to the I<p>-th power and places the result in I<r>
(C<r=a^p>). This function is faster than repeated applications of
BN_mul().
@@ -108,7 +116,10 @@ the arguments.
=head1 RETURN VALUES
-For all functions, 1 is returned for success, 0 on error. The return
+The BN_mod_sqrt() returns the result (possibly incorrect if I<p> is
+not a prime), or NULL.
+
+For all remaining functions, 1 is returned for success, 0 on error. The return
value should always be checked (e.g., C<if (!BN_add(r,a,b)) goto err;>).
The error codes can be obtained by L<ERR_get_error(3)>.
diff --git a/util/missingcrypto.txt b/util/missingcrypto.txt
index b61bdeb880..4d2fd7f6b7 100644
--- a/util/missingcrypto.txt
+++ b/util/missingcrypto.txt
@@ -264,7 +264,6 @@ BN_mod_lshift(3)
BN_mod_lshift1(3)
BN_mod_lshift1_quick(3)
BN_mod_lshift_quick(3)
-BN_mod_sqrt(3)
BN_mod_sub_quick(3)
BN_nist_mod_192(3)
BN_nist_mod_224(3)