Skip to content

Commit 6ff397d

Browse files
committed
RSA: Replace user_error's with exceptions
1 parent b085725 commit 6ff397d

File tree

2 files changed

+172
-99
lines changed

2 files changed

+172
-99
lines changed

phpseclib/Crypt/Base.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ class UndefinedMethodException extends Exception {}
132132
*/
133133
class InvalidLengthException extends Exception {}
134134

135+
/**
136+
* InvalidPaddingException
137+
*
138+
* @author Jim Wigginton <[email protected]>
139+
* @version 0.3.5
140+
* @access public
141+
* @package Crypt_Base
142+
*/
143+
class InvalidPaddingException extends Exception {}
144+
135145
/**
136146
* Base Class for all Crypt_* cipher classes
137147
*
@@ -141,7 +151,7 @@ class InvalidLengthException extends Exception {}
141151
* @access public
142152
* @package Crypt_Base
143153
*/
144-
class Crypt_Base {
154+
abstract class Crypt_Base {
145155
/**
146156
* The Encryption Mode
147157
*
@@ -1364,7 +1374,7 @@ function _unpad($text)
13641374
$length = ord($text[strlen($text) - 1]);
13651375

13661376
if (!$length || $length > $this->block_size) {
1367-
return false;
1377+
throw new InvalidPaddingException("An illegal padding character ($length) has been detected");
13681378
}
13691379

13701380
return substr($text, 0, -$length);

0 commit comments

Comments
 (0)