Documentation
¶
Overview ¶
Package installation manages license-bound installation keys and
Package installation manages license-bound installation keys and machine activation. An installation generates an Ed25519 key pair; the machine fingerprint is the lowercase hex SHA-256 of the raw 32-byte public key. Activation attaches the fingerprint and the base64-encoded public key to the machine's metadata, binding the key to the license.
Key creation and storage:
key, err := installation.NewKey() seed := key.Seed() // ... persist seed ... key, err = installation.ParseKey(seed)
Activation:
machine, err := installation.Activate(ctx, license, key,
licensing.WithMachineName("my-installation"))
Air-gapped activation:
req := installation.ActivationRequest{
Fingerprint: key.Fingerprint(),
PublicKey: base64.StdEncoding.EncodeToString(key.Public()),
LicenseID: license.ID,
Version: "1.0.0",
}
data, _ := json.Marshal(req)
// ... transfer data to the vendor side ...
Index ¶
- Variables
- func Activate(ctx context.Context, license *licensing.License, key Key, ...) (*licensing.Machine, error)
- func Fingerprint(pub ed25519.PublicKey) string
- func PublicKeyOf(machine *licensing.Machine) (ed25519.PublicKey, error)
- func ValidFingerprint(s string) bool
- type ActivationRequest
- type Key
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyMismatch reports that the public key from machine metadata // does not hash to the machine's fingerprint. ErrKeyMismatch = errors.New("public key does not hash to the machine fingerprint") // ErrPublicKeyMissing reports that the machine metadata has no // publicKey entry. ErrPublicKeyMissing = errors.New("machine metadata does not contain a public key") // ErrPublicKeyInvalid reports that the publicKey metadata value is // not valid base64 or not a 32-byte key. ErrPublicKeyInvalid = errors.New("machine metadata public key is invalid") // ErrSeedSize reports that a seed passed to ParseKey has the wrong // length. ErrSeedSize = errors.New("seed must be 32 bytes") // ErrFingerprintRequired reports that an activation request is // missing the fingerprint field. ErrFingerprintRequired = errors.New("activation request fingerprint is required") // ErrLicenseIDRequired reports that an activation request is missing // the license_id field. ErrLicenseIDRequired = errors.New("activation request license_id is required") )
Activation and key errors matched with errors.Is.
Functions ¶
func Activate ¶
func Activate( ctx context.Context, license *licensing.License, key Key, opts ...licensing.ActivationOption, ) (*licensing.Machine, error)
Activate activates a machine for the license with the installation key's fingerprint and publicKey metadata. The caller's metadata is merged; publicKey and fingerprint from the key always win.
func Fingerprint ¶
Fingerprint computes the installation fingerprint of a raw Ed25519 public key: lowercase hex SHA-256.
func PublicKeyOf ¶
PublicKeyOf reads the "publicKey" entry from the machine's metadata, verifies it hashes to the machine's fingerprint, and returns the raw 32-byte Ed25519 public key. It returns ErrPublicKeyMissing, ErrPublicKeyInvalid, or ErrKeyMismatch on failure.
func ValidFingerprint ¶
ValidFingerprint reports whether s is a well-formed fingerprint: exactly 64 lowercase hex characters.
Types ¶
type ActivationRequest ¶
type ActivationRequest struct {
// Fingerprint is the lowercase hex SHA-256 of the public key.
Fingerprint string `json:"fingerprint"`
// PublicKey is standard base64 of the 32-byte Ed25519 public key.
PublicKey string `json:"public_key"`
// LicenseID is the license UUID (not the license key).
LicenseID string `json:"license_id"`
// Version is the build version of the installation.
Version string `json:"version"`
}
ActivationRequest is the payload for air-gapped activation: the installation sends this to the vendor side, which activates a machine from it on the vendor's network.
func ParseActivationRequest ¶
func ParseActivationRequest(data []byte) (*ActivationRequest, error)
ParseActivationRequest decodes an activation request from JSON.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is an Ed25519 installation key pair. The private key is 64 bytes (seed + public key); the public key is 32 bytes.
func (Key) Fingerprint ¶
Fingerprint returns the lowercase hex SHA-256 of the raw public key. It matches Fingerprint(k.Public()).
func (Key) PrivateKey ¶
func (k Key) PrivateKey() ed25519.PrivateKey
PrivateKey returns the underlying ed25519.PrivateKey.
func (Key) Public ¶
Public returns the 32-byte Ed25519 public key. The public key bytes are the last 32 bytes of the private key seed+pub encoding.