diff --git a/.github/workflows/cargo_check.yml b/.github/workflows/cargo_check.yml index 6676e165..fd396149 100644 --- a/.github/workflows/cargo_check.yml +++ b/.github/workflows/cargo_check.yml @@ -66,12 +66,6 @@ jobs: command: check args: --target thumbv7em-none-eabi --release --features debug_allocations - - name: Check OpenSK ram_storage - uses: actions-rs/cargo@v1 - with: - command: check - args: --target thumbv7em-none-eabi --release --features ram_storage - - name: Check OpenSK verbose uses: actions-rs/cargo@v1 with: diff --git a/Cargo.toml b/Cargo.toml index 5b017954..ed293cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ debug_allocations = ["lang_items/debug_allocations"] debug_ctap = ["crypto/derive_debug", "libtock_drivers/debug_ctap"] panic_console = ["lang_items/panic_console"] std = ["cbor/std", "crypto/std", "crypto/derive_debug", "lang_items/std", "persistent_store/std"] -ram_storage = [] verbose = ["debug_ctap", "libtock_drivers/verbose_usb"] with_ctap1 = ["crypto/with_ctap1"] with_ctap2_1 = [] diff --git a/deploy.py b/deploy.py index 42f3e441..42579a2b 100755 --- a/deploy.py +++ b/deploy.py @@ -863,14 +863,6 @@ def main(args): "This is useful to allow flashing multiple OpenSK authenticators " "in a row without them being considered clones."), ) - main_parser.add_argument( - "--no-persistent-storage", - action="append_const", - const="ram_storage", - dest="features", - help=("Compiles and installs the OpenSK application without persistent " - "storage (i.e. unplugging the key will reset the key)."), - ) main_parser.add_argument( "--elf2tab-output", diff --git a/fuzz/fuzz_helper/Cargo.toml b/fuzz/fuzz_helper/Cargo.toml index 3b70f43f..2f2a5c18 100644 --- a/fuzz/fuzz_helper/Cargo.toml +++ b/fuzz/fuzz_helper/Cargo.toml @@ -10,5 +10,5 @@ arrayref = "0.3.6" libtock_drivers = { path = "../../third_party/libtock-drivers" } crypto = { path = "../../libraries/crypto", features = ['std'] } cbor = { path = "../../libraries/cbor", features = ['std'] } -ctap2 = { path = "../..", features = ['std', 'ram_storage'] } +ctap2 = { path = "../..", features = ['std'] } lang_items = { path = "../../third_party/lang-items", features = ['std'] } diff --git a/libraries/persistent_store/src/lib.rs b/libraries/persistent_store/src/lib.rs index 9b87bd41..c8be44b4 100644 --- a/libraries/persistent_store/src/lib.rs +++ b/libraries/persistent_store/src/lib.rs @@ -348,6 +348,7 @@ #[macro_use] extern crate alloc; +#[cfg(feature = "std")] mod buffer; #[cfg(feature = "std")] mod driver; @@ -357,6 +358,7 @@ mod model; mod storage; mod store; +#[cfg(feature = "std")] pub use self::buffer::{BufferCorruptFunction, BufferOptions, BufferStorage}; #[cfg(feature = "std")] pub use self::driver::{ diff --git a/run_desktop_tests.sh b/run_desktop_tests.sh index 7f3b8f31..2e80b3d2 100755 --- a/run_desktop_tests.sh +++ b/run_desktop_tests.sh @@ -48,7 +48,6 @@ cargo check --release --target=thumbv7em-none-eabi --features with_ctap2_1 cargo check --release --target=thumbv7em-none-eabi --features debug_ctap cargo check --release --target=thumbv7em-none-eabi --features panic_console cargo check --release --target=thumbv7em-none-eabi --features debug_allocations -cargo check --release --target=thumbv7em-none-eabi --features ram_storage cargo check --release --target=thumbv7em-none-eabi --features verbose cargo check --release --target=thumbv7em-none-eabi --features debug_ctap,with_ctap1 cargo check --release --target=thumbv7em-none-eabi --features debug_ctap,with_ctap1,panic_console,debug_allocations,verbose diff --git a/src/ctap/storage.rs b/src/ctap/storage.rs index 87c4c6c7..5e42ec74 100644 --- a/src/ctap/storage.rs +++ b/src/ctap/storage.rs @@ -31,9 +31,9 @@ use cbor::cbor_array_vec; use core::convert::TryInto; use crypto::rng256::Rng256; -#[cfg(any(test, feature = "ram_storage"))] +#[cfg(feature = "std")] type Storage = persistent_store::BufferStorage; -#[cfg(not(any(test, feature = "ram_storage")))] +#[cfg(not(feature = "std"))] type Storage = crate::embedded_flash::SyscallStorage; // Those constants may be modified before compilation to tune the behavior of the key. @@ -54,9 +54,6 @@ type Storage = crate::embedded_flash::SyscallStorage; // We have: I = (P * 4084 - 5107 - K * S) / 8 * C // // With P=20 and K=150, we have I=2M which is enough for 500 increments per day for 10 years. -#[cfg(feature = "ram_storage")] -const NUM_PAGES: usize = 3; -#[cfg(not(feature = "ram_storage"))] const NUM_PAGES: usize = 20; const MAX_SUPPORTED_RESIDENTIAL_KEYS: usize = 150; @@ -92,9 +89,9 @@ impl PersistentStore { /// /// This should be at most one instance of persistent store per program lifetime. pub fn new(rng: &mut impl Rng256) -> PersistentStore { - #[cfg(not(any(test, feature = "ram_storage")))] + #[cfg(not(feature = "std"))] let storage = PersistentStore::new_prod_storage(); - #[cfg(any(test, feature = "ram_storage"))] + #[cfg(feature = "std")] let storage = PersistentStore::new_test_storage(); let mut store = PersistentStore { store: persistent_store::Store::new(storage).ok().unwrap(), @@ -104,17 +101,14 @@ impl PersistentStore { } /// Creates a syscall storage in flash. - #[cfg(not(any(test, feature = "ram_storage")))] + #[cfg(not(feature = "std"))] fn new_prod_storage() -> Storage { Storage::new(NUM_PAGES).unwrap() } /// Creates a buffer storage in RAM. - #[cfg(any(test, feature = "ram_storage"))] + #[cfg(feature = "std")] fn new_test_storage() -> Storage { - #[cfg(not(test))] - const PAGE_SIZE: usize = 0x100; - #[cfg(test)] const PAGE_SIZE: usize = 0x1000; let store = vec![0xff; NUM_PAGES * PAGE_SIZE].into_boxed_slice(); let options = persistent_store::BufferOptions { diff --git a/src/embedded_flash/mod.rs b/src/embedded_flash/mod.rs index b16504bb..862b37ec 100644 --- a/src/embedded_flash/mod.rs +++ b/src/embedded_flash/mod.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(not(any(test, feature = "ram_storage")))] +#[cfg(not(feature = "std"))] mod syscall; -#[cfg(not(any(test, feature = "ram_storage")))] +#[cfg(not(feature = "std"))] pub use self::syscall::SyscallStorage;