Skip to content

Commit 5537635

Browse files
authored
kem: additional re-exports from crypto-common (#2222)
- re-exports `crypto-common` itself as `common` - re-exports `KeyInit`, which is useful for seeds - re-exports `Key` as the type for representing serialized encapsulation and decapsulation keys - re-exports `InvalidKey` as the error when `TryKeyInit` fails
1 parent 0fa1faa commit 5537635

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

kem/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Traits for Key Encapsulation Mechanisms (KEMs): public-key cryptosystems designe
1717
"""
1818

1919
[dependencies]
20-
crypto-common = { version = "0.2.0-rc.12", features = ["rand_core"] }
20+
common = { package = "crypto-common", version = "0.2.0-rc.12", features = ["rand_core"] }
2121
rand_core = "0.10.0-rc-5"
2222

2323
[features]
24-
getrandom = ["crypto-common/getrandom"]
24+
getrandom = ["common/getrandom"]
2525

2626
[package.metadata.docs.rs]
2727
all-features = true

kem/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
#![forbid(unsafe_code)]
99
#![warn(missing_docs, unused_qualifications, missing_debug_implementations)]
1010

11-
pub use crypto_common::{Generate, KeyExport, KeySizeUser, TryKeyInit, typenum::consts};
11+
pub use common::{
12+
self, Generate, InvalidKey, Key, KeyExport, KeyInit, KeySizeUser, TryKeyInit, typenum::consts,
13+
};
1214

1315
use rand_core::TryCryptoRng;
1416

1517
#[cfg(feature = "getrandom")]
16-
use {crypto_common::getrandom::SysRng, rand_core::TryRngCore};
18+
use {common::getrandom, rand_core::TryRngCore};
1719

1820
/// Encapsulator for shared secrets.
1921
///
@@ -28,8 +30,9 @@ pub trait Encapsulate<EK, SS>: TryKeyInit + KeyExport {
2830
/// Encapsulate a fresh shared secret generated using the system's secure RNG.
2931
#[cfg(feature = "getrandom")]
3032
fn encapsulate(&self) -> (EK, SS) {
31-
let Ok(ret) = self.encapsulate_with_rng(&mut SysRng.unwrap_err());
32-
ret
33+
match self.encapsulate_with_rng(&mut getrandom::SysRng.unwrap_err()) {
34+
Ok(ret) => ret,
35+
}
3336
}
3437
}
3538

0 commit comments

Comments
 (0)