tka.go 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package tailcfg
  4. import (
  5. "tailscale.com/types/key"
  6. "tailscale.com/types/tkatype"
  7. )
  8. // TKAInitBeginRequest submits a genesis AUM to seed the creation of the
  9. // tailnet's key authority.
  10. type TKAInitBeginRequest struct {
  11. // Version is the client's capabilities.
  12. Version CapabilityVersion
  13. // NodeKey is the client's current node key.
  14. NodeKey key.NodePublic
  15. // GenesisAUM is the initial (genesis) AUM that the node generated
  16. // to bootstrap tailnet key authority state.
  17. GenesisAUM tkatype.MarshaledAUM
  18. }
  19. // TKASignInfo describes information about an existing node that needs
  20. // to be signed into a node-key signature.
  21. type TKASignInfo struct {
  22. // NodeID is the ID of the node which needs a signature. It must
  23. // correspond to NodePublic.
  24. NodeID NodeID
  25. // NodePublic is the node (Wireguard) public key which is being
  26. // signed.
  27. NodePublic key.NodePublic
  28. // RotationPubkey specifies the public key which may sign
  29. // a NodeKeySignature (NKS), which rotates the node key.
  30. //
  31. // This is necessary so the node can rotate its node-key without
  32. // talking to a node which holds a trusted network-lock key.
  33. // It does this by nesting the original NKS in a 'rotation' NKS,
  34. // which it then signs with the key corresponding to RotationPubkey.
  35. //
  36. // This field expects a raw ed25519 public key.
  37. RotationPubkey []byte
  38. }
  39. // TKAInitBeginResponse is the JSON response from a /tka/init/begin RPC.
  40. // This structure describes node information which must be signed to
  41. // complete initialization of the tailnets' key authority.
  42. type TKAInitBeginResponse struct {
  43. // NeedSignatures specify information about the nodes in your tailnet
  44. // which need initial signatures to function once the tailnet key
  45. // authority is in use. The generated signatures should then be
  46. // submitted in a /tka/init/finish RPC.
  47. NeedSignatures []TKASignInfo
  48. }
  49. // TKAInitFinishRequest is the JSON request of a /tka/init/finish RPC.
  50. // This RPC finalizes initialization of the tailnet key authority
  51. // by submitting node-key signatures for all existing nodes.
  52. type TKAInitFinishRequest struct {
  53. // Version is the client's capabilities.
  54. Version CapabilityVersion
  55. // NodeKey is the client's current node key.
  56. NodeKey key.NodePublic
  57. // Signatures are serialized tka.NodeKeySignatures for all nodes
  58. // in the tailnet.
  59. Signatures map[NodeID]tkatype.MarshaledSignature
  60. // SupportDisablement is a disablement secret for Tailscale support.
  61. // This is only generated if --gen-disablement-for-support is specified
  62. // in an invocation to 'tailscale lock init'.
  63. SupportDisablement []byte `json:",omitempty"`
  64. }
  65. // TKAInitFinishResponse is the JSON response from a /tka/init/finish RPC.
  66. // This schema describes the successful enablement of the tailnet's
  67. // key authority.
  68. type TKAInitFinishResponse struct {
  69. // Nothing. (yet?)
  70. }
  71. // TKAInfo encodes the control plane's view of tailnet key authority (TKA)
  72. // state. This information is transmitted as part of the MapResponse.
  73. type TKAInfo struct {
  74. // Head describes the hash of the latest AUM applied to the authority.
  75. // Head is encoded as tka.AUMHash.MarshalText.
  76. //
  77. // If the Head state differs to that known locally, the node should perform
  78. // synchronization via a separate RPC.
  79. Head string `json:",omitempty"`
  80. // Disabled indicates the control plane believes TKA should be disabled,
  81. // and the node should reach out to fetch a disablement
  82. // secret. If the disablement secret verifies, then the node should then
  83. // disable TKA locally.
  84. // This field exists to disambiguate a nil TKAInfo in a delta mapresponse
  85. // from a nil TKAInfo indicating TKA should be disabled.
  86. Disabled bool `json:",omitempty"`
  87. }
  88. // TKABootstrapRequest is sent by a node to get information necessary for
  89. // enabling or disabling the tailnet key authority.
  90. type TKABootstrapRequest struct {
  91. // Version is the client's capabilities.
  92. Version CapabilityVersion
  93. // NodeKey is the client's current node key.
  94. NodeKey key.NodePublic
  95. // Head represents the node's head AUMHash (tka.Authority.Head), if
  96. // network lock is enabled.
  97. Head string
  98. }
  99. // TKABootstrapResponse encodes values necessary to enable or disable
  100. // the tailnet key authority (TKA).
  101. type TKABootstrapResponse struct {
  102. // GenesisAUM returns the initial AUM necessary to initialize TKA.
  103. GenesisAUM tkatype.MarshaledAUM `json:",omitempty"`
  104. // DisablementSecret encodes a secret necessary to disable TKA.
  105. DisablementSecret []byte `json:",omitempty"`
  106. }
  107. // TKASyncOfferRequest encodes a request to synchronize tailnet key authority
  108. // state (TKA). Values of type tka.AUMHash are encoded as strings in their
  109. // MarshalText form.
  110. type TKASyncOfferRequest struct {
  111. // Version is the client's capabilities.
  112. Version CapabilityVersion
  113. // NodeKey is the client's current node key.
  114. NodeKey key.NodePublic
  115. // Head represents the node's head AUMHash (tka.Authority.Head). This
  116. // corresponds to tka.SyncOffer.Head.
  117. Head string
  118. // Ancestors represents a selection of ancestor AUMHash values ascending
  119. // from the current head. This corresponds to tka.SyncOffer.Ancestors.
  120. Ancestors []string
  121. }
  122. // TKASyncOfferResponse encodes a response in synchronizing a node's
  123. // tailnet key authority state. Values of type tka.AUMHash are encoded as
  124. // strings in their MarshalText form.
  125. type TKASyncOfferResponse struct {
  126. // Head represents the control plane's head AUMHash (tka.Authority.Head).
  127. // This corresponds to tka.SyncOffer.Head.
  128. Head string
  129. // Ancestors represents a selection of ancestor AUMHash values ascending
  130. // from the control plane's head. This corresponds to
  131. // tka.SyncOffer.Ancestors.
  132. Ancestors []string
  133. // MissingAUMs encodes AUMs that the control plane believes the node
  134. // is missing.
  135. MissingAUMs []tkatype.MarshaledAUM
  136. }
  137. // TKASyncSendRequest encodes AUMs that a node believes the control plane
  138. // is missing, and notifies control of its local TKA state (specifically
  139. // the head hash).
  140. type TKASyncSendRequest struct {
  141. // Version is the client's capabilities.
  142. Version CapabilityVersion
  143. // NodeKey is the client's current node key.
  144. NodeKey key.NodePublic
  145. // Head represents the node's head AUMHash (tka.Authority.Head) after
  146. // applying any AUMs from the sync-offer response.
  147. // It is encoded as tka.AUMHash.MarshalText.
  148. Head string
  149. // MissingAUMs encodes AUMs that the node believes the control plane
  150. // is missing.
  151. MissingAUMs []tkatype.MarshaledAUM
  152. // Interactive is true if additional error checking should be performed as
  153. // the request is on behalf of an interactive operation (e.g., an
  154. // administrator publishing new changes) as opposed to an automatic
  155. // synchronization that may be reporting lost data.
  156. Interactive bool
  157. }
  158. // TKASyncSendResponse encodes the control plane's response to a node
  159. // submitting AUMs during AUM synchronization.
  160. type TKASyncSendResponse struct {
  161. // Head represents the control plane's head AUMHash (tka.Authority.Head),
  162. // after applying the missing AUMs.
  163. Head string
  164. }
  165. // TKADisableRequest disables network-lock across the tailnet using the
  166. // provided disablement secret.
  167. //
  168. // This is the request schema for a /tka/disable noise RPC.
  169. type TKADisableRequest struct {
  170. // Version is the client's capabilities.
  171. Version CapabilityVersion
  172. // NodeKey is the client's current node key.
  173. NodeKey key.NodePublic
  174. // Head represents the node's head AUMHash (tka.Authority.Head).
  175. // It is encoded as tka.AUMHash.MarshalText.
  176. Head string
  177. // DisablementSecret encodes the secret necessary to disable TKA.
  178. DisablementSecret []byte
  179. }
  180. // TKADisableResponse is the JSON response from a /tka/disable RPC.
  181. // This schema describes the successful disablement of the tailnet's
  182. // key authority.
  183. type TKADisableResponse struct {
  184. // Nothing. (yet?)
  185. }
  186. // TKASubmitSignatureRequest transmits a node-key signature to the control plane.
  187. //
  188. // This is the request schema for a /tka/sign noise RPC.
  189. type TKASubmitSignatureRequest struct {
  190. // Version is the client's capabilities.
  191. Version CapabilityVersion
  192. // NodeKey is the client's current node key. The node-key which
  193. // is being signed is embedded in Signature.
  194. NodeKey key.NodePublic
  195. // Signature encodes the node-key signature being submitted.
  196. Signature tkatype.MarshaledSignature
  197. }
  198. // TKASubmitSignatureResponse is the JSON response from a /tka/sign RPC.
  199. type TKASubmitSignatureResponse struct {
  200. // Nothing. (yet?)
  201. }
  202. // TKASignaturesUsingKeyRequest asks the control plane for
  203. // all signatures which are signed by the provided keyID.
  204. //
  205. // This is the request schema for a /tka/affected-sigs RPC.
  206. type TKASignaturesUsingKeyRequest struct {
  207. // Version is the client's capabilities.
  208. Version CapabilityVersion
  209. // NodeKey is the client's current node key.
  210. NodeKey key.NodePublic
  211. // KeyID is the key we are querying using.
  212. KeyID tkatype.KeyID
  213. }
  214. // TKASignaturesUsingKeyResponse is the JSON response to
  215. // a /tka/affected-sigs RPC.
  216. //
  217. // It enumerates all signatures which are signed by the
  218. // queried keyID.
  219. type TKASignaturesUsingKeyResponse struct {
  220. Signatures []tkatype.MarshaledSignature
  221. }