Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
84105c3b05 | ||
|
a70db805b7 | ||
|
750e0a8d11 | ||
|
be3bfa3806 |
@@ -31,19 +31,26 @@ class Owa extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
if($keyId) {
|
if($keyId) {
|
||||||
$r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
|
$r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
|
||||||
where hubloc_addr = '%s' limit 1",
|
where hubloc_addr = '%s' ",
|
||||||
dbesc(str_replace('acct:','',$keyId))
|
dbesc(str_replace('acct:','',$keyId))
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
$hubloc = $r[0];
|
foreach($r as $hubloc) {
|
||||||
$verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']);
|
$verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']);
|
||||||
if($verified && $verified['header_signed'] && $verified['header_valid']) {
|
if($verified && $verified['header_signed'] && $verified['header_valid']) {
|
||||||
$ret['success'] = true;
|
logger('OWA header: ' . print_r($verified,true),LOGGER_DATA);
|
||||||
$token = random_string(32);
|
logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA);
|
||||||
\Zotlabs\Zot\Verify::create('owt',0,$token,$r[0]['hubloc_addr']);
|
$ret['success'] = true;
|
||||||
$result = '';
|
$token = random_string(32);
|
||||||
openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']);
|
\Zotlabs\Zot\Verify::create('owt',0,$token,$hubloc['hubloc_addr']);
|
||||||
$ret['encrypted_token'] = base64url_encode($result);
|
$result = '';
|
||||||
|
openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']);
|
||||||
|
$ret['encrypted_token'] = base64url_encode($result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger('OWA fail: ' . $hubloc['hubloc_id'] . ' ' . $hubloc['hubloc_addr']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -117,7 +117,7 @@ class HTTPSig {
|
|||||||
|
|
||||||
logger('verified: ' . $x, LOGGER_DEBUG);
|
logger('verified: ' . $x, LOGGER_DEBUG);
|
||||||
|
|
||||||
if($x === false)
|
if(! $x)
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
if(! $spoofable)
|
if(! $spoofable)
|
||||||
|
@@ -22,13 +22,13 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
|
|||||||
$alg = OPENSSL_ALGO_SHA256;
|
$alg = OPENSSL_ALGO_SHA256;
|
||||||
$verify = @openssl_verify($data,$sig,$key,$alg);
|
$verify = @openssl_verify($data,$sig,$key,$alg);
|
||||||
|
|
||||||
if(! $verify) {
|
if($verify === (-1)) {
|
||||||
while($msg = openssl_error_string())
|
while($msg = openssl_error_string())
|
||||||
logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR);
|
logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR);
|
||||||
btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
|
btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $verify;
|
return (($verify > 0) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pkcs5_pad ($text, $blocksize)
|
function pkcs5_pad ($text, $blocksize)
|
||||||
|
Reference in New Issue
Block a user