Skip to content

Commit 13941dc

Browse files
authored
kem: use TryCryptoRng for encapsulate (#2049)
The method is fallible anyway, so errors should be propagated rather than panicking
1 parent 83720f2 commit 13941dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kem/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![warn(missing_docs, unused_qualifications, missing_debug_implementations)]
1111

1212
use core::fmt::Debug;
13-
use rand_core::CryptoRng;
13+
use rand_core::TryCryptoRng;
1414

1515
/// A value that can be encapsulated to. Often, this will just be a public key. However, it can
1616
/// also be a bundle of public keys, or it can include a sender's private key for authenticated
@@ -20,7 +20,7 @@ pub trait Encapsulate<EK, SS> {
2020
type Error: Debug;
2121

2222
/// Encapsulates a fresh shared secret
23-
fn encapsulate<R: CryptoRng + ?Sized>(&self, rng: &mut R) -> Result<(EK, SS), Self::Error>;
23+
fn encapsulate<R: TryCryptoRng + ?Sized>(&self, rng: &mut R) -> Result<(EK, SS), Self::Error>;
2424
}
2525

2626
/// A value that can be used to decapsulate an encapsulated key.

0 commit comments

Comments
 (0)