[#BN_mod_exp_mont_consttime]
= BN&lowbar;mod&lowbar;exp&lowbar;mont&lowbar;consttime
:mrdocs:

Compute modular exponentiation in constant time&colon; `rr` &equals; (`a` &circ; `p)` mod `m&period;`

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
BN&lowbar;mod&lowbar;exp&lowbar;mont&lowbar;consttime(
    xref:BIGNUM.adoc[BIGNUM]* rr,
    xref:BIGNUM.adoc[BIGNUM] const* a,
    xref:BIGNUM.adoc[BIGNUM] const* p,
    xref:BIGNUM.adoc[BIGNUM] const* m,
    xref:BN_CTX.adoc[BN&lowbar;CTX]* ctx,
    xref:BN_MONT_CTX.adoc[BN&lowbar;MONT&lowbar;CTX]* in&lowbar;mont);
----

== Return Value

1 on success, or 0 on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *rr*
| Destination for the result&period;
| *a*
| Base&period;
| *p*
| Exponent (treated as secret for timing purposes)&period;
| *m*
| Odd modulus&period;
| *ctx*
| BN&lowbar;CTX for temporary storage&period;
| *in&lowbar;mont*
| Optional precomputed Montgomery context for `m,` or NULL to build one&period;
|===


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