From f23a877cd8ad8d583b74c312c7e9baa842b5a86a Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 15:38:48 -0500 Subject: Discovery::lookup now throws an exception --- plugins/OStatus/classes/Ostatus_profile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/OStatus/classes') diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 35539bff7..7b1aec76b 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -1288,9 +1288,9 @@ class Ostatus_profile extends Memcached_DataObject $disco = new Discovery(); - $result = $disco->lookup($addr); - - if (!$result) { + try { + $result = $disco->lookup($addr); + } catch (Exception $e) { self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), null); return null; } -- cgit v1.2.3-54-g00ecf From 0ecf435dc5df3d6424fc7bd0438d2856aa07c1da Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 16:50:00 -0500 Subject: adding sequenceKeys() to magicsig --- plugins/OStatus/classes/Magicsig.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/OStatus/classes') diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 751527c81..dee193cd5 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -84,6 +84,10 @@ class Magicsig extends Memcached_DataObject return array('user_id' => 'K'); } + function sequenceKeys() { + return array(false, false, false); + } + function insert() { $this->keypair = $this->toString(); -- cgit v1.2.3-54-g00ecf From 6ee7660a585faf290dc1650a714d280b40ac3a2d Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 16:51:50 -0500 Subject: should be sequenceKey (singular) --- plugins/OStatus/classes/HubSub.php | 2 +- plugins/OStatus/classes/Magicsig.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/OStatus/classes') diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php index 1ac181fee..e599d83a9 100644 --- a/plugins/OStatus/classes/HubSub.php +++ b/plugins/OStatus/classes/HubSub.php @@ -99,7 +99,7 @@ class HubSub extends Memcached_DataObject return array_keys($this->keyTypes()); } - function sequenceKeys() + function sequenceKey() { return array(false, false, false); } diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index dee193cd5..d47dcf143 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -84,7 +84,7 @@ class Magicsig extends Memcached_DataObject return array('user_id' => 'K'); } - function sequenceKeys() { + function sequenceKey() { return array(false, false, false); } -- cgit v1.2.3-54-g00ecf From ee7603b09f162188caaf1d319a70e7fd5d6aa385 Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 17:52:12 -0500 Subject: better return check in Magicsig::staticGet() --- plugins/OStatus/classes/Magicsig.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins/OStatus/classes') diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index d47dcf143..30da63c36 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -50,7 +50,11 @@ class Magicsig extends Memcached_DataObject public /*static*/ function staticGet($k, $v=null) { $obj = parent::staticGet(__CLASS__, $k, $v); - return Magicsig::fromString($obj->keypair); + if (!empty($obj)) { + return Magicsig::fromString($obj->keypair); + } + + return $obj; } -- cgit v1.2.3-54-g00ecf From 831eb0d2b6e35073992106a792f2878bb98e6aa4 Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 18:22:08 -0500 Subject: renaming sha256 to prevent conflict --- plugins/OStatus/classes/Magicsig.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/OStatus/classes') diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 30da63c36..96900d876 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -181,14 +181,15 @@ class Magicsig extends Memcached_DataObject switch ($this->alg) { case 'RSA-SHA256': - return 'sha256'; + return 'magicsig_sha256'; } } public function sign($bytes) { - $sig = $this->_rsa->createSign($bytes, null, 'sha256'); + $hash = $this->getHash(); + $sig = $this->_rsa->createSign($bytes, null, $hash); if ($this->_rsa->isError()) { $error = $this->_rsa->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -200,7 +201,8 @@ class Magicsig extends Memcached_DataObject public function verify($signed_bytes, $signature) { - $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'sha256'); + $hash = $this->getHash(); + $result = $this->_rsa->validateSign($signed_bytes, $signature, null, $hash); if ($this->_rsa->isError()) { $error = $this->keypair->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -213,7 +215,7 @@ class Magicsig extends Memcached_DataObject // Define a sha256 function for hashing // (Crypt_RSA should really be updated to use hash() ) -function sha256($bytes) +function magicsig_sha256($bytes) { return hash('sha256', $bytes); } -- cgit v1.2.3-54-g00ecf