crypto logging

This commit is contained in:
friendica 2013-07-23 20:51:37 -07:00
parent 2c9e6bb10f
commit 727ab78f9a

View File

@ -211,10 +211,14 @@ function AES256CBC_decrypt($data,$key,$iv) {
}
function aes_encapsulate($data,$pubkey) {
if(! $pubkey)
logger('aes_encapsulate: no key. data: ' . $data);
$key = random_string(32,RANDOM_STRING_TEXT);
$iv = random_string(16,RANDOM_STRING_TEXT);
$result['data'] = base64url_encode(AES256CBC_encrypt($data,$key,$iv),true);
openssl_public_encrypt($key,$k,$pubkey);
if(! openssl_public_encrypt($key,$k,$pubkey)) {
logger('aes_encapsulate: RSA failed. ' . print_r(debug_backtrace(),true));
}
$result['key'] = base64url_encode($k,true);
openssl_public_encrypt($iv,$i,$pubkey);
$result['iv'] = base64url_encode($i,true);