Closed pitdicker closed 6 years ago
I should add that the output of this RNG matches the reference implementation. I have tested the first 65536 result with a couple of random seeds.
This PR could probably be done directly against upstream? (Possibly it would leave some smaller details to fix later, but I think this would be easier than merging here then upstream.)
Now that I see the direction you want to go with upstream, I will do that. If you have an interest at looking at it already, that would be nice because I probably will not be able to make the PR today.
I just created #209; hopefully this can land on top of that (maybe add convert_slice_32
to this module for now; I'm still not sure about the le
module).
Great! That should make it much simpler (for me).
Might as well merge this I guess.
I should have said I converted init
to use an array as you suggested, but was not ready to add the commit yet. I will make a PR together with a change to the le
functions to correct alignment.
Ah, ok. Probably the le
stuff should be moved into a different file, but whether that should be called le
, conversions
, utils
or something else I don't know. Also not sure whether it should be minimal or include a fair number of functions.
This implements the HC-128 cryptographically secure RNG. See https://github.com/dhardy/rand/issues/53.
It is similar to ISAAC, but proven to be secure and (in many cases) faster.
I have been sitting on this code for a few weeks hoping that I could reduce the amount of unsafe code and some duplication. But that didn't work out yet, so I am just making a PR as it is.