blob: d424b4c39d75f90652fdfb3be4837306ff113066 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
include('library/asn1.php');
function modexp_init(&$a) {
if($a->argc != 2)
killme();
$nick = $a->argv[1];
$r = q("SELECT `pubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($nick)
);
if(! count($r))
killme();
$lines = explode("\n",$r[0]['pubkey']);
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();
}
|