diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-02 13:08:43 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-03 15:53:49 +0200 |
commit | 15532df83da6a8bd91db1b28431e0c14d5cbce05 (patch) | |
tree | 38811376618fee5a1fa8ae4d824db02853f3b5fe /Userland/Libraries/LibTLS | |
parent | 5c045b693427f35b13b40f586fa63bd1d08e06ed (diff) | |
download | serenity-15532df83da6a8bd91db1b28431e0c14d5cbce05.zip |
AK+Everywhere: Change AK::fill_with_random to accept a Bytes object
Rather than the very C-like API we currently have, accepting a void* and
a length, let's take a Bytes object instead. In almost all existing
cases, the compiler figures out the length.
Diffstat (limited to 'Userland/Libraries/LibTLS')
-rw-r--r-- | Userland/Libraries/LibTLS/Handshake.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibTLS/HandshakeClient.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibTLS/Record.cpp | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibTLS/Handshake.cpp b/Userland/Libraries/LibTLS/Handshake.cpp index 1cb0aa420c..b0ae6891a0 100644 --- a/Userland/Libraries/LibTLS/Handshake.cpp +++ b/Userland/Libraries/LibTLS/Handshake.cpp @@ -18,7 +18,7 @@ namespace TLS { ByteBuffer TLSv12::build_hello() { - fill_with_random(&m_context.local_random, 32); + fill_with_random(m_context.local_random); auto packet_version = (u16)m_context.options.version; auto version = (u16)m_context.options.version; diff --git a/Userland/Libraries/LibTLS/HandshakeClient.cpp b/Userland/Libraries/LibTLS/HandshakeClient.cpp index f86b30af7e..ec4e1a44df 100644 --- a/Userland/Libraries/LibTLS/HandshakeClient.cpp +++ b/Userland/Libraries/LibTLS/HandshakeClient.cpp @@ -157,7 +157,7 @@ void TLSv12::build_rsa_pre_master_secret(PacketBuilder& builder) u8 random_bytes[48]; size_t bytes = 48; - fill_with_random(random_bytes, bytes); + fill_with_random(random_bytes); // remove zeros from the random bytes for (size_t i = 0; i < bytes; ++i) { diff --git a/Userland/Libraries/LibTLS/Record.cpp b/Userland/Libraries/LibTLS/Record.cpp index 18a7f3b963..ab0f2e831f 100644 --- a/Userland/Libraries/LibTLS/Record.cpp +++ b/Userland/Libraries/LibTLS/Record.cpp @@ -159,7 +159,7 @@ void TLSv12::update_packet(ByteBuffer& packet) u8 iv[16]; Bytes iv_bytes { iv, 16 }; Bytes { m_context.crypto.local_aead_iv, 4 }.copy_to(iv_bytes); - fill_with_random(iv_bytes.offset(4), 8); + fill_with_random(iv_bytes.slice(4, 8)); memset(iv_bytes.offset(12), 0, 4); // write the random part of the iv out @@ -207,7 +207,7 @@ void TLSv12::update_packet(ByteBuffer& packet) VERIFY_NOT_REACHED(); } auto iv = iv_buffer_result.release_value(); - fill_with_random(iv.data(), iv.size()); + fill_with_random(iv); // write it into the ciphertext portion of the message ct.overwrite(header_size, iv.data(), iv.size()); |