[Botan-devel] Problem with ECB mode

Rickard Bellgrim rickard.bellgrim at iis.se
Mon May 24 11:31:24 EDT 2010


Hi

I am having some problem with the ECB mode. The problem is that I do not get the correct length of data back from Botan. I only get 16B of encrypted data compared to expected 48B. The code does work for both AES (in CBC mode (have not implemented OFB and CFB)) and DES (in CBC, OFB, and CFB mode).

Do you know what the problem could be? (Using Botan 1.9.7)

You can find an example code below. I have simplified it and it should not compile because of the extra text.

********

SymmetricKey botanKey = This hex string "00000000000000000000000000000000";
InitializationVector botanIV = This hex string "00000000000000000000000000000000";
MemoryRegion data = This hex string "4938673409687134684698438657403986439058740935874395813968496846";

// Init
Pipe cryption = new Pipe(get_cipher("AES-128/ECB/PKCS7", botanKey, botanIV, Botan::ENCRYPTION));
cryption->start_msg();

// Update
cryption->write(data);
int bytesRead1 = cryption->read(output1, "This is the maximum size we can get: data.size() + getBlockSize() - 1");

// Final
cryption->end_msg();
int bytesRead2 = cryption->read(output2, ""This is the maximum size we can get: getBlockSize()");

********

// Rickard


More information about the botan-devel mailing list