devicekey

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package devicekey reads the key pair a device enrols with: the agent's SSH host key, whose public half the device record stores as PEM. A device proves it holds the private half by signing a server challenge with Sign, which the server checks with Verify.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPublicKey = errors.New("invalid device public key")

ErrInvalidPublicKey is returned when a device's stored key is not a PEM public key.

View Source
var ErrInvalidSignature = errors.New("invalid device key signature")

ErrInvalidSignature is returned when a signature does not prove possession of a device key.

Functions

func ParsePublicKey

func ParsePublicKey(pemKey string) (gossh.PublicKey, error)

ParsePublicKey reads a device public key stored as PEM: an "RSA PUBLIC KEY" block as PKCS#1, which is what the agent sends, and any other block as PKIX. It returns ErrInvalidPublicKey when there is no PEM block, the block does not parse that way, or the key is of a type x/crypto/ssh cannot represent.

func Sign

func Sign(key crypto.Signer, statement Statement) (string, error)

Sign signs statement with key, which must be the private half of statement's public key, the device's enrolled key; Sign does not check that, and Verify refuses what a mismatched key signs. It returns the signature in the form Verify reads, or the error x/crypto/ssh returns for a key type it cannot sign with or a signature that fails.

func Verify

func Verify(statement Statement, signature string) error

Verify checks that signature, made by Sign, proves possession of the private half of statement's public key for statement. It returns ErrInvalidPublicKey when the public key cannot be read, and ErrInvalidSignature for any signature that does not verify, including a SHA-1 RSA one.

Types

type Statement

type Statement struct {
	Challenge       string
	TenantID        string
	ProvisioningKey string
	PublicKey       string
}

Statement is what a device signs to authenticate: the challenge the server issued, and the tenant or provisioning key and the public key the device authenticates with. A field the request omits is signed empty.

Jump to

Keyboard shortcuts

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