What is the best method?
Assumption: I have a function that generates a number of medium-high entropy bytes
Step1: I generate 3 of these medium-high entropy bytes.
Step2: I hash these bytes using a known crypto-strong algorithm (sha256)
Step3: I cut a substring from the result.
Step4: I use this string as my salt (3 byte salt)
So, I can do:
Step1 and 4;
1, 2, 3, and 4;
1, 3, and 4; etc.
The question is which of these operations increases entropy, and which does not?
Some code:
function delicious_delicious_salt()
{
$string = openssl_random_pseudo_bytes(3);
//Do I hash this? Do I generate a longer byte string and cut it?
return $string;
}
What I actually don't know
Does passing pseudo-random bits through a hashing algorithm and cutting a pseudo-random set of bits from the output produce high entropy bits?
I want to implement a salt-generating function for my SHA256 password hashes on my web server, and as an exercise in my own understanding I want it to be as cryptographically secure as I can reasonably make it without going crazy (and taking entropy encoded from HIDs (mouse, mic, video)).