Generate a probable prime of the requested size and congruence constraints.

Synopsis

Declared in <openssl/bn.h>

int
BN_generate_prime_ex(
    BIGNUM* ret,
    int bits,
    int safe,
    BIGNUM const* add,
    BIGNUM const* rem,
    BN_GENCB* cb);

Return Value

1 on success, or 0 on failure.

Parameters

Name

Description

ret

Destination BIGNUM for the prime.

bits

Desired bit length.

safe

Non‐zero to require a safe prime ((p‐1)/2 also prime).

add

Optional modulus for the constraint ret ≡ rem (mod add), or NULL.

rem

Optional residue for that constraint, or NULL (defaults to 1).

cb

Optional generation callback, or NULL.

Created with MrDocs