diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-10-06 21:13:15 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-10-06 21:13:15 -0700 |
commit | 9c10ada9060c9745f49652469e172be8152f6cad (patch) | |
tree | 6ca000ed0e0ca398060262bc9d60654711c4f66c /mod/modexp.php | |
parent | a0ecdd025eadf22142c7ed5018b930127ea10d9f (diff) | |
download | volse-hubzilla-9c10ada9060c9745f49652469e172be8152f6cad.tar.gz volse-hubzilla-9c10ada9060c9745f49652469e172be8152f6cad.tar.bz2 volse-hubzilla-9c10ada9060c9745f49652469e172be8152f6cad.zip |
salmon-magic-public-freaking-nasty-keys
Diffstat (limited to 'mod/modexp.php')
-rw-r--r-- | mod/modexp.php | 33 |
1 files changed, 33 insertions, 0 deletions
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 @@ +<?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(); + +}
\ No newline at end of file |