rewrite the webfinger discovery logic

This commit is contained in:
redmatrix
2016-03-22 19:58:59 -07:00
parent 51a840f46a
commit 6f2ba0c619
5 changed files with 264 additions and 259 deletions

View File

@@ -308,11 +308,33 @@ function metorsa($m,$e) {
return $key;
}
function salmon_key($pubkey) {
pemtome($pubkey,$m,$e);
return 'RSA' . '.' . base64url_encode($m,true) . '.' . base64url_encode($e,true) ;
}
function convert_salmon_key($key) {
if(strstr($key,','))
$rawkey = substr($key,strpos($key,',')+1);
else
$rawkey = substr($key,5);
$key_info = explode('.',$rawkey);
$m = base64url_decode($key_info[1]);
$e = base64url_decode($key_info[2]);
logger('key details: ' . print_r($key_info,true), LOGGER_DATA);
$salmon_key = metopem($m,$e);
return $salmon_key;
}
function z_obscure($s) {
return json_encode(crypto_encapsulate($s,get_config('system','pubkey')));
}
@@ -322,3 +344,4 @@ function z_unobscure($s) {
return $s;
return crypto_unencapsulate(json_decode($s,true),get_config('system','prvkey'));
}