use /dev/random for IV+KEY if possible
This commit is contained in:
parent
0516036e15
commit
462ac62c86
|
@ -32,9 +32,19 @@ function display_LoginPage($config_object,$profile)
|
|||
{
|
||||
global $error_message;
|
||||
// generate 256 bit key and initialization vector for user/passwd-encryption
|
||||
srand((double)microtime()*1234567);
|
||||
$key = mcrypt_create_iv(32, MCRYPT_RAND);
|
||||
$iv = mcrypt_create_iv(32, MCRYPT_RAND);
|
||||
// check if we can use /dev/random otherwise use /dev/urandom or rand()
|
||||
$key = @mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
|
||||
if (! $key) $key = @mcrypt_create_iv(32, MCRYPT_DEV_URANDOM);
|
||||
if (! $key) {
|
||||
srand((double)microtime()*1234567);
|
||||
$key = mcrypt_create_iv(32, MCRYPT_RAND);
|
||||
}
|
||||
$iv = @mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
|
||||
if (! $iv) $iv = @mcrypt_create_iv(32, MCRYPT_DEV_URANDOM);
|
||||
if (! $iv) {
|
||||
srand((double)microtime()*1234567);
|
||||
$iv = mcrypt_create_iv(32, MCRYPT_RAND);
|
||||
}
|
||||
|
||||
// save both in cookie
|
||||
setcookie("Key", base64_encode($key), 0, "/");
|
||||
|
|
Loading…
Reference in New Issue