mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-13 08:56:30 +00:00
SSH2: neither of the DSA signature values should be 0
This commit is contained in:
parent
ebb1d53af5
commit
24a06eeff3
@ -3339,6 +3339,8 @@ class Net_SSH2 {
|
|||||||
|
|
||||||
switch ($this->signature_format) {
|
switch ($this->signature_format) {
|
||||||
case 'ssh-dss':
|
case 'ssh-dss':
|
||||||
|
$zero = new Math_BigInteger();
|
||||||
|
|
||||||
$temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4));
|
$temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4));
|
||||||
$p = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256);
|
$p = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256);
|
||||||
|
|
||||||
@ -3363,9 +3365,13 @@ class Net_SSH2 {
|
|||||||
$r = new Math_BigInteger($this->_string_shift($signature, 20), 256);
|
$r = new Math_BigInteger($this->_string_shift($signature, 20), 256);
|
||||||
$s = new Math_BigInteger($this->_string_shift($signature, 20), 256);
|
$s = new Math_BigInteger($this->_string_shift($signature, 20), 256);
|
||||||
|
|
||||||
if ($r->compare($q) >= 0 || $s->compare($q) >= 0) {
|
switch (true) {
|
||||||
user_error('Invalid signature');
|
case $r->equals($zero):
|
||||||
return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
case $r->compare($q) >= 0:
|
||||||
|
case $s->equals($zero):
|
||||||
|
case $s->compare($q) >= 0:
|
||||||
|
user_error('Invalid signature');
|
||||||
|
return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$w = $s->modInverse($q);
|
$w = $s->modInverse($q);
|
||||||
|
Loading…
Reference in New Issue
Block a user