Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
634 B

  1. <?php
  2. include('library/asn1.php');
  3. function modexp_init(&$a) {
  4. if($a->argc != 2)
  5. killme();
  6. $nick = $a->argv[1];
  7. $r = q("SELECT `pubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
  8. dbesc($nick)
  9. );
  10. if(! count($r))
  11. killme();
  12. $lines = explode("\n",$r[0]['pubkey']);
  13. unset($lines[0]);
  14. unset($lines[count($lines)]);
  15. $x = base64_decode(implode('',$lines));
  16. $r = ASN_BASE::parseASNString($x);
  17. $m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
  18. $e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
  19. header("Content-type: application/magic-public-key");
  20. echo 'RSA' . '.' . $m . '.' . $e ;
  21. killme();
  22. }