diff --git a/src/darwin/Framework/CHIP/MTRNOCChainIssuer.h b/src/darwin/Framework/CHIP/MTRNOCChainIssuer.h index 2ef76670532118..0757bbe10021a5 100644 --- a/src/darwin/Framework/CHIP/MTRNOCChainIssuer.h +++ b/src/darwin/Framework/CHIP/MTRNOCChainIssuer.h @@ -43,8 +43,8 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)onNOCChainGenerationNeeded:(CSRInfo *)csrInfo attestationInfo:(AttestationInfo *)attestationInfo - onNOCChainGenerationComplete:(void (^)(NSData * operationalCertificate, NSData * intermediateCertificate, - NSData * rootCertificate, NSData * ipk, NSNumber * adminSubject, + onNOCChainGenerationComplete:(BOOL (^)(NSData * operationalCertificate, NSData * intermediateCertificate, + NSData * rootCertificate, NSData * _Nullable ipk, NSNumber * _Nullable adminSubject, NSError * __autoreleasing * error))onNOCChainGenerationComplete; @end diff --git a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.h b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.h index 803e19eee30eed..3d0c39eacb7a2c 100644 --- a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.h +++ b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.h @@ -127,7 +127,7 @@ class MTROperationalCredentialsDelegate : public chip::Controller::OperationalCr * If ipk and adminSubject are non nil, then they will be used in the AddNOC command sent to the commissionee. If they are not * populated, then the values provided in the MTRDeviceController initialization will be used. */ - void onNOCChainGenerationComplete(NSData * operationalCertificate, NSData * intermediateCertificate, NSData * rootCertificate, + BOOL onNOCChainGenerationComplete(NSData * operationalCertificate, NSData * intermediateCertificate, NSData * rootCertificate, NSData * _Nullable ipk, NSNumber * _Nullable adminSubject, NSError * __autoreleasing * error); void setNSError(CHIP_ERROR err, NSError * __autoreleasing * outError); diff --git a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm index 1113ad18505086..31756493683cc1 100644 --- a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm +++ b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm @@ -205,9 +205,9 @@ dispatch_sync(mNocChainIssuerQueue, ^{ [mNocChainIssuer onNOCChainGenerationNeeded:csrInfo attestationInfo:attestationInfo - onNOCChainGenerationComplete:^void(NSData * operationalCertificate, NSData * intermediateCertificate, + onNOCChainGenerationComplete:^BOOL(NSData * operationalCertificate, NSData * intermediateCertificate, NSData * rootCertificate, NSData * ipk, NSNumber * adminSubject, NSError * __autoreleasing * error) { - onNOCChainGenerationComplete( + return onNOCChainGenerationComplete( operationalCertificate, intermediateCertificate, rootCertificate, ipk, adminSubject, error); }]; }); @@ -222,13 +222,13 @@ } } -void MTROperationalCredentialsDelegate::onNOCChainGenerationComplete(NSData * operationalCertificate, +BOOL MTROperationalCredentialsDelegate::onNOCChainGenerationComplete(NSData * operationalCertificate, NSData * intermediateCertificate, NSData * rootCertificate, NSData * _Nullable ipk, NSNumber * _Nullable adminSubject, NSError * __autoreleasing * error) { if (operationalCertificate == nil || intermediateCertificate == nil || rootCertificate == nil) { setNSError(CHIP_ERROR_INVALID_ARGUMENT, error); - return; + return NO; } // use ipk and adminSubject from CommissioningParameters if not passed in. @@ -240,7 +240,7 @@ }); if (!commissioningParameters.HasValue()) { setNSError(CHIP_ERROR_INCORRECT_STATE, error); - return; + return NO; } chip::Optional ipkOptional; @@ -249,7 +249,7 @@ if (ipk != nil) { if ([ipk length] != sizeof(ipkValue)) { setNSError(CHIP_ERROR_INCORRECT_STATE, error); - return; + return NO; } memcpy(&ipkValue[0], [ipk bytes], [ipk length]); ipkOptional.SetValue(ipkTempSpan); @@ -273,7 +273,9 @@ if (err != CHIP_NO_ERROR) { MTR_LOG_ERROR("Failed to SetNocChain for the device: %" CHIP_ERROR_FORMAT, err.Format()); setNSError(CHIP_ERROR_INCORRECT_STATE, error); + return NO; } + return YES; } CHIP_ERROR MTROperationalCredentialsDelegate::LocalGenerateNOCChain(const chip::ByteSpan & csrElements,