pub struct CautiousRng;Expand description
An exceptionally cautious wrapper for SysRng
Ordinarily, one trusts SysRng.
But we want Arti to run on a wide variety of platforms,
and the chances of a bogus SysRng increases the more places we run.
This Rng combines SysRng with several other entropy sources,
in an attempt to reduce the likelihood of creating compromised keys.1
This Rng is slower than SysRng.
§Panics
This rng will panic if SysRng fails;
but that’s the only sensible behavior for a cryptographic-heavy application like ours.
Who else remembers CVE-2008-0166? ↩
Trait Implementations§
Source§impl Default for CautiousRng
impl Default for CautiousRng
Source§fn default() -> CautiousRng
fn default() -> CautiousRng
Returns the “default value” for a type. Read more
impl EntropicRng for CautiousRng
impl TryCryptoRng for CautiousRng
Source§impl TryRng for CautiousRng
impl TryRng for CautiousRng
Source§type Error = Infallible
type Error = Infallible
The type returned in the event of a RNG error. Read more
Source§fn try_next_u32(&mut self) -> Result<u32, Infallible>
fn try_next_u32(&mut self) -> Result<u32, Infallible>
Return the next random
u32.Source§fn try_next_u64(&mut self) -> Result<u64, Infallible>
fn try_next_u64(&mut self) -> Result<u64, Infallible>
Return the next random
u64.Source§fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Infallible>
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Infallible>
Fill
dst entirely with random data.Auto Trait Implementations§
impl Freeze for CautiousRng
impl RefUnwindSafe for CautiousRng
impl Send for CautiousRng
impl Sync for CautiousRng
impl Unpin for CautiousRng
impl UnsafeUnpin for CautiousRng
impl UnwindSafe for CautiousRng
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<R> CryptoRng for R
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more