thanks so much for reading.
I did so much research on this topic but did not get any further.
I have to decode data in PHP. This is the specification of the encryption (and there is no more specification to get from the encryptor):
keylength = 256
algorithm = AES/CBC/PKCS5Padding
keyspec = PBKDF2withHmacSHA1
iterations = 5000
What I also got, is a key, 49 characters long for decryption.
Each encrypted message is provided in an Array and it's base64 encoded
Example data:
$data = [
"iv" => "DoJQNS0WZRtWB...",
"salt" => "zkcHInm4ewweKG81...",
"encrypted_data" => "30MTuQEW4sVc3...",
];
I tried this:
$password = "supersecretkey";
$salt = base64_decode($data['salt']);
$iterations = 5000;
$key_length = 32;
$is_raw_output = true;
$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);
$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);
$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);
var_dump($output);
var_dump(openssl_error_string());
what I get here is
bool(false)
string(94) "error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length"
I'm not sure if this is the correct approach. I tried also decoding directly without using the hash_pbkdf2 function but all I receive then is garbage.
So if I just use this
$key = "supersecretkey";
$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);
$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING| OPENSSL_RAW_DATA, $iv);
then I just get garbage data like
*+�l��_�y9�{(kNF7��gص��[Se!Y
I would appreciate any help on this topic as I already spent a lot of hours and read tons of documentation.
Unfortunately I do not get any more support from the entity that sends the encrypted data.
Thanks in advance!