[ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

# 11. Prime numbers

 [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

## 11.1 Generation

Function: gcry_error_t gcry_prime_generate (gcry_mpi_t *prime,unsigned int prime_bits, unsigned int factor_bits, gcry_mpi_t **factors, gcry_prime_check_func_t cb_func, void *cb_arg, gcry_random_level_t random_level, unsigned int flags)

Generate a new prime number of prime_bits bits and store it in prime. If factor_bits is non-zero, one of the prime factors of (prime - 1) / 2 must be factor_bits bits long. If factors is non-zero, allocate a new, `NULL`-terminated array holding the prime factors and store it in factors. flags might be used to influence the prime number generation process.

Function: gcry_error_t gcry_prime_group_generator (gcry_mpi_t *r_g, gcry_mpi_t prime, gcry_mpi_t *factors, gcry_mpi_t start_g)

Find a generator for prime where the factorization of (prime-1) is in the `NULL` terminated array factors. Return the generator as a newly allocated MPI in r_g. If start_g is not NULL, use this as the start for the search.

Function: void gcry_prime_release_factors (gcry_mpi_t *factors)

Convenience function to release the factors array.

 [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

## 11.2 Checking

Function: gcry_error_t gcry_prime_check (gcry_mpi_t p, unsigned int flags)

Check wether the number p is prime. Returns zero in case p is indeed a prime, returns `GPG_ERR_NO_PRIME` in case p is not a prime and a different error code in case something went horribly wrong.

 [ << ] [ >> ] [Top] [Contents] [Index] [ ? ]

This document was generated on January, 20 2010 using texi2html 1.76.