Null pad RSA ciphertext's to be the length of the modulo and improve XML parsing

This commit is contained in:
terrafrost 2012-11-19 23:00:04 -06:00
parent 7e120a0f30
commit fbf3ba353e

View File

@ -1148,7 +1148,8 @@ class Crypt_RSA {
xml_set_object($xml, $this);
xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler');
xml_set_character_data_handler($xml, '_data_handler');
if (!xml_parse($xml, $key)) {
// add <xml></xml> to account for "dangling" tags like <BitStrength>...</BitStrength> that are sometimes added
if (!xml_parse($xml, '<xml>' . $key . '</xml>')) {
return false;
}
@ -2481,7 +2482,6 @@ class Crypt_RSA {
}
// Compare
return $this->_equals($em, $em2);
}
@ -2569,6 +2569,8 @@ class Crypt_RSA {
}
$ciphertext = str_split($ciphertext, $this->k);
$ciphertext[count($ciphertext) - 1] = str_pad($ciphertext[count($ciphertext) - 1], $this->k, chr(0), STR_PAD_LEFT);
$plaintext = '';
switch ($this->encryptionMode) {
@ -2637,4 +2639,4 @@ class Crypt_RSA {
return $this->_rsassa_pss_verify($message, $signature);
}
}
}
}