Previous: Bit manipulations, Up: MPI library

11.7 Miscellaneous

— Function: gcry_mpi_t gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits)

Store nbits of the value p points to in a and mark a as an opaque value (i.e. an value that can't be used for any math calculation and is only used to store an arbitrary bit pattern in a).

WARNING: Never use an opaque MPI for actual math operations. The only valid functions are gcry_mpi_get_opaque and gcry_mpi_release. Use gcry_mpi_scan to convert a string of arbitrary bytes into an MPI.

— Function: void * gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits)

Return a pointer to an opaque value stored in a and return its size in nbits. Note that the returned pointer is still owned by a and that the function should never be used for an non-opaque MPI.

— Function: void gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)

Set the flag for the MPI a. Currently only the flag GCRYMPI_FLAG_SECURE is allowed to convert a into an MPI stored in "secure memory".

— Function: void gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)

Clear flag for the multi-precision-integers a. Note that this function is currently useless as no flags are allowed.

— Function: int gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)

Return true when the flag is set for a.

— Function: void gcry_mpi_randomize (gcry_mpi_t w, unsigned int nbits, enum gcry_random_level level)

Set the multi-precision-integers w to a random value of nbits, using random data quality of level level. In case nbits is not a multiple of a byte, nbits is rounded up to the next byte boundary. When using a level of GCRY_WEAK_RANDOM this function makes use of gcry_create_nonce.