49 Type type_ = Type::kSalsa20;
53 std::array<uint8_t, 64> buffer_{};
54 std::size_t buffer_pos_ = 64;
57 void ProcessBytes(uint8_t* data, std::size_t size);
65 RandomObfuscator(
const std::array<uint8_t, 32>& key,
const std::array<uint8_t, 8>& init_vec);
89 std::vector<uint8_t>
Process(
const std::vector<uint8_t>& data);
96 std::string
Process(
const std::string& data);
112 std::random_device rd;
113 std::mt19937 engine(rd());
115 std::uniform_int_distribution<int> uniform_dist(0, 255);
118 std::array<uint8_t, N> array;
119 for (std::size_t i = 0; i < N; ++i)
120 array[i] =
static_cast<uint8_t
>(uniform_dist(engine));
Block and stream cipher abstractions for KeePass encryption.
ChaCha20 stream cipher implementation (RFC 8439, 32-bit counter).
Definition cipher.hh:326
~RandomObfuscator()
Wipes the buffered keystream and destroys the underlying ciphers.
RandomObfuscator(const std::array< uint8_t, 32 > &key, const std::array< uint8_t, 8 > &init_vec)
Constructs a random stream cipher from a raw key and initialization vector.
RandomObfuscator(Type type, const std::array< uint8_t, 32 > &stream_key)
std::vector< uint8_t > Process(const std::vector< uint8_t > &data)
Obfuscates or deobfuscates a byte vector using the random stream.
Type
Definition random.hh:43
RandomObfuscator(Type type, const std::vector< uint8_t > &stream_key)
std::string Process(const std::string &data)
Obfuscates or deobfuscates a string using the random stream.
secure_string Process(const secure_string &data)
Obfuscates or deobfuscates a sensitive string using the random stream.
Salsa20 stream cipher implementation.
Definition cipher.hh:276
String that is stored in wiped and best-effort locked memory.
Definition secure.hh:262
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43
std::array< uint8_t, N > random_array()
Generates an array of N cryptographically random bytes.
Definition random.hh:111
Secure memory handling: zeroization, locked allocations and sensitive value containers.