(gcrypt.info.gz) Basic functions
Info Catalog
(gcrypt.info.gz) Data types
(gcrypt.info.gz) MPI library
(gcrypt.info.gz) MPI formats
11.2 Basic functions
====================
To work with MPIs, storage must be allocated and released for the
numbers. This can be done with one of these functions:
-- Function: gcry_mpi_t gcry_mpi_new (unsigned int NBITS)
Allocate a new MPI object, initialize it to 0 and initially
allocate enough memory for a number of at least NBITS. This
pre-allocation is only a small performance issue and not actually
necessary because Libgcrypt automatically re-allocates the
required memory.
-- Function: gcry_mpi_t gcry_mpi_snew (unsigned int NBITS)
This is identical to `gcry_mpi_new' but allocates the MPI in the so
called "secure memory" which in turn will take care that all
derived values will also be stored in this "secure memory". Use
this for highly confidential data like private key parameters.
-- Function: gcry_mpi_t gcry_mpi_copy (const gcry_mpi_t A)
Create a new MPI as the exact copy of A.
-- Function: void gcry_mpi_release (gcry_mpi_t A)
Release the MPI A and free all associated resources. Passing
`NULL' is allowed and ignored. When a MPI stored in the "secure
memory" is released, that memory gets wiped out immediately.
The simplest operations are used to assign a new value to an MPI:
-- Function: gcry_mpi_t gcry_mpi_set (gcry_mpi_t W, const gcry_mpi_t U)
Assign the value of U to W and return W. If `NULL' is passed for
W, a new MPI is allocated, set to the value of U and returned.
-- Function: gcry_mpi_t gcry_mpi_set_ui (gcry_mpi_t W, unsigned long U)
Assign the value of U to W and return W. If `NULL' is passed for
W, a new MPI is allocated, set to the value of U and returned.
This function takes an `unsigned int' as type for U and thus it is
only possible to set W to small values (usually up to the word
size of the CPU).
-- Function: void gcry_mpi_swap (gcry_mpi_t A, gcry_mpi_t B)
Swap the values of A and B.
Info Catalog
(gcrypt.info.gz) Data types
(gcrypt.info.gz) MPI library
(gcrypt.info.gz) MPI formats
automatically generated byinfo2html