Skip to content

Commit b4d87fa

Browse files
Fix ota encryption key preprocessor macro
1 parent 1d0f34b commit b4d87fa

9 files changed

+23
-23
lines changed

examples/platform/silabs/provision/ProvisionStorageDefault.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include <sl_matter_test_event_trigger_config.h>
3535
#endif // defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
3636
#endif // NDEBUG
37-
#ifdef OTA_ENCRYPTION_ENABLE
37+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
3838
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
39-
#endif // OTA_ENCRYPTION_ENABLE
39+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
4040
#ifndef SLI_SI91X_MCU_INTERFACE
4141
#include <psa/crypto.h>
4242
#endif
@@ -663,14 +663,14 @@ CHIP_ERROR Storage::GetProvisionRequest(bool & value)
663663
return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_Provision_Request, value);
664664
}
665665

666-
#if OTA_ENCRYPTION_ENABLE
666+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
667667
CHIP_ERROR Storage::SetOtaTlvEncryptionKey(const ByteSpan & value)
668668
{
669669
chip::DeviceLayer::Silabs::OtaTlvEncryptionKey::OtaTlvEncryptionKey key;
670670
ReturnErrorOnFailure(key.Import(value.data(), value.size()));
671671
return SilabsConfig::WriteConfigValue(SilabsConfig::kOtaTlvEncryption_KeyId, key.GetId());
672672
}
673-
#endif // OTA_ENCRYPTION_ENABLE
673+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
674674

675675
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
676676
CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)

examples/platform/silabs/provision/ProvisionStorageFlash.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include <platform/CHIPDeviceConfig.h>
2626
#include <platform/silabs/SilabsConfig.h>
2727
#include <string.h>
28-
#ifdef OTA_ENCRYPTION_ENABLE
28+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
2929
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
30-
#endif // OTA_ENCRYPTION_ENABLE
30+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
3131

3232
using namespace chip::Credentials;
3333

@@ -719,12 +719,12 @@ CHIP_ERROR Storage::GetProvisionRequest(bool & value)
719719
// return Flash::Set(Parameters::ID::kProvisionRequest, value);
720720
return CHIP_ERROR_NOT_IMPLEMENTED;
721721
}
722-
#if OTA_ENCRYPTION_ENABLE
722+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
723723
CHIP_ERROR Storage::SetOtaTlvEncryptionKey(const ByteSpan & value)
724724
{
725725
return CHIP_ERROR_NOT_IMPLEMENTED;
726726
}
727-
#endif // OTA_ENCRYPTION_ENABLE
727+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
728728

729729
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
730730
CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)

src/platform/silabs/efr32/efr32-psa-crypto-config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#endif // SL_USE_COAP_CONFIG
3535

3636
// Multi-chip OTA encryption processing
37-
#if OTA_ENCRYPTION_ENABLE
37+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
3838
#define PSA_WANT_ALG_CTR
39-
#endif // OTA_ENCRYPTION_ENABLE
39+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
4040

4141
// Include Generated fies
4242
#include "psa_crypto_config.h"

src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CHIP_ERROR OTAFactoryDataProcessor::ProcessInternal(ByteSpan & block)
4545
CHIP_ERROR error = CHIP_NO_ERROR;
4646

4747
ReturnErrorOnFailure(mAccumulator.Accumulate(block));
48-
#if OTA_ENCRYPTION_ENABLE
48+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
4949
MutableByteSpan mBlock = MutableByteSpan(mAccumulator.data(), mAccumulator.GetThreshold());
5050
OTATlvProcessor::vOtaProcessInternalEncryption(mBlock);
5151
#endif

src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CHIP_ERROR OTAFirmwareProcessor::Init()
4646
{
4747
VerifyOrReturnError(mCallbackProcessDescriptor != nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED);
4848
mAccumulator.Init(sizeof(Descriptor));
49-
#if OTA_ENCRYPTION_ENABLE
49+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
5050
mUnalignmentNum = 0;
5151
#endif
5252

@@ -58,7 +58,7 @@ CHIP_ERROR OTAFirmwareProcessor::Clear()
5858
OTATlvProcessor::ClearInternal();
5959
mAccumulator.Clear();
6060
mDescriptorProcessed = false;
61-
#if OTA_ENCRYPTION_ENABLE
61+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
6262
mUnalignmentNum = 0;
6363
#endif
6464

@@ -71,12 +71,12 @@ CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block)
7171
if (!mDescriptorProcessed)
7272
{
7373
ReturnErrorOnFailure(ProcessDescriptor(block));
74-
#if OTA_ENCRYPTION_ENABLE
74+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
7575
/* 16 bytes to used to store undecrypted data because of unalignment */
7676
mAccumulator.Init(requestedOtaMaxBlockSize + 16);
7777
#endif
7878
}
79-
#if OTA_ENCRYPTION_ENABLE
79+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
8080
MutableByteSpan mBlock = MutableByteSpan(mAccumulator.data(), mAccumulator.GetThreshold());
8181
memcpy(&mBlock[0], &mBlock[requestedOtaMaxBlockSize], mUnalignmentNum);
8282
memcpy(&mBlock[mUnalignmentNum], block.data(), block.size());

src/platform/silabs/multi-ota/OTAFirmwareProcessor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OTAFirmwareProcessor : public OTATlvProcessor
4444

4545
OTADataAccumulator mAccumulator;
4646
bool mDescriptorProcessed = false;
47-
#if OTA_ENCRYPTION_ENABLE
47+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
4848
uint32_t mUnalignmentNum;
4949
#endif
5050
static constexpr size_t kAlignmentBytes = 64;

src/platform/silabs/multi-ota/OTATlvProcessor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include <platform/silabs/multi-ota/OTAMultiImageProcessorImpl.h>
2424
#include <platform/silabs/multi-ota/OTATlvProcessor.h>
25-
#if OTA_ENCRYPTION_ENABLE
25+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
2626
#include <platform/silabs/SilabsConfig.h>
2727
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
2828
#endif
@@ -31,7 +31,7 @@ using namespace ::chip::DeviceLayer::Internal;
3131

3232
namespace chip {
3333

34-
#if OTA_ENCRYPTION_ENABLE
34+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
3535
constexpr uint8_t au8Iv[] = { 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x00, 0x00, 0x00, 0x00 };
3636
#endif
3737
CHIP_ERROR OTATlvProcessor::Process(ByteSpan & block)
@@ -66,7 +66,7 @@ void OTATlvProcessor::ClearInternal()
6666
mLength = 0;
6767
mProcessedLength = 0;
6868
mWasSelected = false;
69-
#if OTA_ENCRYPTION_ENABLE
69+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
7070
mIVOffset = 0;
7171
#endif
7272
}
@@ -105,7 +105,7 @@ CHIP_ERROR OTADataAccumulator::Accumulate(ByteSpan & block)
105105
return CHIP_NO_ERROR;
106106
}
107107

108-
#if OTA_ENCRYPTION_ENABLE
108+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
109109
CHIP_ERROR OTATlvProcessor::vOtaProcessInternalEncryption(MutableByteSpan & block)
110110
{
111111
uint32_t keyId;

src/platform/silabs/multi-ota/OTATlvProcessor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class OTATlvProcessor
9999
void SetLength(uint32_t length) { mLength = length; }
100100
void SetWasSelected(bool selected) { mWasSelected = selected; }
101101
bool WasSelected() { return mWasSelected; }
102-
#if OTA_ENCRYPTION_ENABLE
102+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
103103
CHIP_ERROR vOtaProcessInternalEncryption(MutableByteSpan & block);
104104
#endif
105105

@@ -133,7 +133,7 @@ class OTATlvProcessor
133133

134134
bool IsError(CHIP_ERROR & status);
135135

136-
#if OTA_ENCRYPTION_ENABLE
136+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
137137
/*ota decryption*/
138138
uint32_t mIVOffset = 0;
139139
/* Expected byte size of the OTAEncryptionKeyLength */

third_party/silabs/efr32_sdk.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ template("efr32_sdk") {
547547
}
548548

549549
if (chip_enable_multi_ota_encryption && chip_enable_multi_ota_requestor) {
550-
defines += [ "OTA_ENCRYPTION_ENABLE=1" ]
550+
defines += [ "SL_MATTER_ENABLE_OTA_ENCRYPTION=1" ]
551551
}
552552

553553
if (chip_enable_ota_custom_tlv_testing && chip_enable_multi_ota_requestor) {

0 commit comments

Comments
 (0)