使用php

时间:2019-01-25 15:37:41

标签: php ssl pcap

我必须构建一个rest api,它可以在multipart / formdata post中从android设备接收ssl加密的pcap文件和ssl密钥。 php应该解密并存储文件。我正在尝试像这样使用openssl:

$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 />\n";
    exit;
}

使用来自https://wiki.wireshark.org/SampleCaptures#SSL_with_decryption_keys的蛇油小包进行测试,我遇到如下错误:

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   

有人可以建议我做错了什么,或者如何正确地做到这一点?

0 个答案:

没有答案