From d705c18e4a29a11fc805c0ea15411199adcc7a7c Mon Sep 17 00:00:00 2001 From: Sharad Binjola Date: Fri, 17 Feb 2023 11:59:54 -0800 Subject: [PATCH] Adding preprocessor checks before using DevelopmentCerts:kDac* constants --- .../examples/DeviceAttestationCredsExample.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/credentials/examples/DeviceAttestationCredsExample.cpp b/src/credentials/examples/DeviceAttestationCredsExample.cpp index fa1213ef294b2a..67bd914e482cac 100644 --- a/src/credentials/examples/DeviceAttestationCredsExample.cpp +++ b/src/credentials/examples/DeviceAttestationCredsExample.cpp @@ -52,7 +52,11 @@ class ExampleDACProvider : public DeviceAttestationCredentialsProvider CHIP_ERROR ExampleDACProvider::GetDeviceAttestationCert(MutableByteSpan & out_dac_buffer) { +#if 0x8000 <= CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID && CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID <= 0x801F return CopySpanToMutableSpan(DevelopmentCerts::kDacCert, out_dac_buffer); +#else + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // 0x8000 <= CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID && CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID <= 0x801F } CHIP_ERROR ExampleDACProvider::GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer) @@ -122,6 +126,7 @@ CHIP_ERROR ExampleDACProvider::GetFirmwareInformation(MutableByteSpan & out_firm CHIP_ERROR ExampleDACProvider::SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_signature_buffer) { +#if 0x8000 <= CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID && CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID <= 0x801F Crypto::P256ECDSASignature signature; Crypto::P256Keypair keypair; @@ -135,6 +140,9 @@ CHIP_ERROR ExampleDACProvider::SignWithDeviceAttestationKey(const ByteSpan & mes ReturnErrorOnFailure(keypair.ECDSA_sign_msg(message_to_sign.data(), message_to_sign.size(), signature)); return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_signature_buffer); +#else + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // 0x8000 <= CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID && CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID <= 0x801F } } // namespace