Updated Math_Biginteger from upstream - removing safe* workarounds

This commit is contained in:
James Walker 2010-03-24 15:18:41 -04:00
parent c4273f0ef3
commit cfca789b34
4 changed files with 8 additions and 46 deletions

View File

@ -108,16 +108,16 @@ class Magicsig extends Memcached_DataObject
public function generate($user_id) public function generate($user_id)
{ {
$rsa = new SafeCrypt_RSA(); $rsa = new Crypt_RSA();
$keypair = $rsa->createKey(); $keypair = $rsa->createKey();
$rsa->loadKey($keypair['privatekey']); $rsa->loadKey($keypair['privatekey']);
$this->privateKey = new SafeCrypt_RSA(); $this->privateKey = new Crypt_RSA();
$this->privateKey->loadKey($keypair['privatekey']); $this->privateKey->loadKey($keypair['privatekey']);
$this->publicKey = new SafeCrypt_RSA(); $this->publicKey = new Crypt_RSA();
$this->publicKey->loadKey($keypair['publickey']); $this->publicKey->loadKey($keypair['publickey']);
$this->user_id = $user_id; $this->user_id = $user_id;
@ -169,7 +169,7 @@ class Magicsig extends Memcached_DataObject
{ {
common_log(LOG_DEBUG, "Adding ".$type." key: (".$mod .', '. $exp .")"); common_log(LOG_DEBUG, "Adding ".$type." key: (".$mod .', '. $exp .")");
$rsa = new SafeCrypt_RSA(); $rsa = new Crypt_RSA();
$rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1; $rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
$rsa->setHash('sha256'); $rsa->setHash('sha256');
$rsa->modulus = new Math_BigInteger(base64_url_decode($mod), 256); $rsa->modulus = new Math_BigInteger(base64_url_decode($mod), 256);

View File

@ -67,7 +67,7 @@
* @author Jim Wigginton <terrafrost@php.net> * @author Jim Wigginton <terrafrost@php.net>
* @copyright MMVI Jim Wigginton * @copyright MMVI Jim Wigginton
* @license http://www.gnu.org/licenses/lgpl.txt * @license http://www.gnu.org/licenses/lgpl.txt
* @version $Id: BigInteger.php,v 1.31 2010/03/01 17:28:19 terrafrost Exp $ * @version $Id: BigInteger.php,v 1.33 2010/03/22 22:32:03 terrafrost Exp $
* @link http://pear.php.net/package/Math_BigInteger * @link http://pear.php.net/package/Math_BigInteger
*/ */
@ -294,7 +294,7 @@ class Math_BigInteger {
$this->value = array(); $this->value = array();
} }
if ($x === 0) { if (empty($x)) {
return; return;
} }
@ -718,7 +718,7 @@ class Math_BigInteger {
* *
* Will be called, automatically, when serialize() is called on a Math_BigInteger object. * Will be called, automatically, when serialize() is called on a Math_BigInteger object.
* *
* @see __wakeup * @see __wakeup()
* @access public * @access public
*/ */
function __sleep() function __sleep()
@ -740,7 +740,7 @@ class Math_BigInteger {
* *
* Will be called, automatically, when unserialize() is called on a Math_BigInteger object. * Will be called, automatically, when unserialize() is called on a Math_BigInteger object.
* *
* @see __sleep * @see __sleep()
* @access public * @access public
*/ */
function __wakeup() function __wakeup()

View File

@ -1,18 +0,0 @@
<?php
require_once 'Crypt/RSA.php';
/**
* Crypt_RSA stores a Math_BigInteger with value 0, which triggers a bug
* in Math_BigInteger's wakeup function which spews notices to log or output.
* This wrapper replaces it with a version that survives serialization.
*/
class SafeCrypt_RSA extends Crypt_RSA
{
function __construct()
{
parent::__construct();
$this->zero = new SafeMath_BigInteger();
}
}

View File

@ -1,20 +0,0 @@
<?php
require_once 'Math/BigInteger.php';
/**
* Crypt_RSA stores a Math_BigInteger with value 0, which triggers a bug
* in Math_BigInteger's wakeup function which spews notices to log or output.
* This wrapper replaces it with a version that survives serialization.
*/
class SafeMath_BigInteger extends Math_BigInteger
{
function __wakeup()
{
if ($this->hex == '') {
$this->hex = '0';
}
parent::__wakeup();
}
}