From 636b705d1de119321a64340a21f7320283cb777e Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Mon, 14 Sep 2026 08:25:25 -0700 Subject: [PATCH 1/2] feat(verify): check a genuine Intel TDX quote in the browser The homepage is moving to lead with evidence a visitor can check without trusting us. This adds the page it points at. verify/tdx-verify.js ports agent_manifest._tdx_verify to WebCrypto: the same parse, the same checks on every declared length, the same four steps in the same order. /verify/ runs it on the two GCP C3 captures from 2026-07-21, or on a quote file the reader loads. A port that agrees on two genuine quotes can still disagree on everything else. verifier.yml installs agent-manifest 0.12.0, records its verdict on 3,684 inputs derived from the captures (byte flips across every length and type field and the PEM text, a stride over the rest, truncations at each structure edge) and fails if the port decides any of them differently. Locally 3,684 of 3,684 agree and 1,248 are accepted. Every accepted flip sits after the declared signature data or on a newline outside the certificate blocks, which both parsers ignore. The page states the limit first: these captures bind a manifest hash whose input was never published, so a pass proves genuine TDX silicon and does not tie a record to the machine. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_013aK3gVWzNdcM3hZ2o2awK2 --- .github/workflows/verifier.yml | 39 ++ llms.txt | 1 + sitemap.xml | 1 + tools/check-tdx-verifier.mjs | 97 ++++ tools/tdx-differential.py | 120 +++++ .../fixtures/gcp-tdx-2026-07-21-tdx_quote.bin | Bin 0 -> 8000 bytes .../gcp-tdx-2026-07-21-tdx_quote_manifest.bin | Bin 0 -> 8000 bytes verify/index.html | 152 ++++++ verify/package.json | 4 + verify/tdx-verify.js | 449 ++++++++++++++++++ verify/verify-page.js | 93 ++++ 11 files changed, 956 insertions(+) create mode 100644 .github/workflows/verifier.yml create mode 100644 tools/check-tdx-verifier.mjs create mode 100644 tools/tdx-differential.py create mode 100644 verify/fixtures/gcp-tdx-2026-07-21-tdx_quote.bin create mode 100644 verify/fixtures/gcp-tdx-2026-07-21-tdx_quote_manifest.bin create mode 100644 verify/index.html create mode 100644 verify/package.json create mode 100644 verify/tdx-verify.js create mode 100644 verify/verify-page.js diff --git a/.github/workflows/verifier.yml b/.github/workflows/verifier.yml new file mode 100644 index 0000000..09f0a5f --- /dev/null +++ b/.github/workflows/verifier.yml @@ -0,0 +1,39 @@ +name: Browser TDX verifier + +# verify/tdx-verify.js is a port of agent_manifest._tdx_verify, published on the +# homepage as the thing a visitor can check without trusting us. A port that +# drifts from its original is exactly the kind of quiet failure that page is +# about, so every change runs both verifiers over the committed captures and a +# few thousand mutated copies and fails on the first disagreement. +# +# No paths filter on purpose: a filter that misses a file is a green check that +# never ran, and this job takes under a minute. + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + differential: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install the Python verifier the port is checked against + run: python -m pip install "agent-manifest==0.12.0" + - name: Record Python verdicts + run: python tools/tdx-differential.py --out differential.json + - uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Replay them through the browser port + run: node tools/check-tdx-verifier.mjs differential.json diff --git a/llms.txt b/llms.txt index 7e498e3..a160e2e 100644 --- a/llms.txt +++ b/llms.txt @@ -7,6 +7,7 @@ AgenTrust is the ecosystem at https://agentrust-io.com and the GitHub organizati ## Start here - [Overview and architecture](https://agentrust-io.com/): The components, trust boundaries, governance, and evidence links. +- [Verify an Intel TDX quote](https://agentrust-io.com/verify/): Runs the four-step DCAP check on a genuine GCP confidential VM quote in the browser, ending at the pinned Intel SGX Root CA. A pass proves genuine Intel TDX silicon signed the quote. These captures do not tie a TRACE record to that machine, and the check does not appraise TCB currency or revocation. - [10-minute tool-call tutorial](https://agentrust-io.com/quickstart/): Write a policy, observe a denied call, and inspect a signed session record on a laptop. Software mode provides no hardware isolation or hardware-backed provenance. - [Weight Custody Manifest (WCM)](https://wcm.agentrust-io.com/): Bind model-weight identity and custody terms to key-release policy. The local walkthrough uses synthetic evidence and a placeholder key; it does not load a real model or demonstrate hardware protection. - [Runnable demos](https://agentrust-io.com/demos/): Software examples for policy decisions, evidence verification, delegation, and model-weight custody. Follow each demo's stated prerequisites and limits. diff --git a/sitemap.xml b/sitemap.xml index d482449..ea90ffc 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -9,4 +9,5 @@ https://agentrust-io.com/quickstart/ https://agentrust-io.com/registry/ https://agentrust-io.com/telemetry/ + https://agentrust-io.com/verify/ diff --git a/tools/check-tdx-verifier.mjs b/tools/check-tdx-verifier.mjs new file mode 100644 index 0000000..457d17d --- /dev/null +++ b/tools/check-tdx-verifier.mjs @@ -0,0 +1,97 @@ +#!/usr/bin/env node +/** + * Checks verify/tdx-verify.js, the in-browser port of agent_manifest._tdx_verify. + * + * Without an argument it runs the checks that need nothing but this repository: + * the committed captures are the ones the hardware produced, both verify, a + * tampered one and an expired chain are rejected at the right step. + * + * With the JSON written by tools/tdx-differential.py it also replays every + * recorded mutation and fails if the port and the Python original disagree on + * any of them. CI always passes the JSON; see .github/workflows/verifier.yml. + */ +import { readFile } from 'node:fs/promises'; +import { createHash } from 'node:crypto'; +import { + verifyTdxQuote, pinnedRootFingerprint, OFF_MRTD, QUOTE_HEADER_LENGTH, +} from '../verify/tdx-verify.js'; + +const root = new URL('../', import.meta.url); +const WHEN = '2026-09-14T00:00:00Z'; + +// Pinned in agent-manifest's tests/test_tdx_verify.py for the same files, so a +// swapped or re-captured fixture fails here rather than changing what +// "a genuine quote" refers to on the public page. +const CAPTURES = { + 'gcp-tdx-2026-07-21-tdx_quote.bin': 'f9efbac112efe510aa8ccd20703b063591b8c2c54c474d0ff1d6500299bae0ba', + 'gcp-tdx-2026-07-21-tdx_quote_manifest.bin': '1ae04c74b564ef8795d4c4e4ffd1835d080d9dad4f8879e5cd1e8249503828b2', +}; +const MRTD = '9bf86e6280ec4282b8b5822d8166410a456cdb720109aa799f0011fa63df1de3ee5e35e293fc410c061433163acb03a6'; + +const failures = []; +const check = (condition, message) => { if (!condition) failures.push(message); }; + +const load = async (name) => new Uint8Array(await readFile(new URL(`verify/fixtures/${name}`, root))); + +for (const [name, digest] of Object.entries(CAPTURES)) { + const quote = await load(name); + check(createHash('sha256').update(quote).digest('hex') === digest, `${name}: not the committed hardware capture`); + + const result = await verifyTdxQuote(quote, { verificationTime: WHEN }); + check(result.accepted, `${name}: genuine capture rejected (${result.error})`); + check(result.steps.every((s) => s.status === 'pass'), `${name}: a step did not pass`); + check(result.quote && result.quote.mrtd === MRTD, `${name}: MRTD differs from the capture's`); + check(result.quote && result.quote.reportData.slice(64) === '0'.repeat(64), `${name}: REPORTDATA tail is not zero`); + check(result.chain.length === 3, `${name}: expected a three-certificate PCK chain`); + + const tampered = quote.slice(); + tampered[QUOTE_HEADER_LENGTH + OFF_MRTD] ^= 0xff; + const t = await verifyTdxQuote(tampered, { verificationTime: WHEN }); + check(!t.accepted && t.steps[1].status === 'fail', `${name}: tampered MRTD not rejected at the quote signature`); + + const late = await verifyTdxQuote(quote, { verificationTime: '2033-06-01T00:00:00Z' }); + check(!late.accepted && late.steps[4].status === 'fail', `${name}: expired PCK leaf not rejected at the chain`); +} + +const differentialPath = process.argv[2]; +if (differentialPath) { + const report = JSON.parse(await readFile(differentialPath, 'utf8')); + check(report.verification_time.startsWith('2026-09-14T00:00:00'), 'differential ran at a different verification time'); + check(await pinnedRootFingerprint() === report.pinned_root_sha256, + 'pinned Intel root differs from the one agent_manifest._tdx_verify pins'); + + const quotes = {}; + for (const [name, facts] of Object.entries(report.captures)) { + quotes[name] = await load(name); + check(createHash('sha256').update(quotes[name]).digest('hex') === facts.sha256, `${name}: differential used another file`); + } + + const disagreements = []; + for (const c of report.cases) { + let input = quotes[c.capture]; + if (c.mutation.type === 'flip') { + input = input.slice(); + input[c.mutation.offset] ^= 0xff; + } else if (c.mutation.type === 'truncate') { + input = input.slice(0, c.mutation.length); + } + const ours = await verifyTdxQuote(input, { verificationTime: WHEN }); + if (ours.accepted !== c.accepted) { + disagreements.push(`${c.capture} ${JSON.stringify(c.mutation)}: python ${c.outcome}, port ${ours.accepted ? 'accepted' : `rejected (${ours.error})`}`); + } + } + disagreements.slice(0, 25).forEach((d) => failures.push(d)); + if (disagreements.length > 25) failures.push(`...and ${disagreements.length - 25} more disagreements`); + if (disagreements.length === 0) { + const accepted = report.cases.filter((c) => c.accepted).length; + console.log(`PASS port agrees with agent_manifest._tdx_verify on ${report.cases.length} inputs (${accepted} accepted)`); + } +} else { + console.log('differential skipped: pass the JSON from tools/tdx-differential.py to compare with the Python verifier'); +} + +if (failures.length) { + console.error(failures.join('\n')); + process.exit(1); +} +console.log('PASS both GCP TDX captures verify; tampered quote and expired chain are rejected at the right step'); diff --git a/tools/tdx-differential.py b/tools/tdx-differential.py new file mode 100644 index 0000000..70db6d1 --- /dev/null +++ b/tools/tdx-differential.py @@ -0,0 +1,120 @@ +"""Record what agent-manifest's Python TDX verifier decides, for the browser port to match. + +verify/tdx-verify.js is a port of agent_manifest._tdx_verify. A port that agrees +on two genuine quotes can still disagree on everything else, and a verifier that +accepts something its original rejects is worse than no verifier. So this script +takes both committed captures, derives a deterministic set of mutations from +them (every byte of each length and type field, dense coverage of the PEM +boundaries, a stride over everything else, and truncations at each structure +edge) and records the Python verdict for each one. + +tools/check-tdx-verifier.mjs rebuilds the same mutations from this file's output +and fails if the port accepts or rejects any of them differently. + +Usage: python tools/tdx-differential.py --out differential.json +""" +import argparse +import hashlib +import json +import struct +from datetime import datetime, timezone +from pathlib import Path + +from agent_manifest import _tdx_verify +from agent_manifest._tdx_verify import verify_tdx_quote +from cryptography import x509 +from cryptography.hazmat.primitives import hashes + +ROOT = Path(__file__).resolve().parents[1] +FIXTURES = ROOT / "verify" / "fixtures" +CAPTURES = [ + "gcp-tdx-2026-07-21-tdx_quote.bin", + "gcp-tdx-2026-07-21-tdx_quote_manifest.bin", +] +# Fixed, so a certificate expiring can never make the two runs disagree. +VERIFICATION_TIME = "2026-09-14T00:00:00+00:00" +STRIDE = 5 + + +def offsets(quote: bytes) -> list[int]: + """Byte offsets to flip, derived from the quote's own declared layout.""" + auth_size = struct.unpack_from(" list[int]: + auth_size = struct.unpack_from(" dict: + try: + ok = verify_tdx_quote(quote, verification_time=when) + return {"accepted": ok is True, "outcome": "true" if ok is True else "false"} + except Exception as exc: # noqa: BLE001 - every failure mode is a rejection + return {"accepted": False, "outcome": "raise", "error": type(exc).__name__} + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument("--out", required=True) + args = parser.parse_args() + + when = datetime.fromisoformat(VERIFICATION_TIME).astimezone(timezone.utc) + root = x509.load_pem_x509_certificate(_tdx_verify.INTEL_SGX_ROOT_CA_PEM) + report = { + "verification_time": VERIFICATION_TIME, + "pinned_root_sha256": root.fingerprint(hashes.SHA256()).hex(), + "captures": {}, + "cases": [], + } + for name in CAPTURES: + quote = (FIXTURES / name).read_bytes() + parsed = _tdx_verify.parse_tdx_quote(quote) + report["captures"][name] = { + "sha256": hashlib.sha256(quote).hexdigest(), + "mrtd": parsed.mrtd.hex(), + "report_data": parsed.report_data.hex(), + } + report["cases"].append({"capture": name, "mutation": {"type": "none"}, **verdict(quote, when)}) + for offset in offsets(quote): + mutated = bytearray(quote) + mutated[offset] ^= 0xFF + report["cases"].append( + {"capture": name, "mutation": {"type": "flip", "offset": offset}, **verdict(bytes(mutated), when)} + ) + for length in truncations(quote): + report["cases"].append( + {"capture": name, "mutation": {"type": "truncate", "length": length}, **verdict(quote[:length], when)} + ) + + Path(args.out).write_text(json.dumps(report, indent=1) + "\n", encoding="utf-8") + accepted = sum(c["accepted"] for c in report["cases"]) + print(f"recorded {len(report['cases'])} Python verdicts ({accepted} accepted) to {args.out}") + + +if __name__ == "__main__": + main() diff --git a/verify/fixtures/gcp-tdx-2026-07-21-tdx_quote.bin b/verify/fixtures/gcp-tdx-2026-07-21-tdx_quote.bin new file mode 100644 index 0000000000000000000000000000000000000000..f1c8a3c6d416763fa265daac801d208756e08083 GIT binary patch literal 8000 zcmeHKYm6J!6<(6Cgejp=AOR(*piLymmhAYoUh`;k@632SW6yZ!?Xd`nJ+{YVkL|U+ z_SjY$8rqZwq4E}w&_D?#O^XN=(ML+vLZJjup{1lkkN_$~2nZBZAP~}~*YYLHGrmy>4e{03F=eEe^8?ZSK+<0043FGjjuQ|ufp7cMo zA+}pXuFQI_H(uOMGX4LqF5MZrkyzzkSnAeg1vlJ^lW*Yc^CS zO+L0ir?iK^-q+umwf>`G@;kfX<-dOL^7GeZ07ls_R*pOIXU*IDPTgy~yztd`F7^H6 z`hDP}{?k2kFL-L^-N&}o7e9J6^U#W4Rp0;pj-Ri1_>w=$e^~WWbho?(1pdAk6h$+& z=)OyYB?~e)3|=uR!-c+oOIU(Ym@U{__JlqSm12ge#*AXUcP7dNpCDU`4#h?yEZF3U!}G` zxv==nr{7+EY5xNo*DiT~-k!g0e)Cu(-tf>TyY8z*FOChxWn!Ig-J0X(y{}0(WuLe< zv*_cMAKrVU^`1hfSv~9D_-T)Bi4^kBU$eZp=e<+^vgDP$+Mq z)875h@b`EA_>Qm7Sy?cz*zvLJso(w}^!7O~{&Uw4*IE6{SZ?tN)~qX@uUG7cU)!WS zyS~4VLSD?Cy?_3!{o}MclH16B#`u`m$G>-N-1Ok{_#-!7c(W9-^^F^&JG^gr_I$AJ zYHaN@v%i;r@<>bW*sx?(>4vN4(Y$xlKH}|}UtV>F@!r`5Wxus=wX1yHO$(Ra@uSoCTI!UOdcd!}`LFe} zb4#{ef6JoCVw(8mD{GFw%f53LzrOKK_$qtFtfkvmZ+$KJ>|@*GuccQ0+SxXW;%K~J z=a7dsCzc$#J3fq&FgP)ROnO)ceX=Rqt|xPp!a=6%mE%Mdcd(YCDN}GavPOYw5G}yA zL&Q+pk@r08iHoKjR#jRs&Owfb%`z=<-T*Kunjpr1J5&hZ41lCBhe=_#YGg8ep(47Q zaop3aj+H8YxfbIMN^*PBp&`E+$Op#YFz->yA#GR+(-Bpdy$#4!HGc+k8&Ru>XCqJr}I0-F|Cd^nF8d-a^lnRNC(JIv=?x2&9e7I3mTPa%28*a6UrBG($F|L;A5~!xT z17i^nUrZALgtK@;i;wE=Ao>o}A|4%&cwjE!=9@_}kke(CgB@g9+)ftwdYrav@s=we zk1X_1K##=rAUW@gO1SVIPH)C zF&4!yau8&ODUbsI<%Ng}I@_*=Y(2{Z0f!hwU^qt*z|x(NsfT-wKoA6o7Y6g3znrb7 z#f;)&1eeZ)Q1Jl`Wyvbjn8YN#vOuBL7{@e>M(O+Gl?dM^vGhDR82VV^bJNWFV%% zsi|-b?Hoh~YKjRo!r>Hn2;nF}T~B*MV32{HF!Y4L_D<-*!)<)35F&?}z)gj>L*S<} zAUt{)e54oe4MFHN^tdV_Ji@`@Lr+J75HJ`47y<$cKocBzI(a~6d~gvCod6;d6gp>r z5Em#6ngmEX3IHS+fo7?k&0F*Ug`?Y(3KE@D@E$Trr>JnCk|>tctl*NdnAeJAnNXb% zF^&i(GZD6c`_rdlKp=z$C-9ye7z99NFkv|8ra^WlfYN~*2?8VpxCuB)AutA7P*lr8 zvYv0KL$U?p(4KBVH6wep=8vmcxr3VYllu=bjKd6|ibOX1D|NKxkB; zimYoyXtm5>j0pG??vUUxjy4-~4(RRM07Z)ewb6yHR+%6l(g-Le-2oga1?*LaUU9%a zi#qg*12(RDcz*?h1^ z;3jtqM)PRI4)2nw-8m_RKs|+s6e)XxS1K@2R=vb=34FAl_qLeVG0W8vdbx+DYi_%q$-twK)3QmSauGL z%fS-l!NwCcs^Uc7*=QPm+fBDQJ<57Ll%-fNO^>!-yX8uCXpQx}fRPfa zVbNr=AgT@eguFN)1qe$b4Zc)zBDE1QQq}0ppl? literal 0 HcmV?d00001 diff --git a/verify/fixtures/gcp-tdx-2026-07-21-tdx_quote_manifest.bin b/verify/fixtures/gcp-tdx-2026-07-21-tdx_quote_manifest.bin new file mode 100644 index 0000000000000000000000000000000000000000..7d227a6be5d10b52cf9f0c45cd4756920f623836 GIT binary patch literal 8000 zcmeHKYm6J!6fVzl;3;48Pna|1 zf8fsO6-(qNVzYX!n+i`ZSbT7{dtdRKSI7E1XJ4Q#@~+u>(%4nE?b6PA@SA5mw0hN@ zVH3bjCtaU$13mqdgo8C*mCJ_<=?E_9o{Ez2EIQY00q%V zp8w#bLf?|~`hlzGFF*O<@0RsGy+GXk%%g8!`J<-}YL+m*Q+nR)kIv^ufy<>yR&))IU3i>GhBde8m)=DpE(>Z`{6_iR#jy+*yb zZE4|a&+i|*y!YYp)qU?QeD8%#e?Q)c|EB)_k;k^K`uJa`=_79}-n0L%$L2h{`Qb-O zTbEvNC7s{>sq1Y=r#5e*9N^^h>s0c&hy4r#{X8^N!Ct z_Ry!@>b|#^Z@wXM%lMm@>`u(yvG@-5>mQ9dN^5Uhdg0waIOBk+PHWT!-pHLFd*;HE83M>u8^t(=p@v9;fNb0V zHUojdC_zs=R&Xb6Hxv?jz2c}<1cjLvge z&E{ps#buc~*Hk=_7S`mZU|1vzZBAlr2DDcsNocWXH!DFvS#%hNLh&KAv!xfrkyzf! zA`dN2EZTHueh?#}f6{7Q=RhlryL5_xv5-o9VA22AIASQm>Q~=-%fTSmjNkONor_+4CEIJ!8 z+|{Uz7Rz3_8s&9La=KE1L9gM<`9|Ro?@~&E$dDAIL#igb>yWENylKp-hs^?>2?e36 zZU)niVRtHP7#xTAK@ucLx7-X!97U5LVn9hvI9z;9tYroj$TpHPj&Vb7sM@uZO2Tq` zvN%M=NN932VMI$%&sZbHWI(j_X0aA>`t7*n!S#aLOwwvjcd896i833Da@BZ;Kvm7@ z8x6VmLW=MqoW*kP8%tVEu##b~P4hZ zV^RDf2SIv>0$Bi1UWl-uv8`Ij)G|B}aEL(!2D1bKOwA4$TCjT%2!a6d{6LQLmNK=J zm{uH&;Lw-=Dn1ZFSu#sBCNT-OEKq1Q#x@MUjP|36*4ZD%5mhK=8k}h1*fawq8X%^@ zsp)VG?d(Sb)HDV(!r?S{0O2S>9Z$PMV9)?PInWgX+ilQ=2V3}bA%u=%z)gp@Lg1$x zKzR5l_;5Gg9fHt3(B-O#@DK-wjyxR+Lcm}IU@{bOMM-P-vh1 zVO*dvXb>P_D*%vS7#hV=CTG(96pn6B%1^XU!F`00Mo~duIbJBL8NnfAQMVb&Fo7B$ zU~CagWg=_>=O<4^hd>AnOyXTR&yJx0L4Q$5(G#Ha076ZLSPIup{SOG zL@ifW2W1n)$RVX%r{rL5RB`%1yyzLFXpdVSEM zbRFqdtfuF2L%^x7P>Y8`#ZY`Ty#Udq&Rxujf=wB1&{VC4wVKo!Q5c8UopiPQ7DPtkxIB`l>8~FZslc*wXl?&H=Pl! z=_-X`wMoG0Cj?F~V?r|$8NqQg9VSOvRjN5aA}r~2nS@e1i2)>VQWLTql`_OQBr`dG zm%vT!7WBrkh#lS`Q>$}Q^1fOU5h;`xEjexT$W&yt&VCa1N`K^!?cC7VE3>GMxBN;6g&JLKv zkqXg_Q$f>kE+(5JH7$g5^{_i%sx-8$1>=^iYIXmx zv%67ftd`< RWMC!(GZ~o4!2eYS{sUCxr56AI literal 0 HcmV?d00001 diff --git a/verify/index.html b/verify/index.html new file mode 100644 index 0000000..55dc0e7 --- /dev/null +++ b/verify/index.html @@ -0,0 +1,152 @@ + + + + + +Verify an Intel TDX Quote in Your Browser | AgenTrust + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Offline · In your browser · Intel TDX +

