1 //! Local types that are equivalent to those generated for the IRemotelyProvisionedComponent HAL 2 //! interface 3 4 use crate::{cbor_type_error, try_from_n, AsCborValue, CborError}; 5 use alloc::{ 6 format, 7 string::{String, ToString}, 8 vec::Vec, 9 }; 10 use enumn::N; 11 use kmr_derive::AsCborValue; 12 13 /// IRPC HAL Versions 14 pub const IRPC_V2: i32 = 2; 15 pub const IRPC_V3: i32 = 3; 16 /// `AuthenticatedRequest` CDDL schema version 17 pub const AUTH_REQ_SCHEMA_V1: i32 = 1; 18 /// `CertificateType` for keymint 19 pub const CERT_TYPE_KEYMINT: &str = "keymint"; 20 21 /// Indication of whether RKP is operating in test mode. (Only relevant for RKP v1 and v2.) 22 #[derive(Clone, Copy, PartialEq, Eq, Debug)] 23 pub struct TestMode(pub bool); 24 25 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] 26 #[repr(i32)] 27 pub enum ErrorCode { 28 Ok = 0, // not in HAL, assumed 29 Failed = 1, 30 InvalidMac = 2, 31 ProductionKeyInTestRequest = 3, 32 TestKeyInProductionRequest = 4, 33 InvalidEek = 5, 34 Removed = 6, 35 } 36 37 /// The default value for the minimum number of keys supported in a CSR. 38 pub const MINIMUM_SUPPORTED_KEYS_IN_CSR: i32 = 20; 39 40 #[derive(Clone, Debug, Eq, PartialEq, AsCborValue)] 41 pub struct HardwareInfo { 42 pub version_number: i32, 43 pub rpc_author_name: String, 44 pub supported_eek_curve: EekCurve, 45 pub unique_id: Option<String>, 46 pub supported_num_keys_in_csr: i32, 47 } 48 49 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, AsCborValue, N)] 50 #[repr(i32)] 51 pub enum EekCurve { 52 None = 0, 53 P256 = 1, 54 Curve25519 = 2, 55 } 56 try_from_n!(EekCurve); 57 58 #[derive(Clone, Debug, Eq, PartialEq, AsCborValue)] 59 pub struct MacedPublicKey { 60 pub maced_key: Vec<u8>, 61 } 62 63 #[derive(Clone, Debug, Eq, PartialEq, AsCborValue)] 64 pub struct ProtectedData { 65 pub protected_data: Vec<u8>, 66 } 67 68 #[derive(Clone, Debug, Eq, PartialEq, AsCborValue)] 69 pub struct DeviceInfo { 70 pub device_info: Vec<u8>, 71 } 72