throw new ServerException(sprintf('No public key found for profile (id==%d)', $profile->id));
}
- assert($magicsig->publicKey instanceof Crypt_RSA);
+ assert($magicsig->publicKey instanceof \phpseclib\Crypt\RSA);
return $magicsig;
}
* you'll only get the public key ;)
*
* The string will (hopefully) be formatted as described in Magicsig specification:
- * https://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-01.html#anchor13
+ * https://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-01.html
*
* @return string formatted as Magicsig keypair
*/
}
if ($keypair === false) {
- // For debugging clarity. Keypair did not pass count()-check above.
+ // For debugging clarity. Keypair did not pass count()-check above.
// TRANS: Exception when public key was not properly formatted.
throw new Exception(_m('Incorrectly formatted public key element.'));
}
$magicsig = Magicsig::generate($this->actor->getUser());
}
assert($magicsig instanceof Magicsig);
- assert($magicsig->privateKey instanceof Crypt_RSA);
+ assert($magicsig->privateKey instanceof \phpseclib\Crypt\RSA);
// Prepare text and metadata for signing
$this->data = Magicsig::base64_url_encode($text);
{
$dom = new DOMDocument();
if (!$dom->loadXML(Magicsig::base64_url_decode($this->data))) {
- throw new ServerException('Malformed XML in Salmon payload');
+ throw new ClientException('Malformed XML in Salmon payload');
}
switch ($this->data_type) {
$prov->appendChild($alg);
$sig = $dom->createElementNS(self::NS, 'me:sig', $this->getSignature());
$prov->appendChild($sig);
-
+
$dom->documentElement->appendChild($prov);
break;
default:
- throw new ServerException('Unknown Salmon payload data type');
+ throw new ClientException('Unknown Salmon payload data type');
}
return $dom;
}
public function verify(Profile $profile)
{
if ($this->alg != 'RSA-SHA256') {
- common_log(LOG_DEBUG, "Salmon error: bad algorithm");
+ common_log(LOG_DEBUG, 'Salmon error: bad algorithm: '._ve($this->alg));
return false;
}
if ($this->encoding != self::ENCODING) {
- common_log(LOG_DEBUG, "Salmon error: bad encoding");
+ common_log(LOG_DEBUG, 'Salmon error: bad encoding: '._ve($this->encoding));
return false;
}
try {
$magicsig = $this->getKeyPair($profile, true); // Do discovery too if necessary
} catch (Exception $e) {
- common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
+ common_log(LOG_DEBUG, "Salmon error: getKeyPair for profile id=={$profile->getID()}: "._ve($e->getMessage()));
return false;
}
if (!$magicsig->verify($this->signingText(), $this->getSignature())) {
+ common_log(LOG_INFO, 'Salmon signature verification failed for profile id=='.$profile->getID());
// TRANS: Client error when incoming salmon slap signature does not verify cryptographically.
throw new ClientException(_m('Salmon signature verification failed.'));
}
+ common_debug('Salmon signature verification successful for profile id=='.$profile->getID());
$this->setActor($profile);
return true;
}