1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:37:35 +00:00

LibCrypto+LibTLS+Kernel: Switch the Cipher::Mode interface to use Span

This shaves 2.5 more runtime seconds off 'disasm /bin/id', and makes the
Mode<T> interface a lot more allocation-friendly.
This commit is contained in:
AnotherTest 2020-08-11 23:30:49 +04:30 committed by Andreas Kling
parent caedd05bd8
commit bc7a149039
11 changed files with 182 additions and 153 deletions

View file

@ -68,12 +68,13 @@ public:
typename CipherType::CTRMode cipher(m_key, KeySize);
auto wrapped_buffer = ByteBuffer::wrap(buffer, n);
m_counter = cipher.key_stream(wrapped_buffer, m_counter).value();
Bytes buffer_span { buffer, n };
auto counter_span = m_counter.span();
cipher.key_stream(buffer_span, counter_span, &counter_span);
// Extract a new key from the prng stream.
m_counter = cipher.key_stream(m_key, m_counter).value();
cipher.key_stream(buffer_span, counter_span, &counter_span);
}
template<typename T>