Skip to content

Commit

Permalink
Updated ConvertToNOCResponseStatus() Function Implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis committed May 19, 2022
1 parent 70e259c commit c182bf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,18 +593,24 @@ OperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err)
{
return OperationalCertStatus::kInvalidPublicKey;
}
if (err == CHIP_ERROR_INVALID_FABRIC_INDEX || err == CHIP_ERROR_WRONG_NODE_ID)
if (err == CHIP_ERROR_WRONG_NODE_ID || err == CHIP_ERROR_WRONG_CERT_DN || err == CHIP_ERROR_FABRIC_MISMATCH_ON_ICA)
{
return OperationalCertStatus::kInvalidNodeOpId;
}
if (err == CHIP_ERROR_CA_CERT_NOT_FOUND || err == CHIP_ERROR_CERT_PATH_LEN_CONSTRAINT_EXCEEDED ||
err == CHIP_ERROR_CERT_PATH_TOO_LONG || err == CHIP_ERROR_CERT_USAGE_NOT_ALLOWED || err == CHIP_ERROR_CERT_EXPIRED ||
err == CHIP_ERROR_CERT_NOT_VALID_YET || err == CHIP_ERROR_UNSUPPORTED_CERT_FORMAT ||
err == CHIP_ERROR_UNSUPPORTED_ELLIPTIC_CURVE || err == CHIP_ERROR_CERT_LOAD_FAILED || err == CHIP_ERROR_CERT_NOT_TRUSTED ||
err == CHIP_ERROR_WRONG_CERT_DN)
err == CHIP_ERROR_INVALID_ARGUMENT || err == CHIP_ERROR_UNSUPPORTED_SIGNATURE_TYPE || err == CHIP_ERROR_WRONG_CERT_TYPE ||
err == CHIP_ERROR_CERT_NOT_FOUND || err == CHIP_ERROR_WRONG_TLV_TYPE || err == CHIP_ERROR_INVALID_TLV_TAG ||
err == CHIP_ERROR_BUFFER_TOO_SMALL)
{
return OperationalCertStatus::kInvalidNOC;
}
if (err == CHIP_ERROR_INCORRECT_STATE)
{
return OperationalCertStatus::kMissingCsr;
}
if (err == CHIP_ERROR_NO_MEMORY)
{
return OperationalCertStatus::kTableFull;
Expand All @@ -613,6 +619,10 @@ OperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err)
{
return OperationalCertStatus::kFabricConflict;
}
if (err == CHIP_ERROR_INVALID_FABRIC_INDEX)
{
return OperationalCertStatus::kInvalidFabricIndex;
}

return OperationalCertStatus::kInvalidNOC;
}
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/FabricTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ CHIP_ERROR FabricInfo::SetFabricInfo(FabricInfo & newFabric)
auto * operationalKey = newFabric.GetOperationalKey();
if (operationalKey == nullptr)
{
return CHIP_ERROR_INVALID_ARGUMENT;
return CHIP_ERROR_INCORRECT_STATE;
}

// Verify that public key in NOC matches public key generated by node and sent in CSRResponse message.
Expand Down

0 comments on commit c182bf3

Please sign in to comment.