[#BN_mod_sqrt]
= BN&lowbar;mod&lowbar;sqrt
:mrdocs:

Compute a modular square root&colon; ret&circ;2 ≡ a (mod n) when a quadratic residue&period;

== Synopsis

Declared in `&lt;openssl&sol;bn&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BIGNUM.adoc[BIGNUM]*
BN&lowbar;mod&lowbar;sqrt(
    xref:BIGNUM.adoc[BIGNUM]* ret,
    xref:BIGNUM.adoc[BIGNUM] const* a,
    xref:BIGNUM.adoc[BIGNUM] const* n,
    xref:BN_CTX.adoc[BN&lowbar;CTX]* ctx);
----

== Return Value

Result BIGNUM (possibly `ret),` or NULL if no root exists &sol; on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ret*
| Destination for the root, or NULL to allocate&period;
| *a*
| Value whose square root modulo `n` is requested&period;
| *n*
| Odd prime modulus (Tonelli–Shanks style algorithms)&period;
| *ctx*
| BN&lowbar;CTX scratch space&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
