[botan-devel] How to create a SymmetricKey object for use in FPE_FE1 encrypt method?

S J zx78 at live.com
Tue Jun 16 22:27:48 EDT 2015


Hello,
I'm continuing my endeavour to complete my .NET managed wrapper for Botan.  The module I'm mostly interested in using is the FPE_FE1 module for format preserving encryption.  I'm following the example posted here:  http://botan.randombit.net/manual/fpe.html 
But I encountered a problem.  The sha1 method you define
std::vector<byte> sha1(const std::string& acct_name)
returns an std::vector<byte>.  Further down in the example you are creating SymmetricKey like this
SymmetricKey key(sha1(passwd));
I assume this is the key that is being passed to the fe1_encrypt method?However when I tried the same, I get compile time error.  Complains about something to do with OctetString?Perhaps the key is expecting a different type other than vector<>?
Actually for the sha1 method I did not use the built in SHA_160 from Botan. since the return line
return unlock(hash.final());
was giving me compile time error for 'unlock' in my managed wrapper.  Didn't know how to fix so I just used the built in .NET SHA1CryptoServiceProvider to perform the hash and converted the result to the same type as std::vector<byte>) 
What is the proper way to create the SymmetricKey for use in the FPE::fe1_encrypt method.   
(BTW - I do not need to reverse the encryption - merely using this to encrypt one way.  and I want to use a hash of the plaintext as the key)
Joseph

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20150616/e5501d13/attachment.html>


More information about the botan-devel mailing list