2010-10-07 06:13:15 +02:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 06:07:00 +02:00
|
|
|
use Friendica\App;
|
2018-07-21 14:40:21 +02:00
|
|
|
use Friendica\Database\DBA;
|
2017-04-30 06:07:00 +02:00
|
|
|
|
2017-01-09 13:14:25 +01:00
|
|
|
function modexp_init(App $a) {
|
2010-10-07 06:13:15 +02:00
|
|
|
|
2017-03-21 17:02:59 +01:00
|
|
|
if($a->argc != 2)
|
2010-10-07 06:13:15 +02:00
|
|
|
killme();
|
|
|
|
|
|
|
|
$nick = $a->argv[1];
|
2010-10-12 13:07:03 +02:00
|
|
|
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
2010-10-07 06:13:15 +02:00
|
|
|
dbesc($nick)
|
|
|
|
);
|
|
|
|
|
2018-07-21 14:40:21 +02:00
|
|
|
if (! DBA::is_result($r)) {
|
2010-10-07 06:13:15 +02:00
|
|
|
killme();
|
2016-12-20 10:10:33 +01:00
|
|
|
}
|
2010-10-07 06:13:15 +02:00
|
|
|
|
2010-10-12 13:07:03 +02:00
|
|
|
$lines = explode("\n",$r[0]['spubkey']);
|
2010-10-07 06:13:15 +02: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");
|
|
|
|
echo 'RSA' . '.' . $m . '.' . $e ;
|
|
|
|
|
|
|
|
killme();
|
2016-02-07 15:11:34 +01:00
|
|
|
|
2010-10-12 13:07:03 +02:00
|
|
|
}
|
2016-02-07 15:11:34 +01:00
|
|
|
|