tka: implement State and applying AUMs

Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
Tom DNetto
2022-07-06 13:15:13 -07:00
committed by Tom
parent 1cfd96cdc2
commit 3709074e55
5 changed files with 677 additions and 42 deletions

View File

@ -51,6 +51,29 @@ type Key struct {
Meta map[string]string `cbor:"12,keyasint,omitempty"`
}
// 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 (k Key) Clone() Key {
out := k
if k.Public != nil {
out.Public = make([]byte, len(k.Public))
copy(out.Public, k.Public)
}
if k.Meta != nil {
out.Meta = make(map[string]string, len(k.Meta))
for k, v := range k.Meta {
out.Meta[k] = v
}
}
return out
}
func (k Key) ID() KeyID {
switch k.Kind {
// Because 25519 public keys are so short, we just use the 32-byte