diff options
author | asynts <asynts@gmail.com> | 2020-08-05 14:09:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-06 10:33:16 +0200 |
commit | b3d1a05261b62cb880963e5c3b3d9cdf57146eb4 (patch) | |
tree | cf34eaa4643f17484af4f7343a4fcb891d79c9ba /Libraries/LibTLS | |
parent | ac9f6fd1f8e235039fa3416f6ed68d07cbbf896c (diff) | |
download | serenity-b3d1a05261b62cb880963e5c3b3d9cdf57146eb4.zip |
Refactor: Expose const_cast by removing ByteBuffer::warp(const void*, size_t)
This function did a const_cast internally which made the call side look
"safe". This method is removed completely and call sites are replaced
with ByteBuffer::wrap(const_cast<void*>(data), size) which makes the
behaviour obvious.
Diffstat (limited to 'Libraries/LibTLS')
-rw-r--r-- | Libraries/LibTLS/Handshake.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibTLS/Record.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibTLS/TLSv12.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibTLS/Handshake.cpp b/Libraries/LibTLS/Handshake.cpp index 99165fec5b..5cafe259e8 100644 --- a/Libraries/LibTLS/Handshake.cpp +++ b/Libraries/LibTLS/Handshake.cpp @@ -157,7 +157,7 @@ ByteBuffer TLSv12::build_finished() auto dummy = ByteBuffer::create_zeroed(0); auto digest = m_context.handshake_hash.digest(); - auto hashbuf = ByteBuffer::wrap(digest.immutable_data(), m_context.handshake_hash.digest_size()); + auto hashbuf = ByteBuffer::wrap(const_cast<u8*>(digest.immutable_data()), m_context.handshake_hash.digest_size()); pseudorandom_function(outbuffer, m_context.master_key, (const u8*)"client finished", 15, hashbuf, dummy); builder.append(outbuffer); diff --git a/Libraries/LibTLS/Record.cpp b/Libraries/LibTLS/Record.cpp index 599646ff8b..8b15d465e4 100644 --- a/Libraries/LibTLS/Record.cpp +++ b/Libraries/LibTLS/Record.cpp @@ -239,7 +239,7 @@ ssize_t TLSv12::handle_message(const ByteBuffer& buffer) memcpy(temp_buf, buffer.offset_pointer(0), 3); *(u16*)(temp_buf + 3) = convert_between_host_and_network(length); auto hmac = hmac_message(ByteBuffer::wrap(temp_buf, 5), decrypted, mac_size); - auto message_mac = ByteBuffer::wrap(message_hmac, mac_size); + auto message_mac = ByteBuffer::wrap(const_cast<u8*>(message_hmac), mac_size); if (hmac != message_mac) { dbg() << "integrity check failed (mac length " << length << ")"; dbg() << "mac received:"; diff --git a/Libraries/LibTLS/TLSv12.cpp b/Libraries/LibTLS/TLSv12.cpp index 5e5e401881..0579e23265 100644 --- a/Libraries/LibTLS/TLSv12.cpp +++ b/Libraries/LibTLS/TLSv12.cpp @@ -265,7 +265,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8* if (length == 1) cert.version = buffer[position]; } - // print_buffer(ByteBuffer::wrap(buffer + position, length)); + // print_buffer(ByteBuffer::wrap(const_cast<u8*>(buffer) + position, length)); break; case 0x03: if (_asn1_is_field_present(fields, Constants::pk_id)) { |