instancekey

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: GPL-3.0 Imports: 9 Imported by: 1 module, 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 instancekey loads persistent instance secrets and derives purpose-specific keys.

Index

Constants

View Source
const AdmitPurpose = "nps/admit/v1"

AdmitPurpose is the derivation purpose of the admission key of the exchange carrier.

Variables

This section is empty.

Functions

func AdmitKey added in v0.35.0

func AdmitKey(path, override string) ([]byte, error)

AdmitKey is the admission key of the server whose instance key is at path: override as 64 hex digits when set, else derived, so that it survives a restart and links already handed out keep working.

Types

type Key

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

Key holds a 32-byte instance secret. Use DeriveKey rather than sharing the secret.

func LoadOrCreate

func LoadOrCreate(path string) (*Key, error)

LoadOrCreate reads an existing key or atomically installs a fully written new key. The file contains a version, a 32-byte secret and a checksum to detect corruption. Existing files are never replaced, including malformed or unreadable files.

func (*Key) DeriveKey

func (k *Key) DeriveKey(purpose string, length int) ([]byte, error)

DeriveKey uses HKDF-SHA256 with an independent purpose for each use.

Jump to

Keyboard shortcuts

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