[Botan-devel] Botan C++ vs TPLockBox

atlantida sotlef at atlantida.perm.ru
Sun Sep 16 04:29:27 EDT 2007

Hi, I do remake of a program that uses TPLockBox library.
It writen in Delphi and uses following code for initialization

  gAes : TLbRijndael;
  gServerKey, gMessage, gEncryptedMessage : string;
  i : integer;
  gServerKey := '';
  for i := 4 to 131 do
    gServerKey := gServerKey + chr(i); // length(gServerKey) will be 127
  gAes := TLbRijndael.Create(nil);
  gAes.CipherMode := cmCBC;
  gAes.KeySize := ks256;
  gAes.GenerateKey(gServerKey);		//here I think gAes will use only first
32 bytes
  ...  //forming gMessage  
  gEncryptedMessage := gAes.EncryptString(gMessage);
  ... //processing gEncryptedMessage (in example,

>From this program I made a small, that assignes gMessage := 'Hello,
World'; gEncryptedMessage got value:

I try to find equivalent code for Botan:
#include <botan/botan.h>
#include <stdio.h>

using namespace Botan;

int main(int argc, char* argv[]) {
	LibraryInitializer init;
	byte key[32], *src =
(byte*)"037PNBHfqyr7FwnIvk9XQYVYuQqngW/Wr4U0qKXmfns=", dst[500];
	bzero(dst, 500);
	for (int i = 0, k = 4; i < 32; i++,k++) key[i] = k;
	BlockCipher *c = get_block_cipher("AES-256");
	c->set_key(key, 32);
	c->decrypt(src, dst);
	delete c;
	printf("%s\n", dst);
	return 0;	

After running this, I got other decrypted message (but with same lenght
as 'Hello, World' :-) ). Is there some ideas?

More information about the botan-devel mailing list