uefi_raw/protocol/
rng.rs

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