[Botan-devel] Botan IV key incompatibility?
Jack Lloyd
lloyd at randombit.net
Sun Jul 1 15:31:42 EDT 2007
On Sun, Jul 01, 2007 at 03:16:40PM -0400, John Proffer wrote:
> Hi,
>
> While trying to do database validation, and have encountered a problem -
> seems that Botan's AES implementation is incompatible with that used by
> PHP? PHP needs an IV the same size as the blocksize (32 bytes)..
> whereas Botan's IV only works on 16 bytes when using AES-256.
AES's blocksize is always 16 bytes (128 bits). Are you sure that PHP
is not requiring 32 bytes in hex (16 bytes of binary)?
> In the following code, Botan segfaults my application at cipher->set_iv(iv);
>
> Botan::byte mykey[33] = {"Uf0zFs97zUNzPzHa9z_zz!z:L=ozxz!z"};
> Botan::byte mypass[33] = {"UfzzFs97zUzzP2Ha98_az!z:L=ozxz!j"};
> Botan::SymmetricKey key(mypass,32);
> Botan::InitializationVector iv(mykey,32);
> Keyed_Filter* cipher = get_cipher("AES-256/CFB/NoPadding", ENCRYPTION);
> cipher->set_key(key);
> cipher->set_iv(iv);
>
> Shouldn't the IV be expecting 32 bytes when declaring AES-256 as the
> cipher? Am I calling this in the wrong order or something?
>
It should not segfault. It does throw an exception:
$ ./a.out
terminate called after throwing an instance of 'Botan::Invalid_IV_Length'
what(): Botan: IV length 32 is invalid for AES-256/CFB
Aborted
Jack
More information about the botan-devel
mailing list