Name: Anonymous 2013-08-05 4:41
What function is most secure per byte of output?
//Variable Entropy PoC
//Generic random seeding with current time from php.net
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
//Number of bytes of possible entropy
$min_entropy = 5;
$max_entropy = 1024;
function VerifyPassword($hash, $password)
{
global $min_entropy;
global $max_entropy;
for($iter = 0; $iter < $min_entropy; $iter++)
{
$password .= chr(0x80);
}
for($iter = $min_entropy; $iter <= $max_entropy; $iter++)
{
if(hash("md5", $password) == $hash)
{
return true;
}
$password .= chr(0x80);
}
return false;
}
function GenerateHash($password)
{
global $min_entropy;
global $max_entropy;
$entropy_count = rand($min_entropy, $max_entropy);
for($iter = 0; $iter < $entropy_count; $iter++)
{
$password .= chr(0x80);
}
//This is not hash algo specific, so md5 is the example
return hash("md5", $password);
}
$password = "password";
print hash("md5", $password)." is the md5 hash of 'password'
";
$VEHash = GenerateHash($password);
print $VEHash." is the variable entropy md5 hash of 'password' with between $min_entropy and $max_entropy 0x80 bytes appended to it.
";
if(VerifyPassword($VEHash, $password) === true)
{
print "'password' is the password
";
}
if(VerifyPassword($VEHash, "not the password") === false)
{
print "'not the password' is not the password
";
}
?>
5f4dcc3b5aa765d61d8327deb882cf99 is the md5 hash of 'password'
e756fc1bbb96a0da2e990d6e50f4f741 is the variable entropy md5 hash of 'password' with between 5 and 1024 0x80 bytes appended to it.
'password' is the password
'not the password' is not the password
5f4dcc3b5aa765d61d8327deb882cf99 is the md5 hash of 'password'
f03d3e5fea455e2440e4c4665d424666 is the variable entropy md5 hash of 'password' with between 5 and 1024 0x80 bytes appended to it.
'password' is the password
'not the password' is not the password