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

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.

Created with MrDocs