Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 28d863f

Browse files
uefi-raw: Add RngProtocol
This is the first protocol interface added to uefi-raw, chosen because it's pretty simple. A couple naming notes: * For uefi-raw, I went with a more explicit `protocol` module name rather than `proto`. * Similarly, instead of naming the protocol `Rng` I named it `RngProtocol`. Unlike in the uefi crate, it doesn't implement a `Protocol` trait, so I think it makes sense to give it a longer name clearly indicating what it is.
1 parent 33cffb6 commit 28d863f

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

‎uefi-raw/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#[macro_use]
1818
mod enums;
1919

20+
pub mod protocol;
21+
2022
mod status;
2123

2224
pub use status::Status;

‎uefi-raw/src/protocol/mod.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Protocol definitions.
2+
//!
3+
//! Protocols are sets of related functionality identified by a unique
4+
//! ID. They can be implemented by a UEFI driver or occasionally by a
5+
//! UEFI application.
6+
7+
pub mod rng;

‎uefi-raw/src/protocol/rng.rs‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//! `Rng` protocol.
2+
3+
use crate::{guid, Guid, Status};
4+
5+
newtype_enum! {
6+
/// The algorithms listed are optional, not meant to be exhaustive
7+
/// and may be augmented by vendors or other industry standards.
8+
pub enum RngAlgorithmType: Guid => {
9+
/// Indicates a empty algorithm, used to instantiate a buffer
10+
/// for `get_info`
11+
EMPTY_ALGORITHM = guid!("00000000-0000-0000-0000-000000000000"),
12+
13+
/// The "raw" algorithm, when supported, is intended to provide
14+
/// entropy directly from the source, without it going through
15+
/// some deterministic random bit generator.
16+
ALGORITHM_RAW = guid!("e43176d7-b6e8-4827-b784-7ffdc4b68561"),
17+
18+
/// ALGORITHM_SP800_90_HASH_256
19+
ALGORITHM_SP800_90_HASH_256 = guid!("a7af67cb-603b-4d42-ba21-70bfb6293f96"),
20+
21+
/// ALGORITHM_SP800_90_HMAC_256
22+
ALGORITHM_SP800_90_HMAC_256 = guid!("c5149b43-ae85-4f53-9982-b94335d3a9e7"),
23+
24+
/// ALGORITHM_SP800_90_CTR_256
25+
ALGORITHM_SP800_90_CTR_256 = guid!("44f0de6e-4d8c-4045-a8c7-4dd168856b9e"),
26+
27+
/// ALGORITHM_X9_31_3DES
28+
ALGORITHM_X9_31_3DES = guid!("63c4785a-ca34-4012-a3c8-0b6a324f5546"),
29+
30+
/// ALGORITHM_X9_31_AES
31+
ALGORITHM_X9_31_AES = guid!("acd03321-777e-4d3d-b1c8-20cfd88820c9"),
32+
}
33+
}
34+
35+
/// Rng protocol.
36+
#[repr(C)]
37+
pub struct RngProtocol {
38+
pub get_info: unsafe extern "efiapi" fn(
39+
this: *mut RngProtocol,
40+
algorithm_list_size: *mut usize,
41+
algorithm_list: *mut RngAlgorithmType,
42+
) -> Status,
43+
44+
pub get_rng: unsafe extern "efiapi" fn(
45+
this: *mut RngProtocol,
46+
algorithm: *const RngAlgorithmType,
47+
value_length: usize,
48+
value: *mut u8,
49+
) -> Status,
50+
}
51+
52+
impl RngProtocol {
53+
pub const GUID: Guid = guid!("3152bca5-eade-433d-862e-c01cdc291f44");
54+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /