]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make Magicsig capable of loading public PKCS1 keys
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 4 Oct 2015 15:22:19 +0000 (17:22 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 4 Oct 2015 15:22:19 +0000 (17:22 +0200)
plugins/OStatus/classes/Magicsig.php

index 890f525862ead99c7aa997a7f9b3fcbc70d1b27e..f5a5733dcb2f8288f08709770676c242c9c4f5a4 100644 (file)
@@ -243,8 +243,8 @@ class Magicsig extends Managed_DataObject
      * Fill out $this->privateKey or $this->publicKey with a Crypt_RSA object
      * representing the give key (as mod/exponent pair).
      *
-     * @param string $mod base64-encoded
-     * @param string $exp base64-encoded exponent
+     * @param string $mod base64url-encoded
+     * @param string $exp base64url-encoded exponent
      * @param string $type one of 'public' or 'private'
      */
     public function loadKey($mod, $exp, $type = 'public')
@@ -263,6 +263,15 @@ class Magicsig extends Managed_DataObject
         }
     }
 
+    public function loadPublicKeyPKCS1($key)
+    {
+        $rsa = new Crypt_RSA();
+        if (!$rsa->setPublicKey($key, CRYPT_RSA_PUBLIC_FORMAT_PKCS1)) {
+            throw new ServerException('Could not load PKCS1 public key. We probably got this from a remote Diaspora node as the profile public key.');
+        }
+        $this->publicKey = $rsa;
+    }
+
     /**
      * Returns the name of the crypto algorithm used for this key.
      *