mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibCrypto+LibTLS: Use AK/Random.h
This makes it possible to build both of these on Linux.
This commit is contained in:
parent
9a113b0229
commit
c1dd67e792
5 changed files with 17 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Random.h>
|
||||
#include <LibCrypto/PK/Code/Code.h>
|
||||
|
||||
static constexpr u8 zeros[] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
@ -56,7 +57,7 @@ public:
|
|||
auto em_length = (em_bits + 7) / 8;
|
||||
u8 salt[SaltLength];
|
||||
|
||||
arc4random_buf(salt, SaltLength);
|
||||
AK::fill_with_random(salt, SaltLength);
|
||||
|
||||
if (em_length < hash_length + SaltLength + 2) {
|
||||
dbg() << "Ooops...encoding error";
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Random.h>
|
||||
#include <LibCrypto/ASN1/ASN1.h>
|
||||
#include <LibCrypto/ASN1/DER.h>
|
||||
#include <LibCrypto/ASN1/PEM.h>
|
||||
|
@ -236,7 +237,10 @@ void RSA_PKCS1_EME::encrypt(const ByteBuffer& in, ByteBuffer& out)
|
|||
auto ps_length = mod_len - in.size() - 3;
|
||||
u8 ps[ps_length];
|
||||
|
||||
arc4random_buf(ps, ps_length);
|
||||
// FIXME: Without this assertion, GCC refuses to compile due to a memcpy overflow(!?)
|
||||
ASSERT(ps_length < 16384);
|
||||
|
||||
AK::fill_with_random(ps, ps_length);
|
||||
// since arc4random can create zeros (shocking!)
|
||||
// we have to go through and un-zero the zeros
|
||||
for (size_t i = 0; i < ps_length; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue