mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-21 07:28:45 +00:00
tka,types/key: remove dependency for tailcfg & types/ packages on tka
Following the pattern elsewhere, we create a new tka-specific types package for the types that need to couple between the serialized structure types, and tka. Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
"crypto/subtle"
|
||||
|
||||
"go4.org/mem"
|
||||
"tailscale.com/tka"
|
||||
"tailscale.com/types/structs"
|
||||
"tailscale.com/types/tkatype"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -68,23 +68,26 @@ func (k NLPrivate) Public() NLPublic {
|
||||
}
|
||||
|
||||
// KeyID returns an identifier for this key.
|
||||
func (k NLPrivate) KeyID() tka.KeyID {
|
||||
pub := k.Public()
|
||||
return tka.Key{
|
||||
Kind: tka.Key25519,
|
||||
Public: pub.k[:],
|
||||
}.ID()
|
||||
func (k NLPrivate) KeyID() tkatype.KeyID {
|
||||
// The correct way to compute this is:
|
||||
// return tka.Key{
|
||||
// Kind: tka.Key25519,
|
||||
// Public: pub.k[:],
|
||||
// }.ID()
|
||||
//
|
||||
// However, under the hood the key id for a 25519
|
||||
// key is just the public key, so we avoid the
|
||||
// dependency on tka by just doing this ourselves.
|
||||
pub := k.Public().k
|
||||
return pub[:]
|
||||
}
|
||||
|
||||
// SignAUM implements tka.UpdateSigner.
|
||||
func (k NLPrivate) SignAUM(a *tka.AUM) error {
|
||||
sigHash := a.SigHash()
|
||||
|
||||
a.Signatures = append(a.Signatures, tka.Signature{
|
||||
func (k NLPrivate) SignAUM(sigHash tkatype.AUMSigHash) ([]tkatype.Signature, error) {
|
||||
return []tkatype.Signature{{
|
||||
KeyID: k.KeyID(),
|
||||
Signature: ed25519.Sign(k.k[:], sigHash[:]),
|
||||
})
|
||||
return nil
|
||||
Signature: ed25519.Sign(ed25519.PrivateKey(k.k[:]), sigHash[:]),
|
||||
}}, nil
|
||||
}
|
||||
|
||||
// NLPublic is the public portion of a a NLPrivate.
|
||||
|
Reference in New Issue
Block a user