diff --git a/crypto/bn/sqrt.c b/crypto/bn/sqrt.c index 2ed66c22..e3a7b9ac 100644 --- a/crypto/bn/sqrt.c +++ b/crypto/bn/sqrt.c @@ -57,12 +57,11 @@ #include -/* Returns 'ret' such that - * ret^2 == a (mod p), - * using the Tonelli/Shanks algorithm (cf. Henri Cohen, "A Course - * in Algebraic Computational Number Theory", algorithm 1.5.1). - * 'p' must be prime! */ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { + /* Compute a square root of |a| mod |p| using the Tonelli/Shanks algorithm + * (cf. Henri Cohen, "A Course in Algebraic Computational Number Theory", + * algorithm 1.5.1). |p| is assumed to be a prime. */ + BIGNUM *ret = in; int err = 1; int r; diff --git a/include/openssl/bn.h b/include/openssl/bn.h index 23dd8073..a6866964 100644 --- a/include/openssl/bn.h +++ b/include/openssl/bn.h @@ -565,7 +565,8 @@ OPENSSL_EXPORT int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, OPENSSL_EXPORT int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); -/* BN_mod_sqrt returns a |BIGNUM|, r, such that r^2 == a (mod p). */ +/* BN_mod_sqrt returns a |BIGNUM|, r, such that r^2 == a (mod p). |p| must be a + * prime. */ OPENSSL_EXPORT BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);