diff options
author | Evan Prodromou <evan@status.net> | 2010-02-26 18:28:33 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-02-26 18:28:33 -0500 |
commit | 2344db1ae5b061ee80b0793f70f072cbee3a18f3 (patch) | |
tree | 7908590a14e40aa1e0e843d841e32b1dfe602eae | |
parent | 21edb98a32cf67b9f754c9a74414f113cb71cb37 (diff) |
Revert "change function name"
This reverts commit 21edb98a32cf67b9f754c9a74414f113cb71cb37.
-rw-r--r-- | plugins/OStatus/classes/Magicsig.php | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 7a804a47a..30da63c36 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -33,20 +33,20 @@ class Magicsig extends Memcached_DataObject { const PUBLICKEYREL = 'magic-public-key'; - + public $__table = 'magicsig'; public $user_id; public $keypair; public $alg; - + private $_rsa; public function __construct($alg = 'RSA-SHA256') { $this->alg = $alg; } - + public /*static*/ function staticGet($k, $v=null) { $obj = parent::staticGet(__CLASS__, $k, $v); @@ -57,6 +57,7 @@ class Magicsig extends Memcached_DataObject return $obj; } + function table() { return array( @@ -76,6 +77,7 @@ class Magicsig extends Memcached_DataObject 64, false)); } + function keys() { return array_keys($this->keyTypes()); @@ -112,6 +114,7 @@ class Magicsig extends Memcached_DataObject $this->insert(); } + public function toString($full_pair = true) { $public_key = $this->_rsa->_public_key; @@ -124,15 +127,15 @@ class Magicsig extends Memcached_DataObject $private_exp = '.' . base64_url_encode($private_key->getExponent()); } - return 'RSA.' . $mod . '.' . $exp . $private_exp; + return 'RSA.' . $mod . '.' . $exp . $private_exp; } - + public static function fromString($text) { PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $magic_sig = new Magicsig(); - + // remove whitespace $text = preg_replace('/\s+/', '', $text); @@ -140,7 +143,7 @@ class Magicsig extends Memcached_DataObject if (!preg_match('/RSA\.([^\.]+)\.([^\.]+)(.([^\.]+))?/', $text, $matches)) { return false; } - + $mod = base64_url_decode($matches[1]); $exp = base64_url_decode($matches[2]); if ($matches[4]) { @@ -182,10 +185,10 @@ class Magicsig extends Memcached_DataObject } } - + public function sign($bytes) { - $sig = $this->_rsa->createSign($bytes, null, 'magicsig_sha256'); + $sig = $this->_rsa->createSign($bytes, null, 'sha256'); if ($this->_rsa->isError()) { $error = $this->_rsa->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -197,7 +200,7 @@ class Magicsig extends Memcached_DataObject public function verify($signed_bytes, $signature) { - $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'magicsig_sha256'); + $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'sha256'); if ($this->_rsa->isError()) { $error = $this->keypair->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -205,12 +208,12 @@ class Magicsig extends Memcached_DataObject } return $result; } - + } // Define a sha256 function for hashing // (Crypt_RSA should really be updated to use hash() ) -function magicsig_sha256($bytes) +function sha256($bytes) { return hash('sha256', $bytes); } |