I have to build a rest api, which can receive an ssl encrypted pcap file and the ssl key for it from an android device in a multipart/formdata post. The php should decrypt and store the file. I'm trying to use openssl for it like this:
$method = "AES-128-CBC";
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
$decrypted = openssl_decrypt(file_get_contents($encryptedFile), $method, file_get_contents($sslKeyFile), OPENSSL_RAW_DATA, $iv);
if ($decrypted === false)
{
while ($msg = openssl_error_string())
echo $msg . "<br />
";
exit;
}
Testing with the snakeoil packet from https://wiki.wireshark.org/SampleCaptures#SSL_with_decryption_keys , i'm getting errors like below:
error:0607A082:digital envelope routines:EVP_CIPHER_CTX_set_key_length:invalid key length
error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
Can somebody advice what am i doing wrong, or how to do this properly?