@@ -62,7 +62,7 @@ public function __construct($issuer = null, $digits = 6, $period = 30, $algorith
62
62
public function createSecret ($ bits = 80 , $ requirecryptosecure = true )
63
63
{
64
64
$ secret = '' ;
65
- $ bytes = ceil ($ bits / 5 ); //We use 5 bits of each byte (since we have a 32-character 'alphabet' / BASE32)
65
+ $ bytes = ( int ) ceil ($ bits / 5 ); //We use 5 bits of each byte (since we have a 32-character 'alphabet' / BASE32)
66
66
$ rngprovider = $ this ->getRngProvider ();
67
67
if ($ requirecryptosecure && !$ rngprovider ->isCryptographicallySecure ()) {
68
68
throw new TwoFactorAuthException ('RNG provider is not cryptographically secure ' );
@@ -87,7 +87,7 @@ public function getCode($secret, $time = null)
87
87
$ value = unpack ('N ' , $ hashpart ); // Unpack binary value
88
88
$ value = $ value [1 ] & 0x7FFFFFFF ; // Drop MSB, keep only 31 bits
89
89
90
- return str_pad ($ value % pow (10 , $ this ->digits ), $ this ->digits , '0 ' , STR_PAD_LEFT );
90
+ return str_pad (( string ) ( $ value % pow (10 , $ this ->digits ) ), $ this ->digits , '0 ' , STR_PAD_LEFT );
91
91
}
92
92
93
93
/**
@@ -153,10 +153,6 @@ public function getQRCodeImageAsDataUri($label, $secret, $size = 200)
153
153
*/
154
154
public function ensureCorrectTime (array $ timeproviders = null , $ leniency = 5 )
155
155
{
156
- if ($ timeproviders !== null && !is_array ($ timeproviders )) {
157
- throw new TwoFactorAuthException ('No timeproviders specified ' );
158
- }
159
-
160
156
if ($ timeproviders === null ) {
161
157
$ timeproviders = array (
162
158
new NTPTimeProvider (),
@@ -216,15 +212,15 @@ private function base32Decode($value)
216
212
$ buffer = '' ;
217
213
foreach (str_split ($ value ) as $ char ) {
218
214
if ($ char !== '= ' ) {
219
- $ buffer .= str_pad (decbin (self ::$ _base32lookup [$ char ]), 5 , 0 , STR_PAD_LEFT );
215
+ $ buffer .= str_pad (decbin (self ::$ _base32lookup [$ char ]), 5 , ' 0 ' , STR_PAD_LEFT );
220
216
}
221
217
}
222
218
$ length = strlen ($ buffer );
223
219
$ blocks = trim (chunk_split (substr ($ buffer , 0 , $ length - ($ length % 8 )), 8 , ' ' ));
224
220
225
221
$ output = '' ;
226
222
foreach (explode (' ' , $ blocks ) as $ block ) {
227
- $ output .= chr (bindec (str_pad ($ block , 8 , 0 , STR_PAD_RIGHT )));
223
+ $ output .= chr (bindec (str_pad ($ block , 8 , ' 0 ' , STR_PAD_RIGHT )));
228
224
}
229
225
return $ output ;
230
226
}
0 commit comments