Add documentation of BN_mod_sqrt()
authorTomas Mraz <tomas@openssl.org>
Mon, 28 Feb 2022 17:26:30 +0000 (18:26 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 15 Mar 2022 13:35:56 +0000 (13:35 +0000)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 03eccd2663e36f8b95ba3ae8c30a63313a38ec0a)

doc/man3/BN_add.pod
util/missingcrypto.txt

index 62d3ee72054ca629d413b7c101c22a6f5009ceec..cf6c49c0e3b52df59f28251f6af52110d3dc48e7 100644 (file)
@@ -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)>.
 
index b61bdeb8805fac56b9e396ce4c82d9d5a3d96677..4d2fd7f6b712ab28ce38cdbed5e13e5e3389f0df 100644 (file)
@@ -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)