summaryrefslogtreecommitdiff
path: root/Libraries/LibTLS
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-08-15 18:38:24 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-15 21:21:18 +0200
commitfff581cd725db6b9cc1e1fd25503c68ec2d044d3 (patch)
tree0c0a510f5cbd1c2c6c1613b11209655624eda893 /Libraries/LibTLS
parent525d51bbb526912946c491e502b57cf439ab3906 (diff)
downloadserenity-fff581cd725db6b9cc1e1fd25503c68ec2d044d3.zip
AK: Rename span() to bytes() when appropriate.
I originally defined the bytes() method for the String class, because it made it obvious that it's a span of bytes instead of span of characters. This commit makes this more consistent by defining a bytes() method when the type of the span is known to be u8. Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and such.
Diffstat (limited to 'Libraries/LibTLS')
-rw-r--r--Libraries/LibTLS/Record.cpp10
-rw-r--r--Libraries/LibTLS/TLSv12.cpp2
2 files changed, 6 insertions, 6 deletions
diff --git a/Libraries/LibTLS/Record.cpp b/Libraries/LibTLS/Record.cpp
index ddd34379d5..ba9cb23134 100644
--- a/Libraries/LibTLS/Record.cpp
+++ b/Libraries/LibTLS/Record.cpp
@@ -92,7 +92,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
buffer_position += packet.size() - header_size;
// get the appropricate HMAC value for the entire packet
- auto mac = hmac_message(packet.span(), {}, mac_size, true);
+ auto mac = hmac_message(packet, {}, mac_size, true);
// write the MAC
buffer.overwrite(buffer_position, mac.data(), mac.size());
@@ -114,8 +114,8 @@ void TLSv12::update_packet(ByteBuffer& packet)
ASSERT(length % block_size == 0);
// get a block to encrypt into
- auto view = ct.span().slice(header_size + iv_size, length);
- m_aes_local->encrypt(buffer.span(), view, iv.span());
+ auto view = ct.bytes().slice(header_size + iv_size, length);
+ m_aes_local->encrypt(buffer, view, iv);
// store the correct ciphertext length into the packet
u16 ct_length = (u16)ct.size() - header_size;
@@ -215,8 +215,8 @@ ssize_t TLSv12::handle_message(const ByteBuffer& buffer)
auto decrypted = m_aes_remote->create_aligned_buffer(length - iv_size);
auto iv = buffer.slice_view(header_size, iv_size);
- Bytes decrypted_span = decrypted.span();
- m_aes_remote->decrypt(buffer.span().slice(header_size + iv_size, length - iv_size), decrypted_span, iv.span());
+ Bytes decrypted_span = decrypted;
+ m_aes_remote->decrypt(buffer.bytes().slice(header_size + iv_size, length - iv_size), decrypted_span, iv);
length = decrypted_span.size();
diff --git a/Libraries/LibTLS/TLSv12.cpp b/Libraries/LibTLS/TLSv12.cpp
index 0579e23265..7d219bca6a 100644
--- a/Libraries/LibTLS/TLSv12.cpp
+++ b/Libraries/LibTLS/TLSv12.cpp
@@ -727,7 +727,7 @@ bool TLSv12::add_client_key(const ByteBuffer& certificate_pem_buffer, const Byte
if (certificate_pem_buffer.is_empty() || rsa_key.is_empty()) {
return true;
}
- auto decoded_certificate = decode_pem(certificate_pem_buffer.span(), 0);
+ auto decoded_certificate = decode_pem(certificate_pem_buffer, 0);
if (decoded_certificate.is_empty()) {
dbg() << "Certificate not PEM";
return false;