Verify a real Intel TDX quote

+

A genuine quote from a GCP C3 confidential VM, checked on your machine the same way our Python verifier checks it: four signatures, ending at the Intel SGX Root CA pinned in this page. Nothing is uploaded.

+ +
Two captures from 21 July 2026 · Checked against the Python verifier on 3,684 inputs
+
+ +
+ +
+ Run it +

Check a capture, or bring your own

+

Both captures come from one trust domain and bind different digests in REPORTDATA. You can also load a TDX v4 quote file from your own machine. It is read locally and never sent anywhere.

+ + + + +
+ +
+ Scope +

What this proves, and what it does not

+

A pass proves genuine Intel TDX silicon produced and signed the quote, through a certificate chain that ends at Intel's root.

+
+

It does not yet tie a TRACE record to this machine. These captures bind a manifest hash in REPORTDATA, and the input to that hash was not published, so the 32 bytes verifiably came from the TEE and cannot be opened. The next capture binds the record-signing key and publishes what it hashes.

+
+

It checks signature chains only. It does not appraise whether the platform's TCB is current, check certificate revocation, or compare MRTD and RTMRs against expected values.

+

Two quotes from one trust domain share an MRTD. Matching a record's claimed measurement against a quote's MRTD binds the record to a measurement, never to a particular quote.

