[#BN_generate_prime_ex]
= BN&lowbar;generate&lowbar;prime&lowbar;ex
:mrdocs:

Generate a probable prime of the requested size and congruence constraints&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
BN&lowbar;generate&lowbar;prime&lowbar;ex(
    xref:BIGNUM.adoc[BIGNUM]* ret,
    int bits,
    int safe,
    xref:BIGNUM.adoc[BIGNUM] const* add,
    xref:BIGNUM.adoc[BIGNUM] const* rem,
    xref:BN_GENCB.adoc[BN&lowbar;GENCB]* cb);
----

== Return Value

1 on success, or 0 on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ret*
| Destination BIGNUM for the prime&period;
| *bits*
| Desired bit length&period;
| *safe*
| Non&hyphen;zero to require a safe prime ((p&hyphen;1)&sol;2 also prime)&period;
| *add*
| Optional modulus for the constraint ret ≡ rem (mod add), or NULL&period;
| *rem*
| Optional residue for that constraint, or NULL (defaults to 1)&period;
| *cb*
| Optional generation callback, or NULL&period;
|===


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