From e0dec8b484ea7ec67abd5aa6f803d59fe1525976 Mon Sep 17 00:00:00 2001 From: Chris Bury Date: Mon, 5 Aug 2024 13:37:12 +0100 Subject: [PATCH 1/2] Implemented example for /dev/crypto parser --- procfs/examples/crypto.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 procfs/examples/crypto.rs 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!(); + } + } +} From 53dc3a7521bf6c07ca7c342530d419e10ba53705 Mon Sep 17 00:00:00 2001 From: Chris Bury Date: Mon, 5 Aug 2024 19:27:04 +0100 Subject: [PATCH 2/2] Updated readme to show what the crypto example produces. --- procfs/examples/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 }) +```