mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add test cases for trng
This commit is contained in:
parent
4f39532471
commit
0942858bbc
2 changed files with 60 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ bytemuck = "1.24.0"
|
|||
# pddb testing
|
||||
rand = { version = "0.8.5", features = ["getrandom"], optional = true }
|
||||
rand_chacha = { version = "0.3.1", optional = true }
|
||||
rand_core = "0.6.4"
|
||||
|
||||
aes = { path = "../aes", default-features = false, optional = true }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use String;
|
||||
use rand_core::RngCore;
|
||||
|
||||
use crate::{CommonEnv, ShellCmdApi};
|
||||
|
||||
|
|
@ -37,6 +38,64 @@ impl<'a> ShellCmdApi<'a> for TrngCmd {
|
|||
"u64" => {
|
||||
log::info!("A u64 trng value: {:x}", env.trng.get_u64().unwrap());
|
||||
}
|
||||
"buf" => {
|
||||
let mut test1 = [0u8; 8192];
|
||||
let mut trng = bao1x_hal_service::trng::Trng::new(&env.xns).unwrap();
|
||||
trng.fill_bytes(&mut test1);
|
||||
log::info!("8192 case");
|
||||
for chunk in test1.chunks(32) {
|
||||
for word in chunk.chunks(4) {
|
||||
if word == &[0, 0, 0, 0] {
|
||||
log::info!("zeroes found!");
|
||||
}
|
||||
}
|
||||
log::info!("{:02x?}", chunk);
|
||||
}
|
||||
log::info!("4096 case");
|
||||
let mut test2 = [0u8; 4096];
|
||||
trng.fill_bytes(&mut test2);
|
||||
for chunk in test2.chunks(32) {
|
||||
for word in chunk.chunks(4) {
|
||||
if word == &[0, 0, 0, 0] {
|
||||
log::info!("zeroes found!");
|
||||
}
|
||||
}
|
||||
log::info!("{:02x?}", chunk);
|
||||
}
|
||||
log::info!("4597 case"); // this is a prime number so it doesn't divide into anything
|
||||
let mut test3 = [0u8; 4597];
|
||||
trng.fill_bytes(&mut test3);
|
||||
for chunk in test3.chunks(32) {
|
||||
for word in chunk.chunks(4) {
|
||||
if word == &[0, 0, 0, 0] {
|
||||
log::info!("zeroes found!");
|
||||
}
|
||||
}
|
||||
log::info!("{:02x?}", chunk);
|
||||
}
|
||||
log::info!("125 case");
|
||||
let mut test4 = [0u8; 125];
|
||||
trng.fill_bytes(&mut test4);
|
||||
for chunk in test4.chunks(32) {
|
||||
for word in chunk.chunks(4) {
|
||||
if word == &[0, 0, 0, 0] {
|
||||
log::info!("zeroes found!");
|
||||
}
|
||||
}
|
||||
log::info!("{:02x?}", chunk);
|
||||
}
|
||||
log::info!("61 case");
|
||||
let mut test5 = [0u8; 61];
|
||||
trng.fill_bytes(&mut test5);
|
||||
for chunk in test4.chunks(32) {
|
||||
for word in chunk.chunks(4) {
|
||||
if word == &[0, 0, 0, 0] {
|
||||
log::info!("zeroes found!");
|
||||
}
|
||||
}
|
||||
log::info!("{:02x?}", chunk);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
write!(ret, "{}", helpstring).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue