masterkey

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package masterkey retrieves Chromium master keys (per-platform retrievers + a cross-host Dump format). Firefox and Safari own their own key paths and don't route through here.

Index

Constants

View Source
const DumpVersion = "2"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainRetriever

type ChainRetriever struct {
	// contains filtered or unexported fields
}

ChainRetriever tries retrievers in order, first success wins (macOS V10: gcoredump→password→security).

func (*ChainRetriever) RetrieveKey

func (c *ChainRetriever) RetrieveKey(hints Hints) ([]byte, error)

type DBusRetriever

type DBusRetriever struct{}

DBusRetriever queries GNOME Keyring / KDE Wallet via D-Bus Secret Service.

func (*DBusRetriever) RetrieveKey

func (r *DBusRetriever) RetrieveKey(hints Hints) ([]byte, error)

type Dump

type Dump struct {
	Version   string    `json:"version"`
	CreatedAt time.Time `json:"created_at"`
	Host      Host      `json:"host"`
	Vaults    []Vault   `json:"vaults"`
}

Dump is the portable, cross-host container for Chromium master keys — produce it on one host to decrypt copied profile data on another without DPAPI / ABE / Keychain / D-Bus.

func NewDump

func NewDump() Dump

func ReadJSON

func ReadJSON(r io.Reader) (Dump, error)

ReadJSON parses a Dump and rejects any version this build can't interpret — a silent misparse of an unrecognized schema is worse than a clear error.

func (Dump) WriteJSON

func (d Dump) WriteJSON(w io.Writer) error

type Hints

type Hints struct {
	KeychainLabel  string // macOS Keychain account / Linux D-Bus Secret Service label
	WindowsABEKey  string // Windows ABE browser key (e.g. "chrome"); "" → ABE not applicable
	LocalStatePath string // path to (temp-copied) Local State JSON; only used on Windows
}

Hints bundles inputs for Retriever; each retriever reads only the field that applies to it.

type Host

type Host struct {
	OS       string `json:"os"`
	Arch     string `json:"arch"`
	Hostname string `json:"hostname,omitempty"`
	User     string `json:"user,omitempty"`
}

Host OS / Arch always set; Hostname / User best-effort (empty on syscall failure).

type MasterKeys

type MasterKeys struct {
	V10 []byte `json:"v10,omitempty"`
	V11 []byte `json:"v11,omitempty"`
	V20 []byte `json:"v20,omitempty"`
}

MasterKeys holds one key per cipher tier; a profile can mix tiers (Win v10+v20, Linux v10+v11), so each is populated independently. A nil tier = that cipher version can't be decrypted.

func NewMasterKeys

func NewMasterKeys(r Retrievers, hints Hints) (MasterKeys, error)

NewMasterKeys fetches each non-nil tier and joins per-tier errors. A retriever returning (nil, nil) means "tier not applicable" and contributes no key. Never logs — the caller decides severity.

func (MasterKeys) HasAny

func (k MasterKeys) HasAny() bool

type PosixRetriever

type PosixRetriever struct{}

PosixRetriever derives Chromium's kV10Key via PBKDF2 over the hardcoded "peanuts" password — the deterministic v10 key used when no keyring exists (headless/Docker/CI). Mirrors PosixKeyProvider.

func (*PosixRetriever) RetrieveKey

func (r *PosixRetriever) RetrieveKey(_ Hints) ([]byte, error)

type Retriever

type Retriever interface {
	RetrieveKey(hints Hints) ([]byte, error)
}

Retriever obtains a Chromium master key from one platform source (DPAPI, Keychain, D-Bus, …).

func NewChain

func NewChain(retrievers ...Retriever) Retriever

type Retrievers

type Retrievers struct {
	V10 Retriever
	V11 Retriever
	V20 Retriever
}

Retrievers is the per-tier retriever configuration; unused slots are nil.

func DefaultRetrievers

func DefaultRetrievers() Retrievers

DefaultRetrievers wires the Linux tiers, one per prefix Chromium emits: v10 = PBKDF2("peanuts") (kV10Key, no keyring); v11 = PBKDF2(keyring secret) (kV11Key, via D-Bus). A profile can carry both if the host moved between headless and keyring sessions, so both run independently.

type StaticRetriever

type StaticRetriever struct {
	// contains filtered or unexported fields
}

StaticRetriever returns pre-supplied key bytes (from a Dump) instead of platform retrieval, ignoring Hints. An empty key returns (nil, nil) — the "tier not applicable" signal NewMasterKeys expects.

func NewStaticRetriever

func NewStaticRetriever(key []byte) *StaticRetriever

NewStaticRetriever wraps key bytes; a nil/empty key yields a retriever that reports the tier unavailable.

func (*StaticRetriever) RetrieveKey

func (p *StaticRetriever) RetrieveKey(_ Hints) ([]byte, error)

type Vault

type Vault struct {
	Browser     string     `json:"browser"`
	Kind        string     `json:"kind"`
	UserDataDir string     `json:"user_data_dir"`
	Profiles    []string   `json:"profiles"`
	Keys        MasterKeys `json:"keys"`
}

Vault groups profiles sharing master keys (master keys are per-installation, not per-profile). Browser is the lookup key (e.g. "chrome"); Kind is the engine ("chromium"|"chromium-yandex"| "chromium-opera") so a consumer can rebuild the engine without the local browser table.

Jump to

Keyboard shortcuts

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