@matter/protocol 0.13.1-alpha.0-20250506-f9ad9c3d8 → 0.13.1-alpha.0-20250509-28e1567e1
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 +7 -13
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.js +37 -29
- package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -6
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js +56 -38
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/CertificateManager.d.ts +8 -8
- package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateManager.js +20 -16
- package/dist/cjs/certificate/CertificateManager.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +24 -26
- package/dist/cjs/certificate/DeviceCertification.js.map +2 -2
- package/dist/cjs/common/FailsafeContext.d.ts +2 -2
- package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +20 -13
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +8 -6
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +15 -9
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.js +5 -3
- package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricManager.js +2 -2
- package/dist/cjs/fabric/FabricManager.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -2
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +4 -0
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +11 -2
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +13 -10
- 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 +11 -8
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/cjs/session/pase/PaseClient.js +1 -1
- package/dist/cjs/session/pase/PaseClient.js.map +1 -1
- package/dist/cjs/session/pase/PaseServer.js +1 -1
- package/dist/cjs/session/pase/PaseServer.js.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.d.ts +7 -13
- package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.js +37 -29
- package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -6
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js +57 -38
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/CertificateManager.d.ts +8 -8
- package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateManager.js +20 -16
- package/dist/esm/certificate/CertificateManager.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +24 -26
- package/dist/esm/certificate/DeviceCertification.js.map +2 -2
- package/dist/esm/common/FailsafeContext.d.ts +2 -2
- package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.js +28 -14
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +8 -6
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +15 -9
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/esm/fabric/FabricAuthority.js +5 -3
- package/dist/esm/fabric/FabricAuthority.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +1 -1
- package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
- package/dist/esm/fabric/FabricManager.js +2 -2
- package/dist/esm/fabric/FabricManager.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +2 -2
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +4 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +11 -2
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +13 -10
- 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 +11 -8
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/dist/esm/session/pase/PaseClient.js +1 -1
- package/dist/esm/session/pase/PaseClient.js.map +1 -1
- package/dist/esm/session/pase/PaseServer.js +1 -1
- package/dist/esm/session/pase/PaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/certificate/AttestationCertificateManager.ts +37 -27
- package/src/certificate/CertificateAuthority.ts +60 -38
- package/src/certificate/CertificateManager.ts +20 -16
- package/src/certificate/DeviceCertification.ts +28 -32
- package/src/common/FailsafeContext.ts +29 -14
- package/src/fabric/Fabric.ts +17 -9
- package/src/fabric/FabricAuthority.ts +5 -4
- package/src/fabric/FabricManager.ts +2 -2
- package/src/peer/ControllerCommissioningFlow.ts +2 -2
- package/src/session/SessionManager.ts +13 -2
- package/src/session/case/CaseClient.ts +13 -10
- package/src/session/case/CaseServer.ts +11 -8
- package/src/session/pase/PaseClient.ts +1 -1
- package/src/session/pase/PaseServer.ts +1 -1
|
@@ -6,23 +6,17 @@
|
|
|
6
6
|
import { PrivateKey } from "#general";
|
|
7
7
|
import { VendorId } from "#types";
|
|
8
8
|
export declare class AttestationCertificateManager {
|
|
9
|
-
private
|
|
9
|
+
#private;
|
|
10
10
|
private paaCertId;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private readonly paiKeyIdentifier;
|
|
16
|
-
private readonly paiCertBytes;
|
|
17
|
-
private nextCertificateId;
|
|
18
|
-
constructor(vendorId: VendorId);
|
|
19
|
-
getPAICert(): Uint8Array<ArrayBufferLike>;
|
|
20
|
-
getDACert(productId: number): {
|
|
11
|
+
constructor(vendorId: VendorId, paiKeyPair: PrivateKey, paiKeyIdentifier: Uint8Array);
|
|
12
|
+
static create(vendorId: VendorId): Promise<AttestationCertificateManager>;
|
|
13
|
+
getPAICert(): Promise<Uint8Array<ArrayBufferLike>>;
|
|
14
|
+
getDACert(productId: number): Promise<{
|
|
21
15
|
keyPair: PrivateKey;
|
|
22
16
|
dac: Uint8Array<ArrayBufferLike>;
|
|
23
|
-
}
|
|
17
|
+
}>;
|
|
24
18
|
private generatePAACert;
|
|
25
19
|
private generatePAICert;
|
|
26
|
-
generateDaCert(publicKey: Uint8Array, vendorId: VendorId, productId: number): Uint8Array<ArrayBufferLike
|
|
20
|
+
generateDaCert(publicKey: Uint8Array, vendorId: VendorId, productId: number): Promise<Uint8Array<ArrayBufferLike>>;
|
|
27
21
|
}
|
|
28
22
|
//# sourceMappingURL=AttestationCertificateManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttestationCertificateManager.d.ts","sourceRoot":"","sources":["../../../src/certificate/AttestationCertificateManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,UAAU,EAAe,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAuBlC,qBAAa,6BAA6B
|
|
1
|
+
{"version":3,"file":"AttestationCertificateManager.d.ts","sourceRoot":"","sources":["../../../src/certificate/AttestationCertificateManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,UAAU,EAAe,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAuBlC,qBAAa,6BAA6B;;IACtC,OAAO,CAAC,SAAS,CAAa;gBAelB,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU;WAOvE,MAAM,CAAC,QAAQ,EAAE,QAAQ;IAMtC,UAAU;IAIJ,SAAS,CAAC,SAAS,EAAE,MAAM;;;;IAWjC,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,eAAe;IAkCjB,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM;CAiCpF"}
|
|
@@ -39,30 +39,38 @@ function getPaaCommonName() {
|
|
|
39
39
|
return "Matter Test PAA";
|
|
40
40
|
}
|
|
41
41
|
class AttestationCertificateManager {
|
|
42
|
-
constructor(vendorId) {
|
|
43
|
-
this.vendorId = vendorId;
|
|
44
|
-
this.paiCertBytes = this.generatePAICert(vendorId);
|
|
45
|
-
}
|
|
46
42
|
paaCertId = BigInt(0);
|
|
47
43
|
// We use the official PAA cert for now because else pairing with Chip tool do not work because
|
|
48
44
|
// only this one is the Certificate store
|
|
49
|
-
paaKeyPair = (0, import_general.PrivateKey)(import_ChipPAAuthorities.TestCert_PAA_NoVID_PrivateKey, {
|
|
45
|
+
#paaKeyPair = (0, import_general.PrivateKey)(import_ChipPAAuthorities.TestCert_PAA_NoVID_PrivateKey, {
|
|
50
46
|
publicKey: import_ChipPAAuthorities.TestCert_PAA_NoVID_PublicKey
|
|
51
47
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
#vendorId;
|
|
49
|
+
#paiKeyPair;
|
|
50
|
+
#paiKeyIdentifier;
|
|
51
|
+
#paaKeyIdentifier = import_ChipPAAuthorities.TestCert_PAA_NoVID_SKID;
|
|
52
|
+
#paiCertId = BigInt(1);
|
|
53
|
+
#paiCertBytes;
|
|
54
|
+
#nextCertificateId = 2;
|
|
55
|
+
constructor(vendorId, paiKeyPair, paiKeyIdentifier) {
|
|
56
|
+
this.#vendorId = vendorId;
|
|
57
|
+
this.#paiKeyPair = paiKeyPair;
|
|
58
|
+
this.#paiKeyIdentifier = paiKeyIdentifier;
|
|
59
|
+
this.#paiCertBytes = this.generatePAICert(vendorId);
|
|
60
|
+
}
|
|
61
|
+
static async create(vendorId) {
|
|
62
|
+
const key = await import_general.Crypto.createKeyPair();
|
|
63
|
+
const identifier = await import_general.Crypto.hash(key.publicKey);
|
|
64
|
+
return new AttestationCertificateManager(vendorId, key, identifier.slice(0, 20));
|
|
65
|
+
}
|
|
58
66
|
getPAICert() {
|
|
59
|
-
return this
|
|
67
|
+
return this.#paiCertBytes;
|
|
60
68
|
}
|
|
61
|
-
getDACert(productId) {
|
|
62
|
-
const dacKeyPair = import_general.Crypto.createKeyPair();
|
|
69
|
+
async getDACert(productId) {
|
|
70
|
+
const dacKeyPair = await import_general.Crypto.createKeyPair();
|
|
63
71
|
return {
|
|
64
72
|
keyPair: dacKeyPair,
|
|
65
|
-
dac: this.generateDaCert(dacKeyPair.publicKey, this
|
|
73
|
+
dac: await this.generateDaCert(dacKeyPair.publicKey, this.#vendorId, productId)
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
76
|
// Method unused for now because we use the official Matter Test PAA, but is functional
|
|
@@ -85,7 +93,7 @@ class AttestationCertificateManager {
|
|
|
85
93
|
commonName: getPaaCommonName(),
|
|
86
94
|
vendorId
|
|
87
95
|
},
|
|
88
|
-
ellipticCurvePublicKey: this
|
|
96
|
+
ellipticCurvePublicKey: this.#paaKeyPair.publicKey,
|
|
89
97
|
extensions: {
|
|
90
98
|
basicConstraints: {
|
|
91
99
|
isCa: true,
|
|
@@ -95,16 +103,16 @@ class AttestationCertificateManager {
|
|
|
95
103
|
keyCertSign: true,
|
|
96
104
|
cRLSign: true
|
|
97
105
|
},
|
|
98
|
-
subjectKeyIdentifier: this
|
|
99
|
-
authorityKeyIdentifier: this
|
|
106
|
+
subjectKeyIdentifier: this.#paaKeyIdentifier,
|
|
107
|
+
authorityKeyIdentifier: this.#paaKeyIdentifier
|
|
100
108
|
}
|
|
101
109
|
};
|
|
102
|
-
return import_CertificateManager.CertificateManager.productAttestationAuthorityCertToAsn1(unsignedCertificate, this
|
|
110
|
+
return import_CertificateManager.CertificateManager.productAttestationAuthorityCertToAsn1(unsignedCertificate, this.#paaKeyPair);
|
|
103
111
|
}
|
|
104
112
|
generatePAICert(vendorId, productId) {
|
|
105
113
|
const now = import_general.Time.get().now();
|
|
106
114
|
const unsignedCertificate = {
|
|
107
|
-
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(this
|
|
115
|
+
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(this.#paiCertId)),
|
|
108
116
|
signatureAlgorithm: 1,
|
|
109
117
|
publicKeyAlgorithm: 1,
|
|
110
118
|
ellipticCurveIdentifier: 1,
|
|
@@ -118,7 +126,7 @@ class AttestationCertificateManager {
|
|
|
118
126
|
vendorId,
|
|
119
127
|
productId
|
|
120
128
|
},
|
|
121
|
-
ellipticCurvePublicKey: this
|
|
129
|
+
ellipticCurvePublicKey: this.#paiKeyPair.publicKey,
|
|
122
130
|
extensions: {
|
|
123
131
|
basicConstraints: {
|
|
124
132
|
isCa: true,
|
|
@@ -128,15 +136,15 @@ class AttestationCertificateManager {
|
|
|
128
136
|
keyCertSign: true,
|
|
129
137
|
cRLSign: true
|
|
130
138
|
},
|
|
131
|
-
subjectKeyIdentifier: this
|
|
132
|
-
authorityKeyIdentifier: this
|
|
139
|
+
subjectKeyIdentifier: this.#paiKeyIdentifier,
|
|
140
|
+
authorityKeyIdentifier: this.#paaKeyIdentifier
|
|
133
141
|
}
|
|
134
142
|
};
|
|
135
|
-
return import_CertificateManager.CertificateManager.productAttestationIntermediateCertToAsn1(unsignedCertificate, this
|
|
143
|
+
return import_CertificateManager.CertificateManager.productAttestationIntermediateCertToAsn1(unsignedCertificate, this.#paaKeyPair);
|
|
136
144
|
}
|
|
137
|
-
generateDaCert(publicKey, vendorId, productId) {
|
|
145
|
+
async generateDaCert(publicKey, vendorId, productId) {
|
|
138
146
|
const now = import_general.Time.get().now();
|
|
139
|
-
const certId = this
|
|
147
|
+
const certId = this.#nextCertificateId++;
|
|
140
148
|
const unsignedCertificate = {
|
|
141
149
|
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(certId)),
|
|
142
150
|
signatureAlgorithm: 1,
|
|
@@ -161,11 +169,11 @@ class AttestationCertificateManager {
|
|
|
161
169
|
keyUsage: {
|
|
162
170
|
digitalSignature: true
|
|
163
171
|
},
|
|
164
|
-
subjectKeyIdentifier: import_general.Crypto.hash(publicKey).slice(0, 20),
|
|
165
|
-
authorityKeyIdentifier: this
|
|
172
|
+
subjectKeyIdentifier: (await import_general.Crypto.hash(publicKey)).slice(0, 20),
|
|
173
|
+
authorityKeyIdentifier: this.#paiKeyIdentifier
|
|
166
174
|
}
|
|
167
175
|
};
|
|
168
|
-
return import_CertificateManager.CertificateManager.deviceAttestationCertToAsn1(unsignedCertificate, this
|
|
176
|
+
return import_CertificateManager.CertificateManager.deviceAttestationCertToAsn1(unsignedCertificate, this.#paiKeyPair);
|
|
169
177
|
}
|
|
170
178
|
}
|
|
171
179
|
//# sourceMappingURL=AttestationCertificateManager.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/certificate/AttestationCertificateManager.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAuD;AAEvD,gCAAmD;AACnD,+BAIO;AAbP;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,iBAAiB,UAAoB,WAAoB;AAC9D,SAAO,yBAAyB,SAAS,SAAS,EAAE,EAAE,YAAY,CAAC,IAC/D,cAAc,SAAY,WAAW,KAAK,UAAU,SAAS,EAAE,EAAE,YAAY,CAAC,EAClF;AACJ;AAEA,SAAS,iBAAiB,UAAoB,WAAmB;AAC7D,SAAO,yBAAyB,SAAS,SAAS,EAAE,EAAE,YAAY,CAAC,MAAM,UAAU,SAAS,EAAE,EAAE,YAAY,CAAC;AACjH;AAEA,SAAS,mBAAmB;AAExB,SAAO;AACX;AAEO,MAAM,8BAA8B;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAuD;AAEvD,gCAAmD;AACnD,+BAIO;AAbP;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,iBAAiB,UAAoB,WAAoB;AAC9D,SAAO,yBAAyB,SAAS,SAAS,EAAE,EAAE,YAAY,CAAC,IAC/D,cAAc,SAAY,WAAW,KAAK,UAAU,SAAS,EAAE,EAAE,YAAY,CAAC,EAClF;AACJ;AAEA,SAAS,iBAAiB,UAAoB,WAAmB;AAC7D,SAAO,yBAAyB,SAAS,SAAS,EAAE,EAAE,YAAY,CAAC,MAAM,UAAU,SAAS,EAAE,EAAE,YAAY,CAAC;AACjH;AAEA,SAAS,mBAAmB;AAExB,SAAO;AACX;AAEO,MAAM,8BAA8B;AAAA,EAC/B,YAAY,OAAO,CAAC;AAAA;AA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AM,CAAC;AAAA,MACzC,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,yBAAyB;AAAA,MACzB,eAAW,0CAAe,KAAK,EAAE;AAAA,MACjC,cAAU,0CAAe,KAAK,EAAE;AAAA,MAChC,QAAQ;AAAA,QACJ,YAAY,iBAAiB,QAAQ;AAAA,QACrC;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,QACL,YAAY,iBAAiB,UAAU,SAAS;AAAA,QAChD;AAAA,QACA;AAAA,MACJ;AAAA,MACA,wBAAwB;AAAA,MACxB,YAAY;AAAA,QACR,kBAAkB;AAAA,UACd,MAAM;AAAA,QACV;AAAA,QACA,UAAU;AAAA,UACN,kBAAkB;AAAA,QACtB;AAAA,QACA,uBAAuB,MAAM,sBAAO,KAAK,SAAS,GAAG,MAAM,GAAG,EAAE;AAAA,QAChE,wBAAwB,KAAK;AAAA,MACjC;AAAA,IACJ;AACA,WAAO,6CAAmB,4BAA4B,qBAAqB,KAAK,WAAW;AAAA,EAC/F;AACJ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -11,18 +11,13 @@ import { CaseAuthenticatedTag, FabricId, NodeId } from "#types";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class CertificateAuthority {
|
|
13
13
|
#private;
|
|
14
|
-
private rootCertId;
|
|
15
|
-
private rootKeyPair;
|
|
16
|
-
private rootKeyIdentifier;
|
|
17
|
-
private rootCertBytes;
|
|
18
|
-
private nextCertificateId;
|
|
19
14
|
get construction(): Construction<CertificateAuthority>;
|
|
20
15
|
static create(options: StorageContext | CertificateAuthority.Configuration): Promise<CertificateAuthority>;
|
|
21
16
|
constructor(options: StorageContext | CertificateAuthority.Configuration);
|
|
22
17
|
static [Environmental.create](env: Environment): CertificateAuthority;
|
|
23
18
|
get rootCert(): Uint8Array<ArrayBufferLike>;
|
|
24
19
|
get config(): CertificateAuthority.Configuration;
|
|
25
|
-
generateNoc(publicKey: Uint8Array, fabricId: FabricId, nodeId: NodeId, caseAuthenticatedTags?: CaseAuthenticatedTag[]): Uint8Array<ArrayBufferLike
|
|
20
|
+
generateNoc(publicKey: Uint8Array, fabricId: FabricId, nodeId: NodeId, caseAuthenticatedTags?: CaseAuthenticatedTag[]): Promise<Uint8Array<ArrayBufferLike>>;
|
|
26
21
|
}
|
|
27
22
|
export declare namespace CertificateAuthority {
|
|
28
23
|
type Configuration = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CertificateAuthority.d.ts","sourceRoot":"","sources":["../../../src/certificate/CertificateAuthority.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,aAAa,EAEb,YAAY,EAEZ,WAAW,EACX,aAAa,
|
|
1
|
+
{"version":3,"file":"CertificateAuthority.d.ts","sourceRoot":"","sources":["../../../src/certificate/CertificateAuthority.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,aAAa,EAEb,YAAY,EAEZ,WAAW,EACX,aAAa,EAIb,cAAc,EAKjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAahE;;;GAGG;AACH,qBAAa,oBAAoB;;IAQ7B,IAAI,YAAY,uCAEf;WAEY,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,oBAAoB,CAAC,aAAa;gBAIpE,OAAO,EAAE,cAAc,GAAG,oBAAoB,CAAC,aAAa;IAuCxE,MAAM,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW;IAO9C,IAAI,QAAQ,gCAEX;IAED,IAAI,MAAM,IAAI,oBAAoB,CAAC,aAAa,CAQ/C;IA+BK,WAAW,CACb,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,qBAAqB,CAAC,EAAE,oBAAoB,EAAE;CA8CrD;AAED,yBAAiB,oBAAoB,CAAC;IAClC,KAAY,aAAa,GAAG;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,aAAa,CAAC;QAC3B,iBAAiB,EAAE,UAAU,CAAC;QAC9B,aAAa,EAAE,UAAU,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACL"}
|
|
@@ -30,11 +30,11 @@ var import_CertificateManager = require("./CertificateManager.js");
|
|
|
30
30
|
*/
|
|
31
31
|
const logger = import_general.Logger.get("CertificateAuthority");
|
|
32
32
|
class CertificateAuthority {
|
|
33
|
-
rootCertId = BigInt(0);
|
|
34
|
-
rootKeyPair
|
|
35
|
-
rootKeyIdentifier
|
|
36
|
-
rootCertBytes
|
|
37
|
-
nextCertificateId = BigInt(1);
|
|
33
|
+
#rootCertId = BigInt(0);
|
|
34
|
+
#rootKeyPair;
|
|
35
|
+
#rootKeyIdentifier;
|
|
36
|
+
#rootCertBytes;
|
|
37
|
+
#nextCertificateId = BigInt(1);
|
|
38
38
|
#construction;
|
|
39
39
|
get construction() {
|
|
40
40
|
return this.#construction;
|
|
@@ -45,23 +45,26 @@ class CertificateAuthority {
|
|
|
45
45
|
constructor(options) {
|
|
46
46
|
this.#construction = (0, import_general.Construction)(this, async () => {
|
|
47
47
|
const certValues = options instanceof import_general.StorageContext ? await options.values() : options;
|
|
48
|
+
this.#rootKeyPair = await import_general.Crypto.createKeyPair();
|
|
49
|
+
this.#rootKeyIdentifier = (await import_general.Crypto.hash(this.#rootKeyPair.publicKey)).slice(0, 20);
|
|
50
|
+
this.#rootCertBytes = await this.#generateRootCert();
|
|
48
51
|
if ((typeof certValues.rootCertId === "number" || typeof certValues.rootCertId === "bigint") && (ArrayBuffer.isView(certValues.rootKeyPair) || typeof certValues.rootKeyPair === "object") && ArrayBuffer.isView(certValues.rootKeyIdentifier) && ArrayBuffer.isView(certValues.rootCertBytes) && (typeof certValues.nextCertificateId === "number" || typeof certValues.nextCertificateId === "bigint")) {
|
|
49
|
-
this
|
|
50
|
-
this
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
logger.info(`Loaded stored credentials with ID ${this
|
|
52
|
+
this.#rootCertId = BigInt(certValues.rootCertId);
|
|
53
|
+
this.#rootKeyPair = (0, import_general.PrivateKey)(certValues.rootKeyPair);
|
|
54
|
+
this.#rootKeyIdentifier = certValues.rootKeyIdentifier;
|
|
55
|
+
this.#rootCertBytes = certValues.rootCertBytes;
|
|
56
|
+
this.#nextCertificateId = BigInt(certValues.nextCertificateId);
|
|
57
|
+
logger.info(`Loaded stored credentials with ID ${this.#rootCertId}`);
|
|
55
58
|
return;
|
|
56
59
|
}
|
|
57
|
-
logger.info(`Created new credentials with ID ${this
|
|
60
|
+
logger.info(`Created new credentials with ID ${this.#rootCertId}`);
|
|
58
61
|
if (options instanceof import_general.StorageContext) {
|
|
59
62
|
await options.set({
|
|
60
|
-
rootCertId: this
|
|
61
|
-
rootKeyPair: this
|
|
62
|
-
rootKeyIdentifier: this
|
|
63
|
-
rootCertBytes: this
|
|
64
|
-
nextCertificateId: this
|
|
63
|
+
rootCertId: this.#rootCertId,
|
|
64
|
+
rootKeyPair: this.#rootKeyPair.keyPair,
|
|
65
|
+
rootKeyIdentifier: this.#rootKeyIdentifier,
|
|
66
|
+
rootCertBytes: this.#rootCertBytes,
|
|
67
|
+
nextCertificateId: this.#nextCertificateId
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
});
|
|
@@ -73,51 +76,54 @@ class CertificateAuthority {
|
|
|
73
76
|
return instance;
|
|
74
77
|
}
|
|
75
78
|
get rootCert() {
|
|
76
|
-
return this.rootCertBytes;
|
|
79
|
+
return this.#construction.assert("root cert", this.#rootCertBytes);
|
|
77
80
|
}
|
|
78
81
|
get config() {
|
|
79
82
|
return {
|
|
80
|
-
rootCertId: this
|
|
81
|
-
rootKeyPair: this.rootKeyPair.keyPair,
|
|
82
|
-
rootKeyIdentifier: this.rootKeyIdentifier,
|
|
83
|
-
rootCertBytes: this.rootCertBytes,
|
|
84
|
-
nextCertificateId: this
|
|
83
|
+
rootCertId: this.#rootCertId,
|
|
84
|
+
rootKeyPair: this.construction.assert("root key pair", this.#rootKeyPair).keyPair,
|
|
85
|
+
rootKeyIdentifier: this.construction.assert("root key identifier", this.#rootKeyIdentifier),
|
|
86
|
+
rootCertBytes: this.construction.assert("root cert bytes", this.#rootCertBytes),
|
|
87
|
+
nextCertificateId: this.#nextCertificateId
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
|
-
#generateRootCert() {
|
|
90
|
+
async #generateRootCert() {
|
|
88
91
|
const now = import_general.Time.get().now();
|
|
89
92
|
const unsignedCertificate = {
|
|
90
|
-
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(this
|
|
93
|
+
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(this.#rootCertId)),
|
|
91
94
|
signatureAlgorithm: 1,
|
|
92
95
|
publicKeyAlgorithm: 1,
|
|
93
96
|
ellipticCurveIdentifier: 1,
|
|
94
|
-
issuer: { rcacId: this
|
|
97
|
+
issuer: { rcacId: this.#rootCertId },
|
|
95
98
|
notBefore: (0, import_CertificateManager.jsToMatterDate)(now, -1),
|
|
96
99
|
notAfter: (0, import_CertificateManager.jsToMatterDate)(now, 10),
|
|
97
|
-
subject: { rcacId: this
|
|
98
|
-
ellipticCurvePublicKey: this.
|
|
100
|
+
subject: { rcacId: this.#rootCertId },
|
|
101
|
+
ellipticCurvePublicKey: this.#initializedRootKeyPair.publicKey,
|
|
99
102
|
extensions: {
|
|
100
103
|
basicConstraints: { isCa: true },
|
|
101
104
|
keyUsage: {
|
|
102
105
|
keyCertSign: true,
|
|
103
106
|
cRLSign: true
|
|
104
107
|
},
|
|
105
|
-
subjectKeyIdentifier: this
|
|
106
|
-
authorityKeyIdentifier: this
|
|
108
|
+
subjectKeyIdentifier: this.#initializedRootKeyIdentifier,
|
|
109
|
+
authorityKeyIdentifier: this.#initializedRootKeyIdentifier
|
|
107
110
|
}
|
|
108
111
|
};
|
|
109
|
-
const signature = import_general.Crypto.sign(
|
|
112
|
+
const signature = await import_general.Crypto.sign(
|
|
113
|
+
this.#initializedRootKeyPair,
|
|
114
|
+
import_CertificateManager.CertificateManager.rootCertToAsn1(unsignedCertificate)
|
|
115
|
+
);
|
|
110
116
|
return import_CertificateManager.TlvRootCertificate.encode({ ...unsignedCertificate, signature });
|
|
111
117
|
}
|
|
112
|
-
generateNoc(publicKey, fabricId, nodeId, caseAuthenticatedTags) {
|
|
118
|
+
async generateNoc(publicKey, fabricId, nodeId, caseAuthenticatedTags) {
|
|
113
119
|
const now = import_general.Time.get().now();
|
|
114
|
-
const certId = this
|
|
120
|
+
const certId = this.#nextCertificateId++;
|
|
115
121
|
const unsignedCertificate = {
|
|
116
122
|
serialNumber: import_general.Bytes.fromHex((0, import_general.toHex)(certId)),
|
|
117
123
|
signatureAlgorithm: 1,
|
|
118
124
|
publicKeyAlgorithm: 1,
|
|
119
125
|
ellipticCurveIdentifier: 1,
|
|
120
|
-
issuer: { rcacId: this
|
|
126
|
+
issuer: { rcacId: this.#rootCertId },
|
|
121
127
|
notBefore: (0, import_CertificateManager.jsToMatterDate)(now, -1),
|
|
122
128
|
notAfter: (0, import_CertificateManager.jsToMatterDate)(now, 10),
|
|
123
129
|
subject: { fabricId, nodeId, caseAuthenticatedTags },
|
|
@@ -128,15 +134,27 @@ class CertificateAuthority {
|
|
|
128
134
|
digitalSignature: true
|
|
129
135
|
},
|
|
130
136
|
extendedKeyUsage: [2, 1],
|
|
131
|
-
subjectKeyIdentifier: import_general.Crypto.hash(publicKey).slice(0, 20),
|
|
132
|
-
authorityKeyIdentifier: this
|
|
137
|
+
subjectKeyIdentifier: (await import_general.Crypto.hash(publicKey)).slice(0, 20),
|
|
138
|
+
authorityKeyIdentifier: this.#initializedRootKeyIdentifier
|
|
133
139
|
}
|
|
134
140
|
};
|
|
135
|
-
const signature = import_general.Crypto.sign(
|
|
136
|
-
this
|
|
141
|
+
const signature = await import_general.Crypto.sign(
|
|
142
|
+
this.#initializedRootKeyPair,
|
|
137
143
|
import_CertificateManager.CertificateManager.nodeOperationalCertToAsn1(unsignedCertificate)
|
|
138
144
|
);
|
|
139
145
|
return import_CertificateManager.TlvOperationalCertificate.encode({ ...unsignedCertificate, signature });
|
|
140
146
|
}
|
|
147
|
+
get #initializedRootKeyPair() {
|
|
148
|
+
if (this.#rootKeyPair === void 0) {
|
|
149
|
+
throw new import_general.InternalError("CA private key is not installed");
|
|
150
|
+
}
|
|
151
|
+
return this.#rootKeyPair;
|
|
152
|
+
}
|
|
153
|
+
get #initializedRootKeyIdentifier() {
|
|
154
|
+
if (this.#rootKeyIdentifier === void 0) {
|
|
155
|
+
throw new import_general.InternalError("CA key identifier is not installed");
|
|
156
|
+
}
|
|
157
|
+
return this.#rootKeyIdentifier;
|
|
158
|
+
}
|
|
141
159
|
}
|
|
142
160
|
//# sourceMappingURL=CertificateAuthority.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/certificate/CertificateAuthority.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAeO;AAEP,gCAQO;AA/BP;AAAA;AAAA;AAAA;AAAA;AAiCA,MAAM,SAAS,sBAAO,IAAI,sBAAsB;AAMzC,MAAM,qBAAqB;AAAA,EAC9B,cAAc,OAAO,CAAC;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB,OAAO,CAAC;AAAA,EAC7B;AAAA,EAEA,IAAI,eAAe;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,aAAa,OAAO,SAA8D;AAC9E,eAAO,yBAAS,sBAAsB,OAAO;AAAA,EACjD;AAAA,EAEA,YAAY,SAA8D;AACtE,SAAK,oBAAgB,6BAAa,MA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sBAAwD;AAAA,MAC1D,cAAc,qBAAM,YAAQ,sBAAM,MAAM,CAAC;AAAA,MACzC,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,yBAAyB;AAAA,MACzB,QAAQ,EAAE,QAAQ,KAAK,YAAY;AAAA,MACnC,eAAW,0CAAe,KAAK,EAAE;AAAA,MACjC,cAAU,0CAAe,KAAK,EAAE;AAAA,MAChC,SAAS,EAAE,UAAU,QAAQ,sBAAsB;AAAA,MACnD,wBAAwB;AAAA,MACxB,YAAY;AAAA,QACR,kBAAkB,EAAE,MAAM,MAAM;AAAA,QAChC,UAAU;AAAA,UACN,kBAAkB;AAAA,QACtB;AAAA,QACA,kBAAkB,CAAC,GAAG,CAAC;AAAA,QACvB,uBAAuB,MAAM,sBAAO,KAAK,SAAS,GAAG,MAAM,GAAG,EAAE;AAAA,QAChE,wBAAwB,KAAK;AAAA,MACjC;AAAA,IACJ;AAEA,UAAM,YAAY,MAAM,sBAAO;AAAA,MAC3B,KAAK;AAAA,MACL,6CAAmB,0BAA0B,mBAAmB;AAAA,IACpE;AAEA,WAAO,oDAA0B,OAAO,EAAE,GAAG,qBAAqB,UAAU,CAAC;AAAA,EACjF;AAAA,EAEA,IAAI,0BAA0B;AAC1B,QAAI,KAAK,iBAAiB,QAAW;AACjC,YAAM,IAAI,6BAAc,iCAAiC;AAAA,IAC7D;AACA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,gCAAgC;AAChC,QAAI,KAAK,uBAAuB,QAAW;AACvC,YAAM,IAAI,6BAAc,oCAAoC;AAAA,IAChE;AACA,WAAO,KAAK;AAAA,EAChB;AACJ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -544,9 +544,9 @@ export declare namespace CertificateManager {
|
|
|
544
544
|
function rootCertToAsn1(cert: Unsigned<RootCertificate>): Uint8Array<ArrayBufferLike>;
|
|
545
545
|
function intermediateCaCertToAsn1(cert: Unsigned<IntermediateCertificate>): Uint8Array<ArrayBufferLike>;
|
|
546
546
|
function nodeOperationalCertToAsn1(cert: Unsigned<OperationalCertificate>): Uint8Array<ArrayBufferLike>;
|
|
547
|
-
function deviceAttestationCertToAsn1(cert: Unsigned<DeviceAttestationCertificate>, key: Key): Uint8Array<ArrayBufferLike
|
|
548
|
-
function productAttestationIntermediateCertToAsn1(cert: Unsigned<ProductAttestationIntermediateCertificate>, key: Key): Uint8Array<ArrayBufferLike
|
|
549
|
-
function productAttestationAuthorityCertToAsn1(cert: Unsigned<ProductAttestationAuthorityCertificate>, key: Key): Uint8Array<ArrayBufferLike
|
|
547
|
+
function deviceAttestationCertToAsn1(cert: Unsigned<DeviceAttestationCertificate>, key: Key): Promise<Uint8Array<ArrayBufferLike>>;
|
|
548
|
+
function productAttestationIntermediateCertToAsn1(cert: Unsigned<ProductAttestationIntermediateCertificate>, key: Key): Promise<Uint8Array<ArrayBufferLike>>;
|
|
549
|
+
function productAttestationAuthorityCertToAsn1(cert: Unsigned<ProductAttestationAuthorityCertificate>, key: Key): Promise<Uint8Array<ArrayBufferLike>>;
|
|
550
550
|
function certificationDeclarationToAsn1(eContent: Uint8Array, subjectKeyIdentifier: Uint8Array, privateKey: JsonWebKey): Uint8Array<ArrayBufferLike>;
|
|
551
551
|
/**
|
|
552
552
|
* Validate general requirements a Matter certificate fields must fulfill.
|
|
@@ -557,19 +557,19 @@ export declare namespace CertificateManager {
|
|
|
557
557
|
* Verify requirements a Matter Root certificate must fulfill.
|
|
558
558
|
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
559
559
|
*/
|
|
560
|
-
function verifyRootCertificate(rootCert: RootCertificate): void
|
|
560
|
+
function verifyRootCertificate(rootCert: RootCertificate): Promise<void>;
|
|
561
561
|
/**
|
|
562
562
|
* Verify requirements a Matter Node Operational certificate must fulfill.
|
|
563
563
|
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
564
564
|
*/
|
|
565
|
-
function verifyNodeOperationalCertificate(nocCert: OperationalCertificate, rootCert: RootCertificate, icaCert?: IntermediateCertificate): void
|
|
565
|
+
function verifyNodeOperationalCertificate(nocCert: OperationalCertificate, rootCert: RootCertificate, icaCert?: IntermediateCertificate): Promise<void>;
|
|
566
566
|
/**
|
|
567
567
|
* Verify requirements a Matter Intermediate CA certificate must fulfill.
|
|
568
568
|
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
569
569
|
*/
|
|
570
|
-
function verifyIntermediateCaCertificate(rootCert: RootCertificate, icaCert: IntermediateCertificate): void
|
|
571
|
-
function createCertificateSigningRequest(key: Key): Uint8Array<ArrayBufferLike
|
|
572
|
-
function getPublicKeyFromCsr(csr: Uint8Array): Uint8Array<ArrayBufferLike
|
|
570
|
+
function verifyIntermediateCaCertificate(rootCert: RootCertificate, icaCert: IntermediateCertificate): Promise<void>;
|
|
571
|
+
function createCertificateSigningRequest(key: Key): Promise<Uint8Array<ArrayBufferLike>>;
|
|
572
|
+
function getPublicKeyFromCsr(csr: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>;
|
|
573
573
|
}
|
|
574
574
|
export {};
|
|
575
575
|
//# sourceMappingURL=CertificateManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CertificateManager.d.ts","sourceRoot":"","sources":["../../../src/certificate/CertificateManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAaH,GAAG,EAEH,WAAW,EASd,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,OAAO,EAEP,oBAAoB,EACpB,QAAQ,EACR,MAAM,EAoBN,wBAAwB,EACxB,cAAc,EACd,QAAQ,EACX,MAAM,QAAQ,CAAC;AAIhB,qBAAa,gBAAiB,SAAQ,WAAW;CAAG;AAcpD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,QAE1C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,SAAI,UAItD;AAoDD,uDAAuD;AACvD,eAAO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wCAUX;IAED,SAAsB,qCAAqC,CACvD,IAAI,EAAE,QAAQ,CAAC,sCAAsC,CAAC,EACtD,GAAG,EAAE,GAAG,wCAUX;IAED,SAAgB,8BAA8B,CAC1C,QAAQ,EAAE,UAAU,EACpB,oBAAoB,EAAE,UAAU,EAChC,UAAU,EAAE,UAAU,+BAoBzB;IAED;;;OAGG;IACH,SAAgB,gCAAgC,CAC5C,IAAI,EAAE,eAAe,GAAG,sBAAsB,GAAG,uBAAuB,QAsC3E;IAED;;;OAGG;IACH,SAAsB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,iBAqFpE;IAED;;;OAGG;IACH,SAAsB,gCAAgC,CAClD,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,uBAAuB,iBAuHpC;IAED;;;OAGG;IACH,SAAsB,+BAA+B,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,uBAAuB,iBAgHhH;IAED,SAAsB,+BAA+B,CAAC,GAAG,EAAE,GAAG,wCAa7D;IAED,SAAsB,mBAAmB,CAAC,GAAG,EAAE,UAAU,wCA+BxD;CACJ"}
|
|
@@ -492,34 +492,34 @@ var CertificateManager;
|
|
|
492
492
|
return genericCertToAsn1(cert);
|
|
493
493
|
}
|
|
494
494
|
CertificateManager2.nodeOperationalCertToAsn1 = nodeOperationalCertToAsn1;
|
|
495
|
-
function deviceAttestationCertToAsn1(cert, key) {
|
|
495
|
+
async function deviceAttestationCertToAsn1(cert, key) {
|
|
496
496
|
const certificate = genericBuildAsn1Structure(cert);
|
|
497
497
|
const certBytes = import_general.DerCodec.encode({
|
|
498
498
|
certificate,
|
|
499
499
|
signAlgorithm: import_general.X962.EcdsaWithSHA256,
|
|
500
|
-
signature: (0, import_general.BitByteArray)(import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
500
|
+
signature: (0, import_general.BitByteArray)(await import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
501
501
|
});
|
|
502
502
|
assertCertificateDerSize(certBytes);
|
|
503
503
|
return certBytes;
|
|
504
504
|
}
|
|
505
505
|
CertificateManager2.deviceAttestationCertToAsn1 = deviceAttestationCertToAsn1;
|
|
506
|
-
function productAttestationIntermediateCertToAsn1(cert, key) {
|
|
506
|
+
async function productAttestationIntermediateCertToAsn1(cert, key) {
|
|
507
507
|
const certificate = genericBuildAsn1Structure(cert);
|
|
508
508
|
const certBytes = import_general.DerCodec.encode({
|
|
509
509
|
certificate,
|
|
510
510
|
signAlgorithm: import_general.X962.EcdsaWithSHA256,
|
|
511
|
-
signature: (0, import_general.BitByteArray)(import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
511
|
+
signature: (0, import_general.BitByteArray)(await import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
512
512
|
});
|
|
513
513
|
assertCertificateDerSize(certBytes);
|
|
514
514
|
return certBytes;
|
|
515
515
|
}
|
|
516
516
|
CertificateManager2.productAttestationIntermediateCertToAsn1 = productAttestationIntermediateCertToAsn1;
|
|
517
|
-
function productAttestationAuthorityCertToAsn1(cert, key) {
|
|
517
|
+
async function productAttestationAuthorityCertToAsn1(cert, key) {
|
|
518
518
|
const certificate = genericBuildAsn1Structure(cert);
|
|
519
519
|
const certBytes = import_general.DerCodec.encode({
|
|
520
520
|
certificate,
|
|
521
521
|
signAlgorithm: import_general.X962.EcdsaWithSHA256,
|
|
522
|
-
signature: (0, import_general.BitByteArray)(import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
522
|
+
signature: (0, import_general.BitByteArray)(await import_general.Crypto.sign(key, import_general.DerCodec.encode(certificate), "der"))
|
|
523
523
|
});
|
|
524
524
|
assertCertificateDerSize(certBytes);
|
|
525
525
|
return certBytes;
|
|
@@ -570,7 +570,7 @@ var CertificateManager;
|
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
572
|
CertificateManager2.validateGeneralCertificateFields = validateGeneralCertificateFields;
|
|
573
|
-
function verifyRootCertificate(rootCert) {
|
|
573
|
+
async function verifyRootCertificate(rootCert) {
|
|
574
574
|
CertificateManager2.validateGeneralCertificateFields(rootCert);
|
|
575
575
|
if ("nodeId" in rootCert.subject) {
|
|
576
576
|
throw new CertificateError(`Root certificate must not contain a nodeId.`);
|
|
@@ -626,10 +626,10 @@ var CertificateManager;
|
|
|
626
626
|
`Root certificate authorityKeyIdentifier must be equal to subjectKeyIdentifier.`
|
|
627
627
|
);
|
|
628
628
|
}
|
|
629
|
-
import_general.Crypto.verify((0, import_general.PublicKey)(rootCert.ellipticCurvePublicKey), rootCertToAsn1(rootCert), rootCert.signature);
|
|
629
|
+
await import_general.Crypto.verify((0, import_general.PublicKey)(rootCert.ellipticCurvePublicKey), rootCertToAsn1(rootCert), rootCert.signature);
|
|
630
630
|
}
|
|
631
631
|
CertificateManager2.verifyRootCertificate = verifyRootCertificate;
|
|
632
|
-
function verifyNodeOperationalCertificate(nocCert, rootCert, icaCert) {
|
|
632
|
+
async function verifyNodeOperationalCertificate(nocCert, rootCert, icaCert) {
|
|
633
633
|
CertificateManager2.validateGeneralCertificateFields(nocCert);
|
|
634
634
|
if (nocCert.subject.nodeId === void 0 || Array.isArray(nocCert.subject.nodeId)) {
|
|
635
635
|
throw new CertificateError(`Invalid nodeId in NoC certificate: ${import_general.Diagnostic.json(nocCert.subject.nodeId)}`);
|
|
@@ -701,14 +701,14 @@ var CertificateManager;
|
|
|
701
701
|
`Noc certificate authorityKeyIdentifier must be equal to Root/Ica subjectKeyIdentifier.`
|
|
702
702
|
);
|
|
703
703
|
}
|
|
704
|
-
import_general.Crypto.verify(
|
|
704
|
+
await import_general.Crypto.verify(
|
|
705
705
|
(0, import_general.PublicKey)((icaCert ?? rootCert).ellipticCurvePublicKey),
|
|
706
706
|
nodeOperationalCertToAsn1(nocCert),
|
|
707
707
|
nocCert.signature
|
|
708
708
|
);
|
|
709
709
|
}
|
|
710
710
|
CertificateManager2.verifyNodeOperationalCertificate = verifyNodeOperationalCertificate;
|
|
711
|
-
function verifyIntermediateCaCertificate(rootCert, icaCert) {
|
|
711
|
+
async function verifyIntermediateCaCertificate(rootCert, icaCert) {
|
|
712
712
|
CertificateManager2.validateGeneralCertificateFields(icaCert);
|
|
713
713
|
if ("nodeId" in icaCert.subject) {
|
|
714
714
|
throw new CertificateError(`Ica certificate must not contain a nodeId.`);
|
|
@@ -776,10 +776,14 @@ var CertificateManager;
|
|
|
776
776
|
`Ica certificate authorityKeyIdentifier must be equal to root cert subjectKeyIdentifier.`
|
|
777
777
|
);
|
|
778
778
|
}
|
|
779
|
-
import_general.Crypto.verify(
|
|
779
|
+
await import_general.Crypto.verify(
|
|
780
|
+
(0, import_general.PublicKey)(rootCert.ellipticCurvePublicKey),
|
|
781
|
+
intermediateCaCertToAsn1(icaCert),
|
|
782
|
+
icaCert.signature
|
|
783
|
+
);
|
|
780
784
|
}
|
|
781
785
|
CertificateManager2.verifyIntermediateCaCertificate = verifyIntermediateCaCertificate;
|
|
782
|
-
function createCertificateSigningRequest(key) {
|
|
786
|
+
async function createCertificateSigningRequest(key) {
|
|
783
787
|
const request = {
|
|
784
788
|
version: 0,
|
|
785
789
|
subject: { organization: import_general.X520.OrganisationName("CSR") },
|
|
@@ -789,11 +793,11 @@ var CertificateManager;
|
|
|
789
793
|
return import_general.DerCodec.encode({
|
|
790
794
|
request,
|
|
791
795
|
signAlgorithm: import_general.X962.EcdsaWithSHA256,
|
|
792
|
-
signature: (0, import_general.BitByteArray)(import_general.Crypto.sign(key, import_general.DerCodec.encode(request), "der"))
|
|
796
|
+
signature: (0, import_general.BitByteArray)(await import_general.Crypto.sign(key, import_general.DerCodec.encode(request), "der"))
|
|
793
797
|
});
|
|
794
798
|
}
|
|
795
799
|
CertificateManager2.createCertificateSigningRequest = createCertificateSigningRequest;
|
|
796
|
-
function getPublicKeyFromCsr(csr) {
|
|
800
|
+
async function getPublicKeyFromCsr(csr) {
|
|
797
801
|
const { [import_general.DerKey.Elements]: rootElements } = import_general.DerCodec.decode(csr);
|
|
798
802
|
if (rootElements?.length !== 3) throw new CertificateError("Invalid CSR data");
|
|
799
803
|
const [requestNode, signAlgorithmNode, signatureNode] = rootElements;
|
|
@@ -811,7 +815,7 @@ var CertificateManager;
|
|
|
811
815
|
signAlgorithmNode[import_general.DerKey.Elements]?.[0]?.[import_general.DerKey.Bytes]
|
|
812
816
|
))
|
|
813
817
|
throw new CertificateError("Unsupported signature type");
|
|
814
|
-
import_general.Crypto.verify((0, import_general.PublicKey)(publicKey), import_general.DerCodec.encode(requestNode), signatureNode[import_general.DerKey.Bytes], "der");
|
|
818
|
+
await import_general.Crypto.verify((0, import_general.PublicKey)(publicKey), import_general.DerCodec.encode(requestNode), signatureNode[import_general.DerKey.Bytes], "der");
|
|
815
819
|
return publicKey;
|
|
816
820
|
}
|
|
817
821
|
CertificateManager2.getPublicKeyFromCsr = getPublicKeyFromCsr;
|