[Botan-devel] Problem with encrypting and decrypting serialized data

Michał Płoski mludy at wp.pl
Fri May 14 23:19:23 EDT 2010


Hi everyone. I faced the big problem I cant solve for few days.
I have input data unsigned char serializedUdp[] which are serialized. I 
need to encrypt this data ,pass to other function and then decrypt and 
get the same data what in input. After that data should be mapped to 
structure.
Problem is that whatever im trying to do serialized data after 
decryption are diffrent than imput.

  SecureVector<byte> Encryption::encrypt(unsigned char 
serializedUdp[],unsigned int length,SymmetricKey 
&keys,InitializationVector &vector)

  {
DataSource_Memory botan_in(serializedUdp,length);
SymmetricKey key(rng, 16);
keys = key;
InitializationVector iv(rng, 16);
vector=iv;

Pipe pipe(get_cipher("AES-128/CBC", keys,vector, ENCRYPTION))
pipe.process_msg(botan_in);
encrypted_raw=pipe.read_all(0);
return encrypted_raw;
}

void Encryption::decrypt(SecureVector<byte> encrypted_raw,int length 
,SymmetricKey &klucz,InitializationVector &wektor_inicjujacy)
{


   Pipe pipe2(get_cipher("AES-128/CBC", klucz, wektor_inicjujacy, 
DECRYPTION));
   pipe2.process_msg(encrypted_raw);
   SecureVector<byte> decrypted_raw=pipe2.read_all(0);
//And i dont know what do at this moment. Any mapping gives me bad 
value/or error

If anyone have idea how to solve this problem i would be greatfull
Best regards;



More information about the botan-devel mailing list