-
-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rand_os crate has no purpose now #854
Comments
But why? I agree, What's your goal? Some people are complaining about the semver breakage caused by our usage of the 0.3.1 → 0.4 shim (#852), but you're complaining about the lack of a shim. I don't think we can win here, but the fewer new versions of |
For example I plan to use |
Yes, I'd want a shim so the merlin crate would work with rand_core 0.5, but not sure if that's even possible. I've crates now stuck at rand 0.6.? for the foreseeable future. I actually think I still think Also It'd appear less silly if I think a lone |
How are |
Probably I wasn't explicit enough: I plan to use types generic over |
You cannot make that work because Above, I'm saying you're plans audit poorly even if you pass It still appears |
Both So your complaint is that now auditors must examine both the |
Just to clarify: I do not claim
Any generic code must choose if it constructs an If you employ If you employ
Yes and no, Yet, audits agree on what parts are covered and not covered beforehand, which saves considerable time and money. It's perfectly reasonable that stream cipher implementation should not be covered by an audit, so auditors would not necessarily do this test. And I think anything else in
There is a case along the lines @newpavlov argued to move |
But of course. This is the case anyway unless you propose that Actually, just about the whole purpose of
This is a good point. In Rand 0.6 this wasn't a problem because it was part of an auto-implemented extension trait which could not be manually implemented. We are now allowing PRNGs to implement a non-deterministic function in any way they like. There is still the point that a PRNG could implement any logic it likes in
Of course seedable PRNGs should not do this, but for Personally I am in favour of moving |
I agree that it makes sense to move |
That we can do with minimal chance of breakage (including a new release of The follow-up question is whether we should deprecate |
Well, we can mark I guess we could deprecate Regarding moving |
Yes, de-duplication is one of my rationales. We could add a function like follows instead of fn make_rng<R: SeedableRng, S: Default+RngCore = OsRng>() {
R::from_rng(S).unwrap()
} |
In principle
Ahh, I now understand, thank you !!! :) In my mind, we were keeping It's possible I'm not doing the cryptography folk's prejudice justice: It's largely the complexity of I'm therefore partly wrong about I still think
Yet, I'm no longer confident this warrants the breakage. :) |
As an aside, there are also almost perfectly deterministic computing environments, like the "execute block functions" in most blockchains, which afaik ban randomness, floating point arithmetic, etc. I suppose getrandom might exist but panic in such environments? |
Right now
We don't have
Right now |
Oh? Are all the concerns about features being additive addressed? |
AFAIK, yes. |
@burdges @newpavlov |
I'd love some clarification on two points: Should getrandom/
We need the error type from getrandom but if getrandom cannot work then rand_core could break the build with an informative error message whenever someone sets some special feature like rand_os_required or whatever? Should crates support both I tried doing this by copying the features from https://docs.rs/crate/rand/0.6.5/source/Cargo.toml in |
Not on all, but on some yes (e.g. SGX). If I think you ask a wrong question. If application or library requires system entropy it has to use
I wouldn't say they "should", but they certainly can by being generic over |
I read https://github.com/rust-random/rand/blob/master/rand_os/Cargo.toml#L25 as activating std for rand_core whenever rand_os gets used, maybe causing w3f/schnorrkel#31 (comment) And rand_os never says
Cute trick
Yes, crates should be "generic" over Any "user facing" crates should provide safe defaults without the users specifying anything. I'm asking if such crates should operate with |
Oh, good catch! This is indeed an oversight.
You can write code like this: // `thread_rng` here is a crate feature
#[cfg(not(thread_rng))]
type DefaultRng = OsRng;
#[cfg(thread_rng)]
type DefaultRng = ThreadRng;
struct Foo<R: CoreRng + CryptoRng=DefaultRng> { .. } Unfortunately defaults for type parameters don't work with functions, see rust-lang/rust#36887. BTW cases like this were one of the reasons why I advocated that we need a stand-alone crate for |
Yes Are there build.rs tricks with which |
AFAIK no. It's essentially boils down to a problem of detecting if current build uses |
Cool. We've two approaches for inclusion code from lib.rs then, either
or else
which you invoke via |
I don't think this is the place to discuss your library's API. I personally have no idea what your requirements are, and it sounds like you also have little idea (e.g. whether it should compile with neither I think the only action item from this issue is the question of moving |
Yes, sorry for the derail. :) |
We can close this issue in favor of further discussion on #863 since the issues got kinda confused here mostly due to my miss understandings. I've made comments elsewhere that reopenned and/or summarized any remaining discussion from here. |
If I understand, rand_core now depends upon getrandom for
SeedableRng::from_entropy
, which makes the rand_os crate pointless.Ideally, I'd think
OsRng
should be merged into rand_core, rand_os should be deprecated, and theSeedableRng::from_entropy
method removed.Alternatively, you might remove both
SeedableRng::from_entropy
method and the rand_core dependency on getrandom, making rand_os the only crate that ever depends upon getrandom, so getrandom could be folded into rand_os, but nobody cares.In all cases, there should be no crates anywhere besides the one containing
OsRng
that depend upon getrandom, but some crate called getrandom or rand_os separates out the OS specific code.In all cases,
RandCore
v0.4 and v0.6? agree, so you can yank this wholeRandCore
v0.5 breakage mess.The text was updated successfully, but these errors were encountered: