refactor
This commit is contained in:
parent
9f76f20ea8
commit
4015c1bb6e
@ -68,7 +68,9 @@ decrypt_data(const key_type &key, const unsigned char *buffer,
|
||||
template <typename buffer, typename result>
|
||||
[[nodiscard]] inline auto decrypt_data(const key_type &key, const buffer &buf,
|
||||
result &res) -> bool {
|
||||
return decrypt_data<result>(key, buf.data(), buf.size(), res);
|
||||
return decrypt_data<result>(
|
||||
key, reinterpret_cast<const unsigned char *>(buf.data()), buf.size(),
|
||||
res);
|
||||
}
|
||||
|
||||
template <typename buffer, typename result>
|
||||
@ -134,13 +136,15 @@ inline void encrypt_data(std::string_view encryption_token,
|
||||
template <typename buffer, typename result>
|
||||
inline void encrypt_data(std::string_view encryption_token, const buffer &buf,
|
||||
result &res) {
|
||||
encrypt_data<result>(generate_key(encryption_token), buf.data(), buf.size(),
|
||||
res);
|
||||
encrypt_data<result>(generate_key(encryption_token),
|
||||
reinterpret_cast<const unsigned char *>(buf.data()),
|
||||
buf.size(), res);
|
||||
}
|
||||
|
||||
template <typename buffer, typename result>
|
||||
inline void encrypt_data(const key_type &key, const buffer &buf, result &res) {
|
||||
encrypt_data<result>(key, buf.data(), buf.size(), res);
|
||||
encrypt_data<result>(key, reinterpret_cast<const unsigned char *>(buf.data()),
|
||||
buf.size(), res);
|
||||
}
|
||||
|
||||
template <typename buffer, typename result>
|
||||
@ -148,7 +152,9 @@ inline void
|
||||
encrypt_data(const std::array<unsigned char,
|
||||
crypto_aead_xchacha20poly1305_IETF_NPUBBYTES> &iv,
|
||||
const key_type &key, const buffer &buf, result &res) {
|
||||
encrypt_data<result>(iv, key, buf.data(), buf.size(), res);
|
||||
encrypt_data<result>(iv, key,
|
||||
reinterpret_cast<const unsigned char *>(buf.data()),
|
||||
buf.size(), res);
|
||||
}
|
||||
} // namespace repertory::utils::encryption
|
||||
|
||||
|
@ -189,7 +189,8 @@ TEST(encrypting_reader, file_data_as_stream) {
|
||||
for (std::uint8_t j = 0U; j < 2U; j++) {
|
||||
EXPECT_FALSE(
|
||||
io_stream
|
||||
->read(&buffer[(buffer.size() / 2U) * j],
|
||||
->read(
|
||||
reinterpret_cast<char *>(&buffer[(buffer.size() / 2U) * j]),
|
||||
static_cast<std::streamsize>(buffer.size()) / 2U)
|
||||
.fail());
|
||||
EXPECT_TRUE(io_stream->good());
|
||||
|
Loading…
x
Reference in New Issue
Block a user