dhardy / rand

http://doc.rust-lang.org/rand
Other
2 stars 2 forks source link

Add HC-128 RNG #74

Closed pitdicker closed 6 years ago

pitdicker commented 6 years ago

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.

pitdicker commented 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.

dhardy commented 6 years ago

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.)

pitdicker commented 6 years ago

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.

dhardy commented 6 years ago

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).

pitdicker commented 6 years ago

Great! That should make it much simpler (for me).

dhardy commented 6 years ago

Might as well merge this I guess.

pitdicker commented 6 years ago

I should have said I converted initto 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.

dhardy commented 6 years ago

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.