Skip to content
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

freebsd: Increase consistancy with libc implementation #36

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

josephlr
Copy link
Member

@josephlr josephlr commented Jun 17, 2019

In #35 @myfreeweb pointed out that the FreeBSD's libc implemenation calls kern_arnd in a loop, and simply retries if the syscall returns a short buffer.

There doesn't seem like a good reason to differ from their implementation, so this PR changes the implementation to be more like the one for Linux getrandom.

@josephlr josephlr mentioned this pull request Jun 17, 2019
@dhardy
Copy link
Member

dhardy commented Jun 18, 2019

And yet that implementation still has a limit of 256 bytes, so unless someone wants to check up on the kernel source code we should keep the chunking I think.

@newpavlov
Copy link
Member

IIUC if we provide buffer larger than 256 bytes, kernel will fill only first 256 bytes and will return 256. Thus we don't need explicit chunking.

@josephlr
Copy link
Member Author

IIUC if we provide buffer larger than 256 bytes, kernel will fill only first 256 bytes and will return 256. Thus we don't need explicit chunking.

This is correct, I also think the the 256 bytes is an implementation detail; I couldn't find documentation for the behavior. In that case, this implementation no longer makes assumptions about how KERN ARND works.

@dhardy
Copy link
Member

dhardy commented Jun 19, 2019

In that case, 👍 . Over to you @newpavlov

@newpavlov newpavlov merged commit a91b60b into rust-random:master Jun 19, 2019
@josephlr josephlr deleted the freebsd branch June 23, 2019 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants