Skip to content

Commit 6408448

Browse files
authored
kem: re-export Generate; add getrandom feature (#2140)
Since KEMs require randomness and unconditionally enables the `rand_core` feature of `crypto-common`, this unconditionally re-exports the `Generate` trait, which can be used to generate decapsulation keys (though the bounds on `Decapsulate` remain unchanged). This also adds a passthrough feature for `getrandom` to enable `crypto-common/getrandom`. Ideally this would also add a method to `Encapsulate` which can use `getrandom::SysRng` as the RNG for encapsulating, but since there isn't yet a prerelease with that feature this doesn't attempt to add it yet.
1 parent 84b88b2 commit 6408448

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kem/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ categories = ["cryptography", "no-std"]
1313
description = "Traits for key encapsulation mechanisms"
1414

1515
[dependencies]
16-
crypto-common = { version = "0.2.0-rc.5", features = ["rand_core"], path = "../crypto-common" }
16+
crypto-common = { version = "0.2.0-rc.6", features = ["rand_core"], path = "../crypto-common" }
1717
rand_core = "0.10.0-rc-3"
18-
zeroize = { version = "1.7", default-features = false }
18+
19+
[features]
20+
getrandom = ["crypto-common/getrandom"]
1921

2022
[package.metadata.docs.rs]
2123
all-features = true
2224

25+
# TODO(tarcieri): make README.md an actually valid example
2326
[lib]
2427
doctest = false

kem/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![forbid(unsafe_code)]
99
#![warn(missing_docs, unused_qualifications, missing_debug_implementations)]
1010

11-
pub use crypto_common::{KeyInit, KeySizeUser, typenum::consts};
11+
pub use crypto_common::{Generate, KeyInit, KeySizeUser, typenum::consts};
1212

1313
use rand_core::TryCryptoRng;
1414

0 commit comments

Comments
 (0)