types/key: add MachinePrivate and MachinePublic.

Plumb throughout the codebase as a replacement for the mixed use of
tailcfg.MachineKey and wgkey.Private/Public.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-09-01 01:52:27 -07:00
committed by Dave Anderson
parent 4ce091cbd8
commit 4fdb88efe1
24 changed files with 605 additions and 234 deletions

View File

@@ -13,6 +13,7 @@ import (
"time"
"inet.af/netaddr"
"tailscale.com/types/key"
"tailscale.com/types/wgkey"
"tailscale.com/version"
)
@@ -213,6 +214,7 @@ func TestNodeEqual(t *testing.T) {
return k.Public()
}
n1 := newPublicKey(t)
m1 := key.NewMachine().Public()
now := time.Now()
tests := []struct {
@@ -290,13 +292,13 @@ func TestNodeEqual(t *testing.T) {
true,
},
{
&Node{Machine: MachineKey(n1)},
&Node{Machine: MachineKey(newPublicKey(t))},
&Node{Machine: m1},
&Node{Machine: key.NewMachine().Public()},
false,
},
{
&Node{Machine: MachineKey(n1)},
&Node{Machine: MachineKey(n1)},
&Node{Machine: m1},
&Node{Machine: m1},
true,
},
{
@@ -393,14 +395,6 @@ func TestNetInfoFields(t *testing.T) {
}
}
func TestMachineKeyMarshal(t *testing.T) {
var k1, k2 MachineKey
for i := range k1 {
k1[i] = byte(i)
}
testKey(t, "mkey:", k1, &k2)
}
func TestNodeKeyMarshal(t *testing.T) {
var k1, k2 NodeKey
for i := range k1 {