diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-27 12:28:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-27 12:28:17 +0200 |
commit | c1dd67e7929b94700bd4bdb2e1856d95e5b30cc4 (patch) | |
tree | f5f7e2b31ff3923af33c16a7265882fb89578013 /Libraries/LibCrypto/PK/RSA.cpp | |
parent | 9a113b0229dbebfd5f880cd40661c1d0a11a8ff8 (diff) | |
download | serenity-c1dd67e7929b94700bd4bdb2e1856d95e5b30cc4.zip |
LibCrypto+LibTLS: Use AK/Random.h
This makes it possible to build both of these on Linux.
Diffstat (limited to 'Libraries/LibCrypto/PK/RSA.cpp')
-rw-r--r-- | Libraries/LibCrypto/PK/RSA.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp index 7e257b1715..e7c8c26bfe 100644 --- a/Libraries/LibCrypto/PK/RSA.cpp +++ b/Libraries/LibCrypto/PK/RSA.cpp @@ -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) |