[WTF] Introduce WTF::RandomDevice which keeps /dev/urandom opened
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Apr 2017 07:04:38 +0000 (07:04 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Apr 2017 07:04:38 +0000 (07:04 +0000)
commitaa4569c5ae76b5fa8f9285e8d06f2ba3321db8a9
tree033f8704ccf765818e1d2e364a4cd44b64e1ab35
parent6c1cb032e825c1a385122efe20d48f21df61b31f
[WTF] Introduce WTF::RandomDevice which keeps /dev/urandom opened
https://bugs.webkit.org/show_bug.cgi?id=170095

Reviewed by Michael Catanzaro.

In this patch, we introduce RandomDevice, which keeps /dev/urandom opened
to avoid repeatedly open and close urandom file descriptor in Linux.

The purpose is similar to std::random_device, but WTF::RandomDevice explicitly
avoids using ARC4, which is recently attempted to be removed from the WebKit
tree[1].

[1]: https://trac.webkit.org/r214329

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/OSRandomSource.cpp:
(WTF::cryptographicallyRandomValuesFromOS):
(WTF::crashUnableToOpenURandom): Deleted.
(WTF::crashUnableToReadFromURandom): Deleted.
* wtf/RandomDevice.cpp: Copied from Source/WTF/wtf/OSRandomSource.cpp.
(WTF::crashUnableToOpenURandom):
(WTF::crashUnableToReadFromURandom):
(WTF::RandomDevice::RandomDevice):
(WTF::RandomDevice::~RandomDevice):
(WTF::RandomDevice::cryptographicallyRandomValues):
* wtf/RandomDevice.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214867 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/OSRandomSource.cpp
Source/WTF/wtf/RandomDevice.cpp [new file with mode: 0644]
Source/WTF/wtf/RandomDevice.h [new file with mode: 0644]