+

Certificate validity is checked against your device's clock.

+
+ +
+ How it matches the original +

A port, held to its original

+

This page runs verify/tdx-verify.js, a port of agent_manifest._tdx_verify: the same parse, the same checks on every length the quote declares, and the same four steps in the same order.

+

On every change, CI runs both verifiers over the two captures and 3,684 generated inputs: byte flips across every length and type field and the certificate text, a stride over everything else, and truncations at each structure edge. It fails if they disagree on a single one.

+

To run the original yourself:

+
+
Terminal
+
python -m pip install agent-manifest
+curl -fsSLO https://agentrust-io.com/verify/fixtures/gcp-tdx-2026-07-21-tdx_quote.bin
+python -c "from agent_manifest._tdx_verify import verify_tdx_quote; print(verify_tdx_quote(open('gcp-tdx-2026-07-21-tdx_quote.bin', 'rb').read()))"
+
+

A genuine quote prints True.

+
+ +
+ +
+
+
+ AgenTrust +
Open specifications for verifiable AI
+
+ +
Sponsored by OPAQUE, which funds the engineering, infrastructure and confidential-computing work behind these projects.
+
+ +
+ + + + + + diff --git a/verify/package.json b/verify/package.json new file mode 100644 index 0000000..e986b24 --- /dev/null +++ b/verify/package.json @@ -0,0 +1,4 @@ +{ + "private": true, + "type": "module" +} diff --git a/verify/tdx-verify.js b/verify/tdx-verify.js new file mode 100644 index 0000000..c8865ab --- /dev/null +++ b/verify/tdx-verify.js @@ -0,0 +1,449 @@ +/* Intel TDX v4 DCAP quote verification, for the browser and for Node. + * + * A port of agent_manifest._tdx_verify (agentrust-io/agent-manifest, + * python/src/agent_manifest/_tdx_verify.py). The profile check, the nested + * type-6 certification-data parse, every declared-length check and the four + * fail-closed steps follow that file in the same order. CI runs both verifiers + * over the committed GCP captures and over mutated copies of them, and fails if + * they ever disagree (tools/tdx-differential.py, tools/check-tdx-verifier.mjs). + * + * WebCrypto does the ECDSA. The rest is parsing, and the only X.509 this file + * understands is what an Intel PCK chain uses: EC keys on P-256 or P-384 with + * ecdsa-with-SHA256/384/512 signatures. Anything else is rejected, never + * skipped. + */ + +// Intel SGX Provisioning Certification Root CA, byte-identical to the copy +// pinned in agent_manifest._tdx_verify. CI compares the two fingerprints. +export const INTEL_SGX_ROOT_CA_PEM = `-----BEGIN CERTIFICATE----- +MIICjzCCAjSgAwIBAgIUImUM1lqdNInzg7SVUr9QGzknBqwwCgYIKoZIzj0EAwIw +aDEaMBgGA1UEAwwRSW50ZWwgU0dYIFJvb3QgQ0ExGjAYBgNVBAoMEUludGVsIENv +cnBvcmF0aW9uMRQwEgYDVQQHDAtTYW50YSBDbGFyYTELMAkGA1UECAwCQ0ExCzAJ +BgNVBAYTAlVTMB4XDTE4MDUyMTEwNDUxMFoXDTQ5MTIzMTIzNTk1OVowaDEaMBgG +A1UEAwwRSW50ZWwgU0dYIFJvb3QgQ0ExGjAYBgNVBAoMEUludGVsIENvcnBvcmF0 +aW9uMRQwEgYDVQQHDAtTYW50YSBDbGFyYTELMAkGA1UECAwCQ0ExCzAJBgNVBAYT +AlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEC6nEwMDIYZOj/iPWsCzaEKi7 +1OiOSLRFhWGjbnBVJfVnkY4u3IjkDYYL0MxO4mqsyYjlBalTVYxFP2sJBK5zlKOB +uzCBuDAfBgNVHSMEGDAWgBQiZQzWWp00ifODtJVSv1AbOScGrDBSBgNVHR8ESzBJ +MEegRaBDhkFodHRwczovL2NlcnRpZmljYXRlcy50cnVzdGVkc2VydmljZXMuaW50 +ZWwuY29tL0ludGVsU0dYUm9vdENBLmRlcjAdBgNVHQ4EFgQUImUM1lqdNInzg7SV +Ur9QGzknBqwwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwCgYI +KoZIzj0EAwIDSQAwRgIhAOW/5QkR+S9CiSDcNoowLuPRLsWGf/Yi7GSX94BgwTwg +AiEA4J0lrHoMs+Xo5o/sX6O9QWxHRAvZUGOdRQ7cvqRXaqI= +-----END CERTIFICATE----- +`; + +const QUOTE_HEADER_LEN = 48; +const TD_REPORT_LEN = 584; +export const OFF_MRTD = 136; +const OFF_RTMR0 = 328; +const OFF_REPORTDATA = 520; +const TDX_QUOTE_VERSION = 4; +const ATT_KEY_TYPE_ECDSA_P256 = 2; +const TEE_TYPE_TDX = 0x81; +const SGX_REPORT_LEN = 384; +const OFF_QE_REPORT_DATA = 320; +const CERT_TYPE_QE_REPORT = 6; +const CERT_TYPE_PCK_CHAIN = 5; + +export const QUOTE_HEADER_LENGTH = QUOTE_HEADER_LEN; + +/** The steps a result reports, in the order the Python verifier runs them. */ +export const STEPS = [ + { id: 'profile', label: 'signed header declares TDX v4 with an ECDSA P-256 attestation key' }, + { id: 'quote-signature', label: 'attestation key signature over header and TD report' }, + { id: 'qe-binding', label: 'QE report binds the attestation key' }, + { id: 'qe-report-signature', label: 'QE report signed by the platform PCK certificate' }, + { id: 'pck-chain', label: 'PCK chain ends at the pinned Intel SGX Root CA' }, +]; + +export class TdxVerificationError extends Error { + constructor(message) { + super(message); + this.name = 'TdxVerificationError'; + } +} + +function fail(message) { + throw new TdxVerificationError(message); +} + +const u16 = (b, o) => b[o] | (b[o + 1] << 8); +const u32 = (b, o) => (b[o] | (b[o + 1] << 8) | (b[o + 2] << 16) | (b[o + 3] << 24)) >>> 0; + +export const hex = (bytes) => Array.from(bytes, (x) => x.toString(16).padStart(2, '0')).join(''); + +function bytesEqual(a, b) { + if (a.length !== b.length) return false; + let diff = 0; + for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i]; + return diff === 0; +} + +function concat(...parts) { + const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0)); + let at = 0; + for (const p of parts) { + out.set(p, at); + at += p.length; + } + return out; +} + +/** Parse the quote header and TD report body. Mirrors parse_tdx_quote(strict=True). */ +export function parseTdxQuote(quote) { + if (quote.length < QUOTE_HEADER_LEN + TD_REPORT_LEN) { + fail(`quote too short: ${quote.length} bytes, need ${QUOTE_HEADER_LEN + TD_REPORT_LEN}`); + } + const version = u16(quote, 0); + const attKeyType = u16(quote, 2); + const teeType = u32(quote, 4); + if (version !== TDX_QUOTE_VERSION) fail(`unsupported TDX quote version ${version} (expected 4)`); + if (attKeyType !== ATT_KEY_TYPE_ECDSA_P256) { + fail(`unsupported TDX attestation key type ${attKeyType} (expected 2)`); + } + if (teeType !== TEE_TYPE_TDX) fail(`not a TDX quote: tee_type 0x${teeType.toString(16)}`); + const body = quote.subarray(QUOTE_HEADER_LEN, QUOTE_HEADER_LEN + TD_REPORT_LEN); + const rtmrs = [0, 1, 2, 3].map((i) => body.subarray(OFF_RTMR0 + i * 48, OFF_RTMR0 + i * 48 + 48)); + return { + version, + teeType, + mrtd: body.subarray(OFF_MRTD, OFF_MRTD + 48), + rtmrs, + reportData: body.subarray(OFF_REPORTDATA, OFF_REPORTDATA + 64), + }; +} + +/** + * Parse the signature section, including the nested type-6 QE-report + * certification data. Every length is declared by the quote, which is + * untrusted, so each one is checked before it is used. Mirrors + * parse_tdx_quote_signature. + */ +export function parseTdxQuoteSignature(quote) { + if (quote.length < QUOTE_HEADER_LEN + TD_REPORT_LEN + 4) fail('quote too short to contain a signature'); + + const signedBody = quote.subarray(0, QUOTE_HEADER_LEN + TD_REPORT_LEN); + let off = QUOTE_HEADER_LEN + TD_REPORT_LEN; + const authSize = u32(quote, off); + off += 4; + if (off + authSize > quote.length) { + fail(`quote declares ${authSize} bytes of signature data, ${quote.length - off} available`); + } + const auth = quote.subarray(off, off + authSize); + if (auth.length < 134) fail('truncated quote signature data'); + + const quoteSignature = auth.subarray(0, 64); + const attestationKey = auth.subarray(64, 128); + const certType = u16(auth, 128); + const certSize = u32(auth, 130); + if (certType !== CERT_TYPE_QE_REPORT) { + fail(`unexpected certification data type ${certType} (expected QE report)`); + } + if (134 + certSize > auth.length) { + fail(`quote declares ${certSize} bytes of QE certification data, ${auth.length - 134} available`); + } + const certData = auth.subarray(134, 134 + certSize); + if (certData.length < 448 + 6) fail('truncated QE certification data'); + + const qeReport = certData.subarray(0, SGX_REPORT_LEN); + const qeReportSignature = certData.subarray(SGX_REPORT_LEN, SGX_REPORT_LEN + 64); + let o2 = SGX_REPORT_LEN + 64; + const qeAuthSize = u16(certData, o2); + o2 += 2; + if (o2 + qeAuthSize + 6 > certData.length) { + fail(`quote declares ${qeAuthSize} bytes of QE auth data, ` + + `${Math.max(0, certData.length - o2 - 6)} available before the PCK header`); + } + const qeAuthData = certData.subarray(o2, o2 + qeAuthSize); + o2 += qeAuthSize; + const pckCertType = u16(certData, o2); + const pckSize = u32(certData, o2 + 2); + o2 += 6; + if (pckCertType !== CERT_TYPE_PCK_CHAIN) { + fail(`unexpected PCK certification type ${pckCertType} (expected PEM chain)`); + } + if (o2 + pckSize > certData.length) { + fail(`quote declares ${pckSize} bytes of PCK chain, ${certData.length - o2} available`); + } + + return { + signedBody, + quoteSignature, + attestationKey, + qeReport, + qeReportSignature, + qeAuthData, + pckChainPem: certData.subarray(o2, o2 + pckSize), + }; +} + +/* ---- DER, only as much as a PCK chain needs ------------------------------ */ + +function tlv(buf, off, end) { + if (off + 2 > end) fail('truncated DER element'); + const tag = buf[off]; + let len = buf[off + 1]; + let header = 2; + if (len & 0x80) { + const n = len & 0x7f; + if (n === 0 || n > 4 || off + 2 + n > end) fail('unsupported DER length'); + len = 0; + for (let i = 0; i < n; i++) len = len * 256 + buf[off + 2 + i]; + header += n; + } + const start = off + header; + if (start + len > end) fail('DER element overruns its container'); + return { tag, start, end: start + len, whole: buf.subarray(off, start + len) }; +} + +function children(buf, el) { + const out = []; + for (let at = el.start; at < el.end;) { + const child = tlv(buf, at, el.end); + out.push(child); + at = child.end; + } + return out; +} + +function expectTag(el, tag, what) { + if (!el || el.tag !== tag) fail(`certificate ${what} is missing or malformed`); + return el; +} + +function objectId(buf, el) { + expectTag(el, 0x06, 'object identifier'); + const b = buf.subarray(el.start, el.end); + if (b.length === 0 || b[b.length - 1] & 0x80) fail('certificate object identifier is truncated'); + const arcs = []; + let value = 0; + for (const byte of b) { + value = value * 128 + (byte & 0x7f); + if (!(byte & 0x80)) { + arcs.push(value); + value = 0; + } + } + const first = arcs.shift(); + const head = first < 40 ? [0, first] : first < 80 ? [1, first - 40] : [2, first - 80]; + return [...head, ...arcs].join('.'); +} + +function certificateTime(buf, el) { + const text = String.fromCharCode(...buf.subarray(el.start, el.end)); + let m; + if (el.tag === 0x17 && (m = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(text))) { + const yy = Number(m[1]); + return Date.UTC(yy >= 50 ? 1900 + yy : 2000 + yy, m[2] - 1, m[3], m[4], m[5], m[6]); + } + if (el.tag === 0x18 && (m = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z$/.exec(text))) { + return Date.UTC(Number(m[1]), m[2] - 1, m[3], m[4], m[5], m[6]); + } + return fail('unsupported certificate time encoding'); +} + +const EC_PUBLIC_KEY = '1.2.840.10045.2.1'; +const CURVES = { '1.2.840.10045.3.1.7': { name: 'P-256', size: 32 }, '1.3.132.0.34': { name: 'P-384', size: 48 } }; +const SIGNATURE_HASHES = { + '1.2.840.10045.4.3.2': 'SHA-256', + '1.2.840.10045.4.3.3': 'SHA-384', + '1.2.840.10045.4.3.4': 'SHA-512', +}; + +function commonName(buf, name) { + for (const set of children(buf, name)) { + for (const pair of children(buf, set)) { + const [type, value] = children(buf, pair); + if (type && value && objectId(buf, type) === '2.5.4.3') { + return new TextDecoder().decode(buf.subarray(value.start, value.end)); + } + } + } + return ''; +} + +/** Parse one DER certificate into the fields chain verification uses. */ +export function parseCertificate(der) { + const cert = tlv(der, 0, der.length); + if (cert.tag !== 0x30 || cert.end !== der.length) fail('certificate is not a single DER SEQUENCE'); + const [tbs, signatureAlgorithm, signatureValue] = children(der, cert); + expectTag(tbs, 0x30, 'TBSCertificate'); + expectTag(signatureAlgorithm, 0x30, 'signature algorithm'); + expectTag(signatureValue, 0x03, 'signature'); + + const fields = children(der, tbs); + const first = fields[0] && fields[0].tag === 0xa0 ? 1 : 0; + const [, , issuer, validity, subject, spki] = fields.slice(first); + expectTag(issuer, 0x30, 'issuer'); + expectTag(validity, 0x30, 'validity'); + expectTag(subject, 0x30, 'subject'); + expectTag(spki, 0x30, 'public key'); + + const [notBefore, notAfter] = children(der, validity); + if (!notBefore || !notAfter) fail('certificate validity is malformed'); + + const [keyAlgorithm] = children(der, spki); + expectTag(keyAlgorithm, 0x30, 'public key algorithm'); + const [keyType, curve] = children(der, keyAlgorithm); + const ec = objectId(der, keyType) === EC_PUBLIC_KEY; + + if (der[signatureValue.start] !== 0) fail('certificate signature has unused bits'); + + return { + der, + tbs: tbs.whole, + spki: spki.whole, + ec, + curve: ec && curve && curve.tag === 0x06 ? CURVES[objectId(der, curve)] || null : null, + hash: SIGNATURE_HASHES[objectId(der, children(der, signatureAlgorithm)[0])] || null, + signature: der.subarray(signatureValue.start + 1, signatureValue.end), + notBefore: certificateTime(der, notBefore), + notAfter: certificateTime(der, notAfter), + subjectCN: commonName(der, subject), + }; +} + +/** Every CERTIFICATE block in a PEM bundle, leaf first. Rejects bad base64. */ +export function pemCertificates(pemBytes) { + let text = ''; + for (const byte of pemBytes) text += String.fromCharCode(byte); + const blocks = [...text.matchAll(/-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/g)]; + if (blocks.length === 0) fail('no certificates found in the PCK chain'); + return blocks.map(([, body]) => { + const b64 = body.replace(/[\r\n\t ]/g, ''); + if (b64.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(b64)) fail('PCK chain PEM is not valid base64'); + const raw = atob(b64); + const der = new Uint8Array(raw.length); + for (let i = 0; i < raw.length; i++) der[i] = raw.charCodeAt(i); + return der; + }); +} + +/** DER ECDSA-Sig-Value to the raw r||s form WebCrypto verifies. */ +function rawSignature(der, size) { + const seq = tlv(der, 0, der.length); + if (seq.tag !== 0x30 || seq.end !== der.length) fail('malformed ECDSA signature'); + const parts = children(der, seq); + if (parts.length !== 2 || parts.some((p) => p.tag !== 0x02)) fail('malformed ECDSA signature'); + const out = new Uint8Array(size * 2); + parts.forEach((part, k) => { + let value = der.subarray(part.start, part.end); + while (value.length > size && value[0] === 0) value = value.subarray(1); + if (value.length > size) fail('ECDSA signature integer is too large'); + out.set(value, k * size + size - value.length); + }); + return out; +} + +const pemToDer = (pem) => pemCertificates(new TextEncoder().encode(pem))[0]; + +async function sha256(subtle, data) { + return new Uint8Array(await subtle.digest('SHA-256', data)); +} + +async function certificateKey(subtle, cert, what) { + if (!cert.ec) fail(`${what} is not an EC key`); + if (!cert.curve) fail(`${what} uses an unsupported curve`); + return subtle.importKey('spki', cert.spki, { name: 'ECDSA', namedCurve: cert.curve.name }, false, ['verify']); +} + +/** SHA-256 of the pinned Intel root, hex. */ +export async function pinnedRootFingerprint(subtle = globalThis.crypto && globalThis.crypto.subtle) { + return hex(await sha256(subtle, pemToDer(INTEL_SGX_ROOT_CA_PEM))); +} + +/** + * Verify a TDX v4 DCAP quote. Resolves to a result object and never rejects: + * `accepted` is true only when every step passed. A step the Python verifier + * would answer with False and a step it would raise on are both a failed step + * here, with `error` carrying the message. + */ +export async function verifyTdxQuote(input, options = {}) { + const quote = input instanceof Uint8Array ? input : new Uint8Array(input); + const subtle = options.subtle || (globalThis.crypto && globalThis.crypto.subtle); + const now = options.verificationTime ? new Date(options.verificationTime) : new Date(); + const steps = STEPS.map((s) => ({ ...s, status: 'not-run', detail: '' })); + const result = { accepted: false, error: null, steps, quote: null, chain: [], checkedAt: now.toISOString() }; + const step = (id) => steps.find((s) => s.id === id); + let current = 'profile'; + const pass = (id, detail) => Object.assign(step(id), { status: 'pass', detail }); + const reject = (id, detail) => { + Object.assign(step(id), { status: 'fail', detail }); + result.error = detail; + return result; + }; + + try { + if (!subtle) fail('this environment does not provide WebCrypto'); + + const parsed = parseTdxQuote(quote); + result.quote = { + mrtd: hex(parsed.mrtd), + rtmrs: parsed.rtmrs.map(hex), + reportData: hex(parsed.reportData), + }; + const sig = parseTdxQuoteSignature(quote); + pass('profile', 'version 4, attestation key type 2, TEE type 0x81'); + + current = 'quote-signature'; + const attestationKey = await subtle.importKey( + 'raw', concat(Uint8Array.of(4), sig.attestationKey), { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify'], + ); + if (!await subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, attestationKey, sig.quoteSignature, sig.signedBody)) { + return reject(current, 'the attestation key signature does not match the header and TD report'); + } + pass(current, `ECDSA P-256 over ${sig.signedBody.length} signed bytes`); + + current = 'qe-binding'; + const expected = await sha256(subtle, concat(sig.attestationKey, sig.qeAuthData)); + if (!bytesEqual(sig.qeReport.subarray(OFF_QE_REPORT_DATA, OFF_QE_REPORT_DATA + 32), expected)) { + return reject(current, 'the QE report does not bind this attestation key'); + } + pass(current, 'QE REPORTDATA equals SHA-256(attestation key, QE auth data)'); + + // The Python verifier loads the chain and checks every validity period + // before step 3, so a chain problem surfaces here, against step 4. + current = 'pck-chain'; + const certs = pemCertificates(sig.pckChainPem).map(parseCertificate); + result.chain = certs.map((c) => ({ + subject: c.subjectCN, + notBefore: new Date(c.notBefore).toISOString(), + notAfter: new Date(c.notAfter).toISOString(), + })); + if (certs.length < 2) fail('PCK chain must contain at least a leaf and the root'); + certs.forEach((c, i) => { + if (!(c.notBefore <= now.getTime() && now.getTime() < c.notAfter)) { + fail(`PCK chain certificate at position ${i} is outside its validity period`); + } + }); + + current = 'qe-report-signature'; + const pck = certs[0]; + const pckKey = await certificateKey(subtle, pck, 'PCK certificate'); + if (!await subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, pckKey, sig.qeReportSignature, sig.qeReport)) { + return reject(current, 'the PCK certificate did not sign this QE report'); + } + pass(current, `signed by ${pck.subjectCN || 'the PCK leaf'}`); + + current = 'pck-chain'; + for (let i = 0; i < certs.length - 1; i++) { + const issuer = certs[i + 1]; + const issuerKey = await certificateKey(subtle, issuer, 'PCK chain issuer'); + if (!certs[i].hash) fail(`PCK chain link ${i} has no supported signature hash algorithm`); + const signature = rawSignature(certs[i].signature, issuer.curve.size); + if (!await subtle.verify({ name: 'ECDSA', hash: certs[i].hash }, issuerKey, signature, certs[i].tbs)) { + fail(`PCK chain link ${i} signature invalid`); + } + } + const chainRoot = await sha256(subtle, certs[certs.length - 1].der); + const pinned = await sha256(subtle, pemToDer(options.trustedRootPem || INTEL_SGX_ROOT_CA_PEM)); + if (!bytesEqual(chainRoot, pinned)) fail('PCK chain root does not match the pinned Intel SGX Root CA'); + pass(current, `${certs.length} certificates, all in date, root SHA-256 ${hex(pinned).slice(0, 16)}...`); + + result.accepted = true; + return result; + } catch (error) { + return reject(current, error && error.message ? error.message : String(error)); + } +} diff --git a/verify/verify-page.js b/verify/verify-page.js new file mode 100644 index 0000000..8c04199 --- /dev/null +++ b/verify/verify-page.js @@ -0,0 +1,93 @@ +/* Drives /verify/: loads a capture or a local file and renders the result of + * verify/tdx-verify.js. Every value shown comes from the verifier's result + * object and is written with textContent, never as markup. + */ +import { verifyTdxQuote } from './tdx-verify.js'; + +const CAPTURES = { + plain: { file: 'fixtures/gcp-tdx-2026-07-21-tdx_quote.bin', label: 'tdx_quote.bin' }, + manifest: { file: 'fixtures/gcp-tdx-2026-07-21-tdx_quote_manifest.bin', label: 'tdx_quote_manifest.bin' }, +}; + +const WORDS = { pass: ['PASS', 'ok'], fail: ['FAIL', 'alert'], 'not-run': ['not run', 'dim'] }; + +const $ = (id) => document.getElementById(id); + +function line(text, kind) { + const div = document.createElement('div'); + if (kind) div.className = kind; + div.textContent = text; + return div; +} + +function row(name, value) { + const tr = document.createElement('tr'); + const th = document.createElement('td'); + th.textContent = name; + const td = document.createElement('td'); + const code = document.createElement('code'); + code.textContent = value; + td.append(code); + tr.append(th, td); + return tr; +} + +function render(result, label, size) { + $('term-title').textContent = `verify ${label}`; + const body = $('term-body'); + body.replaceChildren(line(`quote: ${label}, ${size} bytes`, 'dim')); + result.steps.forEach((step, i) => { + const [word, kind] = WORDS[step.status]; + body.append(line(`${i === 0 ? 'profile' : `step ${i}`}: ${step.label}: ${word}`, kind)); + if (step.detail) body.append(line(step.detail, 'dim')); + }); + if (result.quote) body.append(line(`REPORTDATA[0:32]: ${result.quote.reportData.slice(0, 64)}`, 'dim')); + body.append(result.accepted + ? line('verdict: ACCEPTED. Genuine Intel TDX quote; the chain ends at the pinned Intel root.', 'ok') + : line(`verdict: REJECTED. ${result.error}`, 'alert')); + body.append(line(`checked ${result.checkedAt} against this device's clock`, 'dim')); + + const fields = $('fields'); + fields.replaceChildren(); + if (result.quote) { + fields.append(row('MRTD', result.quote.mrtd)); + result.quote.rtmrs.forEach((value, i) => fields.append(row(`RTMR${i}`, value))); + fields.append(row('REPORTDATA', result.quote.reportData)); + } + result.chain.forEach((cert, i) => { + fields.append(row(`Certificate ${i + 1}`, `${cert.subject}, valid ${cert.notBefore.slice(0, 10)} to ${cert.notAfter.slice(0, 10)}`)); + }); + $('run-status').textContent = result.accepted ? `${label}: accepted` : `${label}: rejected`; +} + +async function run(bytes, label) { + $('run-status').textContent = `Verifying ${label}`; + render(await verifyTdxQuote(bytes), label, bytes.byteLength); +} + +async function runCapture(key) { + const capture = CAPTURES[key]; + try { + const response = await fetch(new URL(capture.file, import.meta.url)); + if (!response.ok) throw new Error(`could not load ${capture.label} (HTTP ${response.status})`); + await run(new Uint8Array(await response.arrayBuffer()), capture.label); + } catch (error) { + $('term-body').replaceChildren(line(error.message, 'alert')); + } +} + +document.querySelectorAll('[data-capture]').forEach((button) => { + button.addEventListener('click', () => runCapture(button.getAttribute('data-capture'))); +}); + +const input = $('quote-file'); +$('load-file').addEventListener('click', () => input.click()); +input.addEventListener('change', async () => { + const file = input.files && input.files[0]; + if (!file) return; + await run(new Uint8Array(await file.arrayBuffer()), file.name); + input.value = ''; +}); + +$('verifier').hidden = false; +runCapture('plain'); From 4c69ed1dedd132aa317b8bfa4eba01d11a0e0580 Mon Sep 17 00:00:00 2001 From: Imran Siddique Date: Mon, 14 Sep 2026 08:36:29 -0700 Subject: [PATCH 2/2] fix(verify): let measurements wrap at phone width The MRTD, RTMR and REPORTDATA rows are 96 unbroken hex characters, so in a 400px frame the table pushed /verify/ to 1068px wide. Offer a break every 16 characters. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_013aK3gVWzNdcM3hZ2o2awK2 --- verify/verify-page.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/verify/verify-page.js b/verify/verify-page.js index 8c04199..0a22079 100644 --- a/verify/verify-page.js +++ b/verify/verify-page.js @@ -26,7 +26,12 @@ function row(name, value) { th.textContent = name; const td = document.createElement('td'); const code = document.createElement('code'); - code.textContent = value; + // A 96-character measurement has no natural break, so offer one every 16 + // characters rather than letting the table push a phone-width page sideways. + (value.match(/.{1,16}/g) || ['']).forEach((chunk, i) => { + if (i) code.append(document.createElement('wbr')); + code.append(chunk); + }); td.append(code); tr.append(th, td); return tr;