mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
add apis for application keys
This commit is contained in:
parent
87fb3d16fb
commit
df22ecd989
3 changed files with 26 additions and 0 deletions
|
|
@ -29,6 +29,8 @@ efuse = []
|
||||||
policy-menu = []
|
policy-menu = []
|
||||||
|
|
||||||
gen2 = []
|
gen2 = []
|
||||||
|
owc-inc = []
|
||||||
|
app-keys = []
|
||||||
|
|
||||||
std = ["derive-rkyv", "xous-names", "xous-ipc", "locales"]
|
std = ["derive-rkyv", "xous-names", "xous-ipc", "locales"]
|
||||||
derive-rkyv = ["rkyv"]
|
derive-rkyv = ["rkyv"]
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,13 @@ pub enum Opcode {
|
||||||
SetFlags = 513,
|
SetFlags = 513,
|
||||||
/// One way counter operations
|
/// One way counter operations
|
||||||
GetOneWayCounter = 768,
|
GetOneWayCounter = 768,
|
||||||
|
#[cfg(feature = "owc-inc")]
|
||||||
IncOneWayCounter = 769,
|
IncOneWayCounter = 769,
|
||||||
|
|
||||||
|
/// Application key operations
|
||||||
|
#[cfg(feature = "app-keys")]
|
||||||
|
AppKeyOp = 1024,
|
||||||
|
|
||||||
// ----- below are non-cryptographic opcodes but used to manipulate sensitive state -----
|
// ----- below are non-cryptographic opcodes but used to manipulate sensitive state -----
|
||||||
/// Set bootwait parameters
|
/// Set bootwait parameters
|
||||||
Bootwait = 4096,
|
Bootwait = 4096,
|
||||||
|
|
@ -49,3 +54,4 @@ pub enum EphemeralOp {
|
||||||
/// but for detecting fat-fingered API implementations.
|
/// but for detecting fat-fingered API implementations.
|
||||||
pub const OWC_MAGIC_GET: [usize; 3] = [0x2b46_2ab3, 0xf7e3_1b59, 0x7bba_d222];
|
pub const OWC_MAGIC_GET: [usize; 3] = [0x2b46_2ab3, 0xf7e3_1b59, 0x7bba_d222];
|
||||||
pub const OWC_MAGIC_INC: [usize; 3] = [0xeb5d_fc81, 0x8b6d_6a90, 0xf720_491a];
|
pub const OWC_MAGIC_INC: [usize; 3] = [0xeb5d_fc81, 0x8b6d_6a90, 0xf720_491a];
|
||||||
|
pub const APPKEY_GUARD: [u32; 4] = [0x3936_e7a6, 0xfc53_a1f7, 0xf2eb_16f3, 0xd2cc_22d9];
|
||||||
|
|
|
||||||
|
|
@ -35,3 +35,21 @@ pub enum KeywrapError {
|
||||||
/// The return tuple is: (unwrapped key, correctly wrapped key)
|
/// The return tuple is: (unwrapped key, correctly wrapped key)
|
||||||
UpgradeToNew(([u8; 32], [u8; 40])),
|
UpgradeToNew(([u8; 32], [u8; 40])),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Eq, PartialEq, Copy, Clone)]
|
||||||
|
pub enum AppKey {
|
||||||
|
// guard is a sequence of magic numbers that prevent fat-fingering this API
|
||||||
|
// it does not prevent malicious, directed attacks, but rather prevents accidents
|
||||||
|
Write { guard: [u32; 4], index: usize, data: [u8; 32] },
|
||||||
|
ReadRequest { guard: [u32; 4], index: usize },
|
||||||
|
ReadResponse { data: [u8; 32] },
|
||||||
|
Uninit,
|
||||||
|
AccessDenied,
|
||||||
|
WriteError,
|
||||||
|
Success,
|
||||||
|
InternalError,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AppKey {
|
||||||
|
fn default() -> Self { Self::Uninit }
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue