From 9dd3d94b719d8d92f5313d6efe36de31b743acb6 Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 5 Dec 2022 04:04:54 -0600 Subject: [PATCH] Updates people! --- Cargo.lock | 2 +- drivers/randomness_handler/src/main.rs | 19 ++++++++++++++++++- libraries/rand/Cargo.toml | 2 +- libraries/rand/src/lib.rs | 10 +++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba65ca0..88e5e2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.1.0" +version = "0.1.1" dependencies = [ "versioning", ] diff --git a/drivers/randomness_handler/src/main.rs b/drivers/randomness_handler/src/main.rs index 964141f..bc57034 100644 --- a/drivers/randomness_handler/src/main.rs +++ b/drivers/randomness_handler/src/main.rs @@ -8,5 +8,22 @@ pub const VERSION: Version = Version::new(0, 1, 0); fn start() { let mut inner_rng = Csprng::new(); inner_rng.mix_in_data(&[8, 9, 10, 23, 2, 3]); - let _ran_u8 = inner_rng.get_random_u8(); + + // Request PCI IDS and mixin + let pci_id_data = [8, 12]; + inner_rng.mix_in_data(&pci_id_data); + + let rand_bytes = inner_rng.get_random_u128().unwrap(); + inner_rng.mix_in_data(&rand_bytes.to_le_bytes()); + + // Loop driver forever + loop { + // Request Mouse XY + let mouse_x_y = [12, 12]; + inner_rng.mix_in_data(&mouse_x_y); + + // Request the last keypress + let key_press = [7]; + inner_rng.mix_in_data(&key_press); + } } diff --git a/libraries/rand/Cargo.toml b/libraries/rand/Cargo.toml index 775a604..16251f3 100644 --- a/libraries/rand/Cargo.toml +++ b/libraries/rand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand" -version = "0.1.0" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/libraries/rand/src/lib.rs b/libraries/rand/src/lib.rs index 4d79371..e696c0f 100644 --- a/libraries/rand/src/lib.rs +++ b/libraries/rand/src/lib.rs @@ -1,7 +1,9 @@ #![no_std] +use core::fmt::Display; + use versioning::Version; -pub const VERSION: Version = Version::new(0, 1, 0); +pub const VERSION: Version = Version::new(0, 1, 1); pub struct Csprng { state: [u8; 256], @@ -137,4 +139,10 @@ impl Csprng { } } +#[derive(Debug)] pub enum RandError {} +impl Display for RandError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{}", self) + } +}