2010-10-07 04:13:15 +00:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2018-07-21 12:40:21 +00:00
|
|
|
use Friendica\Database\DBA;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
function modexp_init(App $a) {
|
2010-10-07 04:13:15 +00:00
|
|
|
|
2017-03-21 16:02:59 +00:00
|
|
|
if($a->argc != 2)
|
2010-10-07 04:13:15 +00:00
|
|
|
killme();
|
|
|
|
|
|
|
|
$nick = $a->argv[1];
|
2010-10-12 11:07:03 +00:00
|
|
|
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
2018-07-21 13:10:13 +00:00
|
|
|
DBA::escape($nick)
|
2010-10-07 04:13:15 +00:00
|
|
|
);
|
|
|
|
|
2018-07-21 12:46:04 +00:00
|
|
|
if (! DBA::isResult($r)) {
|
2010-10-07 04:13:15 +00:00
|
|
|
killme();
|
2016-12-20 09:10:33 +00:00
|
|
|
}
|
2010-10-07 04:13:15 +00:00
|
|
|
|
2010-10-12 11:07:03 +00:00
|
|
|
$lines = explode("\n",$r[0]['spubkey']);
|
2010-10-07 04:13:15 +00:00
|
|
|
unset($lines[0]);
|
|
|
|
unset($lines[count($lines)]);
|
|
|
|
$x = base64_decode(implode('',$lines));
|
|
|
|
|
|
|
|
$r = ASN_BASE::parseASNString($x);
|
|
|
|
|
|
|
|
$m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
|
|
|
|
$e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
|
|
|
|
|
|
|
|
header("Content-type: application/magic-public-key");
|
2018-11-30 14:06:22 +00:00
|
|
|
echo 'RSA' . '.' . $m . '.' . $e;
|
2010-10-07 04:13:15 +00:00
|
|
|
|
|
|
|
killme();
|
2016-02-07 14:11:34 +00:00
|
|
|
|
2010-10-12 11:07:03 +00:00
|
|
|
}
|
2016-02-07 14:11:34 +00:00
|
|
|
|