Skip to content

Commit

Permalink
Switch return type for OpCert signing request
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cecille committed Mar 4, 2022
1 parent 08ca987 commit d812e54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,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<OpCertResponse>().attestationElements;
nocParams.signature = report.Get<OpCertResponse>().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 @@ -1135,7 +1135,7 @@ void DeviceCommissioner::OnOperationalCertificateSigningRequest(
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);

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

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

struct OpCertResponse
{
OpCertResponse(ByteSpan newAttestationElements, ByteSpan newSignature) :
attestationElements(newAttestationElements), signature(newSignature)
{}
ByteSpan attestationElements;
ByteSpan signature;
};

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

0 comments on commit d812e54

Please sign in to comment.