From 79438881ec2216435baf1857ad6ffdc4fcef2bcb Mon Sep 17 00:00:00 2001 From: Rohan Sahay <103027015+rosahay-silabs@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:42:45 +0530 Subject: [PATCH] Refactor device attestation key handling in ProvisionStorageFlash.cpp --- .../platform/silabs/provision/ProvisionStorageFlash.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp index fae1b5c713b910..b7642150e194dd 100644 --- a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp +++ b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp @@ -649,7 +649,6 @@ CHIP_ERROR Storage::GetDeviceAttestationCSR(uint16_t vid, uint16_t pid, const Ch CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, MutableByteSpan & signature) { - AttestationKey key; uint8_t temp[kDeviceAttestationKeySizeMax] = { 0 }; size_t size = 0; CHIP_ERROR err = Flash::Get(Parameters::ID::kDacKey, temp, sizeof(temp), size); @@ -661,8 +660,16 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab } #endif // CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS ReturnErrorOnFailure(err); +#if (defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE) + uint8_t key_buffer[kDeviceAttestationKeySizeMax] = { 0 }; + MutableByteSpan private_key(key_buffer); + AttestationKey::Unwrap(temp, size, private_key); + return AttestationKey::SignMessageWithKey((const uint8_t *) key_buffer, message, signature); +#else + AttestationKey key; ReturnErrorOnFailure(key.Import(temp, size)); return key.SignMessage(message, signature); +#endif // SLI_SI91X_MCU_INTERFACE } //