GithubHelp home page GithubHelp logo

Comments (2)

tkaitchuck avatar tkaitchuck commented on June 12, 2024

Yes. This is the major API change in the 0.8 release. Previously it attempted to look at the OS / Flags to infer when getrandom was available and use it. In 0.8 it no long does this and simply leaves it up to the feature flags. This was done because the automation logic proved inconvenient for some applications.

If neither runtime-rng or compile-time-rng is set, then there are no random constants available as base value so instead of relying on RandomState::new() which uses these random fixed constants RandomState::generate_with() is available so that the application may provide such values directly. (Note that the values passed to generate_with may be fixed constants, and it will still result in different states each time.)

In terms of security strength runtime-rng is obviously best followed by compile-time-rng. But the flag runtime-rng will implicitly disable compile-time-rng. So if you have a library that needs to work in a no-std environment that does need DOS resistance, then depending on compile-time-rng is reasonable because if an upstream application enables runtime-rng it will use the runtime, and the compiled output will be constant as normal. If anything beyond minimal DOS resistance is not required then just pass fixed keys into generate_with and you will get the same behaviour as it had in 0.7.

from ahash.

Anders429 avatar Anders429 commented on June 12, 2024

Thanks for the explanation. The main cause for my question was use in no-std environments. I initially assumed that I ought to use the runtime-rng feature, but that didn't work in my no-std environment test. I wasn't sure if compile-time-rng was what I wanted, since it wasn't enabled when I was using 0.7. Your explanation was very helpful. I was able to get things working the way I wanted with the compile-time-rng feature.

For the record, I like this change in the new version. It's good for me to actually think about what the hasher is doing when I'm using it.

from ahash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.