[Botan-devel] AES cipher refuses to work

Jack Lloyd lloyd at randombit.net
Tue Jan 11 10:08:41 EST 2005


18 bytes == 144 bits. For a 128-bit key, you want to use 16 bytes.

-Jack

On Tue, Jan 11, 2005 at 01:15:50PM +0100, Marcus Proest wrote:
> 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
> 
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel



More information about the botan-devel mailing list