• Dominik Brodowski's avatar
    hwrng: core - credit entropy for low quality sources of randomness · a43bed82
    Dominik Brodowski authored
    In case the entropy quality is low, there may be less than one bit to
    credit in the call to add_hwgenerator_randomness(): The number of bytes
    returned by rng_get_data() multiplied by the current quality (in entropy
    bits per 1024 bits of input) must be larger than 128 to credit at least
    one bit. However, imx-rngc.c sets the quality to 19, but may return less
    than 32 bytes; hid_u2fzero.c sets the quality to 1; and users may override
    the quality setting manually.
    
    In case there is less than one bit to credit, keep track of it and add
    that credit to the next iteration.
    
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    a43bed82
core.c 13.6 KB