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 #[derive(Debug)] 37 #[repr(C)] 38 pub struct RngProtocol { 39 pub get_info: unsafe extern "efiapi" fn( 40 this: *mut RngProtocol, 41 algorithm_list_size: *mut usize, 42 algorithm_list: *mut RngAlgorithmType, 43 ) -> Status, 44 45 pub get_rng: unsafe extern "efiapi" fn( 46 this: *mut RngProtocol, 47 algorithm: *const RngAlgorithmType, 48 value_length: usize, 49 value: *mut u8, 50 ) -> Status, 51 } 52 53 impl RngProtocol { 54 pub const GUID: Guid = guid!("3152bca5-eade-433d-862e-c01cdc291f44"); 55 } 56