From 9c10ada9060c9745f49652469e172be8152f6cad Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 6 Oct 2010 21:13:15 -0700 Subject: salmon-magic-public-freaking-nasty-keys --- mod/modexp.php | 33 +++++++++++++++++++++++++++++++++ mod/xrd.php | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 mod/modexp.php (limited to 'mod') diff --git a/mod/modexp.php b/mod/modexp.php new file mode 100644 index 000000000..d424b4c39 --- /dev/null +++ b/mod/modexp.php @@ -0,0 +1,33 @@ +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(); + +} \ No newline at end of file diff --git a/mod/xrd.php b/mod/xrd.php index d36b47519..06b2442b2 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -22,7 +22,8 @@ function xrd_content(&$a) { '$accturi' => $uri, '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'], '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'], - '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention' + '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', + '$modexp' => $a->get_baseurl() . '/modexp/' . $r[0]['nickname'] )); echo $o; -- cgit v1.2.3