Compute a modular square root: ret^2 ≡ a (mod n) when a quadratic residue.
Declared in <openssl/bn.h>
BIGNUM*
BN_mod_sqrt(
BIGNUM* ret,
BIGNUM const* a,
BIGNUM const* n,
BN_CTX* ctx);
Result BIGNUM (possibly ret), or NULL if no root exists / on error.
| Name | Description |
|---|---|
| ret | Destination for the root, or NULL to allocate. |
| a | Value whose square root modulo n is requested. |
| n | Odd prime modulus (Tonelli–Shanks style algorithms). |
| ctx | BN_CTX scratch space. |