ADR-0003: Identity and pairing: P-256 self-signed certificates, pinning, SAS, QR
- Status: accepted
- Date: 2026-11-08
- Deciders: maintainer, after the November 2026 research round
- Tags:
security,protocol,android,linux
Context
Every Tether device needs a long-lived cryptographic identity that (a) works as a TLS 1.3 certificate on both Android and Linux, (b) is hardware-backed on the phone where possible, (c) can be pinned after a one-time pairing so that later connections need no user interaction, and (d) can be verified by a human during pairing on a potentially hostile LAN.
There is no CA, no account and no cloud (ADR-0010). The threat we care about at pairing time is an attacker on the same network who answers discovery faster than the real peer or sits in the middle of the first connection. After pairing, the threat is impersonation by a device that is not the pinned peer.
Key algorithm. We wanted Ed25519 for its small keys and simple, misuse-resistant signing. It lost to ECDSA P-256 for Android-specific reasons:
- Hardware-backed keys on Android come from
AndroidKeyStore. EC P-256 has been a mandatory, hardware-backed Keymaster algorithm since Android 6; Ed25519 was only added to Keystore in Android 13 and is implemented in software or inconsistently across vendors’ KeyMint, and its availability for TLS client authentication through Conscrypt’sKeyManagerpath is not something we can rely on across OEMs. - TLS 1.3 makes
ecdsa_secp256r1_sha256mandatory-to-implement; every stack we touch (rustls with ring, Conscrypt, OpenSSL for debugging) handles P-256 certificates without configuration. - The identity is used for TLS only; no custom signing scheme exists where Ed25519’s ergonomics would matter.
Pairing ceremony. Fingerprint comparison (64 hex chars) is what TLS-pinning apps and KDE Connect offer and what users skip. A short authentication string (SAS) derived from both identities and both fresh nonces reduces the comparison to six digits that must match on both screens; an active attacker must make both sides’ SAS agree, which succeeds with probability 10^-6 per attempt, and any failed attempt is visible to the user. This is the model Bluetooth numeric comparison, Signal safety numbers and Matrix verification use.
A QR code covers the common case of a desktop with a screen and a phone with a camera: the desktop shows a one-time secret out of band; the phone proves knowledge of it with an HMAC. The secret never crosses the network.
Decision
- Certificates: self-signed ECDSA P-256 (SHA-256 signature), one per device.
- Android: key pair generated in
AndroidKeyStore(KeyProperties.KEY_ALGORITHM_EC,secp256r1, purposesSIGN), StrongBox when available, non-exportable; the self-signed certificate is created at key generation time. - Linux:
rcgenP-256; PKCS#8 PEM at$XDG_DATA_HOME/tether/identity.key(mode 0600) andidentity.crt. - Validity dates, subject names and chains are ignored by verifiers. Only the public key matters.
- Android: key pair generated in
- Device id = lowercase hex SHA-256 of the DER
SubjectPublicKeyInfoof the leaf certificate (64 chars). On Android that isSHA-256(cert.publicKey.encoded). It is the key in every store, D-Bus path and UI. - Verification (identical both sides): the peer must present exactly one
certificate; compute its id; if a trusted record matches, the session is
paired; otherwise it is unpaired and may only exchange
Hello,Ping/PongandPair*messages.Hello.device_idmust equal the computed id. - Pinning: on pairing success each side persists
{device_id, name, kind, certificate DER}. Pinning is by key hash (the id), so certificate re-issuance with the same key would still match; a new key is a new device. - SAS pairing: initiator sends
PairRequest{nonce(32 B)}, responder answersPairResponse{nonce(32 B)}; both computeSHA-256("tether-sas-v1" || fp_lo || fp_hi || nonce_lo || nonce_hi)with the pairs sorted by device id, take the first 4 bytes as big-endian u32 mod 10^6, zero-pad to 6 digits. Both users must confirm;PairConfirmfrom both completes it;PairRejector 60 s timeout aborts. Test vectors are inprotocol.mdand asserted by Rust and Kotlin unit tests. - QR pairing: desktop renders
tether://pair?v=1&id=<desktop id>&n=<name>&a=<ip:port>...&s=<base64url 16-byte secret>, valid 5 minutes, single use. Phone connects to the first reachable address and sendsPairRequest{nonce, qr_proof = HMAC-SHA256(secret, ASCII phone id)}. Valid proof: desktop repliesPairResponse{qr_accepted = true}andPairConfirmimmediately; phone auto-confirms. No prompt on either side. Invalid proof:PairReject{mismatch}and the secret is burned. - Unpair from either side deletes both records (
Unpairmessage).
Consequences
Positive
- No PKI, no accounts, no certificate expiry handling, no clock dependence.
- The phone’s private key never leaves secure hardware on devices with StrongBox/TEE; a malware-infested phone cannot clone its Tether identity.
- Six-digit SAS is short enough that users actually compare it; QR removes the comparison entirely for the desk-side case.
- Pinning by key hash means certificate details can change freely in future versions.
Negative / risks
- Losing the key means losing the identity: a reinstalled app or a wiped
$XDG_DATA_HOMErequires re-pairing. Accepted and documented; it is also what makes identity theft hard. - Android Keystore keys are device-bound: no backup/restore of the pairing. Accepted.
- A six-digit SAS is weaker than a 64-hex fingerprint against an attacker who can
retry. Mitigations: pairing is a user-initiated, 60 s, one-at-a-time ceremony
(
PairReject{busy}for concurrent attempts); any failure is shown to the user; a mismatch on one side should make them stop. - P-256 ECDSA signature generation needs good randomness; ring and Keystore both use RFC 6979-style or hardware RNG. We rely on them and do not implement any signing ourselves.
- Unpaired (TOFU-style) connections are accepted up to
Helloso pairing can happen; this exposes the TLS handshake andHelloparser to anyone on the LAN. Mitigation: rate-limit unpaired connections per source address; minimal parser surface before pairing.
Alternatives considered
- Ed25519 certificates: rejected for Android Keystore/Conscrypt support
reasons above. Revisit if
minSdkreaches a level where Keystore Ed25519 and TLS use are universal. - RSA-2048/3072: universally supported but slow on phones and large on the wire for no benefit. Rejected.
- Trust on first use only (KDE Connect model): no defence against a first-contact MITM. Rejected.
- PAKE (SPAKE2/OPAQUE) with a PIN: cryptographically stronger pairing that
binds the session to a shared PIN. More code and library review on both
platforms than a hash-derived SAS; the SAS gives equivalent practical security
for a one-time supervised ceremony. Deferred; the
Pair*messages leave room for aPairRequest.pakefield later. - Account-based identity (what Phone Link does with a Microsoft account): violates the no-cloud principle. Rejected.
- Bluetooth out-of-band pairing: requires Bluetooth on both sides at pairing time and a BlueZ agent; useful later for M3 call setup, not for the core identity. Rejected for M1.