Skip to content

Commit

Permalink
Merge pull request google#234 from ia0/no_ram_storage
Browse files Browse the repository at this point in the history
Remove ram_storage feature
  • Loading branch information
ia0 authored Dec 10, 2020
2 parents 7a78d3e + 030bc8c commit f85454e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 31 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/cargo_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
8 changes: 0 additions & 8 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }
2 changes: 2 additions & 0 deletions libraries/persistent_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
mod buffer;
#[cfg(feature = "std")]
mod driver;
Expand All @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion run_desktop_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 6 additions & 12 deletions src/ctap/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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(),
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/embedded_flash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f85454e

Please sign in to comment.