@aptos-labs/inference-verifier 0.0.0-stage → 0.1.1
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/LICENSE +176 -0
- package/README.md +84 -2
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.js +66 -0
- package/dist/bytes.js.map +1 -0
- package/dist/dcap.d.ts +12 -0
- package/dist/dcap.js +583 -0
- package/dist/dcap.js.map +1 -0
- package/dist/der.d.ts +12 -0
- package/dist/der.js +79 -0
- package/dist/der.js.map +1 -0
- package/dist/document.d.ts +27 -0
- package/dist/document.js +159 -0
- package/dist/document.js.map +1 -0
- package/dist/error.d.ts +6 -0
- package/dist/error.js +12 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/intel-root.d.ts +1 -0
- package/dist/intel-root.js +3 -0
- package/dist/intel-root.js.map +1 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.js +234 -0
- package/dist/json.js.map +1 -0
- package/dist/policy.d.ts +2 -0
- package/dist/policy.js +37 -0
- package/dist/policy.js.map +1 -0
- package/dist/quote.d.ts +38 -0
- package/dist/quote.js +123 -0
- package/dist/quote.js.map +1 -0
- package/dist/sigstore.d.ts +44 -0
- package/dist/sigstore.js +385 -0
- package/dist/sigstore.js.map +1 -0
- package/dist/trusted_root.json +126 -0
- package/dist/verify.d.ts +21 -0
- package/dist/verify.js +77 -0
- package/dist/verify.js.map +1 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aptos-labs/inference-verifier
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@aptos-labs/inference-verifier` verifies attestation documents from the Aptos confidential inference router. It validates Intel TDX evidence, signed release provenance, and hardware measurements using the collateral included in the document and the package's bundled trust roots. Verification runs locally without contacting Intel, GitHub, Sigstore, or the attestation collateral service (ATC).
|
|
4
|
+
|
|
5
|
+
The package is implemented in TypeScript, is distributed as an ECMAScript module (ESM), and requires Node.js 22 or later. Browser runtimes are not supported.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @aptos-labs/inference-verifier
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
[`@aptos-labs/inference-sdk`](https://www.npmjs.com/package/@aptos-labs/inference-sdk) integrates this verifier with attestation retrieval and TLS pinning. Use the verifier directly when implementing those parts of the client yourself.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Call `verifyRouterDocument` with the received document bytes, the nonce used to request that document, the trusted source repository, and the current time:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { verifyRouterDocument } from "@aptos-labs/inference-verifier";
|
|
21
|
+
|
|
22
|
+
const evidence = verifyRouterDocument(
|
|
23
|
+
bytes,
|
|
24
|
+
nonce,
|
|
25
|
+
"aptos-labs/confidential-inference-router",
|
|
26
|
+
Math.floor(Date.now() / 1000),
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The function is synchronous and returns a `RouterEvidence` object after all checks pass.
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Description |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `bytes` | `Uint8Array` | Complete UTF-8 JSON attestation document in the Tinfoil v3 format, including its collateral. The maximum size is 4 MiB. |
|
|
35
|
+
| `nonce` | `Uint8Array` | The 32-byte nonce generated by the caller and sent in the attestation request. |
|
|
36
|
+
| `repo` | `string` | Trusted GitHub repository in `owner/repo` format, without a URL prefix or `@tag` suffix. |
|
|
37
|
+
| `nowSecs` | `number` | Current Unix time in seconds, used to check Intel certificate, revocation-list, and collateral validity. |
|
|
38
|
+
|
|
39
|
+
Generate a fresh random nonce for each attestation request and retain it for verification. The repository and verification time come from the caller's configuration and clock; the document does not establish those trusted inputs.
|
|
40
|
+
|
|
41
|
+
To require a specific release, compare `evidence.releaseTag` with the expected tag after verification. The SDK performs this comparison when its `configRepo` option includes an `@tag` suffix.
|
|
42
|
+
|
|
43
|
+
## Verification policy
|
|
44
|
+
|
|
45
|
+
The verifier accepts Intel TDX quote version 4 for the router's GPU-less `small_0d_v011` hardware profile. Verification covers:
|
|
46
|
+
|
|
47
|
+
- The document structure and the quote's binding to the request nonce, TLS key fingerprint, and HPKE key.
|
|
48
|
+
- Intel DCAP signatures, certificate chains, revocation lists, and collateral validity, with an `UpToDate` trusted computing base (TCB) status.
|
|
49
|
+
- The required TDX module measurements, security versions, attributes, and zero-valued RTMR3.
|
|
50
|
+
- Sigstore release provenance from a GitHub-hosted Actions workflow on a tag in the trusted repository, with RTMR1 and RTMR2 matching the quote.
|
|
51
|
+
- A signed hardware catalog from `tinfoilsh/hardware-measurements`, with MRTD and RTMR0 matching the accepted profile.
|
|
52
|
+
|
|
53
|
+
The policy does not require host-specific platform endorsements or release freshness witnesses. A nonce binds the evidence to a request, but does not establish that the attested release is the latest release or remains approved for deployment. Historical releases can pass verification when they satisfy the repository and measurement checks and the Intel collateral is valid.
|
|
54
|
+
|
|
55
|
+
## Returned evidence
|
|
56
|
+
|
|
57
|
+
The package exports the `RouterEvidence` type with the following fields:
|
|
58
|
+
|
|
59
|
+
| Field | Description |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| `tlsPublicKey` | SHA-256 fingerprint of the TLS public key's DER-encoded SubjectPublicKeyInfo (SPKI), represented as lowercase hexadecimal. |
|
|
62
|
+
| `hpkePublicKey` | The 32-byte X25519 HPKE public key, represented as lowercase hexadecimal. |
|
|
63
|
+
| `mrtd` | The trust domain's initial measurement, represented as lowercase hexadecimal. |
|
|
64
|
+
| `rtmrs` | A tuple containing RTMR0 through RTMR3, each represented as lowercase hexadecimal. |
|
|
65
|
+
| `hardware` | Matched hardware profile and catalog digest in `profile@digest` format. |
|
|
66
|
+
| `releaseDigest` | SHA-256 subject digest from the verified release provenance. |
|
|
67
|
+
| `releaseTag` | Release tag established by the verified GitHub Actions identity. |
|
|
68
|
+
| `codeMeasurement` | Measurement predicate type and register values from the signed code provenance, ordered as SNP, RTMR1, and RTMR2. |
|
|
69
|
+
| `tcbStatus` | Verified Intel TCB status. Successful verification requires `UpToDate`. |
|
|
70
|
+
| `collateralExpiresAt` | Earlier of the Intel TCB information and quoting enclave identity `nextUpdate` timestamps, in Unix seconds. |
|
|
71
|
+
|
|
72
|
+
The caller is responsible for comparing `tlsPublicKey` with the SPKI fingerprint of the TLS connection that delivered the document, and for enforcing that pin on subsequent connections while retaining normal certificate and hostname validation. The verifier does not manage connections or cached sessions. Certificate and revocation-list expiry are checked during verification; they are not included in `collateralExpiresAt`.
|
|
73
|
+
|
|
74
|
+
## Error handling
|
|
75
|
+
|
|
76
|
+
Validation failures raise `VerificationError`, which the package exports alongside the `VerificationCategory` type. The error's `message` describes the failure, and its `category` identifies the failed check:
|
|
77
|
+
|
|
78
|
+
| Category | Description |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `envelope` | Invalid document structure, unsupported document format, or a nonce or report-data mismatch. |
|
|
81
|
+
| `encoding` | Invalid JSON, UTF-8, or binary-field encoding. |
|
|
82
|
+
| `dcap` | Invalid Intel quote, signature, certificate chain, revocation data, or collateral. |
|
|
83
|
+
| `tdx` | TDX measurements, attributes, security versions, or TCB status fail the required policy. |
|
|
84
|
+
| `provenance` | Missing or invalid Sigstore evidence, an unexpected publisher, or code measurements that do not match the quote. |
|
|
85
|
+
| `policy` | Unsupported repository format, CPU or device evidence, missing required keys, or an unrecognized hardware profile. |
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function sha256(data: Uint8Array): Buffer;
|
|
2
|
+
export declare function hex(data: Uint8Array): string;
|
|
3
|
+
export declare function equalBytes(left: Uint8Array, right: Uint8Array): boolean;
|
|
4
|
+
export declare function decodeCanonicalBase64(value: string, what: string): Buffer;
|
|
5
|
+
export declare function decodeLowerHex(value: string, what: string, bytes: number): Buffer;
|
|
6
|
+
export declare function utf8(bytes: Uint8Array, what: string): string;
|
|
7
|
+
export declare function rsToDer(signature: Uint8Array): Buffer;
|
|
8
|
+
export declare function p256Spki(xy: Uint8Array): Buffer;
|
|
9
|
+
export declare function zero(bytes: Uint8Array): boolean;
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { fail } from "./error.js";
|
|
3
|
+
export function sha256(data) {
|
|
4
|
+
return createHash("sha256").update(data).digest();
|
|
5
|
+
}
|
|
6
|
+
export function hex(data) {
|
|
7
|
+
return Buffer.from(data).toString("hex");
|
|
8
|
+
}
|
|
9
|
+
export function equalBytes(left, right) {
|
|
10
|
+
if (left.length !== right.length)
|
|
11
|
+
return false;
|
|
12
|
+
return timingSafeEqual(Buffer.from(left), Buffer.from(right));
|
|
13
|
+
}
|
|
14
|
+
export function decodeCanonicalBase64(value, what) {
|
|
15
|
+
if (value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value)) {
|
|
16
|
+
fail("encoding", `${what} is not canonical base64`);
|
|
17
|
+
}
|
|
18
|
+
const decoded = Buffer.from(value, "base64");
|
|
19
|
+
if (decoded.toString("base64") !== value) {
|
|
20
|
+
fail("encoding", `${what} is not canonical base64`);
|
|
21
|
+
}
|
|
22
|
+
return decoded;
|
|
23
|
+
}
|
|
24
|
+
export function decodeLowerHex(value, what, bytes) {
|
|
25
|
+
if (value.length !== bytes * 2 || !/^[0-9a-f]+$/.test(value)) {
|
|
26
|
+
fail("encoding", `${what} is not ${bytes} bytes of lowercase hex`);
|
|
27
|
+
}
|
|
28
|
+
return Buffer.from(value, "hex");
|
|
29
|
+
}
|
|
30
|
+
export function utf8(bytes, what) {
|
|
31
|
+
const text = Buffer.from(bytes).toString("utf8");
|
|
32
|
+
if (!Buffer.from(text, "utf8").equals(Buffer.from(bytes))) {
|
|
33
|
+
fail("encoding", `${what} is not valid UTF-8`);
|
|
34
|
+
}
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
export function rsToDer(signature) {
|
|
38
|
+
if (signature.length !== 64)
|
|
39
|
+
fail("dcap", "ECDSA signature is not 64 bytes");
|
|
40
|
+
const part = (raw) => {
|
|
41
|
+
let start = 0;
|
|
42
|
+
while (start < raw.length - 1 && raw[start] === 0)
|
|
43
|
+
start += 1;
|
|
44
|
+
let body = Buffer.from(raw.subarray(start));
|
|
45
|
+
if ((body[0] & 0x80) !== 0)
|
|
46
|
+
body = Buffer.concat([Buffer.from([0]), body]);
|
|
47
|
+
return Buffer.concat([Buffer.from([0x02, body.length]), body]);
|
|
48
|
+
};
|
|
49
|
+
const body = Buffer.concat([
|
|
50
|
+
part(signature.subarray(0, 32)),
|
|
51
|
+
part(signature.subarray(32)),
|
|
52
|
+
]);
|
|
53
|
+
if (body.length > 127)
|
|
54
|
+
fail("dcap", "ECDSA signature DER is unexpectedly long");
|
|
55
|
+
return Buffer.concat([Buffer.from([0x30, body.length]), body]);
|
|
56
|
+
}
|
|
57
|
+
export function p256Spki(xy) {
|
|
58
|
+
if (xy.length !== 64)
|
|
59
|
+
fail("dcap", "P-256 key is not 64 bytes");
|
|
60
|
+
const prefix = Buffer.from("3059301306072a8648ce3d020106082a8648ce3d03010703420004", "hex");
|
|
61
|
+
return Buffer.concat([prefix, Buffer.from(xy)]);
|
|
62
|
+
}
|
|
63
|
+
export function zero(bytes) {
|
|
64
|
+
return bytes.every((byte) => byte === 0);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,UAAU,MAAM,CAAC,IAAgB;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAgB;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,KAAiB;IAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,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,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAAc;IACrC,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE;QAAE,IAAI,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CACxB,wDAAwD,EACxD,KAAK,CACN,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAiB;IACpC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/dcap.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CollateralEntry } from "./document.js";
|
|
2
|
+
import { type ParsedQuote, type TdReport } from "./quote.js";
|
|
3
|
+
export interface DcapResult {
|
|
4
|
+
quote: ParsedQuote;
|
|
5
|
+
tcbStatus: string;
|
|
6
|
+
advisoryIds: string[];
|
|
7
|
+
evalDataNumber: number;
|
|
8
|
+
collateralExpiresAt: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function verifyDcap(quoteBytes: Buffer, collateral: CollateralEntry[], now: number, rootDer?: Buffer): DcapResult;
|
|
11
|
+
export declare function reportDataMatches(quote: ParsedQuote, expected: Buffer): void;
|
|
12
|
+
export declare function launchInputsAreZero(td: TdReport): void;
|