Skip to content

Commit

Permalink
Merge pull request #13 from SiliconLabs/release2.8.0
Browse files Browse the repository at this point in the history
BTAPP-1610 | Matter support into EFR Connect Mobile App
  • Loading branch information
mantosh83 committed Dec 15, 2023
2 parents bff515d + 7415794 commit 4b5c403
Show file tree
Hide file tree
Showing 171 changed files with 88,536 additions and 221 deletions.
81 changes: 81 additions & 0 deletions Matter.framework/Headers/MTRAsyncCallbackWorkQueue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
*
* 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

@class MTRAsyncCallbackQueueWorkItem;

typedef void (^MTRAsyncCallbackReadyHandler)(id context, NSUInteger retryCount);

// MTRAsyncCallbackQueue high level description
// The MTRAsyncCallbackQueue was made to call one readyHandler
// block at a time asynchronously, and the readyHandler is
// expected to start/schedule a task. When the task finishes
// asynchronously in the future (at any time, from any queue
// or thread), it is expected to ask the workItem object to
// either endWork or retryWork.

// Sequence of steps when queuing a work item:
// - Create MTRAsyncCallbackQueueWorkItem object
// - Create ready handler block (MTRAsyncCallbackReadyHandler)
// - block is called when it's the WorkItem's turn to do work
// - its body is to perform a task that is expected to end asynchronously in the future
// - at the end of work, call on the work item object:
// - endWork for success or failure
// - retryWork for temporary failures
// - Set the readyHandler block on the WorkItem object
// - Call enqueueWorkItem on a MTRAsyncCallbackQueue

// A serial one-at-a-time queue for performing work items
@interface MTRAsyncCallbackWorkQueue : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

// The context object is only held and passed back as a reference and is opaque to the work queue
- (instancetype)initWithContext:(id _Nullable)context queue:(dispatch_queue_t)queue;

// Called by the work queue owner to clean up and cancel work items
- (void)invalidate;

// Work items may be enqueued from any queue or thread
- (void)enqueueWorkItem:(MTRAsyncCallbackQueueWorkItem *)item;

// TODO: Add a "set concurrency width" method to allow for more than 1 work item at a time
@end

// An item in the work queue
@interface MTRAsyncCallbackQueueWorkItem : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

// Both readyHandler and cancelHander will be called on the queue given to initWithQueue
- (instancetype)initWithQueue:(dispatch_queue_t)queue;
@property (nonatomic, strong) MTRAsyncCallbackReadyHandler readyHandler;
@property (nonatomic, strong) dispatch_block_t cancelHandler;

// Called by the creater of the work item when async work is done and should
// be removed from the queue. The work queue will run the next work item.
- (void)endWork;

// Called by the creater of the work item when async work should be retried.
// The work queue will call this workItem's readyHandler again.
- (void)retryWork;
@end

NS_ASSUME_NONNULL_END
46,878 changes: 46,878 additions & 0 deletions Matter.framework/Headers/MTRBaseClusters.h

Large diffs are not rendered by default.

731 changes: 731 additions & 0 deletions Matter.framework/Headers/MTRBaseDevice.h

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions Matter.framework/Headers/MTRCSRInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
*
* Copyright (c) 2022-2023 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/MTRCommandPayloadsObjc.h>
#import <Matter/MTRDefines.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Represents information relating to a certificate signing request for a Matter
* operational certificate.
*/
API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
@interface MTROperationalCSRInfo : NSObject

/**
* DER-encoded certificate signing request.
*/
@property (nonatomic, copy, readonly) MTRCSRDERBytes csr;

/**
* The nonce associated with this CSR.
*/
@property (nonatomic, copy, readonly) NSData * csrNonce;

/**
* TLV-encoded nocsr-elements structure. This includes the "csr" and "csrNonce"
* fields, and can include additional vendor-specific information.
*/
@property (nonatomic, copy, readonly) MTRTLVBytes csrElementsTLV;

/**
* A signature, using the device attestation private key of the device that
* created the CSR, over the concatenation of csrElementsTLV and the attestation
* challenge from the secure session.
*
* The attestation challenge is available in MTRAttestionInfo.
*/
@property (nonatomic, copy, readonly) NSData * attestationSignature;

/**
* Initialize an MTROperationalCSRInfo by providing all the fields. It's the
* caller's responsibility to ensure that csr and csrNonce match the csrElementsTLV.
*/
- (instancetype)initWithCSR:(MTRCSRDERBytes)csr
csrNonce:(NSData *)csrNonce
csrElementsTLV:(MTRTLVBytes)csrElementsTLV
attestationSignature:(NSData *)attestationSignature
MTR_NEWLY_DEPRECATED("Please use one of the initializers that validates the input");

