feat(keystore): sealed real/duress slots (argon2id 16MiB/3, ChaCha20-Poly1305), torn-write-safe 2-copy record, wipe state; virtio-rng driver + Entropy port; RustCrypto deps
This commit is contained in:
@@ -29,6 +29,7 @@ pub const STATUS_DRIVER: u32 = 2;
|
||||
pub const STATUS_DRIVER_OK: u32 = 4;
|
||||
|
||||
pub const DEVICE_ID_BLOCK: u32 = 2;
|
||||
pub const DEVICE_ID_RNG: u32 = 4;
|
||||
pub const DEVICE_ID_GPU: u32 = 16;
|
||||
pub const DEVICE_ID_INPUT: u32 = 18;
|
||||
|
||||
|
||||
@@ -28,8 +28,14 @@ impl VirtioQueue {
|
||||
|
||||
/// Hands the device a chain of `descs` and waits until it is used.
|
||||
pub fn submit(&self, mmio: &impl MmioAccess, descs: &[Descriptor]) -> bool {
|
||||
self.submit_written(mmio, descs).is_some()
|
||||
}
|
||||
|
||||
/// Like `submit`; how many bytes the device wrote into the chain's
|
||||
/// writable buffers (it may write fewer than they hold).
|
||||
pub fn submit_written(&self, mmio: &impl MmioAccess, descs: &[Descriptor]) -> Option<u32> {
|
||||
if descs.is_empty() || descs.len() > QUEUE_SIZE {
|
||||
return false;
|
||||
return None;
|
||||
}
|
||||
let r = &self.rings;
|
||||
for (i, d) in descs.iter().enumerate() {
|
||||
@@ -56,9 +62,11 @@ impl VirtioQueue {
|
||||
core::hint::spin_loop();
|
||||
timeout -= 1;
|
||||
if timeout == 0 {
|
||||
return false;
|
||||
return None;
|
||||
}
|
||||
}
|
||||
true
|
||||
// The used element just added: the chain's head id, then its length.
|
||||
let element = USED + 4 + (avail_idx as usize % QUEUE_SIZE) * 8;
|
||||
Some(r.read::<u32>(element + 4))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user