First of all version of Botan I'm using is Botan-1.10.9 And I'm writing a managed wrapper in Visual C++
Following this example, I'm trying to create a SymmetricKey from the hash of a string so I can pass it into the fe1_encrypt method of the FPE module
Signature of fe1_encrypt is
BigInt FPE::fe1_encrypt(const BigInt &n, const BigInt &X, const SymmetricKey &key, const std::vector<byte> &tweak)
I want the value I pass into the key parameter to be hash of the plaintext (not possibility to decrypt) So really I don't care about it being a SymmetricKey, just need that type because the method requires it as a parameter.
But in their example they have passed the SymmetricKey their hash method that returns an std:vector
However there is no constructor for SymmetricKey that takes this type.
Anyone have any ideas?
EDIT: I tried this with no luck
std::vector<byte> re = SHA_1(plaintextAsString);
Botan::OctetString key(re, re.size());
ERROR
Error 15 error C2664: 'Botan::OctetString::OctetString(Botan::RandomNumberGenerator &,size_t)' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'Botan::RandomNumberGenerator &'
In the documentation,
SymmetricKey
(which is just a typedef forOctetString
) can take a byte array and length as constructor. Alternatively, you can encode the key as a hex string. If you already have the key asstd::vector<byte>
, then this should suffice:Later versions of Botan define another constructor
OctetString (const std::vector<byte> &in)
.