Ejemplo n.º 1
0
/* Try to close the FDs of the random gather module.  This is
   currently only implemented for rndlinux. */
void
_gcry_rngsystem_close_fds (void)
{
  lock_rng ();
#if USE_RNDLINUX
  _gcry_rndlinux_gather_random (NULL, 0, 0, 0);
#endif
  unlock_rng ();
}
Ejemplo n.º 2
0
/* Public function to fill the buffer with LENGTH bytes of
   cryptographically strong random bytes.  Level GCRY_WEAK_RANDOM is
   here mapped to GCRY_STRONG_RANDOM, GCRY_STRONG_RANDOM is strong
   enough for most usage, GCRY_VERY_STRONG_RANDOM is good for key
   generation stuff but may be very slow.  */
void
_gcry_rngsystem_randomize (void *buffer, size_t length,
                           enum gcry_random_level level)
{
    _gcry_rngsystem_initialize (1);  /* Auto-initialize if needed.  */

    if (level != GCRY_VERY_STRONG_RANDOM)
        level = GCRY_STRONG_RANDOM;

    lock_rng ();
    get_random (buffer, length, level);
    unlock_rng ();
}