@matter/protocol 0.15.0-alpha.0-20250616-4b3754906 → 0.15.0-alpha.0-20250619-df2264f15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.js +26 -22
- package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -2
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js +22 -29
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +2 -6
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/certificate/index.d.ts +7 -2
- package/dist/cjs/certificate/index.d.ts.map +1 -1
- package/dist/cjs/certificate/index.js +14 -2
- package/dist/cjs/certificate/index.js.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +34 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.js +64 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +6 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +23 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js +86 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +6 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts +29 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Icac.js +138 -0
- package/dist/cjs/certificate/kinds/Icac.js.map +6 -0
- package/dist/cjs/certificate/kinds/Noc.d.ts +27 -0
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Noc.js +148 -0
- package/dist/cjs/certificate/kinds/Noc.js.map +6 -0
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts +24 -0
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/OperationalBase.js +68 -0
- package/dist/cjs/certificate/kinds/OperationalBase.js.map +6 -0
- package/dist/cjs/certificate/kinds/Rcac.d.ts +25 -0
- package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Rcac.js +119 -0
- package/dist/cjs/certificate/kinds/Rcac.js.map +6 -0
- package/dist/cjs/certificate/kinds/X509Base.d.ts +92 -0
- package/dist/cjs/certificate/kinds/X509Base.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/X509Base.js +344 -0
- package/dist/cjs/certificate/kinds/X509Base.js.map +6 -0
- package/dist/cjs/certificate/kinds/common.d.ts +18 -0
- package/dist/cjs/certificate/kinds/common.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/common.js +42 -0
- package/dist/cjs/certificate/kinds/common.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts +25 -0
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/asn.js +83 -0
- package/dist/cjs/certificate/kinds/definitions/asn.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts +44 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.js +22 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts +52 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/base.js +43 -0
- package/dist/cjs/certificate/kinds/definitions/base.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.js +50 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts +368 -0
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/operational.js +149 -0
- package/dist/cjs/certificate/kinds/definitions/operational.js.map +6 -0
- package/dist/cjs/certificate/kinds/index.d.ts +12 -0
- package/dist/cjs/certificate/kinds/index.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/index.js +29 -0
- package/dist/cjs/certificate/kinds/index.js.map +6 -0
- package/dist/cjs/fabric/Fabric.d.ts +1 -2
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +28 -31
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +3 -3
- package/dist/cjs/session/case/CaseClient.js.map +1 -1
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +2 -2
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.js +20 -16
- package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -2
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js +18 -30
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +2 -6
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/certificate/index.d.ts +7 -2
- package/dist/esm/certificate/index.d.ts.map +1 -1
- package/dist/esm/certificate/index.js +10 -2
- package/dist/esm/certificate/index.js.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +34 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.js +44 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.js.map +6 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +23 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.js +66 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +6 -0
- package/dist/esm/certificate/kinds/Icac.d.ts +29 -0
- package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Icac.js +118 -0
- package/dist/esm/certificate/kinds/Icac.js.map +6 -0
- package/dist/esm/certificate/kinds/Noc.d.ts +27 -0
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Noc.js +128 -0
- package/dist/esm/certificate/kinds/Noc.js.map +6 -0
- package/dist/esm/certificate/kinds/OperationalBase.d.ts +24 -0
- package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/OperationalBase.js +48 -0
- package/dist/esm/certificate/kinds/OperationalBase.js.map +6 -0
- package/dist/esm/certificate/kinds/Rcac.d.ts +25 -0
- package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Rcac.js +99 -0
- package/dist/esm/certificate/kinds/Rcac.js.map +6 -0
- package/dist/esm/certificate/kinds/X509Base.d.ts +92 -0
- package/dist/esm/certificate/kinds/X509Base.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/X509Base.js +347 -0
- package/dist/esm/certificate/kinds/X509Base.js.map +6 -0
- package/dist/esm/certificate/kinds/common.d.ts +18 -0
- package/dist/esm/certificate/kinds/common.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/common.js +22 -0
- package/dist/esm/certificate/kinds/common.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/asn.d.ts +25 -0
- package/dist/esm/certificate/kinds/definitions/asn.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/asn.js +63 -0
- package/dist/esm/certificate/kinds/definitions/asn.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts +44 -0
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/attestation.js +6 -0
- package/dist/esm/certificate/kinds/definitions/attestation.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts +52 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/base.js +23 -0
- package/dist/esm/certificate/kinds/definitions/base.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.js +41 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/operational.d.ts +368 -0
- package/dist/esm/certificate/kinds/definitions/operational.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/operational.js +148 -0
- package/dist/esm/certificate/kinds/definitions/operational.js.map +6 -0
- package/dist/esm/certificate/kinds/index.d.ts +12 -0
- package/dist/esm/certificate/kinds/index.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/index.js +12 -0
- package/dist/esm/certificate/kinds/index.js.map +6 -0
- package/dist/esm/fabric/Fabric.d.ts +1 -2
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +28 -36
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +2 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +3 -3
- package/dist/esm/session/case/CaseClient.js.map +1 -1
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +2 -2
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/certificate/AttestationCertificateManager.ts +20 -16
- package/src/certificate/CertificateAuthority.ts +18 -35
- package/src/certificate/DeviceCertification.ts +2 -6
- package/src/certificate/index.ts +7 -2
- package/src/certificate/kinds/AttestationCertificates.ts +48 -0
- package/src/certificate/kinds/CertificationDeclaration.ts +91 -0
- package/src/certificate/kinds/Icac.ts +156 -0
- package/src/certificate/kinds/Noc.ts +164 -0
- package/src/certificate/kinds/OperationalBase.ts +72 -0
- package/src/certificate/kinds/Rcac.ts +126 -0
- package/src/certificate/kinds/X509Base.ts +380 -0
- package/src/certificate/kinds/common.ts +24 -0
- package/src/certificate/kinds/definitions/asn.ts +97 -0
- package/src/certificate/kinds/definitions/attestation.ts +46 -0
- package/src/certificate/kinds/definitions/base.ts +43 -0
- package/src/certificate/kinds/definitions/certification-declaration.ts +38 -0
- package/src/certificate/kinds/definitions/operational.ts +179 -0
- package/src/certificate/kinds/index.ts +12 -0
- package/src/fabric/Fabric.ts +28 -40
- package/src/peer/ControllerCommissioningFlow.ts +2 -1
- package/src/session/case/CaseClient.ts +3 -3
- package/src/session/case/CaseServer.ts +2 -2
- package/dist/cjs/certificate/CertificateManager.d.ts +0 -578
- package/dist/cjs/certificate/CertificateManager.d.ts.map +0 -1
- package/dist/cjs/certificate/CertificateManager.js +0 -843
- package/dist/cjs/certificate/CertificateManager.js.map +0 -6
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +0 -11
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +0 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.js +0 -54
- package/dist/cjs/certificate/CertificationDeclarationManager.js.map +0 -6
- package/dist/esm/certificate/CertificateManager.d.ts +0 -578
- package/dist/esm/certificate/CertificateManager.d.ts.map +0 -1
- package/dist/esm/certificate/CertificateManager.js +0 -870
- package/dist/esm/certificate/CertificateManager.js.map +0 -6
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts +0 -11
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +0 -1
- package/dist/esm/certificate/CertificationDeclarationManager.js +0 -34
- package/dist/esm/certificate/CertificationDeclarationManager.js.map +0 -6
- package/src/certificate/CertificateManager.ts +0 -1176
- package/src/certificate/CertificationDeclarationManager.ts +0 -52
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Bytes,
|
|
9
|
+
ContextTagged,
|
|
10
|
+
Crypto,
|
|
11
|
+
DatatypeOverride,
|
|
12
|
+
DerBitString,
|
|
13
|
+
DerCodec,
|
|
14
|
+
DerKey,
|
|
15
|
+
DerType,
|
|
16
|
+
Key,
|
|
17
|
+
PublicKey,
|
|
18
|
+
RawBytes,
|
|
19
|
+
X509,
|
|
20
|
+
X520,
|
|
21
|
+
X962,
|
|
22
|
+
} from "#general";
|
|
23
|
+
import { CaseAuthenticatedTag, FabricId, NodeId, TypeFromPartialBitSchema, VendorId } from "#types";
|
|
24
|
+
import { assertCertificateDerSize, CertificateError, Unsigned } from "./common.js";
|
|
25
|
+
import {
|
|
26
|
+
FabricId_Matter,
|
|
27
|
+
FirmwareSigningId_Matter,
|
|
28
|
+
IcacId_Matter,
|
|
29
|
+
matterToJsDate,
|
|
30
|
+
NocCat_Matter,
|
|
31
|
+
NodeId_Matter,
|
|
32
|
+
ProductId_Matter,
|
|
33
|
+
RcacId_Matter,
|
|
34
|
+
VendorId_Matter,
|
|
35
|
+
} from "./definitions/asn.js";
|
|
36
|
+
import { ExtensionKeyUsageBitmap, ExtensionKeyUsageSchema, X509Certificate } from "./definitions/base.js";
|
|
37
|
+
import { CertificateExtension } from "./definitions/operational.js";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Abstract definition of a X.509 certificate that can be signed and converted to ASN.1 DER format.
|
|
41
|
+
* It also provides two static methods to create a certificate signing request (CSR) and to extract the public key
|
|
42
|
+
* from a CSR.
|
|
43
|
+
*/
|
|
44
|
+
export abstract class X509Base<CT extends X509Certificate> {
|
|
45
|
+
#signature?: Uint8Array;
|
|
46
|
+
#cert: Unsigned<CT>;
|
|
47
|
+
|
|
48
|
+
constructor(cert: CT | Unsigned<CT>) {
|
|
49
|
+
this.#cert = cert;
|
|
50
|
+
if ("signature" in cert) {
|
|
51
|
+
this.#signature = cert.signature;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get cert(): Unsigned<CT> {
|
|
56
|
+
return this.#cert;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get isSigned() {
|
|
60
|
+
return this.#signature !== undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get the signature of the certificate.
|
|
65
|
+
* If the certificate is not signed, it throws a CertificateError.
|
|
66
|
+
*/
|
|
67
|
+
get signature() {
|
|
68
|
+
if (this.#signature === undefined) {
|
|
69
|
+
throw new CertificateError("Certificate is not signed");
|
|
70
|
+
}
|
|
71
|
+
return this.#signature;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Set the signature of the certificate.
|
|
76
|
+
* If the certificate is already signed, it throws a CertificateError.
|
|
77
|
+
*/
|
|
78
|
+
set signature(signature: Uint8Array) {
|
|
79
|
+
if (this.isSigned) {
|
|
80
|
+
throw new CertificateError("Certificate is already signed");
|
|
81
|
+
}
|
|
82
|
+
this.#signature = signature;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Sign the certificate using the provided crypto and key.
|
|
87
|
+
* It throws a CertificateError if the certificate is already signed.
|
|
88
|
+
*/
|
|
89
|
+
async sign(crypto: Crypto, key: JsonWebKey) {
|
|
90
|
+
this.signature = await crypto.signEcdsa(key, this.asUnsignedAsn1());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Convert the certificate to ASN.1 DER format without signature.
|
|
95
|
+
*/
|
|
96
|
+
asUnsignedAsn1(): Uint8Array<ArrayBufferLike> {
|
|
97
|
+
const certBytes = DerCodec.encode(this.genericBuildAsn1Structure(this.cert));
|
|
98
|
+
assertCertificateDerSize(certBytes);
|
|
99
|
+
return certBytes;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Convert the subject or issuer field of the certificate to ASN.1 DER format.
|
|
104
|
+
* Preserve order of keys from original subject and also copy potential custom elements
|
|
105
|
+
*/
|
|
106
|
+
#subjectOrIssuerToAsn1(data: { [field: string]: any }) {
|
|
107
|
+
const asn = {} as { [field: string]: any[] };
|
|
108
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
109
|
+
if (value === undefined) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
switch (key) {
|
|
113
|
+
case "commonName":
|
|
114
|
+
asn.commonName = X520.CommonName(value as string);
|
|
115
|
+
break;
|
|
116
|
+
case "sureName":
|
|
117
|
+
asn.sureName = X520.SurName(value as string);
|
|
118
|
+
break;
|
|
119
|
+
case "serialNum":
|
|
120
|
+
asn.serialNum = X520.SerialNumber(value as string);
|
|
121
|
+
break;
|
|
122
|
+
case "countryName":
|
|
123
|
+
asn.countryName = X520.CountryName(value as string);
|
|
124
|
+
break;
|
|
125
|
+
case "localityName":
|
|
126
|
+
asn.localityName = X520.LocalityName(value as string);
|
|
127
|
+
break;
|
|
128
|
+
case "stateOrProvinceName":
|
|
129
|
+
asn.stateOrProvinceName = X520.StateOrProvinceName(value as string);
|
|
130
|
+
break;
|
|
131
|
+
case "orgName":
|
|
132
|
+
asn.orgName = X520.OrganisationName(value as string);
|
|
133
|
+
break;
|
|
134
|
+
case "orgUnitName":
|
|
135
|
+
asn.orgUnitName = X520.OrganizationalUnitName(value as string);
|
|
136
|
+
break;
|
|
137
|
+
case "title":
|
|
138
|
+
asn.title = X520.Title(value as string);
|
|
139
|
+
break;
|
|
140
|
+
case "name":
|
|
141
|
+
asn.name = X520.Name(value as string);
|
|
142
|
+
break;
|
|
143
|
+
case "givenName":
|
|
144
|
+
asn.givenName = X520.GivenName(value as string);
|
|
145
|
+
break;
|
|
146
|
+
case "initials":
|
|
147
|
+
asn.initials = X520.Initials(value as string);
|
|
148
|
+
break;
|
|
149
|
+
case "genQualifier":
|
|
150
|
+
asn.genQualifier = X520.GenerationQualifier(value as string);
|
|
151
|
+
break;
|
|
152
|
+
case "dnQualifier":
|
|
153
|
+
asn.dnQualifier = X520.DnQualifier(value as string);
|
|
154
|
+
break;
|
|
155
|
+
case "pseudonym":
|
|
156
|
+
asn.pseudonym = X520.Pseudonym(value as string);
|
|
157
|
+
break;
|
|
158
|
+
case "domainComponent":
|
|
159
|
+
asn.domainComponent = X520.DomainComponent(value as string);
|
|
160
|
+
break;
|
|
161
|
+
case "nodeId":
|
|
162
|
+
asn.nodeId = NodeId_Matter(value as NodeId);
|
|
163
|
+
break;
|
|
164
|
+
case "firmwareSigningId":
|
|
165
|
+
asn.firmwareSigningId = FirmwareSigningId_Matter(value as number);
|
|
166
|
+
break;
|
|
167
|
+
case "icacId":
|
|
168
|
+
asn.icacId = IcacId_Matter(value as number | bigint);
|
|
169
|
+
break;
|
|
170
|
+
case "rcacId":
|
|
171
|
+
asn.rcacId = RcacId_Matter(value as number | bigint);
|
|
172
|
+
break;
|
|
173
|
+
case "fabricId":
|
|
174
|
+
asn.fabricId = FabricId_Matter(value as FabricId);
|
|
175
|
+
break;
|
|
176
|
+
case "caseAuthenticatedTags":
|
|
177
|
+
// In theory if someone mixes multiple caseAuthenticatedTag fields with other fields we currently would
|
|
178
|
+
// code them in ASN.1 as fields at the first position from the original data which might fail
|
|
179
|
+
// certificate validation. Changing this would require to change Tlv decoding, so lets try that way for now.
|
|
180
|
+
const caseAuthenticatedTags = value as CaseAuthenticatedTag[];
|
|
181
|
+
CaseAuthenticatedTag.validateNocTagList(caseAuthenticatedTags);
|
|
182
|
+
|
|
183
|
+
const cat0 = caseAuthenticatedTags[0];
|
|
184
|
+
const cat1 = caseAuthenticatedTags[1];
|
|
185
|
+
const cat2 = caseAuthenticatedTags[2];
|
|
186
|
+
if (cat0 !== undefined) {
|
|
187
|
+
asn.caseAuthenticatedTag0 = NocCat_Matter(cat0);
|
|
188
|
+
}
|
|
189
|
+
if (cat1 !== undefined) {
|
|
190
|
+
asn.caseAuthenticatedTag1 = NocCat_Matter(cat1);
|
|
191
|
+
}
|
|
192
|
+
if (cat2 !== undefined) {
|
|
193
|
+
asn.caseAuthenticatedTag2 = NocCat_Matter(cat2);
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case "vendorId": // Only relevant for ASN.1 encoding of DAC/PAA/PAI certificates
|
|
197
|
+
asn.vendorId = VendorId_Matter(value as VendorId);
|
|
198
|
+
break;
|
|
199
|
+
case "productId": // Only relevant for ASN.1 encoding of DAC/PAA/PAI certificates
|
|
200
|
+
asn.productId = ProductId_Matter(value as number);
|
|
201
|
+
break;
|
|
202
|
+
case "commonNamePs":
|
|
203
|
+
asn.commonNamePs = X520.CommonName(value as string, true);
|
|
204
|
+
break;
|
|
205
|
+
case "sureNamePs":
|
|
206
|
+
asn.sureNamePs = X520.SurName(value as string, true);
|
|
207
|
+
break;
|
|
208
|
+
case "serialNumPs":
|
|
209
|
+
asn.serialNumPs = X520.SerialNumber(value as string, true);
|
|
210
|
+
break;
|
|
211
|
+
case "countryNamePs":
|
|
212
|
+
asn.countryNamePs = X520.CountryName(value as string, true);
|
|
213
|
+
break;
|
|
214
|
+
case "localityNamePs":
|
|
215
|
+
asn.localityNamePs = X520.LocalityName(value as string, true);
|
|
216
|
+
break;
|
|
217
|
+
case "stateOrProvinceNamePs":
|
|
218
|
+
asn.stateOrProvinceNamePs = X520.StateOrProvinceName(value as string, true);
|
|
219
|
+
break;
|
|
220
|
+
case "orgNamePs":
|
|
221
|
+
asn.orgNamePs = X520.OrganisationName(value as string, true);
|
|
222
|
+
break;
|
|
223
|
+
case "orgUnitNamePs":
|
|
224
|
+
asn.orgUnitNamePs = X520.OrganizationalUnitName(value as string, true);
|
|
225
|
+
break;
|
|
226
|
+
case "titlePs":
|
|
227
|
+
asn.titlePs = X520.Title(value as string, true);
|
|
228
|
+
break;
|
|
229
|
+
case "namePs":
|
|
230
|
+
asn.namePs = X520.Name(value as string, true);
|
|
231
|
+
break;
|
|
232
|
+
case "givenNamePs":
|
|
233
|
+
asn.givenNamePs = X520.GivenName(value as string, true);
|
|
234
|
+
break;
|
|
235
|
+
case "initialsPs":
|
|
236
|
+
asn.initialsPs = X520.Initials(value as string, true);
|
|
237
|
+
break;
|
|
238
|
+
case "genQualifierPs":
|
|
239
|
+
asn.genQualifierPs = X520.GenerationQualifier(value as string, true);
|
|
240
|
+
break;
|
|
241
|
+
case "dnQualifierPs":
|
|
242
|
+
asn.dnQualifierPs = X520.DnQualifier(value as string, true);
|
|
243
|
+
break;
|
|
244
|
+
case "pseudonymPs":
|
|
245
|
+
asn.pseudonymPs = X520.Pseudonym(value as string, true);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
return asn;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Convert the extensions of the certificate to ASN.1 DER format.
|
|
254
|
+
*/
|
|
255
|
+
#extensionsToAsn1(extensions: CertificateExtension) {
|
|
256
|
+
const asn = {} as { [field: string]: any[] | any };
|
|
257
|
+
Object.entries(extensions).forEach(([key, value]) => {
|
|
258
|
+
if (value === undefined) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
switch (key) {
|
|
262
|
+
case "basicConstraints":
|
|
263
|
+
asn.basicConstraints = X509.BasicConstraints(value);
|
|
264
|
+
break;
|
|
265
|
+
case "keyUsage":
|
|
266
|
+
asn.keyUsage = X509.KeyUsage(
|
|
267
|
+
ExtensionKeyUsageSchema.encode(
|
|
268
|
+
value as TypeFromPartialBitSchema<typeof ExtensionKeyUsageBitmap>,
|
|
269
|
+
),
|
|
270
|
+
);
|
|
271
|
+
break;
|
|
272
|
+
case "extendedKeyUsage":
|
|
273
|
+
asn.extendedKeyUsage = X509.ExtendedKeyUsage(value as number[] | undefined);
|
|
274
|
+
break;
|
|
275
|
+
case "subjectKeyIdentifier":
|
|
276
|
+
asn.subjectKeyIdentifier = X509.SubjectKeyIdentifier(value as Uint8Array);
|
|
277
|
+
break;
|
|
278
|
+
case "authorityKeyIdentifier":
|
|
279
|
+
asn.authorityKeyIdentifier = X509.AuthorityKeyIdentifier(value as Uint8Array);
|
|
280
|
+
break;
|
|
281
|
+
case "futureExtension":
|
|
282
|
+
asn.futureExtension = RawBytes(Bytes.concat(...((value as Uint8Array[] | undefined) ?? [])));
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
return asn;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Build the ASN.1 DER structure for the certificate.
|
|
291
|
+
*/
|
|
292
|
+
protected genericBuildAsn1Structure({
|
|
293
|
+
serialNumber,
|
|
294
|
+
notBefore,
|
|
295
|
+
notAfter,
|
|
296
|
+
issuer,
|
|
297
|
+
subject,
|
|
298
|
+
ellipticCurvePublicKey,
|
|
299
|
+
extensions,
|
|
300
|
+
}: Unsigned<CT>) {
|
|
301
|
+
const {
|
|
302
|
+
basicConstraints: { isCa, pathLen },
|
|
303
|
+
} = extensions;
|
|
304
|
+
if (!isCa && pathLen !== undefined) {
|
|
305
|
+
throw new CertificateError("Path length must be undefined for non-CA certificates.");
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
version: ContextTagged(0, 2), // v3
|
|
309
|
+
serialNumber: DatatypeOverride(DerType.Integer, serialNumber),
|
|
310
|
+
signatureAlgorithm: X962.EcdsaWithSHA256,
|
|
311
|
+
issuer: this.#subjectOrIssuerToAsn1(issuer),
|
|
312
|
+
validity: {
|
|
313
|
+
notBefore: matterToJsDate(notBefore),
|
|
314
|
+
notAfter: matterToJsDate(notAfter),
|
|
315
|
+
},
|
|
316
|
+
subject: this.#subjectOrIssuerToAsn1(subject),
|
|
317
|
+
publicKey: X962.PublicKeyEcPrime256v1(ellipticCurvePublicKey),
|
|
318
|
+
extensions: ContextTagged(3, this.#extensionsToAsn1(extensions)),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Create a Certificate Signing Request (CSR) in ASN.1 DER format.
|
|
324
|
+
*/
|
|
325
|
+
static async createCertificateSigningRequest(crypto: Crypto, key: Key) {
|
|
326
|
+
const request = {
|
|
327
|
+
version: 0,
|
|
328
|
+
subject: { organization: X520.OrganisationName("CSR") },
|
|
329
|
+
publicKey: X962.PublicKeyEcPrime256v1(key.publicKey),
|
|
330
|
+
endSignedBytes: ContextTagged(0),
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
return DerCodec.encode({
|
|
334
|
+
request,
|
|
335
|
+
signAlgorithm: X962.EcdsaWithSHA256,
|
|
336
|
+
signature: DerBitString(await crypto.signEcdsa(key, DerCodec.encode(request), "der")),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Extract the public key from a Certificate Signing Request (CSR) in ASN.1 DER format.
|
|
342
|
+
*/
|
|
343
|
+
static async getPublicKeyFromCsr(crypto: Crypto, csr: Uint8Array) {
|
|
344
|
+
const { [DerKey.Elements]: rootElements } = DerCodec.decode(csr);
|
|
345
|
+
if (rootElements?.length !== 3) throw new CertificateError("Invalid CSR data");
|
|
346
|
+
const [requestNode, signAlgorithmNode, signatureNode] = rootElements;
|
|
347
|
+
|
|
348
|
+
// Extract the public key
|
|
349
|
+
const { [DerKey.Elements]: requestElements } = requestNode;
|
|
350
|
+
if (requestElements?.length !== 4) throw new CertificateError("Invalid CSR data");
|
|
351
|
+
const [versionNode, _subjectNode, publicKeyNode] = requestElements;
|
|
352
|
+
const requestVersion = versionNode[DerKey.Bytes][0];
|
|
353
|
+
if (requestVersion !== 0) throw new CertificateError(`Unsupported request version ${requestVersion}`);
|
|
354
|
+
// TODO: verify subject = { OrganisationName: "CSR" }
|
|
355
|
+
|
|
356
|
+
const { [DerKey.Elements]: publicKeyElements } = publicKeyNode;
|
|
357
|
+
if (publicKeyElements?.length !== 2) throw new CertificateError("Invalid CSR data");
|
|
358
|
+
const [_publicKeyTypeNode, publicKeyBytesNode] = publicKeyElements;
|
|
359
|
+
// TODO: verify publicKey algorithm
|
|
360
|
+
const publicKey = publicKeyBytesNode[DerKey.Bytes];
|
|
361
|
+
|
|
362
|
+
// Verify the CSR signature
|
|
363
|
+
if (
|
|
364
|
+
signAlgorithmNode[DerKey.Elements]?.[0]?.[DerKey.Bytes] === undefined ||
|
|
365
|
+
!Bytes.areEqual(
|
|
366
|
+
X962.EcdsaWithSHA256[DerKey.ObjectId][DerKey.Bytes],
|
|
367
|
+
signAlgorithmNode[DerKey.Elements]?.[0]?.[DerKey.Bytes],
|
|
368
|
+
)
|
|
369
|
+
)
|
|
370
|
+
throw new CertificateError("Unsupported signature type");
|
|
371
|
+
await crypto.verifyEcdsa(
|
|
372
|
+
PublicKey(publicKey),
|
|
373
|
+
DerCodec.encode(requestNode),
|
|
374
|
+
signatureNode[DerKey.Bytes],
|
|
375
|
+
"der",
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return publicKey;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ImplementationError, MatterError } from "#general";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Matter specific Certificate Sizes
|
|
10
|
+
* @see {@link MatterSpecification.v13.Core} 6.1.3.
|
|
11
|
+
*/
|
|
12
|
+
export const MAX_DER_CERTIFICATE_SIZE = 600;
|
|
13
|
+
|
|
14
|
+
export class CertificateError extends MatterError {}
|
|
15
|
+
|
|
16
|
+
export type Unsigned<Type> = { [Property in keyof Type as Exclude<Property, "signature">]: Type[Property] };
|
|
17
|
+
|
|
18
|
+
export function assertCertificateDerSize(certBytes: Uint8Array) {
|
|
19
|
+
if (certBytes.length > MAX_DER_CERTIFICATE_SIZE) {
|
|
20
|
+
throw new ImplementationError(
|
|
21
|
+
`Certificate to generate is too big: ${certBytes.length} bytes instead of max ${MAX_DER_CERTIFICATE_SIZE} bytes`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Bytes, DerObject, X520 } from "#general";
|
|
8
|
+
import { FabricId, NodeId, VendorId } from "#types";
|
|
9
|
+
|
|
10
|
+
const YEAR_S = 365 * 24 * 60 * 60;
|
|
11
|
+
const EPOCH_OFFSET_S = 10957 * 24 * 60 * 60;
|
|
12
|
+
|
|
13
|
+
// TODO replace usage of Date by abstraction
|
|
14
|
+
|
|
15
|
+
export function matterToJsDate(date: number) {
|
|
16
|
+
return date === 0 ? X520.NON_WELL_DEFINED_DATE : new Date((date + EPOCH_OFFSET_S) * 1000);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function jsToMatterDate(date: Date, addYears = 0) {
|
|
20
|
+
return date.getTime() === X520.NON_WELL_DEFINED_DATE.getTime()
|
|
21
|
+
? 0
|
|
22
|
+
: Math.floor(date.getTime() / 1000) - EPOCH_OFFSET_S + addYears * YEAR_S;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function intTo16Chars(value: bigint | number) {
|
|
26
|
+
const byteArray = new Uint8Array(8);
|
|
27
|
+
const dataView = Bytes.dataViewOf(byteArray);
|
|
28
|
+
dataView.setBigUint64(0, typeof value === "bigint" ? value : BigInt(value));
|
|
29
|
+
return Bytes.toHex(byteArray).toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function uInt16To8Chars(value: number) {
|
|
33
|
+
const byteArray = new Uint8Array(4);
|
|
34
|
+
const dataView = Bytes.dataViewOf(byteArray);
|
|
35
|
+
dataView.setUint32(0, value);
|
|
36
|
+
return Bytes.toHex(byteArray).toUpperCase();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function uInt16To4Chars(value: number) {
|
|
40
|
+
const byteArray = new Uint8Array(2);
|
|
41
|
+
const dataView = Bytes.dataViewOf(byteArray);
|
|
42
|
+
dataView.setUint16(0, value);
|
|
43
|
+
return Bytes.toHex(byteArray).toUpperCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Matter specific ASN.1 OIDs
|
|
48
|
+
* @see {@link MatterSpecification.v12.Core} Appendix E
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generator function to create a specific ASN field for a Matter OpCert DN with the OID base 1.3.6.1.4.1.37244.1.*.
|
|
53
|
+
* The returned function takes the value and returns the ASN.1 DER object.
|
|
54
|
+
*/
|
|
55
|
+
const GenericMatterOpCertObject =
|
|
56
|
+
<T>(id: number, valueConverter?: (value: T) => string) =>
|
|
57
|
+
(value: T) => [
|
|
58
|
+
DerObject(`2b0601040182a27c01${id.toString(16).padStart(2, "0")}`, {
|
|
59
|
+
value: (valueConverter ?? intTo16Chars)(value as any),
|
|
60
|
+
}),
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Generator function to create a specific ASN field for a Matter AttCert DN with the OID base 1.3.6.1.4.1.37244.2.*.
|
|
65
|
+
* The returned function takes the value and returns the ASN.1 DER object.
|
|
66
|
+
*/
|
|
67
|
+
const GenericMatterAttCertObject =
|
|
68
|
+
<T>(id: number, valueConverter?: (value: T) => string) =>
|
|
69
|
+
(value: T) => [
|
|
70
|
+
DerObject(`2b0601040182a27c02${id.toString(16).padStart(2, "0")}`, {
|
|
71
|
+
value: (valueConverter ?? intTo16Chars)(value as any),
|
|
72
|
+
}),
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
/** matter-node-id = ASN.1 OID 1.3.6.1.4.1.37244.1.1 */
|
|
76
|
+
export const NodeId_Matter = GenericMatterOpCertObject<NodeId>(1);
|
|
77
|
+
|
|
78
|
+
/** matter-firmware-signing-id = ASN.1 OID 1.3.6.1.4.1.37244.1.2 */
|
|
79
|
+
export const FirmwareSigningId_Matter = GenericMatterOpCertObject<number>(2);
|
|
80
|
+
|
|
81
|
+
/** matter-icac-id = ASN.1 OID 1.3.6.1.4.1.37244.1.3 */
|
|
82
|
+
export const IcacId_Matter = GenericMatterOpCertObject<bigint | number>(3);
|
|
83
|
+
|
|
84
|
+
/** matter-rcac-id = ASN.1 OID 1.3.6.1.4.1.37244.1.4 */
|
|
85
|
+
export const RcacId_Matter = GenericMatterOpCertObject<bigint | number>(4);
|
|
86
|
+
|
|
87
|
+
/** matter-fabric-id = ASN.1 OID 1.3.6.1.4.1.37244.1.5 */
|
|
88
|
+
export const FabricId_Matter = GenericMatterOpCertObject<FabricId>(5);
|
|
89
|
+
|
|
90
|
+
/** matter-noc-cat = ASN.1 OID 1.3.6.1.4.1.37244.1.6 */
|
|
91
|
+
export const NocCat_Matter = GenericMatterOpCertObject<number>(6, uInt16To8Chars);
|
|
92
|
+
|
|
93
|
+
/** matter-oid-vid = ASN.1 OID 1.3.6.1.4.1.37244.2.1 */
|
|
94
|
+
export const VendorId_Matter = GenericMatterAttCertObject<VendorId>(1, uInt16To4Chars);
|
|
95
|
+
|
|
96
|
+
/** matter-oid-pid = ASN.1 OID 1.3.6.1.4.1.37244.2.2 */
|
|
97
|
+
export const ProductId_Matter = GenericMatterAttCertObject<number>(2, uInt16To4Chars);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { VendorId } from "#types";
|
|
7
|
+
import { X509Certificate } from "./base.js";
|
|
8
|
+
|
|
9
|
+
/** Definitions for Matter Attestation certificates (PAA, PAI, DAC) */
|
|
10
|
+
export namespace AttestationCertificate {
|
|
11
|
+
export interface Dac extends X509Certificate {
|
|
12
|
+
issuer: {
|
|
13
|
+
commonName: string;
|
|
14
|
+
productId?: number;
|
|
15
|
+
vendorId: VendorId;
|
|
16
|
+
};
|
|
17
|
+
subject: {
|
|
18
|
+
commonName: string;
|
|
19
|
+
productId: number;
|
|
20
|
+
vendorId: VendorId;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Pai extends X509Certificate {
|
|
25
|
+
issuer: {
|
|
26
|
+
commonName: string;
|
|
27
|
+
vendorId?: VendorId;
|
|
28
|
+
};
|
|
29
|
+
subject: {
|
|
30
|
+
commonName: string;
|
|
31
|
+
productId?: number;
|
|
32
|
+
vendorId: VendorId;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Paa extends X509Certificate {
|
|
37
|
+
issuer: {
|
|
38
|
+
commonName: string;
|
|
39
|
+
vendorId?: VendorId;
|
|
40
|
+
};
|
|
41
|
+
subject: {
|
|
42
|
+
commonName: string;
|
|
43
|
+
vendorId?: VendorId;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BitFlag, BitmapSchema, TypeFromPartialBitSchema } from "#types";
|
|
7
|
+
|
|
8
|
+
export const ExtensionKeyUsageBitmap = {
|
|
9
|
+
digitalSignature: BitFlag(0),
|
|
10
|
+
nonRepudiation: BitFlag(1),
|
|
11
|
+
keyEncipherment: BitFlag(2),
|
|
12
|
+
dataEncipherment: BitFlag(3),
|
|
13
|
+
keyAgreement: BitFlag(4),
|
|
14
|
+
keyCertSign: BitFlag(5),
|
|
15
|
+
cRLSign: BitFlag(6),
|
|
16
|
+
encipherOnly: BitFlag(7),
|
|
17
|
+
decipherOnly: BitFlag(8),
|
|
18
|
+
};
|
|
19
|
+
export const ExtensionKeyUsageSchema = BitmapSchema(ExtensionKeyUsageBitmap);
|
|
20
|
+
|
|
21
|
+
export interface X509Certificate {
|
|
22
|
+
serialNumber: Uint8Array;
|
|
23
|
+
signatureAlgorithm: number;
|
|
24
|
+
issuer: {};
|
|
25
|
+
notBefore: number;
|
|
26
|
+
notAfter: number;
|
|
27
|
+
subject: {};
|
|
28
|
+
publicKeyAlgorithm: number;
|
|
29
|
+
ellipticCurveIdentifier: number;
|
|
30
|
+
ellipticCurvePublicKey: Uint8Array;
|
|
31
|
+
extensions: {
|
|
32
|
+
basicConstraints: {
|
|
33
|
+
isCa: boolean;
|
|
34
|
+
pathLen?: number;
|
|
35
|
+
};
|
|
36
|
+
keyUsage: TypeFromPartialBitSchema<typeof ExtensionKeyUsageBitmap>;
|
|
37
|
+
extendedKeyUsage?: number[];
|
|
38
|
+
subjectKeyIdentifier: Uint8Array;
|
|
39
|
+
authorityKeyIdentifier: Uint8Array;
|
|
40
|
+
futureExtension?: Uint8Array[];
|
|
41
|
+
};
|
|
42
|
+
signature: Uint8Array;
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
TlvArray,
|
|
8
|
+
TlvByteString,
|
|
9
|
+
TlvField,
|
|
10
|
+
TlvObject,
|
|
11
|
+
TlvOptionalField,
|
|
12
|
+
TlvString,
|
|
13
|
+
TlvUInt16,
|
|
14
|
+
TlvUInt32,
|
|
15
|
+
TlvUInt8,
|
|
16
|
+
TlvVendorId,
|
|
17
|
+
} from "#types";
|
|
18
|
+
|
|
19
|
+
/** Definitions for Matter Certification Declaration */
|
|
20
|
+
export namespace CertificationDeclaration {
|
|
21
|
+
export const TlvDc = TlvObject({
|
|
22
|
+
formatVersion: TlvField(0, TlvUInt16),
|
|
23
|
+
vendorId: TlvField(1, TlvVendorId),
|
|
24
|
+
produceIdArray: TlvField(2, TlvArray(TlvUInt16, { minLength: 1, maxLength: 100 })),
|
|
25
|
+
deviceTypeId: TlvField(3, TlvUInt32),
|
|
26
|
+
certificateId: TlvField(4, TlvString.bound({ length: 19 })),
|
|
27
|
+
securityLevel: TlvField(5, TlvUInt8),
|
|
28
|
+
securityInformation: TlvField(6, TlvUInt16),
|
|
29
|
+
versionNumber: TlvField(7, TlvUInt16),
|
|
30
|
+
certificationType: TlvField(8, TlvUInt8),
|
|
31
|
+
dacOriginVendorId: TlvOptionalField(9, TlvVendorId),
|
|
32
|
+
dacOriginProductId: TlvOptionalField(10, TlvUInt16),
|
|
33
|
+
authorizedPaaList: TlvOptionalField(
|
|
34
|
+
11,
|
|
35
|
+
TlvArray(TlvByteString.bound({ length: 20 }), { minLength: 1, maxLength: 10 }),
|
|
36
|
+
),
|
|
37
|
+
});
|
|
38
|
+
}
|