Skip to content

Commit

Permalink
Replaces Rng256 with new Rng API (google#612)
Browse files Browse the repository at this point in the history
* Replaces the Rng256 with RngCore from rand_core

The old trait was designed with our software crypto in mind. We should
use a more standard API going forward.

- Removes libraries/rng256/
- Ports libraries/crypto/ to rand_core
- Moves the used RNG trait to api/

* Use StdRng directy in TestEnv
  • Loading branch information
kaczmarczyck authored Apr 11, 2023
1 parent 4cc1b4f commit be42b47
Show file tree
Hide file tree
Showing 34 changed files with 219 additions and 536 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/rng256_test.yml

This file was deleted.

168 changes: 10 additions & 158 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ lang_items = { path = "third_party/lang-items" }
opensk = { path = "libraries/opensk" }
sk-cbor = { path = "libraries/cbor" }
crypto = { path = "libraries/crypto" }
rng256 = { path = "libraries/rng256" }
persistent_store = { path = "libraries/persistent_store" }
byteorder = { version = "1", default-features = false }
arrayref = "0.3.6"
rand = { version = "0.8.4", optional = true }
rand_core = "0.6.4"
ed25519-compact = { version = "1", default-features = false, optional = true }

[features]
debug_allocations = ["lang_items/debug_allocations"]
debug_ctap = ["libtock_drivers/debug_ctap", "opensk/debug_ctap"]
panic_console = ["lang_items/panic_console"]
std = ["crypto/std", "lang_items/std", "persistent_store/std", "rng256/std", "rand", "opensk/std"]
std = ["crypto/std", "lang_items/std", "persistent_store/std", "opensk/std"]
verbose = ["debug_ctap", "libtock_drivers/verbose_usb"]
with_ctap1 = ["crypto/with_ctap1", "opensk/with_ctap1"]
with_nfc = ["libtock_drivers/with_nfc"]
Expand Down
4 changes: 2 additions & 2 deletions examples/crypto_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use alloc::format;
use alloc::vec::Vec;
use core::fmt::Write;
use crypto::{aes256, cbc, ecdsa, sha256, Hash256};
use ctap2::env::tock::TockRng256;
use ctap2::env::tock::TockRng;
use libtock_drivers::console::Console;
use libtock_drivers::result::FlexUnwrap;
use libtock_drivers::timer;
Expand All @@ -36,7 +36,7 @@ fn main() {
let mut with_callback = timer::with_callback(|_, _| {});
let timer = with_callback.init().flex_unwrap();

let mut rng = TockRng256 {};
let mut rng = TockRng {};

writeln!(console, "****************************************").unwrap();
writeln!(
Expand Down
4 changes: 2 additions & 2 deletions libraries/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license = "Apache-2.0"
edition = "2018"

[dependencies]
rng256 = { path = "../rng256" }
arrayref = "0.3.6"
subtle = { version = "2.2.3", default-features = false, features = ["nightly"] }
byteorder = { version = "1", default-features = false }
Expand All @@ -20,7 +19,8 @@ untrusted = { version = "0.7.0", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde_json = { version = "=1.0.69", optional = true }
regex = { version = "1", optional = true }
rand_core = "0.6.4"

[features]
std = ["hex", "ring", "rng256/std", "untrusted", "serde", "serde_json", "regex"]
std = ["hex", "ring", "untrusted", "serde", "serde_json", "regex", "rand_core/getrandom"]
with_ctap1 = []
Loading

0 comments on commit be42b47

Please sign in to comment.