@@ -36,59 +36,6 @@ using android::base::SetProperty;
36
36
namespace android {
37
37
namespace init {
38
38
39
- // Writes 512 bytes of output from Hardware RNG (/dev/hw_random, backed
40
- // by Linux kernel's hw_random framework) into Linux RNG's via /dev/urandom.
41
- // Does nothing if Hardware RNG is not present.
42
- //
43
- // Since we don't yet trust the quality of Hardware RNG, these bytes are not
44
- // mixed into the primary pool of Linux RNG and the entropy estimate is left
45
- // unmodified.
46
- //
47
- // If the HW RNG device /dev/hw_random is present, we require that at least
48
- // 512 bytes read from it are written into Linux RNG. QA is expected to catch
49
- // devices/configurations where these I/O operations are blocking for a long
50
- // time. We do not reboot or halt on failures, as this is a best-effort
51
- // attempt.
52
- Result<void > MixHwrngIntoLinuxRngAction (const BuiltinArguments&) {
53
- unique_fd hwrandom_fd (
54
- TEMP_FAILURE_RETRY (open (" /dev/hw_random" , O_RDONLY | O_NOFOLLOW | O_CLOEXEC)));
55
- if (hwrandom_fd == -1 ) {
56
- if (errno == ENOENT) {
57
- LOG (INFO) << " /dev/hw_random not found" ;
58
- // It's not an error to not have a Hardware RNG.
59
- return {};
60
- }
61
- return ErrnoError () << " Failed to open /dev/hw_random" ;
62
- }
63
-
64
- unique_fd urandom_fd (
65
- TEMP_FAILURE_RETRY (open (" /dev/urandom" , O_WRONLY | O_NOFOLLOW | O_CLOEXEC)));
66
- if (urandom_fd == -1 ) {
67
- return ErrnoError () << " Failed to open /dev/urandom" ;
68
- }
69
-
70
- char buf[512 ];
71
- size_t total_bytes_written = 0 ;
72
- while (total_bytes_written < sizeof (buf)) {
73
- ssize_t chunk_size =
74
- TEMP_FAILURE_RETRY (read (hwrandom_fd, buf, sizeof (buf) - total_bytes_written));
75
- if (chunk_size == -1 ) {
76
- return ErrnoError () << " Failed to read from /dev/hw_random" ;
77
- } else if (chunk_size == 0 ) {
78
- return Error () << " Failed to read from /dev/hw_random: EOF" ;
79
- }
80
-
81
- chunk_size = TEMP_FAILURE_RETRY (write (urandom_fd, buf, chunk_size));
82
- if (chunk_size == -1 ) {
83
- return ErrnoError () << " Failed to write to /dev/urandom" ;
84
- }
85
- total_bytes_written += chunk_size;
86
- }
87
-
88
- LOG (INFO) << " Mixed " << total_bytes_written << " bytes from /dev/hw_random into /dev/urandom" ;
89
- return {};
90
- }
91
-
92
39
static bool SetHighestAvailableOptionValue (const std::string& path, int min, int max) {
93
40
std::ifstream inf (path, std::fstream::in);
94
41
if (!inf) {
0 commit comments