Subversion-Projekte lars-tiefland.ci

Revision

Revision 2049 | Revision 2242 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2049 Revision 2107
Zeile 171... Zeile 171...
171
		{
171
		{
172
			trigger_error('hash_pbkdf2(): Length must be greater than or equal to 0: '.$length, E_USER_WARNING);
172
			trigger_error('hash_pbkdf2(): Length must be greater than or equal to 0: '.$length, E_USER_WARNING);
173
			return FALSE;
173
			return FALSE;
174
		}
174
		}
Zeile -... Zeile 175...
-
 
175
 
-
 
176
		$hash_length = defined('MB_OVERLOAD_STRING')
175
 
177
			? mb_strlen(hash($algo, NULL, TRUE), '8bit')
176
		$hash_length = strlen(hash($algo, NULL, TRUE));
178
			: strlen(hash($algo, NULL, TRUE));
Zeile 177... Zeile 179...
177
		empty($length) && $length = $hash_length;
179
		empty($length) && $length = $hash_length;
178
 
180
 
179
		// Pre-hash password inputs longer than the algorithm's block size
181
		// Pre-hash password inputs longer than the algorithm's block size
Zeile 219... Zeile 221...
219
			'tiger160,4' => 64,
221
			'tiger160,4' => 64,
220
			'tiger192,4' => 64,
222
			'tiger192,4' => 64,
221
			'whirlpool' => 64
223
			'whirlpool' => 64
222
		);
224
		);
Zeile 223... Zeile 225...
223
 
225
 
224
		if (isset($block_sizes[$algo]) && strlen($password) > $block_sizes[$algo])
226
		if (isset($block_sizes[$algo], $password[$block_sizes[$algo]]))
225
		{
227
		{
226
			$password = hash($algo, $password, TRUE);
228
			$password = hash($algo, $password, TRUE);
Zeile 227... Zeile 229...
227
		}
229
		}
228
 
230
 
229
		$hash = '';
231
		$hash = '';
230
		// Note: Blocks are NOT 0-indexed
232
		// Note: Blocks are NOT 0-indexed
231
		for ($bc = ceil($length / $hash_length), $bi = 1; $bi <= $bc; $bi++)
233
		for ($bc = (int) ceil($length / $hash_length), $bi = 1; $bi <= $bc; $bi++)
232
		{
234
		{
233
			$key = $derived_key = hash_hmac($algo, $salt.pack('N', $bi), $password, TRUE);
235
			$key = $derived_key = hash_hmac($algo, $salt.pack('N', $bi), $password, TRUE);
234
			for ($i = 1; $i < $iterations; $i++)
236
			for ($i = 1; $i < $iterations; $i++)
Zeile 238... Zeile 240...
238
 
240
 
239
			$hash .= $derived_key;
241
			$hash .= $derived_key;
Zeile 240... Zeile 242...
240
		}
242
		}
-
 
243
 
-
 
244
		// This is not RFC-compatible, but we're aiming for natural PHP compatibility
-
 
245
		if ( ! $raw_output)
-
 
246
		{
-
 
247
			$hash = bin2hex($hash);
-
 
248
		}
-
 
249
 
241
 
250
		return defined('MB_OVERLOAD_STRING')
242
		// This is not RFC-compatible, but we're aiming for natural PHP compatibility
251
			? mb_substr($hash, 0, $length, '8bit')
243
		return substr($raw_output ? $hash : bin2hex($hash), 0, $length);
252
			: substr($hash, 0, $length);