Skip to content

Commit

Permalink
Switch return type for OpCert signing request (#15868)
Browse files Browse the repository at this point in the history
* Switch return type for OpCert signing request

I originally re-used the AttestationResponse type for the op cert
signing requests because they return data in the same format. This
was confusing, so adding another struct define with the same name.

* Address review comments.
  • Loading branch information
cecille authored Mar 8, 2022
1 parent 7b9fd2b commit d8c337f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio
break;
case CommissioningStage::kSendOpCertSigningRequest: {
NOCChainGenerationParameters nocParams;
nocParams.nocsrElements = report.Get<AttestationResponse>().attestationElements;
nocParams.signature = report.Get<AttestationResponse>().signature;
nocParams.nocsrElements = report.Get<CSRResponse>().nocsrElements;
nocParams.signature = report.Get<CSRResponse>().signature;
mParams.SetNOCChainGenerationParameters(nocParams);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ void DeviceCommissioner::OnOperationalCertificateSigningRequest(
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);

CommissioningDelegate::CommissioningReport report;
report.Set<AttestationResponse>(AttestationResponse(data.NOCSRElements, data.attestationSignature));
report.Set<CSRResponse>(CSRResponse(data.NOCSRElements, data.attestationSignature));
commissioner->CommissioningStageComplete(CHIP_NO_ERROR, report);
}

Expand Down
9 changes: 8 additions & 1 deletion src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ struct AttestationResponse
ByteSpan signature;
};

struct CSRResponse
{
CSRResponse(ByteSpan elements, ByteSpan newSignature) : nocsrElements(elements), signature(newSignature) {}
ByteSpan nocsrElements;
ByteSpan signature;
};

struct NocChain
{
NocChain(ByteSpan newNoc, ByteSpan newIcac, ByteSpan newRcac, AesCcm128KeySpan newIpk, NodeId newAdminSubject) :
Expand Down Expand Up @@ -328,7 +335,7 @@ class CommissioningDelegate
{
public:
virtual ~CommissioningDelegate(){};
struct CommissioningReport : Variant<RequestedCertificate, AttestationResponse, NocChain, OperationalNodeFoundData,
struct CommissioningReport : Variant<RequestedCertificate, AttestationResponse, CSRResponse, NocChain, OperationalNodeFoundData,
ReadCommissioningInfo, AdditionalErrorInfo>
{
CommissioningReport() : stageCompleted(CommissioningStage::kError) {}
Expand Down

0 comments on commit d8c337f

Please sign in to comment.