forked from GNUsocial/gnu-social
cleaning up key generation
This commit is contained in:
parent
4e44cf906b
commit
135c0c8a7f
@ -40,8 +40,8 @@ class Magicsig extends Memcached_DataObject
|
|||||||
public $keypair;
|
public $keypair;
|
||||||
public $alg;
|
public $alg;
|
||||||
|
|
||||||
private $publicKey;
|
public $publicKey;
|
||||||
private $privateKey;
|
public $privateKey;
|
||||||
|
|
||||||
public function __construct($alg = 'RSA-SHA256')
|
public function __construct($alg = 'RSA-SHA256')
|
||||||
{
|
{
|
||||||
@ -100,18 +100,19 @@ class Magicsig extends Memcached_DataObject
|
|||||||
return parent::insert();
|
return parent::insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generate($user_id, $key_length = 512)
|
public function generate($user_id)
|
||||||
{
|
{
|
||||||
$rsa = new Crypt_RSA();
|
$rsa = new Crypt_RSA();
|
||||||
|
|
||||||
extract($rsa->createKey());
|
$keypair = $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 = new Crypt_RSA();
|
||||||
$this->publicKey->loadKey($publickey);
|
$this->publicKey->loadKey($keypair['publickey']);
|
||||||
|
|
||||||
$this->user_id = $user_id;
|
$this->user_id = $user_id;
|
||||||
$this->insert();
|
$this->insert();
|
||||||
@ -186,7 +187,7 @@ class Magicsig extends Memcached_DataObject
|
|||||||
switch ($this->alg) {
|
switch ($this->alg) {
|
||||||
|
|
||||||
case 'RSA-SHA256':
|
case 'RSA-SHA256':
|
||||||
return 'magicsig_sha256';
|
return 'sha256';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user