New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entropy bytes discarded #6978

Closed
mattcaswell opened this Issue Aug 16, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@mattcaswell
Member

mattcaswell commented Aug 16, 2018

If syscall_random returns less than the number of bytes needed then those bytes are discarded. We should perhaps use whatever we get.

bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
buffer = rand_pool_add_begin(pool, bytes_needed);
if (buffer != NULL) {
size_t bytes = 0;
if (syscall_random(buffer, bytes_needed) == (int)bytes_needed)
bytes = bytes_needed;
rand_pool_add_end(pool, bytes, 8 * bytes);
entropy_available = rand_pool_entropy_available(pool);
}
if (entropy_available > 0)
return entropy_available;

All kernels will actually only fail or return the requested number of bytes for the amount we call it with so, while this isn't ideal, it probably doesn't make much difference in practice. We should clean it up though.

@mattcaswell mattcaswell added this to the 1.1.1 milestone Aug 16, 2018

@mattcaswell

This comment has been minimized.

Member

mattcaswell commented Aug 16, 2018

This issue was reported by OSTIF.

mspncp added a commit to mspncp/openssl that referenced this issue Aug 16, 2018

rand_unix: don't discard entropy bytes from syscall_random()
Fixes openssl#6978

Don't discard partial reads from syscall_random() and retry instead.

mspncp added a commit to mspncp/openssl that referenced this issue Aug 16, 2018

rand_unix: don't discard entropy bytes from /dev/*random
Fixes openssl#6978

Don't discard partial reads from /dev/*random and retry instead.

mspncp added a commit to mspncp/openssl that referenced this issue Aug 17, 2018

rand_unix.c: don't discard entropy bytes from syscall_random()
Fixes openssl#6978

Don't discard partial reads from syscall_random() and retry instead.

mspncp added a commit to mspncp/openssl that referenced this issue Aug 18, 2018

rand_unix.c: don't discard entropy bytes from syscall_random()
Fixes openssl#6978

Don't discard partial reads from syscall_random() and retry instead.

@levitte levitte closed this in 630ce41 Aug 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment