key
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package key contains types for different types of public and private keysused by Tailscale.
Index¶
- Constants
- Variables
- func PrivateTypesForTest() set.Set[reflect.Type]
- func RegisterHardwareAttestationKeyFns(emptyFn func() HardwareAttestationKey, createFn HardwareAttestationKeyFn)
- type ChallengePrivate
- type ChallengePublic
- type ControlPrivatedeprecated
- func (k ControlPrivate) IsZero() bool
- func (k ControlPrivate) MarshalJSON() ([]byte, error)
- func (k ControlPrivate) OpenFrom(p MachinePublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (k ControlPrivate) Public() MachinePublic
- func (k ControlPrivate) SealTo(p MachinePublic, cleartext []byte) (ciphertext []byte)
- func (k ControlPrivate) SharedKey(p MachinePublic) MachinePrecomputedSharedKey
- func (k *ControlPrivate) UnmarshalJSON(bs []byte) error
- type DERPMesh
- type DiscoPrivate
- type DiscoPublic
- func (k DiscoPublic) AppendText(b []byte) ([]byte, error)
- func (k DiscoPublic) AppendTo(buf []byte) []byte
- func (k DiscoPublic) Compare(other DiscoPublic) int
- func (k DiscoPublic) IsZero() bool
- func (k DiscoPublic) MarshalText() ([]byte, error)
- func (k DiscoPublic) Raw32() [32]bytedeprecated
- func (k DiscoPublic) ShortString() string
- func (k DiscoPublic) String() string
- func (k *DiscoPublic) UnmarshalText(b []byte) error
- type DiscoShared
- type HardwareAttestationKey
- type HardwareAttestationKeyFn
- type HardwareAttestationPublic
- func (k HardwareAttestationPublic) AppendText(dst []byte) ([]byte, error)
- func (k *HardwareAttestationPublic) Clone() *HardwareAttestationPublic
- func (k HardwareAttestationPublic) Equal(o HardwareAttestationPublic) bool
- func (k HardwareAttestationPublic) IsZero() bool
- func (k HardwareAttestationPublic) MarshalText() ([]byte, error)
- func (k HardwareAttestationPublic) String() string
- func (k *HardwareAttestationPublic) UnmarshalText(b []byte) error
- func (k HardwareAttestationPublic) Verifier() *ecdsa.PublicKey
- type MachinePrecomputedSharedKey
- type MachinePrivate
- func (k MachinePrivate) AppendText(b []byte) ([]byte, error)
- func (k MachinePrivate) Equal(other MachinePrivate) bool
- func (k MachinePrivate) IsZero() bool
- func (k MachinePrivate) MarshalText() ([]byte, error)
- func (k MachinePrivate) OpenFrom(p MachinePublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (k MachinePrivate) Public() MachinePublic
- func (k MachinePrivate) SealTo(p MachinePublic, cleartext []byte) (ciphertext []byte)
- func (k MachinePrivate) SharedKey(p MachinePublic) MachinePrecomputedSharedKey
- func (k *MachinePrivate) UnmarshalText(b []byte) error
- func (k MachinePrivate) UntypedBytes() []bytedeprecated
- type MachinePublic
- func (k MachinePublic) AppendText(b []byte) ([]byte, error)
- func (k MachinePublic) IsZero() bool
- func (k MachinePublic) MarshalText() ([]byte, error)
- func (k MachinePublic) ShortString() string
- func (k MachinePublic) String() string
- func (k *MachinePublic) UnmarshalText(b []byte) error
- func (k MachinePublic) UntypedBytes() []bytedeprecated
- func (k MachinePublic) UntypedHexString() stringdeprecated
- type NLPrivate
- func (k NLPrivate) AppendText(b []byte) ([]byte, error)
- func (k NLPrivate) Equal(other NLPrivate) bool
- func (k NLPrivate) IsZero() bool
- func (k NLPrivate) KeyID() tkatype.KeyID
- func (k NLPrivate) MarshalText() ([]byte, error)
- func (k NLPrivate) Public() NLPublic
- func (k NLPrivate) SignAUM(sigHash tkatype.AUMSigHash) ([]tkatype.Signature, error)
- func (k NLPrivate) SignNKS(sigHash tkatype.NKSSigHash) ([]byte, error)
- func (k *NLPrivate) UnmarshalText(b []byte) error
- type NLPublic
- func (k NLPublic) AppendText(b []byte) ([]byte, error)
- func (k NLPublic) CLIString() string
- func (k NLPublic) Equal(other NLPublic) bool
- func (k NLPublic) IsZero() bool
- func (k NLPublic) KeyID() tkatype.KeyID
- func (k NLPublic) MarshalText() ([]byte, error)
- func (k *NLPublic) UnmarshalText(b []byte) error
- func (k NLPublic) Verifier() ed25519.PublicKey
- type NodePrivate
- func (k NodePrivate) AppendText(b []byte) ([]byte, error)
- func (k NodePrivate) Equal(other NodePrivate) bool
- func (k NodePrivate) IsZero() bool
- func (k NodePrivate) MarshalText() ([]byte, error)
- func (k NodePrivate) OpenFrom(p NodePublic, ciphertext []byte) (cleartext []byte, ok bool)
- func (k NodePrivate) Public() NodePublic
- func (k NodePrivate) SealTo(p NodePublic, cleartext []byte) (ciphertext []byte)
- func (k NodePrivate) SealToChallenge(p ChallengePublic, cleartext []byte) (ciphertext []byte)
- func (k *NodePrivate) UnmarshalText(b []byte) error
- func (k NodePrivate) UntypedHexString() string
- type NodePublic
- func (k NodePublic) AppendText(b []byte) ([]byte, error)
- func (k NodePublic) AppendTo(buf []byte) []byte
- func (p NodePublic) Compare(p2 NodePublic) int
- func (k NodePublic) IsZero() bool
- func (k NodePublic) Less(other NodePublic) bool
- func (k NodePublic) MarshalBinary() (data []byte, err error)
- func (k NodePublic) MarshalText() ([]byte, error)
- func (k NodePublic) Raw32() [32]bytedeprecated
- func (k *NodePublic) ReadRawWithoutAllocating(br *bufio.Reader) error
- func (p NodePublic) Shard() uint8
- func (k NodePublic) ShortString() string
- func (k NodePublic) String() string
- func (k *NodePublic) UnmarshalBinary(in []byte) error
- func (k *NodePublic) UnmarshalText(b []byte) error
- func (k NodePublic) UntypedHexString() stringdeprecated
- func (k NodePublic) WireGuardGoString() string
- func (k NodePublic) WriteRawWithoutAllocating(bw *bufio.Writer) error
- type SortedPairOfDiscoPublic
Constants¶
const (// DiscoPublicRawLen is the length in bytes of a DiscoPublic, when// serialized with AppendTo, Raw32 or WriteRawWithoutAllocating.DiscoPublicRawLen = 32)
const (// NodePublicRawLen is the length in bytes of a NodePublic, when// serialized with AppendTo, Raw32 or WriteRawWithoutAllocating.NodePublicRawLen = 32)
Variables¶
var ErrInvalidMeshKey =errors.New("invalid mesh key")var ErrUnsupported =fmt.Errorf("key type not supported on this platform")Functions¶
funcPrivateTypesForTest¶added inv1.92.0
PrivateTypesForTest returns the set of private key typesin this package, for testing purposes.
funcRegisterHardwareAttestationKeyFns¶added inv1.88.0
func RegisterHardwareAttestationKeyFns(emptyFn func()HardwareAttestationKey, createFnHardwareAttestationKeyFn)
RegisterHardwareAttestationKeyFns registers a hardware attestationkey implementation for the current platform.
Types¶
typeChallengePrivate¶added inv1.34.0
type ChallengePrivate struct {// contains filtered or unexported fields}ChallengePrivate is a challenge key, used to test whether clients control akey they want to prove ownership of.
A ChallengePrivate is ephemeral and not serialized to the disk or network.
funcNewChallenge¶added inv1.34.0
func NewChallenge()ChallengePrivate
NewChallenge creates and returns a new node private key.
func (ChallengePrivate)MarshalText¶added inv1.34.0
func (kChallengePrivate) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler, but by returning an error.It shouldn't need to be marshalled anywhere.
func (ChallengePrivate)OpenFrom¶added inv1.34.0
func (kChallengePrivate) OpenFrom(pNodePublic, ciphertext []byte) (cleartext []byte, okbool)
OpenFrom opens the NaCl box ciphertext, which must be a valuecreated by NodePrivate.SealToChallenge, and returns the inner cleartext ifciphertext is a valid box from p to k.
func (ChallengePrivate)Public¶added inv1.34.0
func (kChallengePrivate) Public()ChallengePublic
Public returns the ChallengePublic for k.Panics if ChallengePublic is zero.
typeChallengePublic¶added inv1.34.0
type ChallengePublic struct {// contains filtered or unexported fields}ChallengePublic is the public portion of a ChallengePrivate.
func (ChallengePublic)AppendText¶added inv1.50.0
func (kChallengePublic) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender.
func (ChallengePublic)IsZero¶added inv1.34.0
func (kChallengePublic) IsZero()bool
IsZero reports whether k is the zero value.
func (ChallengePublic)MarshalText¶added inv1.34.0
func (kChallengePublic) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (ChallengePublic)String¶added inv1.34.0
func (kChallengePublic) String()string
String returns the output of MarshalText as a string.
func (*ChallengePublic)UnmarshalText¶added inv1.34.0
func (k *ChallengePublic) UnmarshalText(b []byte)error
UnmarshalText implements encoding.TextUnmarshaler.
typeControlPrivatedeprecatedadded inv1.16.0
type ControlPrivate struct {// contains filtered or unexported fields}ControlPrivate is a Tailscale control plane private key.
It is functionally equivalent to a MachinePrivate, but serializesto JSON as a byte array rather than a typed string, because ourcontrol plane database stores the key that way.
Deprecated: this type should only be used in Tailscale's controlplane, where existing database serializations require thisless-good serialization format to persist. Other control planeimplementations can use MachinePrivate with no downsides.
funcNewControl¶added inv1.16.0
func NewControl()ControlPrivate
NewControl generates and returns a new control plane private key.
func (ControlPrivate)IsZero¶added inv1.16.0
func (kControlPrivate) IsZero()bool
IsZero reports whether k is the zero value.
func (ControlPrivate)MarshalJSON¶added inv1.16.0
func (kControlPrivate) MarshalJSON() ([]byte,error)
MarshalJSON implements json.Marshaler.
func (ControlPrivate)OpenFrom¶added inv1.16.0
func (kControlPrivate) OpenFrom(pMachinePublic, ciphertext []byte) (cleartext []byte, okbool)
OpenFrom opens the NaCl box ciphertext, which must be a valuecreated by SealTo, and returns the inner cleartext if ciphertext isa valid box from p to k.
func (ControlPrivate)Public¶added inv1.16.0
func (kControlPrivate) Public()MachinePublic
Public returns the MachinePublic for k.Panics if ControlPrivate is zero.
func (ControlPrivate)SealTo¶added inv1.16.0
func (kControlPrivate) SealTo(pMachinePublic, cleartext []byte) (ciphertext []byte)
SealTo wraps cleartext into a NaCl box (seegolang.org/x/crypto/nacl) to p, authenticated from k, using arandom nonce.
The returned ciphertext is a 24-byte nonce concatenated with thebox value.
func (ControlPrivate)SharedKey¶added inv1.30.0
func (kControlPrivate) SharedKey(pMachinePublic)MachinePrecomputedSharedKey
SharedKey returns the precomputed Nacl box shared key between k and p.
func (*ControlPrivate)UnmarshalJSON¶added inv1.16.0
func (k *ControlPrivate) UnmarshalJSON(bs []byte)error
UnmarshalJSON implements json.Unmarshaler.
typeDERPMesh¶added inv1.86.0
type DERPMesh struct {// contains filtered or unexported fields}DERPMesh is a mesh key, used for inter-DERP-node communication and forprivileged DERP clients.
funcDERPMeshFromRaw32¶added inv1.86.0
DERPMeshFromRaw32 parses a 32-byte raw value as a DERP mesh key.
funcParseDERPMesh¶added inv1.86.0
ParseDERPMesh parses a DERP mesh key from a string.This function trims whitespace around the string.If the key is not a 64-digit hexadecimal number, ErrInvalidMeshKey is returned.
func (DERPMesh)MarshalJSON¶added inv1.86.0
MarshalJSON implements theencoding/json.Marshaler interface.
func (*DERPMesh)UnmarshalJSON¶added inv1.86.0
UnmarshalJSON implements theencoding/json.Unmarshaler interface.
typeDiscoPrivate¶added inv1.18.0
type DiscoPrivate struct {// contains filtered or unexported fields}DiscoPrivate is a disco key, used for peer-to-peer path discovery.
funcNewDisco¶added inv1.18.0
func NewDisco()DiscoPrivate
NewDisco creates and returns a new disco private key.
func (DiscoPrivate)Equal¶added inv1.18.0
func (kDiscoPrivate) Equal(otherDiscoPrivate)bool
Equal reports whether k and other are the same key.
func (DiscoPrivate)IsZero¶added inv1.18.0
func (kDiscoPrivate) IsZero()bool
IsZero reports whether k is the zero value.
func (DiscoPrivate)Public¶added inv1.18.0
func (kDiscoPrivate) Public()DiscoPublic
Public returns the DiscoPublic for k.Panics if DiscoPrivate is zero.
func (DiscoPrivate)Shared¶added inv1.18.0
func (kDiscoPrivate) Shared(pDiscoPublic)DiscoShared
Shared returns the DiscoShared for communication between k and p.
typeDiscoPublic¶added inv1.18.0
type DiscoPublic struct {// contains filtered or unexported fields}DiscoPublic is the public portion of a DiscoPrivate.
funcDiscoPublicFromRaw32¶added inv1.18.0
func DiscoPublicFromRaw32(rawmem.RO)DiscoPublic
DiscoPublicFromRaw32 parses a 32-byte raw value as a DiscoPublic.
This should be used only when deserializing a DiscoPublic from abinary protocol.
func (DiscoPublic)AppendText¶added inv1.50.0
func (kDiscoPublic) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender.
func (DiscoPublic)AppendTo¶added inv1.18.0
func (kDiscoPublic) AppendTo(buf []byte) []byte
AppendTo appends k, serialized as a 32-byte binary value, tobuf. Returns the new slice.
func (DiscoPublic)Compare¶added inv1.60.0
func (kDiscoPublic) Compare(otherDiscoPublic)int
Compare returns an integer comparing DiscoPublic k and l lexicographically.The result will be 0 if k == other, -1 if k < other, and +1 if k > other.This is useful for situations requiring only one node in a pair to performsome operation, e.g. probing UDP path lifetime.
func (DiscoPublic)IsZero¶added inv1.18.0
func (kDiscoPublic) IsZero()bool
IsZero reports whether k is the zero value.
func (DiscoPublic)MarshalText¶added inv1.18.0
func (kDiscoPublic) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (DiscoPublic)Raw32deprecatedadded inv1.18.0
func (kDiscoPublic) Raw32() [32]byte
Raw32 returns k encoded as 32 raw bytes.
Deprecated: only needed for a temporary compat shim in tailcfg, donot add more uses.
func (DiscoPublic)ShortString¶added inv1.18.0
func (kDiscoPublic) ShortString()string
ShortString returns the Tailscale conventional debug representationof a disco key.
func (DiscoPublic)String¶added inv1.18.0
func (kDiscoPublic) String()string
String returns the output of MarshalText as a string.
func (*DiscoPublic)UnmarshalText¶added inv1.18.0
func (k *DiscoPublic) UnmarshalText(b []byte)error
MarshalText implements encoding.TextUnmarshaler.
typeDiscoShared¶added inv1.18.0
type DiscoShared struct {// contains filtered or unexported fields}func (DiscoShared)Equal¶added inv1.18.0
func (kDiscoShared) Equal(otherDiscoShared)bool
Equal reports whether k and other are the same key.
func (DiscoShared)IsZero¶added inv1.18.0
func (kDiscoShared) IsZero()bool
func (DiscoShared)Open¶added inv1.18.0
func (kDiscoShared) Open(ciphertext []byte) (cleartext []byte, okbool)
Open opens the NaCl box ciphertext, which must be a value createdby Seal, and returns the inner cleartext if ciphertext is a validbox using shared secret k.
func (DiscoShared)Seal¶added inv1.18.0
func (kDiscoShared) Seal(cleartext []byte) (ciphertext []byte)
Seal wraps cleartext into a NaCl box (seegolang.org/x/crypto/nacl), using k as the shared secret and arandom nonce.
typeHardwareAttestationKey¶added inv1.88.0
type HardwareAttestationKey interface {crypto.Signerjson.Marshalerjson.Unmarshalerio.CloserClone()HardwareAttestationKeyIsZero()bool}HardwareAttestationKey describes a hardware-backed key that is used toidentify a node. Implementation details willvary based on the platform in use (SecureEnclave for Apple, TPM forWindows/Linux, Android Hardware-backed Keystore).This key can only be marshalled and unmarshaled on the same machine.
funcNewEmptyHardwareAttestationKey¶added inv1.88.0
func NewEmptyHardwareAttestationKey() (HardwareAttestationKey,error)
NewEmptyHardwareAttestationKey returns an empty HardwareAttestationKeysuitable for JSON unmarshaling.
funcNewHardwareAttestationKey¶added inv1.88.0
func NewHardwareAttestationKey() (HardwareAttestationKey,error)
NewHardwareAttestationKey returns a newly created HardwareAttestationKey forthe current platform.
typeHardwareAttestationKeyFn¶added inv1.88.0
type HardwareAttestationKeyFn func() (HardwareAttestationKey,error)
HardwareAttestationKeyFn is a callback function type that returns a HardwareAttestationKeyand an error. It is used to register platform-specific implementations ofHardwareAttestationKey.
typeHardwareAttestationPublic¶added inv1.90.0
type HardwareAttestationPublic struct {// contains filtered or unexported fields}HardwareAttestationPublic is the public key counterpart toHardwareAttestationKey.
funcHardwareAttestationPublicFromPlatformKey¶added inv1.90.0
func HardwareAttestationPublicFromPlatformKey(kHardwareAttestationKey)HardwareAttestationPublic
HardwareAttestationPublicFromPlatformKey creates a HardwareAttestationPublicfor communicating the public component of the hardware attestation keywith control and other nodes.
func (HardwareAttestationPublic)AppendText¶added inv1.90.0
func (kHardwareAttestationPublic) AppendText(dst []byte) ([]byte,error)
func (*HardwareAttestationPublic)Clone¶added inv1.90.0
func (k *HardwareAttestationPublic) Clone() *HardwareAttestationPublic
func (HardwareAttestationPublic)Equal¶added inv1.90.0
func (kHardwareAttestationPublic) Equal(oHardwareAttestationPublic)bool
func (HardwareAttestationPublic)IsZero¶added inv1.90.0
func (kHardwareAttestationPublic) IsZero()bool
IsZero reports whether k is the zero value.
func (HardwareAttestationPublic)MarshalText¶added inv1.90.0
func (kHardwareAttestationPublic) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (HardwareAttestationPublic)String¶added inv1.90.0
func (kHardwareAttestationPublic) String()string
String returns the hex-encoded public key with a type prefix.
func (*HardwareAttestationPublic)UnmarshalText¶added inv1.90.0
func (k *HardwareAttestationPublic) UnmarshalText(b []byte)error
UnmarshalText implements encoding.TextUnmarshaler. It expects a typed prefixfollowed by a hex encoded representation of k.
func (HardwareAttestationPublic)Verifier¶added inv1.90.0
func (kHardwareAttestationPublic) Verifier() *ecdsa.PublicKey
Verifier returns the ECDSA public key for verifying signatures made by k.
typeMachinePrecomputedSharedKey¶added inv1.30.0
type MachinePrecomputedSharedKey struct {// contains filtered or unexported fields}MachinePrecomputedSharedKey is a precomputed shared NaCl box shared key.
func (MachinePrecomputedSharedKey)Open¶added inv1.30.0
func (kMachinePrecomputedSharedKey) Open(ciphertext []byte) (cleartext []byte, okbool)
Open opens the NaCl box ciphertext, which must be a value created byMachinePrecomputedSharedKey.Seal or MachinePrivate.SealTo, and returns theinner cleartext if ciphertext is a valid box for the shared key k.
func (MachinePrecomputedSharedKey)Seal¶added inv1.30.0
func (kMachinePrecomputedSharedKey) Seal(cleartext []byte) (ciphertext []byte)
Seal wraps cleartext into a NaCl box (seegolang.org/x/crypto/nacl) using the shared key k as generatedby MachinePrivate.SharedKey.
The returned ciphertext is a 24-byte nonce concatenated with thebox value.
typeMachinePrivate¶added inv1.16.0
type MachinePrivate struct {// contains filtered or unexported fields}MachinePrivate is a machine key, used for communication with theTailscale coordination server.
funcNewMachine¶added inv1.16.0
func NewMachine()MachinePrivate
NewMachine creates and returns a new machine private key.
func (MachinePrivate)AppendText¶added inv1.50.0
func (kMachinePrivate) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender.
func (MachinePrivate)Equal¶added inv1.16.0
func (kMachinePrivate) Equal(otherMachinePrivate)bool
Equal reports whether k and other are the same key.
func (MachinePrivate)IsZero¶added inv1.16.0
func (kMachinePrivate) IsZero()bool
IsZero reports whether k is the zero value.
func (MachinePrivate)MarshalText¶added inv1.16.0
func (kMachinePrivate) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (MachinePrivate)OpenFrom¶added inv1.16.0
func (kMachinePrivate) OpenFrom(pMachinePublic, ciphertext []byte) (cleartext []byte, okbool)
OpenFrom opens the NaCl box ciphertext, which must be a valuecreated by SealTo, and returns the inner cleartext if ciphertext isa valid box from p to k.
func (MachinePrivate)Public¶added inv1.16.0
func (kMachinePrivate) Public()MachinePublic
Public returns the MachinePublic for k.Panics if MachinePrivate is zero.
func (MachinePrivate)SealTo¶added inv1.16.0
func (kMachinePrivate) SealTo(pMachinePublic, cleartext []byte) (ciphertext []byte)
SealTo wraps cleartext into a NaCl box (seegolang.org/x/crypto/nacl) to p, authenticated from k, using arandom nonce.
The returned ciphertext is a 24-byte nonce concatenated with thebox value.
func (MachinePrivate)SharedKey¶added inv1.30.0
func (kMachinePrivate) SharedKey(pMachinePublic)MachinePrecomputedSharedKey
SharedKey returns the precomputed Nacl box shared key between k and p.
func (*MachinePrivate)UnmarshalText¶added inv1.16.0
func (k *MachinePrivate) UnmarshalText(b []byte)error
MarshalText implements encoding.TextUnmarshaler.
func (MachinePrivate)UntypedBytesdeprecatedadded inv1.18.0
func (kMachinePrivate) UntypedBytes() []byte
UntypedBytes returns k, encoded as an untyped 64-character hexstring.
Deprecated: this function is risky to use, because it producesserialized values that do not identify themselves as aMachinePrivate, allowing other code to potentially parse it back inas the wrong key type. For new uses that don't require thisspecific raw byte serialization, please useMarshalText/UnmarshalText.
typeMachinePublic¶added inv1.16.0
type MachinePublic struct {// contains filtered or unexported fields}MachinePublic is the public portion of a a MachinePrivate.
funcMachinePublicFromRaw32¶added inv1.18.0
func MachinePublicFromRaw32(rawmem.RO)MachinePublic
MachinePublicFromRaw32 parses a 32-byte raw value as a MachinePublic.
This should be used only when deserializing a MachinePublic from abinary protocol.
funcParseMachinePublicUntypeddeprecatedadded inv1.16.0
func ParseMachinePublicUntyped(rawmem.RO) (MachinePublic,error)
ParseMachinePublicUntyped parses an untyped 64-character hex valueas a MachinePublic.
Deprecated: this function is risky to use, because it cannot verifythat the hex string was intended to be a MachinePublic. This canlead to accidentally decoding one type of key as another. For newuses that don't require backwards compatibility with the untypedstring format, please use MarshalText/UnmarshalText.
func (MachinePublic)AppendText¶added inv1.50.0
func (kMachinePublic) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender.
func (MachinePublic)IsZero¶added inv1.16.0
func (kMachinePublic) IsZero()bool
IsZero reports whether k is the zero value.
func (MachinePublic)MarshalText¶added inv1.16.0
func (kMachinePublic) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (MachinePublic)ShortString¶added inv1.16.0
func (kMachinePublic) ShortString()string
ShortString returns the Tailscale conventional debug representationof a public key: the first five base64 digits of the key, in squarebrackets.
func (MachinePublic)String¶added inv1.16.0
func (kMachinePublic) String()string
String returns the output of MarshalText as a string.
func (*MachinePublic)UnmarshalText¶added inv1.16.0
func (k *MachinePublic) UnmarshalText(b []byte)error
MarshalText implements encoding.TextUnmarshaler.
func (MachinePublic)UntypedBytesdeprecatedadded inv1.18.0
func (kMachinePublic) UntypedBytes() []byte
UntypedBytes returns k, encoded as an untyped 64-character hexstring.
Deprecated: this function is risky to use, because it producesserialized values that do not identify themselves as aMachinePublic, allowing other code to potentially parse it back inas the wrong key type. For new uses that don't require thisspecific raw byte serialization, please useMarshalText/UnmarshalText.
func (MachinePublic)UntypedHexStringdeprecatedadded inv1.16.0
func (kMachinePublic) UntypedHexString()string
UntypedHexString returns k, encoded as an untyped 64-character hexstring.
Deprecated: this function is risky to use, because it producesserialized values that do not identify themselves as aMachinePublic, allowing other code to potentially parse it back inas the wrong key type. For new uses that don't require backwardscompatibility with the untyped string format, please useMarshalText/UnmarshalText.
typeNLPrivate¶added inv1.30.0
type NLPrivate struct {// contains filtered or unexported fields}NLPrivate is a node-managed network-lock key, used for signingnode-key signatures and authority update messages.
funcNewNLPrivate¶added inv1.30.0
func NewNLPrivate()NLPrivate
NewNLPrivate creates and returns a new network-lock key.
func (NLPrivate)AppendText¶added inv1.50.0
AppendText implements encoding.TextAppender.
func (NLPrivate)MarshalText¶added inv1.30.0
MarshalText implements encoding.TextMarshaler.
func (NLPrivate)SignNKS¶added inv1.30.0
func (kNLPrivate) SignNKS(sigHashtkatype.NKSSigHash) ([]byte,error)
SignNKS signs the tka.NodeKeySignature identified by sigHash.
func (*NLPrivate)UnmarshalText¶added inv1.30.0
MarshalText implements encoding.TextUnmarshaler.
typeNLPublic¶added inv1.30.0
type NLPublic struct {// contains filtered or unexported fields}NLPublic is the public portion of a a NLPrivate.
funcNLPublicFromEd25519Unsafe¶added inv1.34.0
NLPublicFromEd25519Unsafe converts an ed25519 public key intoa type of NLPublic.
New uses of this function should be avoided, as its possible toaccidentally construct an NLPublic from a non network-lock key.
func (NLPublic)AppendText¶added inv1.50.0
AppendText implements encoding.TextAppender.
func (NLPublic)CLIString¶added inv1.34.0
CLIString returns a marshalled representation suitable for usewith tailnet lock commands, of the form tlpub:<hex> instead ofthe nlpub:<hex> form emitted by MarshalText. Both forms canbe decoded by UnmarshalText.
func (NLPublic)KeyID¶added inv1.34.0
KeyID returns a tkatype.KeyID that can be used with a tka.Authority.
func (NLPublic)MarshalText¶added inv1.30.0
MarshalText implements encoding.TextMarshaler, emitting arepresentation of the form nlpub:<hex>.
func (*NLPublic)UnmarshalText¶added inv1.30.0
UnmarshalText implements encoding.TextUnmarshaler. This functionis able to decode both the CLI form (tlpub:<hex>) & theregular form (nlpub:<hex>).
typeNodePrivate¶added inv1.18.0
type NodePrivate struct {// contains filtered or unexported fields}NodePrivate is a node key, used for WireGuard tunnels andcommunication with DERP servers.
funcNewNode¶added inv1.18.0
func NewNode()NodePrivate
NewNode creates and returns a new node private key.
funcNodePrivateFromRaw32deprecatedadded inv1.18.0
func NodePrivateFromRaw32(rawmem.RO)NodePrivate
NodePrivateFromRaw32 parses a 32-byte raw value as a NodePrivate.
Deprecated: only needed to cast from legacy node private key types,do not add more uses unrelated to #3206.
funcParseNodePrivateUntyped¶added inv1.18.0
func ParseNodePrivateUntyped(rawmem.RO) (NodePrivate,error)
func (NodePrivate)AppendText¶added inv1.50.0
func (kNodePrivate) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender.
func (NodePrivate)Equal¶added inv1.18.0
func (kNodePrivate) Equal(otherNodePrivate)bool
Equal reports whether k and other are the same key.
func (NodePrivate)IsZero¶added inv1.18.0
func (kNodePrivate) IsZero()bool
IsZero reports whether k is the zero value.
func (NodePrivate)MarshalText¶added inv1.18.0
func (kNodePrivate) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler.
func (NodePrivate)OpenFrom¶added inv1.18.0
func (kNodePrivate) OpenFrom(pNodePublic, ciphertext []byte) (cleartext []byte, okbool)
OpenFrom opens the NaCl box ciphertext, which must be a valuecreated by SealTo, and returns the inner cleartext if ciphertext isa valid box from p to k.
func (NodePrivate)Public¶added inv1.18.0
func (kNodePrivate) Public()NodePublic
Public returns the NodePublic for k.Panics if NodePrivate is zero.
func (NodePrivate)SealTo¶added inv1.18.0
func (kNodePrivate) SealTo(pNodePublic, cleartext []byte) (ciphertext []byte)
SealTo wraps cleartext into a NaCl box (seegolang.org/x/crypto/nacl) to p, authenticated from k, using arandom nonce.
The returned ciphertext is a 24-byte nonce concatenated with thebox value.
func (NodePrivate)SealToChallenge¶added inv1.34.0
func (kNodePrivate) SealToChallenge(pChallengePublic, cleartext []byte) (ciphertext []byte)
SealToChallenge is like SealTo, but for a ChallengePublic.
func (*NodePrivate)UnmarshalText¶added inv1.18.0
func (k *NodePrivate) UnmarshalText(b []byte)error
MarshalText implements encoding.TextUnmarshaler.
func (NodePrivate)UntypedHexString¶added inv1.18.0
func (kNodePrivate) UntypedHexString()string
typeNodePublic¶added inv1.18.0
type NodePublic struct {// contains filtered or unexported fields}NodePublic is the public portion of a NodePrivate.
funcNodePublicFromRaw32¶added inv1.18.0
func NodePublicFromRaw32(rawmem.RO)NodePublic
NodePublicFromRaw32 parses a 32-byte raw value as a NodePublic.
This should be used only when deserializing a NodePublic from abinary protocol.
funcNodePublicWithBadOldPrefix¶added inv1.36.0
func NodePublicWithBadOldPrefix(kNodePublic)NodePublic
NodePublicWithBadOldPrefix returns a copy of k with its leading public keybytes mutated such that it base64's to a ShortString of [bad01] ("bad ol'"[expired node key]).
funcParseNodePublicUntypeddeprecatedadded inv1.18.0
func ParseNodePublicUntyped(rawmem.RO) (NodePublic,error)
ParseNodePublicUntyped parses an untyped 64-character hex valueas a NodePublic.
Deprecated: this function is risky to use, because it cannot verifythat the hex string was intended to be a NodePublic. This canlead to accidentally decoding one type of key as another. For newuses that don't require backwards compatibility with the untypedstring format, please use MarshalText/UnmarshalText.
func (NodePublic)AppendText¶added inv1.50.0
func (kNodePublic) AppendText(b []byte) ([]byte,error)
AppendText implements encoding.TextAppender. It appends a typed prefixfollowed by hex encoded represtation of k to b.
func (NodePublic)AppendTo¶added inv1.18.0
func (kNodePublic) AppendTo(buf []byte) []byte
AppendTo appends k, serialized as a 32-byte binary value, tobuf. Returns the new slice.
func (NodePublic)Compare¶added inv1.50.0
func (pNodePublic) Compare(p2NodePublic)int
Compare returns -1, 0, or 1, depending on whether p orders before p2,using bytes.Compare on the bytes of the public key.
func (NodePublic)IsZero¶added inv1.18.0
func (kNodePublic) IsZero()bool
IsZero reports whether k is the zero value.
func (NodePublic)Less¶added inv1.18.0
func (kNodePublic) Less(otherNodePublic)bool
Less reports whether k orders before other, using an undocumenteddeterministic ordering.
func (NodePublic)MarshalBinary¶added inv1.30.0
func (kNodePublic) MarshalBinary() (data []byte, errerror)
MarshalBinary implements encoding.BinaryMarshaler.
func (NodePublic)MarshalText¶added inv1.18.0
func (kNodePublic) MarshalText() ([]byte,error)
MarshalText implements encoding.TextMarshaler. It returns a typed prefixfollowed by a hex encoded representation of k.
func (NodePublic)Raw32deprecatedadded inv1.18.0
func (kNodePublic) Raw32() [32]byte
Raw32 returns k encoded as 32 raw bytes.
Deprecated: only needed for a single legacy use in the controlserver and a few places in the wireguard-go API; don't addmore uses.
func (*NodePublic)ReadRawWithoutAllocating¶added inv1.18.0
func (k *NodePublic) ReadRawWithoutAllocating(br *bufio.Reader)error
ReadRawWithoutAllocating initializes k with bytes read from br.The reading is done ~4x slower than io.ReadFull, but in exchange isallocation-free.
func (NodePublic)Shard¶added inv1.26.0
func (pNodePublic) Shard()uint8
Shard returns a uint8 number from a public key withmostly-uniform distribution, suitable for sharding.
func (NodePublic)ShortString¶added inv1.18.0
func (kNodePublic) ShortString()string
ShortString returns the Tailscale conventional debug representationof a public key: the first five base64 digits of the key, in squarebrackets.
func (NodePublic)String¶added inv1.18.0
func (kNodePublic) String()string
String returns k as a hex-encoded string with a type prefix.
func (*NodePublic)UnmarshalBinary¶added inv1.30.0
func (k *NodePublic) UnmarshalBinary(in []byte)error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*NodePublic)UnmarshalText¶added inv1.18.0
func (k *NodePublic) UnmarshalText(b []byte)error
UnmarshalText implements encoding.TextUnmarshaler. It expects a typed prefixfollowed by a hex encoded representation of k.
func (NodePublic)UntypedHexStringdeprecatedadded inv1.18.0
func (kNodePublic) UntypedHexString()string
UntypedHexString returns k, encoded as an untyped 64-character hexstring.
Deprecated: this function is risky to use, because it producesserialized values that do not identify themselves as aNodePublic, allowing other code to potentially parse it back inas the wrong key type. For new uses that don't require backwardscompatibility with the untyped string format, please useMarshalText/UnmarshalText.
func (NodePublic)WireGuardGoString¶added inv1.18.0
func (kNodePublic) WireGuardGoString()string
WireGuardGoString prints k in the same format used by wireguard-go.
func (NodePublic)WriteRawWithoutAllocating¶added inv1.18.0
func (kNodePublic) WriteRawWithoutAllocating(bw *bufio.Writer)error
WriteRawWithoutAllocating writes out k as 32 bytes to bw.The writing is done ~3x slower than bw.Write, but in exchange isallocation-free.
typeSortedPairOfDiscoPublic¶added inv1.86.0
type SortedPairOfDiscoPublic struct {// contains filtered or unexported fields}SortedPairOfDiscoPublic is a lexicographically sorted container of twoDiscoPublic keys.
funcNewSortedPairOfDiscoPublic¶added inv1.86.0
func NewSortedPairOfDiscoPublic(a, bDiscoPublic)SortedPairOfDiscoPublic
NewSortedPairOfDiscoPublic returns a SortedPairOfDiscoPublic from a and b.
func (SortedPairOfDiscoPublic)Equal¶added inv1.86.0
func (sSortedPairOfDiscoPublic) Equal(bSortedPairOfDiscoPublic)bool
Equal returns true if s and b are equal, otherwise it returns false.
func (SortedPairOfDiscoPublic)Get¶added inv1.86.0
func (sSortedPairOfDiscoPublic) Get() [2]DiscoPublic
Get returns the underlying keys.
func (SortedPairOfDiscoPublic)String¶added inv1.86.0
func (sSortedPairOfDiscoPublic) String()string