[Botan-devel] AES cipher refuses to work

Marcus Proest marcus at proest.net
Tue Jan 11 07:15:50 EST 2005


Hi there,

please consider the following code:

#include <botan/botan.h>
#include <fstream>
#include <iostream>
#define KEYL 18

int main() {
   try {
       Botan::LibraryInitializer init("thread_safe use_engines");

       Botan::byte i[KEYL];
       for(int x=0;x<KEYL;x++) i[x]=0;   //testing with a "0" key

       Botan::SymmetricKey key(i,KEYL);   //instantiate key
       Botan::Pipe pipe(Botan::get_cipher("AES/ECB", key, 
Botan::DECRYPTION)); //create pipe !exeption here!

       std::ofstream outfile("/tmp/plaintext");
       std::ifstream infile("/tmp/ciphered");

       pipe.start_msg();
       infile >> pipe;
       pipe.end_msg();
       outfile << pipe;

   } catch (std::exception &e) {
       std::cerr << "exc caught: " << e.what() << std::endl;
   }
   return 0;
}

The output of the above code ist:

   exc caught: Botan: AES cannot accept a key of length 18

A key length of 18 should be 18 byte = 256 bit, or am i missing something?
Nevertheless, even setting KEYL to 17 (=128 bit), 128, 192 or 256 is not 
resulting in success.

The Algorithms seem to be installed properly, since

   /usr/src/Botan-1.4.4> ./check --bench-block

gives me
   AES-128:                    29.90 Mbytes/sec
   AES-192:                    26.25 Mbytes/sec
   AES-256:                    23.38 Mbytes/sec
   Blowfish:                   20.10 Mbytes/sec
   ...

Can somebody tell me what i am doing wrong?

Regards,

Marc




More information about the botan-devel mailing list