secure

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: ? 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 secure is Fort's E2E crypto contract for the relay (spec 028): a Noise IK handshake (X25519) between a client and the daemon's pinned static key, then ChaCha20-Poly1305 AEAD framing. The gateway broker relays these frames opaquely — it can neither read nor forge them. Both ends of Fort's tests use this package, proving the contract round-trips.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FingerprintOf

func FingerprintOf(pub []byte) string

FingerprintOf fingerprints any public key: base32 (no padding) of the first 16 bytes of sha256(pub) — 128 bits, so grinding a second-preimage keypair to match a pinned fingerprint at first contact is 2^128 work, not 2^80.

Types

type Handshake

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

Handshake is one side of a Noise IK handshake.

func NewInitiator

func NewInitiator(static Keypair, pinnedPeerPub []byte) (*Handshake, error)

NewInitiator starts the client side, pinning the daemon's static public key (IK: the initiator must know the responder's key — a substituted key fails).

func NewResponder

func NewResponder(static Keypair) (*Handshake, error)

NewResponder starts the daemon side with its static identity.

func (*Handshake) ReadMessage

func (h *Handshake) ReadMessage(msg []byte) ([]byte, error)

ReadMessage consumes the peer's handshake message.

func (*Handshake) Session

func (h *Handshake) Session() *Session

Session returns the transport session once the handshake completed (nil before).

func (*Handshake) WriteMessage

func (h *Handshake) WriteMessage(payload []byte) ([]byte, error)

WriteMessage produces the next handshake message (payload may be nil).

type Keypair

type Keypair struct {
	Private []byte
	Public  []byte
}

Keypair is a long-term X25519 static identity.

func GenerateKeypair

func GenerateKeypair() (Keypair, error)

GenerateKeypair mints a fresh static identity.

func (Keypair) Fingerprint

func (k Keypair) Fingerprint() string

Fingerprint is the human-comparable identity of a public key: base32 (no padding) of sha256(pub), grouped for reading. Shown by `fort relay join` and on the gateway machine list; clients pin the key it names.

type Session

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

Session seals/opens transport frames after a completed handshake.

func (*Session) Open

func (s *Session) Open(ciphertext []byte) ([]byte, error)

Open decrypts one frame, rejecting any tampering.

func (*Session) Seal

func (s *Session) Seal(plaintext []byte) []byte

Seal encrypts one frame. PRECONDITION: s came from Session() after a completed handshake (never seal application data as a handshake payload — IK's first message is replayable and not forward-secret). Panics on a nil session (caller bug) or nonce exhaustion at 2^64 frames.

Jump to

Keyboard shortcuts

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