[Botan-devel] types

wurzin wurzin at ywave.com
Mon Mar 21 04:20:02 EST 2005


I've been trying to utilize the botan library to protect some sensitive 
user data, and for secure communications of that data for a shareware 
program that I've been writing and I've run into some difficulty with 
the different data types used by the library.  Specifically with the 
example code in section 3.1.5 of the tutorial.  Here's a listing:

S2K *s2k=get_s2k("PBKDF2(SHA-1)");
SecureVector<byte> the_salt=s2k->current_salt();

SymmetricKey master_key=s2k->derive_key(48,passphrase);

KDF *kdf=get_kdf("KDF2(SHA-1)");

SymmetricKey key=kdf->derive_key(20,master_key,"cipher key");
SymmetricKey mac_key=kdf->derive_key(20,master_key,"hmac key");
InitializationVector iv=kdf->derive_key(8,master_key,"cipher iv");

The problem arises when I try to compile the above code in that the last 
three lines which use kdf to derive the keys and the iv.  The error 
reported is that the derive_key functions don't take a SymmetricKey as 
the second argument, but rather only accept type const MemoryRegion<byte> &.

Now I can rewrite the lines as follows:

SymmetricKey key=kdf->derive_key(20,(const MemoryRegion<byte> 
&)master_key,"cipher key");

This seems to work, but I don't know how to reference the resultant key 
to print out its contents for verification that it's not just using a 
pointer value rather than a real key.  Could you give me a run down of 
the various types and there corrosponding underlying type and show me a 
way to print out there respective contents, and possibly a method to 
convert one type to another?

Thanks in advance, and thanks also for the awesome library. :)

More information about the botan-devel mailing list