mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-09 16:11:23 +00:00
all: generate discovery key, plumb it around
Not actually used yet. Updates #483
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
package key
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"go4.org/mem"
|
||||
"golang.org/x/crypto/curve25519"
|
||||
@@ -20,6 +22,15 @@ type Private [32]byte
|
||||
// Private reports whether p is the zero value.
|
||||
func (p Private) IsZero() bool { return p == Private{} }
|
||||
|
||||
// NewPrivate returns a new private key.
|
||||
func NewPrivate() Private {
|
||||
var p Private
|
||||
if _, err := io.ReadFull(crand.Reader, p[:]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// B32 returns k as the *[32]byte type that's used by the
|
||||
// golang.org/x/crypto packages. This allocates; it might
|
||||
// not be appropriate for performance-sensitive paths.
|
||||
|
Reference in New Issue
Block a user