- 
                Notifications
    
You must be signed in to change notification settings  - Fork 237
 
Add no_op backend #666
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
Add no_op backend #666
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The given impl isn't a no-op, and pretending that we randomized dest is not okay for any other dependency needing a securely-generated random key. It is a security hazard.
(This comment is also not an approval of the idea of adding a no-op backend.)
| pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> { | ||
| for byte in dest { | ||
| byte.write(0); | ||
| } | ||
| Ok(()) | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fail, reliably.
          
 Do you have a suggestion for a better name? 
 There are cases where it's completely fine. It doesn't seem like it's pretending when it's in the description?  | 
    
| 
           Maybe a better solution would be to have an implementation that does a runtime panic or error? Again, in my case this code is never hit/run. I just need it to compile for wasm32-unknown-unkown without creating a bunch of bloat or changing the wasm module's interface.  | 
    
| 
           I opened #667 as an alternative.  | 
    
          
 It's not about what this backend claims to do; it's about what getrandom claims to do: 
 Who knows if someone might accidentally build deployment code using this backend? Your alternative looks more acceptable.  | 
    
There are times when I go to use a crate in Wasm and some dependency of a dependency uses this crate for randomness, but I'm not using the functionality that needs the randomness. Providing a custom backend doesn't work because then it creates a wasm export and I want my wasm interface clean. For scenarios like this, it's useful to be able to just have this crate not provide any randomness at all.