-
Notifications
You must be signed in to change notification settings - Fork 587
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
overlord/install/install.go: use plainkey for save key #14706
base: fde-manager-features
Are you sure you want to change the base?
overlord/install/install.go: use plainkey for save key #14706
Conversation
4bc0793
to
5c615ca
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fde-manager-features #14706 +/- ##
=======================================================
Coverage ? 78.83%
=======================================================
Files ? 1096
Lines ? 148248
Branches ? 0
=======================================================
Hits ? 116865
Misses ? 24082
Partials ? 7301
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
5c615ca
to
3be47e8
Compare
3be47e8
to
76c9119
Compare
aa56f86
to
2853766
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.
did a pass
@@ -8236,7 +8236,7 @@ echo '{"features":[]}' | |||
observeExistingTrustedRecoveryAssetsCalled += 1 | |||
return nil | |||
}, | |||
SetBootstrappedContainersFunc: func(key, saveKey secboot.BootstrappedContainer) { | |||
SetBootstrappedContainersFunc: func(key, saveKey secboot.BootstrappedContainer, primaryKey []byte) { |
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.
not new to this PR but shouldn't these check the arguments they get?
boot/assets.go
Outdated
@@ -256,7 +256,7 @@ func isAssetHashTrackedInMap(bam bootAssetsMap, assetName, assetHash string) boo | |||
type TrustedAssetsInstallObserver interface { | |||
BootLoaderSupportsEfiVariables() bool | |||
ObserveExistingTrustedRecoveryAssets(recoveryRootDir string) error | |||
SetBootstrappedContainers(key, saveKey secboot.BootstrappedContainer) | |||
SetBootstrappedContainers(key, saveKey secboot.BootstrappedContainer, primaryKey []byte) |
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.
... AndPrimarKey should be added to the name I suppose now
boot/makebootable_test.go
Outdated
@@ -1102,7 +1102,7 @@ version: 5.0 | |||
// set encryption key | |||
myKey := secboot.CreateMockBootstrappedContainer() | |||
myKey2 := secboot.CreateMockBootstrappedContainer() | |||
obs.SetBootstrappedContainers(myKey, myKey2) | |||
obs.SetBootstrappedContainers(myKey, myKey2, nil) |
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.
are there tests in this package where primaryKey is not set to nil?
overlord/fdestate/backend/seal.go
Outdated
@@ -112,12 +112,12 @@ func sealRunObjectKeys(key secboot.BootstrappedContainer, pbc boot.PredictableBo | |||
// path only unseals one object because unsealing is expensive. | |||
// Furthermore, the run object key is stored on ubuntu-boot so that we do not | |||
// need to continually write/read keys from ubuntu-seed. | |||
primaryKey, err := secbootSealKeys(runKeySealRequests(key, useTokens), sealKeyParams) | |||
createdPrimaryKey, err := secbootSealKeys(runKeySealRequests(key, useTokens), sealKeyParams) |
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'm confused, does it make sense to call it created if it was passed in or it depends whether is passed in or not? even in that case something more generic would be better?
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.
Agreed, according to sbNewProtectedKey
, it will get created only if nil was passed as the primary key
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.
It might be created, or the same if not nil. If we are in the case where use tokens, the primary key will be already picked because of the plainkey, and the parameter primaryKey
will contain that key. And createdPrimaryKey
will be the same key. If we do not use a tokens, then we did not chose a primary key yet. Then primaryKey
is nil. And then createdPrimaryKey
is a new key.
I could name them "primaryKeyInput" and "primaryKeyOutput". Or I could name same "primaryKey", "chosenPrimaryKey". Or "maybePrimaryKey" and "primaryKey".
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.
maybePrimaryKey and primaryKey seem fine here
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.
Done.
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.
Thank you! small nitpicks
secboot/keys/plainkey_test.go
Outdated
|
||
protectorKey, err := keys.NewProtectorKey() | ||
c.Assert(err, IsNil) | ||
protectedKey, primaryKeyOut, unlockKey, err := protectorKey.CreateProtectedKey([]byte("primary-in")) |
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.
maybe another variant where nil is passed, as this mimics what is done in install.PrepareEncryptedSystemData
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.
Good point. Done.
overlord/install/install_test.go
Outdated
c.Check(marker, HasLen, 32) | ||
c.Check(filepath.Join(boot.InstallHostFDESaveDir, "marker"), testutil.FileEquals, marker) | ||
|
||
// the assets cache was written to |
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.
// the assets cache was written to | |
// Check that assets cache was written |
overlord/fdestate/backend/seal.go
Outdated
@@ -112,12 +112,12 @@ func sealRunObjectKeys(key secboot.BootstrappedContainer, pbc boot.PredictableBo | |||
// path only unseals one object because unsealing is expensive. | |||
// Furthermore, the run object key is stored on ubuntu-boot so that we do not | |||
// need to continually write/read keys from ubuntu-seed. | |||
primaryKey, err := secbootSealKeys(runKeySealRequests(key, useTokens), sealKeyParams) | |||
createdPrimaryKey, err := secbootSealKeys(runKeySealRequests(key, useTokens), sealKeyParams) |
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.
Agreed, according to sbNewProtectedKey
, it will get created only if nil was passed as the primary key
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!
small nitpick on test coverage https://github.com/canonical/snapd/pull/14706/files#r1879654817
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.
thanks, style comment
secboot/keys/plainkey.go
Outdated
sbNewProtectedKey = sb_plainkey.NewProtectedKey | ||
) | ||
|
||
// ProtectorKey is a key that can be used to protect "plainkey" keys |
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.
style: all the doc comments should be sentences/paragraphs ending with "." thx
6b5d83e
to
d778338
Compare
I have cleaned up the history. |
d778338
to
941da67
Compare
No description provided.