-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement optimization migrations #441
Conversation
3f1f3b8
to
760f2c3
Compare
803653b
to
e16757b
Compare
1bbae18
to
420e168
Compare
No significant changes. Insignifcant changes
|
3a9c3f2
to
da7d106
Compare
I made the migrations optional for for the That way we can merge this without merging the migrations until the FIDO certification is done. |
f0921a7
to
d39f02a
Compare
I will need some more time to properly review and think through the admin-app changes. IMHO we could merge a first version that updates trussed-auth, trussed-se050-backend, trussed and the affected dependencies but keeps the |
Ok, i'll see if that's possible. Since admin-app is only a dependency of trussed-auth for the tests it might be fine. |
Of course we can also keep it in one PR if that’s easier. I just wanted to mention that option because I think it should not be a big change and it would reduce the amount of unmerged changes. |
The trussed-auth PR bumps to v0.3.0 so it needs to update all the apps that depend on it anyways. So that would still be 2 huge PRs. |
06d13bb
to
e563b01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could also use the FirmwareVersion
from the migrated crates to select the executed migrations. Something along the lines of:
enum FilesystemLayout {
V0,
V1,
}
impl FilesystemLayout {
fn trussed_auth(&self) -> trussed_auth::FilesystemLayout {
match self {
Self::V0 => trussed_auth::FilesystemLayout::V0,
Self::V1 => trussed_auth::FilesystemLayout::V1,
}
}
}
// ...
Migrator {
migrate: |ifs, _efs| {
trussed_auth::migrate::migrate_remove_dat(
ifs,
&[
path!("opcard"),
path!("webcrypt"),
path!("secrets"),
path!("piv"),
],
)
},
enable: |old: FilesystemLayout, new: FilesystemLayout| {
trussed_auth::migrate::enable_migration(old.trussed_auth(), new.trussed_auth())
},
},
// ...
This would reduce the number of magic constants in the runner and would keep the details about the migration inside the migrated crates.
components/apps/src/lib.rs
Outdated
// App 2: secrets | ||
#[cfg(feature = "secrets-app")] | ||
apps.push(&mut self.oath).ok().unwrap(); | ||
if self.migrated_successfully { | ||
// App 2: secrets | ||
#[cfg(feature = "secrets-app")] | ||
apps.push(&mut self.oath).ok().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer to skip creating the relevant apps if migration failed instead of skipping them in apdu_dispatch
and ctaphid_dispatch
, similar to what we do with opcard on a config error.
components/apps/src/lib.rs
Outdated
@@ -335,8 +350,18 @@ impl<R: Runner> Apps<R> { | |||
version, | |||
data.version_string, | |||
data.status(), | |||
migrations::MIGRATORS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to migrate on a config error? I would prefer to just trigger a migration error in that case and disable the affected apps.
e563b01
to
739c5ca
Compare
739c5ca
to
7ddcfd6
Compare
pub(crate) const MIGRATION_VERSION_SPACE_EFFICIENCY: u32 = 1; | ||
|
||
#[cfg(feature = "backend-auth")] | ||
pub(crate) const TRUSSED_AUTH_FS_LAYOUT: trussed_auth::FilesystemLayout = | ||
trussed_auth::FilesystemLayout::V1; | ||
#[cfg(feature = "se050")] | ||
pub(crate) const SE050_BACKEND_FS_LAYOUT: trussed_se050_backend::FilesystemLayout = | ||
trussed_se050_backend::FilesystemLayout::V1; | ||
|
||
pub(crate) const MIGRATORS: &[Migrator] = &[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can just be pub
instead of pub(crate)
since the module is private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I'm not sure this should be merged before the FIDO2 certification is done.
Depends on:
not_before
trussed-dev/trussed#151dat
folder optional trussed-dev/trussed#150deserialize_identifier: add support for all types expected by serde trussed-dev/cbor-smol#8Replaced by:
Reduce space taken by credentials, using a migration step fido-authenticator#55dat
folders to save littlefs space trussed-dev/trussed-auth#39