Skip to content

Commit

Permalink
Refactor device attestation key handling in ProvisionStorageFlash.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
rosahay-silabs committed Jan 16, 2025
1 parent 18a9e04 commit 7943888
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/platform/silabs/provision/ProvisionStorageFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}

//
Expand Down

0 comments on commit 7943888

Please sign in to comment.