BN_mod_sqrt

Compute a modular square root: ret^2 ≡ a (mod n) when a quadratic residue.

Synopsis

Declared in <openssl/bn.h>

BIGNUM*
BN_mod_sqrt(
    BIGNUM* ret,
    BIGNUM const* a,
    BIGNUM const* n,
    BN_CTX* ctx);

Return Value

Result BIGNUM (possibly ret), or NULL if no root exists / on error.

Parameters

NameDescription
retDestination for the root, or NULL to allocate.
aValue whose square root modulo n is requested.
nOdd prime modulus (Tonelli–Shanks style algorithms).
ctxBN_CTX scratch space.