robrichards/xmlseclibs

Help, AES256CBC is adding 16bytes at the start of decrypted text

Closed this issue · 1 comments

Hi,
first of all, thank you for this excellent library I use it in different projects.
I am now stuck trying to encrypt with AES256CBC: when my counterpart decrypts data I send they can decrypt data, but there appear 16 bytes at the start of the decritpted string, so their XML reader blows.

The code I am using is just this:

$fileEncryptor = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);        
$session_key = $fileEncryptor->generateSessionKey();
$encryptedData = $fileEncryptor->encryptData($data);

Then I send them the session key and the IV (encrypted with their PK). It works fine, but of those 16 bytes...

Thanks in advance!

Antoni Marin

Oh sorry, noob mistake, my counterpart was not aware that IV was prepended to the encrypted data.