Skip to content
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

Add plainkey platform #282

Merged
merged 6 commits into from
Mar 15, 2024

Conversation

chrisccoulson
Copy link
Collaborator

@chrisccoulson chrisccoulson commented Feb 1, 2024

This platform provides a way to unlock an encrypted container using a
key recovered from unlocking another container, and is suitable when
access to one encrypted container implies access to another one.

The intention of this is to replace the existing mechanism for unlocking
the save partition in run mode with something that uses a proper keyslot.

Keys are protected with a "platform key" - this is the key that is
stored in the first encrypted container. For the intended use case,
this key is stored inside the data partition, and then loaded by
snap-bootstrap, which should call plainkey.SetPlatformKeys before
unlocking the save partition.

Although normally there will only be a single key supplied to
SetPlatformKeys, it supports setting multiple keys and then matching
a key data object to the correct one. This is to support the possibility
of changing this key during reprovisioning (ie, as part of factory
reset), where there would need to exist 2 keys (the old and new one)
temporarily - this would prevent against loss of data if the process
was interrupted at any point.

@chrisccoulson chrisccoulson force-pushed the add-plainkey-platform branch 5 times, most recently from cd5594c to 166eab8 Compare February 2, 2024 18:08
@chrisccoulson chrisccoulson force-pushed the add-plainkey-platform branch 3 times, most recently from 57c878b to 5d9b63e Compare February 20, 2024 15:26
@chrisccoulson chrisccoulson marked this pull request as ready for review February 20, 2024 15:27
This platform provides a way to unlock an encrypted container using a
key recovered from unlocking another container, and is suitable when
access to one encrypted container implies access to another one.

The intention of this is to replace the existing mechanism for unlocking
the save partition in run mode with something that uses a proper keyslot.

Keys are protected with a "platform key" - this is the key that is
stored in the first encrypted container. For the intended use case,
this key is stored inside the data partition, and then loaded by
snap-bootstrap, which should call plainkey.SetPlatformKeys before
unlocking the save partition.

Although normally there will only be a single key supplied to
SetPlatformKeys, it supports setting multiple keys and then matching
a key data object to the correct one. This is to support the possibility
of changing this key during reprovisioning (ie, as part of factory
reset), where there would need to exist 2 keys (the old and new one)
temporarily - this would prevent against loss of data if the process
was interrupted at any point.
@chrisccoulson chrisccoulson force-pushed the add-plainkey-platform branch from 72c15d7 to 0d14824 Compare March 11, 2024 23:03
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, some small comments

*
*/

package plainkey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to have a doc comment for the package here.

probably a good idea to add one also for tpm2 at some point

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment here now.

// AddPlatformKeys adds keys that will be used by this platform to recover other
// keys. These are typically stored in and loaded from an encrypted container that is
// unlocked via some other mechanism.
func AddPlatformKeys(keys ...[]byte) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? anyway it seems not to be tested atm

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this.

Version int `json:"version"`
Nonce []byte `json:"nonce"`

PlatformKeyID platformKeyId `json:"platform-key-id"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to have a doc comment on this one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment here.

I added a comment for the Nonce field as well and then realized it didn't make sense because the field was holding 2 unrelated values. I've pushed another change that splits this into 2 distinct fields.

@chrisccoulson chrisccoulson requested a review from pedronis March 15, 2024 10:10
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@chrisccoulson chrisccoulson merged commit f8dedd0 into canonical:master Mar 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants