[libcalamares] Also report empty buffer as no-entropy

This commit is contained in:
Adriaan de Groot 2020-01-29 16:08:33 +01:00
parent 842a90e026
commit a574b43eb8
2 changed files with 6 additions and 0 deletions

View File

@ -26,6 +26,11 @@ CalamaresUtils::EntropySource
CalamaresUtils::getEntropy( int size, QByteArray& b ) CalamaresUtils::getEntropy( int size, QByteArray& b )
{ {
b.clear(); b.clear();
if ( size < 1)
{
return EntropySource::None;
}
b.resize( size ); b.resize( size );
char* buffer = b.data(); char* buffer = b.data();
std::fill( buffer, buffer + size, 0xcb ); std::fill( buffer, buffer + size, 0xcb );

View File

@ -28,6 +28,7 @@ namespace CalamaresUtils
/// @brief Which entropy source was actually used for the entropy. /// @brief Which entropy source was actually used for the entropy.
enum class EntropySource enum class EntropySource
{ {
None, ///< Buffer is empty, no random data
URandom, ///< Read from /dev/urandom URandom, ///< Read from /dev/urandom
Twister ///< Generated by pseudo-random Twister ///< Generated by pseudo-random
}; };