Meta+LibCrypto: Add SecureRandom and replace PRNG usage with it

This adds a thin wrapper to LibCrypto for generating cryptographically
secure random values and replaces current usages of PRNG within
LibCrypto as well.
This commit is contained in:
rmg-x 2024-12-20 10:32:11 -06:00 committed by Ali Mohammad Pur
commit f55f507e56
Notes: github-actions[bot] 2024-12-24 16:56:11 +00:00
10 changed files with 50 additions and 6 deletions

View file

@ -12,6 +12,7 @@
#include <LibCrypto/ASN1/PEM.h>
#include <LibCrypto/Certificate/Certificate.h>
#include <LibCrypto/PK/RSA.h>
#include <LibCrypto/SecureRandom.h>
namespace Crypto::PK {
@ -253,7 +254,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
Vector<u8, 8096> ps;
ps.resize(ps_length);
fill_with_random(ps);
fill_with_secure_random(ps);
// 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) {