Re: SHA2 output as subsequent SHA2 input
- From: Phil Carmody <thefatphil_demunged@xxxxxxxxxxx>
- Date: Tue, 29 Apr 2008 04:37:32 +0300
Chris McDonald <chris@xxxxxxxxxxxxxxx> writes:
(Please excuse this naive question!)
I've been asked to investigate the use of SHA2 for random number
generation. I've located some explanations of that, but my reading
has generated two additional questions, whose answers are probably well
understood by readers here.
- Let's say that I have a hash function H and a key K.
Are there any known weakness in the sequence of hash results if I
keep using the hash output as the next hash input:
R0 = H(K)
R1 = H(R0)
R2 = H(R1)
....
Ri+1 = H(Ri)
Except R_n \in Range(H^n), you mean?
H^i will have some short cycles. If you're unlucky enough to
start in a particularly short one (which is unlikely, admittedly),
you're buggered.
R_i = H(K||i), for example, does not have that same issue.
Obviously the hash's result would need to be sufficiently long.
In particular, could 256-bit SHA2 be used to provide such a sequence
of results?
_ If I wish to generate 32-bit integer pseudo random values, can I use, say,
the same 32-bits from the above sequence to provide these values:
V0 = 32bitsof(R0)
V1 = 32bitsof(R1)
....
Vi = 32bitsof(Ri)
Each subset of the bits of the hash is supposed to be equally
independent. Therefore the above will work as intended.
However, as all 256 bits are independent, you can get 8 32-bit
values from that 256 bit result.
R_{8i+j} = bits 32*j .. 32j+31 of H(K||i)
therefore does the job equally.
Phil
--
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration
.
- Follow-Ups:
- Re: SHA2 output as subsequent SHA2 input
- From: Chris McDonald
- Re: SHA2 output as subsequent SHA2 input
- References:
- SHA2 output as subsequent SHA2 input
- From: Chris McDonald
- SHA2 output as subsequent SHA2 input
- Prev by Date: Re: AES128 key predictability
- Next by Date: Re: SHA2 output as subsequent SHA2 input
- Previous by thread: Re: SHA2 output as subsequent SHA2 input
- Next by thread: Re: SHA2 output as subsequent SHA2 input
- Index(es):
Relevant Pages
|
|