lloyd at randombit.net
Wed Mar 23 09:52:22 EST 2005
On Mon, Mar 21, 2005 at 01:20:02AM -0800, wurzin wrote:
> 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> &.
I think I need to update the tutorial, then. :/
> Now I can rewrite the lines as follows:
> SymmetricKey key=kdf->derive_key(20,(const MemoryRegion<byte>
> &)master_key,"cipher key");
You'll want to use master_key.bits_of(); what you're doing probably works on
some compilers in the current versions, but it's fragile.
> 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?
SymmetricKey is basically a wrapper around SecureVector<byte> with some
additional helper functions. To print out the key, SymmetricKey has a function
as_string() which will return the hex value.
The conversions between these works as follows:
SecureVector<byte> bits = some_key.bits_of();
More information about the botan-devel