Documentation
¶
Overview ¶
Package codephrase generates croc codes and resolves them into relay-room and PAKE components.
Index ¶
Constants ¶
const (
SSHCodeWordCount = 6
)
Variables ¶
var ErrCodeTooShort = errors.New("code is too short (must be at least 6 characters)")
ErrCodeTooShort is returned when a croc code is shorter than six bytes.
var ErrInvalidRelayCount = errors.New("relay count must be positive")
ErrInvalidRelayCount is returned when a code cannot be assigned because the public relay pool is empty.
var ErrInvalidRelayIndex = errors.New("relay index is outside the relay pool")
ErrInvalidRelayIndex is returned when a requested relay is outside the pool.
Functions ¶
func GenerateForRelay ¶
GenerateForRelay returns a normal three-word EFF code assigned to relayIndex by RelayIndex. On average it generates relayCount candidates.
func GenerateSSH ¶
GenerateSSH returns a cryptographically random six-word SSH invitation.
Types ¶
type Components ¶
Components contains the protocol inputs derived from a user-facing croc code. RoomName is ready to send to a relay.
func Parse ¶
func Parse(secret string) (Components, error)
Parse resolves a croc code into the relay room and PAKE passphrase used by the protocol. Exactly three lowercase ASCII words use the current three-word format. Four lowercase ASCII words keep compatibility with the previous four-word format; every other valid code uses croc's legacy byte-based split.
type Format ¶
type Format string
Format identifies how a croc code is divided into its room and PAKE parts.
const ( // FormatLegacy uses the first four bytes for the room and bytes after the // fifth byte for PAKE. FormatLegacy Format = "legacy" // FormatThreeWord uses the first word for the room and the final two words // for PAKE. FormatThreeWord Format = "three-word" // FormatFourWord uses the first two words for the room and the final two // words for PAKE. It is retained for compatibility with older codes. FormatFourWord Format = "four-word" )
type SSHComponents ¶
SSHComponents contains the rendezvous and PAKE inputs for a croc SSH invitation. SSH codes deliberately use more entropy than file-transfer codes: two words select an unguessable relay room and four words remain in the PAKE password.
func ParseSSH ¶
func ParseSSH(secret string) (SSHComponents, error)
ParseSSH resolves a six-word SSH invitation into its relay room and PAKE password. Only words from croc's embedded EFF list are accepted, which keeps parsing unambiguous even though one list entry ("yo-yo") contains a hyphen.