Skip to content

Commit

Permalink
Addressed review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis committed Jan 21, 2022
1 parent 2652468 commit 23afea0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/controller/ExampleOperationalCredentialsIssuer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -96,6 +96,8 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::GenerateNOCChainAfterValidation(
MutableByteSpan & noc)
{
ChipDN noc_dn;
// TODO: Is there a way to make this code less error-prone for consumers?
// The consumer doesn't need to know the exact OID value.
noc_dn.AddAttribute(chip::ASN1::kOID_AttributeType_ChipFabricId, fabricId);
noc_dn.AddAttribute(chip::ASN1::kOID_AttributeType_ChipNodeId, nodeId);
// TODO: Add support for the CASE Authenticated Tags attributes
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
16 changes: 7 additions & 9 deletions src/credentials/CHIPCert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
Expand Down Expand Up @@ -702,24 +702,22 @@ CHIP_ERROR ChipDN::DecodeFromTLV(TLVReader & reader)
{
CHIP_ERROR err;
TLVType outerContainer;
Tag tlvTag;
uint32_t tlvTagNum;
OID attrOID;
bool attrIsPrintableString;

static constexpr uint32_t kOID_AttributeIsPrintableString_Flag = 0x00000080;
static constexpr uint32_t kOID_AttributeType_Mask = 0x0000007F;

VerifyOrReturnError(reader.GetType() == kTLVType_List, CHIP_ERROR_WRONG_TLV_TYPE);

// Enter the List TLV element that represents the DN in TLV format.
ReturnErrorOnFailure(reader.EnterContainer(outerContainer));

// Read the RDN attributes in the List.
while ((err = reader.Next()) == CHIP_NO_ERROR)
{
// Get the TLV tag, make sure it is a context tag and extract the context tag number.
tlvTag = reader.GetTag();
Tag tlvTag = reader.GetTag();
VerifyOrReturnError(IsContextTag(tlvTag), CHIP_ERROR_INVALID_TLV_TAG);
tlvTagNum = TagNumFromTag(tlvTag);
uint32_t tlvTagNum = TagNumFromTag(tlvTag);

// Derive the OID of the corresponding ASN.1 attribute from the TLV tag number.
// The numeric value of the OID is encoded in the bottom 7 bits of the TLV tag number.
Expand All @@ -732,9 +730,9 @@ CHIP_ERROR ChipDN::DecodeFromTLV(TLVReader & reader)
// will fail for lack of the OID's encoded representation. Given this there's no
// need to test the validity of the OID here.
//
attrOID = GetOID(kOIDCategory_AttributeType, static_cast<uint8_t>(tlvTagNum & kOID_AttributeType_Mask));
OID attrOID = GetOID(kOIDCategory_AttributeType, static_cast<uint8_t>(tlvTagNum & kOID_AttributeType_Mask));

attrIsPrintableString = (tlvTagNum & kOID_AttributeIsPrintableString_Flag) == kOID_AttributeIsPrintableString_Flag;
bool attrIsPrintableString = (tlvTagNum & kOID_AttributeIsPrintableString_Flag) == kOID_AttributeIsPrintableString_Flag;

// For 64-bit CHIP-defined DN attributes.
if (IsChip64bitDNAttr(attrOID))
Expand Down
4 changes: 3 additions & 1 deletion src/credentials/CHIPCert.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
Expand Down Expand Up @@ -269,6 +269,8 @@ class ChipDN

/**
* @brief Decode ChipDN attributes from TLV encoded format.
*
* @param reader A TLVReader positioned at the ChipDN TLV list.
**/
CHIP_ERROR DecodeFromTLV(chip::TLV::TLVReader & reader);

Expand Down
2 changes: 1 addition & 1 deletion src/credentials/CHIPCertToX509.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/GenerateChipX509Cert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/tests/TestChipCert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/tools/chip-cert/Cmd_GenCert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
*
Expand Down

0 comments on commit 23afea0

Please sign in to comment.