Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented crypto example #315

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions procfs/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
```
28 changes: 28 additions & 0 deletions procfs/examples/crypto.rs
Original file line number Diff line number Diff line change
@@ -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!();
}
}
}
Loading