• Jason A. Donenfeld's avatar
    random: mix in timestamps and reseed on system restore · b7b67d13
    Jason A. Donenfeld authored
    Since the RNG loses freshness with system suspend/hibernation, when we
    resume, immediately reseed using whatever data we can, which for this
    particular case is the various timestamps regarding system suspend time,
    in addition to more generally the RDSEED/RDRAND/RDTSC values that happen
    whenever the crng reseeds.
    
    On systems that suspend and resume automatically all the time -- such as
    Android -- we skip the reseeding on suspend resumption, since that could
    wind up being far too busy. This is the same trade-off made in
    WireGuard.
    
    In addition to reseeding upon resumption always mix into the pool these
    various stamps on every power notification event.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    b7b67d13
random.c 53 KB