Skip to content

Commit

Permalink
Pull request project-chip#1643: Bugfix: Provision defaults.
Browse files Browse the repository at this point in the history
Merge in WMN_TOOLS/matter from bugfix/provision-defaults to RC_2.3.0-1.3

Squashed commit of the following:

commit 3eeeb2a30fbdc8cb8a6a992f3f343e47993ad891
Author: Ricardo Casallas <77841255+rcasallas-silabs@users.noreply.github.com>
Date:   Thu Mar 14 10:17:52 2024 -0400

    Bugfix: Provision defaults.
  • Loading branch information
rcasallas-silabs authored and jmartinez-silabs committed Mar 29, 2024
1 parent 6d6213b commit ae594f3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 46 deletions.
2 changes: 2 additions & 0 deletions examples/platform/silabs/provision/ProvisionStorage.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "ProvisionStorage.h"
#include "ProvisionProtocol.h"
#include <CHIPProjectConfig.h>
#include <lib/core/CHIPEncoding.h>
#include <lib/support/Base64.h>
#include <lib/support/BytesToHex.h>
#include <crypto/CHIPCryptoPAL.h>
#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <setup_payload/Base38Encode.h>
#include <setup_payload/SetupPayload.h>
Expand Down
24 changes: 12 additions & 12 deletions examples/platform/silabs/provision/ProvisionStorageDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ CHIP_ERROR Storage::SetCertificationDeclaration(const ByteSpan & value)
CHIP_ERROR Storage::GetCertificationDeclaration(MutableByteSpan & value)
{
CHIP_ERROR err = ReadFileByKey(*this, "GetCertificationDeclaration", SilabsConfig::kConfigKey_Creds_CD_Offset, SilabsConfig::kConfigKey_Creds_CD_Size, value);
#if defined(SILABS_PROVISION_VERSION_1_0) && SILABS_PROVISION_VERSION_1_0
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
#if defined(SL_PROVISION_VERSION_1_0) && SL_PROVISION_VERSION_1_0
if(CHIP_ERROR_NOT_FOUND == err)
{
// Reading from the old script's location.
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SILABS_CREDENTIALS_CD_OFFSET, SILABS_CREDENTIALS_CD_SIZE, value);
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_CD_OFFSET, SL_CREDENTIALS_CD_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
if(CHIP_ERROR_NOT_FOUND == err)
{
// Example CD
err = Examples::GetExampleDACProvider()->GetCertificationDeclaration(value);
Expand All @@ -466,15 +466,15 @@ CHIP_ERROR Storage::SetProductAttestationIntermediateCert(const ByteSpan & value
CHIP_ERROR Storage::GetProductAttestationIntermediateCert(MutableByteSpan & value)
{
CHIP_ERROR err = ReadFileByKey(*this, "GetProductAttestationIntermediateCert", SilabsConfig::kConfigKey_Creds_PAI_Offset, SilabsConfig::kConfigKey_Creds_PAI_Size, value);
#if defined(SILABS_PROVISION_VERSION_1_0) && SILABS_PROVISION_VERSION_1_0
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
#if defined(SL_PROVISION_VERSION_1_0) && SL_PROVISION_VERSION_1_0
if(CHIP_ERROR_NOT_FOUND == err)
{
// Reading from the old script's location.
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SILABS_CREDENTIALS_PAI_OFFSET, SILABS_CREDENTIALS_PAI_SIZE, value);
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_PAI_OFFSET, SL_CREDENTIALS_PAI_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
if(CHIP_ERROR_NOT_FOUND == err)
{
// Example PAI
err = Examples::GetExampleDACProvider()->GetProductAttestationIntermediateCert(value);
Expand All @@ -492,15 +492,15 @@ CHIP_ERROR Storage::SetDeviceAttestationCert(const ByteSpan & value)
CHIP_ERROR Storage::GetDeviceAttestationCert(MutableByteSpan & value)
{
CHIP_ERROR err = ReadFileByKey(*this, "GetDeviceAttestationCert", SilabsConfig::kConfigKey_Creds_DAC_Offset, SilabsConfig::kConfigKey_Creds_DAC_Size, value);
#if defined(SILABS_PROVISION_VERSION_1_0) && SILABS_PROVISION_VERSION_1_0
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
#if defined(SL_PROVISION_VERSION_1_0) && SL_PROVISION_VERSION_1_0
if(CHIP_ERROR_NOT_FOUND == err)
{
// Reading from the old script's location.
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SILABS_CREDENTIALS_DAC_OFFSET, SILABS_CREDENTIALS_DAC_SIZE, value);
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_DAC_OFFSET, SL_CREDENTIALS_DAC_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
if(CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err)
if(CHIP_ERROR_NOT_FOUND == err)
{
// Example DAC
return Examples::GetExampleDACProvider()->GetDeviceAttestationCert(value);
Expand Down
28 changes: 14 additions & 14 deletions examples/platform/silabs/silabs_creds.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
* "chip_build_device_attestation_credentials=true".
*/

#ifndef SILABS_PROVISION_VERSION_1_0
#define SILABS_PROVISION_VERSION_1_0 0
#ifndef SL_PROVISION_VERSION_1_0
#define SL_PROVISION_VERSION_1_0 0
#endif

#ifndef SILABS_CREDENTIALS_DAC_OFFSET
#define SILABS_CREDENTIALS_DAC_OFFSET 0x0000
#ifndef SL_CREDENTIALS_DAC_OFFSET
#define SL_CREDENTIALS_DAC_OFFSET 0x0000
#endif

#ifndef SILABS_CREDENTIALS_DAC_SIZE
#define SILABS_CREDENTIALS_DAC_SIZE 481
#ifndef SL_CREDENTIALS_DAC_SIZE
#define SL_CREDENTIALS_DAC_SIZE 0
#endif

#ifndef SILABS_CREDENTIALS_PAI_OFFSET
#define SILABS_CREDENTIALS_PAI_OFFSET 0x0200
#ifndef SL_CREDENTIALS_PAI_OFFSET
#define SL_CREDENTIALS_PAI_OFFSET 0x0200
#endif

#ifndef SILABS_CREDENTIALS_PAI_SIZE
#define SILABS_CREDENTIALS_PAI_SIZE 443
#ifndef SL_CREDENTIALS_PAI_SIZE
#define SL_CREDENTIALS_PAI_SIZE 0
#endif

#ifndef SILABS_CREDENTIALS_CD_OFFSET
#define SILABS_CREDENTIALS_CD_OFFSET 0x0400
#ifndef SL_CREDENTIALS_CD_OFFSET
#define SL_CREDENTIALS_CD_OFFSET 0x0400
#endif

#ifndef SILABS_CREDENTIALS_CD_SIZE
#define SILABS_CREDENTIALS_CD_SIZE 244
#ifndef SL_CREDENTIALS_CD_SIZE
#define SL_CREDENTIALS_CD_SIZE 0
#endif
3 changes: 1 addition & 2 deletions provision/modules/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ def compile(self):
file_ver = self.compileFileInputs(versions, inputs_path)
# Command-line inputs
cmd_ver = self.compileCommandInputs(versions, file_ver, params_path)
# Export compiled inputs
# Update version
self.set(ID.kVersion, cmd_ver.tag)
self.export()
# Apply defaults
for k, a in self.ids.items():
if (a.value is None) and (a.default is not None):
Expand Down
10 changes: 6 additions & 4 deletions provision/modules/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def execute(self, paths, args):
os.makedirs(temp.value)
paths.setTemp(args.str(ID.kTemporaryDir))

# Compute defaults
if ('auto' == action) or ('binary' == action):
self.computeDefaults(paths, args)
# Export arguments (including generated values)
args.export()

# Stop
if args.value(ID.kStop):
_util.warn("Stop requested.")
exit(0)

# Compute defaults
if ('auto' == action) or ('binary' == action):
self.computeDefaults(paths, args)

# Connection string
conn = ConnectionArguments(args)

Expand Down
28 changes: 14 additions & 14 deletions provision/silabs_creds.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
* "chip_build_device_attestation_credentials=true".
*/

#ifndef SILABS_PROVISION_VERSION_1_0
#define SILABS_PROVISION_VERSION_1_0 {{use_legacy_certs_format}}
#ifndef SL_PROVISION_VERSION_1_0
#define SL_PROVISION_VERSION_1_0 {{use_legacy_certs_format}}
#endif

#ifndef SILABS_CREDENTIALS_DAC_OFFSET
#define SILABS_CREDENTIALS_DAC_OFFSET {{dac_offset}}
#ifndef SL_CREDENTIALS_DAC_OFFSET
#define SL_CREDENTIALS_DAC_OFFSET {{dac_offset}}
#endif

#ifndef SILABS_CREDENTIALS_DAC_SIZE
#define SILABS_CREDENTIALS_DAC_SIZE {{dac_size}}
#ifndef SL_CREDENTIALS_DAC_SIZE
#define SL_CREDENTIALS_DAC_SIZE {{dac_size}}
#endif

#ifndef SILABS_CREDENTIALS_PAI_OFFSET
#define SILABS_CREDENTIALS_PAI_OFFSET {{pai_offset}}
#ifndef SL_CREDENTIALS_PAI_OFFSET
#define SL_CREDENTIALS_PAI_OFFSET {{pai_offset}}
#endif

#ifndef SILABS_CREDENTIALS_PAI_SIZE
#define SILABS_CREDENTIALS_PAI_SIZE {{pai_size}}
#ifndef SL_CREDENTIALS_PAI_SIZE
#define SL_CREDENTIALS_PAI_SIZE {{pai_size}}
#endif

#ifndef SILABS_CREDENTIALS_CD_OFFSET
#define SILABS_CREDENTIALS_CD_OFFSET {{cd_offset}}
#ifndef SL_CREDENTIALS_CD_OFFSET
#define SL_CREDENTIALS_CD_OFFSET {{cd_offset}}
#endif

#ifndef SILABS_CREDENTIALS_CD_SIZE
#define SILABS_CREDENTIALS_CD_SIZE {{cd_size}}
#ifndef SL_CREDENTIALS_CD_SIZE
#define SL_CREDENTIALS_CD_SIZE {{cd_size}}
#endif

0 comments on commit ae594f3

Please sign in to comment.