Skip to content

Commit d014976

Browse files
authored
Merge branch 'master' into feature/message-cluster-present-message-update
2 parents 8e90ee8 + 058f199 commit d014976

23 files changed

+2007
-7
lines changed

examples/darwin-framework-tool/BUILD.gn

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ declare_args() {
4242
}
4343

4444
enable_provisional_features = config_enable_yaml_tests
45+
46+
# Disable generating compiler database by default
47+
generate_compilation_database = false
4548
}
4649

4750
sdk = "macosx"
@@ -107,6 +110,12 @@ action("build-darwin-framework") {
107110
args += [ "--no-clang" ]
108111
}
109112

113+
if (generate_compilation_database) {
114+
args += [ "--compdb" ]
115+
} else {
116+
args += [ "--no-compdb" ]
117+
}
118+
110119
if (config_enable_yaml_tests) {
111120
args += [ "--enable-encoding-sentinel-enum-values" ]
112121
} else {

scripts/build/build_darwin_framework.py

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ def build_darwin_framework(args):
129129
if args.enable_encoding_sentinel_enum_values:
130130
cflags += ["-DCHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES=1"]
131131

132+
if args.compdb:
133+
cflags += ["-gen-cdb-fragment-path ", abs_path + '/compdb']
134+
132135
command += ["OTHER_CFLAGS=" + ' '.join(cflags), "OTHER_LDFLAGS=" + ' '.join(ldflags)]
133136
command_result = run_command(command)
134137
print("Build Framework Result: {}".format(command_result))
@@ -172,6 +175,7 @@ def build_darwin_framework(args):
172175
parser.add_argument('--ble', action=argparse.BooleanOptionalAction)
173176
parser.add_argument('--clang', action=argparse.BooleanOptionalAction)
174177
parser.add_argument('--enable-encoding-sentinel-enum-values', action=argparse.BooleanOptionalAction)
178+
parser.add_argument('--compdb', action=argparse.BooleanOptionalAction)
175179

176180
args = parser.parse_args()
177181
build_darwin_framework(args)
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2020-2023 Project CHIP Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
JQ=$(which jq)
19+
if [ $? -ne 0 ]; then
20+
echo "'jq' not detected in PATH. Install using: brew install jq"
21+
exit 1
22+
fi
23+
24+
set -e
25+
set -x
26+
27+
source "$(dirname "$0")/../../scripts/activate.sh"
28+
CHIP_ROOT="$(dirname "$0")/../.."
29+
OUTPUT_DIR=$2
30+
31+
# Build the framework
32+
scripts/examples/gn_build_example.sh "$@" generate_compilation_database=true
33+
34+
# Clean up any stale DB files
35+
find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs rm
36+
37+
# Construct json from fragments generated by xcodebuild
38+
COMPDB_FRAGMENTS_DIR=$(find "$OUTPUT_DIR" -type d -name compdb)
39+
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' "$COMPDB_FRAGMENTS_DIR"/*.json >"$OUTPUT_DIR"/compile_commands_darwin_framework.json
40+
41+
# Get ninja to build comdb for the rest
42+
ninja -C "$OUTPUT_DIR" -t compdb >"$OUTPUT_DIR"/compile_commands_rest.json
43+
44+
# Combine the generated compdb into one
45+
find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs jq -s 'map(.[])' >"$OUTPUT_DIR"/compile_commands.json

src/controller/java/AndroidDeviceControllerWrapper.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ CHIP_ERROR AndroidDeviceControllerWrapper::UpdateDeviceAttestationDelegateBridge
543543
return err;
544544
}
545545

546-
CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate)
546+
CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate,
547+
jobject cdTrustKeys)
547548
{
548549
CHIP_ERROR err = CHIP_NO_ERROR;
549550

@@ -566,6 +567,29 @@ CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(job
566567
}
567568
mDeviceAttestationVerifier = deviceAttestationVerifier;
568569

570+
if (cdTrustKeys != nullptr)
571+
{
572+
WellKnownKeysTrustStore * cdTrustStore = mDeviceAttestationVerifier->GetCertificationDeclarationTrustStore();
573+
VerifyOrExit(cdTrustStore != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
574+
575+
jint size;
576+
err = JniReferences::GetInstance().GetListSize(cdTrustKeys, size);
577+
VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT);
578+
579+
for (jint i = 0; i < size; i++)
580+
{
581+
jobject jTrustKey = nullptr;
582+
err = JniReferences::GetInstance().GetListItem(cdTrustKeys, i, jTrustKey);
583+
584+
VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT);
585+
586+
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
587+
JniByteArray jniTrustKey(env, static_cast<jbyteArray>(jTrustKey));
588+
err = cdTrustStore->AddTrustedKey(jniTrustKey.byteSpan());
589+
VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT);
590+
}
591+
}
592+
569593
mController->SetDeviceAttestationVerifier(mDeviceAttestationVerifier);
570594

