Movatterモバイル変換


[0]ホーム

URL:


tka

package
v1.92.2Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:31Imported by:19

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package tka implements the Tailnet Key Authority (TKA) for Tailnet Lock.

Index

Constants

View Source
const (DeeplinkTailscaleURLScheme = "tailscale"DeeplinkCommandSign        = "sign-device")

Variables

View Source
var ErrNoIntersection =errors.New("no intersection")

ErrNoIntersection is returned when a shared AUM couldnot be determined when evaluating a remote sync offer.

View Source
var ErrNoSuchKey =errors.New("key not found")

ErrNoSuchKey is returned if the key referenced by a KeyID does not exist.

Functions

funcCreateadded inv1.30.0

func Create(storageChonk, stateState, signerSigner) (*Authority,AUM,error)

Create initializes a brand-new TKA, generating a genesis updateand committing it to the given storage.

The given signer must also be present in state as a trusted key.

Do not use this to initialize a TKA that already exists, use Open()or Bootstrap() instead.

funcDisablementKDFadded inv1.32.0

func DisablementKDF(secret []byte) []byte

DisablementKDF computes a public value which can be stored in akey authority, but cannot be reversed to find the input secret.

When the output of this function is stored in tka state (i.e. intka.State.DisablementSecrets) a call to Authority.ValidDisablement()with the input of this function as the argument will return true.

funcFromSyncOfferadded inv1.92.0

func FromSyncOffer(offerSyncOffer) (headstring, ancestors []string, errerror)

FromSyncOffer marshals the fields of a SyncOffer so they can besent in a [tailcfg.TKASyncOfferRequest].

funcResignNKSadded inv1.68.0

ResignNKS re-signs a node-key signature for a new node-key.

This only matters on network-locked tailnets, because node-key signatures arehow other nodes know that a node-key is authentic. When the node-key isrotated then the existing signature becomes invalid, so this function isresponsible for generating a new wrapping signature to certify the new node-key.

