Skip to content

Commit c9e2b03

Browse files
Merge pull request #22 from rdragos/chore/rand-0.10
Migrate HPKE RNG API to rand_core 0.10
2 parents b3a28f3 + d7fc107 commit c9e2b03

20 files changed

Lines changed: 311 additions & 458 deletions

Cargo.toml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,28 @@ categories = ["cryptography", "no-std"]
1313
[dependencies]
1414
zeroize = { version = "1.8", default-features = false, features = ["derive", "alloc"] }
1515
subtle = { version = "2.6", default-features = false }
16-
rand_core = { version = "0.9", default-features = false }
17-
rand_core_06 = { package = "rand_core", version = "0.6", default-features = false }
18-
rand_core_10 = { package = "rand_core", version = "0.10", default-features = false, optional = true }
16+
rand_core = { version = "0.10", default-features = false }
1917
hkdf = { version = "0.13", default-features = false }
2018
sha2 = { version = "0.11", default-features = false }
2119
sha3 = { version = "0.12", default-features = false }
2220
shake = { version = "0.1", default-features = false, optional = true }
2321
aead = { version = "0.5", default-features = false, features = ["alloc"] }
2422
aes-gcm = { version = "0.10", default-features = false, features = ["aes", "alloc", "zeroize"] }
2523
chacha20poly1305 = { version = "0.10", default-features = false, features = ["alloc"] }
26-
x25519-dalek = { version = "2", default-features = false, features = ["zeroize", "static_secrets"] }
24+
x25519-dalek = { version = "3", default-features = false, features = ["zeroize", "static_secrets"] }
2725
ed448-goldilocks = { version = "0.14.0-pre.12", default-features = false }
28-
p256 = { version = "0.13", default-features = false, features = ["arithmetic", "ecdh"] }
29-
p384 = { version = "0.13", default-features = false, features = ["arithmetic", "ecdh"] }
30-
p521 = { version = "0.13", default-features = false, features = ["arithmetic", "ecdh"] }
31-
k256 = { version = "0.13", default-features = false, features = ["arithmetic", "ecdh"] }
26+
p256 = { version = "0.14", default-features = false, features = ["arithmetic", "ecdh"] }
27+
p384 = { version = "0.14", default-features = false, features = ["arithmetic", "ecdh"] }
28+
p521 = { version = "0.14", default-features = false, features = ["arithmetic", "ecdh"] }
29+
k256 = { version = "0.14", default-features = false, features = ["arithmetic", "ecdh"] }
3230
ml-kem = { version = "0.3.2", default-features = false, features = ["zeroize"], optional = true }
33-
x-wing = { version = "0.1.0-rc.0", default-features = false, features = ["zeroize"], optional = true }
31+
x-wing = { version = "0.1.0", default-features = false, features = ["zeroize"], optional = true }
3432
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
3533

3634
[features]
3735
default = ["std"]
38-
std = ["rand_core/std", "subtle/std", "aes-gcm/std", "chacha20poly1305/std"]
39-
pq = ["dep:ml-kem", "dep:x-wing", "dep:rand_core_10", "dep:shake"]
36+
std = ["subtle/std", "aes-gcm/std", "chacha20poly1305/std"]
37+
pq = ["dep:ml-kem", "dep:x-wing", "dep:shake"]
4038
serde = ["dep:serde"]
4139
differential = []
4240
comparative = ["pq"]
@@ -49,11 +47,11 @@ hpke-rs-crypto = "0.6"
4947
serde = { version = "1", features = ["derive"] }
5048
serde_json = "1"
5149
trybuild = { version = "1", features = ["diff"] }
52-
rand = "0.9"
53-
rand_chacha = "0.9"
50+
rand = "0.10"
51+
rand_chacha = "0.10"
5452
criterion = { version = "0.8", features = ["html_reports"] }
5553
hex = "0.4"
56-
hpke = { package = "hpke", git = "https://github.com/rozbb/rust-hpke", rev = "2cbc9ca", features = ["x25519", "p256", "aes", "chacha", "alloc", "xwing"] }
54+
hpke = { package = "hpke", git = "https://github.com/rozbb/rust-hpke", rev = "57b14d8", features = ["x25519", "nistp", "aes", "chacha", "alloc", "mlkem"] }
5755

5856
[profile.bench]
5957
lto = "thin"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ A clean-slate Rust implementation of [HPKE (RFC 9180)](https://www.rfc-editor.or
99
1010
```rust
1111
use hpke_ng::*;
12-
use rand_core::OsRng;
12+
use rand::rngs::SysRng;
13+
use rand_core::UnwrapErr;
1314

1415
type Suite = Hpke<DhKemX25519HkdfSha256, HkdfSha256, ChaCha20Poly1305>;
1516

16-
let mut os = OsRng;
17-
let mut rng = os.unwrap_mut();
17+
let mut os = SysRng;
18+
let mut rng = UnwrapErr(&mut os);
1819
let (sk_r, pk_r) = DhKemX25519HkdfSha256::generate(&mut rng)?;
1920
let (enc, ct) = Suite::seal_base(&mut rng, &pk_r, b"info", b"aad", b"hello")?;
2021
let pt = Suite::open_base(&enc, &sk_r, b"info", b"aad", &ct)?;

0 commit comments

Comments
 (0)