Skip to content

Commit

Permalink
Make the use of the raw backend optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Mar 28, 2024
1 parent 0f33b19 commit d5aee1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ enum EnableState {
Failed(se05x::se05x::Error),
}

#[derive(Clone, Debug)]
pub enum FilesystemLayout {
V0,
V1,
}

pub struct Se050Backend<Twi, D> {
se: Se05X<Twi, D>,
enabled: EnableState,
metadata_location: Location,
hw_key: HardwareKey,
ns: Namespace,
configured: bool,
layout: FilesystemLayout,
}

impl<Twi: I2CForT1, D: DelayUs<u32>> Se050Backend<Twi, D> {
Expand All @@ -68,6 +75,7 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> Se050Backend<Twi, D> {
metadata_location: Location,
hardware_key: Option<Bytes<{ MAX_HW_KEY_LEN }>>,
ns: Namespace,
layout: FilesystemLayout,
) -> Self {
Se050Backend {
se,
Expand All @@ -79,6 +87,7 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> Se050Backend<Twi, D> {
},
ns,
configured: false,
layout,
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/trussed_auth_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,14 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> ExtensionImpl<trussed_auth::AuthExtension>
generator
}

let fs = once(|resources, _| resources.raw_filestore(backend_path));
let global_fs = once(|resources, _| resources.raw_filestore(PathBuf::from(BACKEND_DIR)));
let fs = once(|resources, _| match self.layout {
crate::FilesystemLayout::V0 => resources.filestore(backend_path),
crate::FilesystemLayout::V1 => resources.raw_filestore(backend_path),
});
let global_fs = once(|resources, _| match self.layout {
crate::FilesystemLayout::V0 => resources.filestore(PathBuf::from(BACKEND_DIR)),
crate::FilesystemLayout::V1 => resources.raw_filestore(PathBuf::from(BACKEND_DIR)),
});
let client_id = core_ctx.path.clone();
let keystore = once(|resources, core_ctx| resources.keystore(core_ctx.path.clone()));

Expand Down

0 comments on commit d5aee1b

Please sign in to comment.