public function onMagicsigPublicKeyFromXRD(XML_XRD $xrd, &$pubkey) { // See if we have a Diaspora public key in the XRD response $link = $xrd->get(self::REL_PUBLIC_KEY, 'RSA'); if (!is_null($link)) { // If we do, decode it so we have the PKCS1 format (starts with -----BEGIN PUBLIC KEY-----) $pkcs1 = base64_decode($link->href); $magicsig = new Magicsig(Magicsig::DEFAULT_SIGALG); // Diaspora uses RSA-SHA256 (we do too) try { // Try to load the public key so we can get it in the standard Magic signature format $magicsig->loadPublicKeyPKCS1($pkcs1); // We found it and will now store it in $pubkey in a proper format! // This is how it would be found in a well implemented XRD according to the standard. $pubkey = 'data:application/magic-public-key,' . $magicsig->toString(); common_debug('magic-public-key found in diaspora-public-key: ' . $pubkey); return false; } catch (ServerException $e) { common_log(LOG_WARNING, $e->getMessage()); } } return true; }