]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
cleaning up key generation
authorJames Walker <walkah@walkah.net>
Sat, 13 Mar 2010 02:44:18 +0000 (21:44 -0500)
committerJames Walker <walkah@walkah.net>
Sat, 13 Mar 2010 02:44:18 +0000 (21:44 -0500)
plugins/OStatus/classes/Magicsig.php

index 82b6017ded04a5e0cc7fb8f0d477a25e5a8bc842..73690965ffb2762f94905747885a394e1faefe55 100644 (file)
@@ -40,8 +40,8 @@ class Magicsig extends Memcached_DataObject
     public $keypair;
     public $alg;
     
-    private $publicKey;
-    private $privateKey;
+    public $publicKey;
+    public $privateKey;
     
     public function __construct($alg = 'RSA-SHA256')
     {
@@ -100,18 +100,19 @@ class Magicsig extends Memcached_DataObject
         return parent::insert();
     }
 
-    public function generate($user_id, $key_length = 512)
+    public function generate($user_id)
     {
         $rsa = new Crypt_RSA();
+        
+        $keypair = $rsa->createKey();
 
-        extract($rsa->createKey());
-
-        $rsa->loadKey($privatekey);
+        $rsa->loadKey($keypair['privatekey']);
 
-        $this->privateKey = $rsa;
+        $this->privateKey = new Crypt_RSA();
+        $this->privateKey->loadKey($keypair['privatekey']);
 
         $this->publicKey = new Crypt_RSA();
-        $this->publicKey->loadKey($publickey);
+        $this->publicKey->loadKey($keypair['publickey']);
         
         $this->user_id = $user_id;
         $this->insert();
@@ -186,7 +187,7 @@ class Magicsig extends Memcached_DataObject
         switch ($this->alg) {
 
         case 'RSA-SHA256':
-            return 'magicsig_sha256';
+            return 'sha256';
         }
 
     }