@tinfoilsh/verifier 0.1.0
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/README.md +40 -0
- package/dist/attestation.d.ts +19 -0
- package/dist/attestation.d.ts.map +1 -0
- package/dist/attestation.js +127 -0
- package/dist/attestation.js.map +1 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +127 -0
- package/dist/client.js.map +1 -0
- package/dist/github.d.ts +22 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +69 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +13 -0
- package/dist/router.js.map +1 -0
- package/dist/sev/cert-chain.d.ts +22 -0
- package/dist/sev/cert-chain.d.ts.map +1 -0
- package/dist/sev/cert-chain.js +314 -0
- package/dist/sev/cert-chain.js.map +1 -0
- package/dist/sev/certs.d.ts +3 -0
- package/dist/sev/certs.d.ts.map +1 -0
- package/dist/sev/certs.js +77 -0
- package/dist/sev/certs.js.map +1 -0
- package/dist/sev/constants.d.ts +21 -0
- package/dist/sev/constants.d.ts.map +1 -0
- package/dist/sev/constants.js +22 -0
- package/dist/sev/constants.js.map +1 -0
- package/dist/sev/index.d.ts +10 -0
- package/dist/sev/index.d.ts.map +1 -0
- package/dist/sev/index.js +9 -0
- package/dist/sev/index.js.map +1 -0
- package/dist/sev/report.d.ts +52 -0
- package/dist/sev/report.d.ts.map +1 -0
- package/dist/sev/report.js +258 -0
- package/dist/sev/report.js.map +1 -0
- package/dist/sev/types.d.ts +35 -0
- package/dist/sev/types.d.ts.map +1 -0
- package/dist/sev/types.js +2 -0
- package/dist/sev/types.js.map +1 -0
- package/dist/sev/utils.d.ts +8 -0
- package/dist/sev/utils.d.ts.map +1 -0
- package/dist/sev/utils.js +59 -0
- package/dist/sev/utils.js.map +1 -0
- package/dist/sev/validation.d.ts +39 -0
- package/dist/sev/validation.d.ts.map +1 -0
- package/dist/sev/validation.js +323 -0
- package/dist/sev/validation.js.map +1 -0
- package/dist/sev/verify.d.ts +11 -0
- package/dist/sev/verify.d.ts.map +1 -0
- package/dist/sev/verify.js +140 -0
- package/dist/sev/verify.js.map +1 -0
- package/dist/sigstore.d.ts +13 -0
- package/dist/sigstore.d.ts.map +1 -0
- package/dist/sigstore.js +80 -0
- package/dist/sigstore.js.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Report } from './report.js';
|
|
2
|
+
import { CertificateChain } from './cert-chain.js';
|
|
3
|
+
import { tcbFromInt, tcbMeetsMinimum, bytesToHex } from './utils.js';
|
|
4
|
+
import { ReportSigner } from './constants.js';
|
|
5
|
+
import { uint8ArrayEqual } from '@freedomofpress/crypto-browser';
|
|
6
|
+
// Default validation options
|
|
7
|
+
export const defaultValidationOptions = {
|
|
8
|
+
guestPolicy: {
|
|
9
|
+
abiMinor: 0,
|
|
10
|
+
abiMajor: 0,
|
|
11
|
+
smt: true,
|
|
12
|
+
migrateMa: false,
|
|
13
|
+
debug: false,
|
|
14
|
+
singleSocket: false,
|
|
15
|
+
cxlAllowed: false,
|
|
16
|
+
memAes256Xts: false,
|
|
17
|
+
raplDis: false,
|
|
18
|
+
ciphertextHidingDram: false,
|
|
19
|
+
pageSwapDisabled: false,
|
|
20
|
+
},
|
|
21
|
+
minimumGuestSvn: 0,
|
|
22
|
+
minimumBuild: 21,
|
|
23
|
+
minimumVersion: (1 << 8) | 55, // 1.55
|
|
24
|
+
minimumTcb: {
|
|
25
|
+
blSpl: 0x7,
|
|
26
|
+
teeSpl: 0,
|
|
27
|
+
snpSpl: 0xe,
|
|
28
|
+
ucodeSpl: 0x48,
|
|
29
|
+
},
|
|
30
|
+
minimumLaunchTcb: {
|
|
31
|
+
blSpl: 0x7,
|
|
32
|
+
teeSpl: 0,
|
|
33
|
+
snpSpl: 0xe,
|
|
34
|
+
ucodeSpl: 0x48,
|
|
35
|
+
},
|
|
36
|
+
permitProvisionalFirmware: false,
|
|
37
|
+
platformInfo: {
|
|
38
|
+
smtEnabled: true,
|
|
39
|
+
tsmeEnabled: false,
|
|
40
|
+
eccEnabled: false,
|
|
41
|
+
raplDisabled: false,
|
|
42
|
+
ciphertextHidingDramEnabled: false,
|
|
43
|
+
aliasCheckComplete: false,
|
|
44
|
+
tioEnabled: false,
|
|
45
|
+
},
|
|
46
|
+
requireAuthorKey: false,
|
|
47
|
+
requireIdBlock: false,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Validate policy with security-aware checks.
|
|
51
|
+
*
|
|
52
|
+
* Logic:
|
|
53
|
+
* - Check ABI version compatibility
|
|
54
|
+
* - Reject unauthorized capabilities (report has them, required doesn't allow)
|
|
55
|
+
* - Reject missing required restrictions/features
|
|
56
|
+
*
|
|
57
|
+
* @param reportPolicy - The policy from the attestation report
|
|
58
|
+
* @param required - The required policy constraints
|
|
59
|
+
* @throws Error if validation fails
|
|
60
|
+
*/
|
|
61
|
+
function validatePolicy(reportPolicy, required) {
|
|
62
|
+
// ABI version check - required version must not be greater than report version
|
|
63
|
+
if (comparePolicyVersions(required, reportPolicy) > 0) {
|
|
64
|
+
throw new Error(`Required ABI version (${required.abiMajor}.${required.abiMinor}) is greater than report's ABI version (${reportPolicy.abiMajor}.${reportPolicy.abiMinor})`);
|
|
65
|
+
}
|
|
66
|
+
// Unauthorized capabilities (report has them enabled, but required doesn't allow)
|
|
67
|
+
if (!required.migrateMa && reportPolicy.migrateMa) {
|
|
68
|
+
throw new Error(`Found unauthorized migration agent capability. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
69
|
+
}
|
|
70
|
+
if (!required.debug && reportPolicy.debug) {
|
|
71
|
+
throw new Error(`Found unauthorized debug capability. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
72
|
+
}
|
|
73
|
+
if (!required.smt && reportPolicy.smt) {
|
|
74
|
+
throw new Error(`Found unauthorized symmetric multithreading (SMT) capability. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
75
|
+
}
|
|
76
|
+
if (!required.cxlAllowed && reportPolicy.cxlAllowed) {
|
|
77
|
+
throw new Error(`Found unauthorized CXL capability. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
78
|
+
}
|
|
79
|
+
if (!required.memAes256Xts && reportPolicy.memAes256Xts) {
|
|
80
|
+
throw new Error(`Found unauthorized memory encryption mode. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
81
|
+
}
|
|
82
|
+
// Required restrictions/features (report lacks what required mandates)
|
|
83
|
+
if (required.singleSocket && !reportPolicy.singleSocket) {
|
|
84
|
+
throw new Error(`Required single socket restriction not present. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
85
|
+
}
|
|
86
|
+
if (required.memAes256Xts && !reportPolicy.memAes256Xts) {
|
|
87
|
+
throw new Error(`Found unauthorized memory encryption mode. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
88
|
+
}
|
|
89
|
+
if (required.raplDis && !reportPolicy.raplDis) {
|
|
90
|
+
throw new Error(`Found unauthorized RAPL capability. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
91
|
+
}
|
|
92
|
+
if (required.ciphertextHidingDram && !reportPolicy.ciphertextHidingDram) {
|
|
93
|
+
throw new Error(`Ciphertext hiding in DRAM isn't enforced. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
94
|
+
}
|
|
95
|
+
if (required.pageSwapDisabled && !reportPolicy.pageSwapDisabled) {
|
|
96
|
+
throw new Error(`Page swap isn't disabled. Report policy: ${JSON.stringify(reportPolicy)}, Required policy: ${JSON.stringify(required)}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compare policy ABI versions.
|
|
101
|
+
*
|
|
102
|
+
* @param required - Required policy
|
|
103
|
+
* @param report - Report policy
|
|
104
|
+
* @returns > 0 if required version is greater than report version,
|
|
105
|
+
* = 0 if versions are equal,
|
|
106
|
+
* < 0 if required version is less than report version
|
|
107
|
+
*/
|
|
108
|
+
function comparePolicyVersions(required, report) {
|
|
109
|
+
// Compare major version first
|
|
110
|
+
if (required.abiMajor !== report.abiMajor) {
|
|
111
|
+
return required.abiMajor - report.abiMajor;
|
|
112
|
+
}
|
|
113
|
+
// If major versions are equal, compare minor versions
|
|
114
|
+
return required.abiMinor - report.abiMinor;
|
|
115
|
+
}
|
|
116
|
+
function tcbPartsToString(tcb) {
|
|
117
|
+
return `TCBParts(bootloader=${tcb.blSpl}, tee=${tcb.teeSpl}, snp=${tcb.snpSpl}, microcode=${tcb.ucodeSpl})`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Validate the supplied SEV-SNP attestation report according to options.
|
|
121
|
+
*
|
|
122
|
+
* @param report - The attestation report to validate
|
|
123
|
+
* @param chain - The certificate chain
|
|
124
|
+
* @param options - Validation options
|
|
125
|
+
* @throws Error if validation fails
|
|
126
|
+
*/
|
|
127
|
+
export function validateReport(report, chain, options) {
|
|
128
|
+
// Policy constraints
|
|
129
|
+
if (options.guestPolicy) {
|
|
130
|
+
validatePolicy(report.policyParsed, options.guestPolicy);
|
|
131
|
+
}
|
|
132
|
+
if (options.minimumGuestSvn !== undefined) {
|
|
133
|
+
if (report.guestSvn < options.minimumGuestSvn) {
|
|
134
|
+
throw new Error(`Guest SVN ${report.guestSvn} is less than minimum required ${options.minimumGuestSvn}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (options.minimumBuild !== undefined) {
|
|
138
|
+
if (report.currentBuild < options.minimumBuild) {
|
|
139
|
+
throw new Error(`Current SNP firmware build number ${report.currentBuild} is less than minimum required ${options.minimumBuild}`);
|
|
140
|
+
}
|
|
141
|
+
if (report.committedBuild < options.minimumBuild) {
|
|
142
|
+
throw new Error(`Committed SNP firmware build number ${report.committedBuild} is less than minimum required ${options.minimumBuild}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (options.minimumVersion !== undefined) {
|
|
146
|
+
const currentVersion = (report.currentMajor << 8) | report.currentMinor;
|
|
147
|
+
const committedVersion = (report.committedMajor << 8) | report.committedMinor;
|
|
148
|
+
if (currentVersion < options.minimumVersion) {
|
|
149
|
+
throw new Error(`Current SNP firmware version ${report.currentMajor}.${report.currentMinor} is less than minimum required ${options.minimumVersion >> 8}.${options.minimumVersion & 0xff}`);
|
|
150
|
+
}
|
|
151
|
+
if (committedVersion < options.minimumVersion) {
|
|
152
|
+
throw new Error(`Committed SNP firmware version ${report.committedMajor}.${report.committedMinor} is less than minimum required ${options.minimumVersion >> 8}.${options.minimumVersion & 0xff}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// TCB requirements
|
|
156
|
+
if (options.minimumTcb) {
|
|
157
|
+
const currentTcbParts = tcbFromInt(report.currentTcb);
|
|
158
|
+
const committedTcbParts = tcbFromInt(report.committedTcb);
|
|
159
|
+
const reportedTcbParts = tcbFromInt(report.reportedTcb);
|
|
160
|
+
if (!tcbMeetsMinimum(currentTcbParts, options.minimumTcb)) {
|
|
161
|
+
throw new Error(`Current TCB ${tcbPartsToString(currentTcbParts)} does not meet minimum requirements ${tcbPartsToString(options.minimumTcb)}`);
|
|
162
|
+
}
|
|
163
|
+
if (!tcbMeetsMinimum(committedTcbParts, options.minimumTcb)) {
|
|
164
|
+
throw new Error(`Committed TCB ${tcbPartsToString(committedTcbParts)} does not meet minimum requirements ${tcbPartsToString(options.minimumTcb)}`);
|
|
165
|
+
}
|
|
166
|
+
if (!tcbMeetsMinimum(reportedTcbParts, options.minimumTcb)) {
|
|
167
|
+
throw new Error(`Reported TCB ${tcbPartsToString(reportedTcbParts)} does not meet minimum requirements ${tcbPartsToString(options.minimumTcb)}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// VCEK-specific TCB check
|
|
171
|
+
chain.validateVcekTcb(tcbFromInt(report.reportedTcb));
|
|
172
|
+
if (options.minimumLaunchTcb) {
|
|
173
|
+
const launchTcbParts = tcbFromInt(report.launchTcb);
|
|
174
|
+
if (!tcbMeetsMinimum(launchTcbParts, options.minimumLaunchTcb)) {
|
|
175
|
+
throw new Error(`Launch TCB ${tcbPartsToString(launchTcbParts)} does not meet minimum requirements ${tcbPartsToString(options.minimumLaunchTcb)}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Field equality checks
|
|
179
|
+
if (options.reportData) {
|
|
180
|
+
if (report.reportData.length !== 64) {
|
|
181
|
+
throw new Error(`Report data length is ${report.reportData.length}, expected 64 bytes`);
|
|
182
|
+
}
|
|
183
|
+
if (!uint8ArrayEqual(report.reportData, options.reportData)) {
|
|
184
|
+
throw new Error(`Report data mismatch: got ${bytesToHex(report.reportData)}, expected ${bytesToHex(options.reportData)}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (options.hostData) {
|
|
188
|
+
if (report.hostData.length !== 32) {
|
|
189
|
+
throw new Error(`Host data length is ${report.hostData.length}, expected 32 bytes`);
|
|
190
|
+
}
|
|
191
|
+
if (!uint8ArrayEqual(report.hostData, options.hostData)) {
|
|
192
|
+
throw new Error(`Host data mismatch: got ${bytesToHex(report.hostData)}, expected ${bytesToHex(options.hostData)}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (options.measurement) {
|
|
196
|
+
if (report.measurement.length !== 48) {
|
|
197
|
+
throw new Error(`Measurement length is ${report.measurement.length}, expected 48 bytes`);
|
|
198
|
+
}
|
|
199
|
+
if (!uint8ArrayEqual(report.measurement, options.measurement)) {
|
|
200
|
+
throw new Error(`Measurement mismatch: got ${bytesToHex(report.measurement)}, expected ${bytesToHex(options.measurement)}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (options.chipId) {
|
|
204
|
+
if (report.chipId.length !== 64) {
|
|
205
|
+
throw new Error(`Chip ID length is ${report.chipId.length}, expected 64 bytes`);
|
|
206
|
+
}
|
|
207
|
+
if (!uint8ArrayEqual(report.chipId, options.chipId)) {
|
|
208
|
+
throw new Error(`Chip ID mismatch: got ${bytesToHex(report.chipId)}, expected ${bytesToHex(options.chipId)}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (options.imageId) {
|
|
212
|
+
if (report.imageId.length !== 16) {
|
|
213
|
+
throw new Error(`Image ID length is ${report.imageId.length}, expected 16 bytes`);
|
|
214
|
+
}
|
|
215
|
+
if (!uint8ArrayEqual(report.imageId, options.imageId)) {
|
|
216
|
+
throw new Error(`Image ID mismatch: got ${bytesToHex(report.imageId)}, expected ${bytesToHex(options.imageId)}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (options.familyId) {
|
|
220
|
+
if (report.familyId.length !== 16) {
|
|
221
|
+
throw new Error(`Family ID length is ${report.familyId.length}, expected 16 bytes`);
|
|
222
|
+
}
|
|
223
|
+
if (!uint8ArrayEqual(report.familyId, options.familyId)) {
|
|
224
|
+
throw new Error(`Family ID mismatch: got ${bytesToHex(report.familyId)}, expected ${bytesToHex(options.familyId)}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (options.reportId) {
|
|
228
|
+
if (report.reportId.length !== 32) {
|
|
229
|
+
throw new Error(`Report ID length is ${report.reportId.length}, expected 32 bytes`);
|
|
230
|
+
}
|
|
231
|
+
if (!uint8ArrayEqual(report.reportId, options.reportId)) {
|
|
232
|
+
throw new Error(`Report ID mismatch: got ${bytesToHex(report.reportId)}, expected ${bytesToHex(options.reportId)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (options.reportIdMa) {
|
|
236
|
+
if (report.reportIdMa.length !== 32) {
|
|
237
|
+
throw new Error(`Report ID MA length is ${report.reportIdMa.length}, expected 32 bytes`);
|
|
238
|
+
}
|
|
239
|
+
if (!uint8ArrayEqual(report.reportIdMa, options.reportIdMa)) {
|
|
240
|
+
throw new Error(`Report ID MA mismatch: got ${bytesToHex(report.reportIdMa)}, expected ${bytesToHex(options.reportIdMa)}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// VCEK-specific CHIP_ID ↔ HWID equality check
|
|
244
|
+
if (report.signerInfoParsed.signingKey === ReportSigner.VcekReportSigner) {
|
|
245
|
+
if (report.signerInfoParsed.maskChipKey && report.chipId.some(b => b !== 0)) {
|
|
246
|
+
throw new Error('maskChipKey is set but CHIP_ID is not zeroed');
|
|
247
|
+
}
|
|
248
|
+
if (!report.signerInfoParsed.maskChipKey) {
|
|
249
|
+
chain.validateVcekHwid(report.chipId);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Platform info check
|
|
253
|
+
if (options.platformInfo) {
|
|
254
|
+
validatePlatformInfo(report.platformInfoParsed, options.platformInfo);
|
|
255
|
+
}
|
|
256
|
+
// VMPL check
|
|
257
|
+
if (options.vmpl !== undefined) {
|
|
258
|
+
if (!(0 <= report.vmpl && report.vmpl <= 3)) {
|
|
259
|
+
throw new Error(`VMPL ${report.vmpl} is not in valid range 0-3`);
|
|
260
|
+
}
|
|
261
|
+
if (report.vmpl !== options.vmpl) {
|
|
262
|
+
throw new Error(`VMPL mismatch: got ${report.vmpl}, expected ${options.vmpl}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Provisional firmware check - we only support permitProvisionalFirmware = false
|
|
266
|
+
if (options.permitProvisionalFirmware) {
|
|
267
|
+
throw new Error('Provisional firmware is not supported');
|
|
268
|
+
}
|
|
269
|
+
// When permitProvisionalFirmware = false, committed and current values must be equal
|
|
270
|
+
if (report.committedBuild !== report.currentBuild) {
|
|
271
|
+
throw new Error(`Committed build ${report.committedBuild} does not match current build ${report.currentBuild}`);
|
|
272
|
+
}
|
|
273
|
+
if (report.committedMinor !== report.currentMinor) {
|
|
274
|
+
throw new Error(`Committed minor version ${report.committedMinor} does not match current minor version ${report.currentMinor}`);
|
|
275
|
+
}
|
|
276
|
+
if (report.committedMajor !== report.currentMajor) {
|
|
277
|
+
throw new Error(`Committed major version ${report.committedMajor} does not match current major version ${report.currentMajor}`);
|
|
278
|
+
}
|
|
279
|
+
if (report.committedTcb !== report.currentTcb) {
|
|
280
|
+
throw new Error(`Committed TCB 0x${report.committedTcb.toString(16)} does not match current TCB 0x${report.currentTcb.toString(16)}`);
|
|
281
|
+
}
|
|
282
|
+
// ID-block / author key requirements
|
|
283
|
+
if (options.requireAuthorKey || options.requireIdBlock) {
|
|
284
|
+
throw new Error('ID-block and author key requirements are not supported yet');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Validate platform info with security-aware checks.
|
|
289
|
+
*
|
|
290
|
+
* Logic:
|
|
291
|
+
* - If report has a feature enabled that required doesn't allow -> FAIL
|
|
292
|
+
* - If report lacks a feature that required mandates -> FAIL
|
|
293
|
+
*
|
|
294
|
+
* @param reportInfo - Platform info from the attestation report
|
|
295
|
+
* @param required - Required platform info constraints
|
|
296
|
+
* @throws Error if validation fails
|
|
297
|
+
*/
|
|
298
|
+
function validatePlatformInfo(reportInfo, required) {
|
|
299
|
+
// Unauthorized features (report has it enabled, but required doesn't allow it)
|
|
300
|
+
if (reportInfo.smtEnabled && !required.smtEnabled) {
|
|
301
|
+
throw new Error(`Unauthorized platform feature SMT enabled. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
302
|
+
}
|
|
303
|
+
// Required features (report lacks something that required mandates)
|
|
304
|
+
if (!reportInfo.eccEnabled && required.eccEnabled) {
|
|
305
|
+
throw new Error(`Required platform feature ECC not enabled. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
306
|
+
}
|
|
307
|
+
if (!reportInfo.tsmeEnabled && required.tsmeEnabled) {
|
|
308
|
+
throw new Error(`Required platform feature TSME not enabled. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
309
|
+
}
|
|
310
|
+
if (!reportInfo.raplDisabled && required.raplDisabled) {
|
|
311
|
+
throw new Error(`Required platform feature RAPL not disabled. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
312
|
+
}
|
|
313
|
+
if (!reportInfo.ciphertextHidingDramEnabled && required.ciphertextHidingDramEnabled) {
|
|
314
|
+
throw new Error(`Required ciphertext hiding in DRAM not enforced. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
315
|
+
}
|
|
316
|
+
if (!reportInfo.aliasCheckComplete && required.aliasCheckComplete) {
|
|
317
|
+
throw new Error(`Required memory alias check hasn't been completed. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
318
|
+
}
|
|
319
|
+
if (!reportInfo.tioEnabled && required.tioEnabled) {
|
|
320
|
+
throw new Error(`Required TIO not enabled. Report platform info: ${JSON.stringify(reportInfo)}, Required platform info: ${JSON.stringify(required)}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/sev/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CA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chain.js';
|
|
3
|
+
/**
|
|
4
|
+
* Verify attestation report with the certificate chain.
|
|
5
|
+
*
|
|
6
|
+
* @param chain - The certificate chain (ARK > ASK > VCEK)
|
|
7
|
+
* @param report - The attestation report
|
|
8
|
+
* @returns True if verification succeeds
|
|
9
|
+
*/
|
|
10
|
+
export declare function verifyAttestation(chain: CertificateChain, report: Report): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/sev/verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA8ExD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAgBlB"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { POLICY_RESERVED_1_BIT } from './constants.js';
|
|
2
|
+
import { KeyTypes, HashAlgorithms } from '@freedomofpress/crypto-browser';
|
|
3
|
+
/**
|
|
4
|
+
* Verify the attestation report signature using VCEK's public key.
|
|
5
|
+
*
|
|
6
|
+
* @param vcekPublicKey - The VCEK public key
|
|
7
|
+
* @param report - The attestation report
|
|
8
|
+
* @returns True if signature is valid
|
|
9
|
+
* @throws Error if validation fails
|
|
10
|
+
*/
|
|
11
|
+
async function verifyReportSignature(vcekPublicKey, report) {
|
|
12
|
+
// Validate Report Format
|
|
13
|
+
if (report.version < 2) {
|
|
14
|
+
throw new Error(`Report version is lower than 2: is ${report.version}`);
|
|
15
|
+
}
|
|
16
|
+
// Check reserved bit must be 1
|
|
17
|
+
if (!(report.policy & (1n << BigInt(POLICY_RESERVED_1_BIT)))) {
|
|
18
|
+
throw new Error(`policy[${POLICY_RESERVED_1_BIT}] is reserved, must be 1, got 0`);
|
|
19
|
+
}
|
|
20
|
+
// Check policy bits 63-26 must be zero
|
|
21
|
+
if (report.policy >> 26n) {
|
|
22
|
+
throw new Error('policy bits 63-26 must be zero');
|
|
23
|
+
}
|
|
24
|
+
// Check signature algorithm must be ECDSA
|
|
25
|
+
if (report.signatureAlgo !== 1) { // 1 = SignEcdsaP384Sha384
|
|
26
|
+
throw new Error(`Unknown SignatureAlgo: ${report.signatureAlgo}`);
|
|
27
|
+
}
|
|
28
|
+
// Convert the signature from AMD's little-endian format to WebCrypto raw format
|
|
29
|
+
// The signature in the report is in raw R||S format in AMD's little-endian format
|
|
30
|
+
// Each component is 72 bytes (0x48) for P384, zero-extended
|
|
31
|
+
// WebCrypto expects raw format: R || S as big-endian, each padded to curve size (48 bytes for P-384)
|
|
32
|
+
// Reverse bytes to convert from little-endian to big-endian
|
|
33
|
+
const rBytesLE = report.signature.slice(0, 0x48);
|
|
34
|
+
const sBytesLE = report.signature.slice(0x48, 0x90);
|
|
35
|
+
const rBytesBE = reverseBytes(rBytesLE);
|
|
36
|
+
const sBytesBE = reverseBytes(sBytesLE);
|
|
37
|
+
// Strip leading zeros and convert to BigInt for normalization
|
|
38
|
+
const r = bytesToBigInt(stripLeadingZeros(rBytesBE));
|
|
39
|
+
const s = bytesToBigInt(stripLeadingZeros(sBytesBE));
|
|
40
|
+
// Convert back to fixed 48-byte arrays (P-384 curve size)
|
|
41
|
+
const rRaw = bigIntToFixedBytes(r, 48);
|
|
42
|
+
const sRaw = bigIntToFixedBytes(s, 48);
|
|
43
|
+
// Create raw signature: R || S
|
|
44
|
+
const rawSignature = new Uint8Array(96);
|
|
45
|
+
rawSignature.set(rRaw, 0);
|
|
46
|
+
rawSignature.set(sRaw, 48);
|
|
47
|
+
// Get the signed data - slice to ensure we have the correct view
|
|
48
|
+
const signedData = report.signedData.slice();
|
|
49
|
+
try {
|
|
50
|
+
const isValid = await crypto.subtle.verify({ name: KeyTypes.Ecdsa, hash: HashAlgorithms.SHA384 }, vcekPublicKey, rawSignature, signedData);
|
|
51
|
+
return isValid;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
throw new Error('Attestation signature verification failed', { cause: e });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Verify attestation report with the certificate chain.
|
|
59
|
+
*
|
|
60
|
+
* @param chain - The certificate chain (ARK > ASK > VCEK)
|
|
61
|
+
* @param report - The attestation report
|
|
62
|
+
* @returns True if verification succeeds
|
|
63
|
+
*/
|
|
64
|
+
export async function verifyAttestation(chain, report) {
|
|
65
|
+
// Verify certificate chain
|
|
66
|
+
const isChainValid = await chain.verifyChain();
|
|
67
|
+
if (!isChainValid) {
|
|
68
|
+
throw new Error('Certificate chain verification returned false');
|
|
69
|
+
}
|
|
70
|
+
// Get the CryptoKey from VCEK certificate
|
|
71
|
+
// (EC P-384 key type is validated in validateVcekFormat during chain verification)
|
|
72
|
+
const vcekPublicKey = await chain.vcekPublicKey;
|
|
73
|
+
const isSignatureValid = await verifyReportSignature(vcekPublicKey, report);
|
|
74
|
+
if (!isSignatureValid) {
|
|
75
|
+
throw new Error('Report signature verification returned false');
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Reverse the bytes in a bytes array.
|
|
81
|
+
*
|
|
82
|
+
* @param bytes - The bytes array to reverse
|
|
83
|
+
* @returns The reversed bytes array
|
|
84
|
+
*/
|
|
85
|
+
function reverseBytes(bytes) {
|
|
86
|
+
return new Uint8Array([...bytes].reverse());
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Strip leading zeros from a bytes array.
|
|
90
|
+
*
|
|
91
|
+
* @param bytes - The bytes array to strip
|
|
92
|
+
* @returns The bytes array without leading zeros
|
|
93
|
+
*/
|
|
94
|
+
function stripLeadingZeros(bytes) {
|
|
95
|
+
let start = 0;
|
|
96
|
+
while (start < bytes.length && bytes[start] === 0) {
|
|
97
|
+
start++;
|
|
98
|
+
}
|
|
99
|
+
if (start === bytes.length) {
|
|
100
|
+
return new Uint8Array([0]);
|
|
101
|
+
}
|
|
102
|
+
return bytes.slice(start);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert a bytes array to a bigint.
|
|
106
|
+
*
|
|
107
|
+
* @param bytes - The bytes array to convert
|
|
108
|
+
* @returns The bigint
|
|
109
|
+
*/
|
|
110
|
+
function bytesToBigInt(bytes) {
|
|
111
|
+
if (bytes.length === 0) {
|
|
112
|
+
return 0n;
|
|
113
|
+
}
|
|
114
|
+
let result = 0n;
|
|
115
|
+
for (const byte of bytes) {
|
|
116
|
+
result = (result << 8n) | BigInt(byte);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Convert a bigint to a fixed-size bytes array (big-endian, zero-padded).
|
|
122
|
+
*
|
|
123
|
+
* @param value - The bigint to convert
|
|
124
|
+
* @param size - The desired size in bytes
|
|
125
|
+
* @returns The bytes array
|
|
126
|
+
*/
|
|
127
|
+
function bigIntToFixedBytes(value, size) {
|
|
128
|
+
let hex = value.toString(16);
|
|
129
|
+
if (hex.length % 2) {
|
|
130
|
+
hex = '0' + hex;
|
|
131
|
+
}
|
|
132
|
+
const bytes = new Uint8Array(size);
|
|
133
|
+
const hexBytes = hex.length / 2;
|
|
134
|
+
const startOffset = size - hexBytes;
|
|
135
|
+
for (let i = 0; i < hexBytes; i++) {
|
|
136
|
+
bytes[startOffset + i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
137
|
+
}
|
|
138
|
+
return bytes;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/sev/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,E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AQ,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,CAAC;IAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AttestationMeasurement } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Verifies the attested measurements of an enclave image against a trusted root (Sigstore)
|
|
4
|
+
* and returns the measurement payload contained in the DSSE.
|
|
5
|
+
*
|
|
6
|
+
* @param bundleJson - The bundle JSON data
|
|
7
|
+
* @param digest - The expected hex-encoded SHA256 digest of the DSSE payload
|
|
8
|
+
* @param repo - The repository name
|
|
9
|
+
* @returns The verified measurement data
|
|
10
|
+
* @throws Error if verification fails or digests don't match
|
|
11
|
+
*/
|
|
12
|
+
export declare function verifyAttestation(bundleJson: unknown, digest: string, repo: string): Promise<AttestationMeasurement>;
|
|
13
|
+
//# sourceMappingURL=sigstore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sigstore.d.ts","sourceRoot":"","sources":["../src/sigstore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAuBzD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sBAAsB,CAAC,CAyEjC"}
|
package/dist/sigstore.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { PredicateType } from './types.js';
|
|
2
|
+
class GitHubWorkflowRefPattern {
|
|
3
|
+
pattern;
|
|
4
|
+
constructor(pattern) {
|
|
5
|
+
this.pattern = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
6
|
+
}
|
|
7
|
+
verify(cert) {
|
|
8
|
+
const ext = cert.extGitHubWorkflowRef;
|
|
9
|
+
if (!ext) {
|
|
10
|
+
throw new Error('Certificate does not contain GitHubWorkflowRef extension');
|
|
11
|
+
}
|
|
12
|
+
if (!this.pattern.test(ext.workflowRef)) {
|
|
13
|
+
throw new Error(`Certificate's GitHubWorkflowRef "${ext.workflowRef}" does not match pattern "${this.pattern}"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Verifies the attested measurements of an enclave image against a trusted root (Sigstore)
|
|
19
|
+
* and returns the measurement payload contained in the DSSE.
|
|
20
|
+
*
|
|
21
|
+
* @param bundleJson - The bundle JSON data
|
|
22
|
+
* @param digest - The expected hex-encoded SHA256 digest of the DSSE payload
|
|
23
|
+
* @param repo - The repository name
|
|
24
|
+
* @returns The verified measurement data
|
|
25
|
+
* @throws Error if verification fails or digests don't match
|
|
26
|
+
*/
|
|
27
|
+
export async function verifyAttestation(bundleJson, digest, repo) {
|
|
28
|
+
try {
|
|
29
|
+
const { SigstoreVerifier, TrustedRootProvider, GITHUB_OIDC_ISSUER, AllOf, OIDCIssuer, GitHubWorkflowRepository, } = await import('@freedomofpress/sigstore-browser');
|
|
30
|
+
const verifier = new SigstoreVerifier();
|
|
31
|
+
const tufProvider = new TrustedRootProvider({ disableCache: true });
|
|
32
|
+
await verifier.loadSigstoreRootWithTUF(tufProvider);
|
|
33
|
+
const bundle = bundleJson;
|
|
34
|
+
// Create policy for GitHub Actions certificate identity
|
|
35
|
+
const policy = new AllOf([
|
|
36
|
+
new OIDCIssuer(GITHUB_OIDC_ISSUER),
|
|
37
|
+
new GitHubWorkflowRepository(repo),
|
|
38
|
+
new GitHubWorkflowRefPattern(/^refs\/tags\//),
|
|
39
|
+
]);
|
|
40
|
+
// Verify the DSSE envelope and get the payload
|
|
41
|
+
// This verifies the signature on the DSSE envelope, applies the
|
|
42
|
+
// certificate identity policy, and checks Rekor log consistency.
|
|
43
|
+
// It returns the verified payload from within the envelope.
|
|
44
|
+
const { payloadType, payload: payloadBytes } = await verifier.verifyDsse(bundle, policy);
|
|
45
|
+
const payload = JSON.parse(new TextDecoder().decode(payloadBytes));
|
|
46
|
+
if (payloadType !== 'application/vnd.in-toto+json') {
|
|
47
|
+
throw new Error(`Unsupported payload type: ${payloadType}. Only supports In-toto.`);
|
|
48
|
+
}
|
|
49
|
+
const predicateType = payload.predicateType;
|
|
50
|
+
const predicateFields = payload.predicate;
|
|
51
|
+
// Manual Payload Digest Verification
|
|
52
|
+
// Now, verify that the provided external digest matches the
|
|
53
|
+
// actual digest in the payload returned from the verified envelope
|
|
54
|
+
if (digest !== payload.subject[0].digest.sha256) {
|
|
55
|
+
throw new Error(`Provided digest does not match verified DSSE payload digest. Expected: ${digest}, Got: ${payload.subject[0].digest.sha256}`);
|
|
56
|
+
}
|
|
57
|
+
// Convert predicate type to measurement type
|
|
58
|
+
let registers;
|
|
59
|
+
if (!predicateFields) {
|
|
60
|
+
throw new Error('Payload does not contain predicate');
|
|
61
|
+
}
|
|
62
|
+
if (predicateType === PredicateType.SnpTdxMultiplatformV1) {
|
|
63
|
+
if (!predicateFields.snp_measurement) {
|
|
64
|
+
throw new Error('SNP TDX Multiplatform V1 predicate does not contain snp_measurement');
|
|
65
|
+
}
|
|
66
|
+
registers = [predicateFields.snp_measurement];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`Unsupported predicate type: ${predicateType}`);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
type: predicateType,
|
|
73
|
+
registers,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new Error('Attestation processing failed', { cause: e });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=sigstore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sigstore.js","sourceRoot":"","sources":["../src/sigstore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,wBAAwB;IACpB,OAAO,CAAS;IAExB,YAAY,OAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,IAAqB;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC;QACtC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,oCAAoC,GAAG,CAAC,WAAW,6BAA6B,IAAI,CAAC,OAAO,GAAG,CAChG,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAmB,EACnB,MAAc,EACd,IAAY;IAGZ,IAAI,CAAC;QACH,MAAM,EACJ,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,KAA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