]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
IMPORTANT - fixed Magicsig to properly overload getKV (prev. staticGet)
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Aug 2013 17:07:18 +0000 (19:07 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Aug 2013 17:07:18 +0000 (19:07 +0200)
In commit e95f77d34c501d345e731ccf6bc722034d155b77 Magicsig lost the 'staticGet' function (later renamed to getKV in 2a4dc77a633cc78907934fd93200ac16d55be78e ), which was important to properly initialize the Magicsig object (fromString)

plugins/OStatus/classes/Magicsig.php

index 4a703ae3b784f28009cbbd26e4f400cb8c04b7c1..9c7ac62d7249758893a83fe0e07e96de77f7e473 100644 (file)
@@ -81,6 +81,31 @@ class Magicsig extends Managed_DataObject
         $this->alg = $alg;
     }
 
+    /**
+     * Fetch a Magicsig object from the cache or database on a field match.
+     *
+     * @param string $k
+     * @param mixed $v
+     * @return Magicsig
+     */
+    static function getKV($k, $v=null)
+    {
+        $obj =  parent::getKV($k, $v);
+        if (!empty($obj)) {
+            $obj = Magicsig::fromString($obj->keypair);
+
+            // Double check keys: Crypt_RSA did not
+            // consistently generate good keypairs.
+            // We've also moved to 1024 bit keys.
+            if (strlen($obj->publicKey->modulus->toBits()) != 1024) {
+                $obj->delete();
+                return false;
+            }
+        }
+
+        return $obj;
+    }
+
     public static function schemaDef()
     {
         return array(