mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
set password in load methods for each pubkey instead of in loader
This commit is contained in:
parent
5573187f3d
commit
eb659a5544
@ -171,7 +171,10 @@ abstract class AsymmetricKey
|
||||
|
||||
$components['format'] = $format;
|
||||
|
||||
return static::onLoad($components);
|
||||
$new = static::onLoad($components);
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +202,10 @@ abstract class AsymmetricKey
|
||||
|
||||
$components['format'] = $format;
|
||||
|
||||
return static::onLoad($components);
|
||||
$new = static::onLoad($components);
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,26 +39,16 @@ abstract class PublicKeyLoader
|
||||
public static function load($key, $password = false)
|
||||
{
|
||||
try {
|
||||
$new = EC::load($key, $password);
|
||||
} catch (\Exception $e) {}
|
||||
return EC::load($key, $password);
|
||||
} catch (NoKeyLoadedException $e) {}
|
||||
|
||||
if (!isset($new)) {
|
||||
try {
|
||||
$new = RSA::load($key, $password);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
try {
|
||||
return RSA::load($key, $password);
|
||||
} catch (NoKeyLoadedException $e) {}
|
||||
|
||||
if (!isset($new)) {
|
||||
try {
|
||||
$new = DSA::load($key, $password);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
if (isset($new)) {
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
}
|
||||
try {
|
||||
return DSA::load($key, $password);
|
||||
} catch (NoKeyLoadedException $e) {}
|
||||
|
||||
try {
|
||||
$x509 = new X509();
|
||||
|
Loading…
Reference in New Issue
Block a user