tlsdistrusttest

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tlsdistrusttest holds the public certificates of the October 2026 eMudhra incident and builds, for tests only, a server certificate signed by a compromised intermediate.

Sources (all public): the certificates in testdata/emudhra-intermediates.pem and testdata/sectigo-cross-signed.pem are the PEM files of the "emudhra-attestation.zip" and "emudhra-attestation-aaa-cross.zip" attachments (ids 9664066 and 9664067) of https://bugzilla.mozilla.org/show_bug.cgi?id=2083449; TestFingerprintsMatchTheBug compares their SHA-256 fingerprints with the ones the bug lists. testdata/emsign-roots.pem holds emSign ECC Root CA - G3, emSign Root CA - C1 and emSign ECC Root CA - C3 (removed in NSS 3.131.1) and emSign Root CA - G1 (still trusted) as NSS_3_131_RTM lib/ckfw/builtins/certdata.txt carries them.

Each of the eight intermediates has a P-384 private key below 256, recoverable from its public key by trying every scalar (Mozilla bug 2083449 comment 5; https://scotthelme.co.uk/eight-bits-of-trust-emudhras-ca-keys-cracked-in-milliseconds/). Forge does exactly that, in memory, to prove that a client without the distrust accepts a certificate a third party can mint. Import this package only from _test.go files: TestNoProductionCodeImportsTheTestHelper enforces it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockedState

func BlockedState(serverName string, chain ...*x509.Certificate) tls.ConnectionState

BlockedState is the connection state a verifier reports for a chain that ends at certificate.

func CrossSigned

func CrossSigned(t testing.TB) []*x509.Certificate

CrossSigned are the same eight keys as Sectigo's "AAA Certificate Services" cross-signed them in May 2025.

func EmSignRootG1

func EmSignRootG1(t testing.TB) *x509.Certificate

EmSignRootG1 is emSign Root CA - G1, which NSS 3.131.1 still trusts and which must not be blocked.

func Intermediates

func Intermediates(t testing.TB) []*x509.Certificate

Intermediates are the eight intermediates eMudhra issued under emSign Root TLS CA - G3 and emSign Root CS CA - G3.

func IsRefusal

func IsRefusal(err error) bool

IsRefusal reports whether err is a refusal of a chain through a compromised CA: this package's DistrustedError, or the "no valid chains built" error of Go 1.27.3 and later, whose crypto/x509 carries the same eight digests (verify.go distrustedSPKIHashes) and refuses the chain before a VerifyConnection hook runs. The package cannot import tlsdistrust (its own tests import this one), so it matches the message.

func IsTLS

func IsTLS(certificate *x509.Certificate) bool

IsTLS reports whether certificate is one of the six TLS intermediates (the other two sign code).

func Recover

func Recover(t testing.TB, certificate *x509.Certificate) *ecdsa.PrivateKey

Recover returns the private key of certificate, a P-384 CA whose private scalar is below 256.

func RemovedRoots

func RemovedRoots(t testing.TB) []*x509.Certificate

RemovedRoots are emSign ECC Root CA - G3, emSign Root CA - C1 and emSign ECC Root CA - C3.

Types

type ForgedServer

type ForgedServer struct {
	Certificate tls.Certificate
	// Roots trusts issuer alone, as a trust store that still carries the intermediate (or a root above it) would.
	Roots      *x509.CertPool
	ServerName string
}

ForgedServer is a server certificate for ServerName that issuer's recovered key signed.

func Forge

func Forge(t testing.TB, issuer *x509.Certificate) ForgedServer

Forge signs a server certificate with the recovered key of issuer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL