-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add plainkey platform #282
Conversation
cd5594c
to
166eab8
Compare
57c878b
to
5d9b63e
Compare
5d9b63e
to
72c15d7
Compare
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.
72c15d7
to
0d14824
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.
thanks, some small comments
* | ||
*/ | ||
|
||
package plainkey |
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 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
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've added a comment here now.
plainkey/platform.go
Outdated
// 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) { |
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 need this? anyway it seems not to be tested atm
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've removed this.
Version int `json:"version"` | ||
Nonce []byte `json:"nonce"` | ||
|
||
PlatformKeyID platformKeyId `json:"platform-key-id"` |
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 would be good to have a doc comment on this one
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 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.
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
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.