How do I use Botan::MemoryRegion?

185 Views Asked by At

Does anyone know how to create an object of type Botan::MemoryRegion for use in this method?

BigInt BOTAN_DLL fe1_encrypt(const BigInt& n, const BigInt& X,
                         const SymmetricKey& key,
                         const MemoryRegion<byte>& tweak);
1

There are 1 best solutions below

0
On BEST ANSWER

Both MemoryVector and SecureVector inherit from MemoryRegion and can be used quite similar to std::vector.

BYTE tweakData[tweakDataLen] = { ... };
MemoryVector<byte> myTweak(tweakData, tweakDataLen);

SecureVector takes some precautions to prevent the data from spreading around (e.g. overwrite-before-delete and supresses some swap-to-disk scenarios)