The signature itself is a SigRotation signature, which embeds the old signatureand certifies the new node-key as a replacement for the old by signing the newsignature with RotationPubkey (which is the node's own network-lock key).

funcSignByCredentialadded inv1.68.2

func SignByCredential(privKey []byte, wrapped *NodeKeySignature, nodeKeykey.NodePublic) (tkatype.MarshaledSignature,error)

SignByCredential signs a node public key by a private key which has itssigning authority delegated by a SigCredential signature. This is used bywrapped auth keys.

Types

typeAUM

type AUM struct {MessageKindAUMKind     `cbor:"1,keyasint"`PrevAUMHashPrevAUMHash `cbor:"2,keyasint"`// Key encodes a public key to be added to the key authority.// This field is used for AddKey AUMs.Key *Key `cbor:"3,keyasint,omitempty"`// KeyID references a public key which is part of the key authority.// This field is used for RemoveKey and UpdateKey AUMs.KeyIDtkatype.KeyID `cbor:"4,keyasint,omitempty"`// State describes the full state of the key authority.// This field is used for Checkpoint AUMs.State *State `cbor:"5,keyasint,omitempty"`// Votes and Meta describe properties of a key in the key authority.// These fields are used for UpdateKey AUMs.Votes *uint             `cbor:"6,keyasint,omitempty"`Meta  map[string]string `cbor:"7,keyasint,omitempty"`// Signatures lists the signatures over this AUM.// CBOR key 23 is the last key which can be encoded as a single byte.Signatures []tkatype.Signature `cbor:"23,keyasint,omitempty"`}

AUM describes an Authority Update Message.

The rules for adding new types of AUMs (MessageKind):

  • CBOR key IDs must never be changed.
  • New AUM types must not change semantics that are manipulated by otherAUM types.
  • The serialization of existing data cannot change (in other words, ifan existing serialization test in aum_test.go fails, you need to try adifferent approach).

The rules for adding new fields are as follows:

  • Must all be optional.
  • An unset value must not result in serialization overhead. This isnecessary so the serialization of older AUMs stays the same.
  • New processing semantics of the new fields must be compatible with thebehavior of old clients (which will ignore the field).
  • No floats!

func (*AUM)Hash

func (a *AUM) Hash()AUMHash

Hash returns a cryptographic digest of all AUM contents.

func (*AUM)Parent

func (a *AUM) Parent() (hAUMHash, okbool)

Parent returns the parent's AUM hash and true, or azero value and false if there was no parent.

func (*AUM)Serialize

func (a *AUM) Serialize()tkatype.MarshaledAUM

Serialize returns the given AUM in a serialized format.

We would implement encoding.BinaryMarshaler, except that wouldunfortunately get called by the cbor marshaller resulting in infiniterecursion.

func (AUM)SigHash

func (aAUM) SigHash()tkatype.AUMSigHash

SigHash returns the cryptographic digest which a signatureis over.

This is identical to Hash() except the Signatures are notserialized. Without this, the hash used for signatureswould be circularly dependent on the signatures.

func (*AUM)StaticValidate

func (a *AUM) StaticValidate()error

StaticValidate returns a nil error if the AUM is well-formed.

func (*AUM)Unserializeadded inv1.30.0

func (a *AUM) Unserialize(data []byte)error

Unserialize decodes bytes representing a marshaled AUM.

We would implement encoding.BinaryUnmarshaler, except that wouldunfortunately get called by the cbor unmarshaller resulting in infiniterecursion.

func (*AUM)Weight

func (a *AUM) Weight(stateState)uint

Weight computes the 'signature weight' of the AUMbased on keys in the state machine. The caller mustensure that all signatures are valid.

More formally: W = Sum(key.votes)

AUMs with a higher weight than their siblingsare preferred when resolving forks in the AUM chain.

typeAUMHash

type AUMHash [blake2s.Size]byte

AUMHash represents the BLAKE2s digest of an Authority Update Message (AUM).

funcCompactadded inv1.38.0

func Compact(storageCompactableChonk, headAUMHash, optsCompactionOptions) (lastActiveAncestorAUMHash, errerror)

Compact deletes old AUMs from storage, based on the parameters given in opts.

func (AUMHash)AppendTextadded inv1.50.0

func (hAUMHash) AppendText(b []byte) ([]byte,error)

AppendText implements encoding.TextAppender.

func (AUMHash)IsZeroadded inv1.32.0

func (hAUMHash) IsZero()bool

IsZero returns true if the hash is the empty value.

func (AUMHash)MarshalTextadded inv1.30.0

func (hAUMHash) MarshalText() ([]byte,error)

MarshalText implements encoding.TextMarshaler.

func (AUMHash)Stringadded inv1.30.0

func (hAUMHash) String()string

String returns the AUMHash encoded as base32.This is suitable for use as a filename, and for storing in text-preferred media.

func (*AUMHash)UnmarshalTextadded inv1.30.0

func (h *AUMHash) UnmarshalText(text []byte)error

UnmarshalText implements encoding.TextUnmarshaler.

typeAUMKind

type AUMKinduint8

AUMKind describes valid AUM types.

const (AUMInvalidAUMKind =iota// An AddKey AUM describes a new key trusted by the TKA.//// Only the Key optional field may be set.AUMAddKey// A RemoveKey AUM describes the removal of a key trusted by TKA.//// Only the KeyID optional field may be set.AUMRemoveKey// A NoOp AUM carries no information and is used in tests.AUMNoOp// A UpdateKey AUM updates the metadata or votes of an existing key.//// Only KeyID, along with either/or Meta or Votes optional fields// may be set.AUMUpdateKey// A Checkpoint AUM specifies the full state of the TKA.//// Only the State optional field may be set.AUMCheckpoint)

Valid AUM types. Do NOT reorder.

func (AUMKind)String

func (kAUMKind) String()string

typeAuthorityadded inv1.30.0

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

Authority is a Tailnet Key Authority. This type is the main couplingpoint to the rest of the tailscale client.

Authority objects can either be created from an existing, non-emptytailchonk (via tka.Open()), or created from scratch using tka.Bootstrap()or tka.Create().

funcBootstrapadded inv1.30.0

func Bootstrap(storageChonk, bootstrapAUM) (*Authority,error)

Bootstrap initializes a TKA based on the given checkpoint.

Call this when setting up a new nodes' TKA, but other nodeswith initialized TKA's exist.

Pass the returned genesis AUM from Create(), or a later checkpoint AUM.

TODO(tom): We should test an authority bootstrapped from a later checkpointworks fine with sync and everything.

funcOpenadded inv1.30.0

func Open(storageChonk) (*Authority,error)

Open initializes an existing TKA from the given tailchonk.

Only use this if the current node has initialized an Authority before.If a TKA exists on other nodes but there's nothing locally, use Bootstrap().If no TKA exists anywhere and you are creating it for the firsttime, use New().

func (*Authority)Cloneadded inv1.30.0

func (a *Authority) Clone() *Authority

Clone duplicates the Authority structure.

func (*Authority)Compactadded inv1.38.0

Compact deletes historical AUMs based on the given compaction options.

func (*Authority)Headadded inv1.30.0

func (a *Authority) Head()AUMHash

Head returns the AUM digest of the latest update applied to the statemachine.

func (*Authority)Informadded inv1.30.0

func (a *Authority) Inform(storageChonk, updates []AUM)error

Inform is the same as InformIdempotent, except the state of the Authorityis updated in-place.

func (*Authority)InformIdempotentadded inv1.30.0

func (a *Authority) InformIdempotent(storageChonk, updates []AUM) (Authority,error)

InformIdempotent returns a new Authority based on applying the givenupdates, with the given updates committed to storage.

If any of the updates could not be applied:

  • An error is returned
  • No changes to storage are made.

MissingAUMs() should be used to get a list of updates appropriate forthis function. In any case, updates should be ordered oldest to newest.

func (*Authority)KeyTrustedadded inv1.30.0

func (a *Authority) KeyTrusted(keyIDtkatype.KeyID)bool

KeyTrusted returns true if the given keyID is trusted by the tailnetkey authority.

func (*Authority)Keysadded inv1.34.0

func (a *Authority) Keys() []Key

Keys returns the set of keys trusted by the tailnet key authority.

func (*Authority)MakeRetroactiveRevocationadded inv1.48.0

func (a *Authority) MakeRetroactiveRevocation(storageChonk, removeKeys []tkatype.KeyID, ourKeytkatype.KeyID, forkFromAUMHash) (*AUM,error)

MakeRetroactiveRevocation generates a forking update which revokes the specified keys, insuch a manner that any malicious use of those keys is erased.

If forkFrom is specified, it is used as the parent AUM to fork from. If the zero value,the parent AUM is determined automatically.

The generated AUM must be signed with more signatures than the sum of key votes thatwere compromised, before being consumed by tka.Authority methods.

func (*Authority)MissingAUMsadded inv1.30.0

func (a *Authority) MissingAUMs(storageChonk, remoteOfferSyncOffer) ([]AUM,error)

MissingAUMs returns AUMs a remote may be missing based on theremotes' SyncOffer.

func (*Authority)NewDeeplinkadded inv1.44.0

func (a *Authority) NewDeeplink(paramsNewDeeplinkParams) (string,error)

NewDeeplink creates a signed deeplink using the authority's stateID as asecret. This deeplink can then be validated by ValidateDeeplink.

func (*Authority)NewUpdateradded inv1.30.0

func (a *Authority) NewUpdater(signerSigner) *UpdateBuilder

NewUpdater returns a builder you can use to make changes tothe tailnet key authority.

The provided signer function, if non-nil, is called with each updateto compute and apply signatures.

Updates are specified by calling methods on the returned UpdatedBuilder.Call Finalize() when you are done to obtain the specific update messageswhich actuate the changes.

func (*Authority)NodeKeyAuthorizedadded inv1.30.0

func (a *Authority) NodeKeyAuthorized(nodeKeykey.NodePublic, nodeKeySignaturetkatype.MarshaledSignature)error

NodeKeyAuthorized checks if the provided nodeKeySignature authorizesthe given node key.

func (*Authority)NodeKeyAuthorizedWithDetailsadded inv1.68.0

func (a *Authority) NodeKeyAuthorizedWithDetails(nodeKeykey.NodePublic, nodeKeySignaturetkatype.MarshaledSignature) (*RotationDetails,error)

NodeKeyAuthorized checks if the provided nodeKeySignature authorizesthe given node key, and returns RotationDetails if the signature isa valid rotation signature.

func (*Authority)StateIDsadded inv1.34.0

func (a *Authority) StateIDs() (uint64,uint64)

StateIDs returns the stateIDs for this tailnet key authority. Theseare values that are fixed for the lifetime of the authority: seecomments on the relevant fields in state.go.

func (*Authority)SyncOfferadded inv1.30.0

func (a *Authority) SyncOffer(storageChonk) (SyncOffer,error)

SyncOffer returns an abbreviated description of the current AUMchain, which can be used to synchronize with another (untrusted)Authority instance.

The returned SyncOffer structure should be transmitted to the remoteAuthority, which should call MissingAUMs() using it to determineAUMs which need to be transmitted. This list of AUMs from the remotecan then be applied locally with Inform().

This SyncOffer + AUM exchange should be performed by both ends,because it's possible that either end has AUMs that the other needsto find out about.

func (*Authority)ValidDisablementadded inv1.30.0

func (a *Authority) ValidDisablement(secret []byte)bool

ValidDisablement returns true if the disablement secret was correct.

If this method returns true, the caller should shut down the authorityand purge all network-lock state.

func (*Authority)ValidateDeeplinkadded inv1.44.0

func (a *Authority) ValidateDeeplink(urlStringstring)DeeplinkValidationResult

ValidateDeeplink validates a device signing deeplink using the authority's stateID.The input urlString follows this structure:

tailscale://sign-device/v1/?nk=xxx&tp=xxx&dn=xxx&os=xxx&em=xxx&hm=xxx

where:- "nk" is the nodekey of the node being signed- "tp" is the tailnet lock public key- "dn" is the name of the node- "os" is the operating system of the node- "em" is the email address associated with the node- "hm" is a SHA-256 HMAC computed over the concatenation of the above fields, encoded as a hex string

typeChonk

type Chonk interface {// AUM returns the AUM with the specified digest.//// If the AUM does not exist, then os.ErrNotExist is returned.AUM(hashAUMHash) (AUM,error)// ChildAUMs returns all AUMs with a specified previous// AUM hash.ChildAUMs(prevAUMHashAUMHash) ([]AUM,error)// CommitVerifiedAUMs durably stores the provided AUMs.// Callers MUST ONLY provide AUMs which are verified (specifically,// a call to aumVerify() must return a nil error).// as the implementation assumes that only verified AUMs are stored.CommitVerifiedAUMs(updates []AUM)error// Heads returns AUMs for which there are no children. In other// words, the latest AUM in all possible chains (the 'leaves').Heads() ([]AUM,error)// SetLastActiveAncestor is called to record the oldest-known AUM// that contributed to the current state. This value is used as// a hint on next startup to determine which chain to pick when computing// the current state, if there are multiple distinct chains.SetLastActiveAncestor(hashAUMHash)error// LastActiveAncestor returns the oldest-known AUM that was (in a// previous run) an ancestor of the current state. This is used// as a hint to pick the correct chain in the event that the Chonk stores// multiple distinct chains.LastActiveAncestor() (*AUMHash,error)}

Chonk implementations provide durable storage for AUMs and otherTKA state.

All methods must be thread-safe.

The name 'tailchonk' was coined by @catzkorn.

typeCompactableChonkadded inv1.38.0

type CompactableChonk interface {Chonk// AllAUMs returns all AUMs stored in the chonk.AllAUMs() ([]AUMHash,error)// CommitTime returns the time at which the AUM was committed.//// If the AUM does not exist, then os.ErrNotExist is returned.CommitTime(hashAUMHash) (time.Time,error)// PurgeAUMs permanently and irrevocably deletes the specified// AUMs from storage.PurgeAUMs(hashes []AUMHash)error// RemoveAll permanently and completely clears the TKA state. This should// be called when the user disables Tailnet Lock.RemoveAll()error}

CompactableChonk implementation are extensions of Chonk, which areable to be operated by compaction logic to deleted old AUMs.

typeCompactionOptionsadded inv1.38.0

type CompactionOptions struct {// The minimum number of ancestor AUMs to remember. The actual length// of the chain post-compaction may be longer to reach a Checkpoint AUM.MinChainint// The minimum duration to store an AUM before it is a candidate for deletion.MinAgetime.Duration}

CompactionOptions describes tuneables to use when compacting a Chonk.

typeDeeplinkValidationResultadded inv1.44.0

type DeeplinkValidationResult struct {IsValidboolErrorstringVersionuint8NodeKeystringTLPubstringDeviceNamestringOSNamestringEmailAddressstring}

typeFS

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

FS implements filesystem storage of TKA state.

FS implements the Chonk interface.

funcChonkDiradded inv1.30.0

func ChonkDir(dirstring) (*FS,error)

ChonkDir returns an implementation of Chonk which uses thegiven directory to store TKA state.

func (*FS)AUM

func (c *FS) AUM(hashAUMHash) (AUM,error)

AUM returns the AUM with the specified digest.

If the AUM does not exist, then os.ErrNotExist is returned.

func (*FS)AllAUMsadded inv1.38.0

func (c *FS) AllAUMs() ([]AUMHash,error)

AllAUMs returns all AUMs stored in the chonk.

func (*FS)ChildAUMs

func (c *FS) ChildAUMs(prevAUMHashAUMHash) ([]AUM,error)

AUM returns any known AUMs with a specific parent hash.

func (*FS)CommitTimeadded inv1.38.0

func (c *FS) CommitTime(hAUMHash) (time.Time,error)

CommitTime returns the time at which the AUM was committed.

If the AUM does not exist, then os.ErrNotExist is returned.

func (*FS)CommitVerifiedAUMs

func (c *FS) CommitVerifiedAUMs(updates []AUM)error

CommitVerifiedAUMs durably stores the provided AUMs.Callers MUST ONLY provide AUMs which are verified (specifically,a call to aumVerify must return a nil error), as theimplementation assumes that only verified AUMs are stored.

func (*FS)Heads

func (c *FS) Heads() ([]AUM,error)

Heads returns AUMs for which there are no children. In otherwords, the latest AUM in all possible chains (the 'leaves').

Heads is expected to be called infrequently compared to AUM() orChildAUMs(), so we haven't put any work into maintaining an index.Instead, the full set of AUMs is scanned.

func (*FS)LastActiveAncestor

func (c *FS) LastActiveAncestor() (*AUMHash,error)

LastActiveAncestor returns the oldest-known AUM that was (in aprevious run) an ancestor of the current state. This is usedas a hint to pick the correct chain in the event that the Chonk storesmultiple distinct chains.

Nil is returned if no last-active ancestor is set.

func (*FS)PurgeAUMsadded inv1.38.0

func (c *FS) PurgeAUMs(hashes []AUMHash)error

PurgeAUMs marks the specified AUMs for deletion from storage.

func (*FS)RemoveAlladded inv1.90.7

func (c *FS) RemoveAll()error

RemoveAll permanently and completely clears the TKA state.

func (*FS)SetLastActiveAncestor

func (c *FS) SetLastActiveAncestor(hashAUMHash)error

SetLastActiveAncestor is called to record the oldest-known AUMthat contributed to the current state. This value is used asa hint on next startup to determine which chain to pick when computingthe current state, if there are multiple distinct chains.

typeKey

type Key struct {KindKeyKind `cbor:"1,keyasint"`// Votes describes the weight applied to signatures using this key.// Weighting is used to deterministically resolve branches in the AUM// chain (i.e. forks, where two AUMs exist with the same parent).Votesuint `cbor:"2,keyasint"`// Public encodes the public key of the key. For 25519 keys,// this is simply the point on the curve representing the public// key.Public []byte `cbor:"3,keyasint"`// Meta describes arbitrary metadata about the key. This could be// used to store the name of the key, for instance.Meta map[string]string `cbor:"12,keyasint,omitempty"`}

Key describes the public components of a key known to network-lock.

func (Key)Clone

func (kKey) Clone()Key

Clone makes an independent copy of Key.

NOTE: There is a difference between a nil slice and an empty slice for encoding purposes,so an implementation of Clone() must take care to preserve this.

func (Key)Ed25519added inv1.34.0

func (kKey) Ed25519() (ed25519.PublicKey,error)

Ed25519 returns the ed25519 public key encoded by Key. An error isreturned for keys which do not represent ed25519 public keys.

func (Key)ID

func (kKey) ID() (tkatype.KeyID,error)

ID returns the KeyID of the key.

func (Key)MustIDadded inv1.36.0

func (kKey) MustID()tkatype.KeyID

MustID returns the KeyID of the key, panicking if an error isencountered. This must only be used for tests.

func (Key)StaticValidate

func (kKey) StaticValidate()error

typeKeyKind

type KeyKinduint8

KeyKind describes the different varieties of a Key.

const (KeyInvalidKeyKind =iotaKey25519)

Valid KeyKind values.

func (KeyKind)String

func (kKeyKind) String()string

typeMem

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

Mem implements in-memory storage of TKA state, suitable fortests or cases where filesystem storage is unavailable.

Mem implements the Chonk interface.

Mem is thread-safe.

funcChonkMemadded inv1.92.0

func ChonkMem() *Mem

ChonkMem returns an implementation of Chonk which stores TKA statein-memory.

func (*Mem)AUM

func (c *Mem) AUM(hashAUMHash) (AUM,error)

AUM returns the AUM with the specified digest.

func (*Mem)AllAUMsadded inv1.90.7

func (c *Mem) AllAUMs() ([]AUMHash,error)

AllAUMs returns all AUMs stored in the chonk.

func (*Mem)ChildAUMs

func (c *Mem) ChildAUMs(prevAUMHashAUMHash) ([]AUM,error)

ChildAUMs returns all AUMs with a specified previousAUM hash.

func (*Mem)CommitTimeadded inv1.90.7

func (c *Mem) CommitTime(hAUMHash) (time.Time,error)

CommitTime returns the time at which the AUM was committed.

If the AUM does not exist, then os.ErrNotExist is returned.

func (*Mem)CommitVerifiedAUMs

func (c *Mem) CommitVerifiedAUMs(updates []AUM)error

CommitVerifiedAUMs durably stores the provided AUMs.Callers MUST ONLY provide well-formed and verified AUMs,as the rest of the TKA implementation assumes that onlyverified AUMs are stored.

func (*Mem)Heads

func (c *Mem) Heads() ([]AUM,error)

Heads returns AUMs for which there are no children. In otherwords, the latest AUM in all chains (the 'leaf').

func (*Mem)LastActiveAncestor

func (c *Mem) LastActiveAncestor() (*AUMHash,error)

func (*Mem)PurgeAUMsadded inv1.90.7

func (c *Mem) PurgeAUMs(hashes []AUMHash)error

PurgeAUMs marks the specified AUMs for deletion from storage.

func (*Mem)RemoveAlladded inv1.90.7

func (c *Mem) RemoveAll()error

RemoveAll permanently and completely clears the TKA state.

func (*Mem)SetClockadded inv1.92.0

func (c *Mem) SetClock(clocktstime.Clock)

SetClock sets the clock used byMem. This is only for use in tests,and will panic if called from non-test code.

func (*Mem)SetLastActiveAncestor

func (c *Mem) SetLastActiveAncestor(hashAUMHash)error

typeNewDeeplinkParamsadded inv1.44.0

type NewDeeplinkParams struct {NodeKeystringTLPubstringDeviceNamestringOSNamestringLoginNamestring}

typeNodeKeySignatureadded inv1.30.0

type NodeKeySignature struct {// SigKind identifies the variety of signature.SigKindSigKind `cbor:"1,keyasint"`// Pubkey identifies the key.NodePublic which is being authorized.// SigCredential signatures do not use this field.Pubkey []byte `cbor:"2,keyasint,omitempty"`// KeyID identifies which key in the tailnet key authority should// be used to verify this signature. Only set for SigDirect and// SigCredential signature kinds.KeyID []byte `cbor:"3,keyasint,omitempty"`// Signature is the packed (R, S) ed25519 signature over all other// fields of the structure.Signature []byte `cbor:"4,keyasint,omitempty"`// Nested describes a NodeKeySignature which authorizes the node-key// used as Pubkey. Only used for SigRotation signatures.Nested *NodeKeySignature `cbor:"5,keyasint,omitempty"`// WrappingPubkey specifies the ed25519 public key which must be used// to sign a Signature which embeds this one.//// For SigRotation signatures multiple levels deep, intermediate// signatures may omit this value, in which case the parent WrappingPubkey// is used.//// SigCredential signatures use this field to specify the public key// they are certifying, following the usual semanticsfor WrappingPubkey.WrappingPubkey []byte `cbor:"6,keyasint,omitempty"`}

NodeKeySignature encapsulates a signature that authorizes a specificnode key, based on verification from keys in the tailnet key authority.

funcDecodeWrappedAuthkeyadded inv1.68.2

func DecodeWrappedAuthkey(wrappedAuthKeystring, logflogger.Logf) (authKeystring, isWrappedbool, sig *NodeKeySignature, prived25519.PrivateKey)

DecodeWrappedAuthkey separates wrapping information from an authkey, if any.In all cases the authkey is returned, sans wrapping information if any.

If the authkey is wrapped, isWrapped returns true, along with the wrapping signatureand private key.

func (*NodeKeySignature)Cloneadded inv1.74.0

func (src *NodeKeySignature) Clone() *NodeKeySignature

Clone makes a deep copy of NodeKeySignature.The result aliases no memory with the original.

func (*NodeKeySignature)Serializeadded inv1.30.0

Serialize returns the given NKS in a serialized format.

We would implement encoding.BinaryMarshaler, except that wouldunfortunately get called by the cbor marshaller resulting in infiniterecursion.

func (NodeKeySignature)SigHashadded inv1.30.0

func (sNodeKeySignature) SigHash() [blake2s.Size]byte

SigHash returns the cryptographic digest which a signatureis over.

This is a hash of the serialized structure, sans the signature.Without this exclusion, the hash used for the signaturewould be circularly dependent on the signature.

func (NodeKeySignature)Stringadded inv1.68.0

func (sNodeKeySignature) String()string

String returns a human-readable representation of the NodeKeySignature,making it easy to see nested signatures.

func (*NodeKeySignature)Unserializeadded inv1.30.0

func (s *NodeKeySignature) Unserialize(data []byte)error

Unserialize decodes bytes representing a marshaled NKS.

We would implement encoding.BinaryUnmarshaler, except that wouldunfortunately get called by the cbor unmarshaller resulting in infiniterecursion.

func (NodeKeySignature)UnverifiedAuthorizingKeyIDadded inv1.38.0

func (sNodeKeySignature) UnverifiedAuthorizingKeyID() (tkatype.KeyID,error)

UnverifiedAuthorizingKeyID returns the KeyID of the key which authorizesthis signature.

SAFETY: The caller MUST verify the signature usingAuthority.NodeKeyAuthorized if treating this as authentic information.

func (NodeKeySignature)UnverifiedWrappingPublicadded inv1.38.0

func (sNodeKeySignature) UnverifiedWrappingPublic() (pubed25519.PublicKey, okbool)

UnverifiedWrappingPublic returns the public key which must sign asignature which embeds this one, if any.

See docs on NodeKeySignature.WrappingPubkey & SigRotation for documentationabout wrapping public keys.

SAFETY: The caller MUST verify the signature usingAuthority.NodeKeyAuthorized if treating this as authentic information.

typePrevAUMHashadded inv1.92.0

type PrevAUMHash []byte

PrevAUMHash represents the BLAKE2s digest of an Authority Update Message (AUM).Unlike an AUMHash, this can be empty if there is no previous AUM hash(which occurs in the genesis AUM).

func (PrevAUMHash)Stringadded inv1.92.0

func (hPrevAUMHash) String()string

String returns the PrevAUMHash encoded as base32.This is suitable for use as a filename, and for storing in text-preferred media.

typeRotationDetailsadded inv1.68.0

type RotationDetails struct {// PrevNodeKeys is a list of node keys which have been rotated out.PrevNodeKeys []key.NodePublic// InitialSig is the first signature in the chain which led to// this rotating signature.InitialSig *NodeKeySignature}

RotationDetails holds additional information about a nodeKeySignatureof kind SigRotation.

typeSigKindadded inv1.30.0

type SigKinduint8

SigKind describes valid NodeKeySignature types.

const (SigInvalidSigKind =iota// SigDirect describes a signature over a specific node key, signed// by a key in the tailnet key authority referenced by the specified keyID.SigDirect// SigRotation describes a signature over a specific node key, signed// by the rotation key authorized by a nested NodeKeySignature structure.//// While it is possible to nest rotations multiple times up to the CBOR// nesting limit, it is intended that nodes simply regenerate their outer// SigRotation signature and sign it again with their rotation key. That// way, SigRotation nesting should only be 2 deep in the common case.SigRotation// SigCredential describes a signature over a specific public key, signed// by a key in the tailnet key authority referenced by the specified keyID.// In effect, SigCredential delegates the ability to make a signature to// a different public/private key pair.//// It is intended that a different public/private key pair be generated// for each different SigCredential that is created. Implementors must// take care that the private side is only known to the entity that needs// to generate the wrapping SigRotation signature, and it is immediately// discarded after use.//// SigCredential is expected to be nested in a SigRotation signature.SigCredential)

func (SigKind)Stringadded inv1.30.0

func (sSigKind) String()string

typeSigneradded inv1.30.0

type Signer interface {// SignAUM returns signatures for the AUM encoded by the given AUMSigHash.SignAUM(tkatype.AUMSigHash) ([]tkatype.Signature,error)}

Types implementing Signer can sign update messages.

typeState

type State struct {// LastAUMHash is the blake2s digest of the last-applied AUM.// Because AUMs are strictly ordered and form a hash chain, we// check the previous AUM hash in an update we are applying// is the same as the LastAUMHash.LastAUMHash *AUMHash `cbor:"1,keyasint"`// DisablementSecrets are KDF-derived values which can be used// to turn off the TKA in the event of a consensus-breaking bug.DisablementSecrets [][]byte `cbor:"2,keyasint"`// Keys are the public keys of either:////   1. The signing nodes currently trusted by the TKA.//   2. Ephemeral keys that were used to generate pre-signed auth keys.Keys []Key `cbor:"3,keyasint"`// StateID's are nonce's, generated on enablement and fixed for// the lifetime of the Tailnet Key Authority. We generate 16-bytes// worth of keyspace here just in case we come up with a cool future// use for this.StateID1uint64 `cbor:"4,keyasint,omitempty"`StateID2uint64 `cbor:"5,keyasint,omitempty"`}

State describes Tailnet Key Authority state at an instant in time.

State is mutated by applying Authority Update Messages (AUMs), resultingin a new State.

func (State)Clone

func (sState) Clone()State

Clone makes an independent copy of State.

NOTE: There is a difference between a nil slice and an emptyslice for encoding purposes, so an implementation of Clone()must take care to preserve this.

func (State)GetKey

func (sState) GetKey(keytkatype.KeyID) (Key,error)

GetKey returns the trusted key with the specified KeyID.

typeSyncOfferadded inv1.30.0

type SyncOffer struct {HeadAUMHashAncestors []AUMHash}

SyncOffer conveys information about the current head & ancestor AUMs,for the purpose of synchronization with some remote end.

Ancestors should contain a subset of the ancestors of the chain.The last entry in that slice is the oldest-known AUM in the chain.

funcToSyncOfferadded inv1.92.0

func ToSyncOffer(headstring, ancestors []string) (SyncOffer,error)

ToSyncOffer creates a SyncOffer from the fields received ina [tailcfg.TKASyncOfferRequest].

typeUpdateBuilderadded inv1.30.0

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

UpdateBuilder implements a builder for changes to the tailnetkey authority.

Finalize must be called to compute the update messages, whichmust then be applied to all Authority objects using Inform().

func (*UpdateBuilder)AddKeyadded inv1.30.0

func (b *UpdateBuilder) AddKey(keyKey)error

AddKey adds a new key to the authority.

func (*UpdateBuilder)Finalizeadded inv1.30.0

func (b *UpdateBuilder) Finalize(storageChonk) ([]AUM,error)

Finalize returns the set of update message to actuate the update.

func (*UpdateBuilder)RemoveKeyadded inv1.30.0

func (b *UpdateBuilder) RemoveKey(keyIDtkatype.KeyID)error

RemoveKey removes a key from the authority.

func (*UpdateBuilder)SetKeyMetaadded inv1.30.0

func (b *UpdateBuilder) SetKeyMeta(keyIDtkatype.KeyID, meta map[string]string)error

SetKeyMeta updates key-value metadata stored against an existing key.

TODO(tom): Provide an API to update specific values rather than the wholemap.

func (*UpdateBuilder)SetKeyVoteadded inv1.30.0

func (b *UpdateBuilder) SetKeyVote(keyIDtkatype.KeyID, votesuint)error

SetKeyVote updates the number of votes of an existing key.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp