[botan-devel] Segfault on set_key due to invalid key length?

Jeffrey Walton noloader at gmail.com
Tue Aug 8 00:08:29 EDT 2017


Hi Everyone,

I'm working on Master and the example at
https://botan.randombit.net/manual/symmetric_crypto.html.

$ cat test.cxx
#include <botan/block_cipher.h>
#include <botan/hex.h>
#include <iostream>
int main ()
{
  std::vector<uint8_t> key =
Botan::hex_decode("00000000000000000000000000000000");
  std::vector<uint8_t> block =
Botan::hex_decode("6a84867cd77e12ad07ea1be895c53fa3");
  std::unique_ptr<Botan::BlockCipher>
cipher(Botan::BlockCipher::create("AES-128/ECB"));
  cipher->set_key(key);
  cipher->encrypt(block);
  std::cout << std::endl <<cipher->name() << "single block encrypt: "
<< Botan::hex_encode(block);

  return 0;
}

And:

  /opt/cfarm/gcc-latest/bin/c++ -g3 -O0 -I build/include test.cxx
./libbotan-2.a -o test.exe

Then:

(gdb) r
Starting program: /home/noloader/botan/test.exe

Program received signal SIGSEGV, Segmentation fault.
0x00000000004082d0 in Botan::SymmetricAlgorithm::valid_keylength (this=0x0,
    length=0x10) at build/include/botan/sym_algo.h:59
59               return key_spec().valid_keylength(length);


Any ideas?

Jeff


More information about the botan-devel mailing list