Skip to content
Clients

Browser

A web page can't reach the TPM by itself, so a bridge must be built to a client application to enroll the device. Once the bridge is made, the rest of the integration stays the same.

Coming soon

Root Herald bridges are in development and coming soon: an extension and host your pages will be able to use directly, instead of building your own.

The extra work

Every other client runs where the TPM is. From a page, you ship two pieces those clients don't need: a client application on the device, built on the native SDK, and the bridge between it and your page.

Ways to build a bridge

Browser extension

Your page messages your extension, and your extension passes the message to your client application, which the browser starts and talks to over standard input and output. The answer comes straight back to the page, and only the sites your extension lists can message it.

Watch for: You publish the extension in each browser's store, and your installer registers your application with each browser. In Firefox, a page can't message an extension directly, so a content script relays it.

Link handler

Your client application registers a URL scheme, and your page opens a link that starts it. There's nothing to publish in a store.

Watch for: Any site can open your link. Put only a hand-off key in it, have your application report to your own server, and complete the result only in the browser session that started it.

A client application that long-polls

Your client application runs in the background, like a tray app or an agent, and keeps a long poll open to your server. When your page needs an attestation, your server hands the challenge to the waiting application, which answers it and posts the evidence back while the page waits on your server.

Watch for: Pair each installed application with whoever it answers for, using something the user confirms in both places, such as a short code, and give a challenge only to the application paired with whoever asked.

Build an extension or a link handler

1

Register your link

Have your installer register a scheme for your app, so opening yourapp://… runs it with the link as its argument. The browser asks the user once per site before it opens your app.

Windows registrytext
HKCU\Software\Classes\yourapp
    (Default)      "URL:Your App"
    URL Protocol   ""

HKCU\Software\Classes\yourapp\shell\open\command
    (Default)      "C:\Program Files\YourApp\yourapp.exe" "%1"
Linux: yourapp.desktoptext
[Desktop Entry]
Type=Application
Name=Your App
Exec=/opt/yourapp/yourapp %u
MimeType=x-scheme-handler/yourapp;
NoDisplay=true

On Linux, install the file into ~/.local/share/applications and run xdg-mime default yourapp.desktop x-scheme-handler/yourapp. On macOS, declare the scheme under CFBundleURLTypes in your app's Info.plist; the link arrives as an Apple event rather than an argument.

2

Start a hand-off on your server

When the page wants an attestation, have your server issue a challenge, keep it under a random hand-off key together with the browser session that asked, and send the page a link carrying only that key. The challenge itself never goes in the link.

server (Node)ts
import { randomBytes } from "node:crypto";

app.post("/handoff", async (req, res) => {
  const { nonce, challenge } = await rh.issueChallenge({
    ask: ["identity"],
  });

  const key = randomBytes(24).toString("base64url");

  await saveHandoff(key, { session: sessionOf(req), nonce, challenge });

  res.json({ link: `yourapp://attest?v=1&key=${key}` });
});
3

Open the link from the page

page.tsts
const { link } = await postJSON("/handoff", {});

window.location.href = link;
4

Answer the challenge in your app

In your app, parse the link strictly and fetch the challenge for its key from your server. Use RootHeraldAttest with the attestation key blob your app kept at enrollment to answer it, post the evidence back under the same key, and then open your site to finish. Your app only ever talks to your own server, at an address built into it: never one taken from the link, since any page can open the link.

yourapp.cc
int main(int argc, char** argv) {
    const char* key = argc == 2 ? handoff_key(argv[1]) : NULL;

    if (key == NULL) {
        return 1;
    }

    const char* challenge = fetch_challenge(key);

    if (challenge == NULL) {
        return 1;
    }

    RH_HANDLE rh;

    if (RootHeraldOpen(&rh) != RH_OK) {
        return 1;
    }

    size_t n, ak_len;

    if (!load_ak_blob(ak, sizeof ak, &ak_len)) {
        RootHeraldClose(rh);
        report_enroll_needed(key);
        return 1;
    }

    RH_STATUS st = RootHeraldAttest(rh, challenge, ak, ak_len,
                                    buf, sizeof buf, &n);

    RootHeraldClose(rh);

    if (st != RH_OK) {
        report_failure(key, st);
        return 1;
    }

    post_evidence(key, buf);

    open_in_browser(key);

    return 0;
}

open_in_browser opens https://yourapp.example/handoff/finish?key=… in the user's default browser.

5

Finish in the same browser session

On your server, verify the evidence only when the finishing request comes from the browser session that started the hand-off. That's what stops another site from opening your link with its own hand-off and collecting this device's answer.

server (Node)ts
app.get("/handoff/:key/challenge", async (req, res) => {
  const handoff = await handoffOf(req.params.key);

  if (!handoff) {
    return res.sendStatus(404);
  }

  res.json({ challenge: handoff.challenge });
});

app.post("/handoff/:key/evidence", async (req, res) => {
  await saveEvidence(req.params.key, req.body.evidence);

  res.sendStatus(204);
});

app.get("/handoff/finish", async (req, res) => {
  const handoff = await handoffOf(String(req.query.key));

  if (!handoff?.evidence || handoff.session !== sessionOf(req)) {
    return res.sendStatus(403);
  }

  const result = await rh.verify(handoff.evidence, {
    nonce: handoff.nonce,
  });

  await applyVerdict(req, result);

  res.redirect("/");
});

The finish page opens in the default browser, so the hand-off completes when that's the browser the user started in.

Mobile browsers

On a phone, the bridge is a link into your app. On iOS, that's a Universal Link: your page opens it with a hand-off key, your app answers the challenge with the Root Herald iOS SDK and posts the evidence to your server, and the result completes in the browser session that started it, as with a link handler. Root Herald has no Android client SDK yet.

Apple: supporting universal links in your app ↗

Enroll through your client application

Once the bridge is in place, enrollment follows the normal steps for your client application's platform: Windows, Linux, macOS or iOS. On Windows, enroll from your installer, which already runs elevated, while a link or an extension starts your app without elevation.