mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add storage for the swap encryption key
This is set to 0 in the image creator, but the keying ceremony should set this to something more secure after the device has been initialized (and likewise, re-encrypt the swap region to match the new, secure key).
This commit is contained in:
parent
bac8e4ff4d
commit
798566e6d2
1 changed files with 15 additions and 3 deletions
|
|
@ -14,6 +14,10 @@ pub struct Swap {
|
|||
/// Region name (as a type)
|
||||
pub name: XousArgumentCode,
|
||||
|
||||
/// Encryption key. Set to 0 by the image creator, but set to something more interesting
|
||||
/// by the device upon completion of the keying ceremony.
|
||||
pub key: [u8; 32],
|
||||
|
||||
/// Unused
|
||||
_padding: u32,
|
||||
}
|
||||
|
|
@ -21,28 +25,36 @@ pub struct Swap {
|
|||
impl fmt::Display for Swap {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, " Swap: {:08x} - {:08x}", self.offset, self.offset + self.size)?;
|
||||
writeln!(f, " key: {:x?}", self.key)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Swap {
|
||||
pub fn new(offset: XousSize, size: XousSize) -> Self {
|
||||
Swap { offset, size, name: u32::from_le_bytes(*b"Swap") as XousArgumentCode, _padding: 0 }
|
||||
Swap {
|
||||
offset,
|
||||
size,
|
||||
name: u32::from_le_bytes(*b"Swap") as XousArgumentCode,
|
||||
key: [0u8; 32],
|
||||
_padding: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl XousArgument for Swap {
|
||||
fn code(&self) -> XousArgumentCode { self.name }
|
||||
|
||||
fn length(&self) -> XousSize { 16 as XousSize }
|
||||
fn length(&self) -> XousSize { (16 + 32) as XousSize }
|
||||
|
||||
fn serialize(&self, output: &mut dyn io::Write) -> io::Result<usize> {
|
||||
let mut written = 0;
|
||||
output.write_all(&self.offset.to_le_bytes())?;
|
||||
output.write_all(&self.size.to_le_bytes())?;
|
||||
output.write_all(&self.name.to_le_bytes())?;
|
||||
output.write_all(&self.key)?;
|
||||
output.write_all(&0u32.to_le_bytes())?;
|
||||
written += 4 * 4;
|
||||
written += 4 * 4 + 32;
|
||||
Ok(written)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue