-
Notifications
You must be signed in to change notification settings - Fork 60
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
[nrf noup] Migrate Operational Keys from mbedTLS to PSA ITS #374
[nrf noup] Migrate Operational Keys from mbedTLS to PSA ITS #374
Conversation
ArekBalysNordic
commented
Jan 4, 2024
•
edited
Loading
edited
- Extended the OperationalKeystore API by a mechanism for migration of operational keys stored in one Operational Keystore implementation to another.
- Extended the OperationalKeystore API by exporting keypair for Fabric.
- Added Unit tests to PersistentStorageOpKeyStore and PSAOpKeystore regarding the new OperationalKeystore for migration and exporting OpKeys.
- Added unit tests for the created export and migrate methods.
- Emitting a new ChipEvent if the key has been migrated wrongly.
33748f2
to
388e8f2
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.
What about to contributing this to upstream as well, to get more reviews?
VerifyOrExit(status == PSA_SUCCESS, error = CHIP_ERROR_INTERNAL); | ||
|
||
bbuf.Put(input.ConstBytes(), mPublicKey.Length()); | ||
VerifyOrExit(bbuf.Fit(), error = CHIP_ERROR_NO_MEMORY); |
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.
What happens with key that is imported at line 166 if this error occurs?
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 guess it should destroy a private key if the error occurs because we need to have a valid keypair. I will add it.
Sure, why not, we can start pushing PSA changes into upstream. :) |
b6394cc
to
236acea
Compare
ReturnErrorOnFailure(reader.ExitContainer(containerType)); | ||
ReturnErrorOnFailure(reader.VerifyEndOfContainer()); | ||
|
||
if (keyData.size() == kP256_PrivateKey_Length + kP256_PublicKey_Length) |
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: I would error out if that happens
93d9f1d
to
35f1c18
Compare
35f1c18
to
d89f733
Compare
I've changed the way to migrate Operational Keys. Now the keys are migrated in the Server::Init method, just after getting info about FabricTable. If the key cannot be migrated, then the new ChipEvent is posted and the Server::Init method doesn't fail. I've added two methods to OperationalKeystore API to migrate and export keys, and implemented both virtual methods for PersistentOperationalKeystore and PSAOperationalKeystore. And also I've written tests for migration and exporting. Please review those changes before I will go upstream with them. |
92cc164
to
8e039d9
Compare
8e039d9
to
e0e66d4
Compare
e0e66d4
to
481f395
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.
Good work with tests. Found some inconsistencies that you can look into.
// Load up the operational key structure from storage | ||
uint16_t size = static_cast<uint16_t>(buf.Capacity()); | ||
CHIP_ERROR err = storage->SyncGetKeyValue(DefaultStorageKeyAllocator::FabricOpKey(fabricIndex).KeyName(), buf.Bytes(), size); | ||
if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) |
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.
In the PSA migration function you seem to assume that for already migrated fabric CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND will be returned, but due to this code this will likely be CHIP_ERROR_INVALID_FABRIC_INDEX, right?
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 changed it to return the CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND error for the Export method and keep CHIP_ERROR_INVALID_FABRIC_INDEX for the Signing method
481f395
to
70eedef
Compare
ffbfd48
to
8886e9d
Compare
063d14c
to
78bc9bd
Compare
…gration - Extended the OperationalKeystore API by mechanism for migration of operational keys stored in one Operational Keystore implementation to another. - Extended the OperationalKeystore API by exporting keypair for Fabric. - Added Unit tests to PersistentStorageOpKeyStore and PSAOpKeystore regarding the new OperationalKeystore for migration and exporting OpKeys. Added first unit tests, created export method Aligned NXP and Silabs platform to the recent OperationalKeystore changes.
Initialize PSA in the Application side instead of Matter Server.
78bc9bd
to
b3aa01d
Compare