diff --git a/kem/src/lib.rs b/kem/src/lib.rs index cd471186b..cbb57226b 100644 --- a/kem/src/lib.rs +++ b/kem/src/lib.rs @@ -14,7 +14,7 @@ pub use common::{ use common::array::{self, ArraySize}; use core::{array::TryFromSliceError, convert::Infallible}; -use rand_core::TryCryptoRng; +use rand_core::CryptoRng; #[cfg(feature = "getrandom")] use common::getrandom::{SysRng, rand_core::UnwrapErr}; @@ -50,17 +50,14 @@ pub trait KemParams { pub trait Encapsulate: KemParams + TryKeyInit + KeyExport { /// Encapsulates a fresh [`SharedSecret`] generated using the supplied random number /// generator `R`. - fn encapsulate_with_rng( - &self, - rng: &mut R, - ) -> Result<(Ciphertext, SharedSecret), R::Error>; + fn encapsulate_with_rng(&self, rng: &mut R) -> (Ciphertext, SharedSecret) + where + R: CryptoRng + ?Sized; /// Encapsulate a fresh shared secret generated using the system's secure RNG. #[cfg(feature = "getrandom")] fn encapsulate(&self) -> (Ciphertext, SharedSecret) { - match self.encapsulate_with_rng(&mut UnwrapErr(SysRng)) { - Ok(ret) => ret, - } + self.encapsulate_with_rng(&mut UnwrapErr(SysRng)) } }