rcstore

package
v0.81.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rcstore implements the TUF metadata signing used by fakeintake's Remote Config endpoints.

Index

Constants

View Source
const TUFExpires = "2030-01-01T00:00:00Z"

TUFExpires is hardcoded for fakeintake; long horizon so test setups don't hit expiry.

Variables

This section is empty.

Functions

func BuildRootJSON

func BuildRootJSON(key ed25519.PrivateKey, keyID, publicKeyHex string) ([]byte, error)

BuildRootJSON returns a signed root.json containing a single ed25519 key trusted for all four TUF roles.

func CanonicalJSON

func CanonicalJSON(v any) ([]byte, error)

CanonicalJSON encodes v in TUF canonical form: object keys sorted lexicographically, no whitespace, and no HTML escaping.

Only used for hashing (the key ID and digest inputs). The signed payloads themselves are signed-then-embedded verbatim, so byte-identical re-serialisation is not required there.

func ComputeKeyID

func ComputeKeyID(publicKeyHex string) (string, error)

ComputeKeyID returns hex(sha256(canonical_json(key_object))) for an ed25519 key, matching go-tuf's keyid computation when keyid_hash_algorithms is omitted.

func DefaultKeyPath

func DefaultKeyPath() (string, error)

DefaultKeyPath is the on-disk location of the persistent signing key seed when the caller does not specify one.

func KeyFromHexSeed added in v0.81.0

func KeyFromHexSeed(hexSeed string) (ed25519.PrivateKey, error)

KeyFromHexSeed derives an ed25519 private key from a 64-character hex-encoded 32-byte seed. Returns an error when hexSeed is malformed.

func LoadOrCreateSigningKey

func LoadOrCreateSigningKey(path string) (ed25519.PrivateKey, bool, error)

LoadOrCreateSigningKey reads a 32-byte ed25519 seed from path. If path is empty, falls back to DefaultKeyPath. If the file does not exist, a fresh key is generated and written. The returned bool reports whether a new key was generated this call (callers may want to log a hint about flushing remote-config.db).

func PublicKeyHex

func PublicKeyHex(key ed25519.PrivateKey) string

PublicKeyHex is a convenience accessor for tests/handlers that need to surface the verifying key.

func SignEnvelope

func SignEnvelope(key ed25519.PrivateKey, keyID string, signedValue any) ([]byte, error)

SignEnvelope marshals signedValue once, signs those bytes with key, and returns a TUF envelope embedding the same bytes verbatim.

func VerifyEnvelope

func VerifyEnvelope(pub ed25519.PublicKey, envelope []byte) error

VerifyEnvelope is a small helper used by tests to round-trip our own output: parse the envelope, verify the signature against the embedded raw bytes.

Types

type Config

type Config struct {
	OrgID      string
	Product    string
	ConfigID   string
	ConfigName string
	Data       []byte
}

Config is a single Remote Config entry held by the in-memory store.

func (Config) Path

func (c Config) Path() string

Path returns the TUF target path for the config: datadog/<org>/<product>/<id>/<name>.

type RepoMetas

type RepoMetas struct {
	Root      []byte
	Targets   []byte
	Snapshot  []byte
	Timestamp []byte
}

RepoMetas bundles the four TUF metadata documents that make up a repo.

func GenerateTUFMetas

func GenerateTUFMetas(cfgs []Config, key ed25519.PrivateKey, keyID string, root []byte, version uint64) (RepoMetas, error)

GenerateTUFMetas builds targets/snapshot/timestamp at the given version from the supplied configs, alongside the cached root bytes.

Jump to

Keyboard shortcuts

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