Skip to content

Commit fc2c4bc

Browse files
ArekBalysNordicadigie
authored andcommitted
[nrf toup][nrfconnect] Fix DAC migration
- Fixed wrong dependency in Kconfigs - Fixed wrong bracket placement that causes overwriting DAC private key. Signed-off-by: Arkadiusz Balys <[email protected]> (cherry picked from commit 668f104) Signed-off-by: Adrian Gielniewski <[email protected]>
1 parent 98bf3b2 commit fc2c4bc

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

config/nrfconnect/chip-module/Kconfig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ endif # CHIP_FACTORY_DATA_BUILD
321321

322322
# See config/zephyr/Kconfig for full definition
323323
config CHIP_FACTORY_RESET_ERASE_SETTINGS
324-
default y
325-
depends on NVS || ZMS
326-
depends on !CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
324+
default y if !CHIP_CRYPTO_PSA_DAC_PRIV_KEY_ITS || BUILD_WITH_TFM
327325

328326
config CHIP_LOG_SIZE_OPTIMIZATION
329327
bool "Disable some detailed logs to decrease flash usage"
@@ -360,9 +358,12 @@ config CHIP_ENABLE_READ_CLIENT
360358

361359
config CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
362360
bool "Migrate DAC private key from factory data to a secure storage"
361+
default y
363362
depends on CHIP_CRYPTO_PSA
364363
depends on CHIP_FACTORY_DATA
365364

365+
if CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
366+
366367
choice CHIP_CRYPTO_PSA_DAC_PRIV_KEY_MIGRATION_DEST
367368
prompt "Destination for DAC private key migration"
368369
default CHIP_CRYPTO_PSA_DAC_PRIV_KEY_ITS
@@ -400,6 +401,8 @@ config CHIP_CRYPTO_PSA_DAC_PRIV_KEY_KMU_ENCRYPTED
400401
help
401402
Encrypt the DAC private key in the CRACEN KMU secure storage.
402403

404+
endif # CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
405+
403406
config CHIP_PERSISTENT_SUBSCRIPTIONS
404407
default n
405408
# selecting experimental for this feature since there is an issue with multiple controllers.

config/nrfconnect/chip-module/Kconfig.defaults

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,6 @@ config MBEDTLS_SSL_COOKIE_C
433433
config MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
434434
default y
435435

436-
config CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
437-
default y if !CHIP_WIFI
438-
439436
# ==============================================================================
440437
# Logging configuration
441438
# ==============================================================================

src/platform/nrfconnect/FactoryDataProvider.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,16 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::MoveDACPrivateKeyToSecureStora
174174
#else
175175
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_VOLATILE);
176176
#endif // CONFIG_CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
177+
VerifyOrReturnError(psa_import_key(&attributes, reinterpret_cast<uint8_t *>(mFactoryData.dac_priv_key.data),
178+
mFactoryData.dac_priv_key.len, &mDACPrivKeyId) == PSA_SUCCESS,
179+
CHIP_ERROR_INTERNAL);
177180
}
178-
VerifyOrReturnError(psa_import_key(&attributes, reinterpret_cast<uint8_t *>(mFactoryData.dac_priv_key.data),
179-
mFactoryData.dac_priv_key.len, &mDACPrivKeyId) == PSA_SUCCESS,
180-
CHIP_ERROR_INTERNAL);
181181

182182
#ifdef CONFIG_CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
183-
#ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS
183+
#if defined(CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS) && defined(CONFIG_CHIP_CRYPTO_PSA_DAC_PRIV_KEY_ITS) && \
184+
!defined(CONFIG_BUILD_WITH_TFM)
184185
#error "Do not use both CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS and CONFIG_CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY kconfig options " \
185-
"because you will permanently lose the DAC private key from the device."
186+
"while saving the DAC private key to ITS because you will permanently lose the DAC private key from the device."
186187
#endif
187188
// Check once again if the saved key has attributes set before removing it from the factory data set.
188189
VerifyOrReturnError(psa_get_key_attributes(mDACPrivKeyId, &attributes) == PSA_SUCCESS, CHIP_ERROR_INTERNAL);

0 commit comments

Comments
 (0)