]> Cypherpunks repositories - gostls13.git/commit
crypto/rand: batch large calls to linux getrandom
authorMichael McLoughlin <mmcloughlin@gmail.com>
Sun, 16 Jul 2017 00:21:26 +0000 (18:21 -0600)
committerAdam Langley <agl@golang.org>
Wed, 9 Aug 2017 19:29:14 +0000 (19:29 +0000)
commitd401c427b29f48d5cbc5092e62c20aa8524ce356
tree69f35623bf5c665d687eba295db7bc619a5f9f31
parent60b9ae4cf3a0428668748a53f278a80d41fbfc38
crypto/rand: batch large calls to linux getrandom

The linux getrandom system call returns at most 33554431 = 2^25-1 bytes per
call. The existing behavior for larger reads is to report a failure, because
there appears to have been an unexpected short read. In this case the system
falls back to reading from "/dev/urandom".

This change performs reads of 2^25 bytes or more with multiple calls to
getrandom.

Fixes #20877

Change-Id: I618855bdedafd86cd11219fe453af1d6fa2c88a7
Reviewed-on: https://go-review.googlesource.com/49170
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/crypto/rand/rand_linux.go
src/crypto/rand/rand_linux_test.go [new file with mode: 0644]