CiFEr
Functions
prime.h File Reference

Prime number related functions. More...

Go to the source code of this file.

Functions

bool cfe_is_safe_prime (mpz_t p)
 
cfe_error cfe_get_prime (mpz_t res, size_t bits, bool safe)
 

Detailed Description

Prime number related functions.

Function Documentation

◆ cfe_is_safe_prime()

bool cfe_is_safe_prime ( mpz_t  p)

Checks whether the number passed as argument is a safe prime.

Parameters
pThe number to be checked
Returns
true if number is a safe prime, false otherwise

◆ cfe_get_prime()

cfe_error cfe_get_prime ( mpz_t  res,
size_t  bits,
bool  safe 
)

Sets the first argument to a prime with specified bit length. The prime will be a safe prime if the safe parameter is true.

Parameters
resThe safe prime (result value is stored here)
bitsBit length of the safe prime
safeBoolean value if the prime will be safe or not
Returns
Error code