Skip to content

Commit

Permalink
Adding preprocessor checks before using DevelopmentCerts:kDac* constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Feb 18, 2023
1 parent fc8a2af commit d705c18
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/credentials/examples/DeviceAttestationCredsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit d705c18

Please sign in to comment.