mirror of
https://github.com/danog/tgseclib.git
synced 2025-01-22 05:51:20 +01:00
- make it so the following all do the same thing:
$pubKey = new Crypt_RSA(); $pubKey->loadKey($privKey->getPublicKey()); $pubKey->setPublicKey(); $pubKey = new Crypt_RSA(); $pubKey->loadKey($privKey->getPublicKey()); $pubKey->setPublicKey($privKey->getPublicKey()); $pubKey = new Crypt_RSA(); $pubKey->setPublicKey($privKey->getPublicKey()); git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@211 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
960dd01fe1
commit
6d60fa63e5
@ -1351,12 +1351,17 @@ class Crypt_RSA {
|
||||
*
|
||||
* @see getPublicKey()
|
||||
* @access public
|
||||
* @param String $key
|
||||
* @param String $key optional
|
||||
* @param Integer $type optional
|
||||
* @return Boolean
|
||||
*/
|
||||
function setPublicKey($key, $type = false)
|
||||
function setPublicKey($key = false, $type = false)
|
||||
{
|
||||
if ($key === false && !empty($this->modulus)) {
|
||||
$this->publicExponent = $this->exponent;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($type === false) {
|
||||
$types = array(
|
||||
CRYPT_RSA_PUBLIC_FORMAT_RAW,
|
||||
@ -1370,16 +1375,20 @@ class Crypt_RSA {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$components = $this->_parseKey($key, $type);
|
||||
}
|
||||
|
||||
if (empty($this->modulus) || !$this->modulus->equals($components['modulus'])) {
|
||||
user_error('Trying to load a public key? Use loadKey() instead. It\'s called loadKey() and not loadPrivateKey() for a reason.', E_USER_NOTICE);
|
||||
if ($components === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->modulus) || !$this->modulus->equals($components['modulus'])) {
|
||||
$this->modulus = $components['modulus'];
|
||||
$this->exponent = $this->publicExponent = $components['publicExponent'];
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->publicExponent = $components['publicExponent'];
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user