[Botan-devel] Re: Stream cipher operations

Carlton Davis carlton at cs.mcgill.ca
Thu Oct 13 17:11:01 EDT 2005


I ran into another issue during some additional test
involving some stream cipher operations. Essentially,
I want to generate a symmetric key or octet string
on a network node, encrypts the symmetric key with
nodeB public key, and sends the encrypted key to nodeB.
I use the code below to test the above operation
and I got the following:
---

"terminate called after throwing an instance of
'Botan::Invalid_Key_Length'
  what():  Botan: WiderWake4+1-BE cannot accept a key of length 128
Abort trap"

--

Here is the code:

  std::string passphrase = "testing";
  //Just testing here: a quick insecure way of getting a 128-bit key
  HashFunction* hash = get_hash("MD5");
  SymmetricKey skey = hash->process(passphrase);

  unsigned short flag = 4;
  for (i = 0; i != sizeof(flag); i++)
    buf[i] = get_byte(i, flag);
  fprintf(stderr, "\nThe number is: %i\n", make_u16bit(buf[0], buf[1]));

  StreamCipher* cipher = get_stream_cipher("WiderWake4+1-BE");
  cipher->set_key(skey);  //This is fine
  cipher->encrypt(buf, 2);

  SecureVector<byte> bits = skey.bits_of();
  PK_Encryptor* enc = get_pk_encryptor(*pubkey, "Raw");
  SecureVector<byte> ciphertext = enc->encrypt(bits,sizeof(bits));

  PK_Decryptor* dec = get_pk_decryptor(*privkey, "Raw");
  SecureVector<byte> plaintext = dec->decrypt(ciphertext, sizeof(ciphertext));

  StreamCipher* cipher2 = get_stream_cipher("WiderWake4+1-BE");
  //The prblem is this set_key operation
  cipher2->set_key(SymmetricKey(plaintext));
  cipher2->decrypt(buf, 2);

  fprintf(stderr, "\nAfter decryption, the byte values are %x and %x\n",
	  buf[0], buf[1]);
  unsigned short decryptflag = make_u16bit(buf[0], buf[1]);
  fprintf(stderr, "\nThe decrypted number is: %i\n", decryptflag);
---

Any idea why WiderWake4+1 is not accepting the SymmetricKey object
I created?

Thanks and best regards,

-Carlton






More information about the botan-devel mailing list