summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/magicenvelope.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus/lib/magicenvelope.php')
-rw-r--r--plugins/OStatus/lib/magicenvelope.php23
1 files changed, 11 insertions, 12 deletions
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index 967e5f6d1..bbd4ce17a 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -32,7 +32,7 @@ class MagicEnvelope
const ENCODING = 'base64url';
const NS = 'http://salmon-protocol.org/ns/magic-env';
-
+
private function normalizeUser($user_id)
{
if (substr($user_id, 0, 5) == 'http:' ||
@@ -70,13 +70,13 @@ class MagicEnvelope
$keypair = $parts[1];
}
}
-
+
if ($keypair) {
return $keypair;
}
}
}
- throw new Exception('Unable to locate signer public key');
+ throw new Exception('Unable to locate signer public key.');
}
@@ -92,8 +92,7 @@ class MagicEnvelope
'sig' => $signature_alg->sign($armored_text),
'alg' => $signature_alg->getName()
);
-
-
+
}
public function toXML($env) {
@@ -105,13 +104,13 @@ class MagicEnvelope
$xs->element('me:alg', null, $env['alg']);
$xs->element('me:sig', null, $env['sig']);
$xs->elementEnd('me:env');
-
+
$string = $xs->getString();
common_debug($string);
return $string;
}
-
+
public function unfold($env)
{
$dom = new DOMDocument();
@@ -137,7 +136,7 @@ class MagicEnvelope
return $dom->saveXML();
}
-
+
public function getAuthor($text) {
$doc = new DOMDocument();
if (!$doc->loadXML($text)) {
@@ -154,12 +153,12 @@ class MagicEnvelope
}
}
}
-
+
public function checkAuthor($text, $signer_uri)
{
return ($this->getAuthor($text) == $signer_uri);
}
-
+
public function verify($env)
{
if ($env['alg'] != 'RSA-SHA256') {
@@ -181,14 +180,14 @@ class MagicEnvelope
common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
return false;
}
-
+
$verifier = Magicsig::fromString($keypair);
if (!$verifier) {
common_log(LOG_DEBUG, "Salmon error: unable to parse keypair");
return false;
}
-
+
return $verifier->verify($env['data'], $env['sig']);
}