[Botan-devel] Question about InitializationVector

Kevin Tambascio kevin.tambascio at gmail.com
Fri May 5 17:45:11 EDT 2006


I am trying to use AES/CBC to encrypt some data.  The code worked fine
when I used the same IV for both encrypt/decrypt.  When tried to
decrypt the data with another instance of the application, using a new
IV, the first 16 bytes failed to decrypt, which is expected.  I needed
to figure out a way to derive the IV from the password so that it is

So I looked more through the tutorial and found something close to what I need.

SymmetricKey symmetricKey(pKey->GetKeyBuffer(), pKey->GetKeySize());
KDF* kdf = get_kdf("KDF2(SHA-1)");
InitializationVector iv = kdf->derive_key(16, pKey->GetKeyBuffer(),
pKey->GetKeySize(), "cipher iv");

This seems to work fine.  One issue, is that my interface accepts a
password that is treated as a raw byte stream (could be random data
from a PRNG), and may or not be a string.  So I am not using the S2K
object to derive the key, and hash it 4096 times, as one of the
example shows.  My main concern is that if this is secure enough. 
pKey is a pointer to my own class, that holds the raw byte stream that
makes up the passphrase (which may or may not be a string).

Any thoughts/examples would be appreciated.  I'm trying to use both
AES-128 and AES-256, and Blowfish/Twofish.


More information about the botan-devel mailing list