LibTLS+Userland: Remove all uses of ByteBuffer::slice_view()

This was another way to get a non-owning ByteBuffer wrapper.
This commit is contained in:
Andreas Kling 2020-12-19 18:19:15 +01:00
parent d5600e966a
commit b30acdb4b7
Notes: sideshowbarker 2024-07-19 00:44:16 +09:00
4 changed files with 21 additions and 21 deletions

View File

@ -65,7 +65,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
if (packet[0] == (u8)MessageType::Handshake && packet.size() > header_size) {
u8 handshake_type = packet[header_size];
if (handshake_type != HandshakeType::HelloRequest && handshake_type != HandshakeType::HelloVerifyRequest) {
update_hash(packet.slice_view(header_size, packet.size() - header_size));
update_hash(packet.bytes().slice(header_size, packet.size() - header_size));
}
}
if (m_context.cipher_spec_set && m_context.crypto.created) {
@ -272,7 +272,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
if (m_context.cipher_spec_set && type != MessageType::ChangeCipher) {
#ifdef TLS_DEBUG
dbg() << "Encrypted: ";
print_buffer(buffer.slice_view(header_size, length));
print_buffer(buffer.slice(header_size, length));
#endif
if (is_aead()) {

View File

@ -579,7 +579,7 @@ void TLSv12::consume(ReadonlyBytes record)
#endif
break;
}
auto consumed = handle_message(m_context.message_buffer.slice_view(index, length));
auto consumed = handle_message(m_context.message_buffer.bytes().slice(index, length));
#ifdef TLS_DEBUG
if (consumed > 0)

View File

@ -85,9 +85,9 @@ static bool test_single(const Testcase& testcase)
// Checking the results:
bool return_ok = actual_return == testcase.expected_return;
bool canary_1_ok = actual.slice_view(0, SANDBOX_CANARY_SIZE) == expected.slice_view(0, SANDBOX_CANARY_SIZE);
bool main_ok = actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n);
bool canary_2_ok = actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE);
bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE);
bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n);
bool canary_2_ok = actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE);
bool buf_ok = actual == expected;
// Evaluate gravity:
@ -98,20 +98,20 @@ static bool test_single(const Testcase& testcase)
if (!canary_1_ok) {
warnln("Canary 1 overwritten: Expected {}\n"
" instead got {}",
show(expected.slice_view(0, SANDBOX_CANARY_SIZE)),
show(actual.slice_view(0, SANDBOX_CANARY_SIZE)));
show(expected.slice(0, SANDBOX_CANARY_SIZE)),
show(actual.slice(0, SANDBOX_CANARY_SIZE)));
}
if (!main_ok) {
warnln("Wrong output: Expected {}\n"
" instead, got {}",
show(expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)),
show(actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)));
show(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)),
show(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)));
}
if (!canary_2_ok) {
warnln("Canary 2 overwritten: Expected {}\n"
" instead, got {}",
show(expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)),
show(actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)));
show(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)),
show(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)));
}
if (!return_ok) {
warnln("Wrong return value: Expected {}, got {} instead!", testcase.expected_return, actual_return);

View File

@ -89,9 +89,9 @@ static bool test_single(const Testcase& testcase)
// Checking the results:
bool return_ok = actual_return == testcase.src_n;
bool canary_1_ok = actual.slice_view(0, SANDBOX_CANARY_SIZE) == expected.slice_view(0, SANDBOX_CANARY_SIZE);
bool main_ok = actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n);
bool canary_2_ok = actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE);
bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE);
bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n);
bool canary_2_ok = actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE);
bool buf_ok = actual == expected;
// Evaluate gravity:
@ -102,20 +102,20 @@ static bool test_single(const Testcase& testcase)
if (!canary_1_ok) {
warnln("Canary 1 overwritten: Expected canary {}\n"
" instead got {}",
show(expected.slice_view(0, SANDBOX_CANARY_SIZE)),
show(actual.slice_view(0, SANDBOX_CANARY_SIZE)));
show(expected.slice(0, SANDBOX_CANARY_SIZE)),
show(actual.slice(0, SANDBOX_CANARY_SIZE)));
}
if (!main_ok) {
warnln("Wrong output: Expected {}\n"
" instead got {}",
show(expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)),
show(actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)));
show(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)),
show(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)));
}
if (!canary_2_ok) {
warnln("Canary 2 overwritten: Expected {}\n"
" instead got {}",
show(expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)),
show(actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)));
show(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)),
show(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)));
}
if (!return_ok) {
warnln("Wrong return value: Expected {}, got {} instead!", testcase.src_n, actual_return);