Protocol: now set data['alg'] on all encapsulated encrypted packets, so that we can more easily retire 'aes256cbc' once it is no longer viable.

This commit is contained in:
friendica
2013-11-20 15:20:12 -08:00
parent f6c41e61ac
commit d7ee552c57
12 changed files with 62 additions and 42 deletions

View File

@@ -57,9 +57,9 @@ function editpost_content(&$a) {
if($itm[0]['item_flags'] & ITEM_OBSCURED) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = aes_unencapsulate(json_decode_plus($itm[0]['title']),$key);
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
if($itm[0]['body'])
$itm[0]['body'] = aes_unencapsulate(json_decode_plus($itm[0]['body']),$key);
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']),$key);
}
$tpl = get_markup_template("jot.tpl");

View File

@@ -79,7 +79,7 @@ function message_post(&$a) {
$global_perms = get_perms();
if($j['permissions']['data']) {
$permissions = aes_unencapsulate($j['permissions'],$channel['channel_prvkey']);
$permissions = crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']);
if($permissions)
$permissions = json_decode($permissions);
logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);

View File

@@ -172,7 +172,7 @@ function post_post(&$a) {
*/
if(array_key_exists('iv',$data)) {
$data = aes_unencapsulate($data,get_config('system','prvkey'));
$data = crypto_unencapsulate($data,get_config('system','prvkey'));
logger('mod_zot: decrypt1: ' . $data, LOGGER_DATA);
// susceptible to Bleichenbacher's attack
@@ -312,7 +312,7 @@ function post_post(&$a) {
);
}
}
$encrypted = aes_encapsulate(json_encode($ret),$sitekey);
$encrypted = crypto_encapsulate(json_encode($ret),$sitekey);
json_return_and_die($encrypted);
/** pickup: end */

View File

@@ -26,7 +26,7 @@ function probe_content(&$a) {
$j = json_decode($res['body'],true);
}
if($j && $j['permissions'] && $j['permissions']['iv'])
$j['permissions'] = json_decode(aes_unencapsulate($j['permissions'],$channel['channel_prvkey']),true);
$j['permissions'] = json_decode(crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']),true);
$o .= str_replace("\n",'<br />',print_r($j,true));
$o .= '</pre>';
}

View File

@@ -7,6 +7,14 @@ function register_init(&$a) {
$result = null;
$cmd = ((argc() > 1) ? argv(1) : '');
// Provide a stored request for somebody desiring a connection
// when they first need to register someplace. Once they've
// created a channel, we'll try to revive the connection request
// and process it.
if($_REQUEST['connect'])
$_SESSION['connect'] = $_REQUEST['connect'];
switch($cmd) {
case 'invite_check.json':
$result = check_account_invite($_REQUEST['invite_code']);