Documentation
¶
Overview ¶
Package codepair pair two devices on a LAN with a short human-typed code and an authenticated key exchange.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize folds a typed code into the form Keys hashes: upper case, without the dashes and spaces a caller puts between groups. It never fails, so a caller can pass whatever the user entered.
Types ¶
type Config ¶
type Config struct {
Protocol string
PeerKeyInfo string
Iterations int
CodeLength int
Alphabet string
}
Config names the pairing protocol this caller runs. The zero value is not usable: Validate refuses a config that leaves any field out, because an empty Protocol or PeerKeyInfo would derive keys under a shared, guessable label and a zero Iterations would make the code's stretch free.
func (Config) Keys ¶
Keys derives the two secrets of one pairing from the typed code and the X25519 shared secret. authKey is the key Proof signs with, stretched from the low-entropy code so that one guess costs c.Iterations of PBKDF2; peerKey is the long-term key HKDF derives from shared alone, so what a caller stores never depends on the code.
func (Config) NewCode ¶
NewCode returns a code of c.CodeLength characters drawn uniformly from c.Alphabet. It is the secret the user types, so a caller may show it in any grouping it likes: Normalize drops the separators again.
func (Config) Transcript ¶
Transcript builds the bytes both sides prove over: the protocol, both public keys, then both ids and display names. Because the names are in it, a relay that swaps the name a device is stored under fails the proofs.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter bounds online guessing at the code. A caller charges it once per guess, before checking the guess, so guesses made side by side cannot outnumber the limit. Two counts are kept: a per-remote one that locks one computer out after maxFailures, and a global one that reports burnFailures, at which the caller should drop the code.
func NewLimiter ¶
NewLimiter returns a limiter that locks one remote out for lockout once it has failed maxFailures guesses, and reports burned once burnFailures guesses have failed in all.
func (*Limiter) Charge ¶
Charge records one guess from remote. It returns burned once the guesses failed in all have reached burnFailures, which is the caller's signal to stop honouring the code; further charges keep returning burned until Refund gives a guess back.