-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding darwin callbacks for NOC Generation (#21705)
* Adding darwin callbacks for NOC Generation * Fixing compiler errors in new dependencies in src/credentials * Addressing feedback from woody-apple@ and bzbarsky-apple@ * Addressing second round of feedback * Address feedback around returning errors and adding comments * Adding comments Co-authored-by: Justin Wood <woody@apple.com>
- Loading branch information
Showing
15 changed files
with
513 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Represents information relating to product attestation. | ||
* | ||
*/ | ||
@interface AttestationInfo : NSObject | ||
|
||
@property (nonatomic, copy) NSData * challenge; | ||
|
||
@property (nonatomic, copy) NSData * nonce; | ||
|
||
@property (nonatomic, copy) NSData * elements; | ||
|
||
@property (nonatomic, copy) NSData * elementsSignature; | ||
|
||
@property (nonatomic, copy) NSData * dac; | ||
|
||
@property (nonatomic, copy) NSData * pai; | ||
|
||
@property (nonatomic, copy) NSData * certificationDeclaration; | ||
|
||
@property (nonatomic, copy) NSData * firmwareInfo; | ||
|
||
- (instancetype)initWithChallenge:(NSData *)challenge | ||
nonce:(NSData *)nonce | ||
elements:(NSData *)elements | ||
elementsSignature:(NSData *)elementsSignature | ||
dac:(NSData *)dac | ||
pai:(NSData *)pai | ||
certificationDeclaration:(NSData *)certificationDeclaration | ||
firmwareInfo:(NSData *)firmwareInfo; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "MTRAttestationInfo.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation AttestationInfo : NSObject | ||
|
||
- (instancetype)initWithChallenge:(NSData *)challenge | ||
nonce:(NSData *)nonce | ||
elements:(NSData *)elements | ||
elementsSignature:(NSData *)elementsSignature | ||
dac:(NSData *)dac | ||
pai:(NSData *)pai | ||
certificationDeclaration:(NSData *)certificationDeclaration | ||
firmwareInfo:(NSData *)firmwareInfo | ||
{ | ||
if (self = [super init]) { | ||
_challenge = challenge; | ||
_nonce = nonce; | ||
_elements = elements; | ||
_elementsSignature = elementsSignature; | ||
_dac = dac; | ||
_pai = pai; | ||
_certificationDeclaration = certificationDeclaration; | ||
_firmwareInfo = firmwareInfo; | ||
} | ||
return self; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Represents information relating to NOC CSR. | ||
* | ||
*/ | ||
@interface CSRInfo : NSObject | ||
|
||
@property (nonatomic, copy) NSData * nonce; | ||
|
||
@property (nonatomic, copy) NSData * elements; | ||
|
||
@property (nonatomic, copy) NSData * elementsSignature; | ||
|
||
@property (nonatomic, copy) NSData * csr; | ||
|
||
- (instancetype)initWithNonce:(NSData *)nonce | ||
elements:(NSData *)elements | ||
elementsSignature:(NSData *)elementsSignature | ||
csr:(NSData *)csr; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "MTRCSRInfo.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation CSRInfo : NSObject | ||
|
||
- (instancetype)initWithNonce:(NSData *)nonce | ||
elements:(NSData *)elements | ||
elementsSignature:(NSData *)elementsSignature | ||
csr:(NSData *)csr | ||
{ | ||
if (self = [super init]) { | ||
_nonce = nonce; | ||
_elements = elements; | ||
_elementsSignature = elementsSignature; | ||
_csr = csr; | ||
} | ||
return self; | ||
} | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <Matter/MTRAttestationInfo.h> | ||
#import <Matter/MTRCSRInfo.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol MTRNOCChainIssuer <NSObject> | ||
@required | ||
|
||
/** | ||
* @brief When a MTRNOCChainIssuer is set for the MTRDeviceController, then onNOCChainGenerationNeeded will be | ||
* called when the NOC CSR needs to be signed. This allows for custom credentials issuer | ||
* implementations, for example, when a proprietary cloud API will perform the CSR signing. | ||
* The commissioning workflow will stop upon the onNOCChainGenerationNeeded callback and | ||
* resume once onNOCChainGenerationComplete is called | ||
* The following fields MUST be passed to onNOCChainGenerationComplete with non-nil values: | ||
* rootCertificate, intermediateCertificate, operationalCertificate. | ||
* If ipk and adminSubject are passed, then they will be used in | ||
* the AddNOC command sent to the commissionee. If they are not passed, then the values | ||
* provided in the MTRDeviceController initialization will be used. | ||
* | ||
* All csr and attestation fields are provided to allow for custom attestestation checks. | ||
*/ | ||
- (void)onNOCChainGenerationNeeded:(CSRInfo *)csrInfo | ||
attestationInfo:(AttestationInfo *)attestationInfo | ||
onNOCChainGenerationComplete:(void (^)(NSData * operationalCertificate, NSData * intermediateCertificate, | ||
NSData * rootCertificate, NSData * ipk, NSNumber * adminSubject, | ||
NSError * __autoreleasing * error))onNOCChainGenerationComplete; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.