Skip to content

Commit

Permalink
Code cleanup: CHIPCertToX509. (#10931)
Browse files Browse the repository at this point in the history
-- removed element type check from reader.Next() where it is later checked by reader.Get()
 -- removed size checks/adjustments around integer reader.Get().
    These checks are now performed by the Get() method itself.
 -- Added new Get(FixedByteSpan<N> & v) method to the TLVReader class.
 -- handle UTF8 DN attribute as CharSpan instead on ByteSpan.
 -- Switched to use VerifyOrReturnError() and ReturnErrorOnFailure() macros.
  • Loading branch information
emargolis authored and pull[bot] committed Feb 9, 2022
1 parent 1339cb3 commit 1818705
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 282 deletions.
2 changes: 1 addition & 1 deletion src/credentials/CHIPCert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ CHIP_ERROR ChipDN::AddAttribute(chip::ASN1::OID oid, uint64_t val)
return CHIP_NO_ERROR;
}

CHIP_ERROR ChipDN::AddAttribute(chip::ASN1::OID oid, ByteSpan val)
CHIP_ERROR ChipDN::AddAttribute(chip::ASN1::OID oid, CharSpan val)
{
uint8_t rdnCount = RDNCount();

Expand Down
6 changes: 3 additions & 3 deletions src/credentials/CHIPCert.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ enum
*/
struct ChipRDN
{
ByteSpan mString; /**< Attribute value when encoded as a string. */
CharSpan mString; /**< Attribute value when encoded as a string. */
uint64_t mChipVal; /**< CHIP specific DN attribute value. */
chip::ASN1::OID mAttrOID; /**< DN attribute CHIP OID. */

Expand Down Expand Up @@ -231,12 +231,12 @@ class ChipDN
* @brief Add string attribute to the DN.
*
* @param oid String OID for DN attribute.
* @param val A ByteSpan object containing a pointer and length of the DN string attribute
* @param val A CharSpan object containing a pointer and length of the DN string attribute
* buffer. The value in the buffer should remain valid while the object is in use.
*
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
**/
CHIP_ERROR AddAttribute(chip::ASN1::OID oid, ByteSpan val);
CHIP_ERROR AddAttribute(chip::ASN1::OID oid, CharSpan val);

/**
* @brief Determine type of a CHIP certificate.
Expand Down
Loading

0 comments on commit 1818705

Please sign in to comment.