Skip to content

Commit f2a51ef

Browse files
authored
Merge pull request #315 from Hwatwasthat/master
Implemented crypto example
2 parents 784dd2c + 53dc3a7 commit f2a51ef

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

procfs/examples/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,23 @@ Lots of references to this locations: addr=0x81ba3000, pfn=531363, refs=128
181181
Found RAM here: 0x100000000-0x11fffffff
182182
Lots of references to this locations: addr=0x1b575000, pfn=111989, refs=134
183183
```
184+
185+
186+
## Crypto
187+
188+
List available crypto algorithms, along with details. Passing an algorithm as an argument will show only that algorithms
189+
190+
implementations (this can potentially be multiple). Partial arguments (i.e "sha") will return all algorithms that match.
191+
192+
```text
193+
Type: sha256
194+
Name: sha256
195+
Driver: sha256-avx2
196+
Module: sha256_ssse3
197+
Priority: 170
198+
Ref Count: 2
199+
Self Test: Passed
200+
Internal: false
201+
fips enabled: false
202+
Type Details: Shash(Shash { block_size: 64, digest_size: 32 })
203+
```

procfs/examples/crypto.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use std::env::args;
2+
3+
use procfs::crypto;
4+
5+
pub fn main() {
6+
let crypto = crypto().expect("Was not able to access current crypto");
7+
let name_arg = args().nth(1);
8+
for (name, entries) in crypto.crypto_blocks {
9+
if let Some(ref name_find) = name_arg {
10+
if !name.contains(name_find) {
11+
continue;
12+
}
13+
}
14+
println!("Type: {name}");
15+
for block in entries {
16+
println!("{:>14}: {}", "Name", block.name);
17+
println!("{:>14}: {}", "Driver", block.driver);
18+
println!("{:>14}: {}", "Module", block.module);
19+
println!("{:>14}: {}", "Priority", block.priority);
20+
println!("{:>14}: {}", "Ref Count", block.ref_count);
21+
println!("{:>14}: {:?}", "Self Test", block.self_test);
22+
println!("{:>14}: {}", "Internal", block.internal);
23+
println!("{:>14}: {}", "fips enabled", block.fips_enabled);
24+
println!("{:>14}: {:?}", "Type Details", block.crypto_type);
25+
println!();
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)