Skip to content

Commit

Permalink
Merge pull request #315 from Hwatwasthat/master
Browse files Browse the repository at this point in the history
Implemented crypto example
  • Loading branch information
eminence authored Aug 22, 2024
2 parents 784dd2c + 53dc3a7 commit f2a51ef
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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!();
}
}
}

0 comments on commit f2a51ef

Please sign in to comment.