diff --git a/procfs/examples/README.md b/procfs/examples/README.md index 7619f3c..597f2d2 100644 --- a/procfs/examples/README.md +++ b/procfs/examples/README.md @@ -181,3 +181,23 @@ Lots of references to this locations: addr=0x81ba3000, pfn=531363, refs=128 Found RAM here: 0x100000000-0x11fffffff Lots of references to this locations: addr=0x1b575000, pfn=111989, refs=134 ``` + + +## Crypto + +List available crypto algorithms, along with details. Passing an algorithm as an argument will show only that algorithms + +implementations (this can potentially be multiple). Partial arguments (i.e "sha") will return all algorithms that match. + +```text +Type: sha256 + Name: sha256 + Driver: sha256-avx2 + Module: sha256_ssse3 + Priority: 170 + Ref Count: 2 + Self Test: Passed + Internal: false + fips enabled: false + Type Details: Shash(Shash { block_size: 64, digest_size: 32 }) +``` diff --git a/procfs/examples/crypto.rs b/procfs/examples/crypto.rs new file mode 100644 index 0000000..7920225 --- /dev/null +++ b/procfs/examples/crypto.rs @@ -0,0 +1,28 @@ +use std::env::args; + +use procfs::crypto; + +pub fn main() { + let crypto = crypto().expect("Was not able to access current crypto"); + let name_arg = args().nth(1); + for (name, entries) in crypto.crypto_blocks { + if let Some(ref name_find) = name_arg { + if !name.contains(name_find) { + continue; + } + } + println!("Type: {name}"); + for block in entries { + println!("{:>14}: {}", "Name", block.name); + println!("{:>14}: {}", "Driver", block.driver); + println!("{:>14}: {}", "Module", block.module); + println!("{:>14}: {}", "Priority", block.priority); + println!("{:>14}: {}", "Ref Count", block.ref_count); + println!("{:>14}: {:?}", "Self Test", block.self_test); + println!("{:>14}: {}", "Internal", block.internal); + println!("{:>14}: {}", "fips enabled", block.fips_enabled); + println!("{:>14}: {:?}", "Type Details", block.crypto_type); + println!(); + } + } +}