/**
* Initialize an MTROperationalCSRInfo by providing the csrNonce (for example,
* the nonce the client initially supplied), and the csrElementsTLV and
* attestationSignature that the server returned. This will ensure that
* csrNonce matches the data in csrElementsTLV, returning nil if it does not,
* and extract the csr from csrElementsTLV.
*/
- (nullable instancetype)initWithCSRNonce:(NSData *)csrNonce
csrElementsTLV:(MTRTLVBytes)csrElementsTLV
attestationSignature:(NSData *)attestationSignature MTR_NEWLY_AVAILABLE;

/**
* Initialize an MTROperationalCSRInfo by providing just the csrElementsTLV and
* attestationSignature (which can come from an
* MTROperationalCredentialsClusterCSRResponseParams). This will extract the
* csr and csrNonce from the csrElementsTLV, if possible, and return nil if that
* fails.
*/
- (nullable instancetype)initWithCSRElementsTLV:(MTRTLVBytes)csrElementsTLV
attestationSignature:(NSData *)attestationSignature MTR_NEWLY_AVAILABLE;

/**
* Initialize an MTROperationalCSRInfo by providing an
* MTROperationalCredentialsClusterCSRResponseParams. This will extract the
* relevant fields from the response data.
*/
- (nullable instancetype)initWithCSRResponseParams:(MTROperationalCredentialsClusterCSRResponseParams *)responseParams
MTR_NEWLY_AVAILABLE;
@end

MTR_DEPRECATED("Please use MTROperationalCSRInfo", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4))
@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
112 changes: 112 additions & 0 deletions Matter.framework/Headers/MTRCertificateInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* Copyright (c) 2023 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/MTRCertificates.h>

NS_ASSUME_NONNULL_BEGIN

@class MTRDistinguishedNameInfo;

/**
* Exposes Matter-specific information from an operational X.509 certificate.
*
* Note: This class does not support parsing certificates related to Device Attestation.
*/
NS_SWIFT_SENDABLE
API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
@interface MTRCertificateInfo : NSObject <NSCopying>

+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;

/**
* Initializes the receiver with an operational certificate in Matter TLV format.
*
* This can be a node operational certificate, a Matter intermediate
* certificate, or a Matter root certificate.
*/
- (nullable instancetype)initWithTLVBytes:(MTRCertificateTLVBytes)bytes;

/**
* The Distinguished Name of the issuer of the certificate.
*
* For a node operational certificate, the issuer will match the subject of the
* root certificate or intermediate certificate that represents the entity that
* issued the node operational certificate.
*
* For an intermediate certificate, the issuer will match the subject of the
* root certificate.
*
* Matter root certificates are self-signed, i.e. the issuer and the subject are
* the same.
*/
@property (readonly) MTRDistinguishedNameInfo * issuer;

/**
* The Distinguished Name of the entity represented by the certificate.
*/
@property (readonly) MTRDistinguishedNameInfo * subject;

@property (readonly) NSDate * notBefore;
@property (readonly) NSDate * notAfter;

@end

/**
* Represents the Matter-specific components of an X.509 Distinguished Name.
*/
NS_SWIFT_SENDABLE
API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
@interface MTRDistinguishedNameInfo : NSObject <NSCopying>

+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;

/**
* The Node ID contained in the DN, if any. Will be non-nil for the subject of
* a valid node operational certificate.
*/
@property (readonly, nullable) NSNumber * nodeID;

/**
* The Fabric ID contained in the DN, if any. Will be non-nil for the subject
* of a valid node operational certificate, and may be non-nil for the subject
* of a valid intermediate or root certificate.
*/
@property (readonly, nullable) NSNumber * fabricID;

/**
* The `RCAC` ID contained in the DN, if any. Will be non-nil for the subject
* of a valid root certificate.
*/
@property (readonly, nullable) NSNumber * rootCACertificateID;

/**
* The `ICAC` ID contained in the DN, if any. Will be non-nil for the subject
* of a valid intermediate certificate.
*/
@property (readonly, nullable) NSNumber * intermediateCACertificateID;

/**
* The set of CASE Authenticated Tags contained in the DN. Maybe be non-empty for
* the subject of a valid node operational certificate.
*/
@property (readonly) NSSet<NSNumber *> * caseAuthenticatedTags;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 4b5c403

Please sign in to comment.