[Botan-devel] Dubious MinGW error messages

Jack Lloyd lloyd at randombit.net
Mon Apr 21 13:13:45 EDT 2008


On Mon, Apr 21, 2008 at 06:54:35PM +0200, Hans Mull wrote:
> Hi!
> I've just startet using botan and want to encrypt a string with a string
> password so I've modified the code from the tutorial slightly (removed
> the DataSink stuff etc.). When using Botan 1.6.4 on
> Win32/Code::Blocks/MinGW 5.1.3 the comppiler complains about many
> things. This is my code:
[...]
> Which function should I use instead the one from the tutorial? I think
> these error messages appear because the tutorial is a bit outdated.
> It would be kind if you help me!

Hi,

Yes the tutorial needs to be updated a bit for the latest
releases. Two changes to your code are needed for Botan 1.6:

When calling derive_key() you need to pass a MemoryRegion<byte> rather
than a SymmetricKey. You can perform this conversion using bits_of:

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

Also the ptr() function of SecureVector<byte> has been renamed begin():

    ctss << (const char*)the_salt.begin();
    [...]
    ctss << (const char*)hmac.begin();

Initializing the library each time you call the function may be a bit
expensive, BTW. It should work, but it will cause new allocations,
entropy polls, etc to run each time you call botanEncrypt()

Regards,
  Jack



More information about the botan-devel mailing list