summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorJean-Baptiste Boric <jblbeurope@gmail.com>2021-05-14 17:27:38 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-14 22:24:02 +0200
commit090936e42421191f21ee946e1c04c1e36c4f9a5f (patch)
tree43af5bdfab901f83f75c2a66676560b7fd4e696f /Userland/Libraries
parent5a0468c21f676297aac8e97e348c6287e31653f7 (diff)
downloadserenity-090936e42421191f21ee946e1c04c1e36c4f9a5f.zip
Userland: Replace arc4random() with get_random<u32>()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCrypto/PK/RSA.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MathObject.cpp3
2 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCrypto/PK/RSA.cpp b/Userland/Libraries/LibCrypto/PK/RSA.cpp
index e426d755ab..97e2480a53 100644
--- a/Userland/Libraries/LibCrypto/PK/RSA.cpp
+++ b/Userland/Libraries/LibCrypto/PK/RSA.cpp
@@ -339,7 +339,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
ps.resize(ps_length);
fill_with_random(ps.data(), ps_length);
- // since arc4random can create zeros (shocking!)
+ // since fill_with_random can create zeros (shocking!)
// we have to go through and un-zero the zeros
for (size_t i = 0; i < ps_length; ++i)
while (!ps[i])
diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
index 16489c7c19..c48c09916d 100644
--- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
@@ -6,6 +6,7 @@
*/
#include <AK/Function.h>
+#include <AK/Random.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/MathObject.h>
#include <math.h>
@@ -86,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::abs)
JS_DEFINE_NATIVE_FUNCTION(MathObject::random)
{
#ifdef __serenity__
- double r = (double)arc4random() / (double)UINT32_MAX;
+ double r = (double)get_random<u32>() / (double)UINT32_MAX;
#else
double r = (double)rand() / (double)RAND_MAX;
#endif