Add a key store to avoid storing secrets in the store
This commit is contained in:
3
src/env/mod.rs
vendored
3
src/env/mod.rs
vendored
@@ -15,6 +15,7 @@
|
||||
use crate::api::connection::HidConnection;
|
||||
use crate::api::customization::Customization;
|
||||
use crate::api::firmware_protection::FirmwareProtection;
|
||||
use crate::api::key_store::KeyStore;
|
||||
use crate::api::upgrade_storage::UpgradeStorage;
|
||||
use crate::api::user_presence::UserPresence;
|
||||
use persistent_store::{Storage, Store};
|
||||
@@ -29,6 +30,7 @@ pub trait Env {
|
||||
type Rng: Rng256;
|
||||
type UserPresence: UserPresence;
|
||||
type Storage: Storage;
|
||||
type KeyStore: KeyStore;
|
||||
type UpgradeStorage: UpgradeStorage;
|
||||
type FirmwareProtection: FirmwareProtection;
|
||||
type Write: core::fmt::Write;
|
||||
@@ -38,6 +40,7 @@ pub trait Env {
|
||||
fn rng(&mut self) -> &mut Self::Rng;
|
||||
fn user_presence(&mut self) -> &mut Self::UserPresence;
|
||||
fn store(&mut self) -> &mut Store<Self::Storage>;
|
||||
fn key_store(&mut self) -> &mut Self::KeyStore;
|
||||
|
||||
/// Returns the upgrade storage instance.
|
||||
///
|
||||
|
||||
5
src/env/test/mod.rs
vendored
5
src/env/test/mod.rs
vendored
@@ -151,6 +151,7 @@ impl Env for TestEnv {
|
||||
type Rng = TestRng256;
|
||||
type UserPresence = TestUserPresence;
|
||||
type Storage = BufferStorage;
|
||||
type KeyStore = Self;
|
||||
type UpgradeStorage = BufferUpgradeStorage;
|
||||
type FirmwareProtection = Self;
|
||||
type Write = TestWrite;
|
||||
@@ -169,6 +170,10 @@ impl Env for TestEnv {
|
||||
&mut self.store
|
||||
}
|
||||
|
||||
fn key_store(&mut self) -> &mut Self {
|
||||
self
|
||||
}
|
||||
|
||||
fn upgrade_storage(&mut self) -> Option<&mut Self::UpgradeStorage> {
|
||||
self.upgrade_storage.as_mut()
|
||||
}
|
||||
|
||||
5
src/env/tock/mod.rs
vendored
5
src/env/tock/mod.rs
vendored
@@ -197,6 +197,7 @@ impl Env for TockEnv {
|
||||
type Rng = TockRng256;
|
||||
type UserPresence = Self;
|
||||
type Storage = TockStorage;
|
||||
type KeyStore = Self;
|
||||
type UpgradeStorage = TockUpgradeStorage;
|
||||
type FirmwareProtection = Self;
|
||||
type Write = Console;
|
||||
@@ -215,6 +216,10 @@ impl Env for TockEnv {
|
||||
&mut self.store
|
||||
}
|
||||
|
||||
fn key_store(&mut self) -> &mut Self {
|
||||
self
|
||||
}
|
||||
|
||||
fn upgrade_storage(&mut self) -> Option<&mut Self::UpgradeStorage> {
|
||||
self.upgrade_storage.as_mut()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user