571595
exit:

src/controller/java/AndroidDeviceControllerWrapper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
202202
CHIP_ERROR UpdateDeviceAttestationDelegateBridge(jobject deviceAttestationDelegate, chip::Optional<uint16_t> expiryTimeoutSecs,
203203
bool shouldWaitAfterDeviceAttestation);
204204

205-
CHIP_ERROR UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate);
205+
CHIP_ERROR UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate, jobject cdTrustKeys);
206206

207207
CHIP_ERROR StartOTAProvider(jobject otaProviderDelegate);
208208

src/controller/java/CHIPDeviceController-JNI.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ JNI_METHOD(void, setDeviceAttestationDelegate)
533533
}
534534

535535
JNI_METHOD(void, setAttestationTrustStoreDelegate)
536-
(JNIEnv * env, jobject self, jlong handle, jobject attestationTrustStoreDelegate)
536+
(JNIEnv * env, jobject self, jlong handle, jobject attestationTrustStoreDelegate, jobject cdTrustKeys)
537537
{
538538
chip::DeviceLayer::StackLock lock;
539539
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -544,7 +544,7 @@ JNI_METHOD(void, setAttestationTrustStoreDelegate)
544544
if (attestationTrustStoreDelegate != nullptr)
545545
{
546546
jobject attestationTrustStoreDelegateRef = env->NewGlobalRef(attestationTrustStoreDelegate);
547-
err = wrapper->UpdateAttestationTrustStoreBridge(attestationTrustStoreDelegateRef);
547+
err = wrapper->UpdateAttestationTrustStoreBridge(attestationTrustStoreDelegateRef, cdTrustKeys);
548548
SuccessOrExit(err);
549549
}
550550

src/controller/java/src/chip/devicecontroller/ChipDeviceController.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import android.bluetooth.BluetoothGatt;
2121
import android.util.Log;
22+
import chip.devicecontroller.ChipDeviceController.CompletionListener;
2223
import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCallback;
2324
import chip.devicecontroller.model.AttributeWriteRequest;
2425
import chip.devicecontroller.model.ChipAttributePath;
@@ -117,10 +118,18 @@ public void setDeviceAttestationDelegate(
117118
* paa certificates before commissioning.
118119
*
119120
* @param attestationTrustStoreDelegate Delegate for attestation trust store
121+
* @param cdTrustKeys certification Declaration Trust Keys
120122
*/
123+
public void setAttestationTrustStoreDelegate(
124+
AttestationTrustStoreDelegate attestationTrustStoreDelegate,
125+
@Nullable List<byte[]> cdTrustKeys) {
126+
setAttestationTrustStoreDelegate(
127+
deviceControllerPtr, attestationTrustStoreDelegate, cdTrustKeys);
128+
}
129+
121130
public void setAttestationTrustStoreDelegate(
122131
AttestationTrustStoreDelegate attestationTrustStoreDelegate) {
123-
setAttestationTrustStoreDelegate(deviceControllerPtr, attestationTrustStoreDelegate);
132+
setAttestationTrustStoreDelegate(deviceControllerPtr, attestationTrustStoreDelegate, null);
124133
}
125134

126135
/**
@@ -1367,7 +1376,9 @@ private native void setDeviceAttestationDelegate(
13671376
long deviceControllerPtr, int failSafeExpiryTimeoutSecs, DeviceAttestationDelegate delegate);
13681377

13691378
private native void setAttestationTrustStoreDelegate(
1370-
long deviceControllerPtr, AttestationTrustStoreDelegate delegate);
1379+
long deviceControllerPtr,
1380+
AttestationTrustStoreDelegate delegate,
1381+
@Nullable List<byte[]> cdTrustKeys);
13711382

13721383
private native void startOTAProvider(long deviceControllerPtr, OTAProviderDelegate delegate);
13731384

src/darwin/Framework/CHIP/Matter.h

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#define MTR_INCLUDED_FROM_UMBRELLA_HEADER
2121

22+
#import <Matter/MTRAccessGrant.h>
2223
#import <Matter/MTRAsyncCallbackWorkQueue.h>
2324
#import <Matter/MTRBackwardsCompatShims.h>
2425
#import <Matter/MTRBaseClusters.h>
@@ -45,6 +46,7 @@
4546
#import <Matter/MTRDeviceControllerParameters.h>
4647
#import <Matter/MTRDeviceControllerStartupParams.h>
4748
#import <Matter/MTRDeviceControllerStorageDelegate.h>
49+
#import <Matter/MTRDeviceTypeRevision.h>
4850
#import <Matter/MTRDiagnosticLogsType.h>
4951
#import <Matter/MTRError.h>
5052
#import <Matter/MTRFabricInfo.h>
@@ -56,6 +58,9 @@
5658
#import <Matter/MTROnboardingPayloadParser.h>
5759
#import <Matter/MTROperationalCertificateIssuer.h>
5860
#import <Matter/MTRQRCodeSetupPayloadParser.h>
61+
#import <Matter/MTRServerAttribute.h>
62+
#import <Matter/MTRServerCluster.h>
63+
#import <Matter/MTRServerEndpoint.h>
5964
#import <Matter/MTRSetupPayload.h>
6065
#import <Matter/MTRStorage.h>
6166
#import <Matter/MTRStructsObjc.h>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
#import <Matter/MTRBaseClusters.h>
19+
#import <Matter/MTRDefines.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
/**
24+
* An access grant, which can be represented as an entry in the Matter Access
25+
* Control cluster.
26+
*/
27+
MTR_NEWLY_AVAILABLE
28+
@interface MTRAccessGrant : NSObject <NSCopying>
29+
30+
- (instancetype)init NS_UNAVAILABLE;
31+
+ (instancetype)new NS_UNAVAILABLE;
32+
33+
/**
34+
* Grant access at the provided level to a specific node on the fabric. The
35+
* provided nodeID must be an operational node identifier.
36+
*/
37+
+ (nullable MTRAccessGrant *)accessGrantForNodeID:(NSNumber *)nodeID privilege:(MTRAccessControlEntryPrivilege)privilege;
38+
39+
/**
40+
* Grant access to any node on the fabric that has a matching CASE Authenticated
41+
* Tag in its operational certificate. The provided caseAuthenticatedTag must
42+
* be a 32-bit unsigned integer with lower 16 bits not 0, per the Matter
43+
* specification.
44+
*/
45+
+ (nullable MTRAccessGrant *)accessGrantForCASEAuthenticatedTag:(NSNumber *)caseAuthenticatedTag privilege:(MTRAccessControlEntryPrivilege)privilege;
46+
47+
/**
48+
* Grant access to any node on the fabric that is communicating with us via
49+
* group messages sent to the given group. The provided groupID must be a valid
50+
* group identifier in the range 1-65535.
51+
*/
52+
+ (nullable MTRAccessGrant *)accessGrantForGroupID:(NSNumber *)groupID privilege:(MTRAccessControlEntryPrivilege)privilege;
53+
54+
/**
55+
* Grant access to any node on the fabric, as long as it's communicating with us
56+
* over a unicast authenticated channel.
57+
*/
58+
+ (MTRAccessGrant *)accessGrantForAllNodesWithPrivilege:(MTRAccessControlEntryPrivilege)privilege;
59+
60+
/**
61+
* The matter access control subject ID that access has been granted for. Nil
62+
* when access has been granted for all subjects (e.g. via initForAllNodesWithPrivilege).
63+
*/
64+
@property (nonatomic, copy, readonly, nullable) NSNumber * subjectID;
65+
66+
/**
67+
* The privilege that has been granted
68+
*/
69+
@property (nonatomic, assign, readonly) MTRAccessControlEntryPrivilege grantedPrivilege;
70+
71+
/**
72+
* The type of authentication mode the access grant is
73+
* for. MTRAccessControlEntryAuthModeCASE for unicast messages and
74+
* MTRAccessControlEntryAuthModeGroup for groupcast ones.
75+
*/
76+
@property (nonatomic, assign, readonly) MTRAccessControlEntryAuthMode authenticationMode;
77+
78+
@end
79+
80+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)