[Botan-devel] Using ECB mode gets bad initialization vector size

William K. Foster wkf at alum.mit.edu
Sun Jul 11 14:59:55 EDT 2010


I have an app up using Botan successfully for cipher specs like AES-128/CTR,
however, if I try AES-128/ECB, I get an exception thrown that says:

    Botan: IV length 16 is invalid for AES-128/ECB.

Here is code snippet in question:

    std::string spec("AES-128/ECB");
    std::string algorithm(specAlgorithm(spec));
    const unsigned int keyLength(Botan::max_keylength_of(algorithm));
    const unsigned int blockSize(Botan::block_size_of(algorithm)); // Value
is 16
    Botan::AutoSeeded_RNG rng;
    Botan::SymmetricKey masterKey(rng, keyLength);
    Botan::InitializationVector iv(rng, blockSize);
    Botan::Pipe pipe(Botan::get_cipher(spec, masterKey, iv,

Apparently, the code is expecting a blockSize of zero, but if I hard wire it
to zero, it appears my data gets corrupted.

Please suggest what I might be doing wrong here.


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

More information about the botan-devel mailing list