|
@@ -47,7 +47,7 @@ public:
|
|
|
// FIXME: We should have two of these encrypt/decrypt functions that
|
|
|
// we SFINAE out based on whether the Cipher mode needs an ivec
|
|
|
VERIFY(!ivec.is_empty());
|
|
|
- const auto* iv = ivec.data();
|
|
|
+ ReadonlyBytes iv = ivec;
|
|
|
|
|
|
m_cipher_block.set_padding_mode(cipher.padding_mode());
|
|
|
size_t offset { 0 };
|
|
@@ -59,7 +59,7 @@ public:
|
|
|
cipher.encrypt_block(m_cipher_block, m_cipher_block);
|
|
|
VERIFY(offset + block_size <= out.size());
|
|
|
__builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size);
|
|
|
- iv = out.offset(offset);
|
|
|
+ iv = out.slice(offset);
|
|
|
length -= block_size;
|
|
|
offset += block_size;
|
|
|
}
|
|
@@ -70,11 +70,11 @@ public:
|
|
|
cipher.encrypt_block(m_cipher_block, m_cipher_block);
|
|
|
VERIFY(offset + block_size <= out.size());
|
|
|
__builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size);
|
|
|
- iv = out.offset(offset);
|
|
|
+ iv = out.slice(offset);
|
|
|
}
|
|
|
|
|
|
if (ivec_out)
|
|
|
- __builtin_memcpy(ivec_out->data(), iv, min(IV_length(), ivec_out->size()));
|
|
|
+ __builtin_memcpy(ivec_out->data(), iv.data(), min(IV_length(), ivec_out->size()));
|
|
|
}
|
|
|
|
|
|
virtual void decrypt(ReadonlyBytes in, Bytes& out, ReadonlyBytes ivec = {}) override
|
|
@@ -86,7 +86,7 @@ public:
|
|
|
auto& cipher = this->cipher();
|
|
|
|
|
|
VERIFY(!ivec.is_empty());
|
|
|
- const auto* iv = ivec.data();
|
|
|
+ ReadonlyBytes iv = ivec;
|
|
|
|
|
|
auto block_size = cipher.block_size();
|
|
|
|
|
@@ -98,8 +98,8 @@ public:
|
|
|
size_t offset { 0 };
|
|
|
|
|
|
while (length > 0) {
|
|
|
- auto* slice = in.offset(offset);
|
|
|
- m_cipher_block.overwrite(slice, block_size);
|
|
|
+ auto slice = in.slice(offset);
|
|
|
+ m_cipher_block.overwrite(slice.data(), block_size);
|
|
|
cipher.decrypt_block(m_cipher_block, m_cipher_block);
|
|
|
m_cipher_block.apply_initialization_vector(iv);
|
|
|
auto decrypted = m_cipher_block.bytes();
|