You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cloak/cmd/ck-server/keygen.go

24 lines
465 B
Go

package main
import (
"crypto/rand"
"encoding/base64"
ecdh "github.com/cbeuw/go-ecdh"
)
var b64 = base64.StdEncoding.EncodeToString
func generateUID() string {
UID := make([]byte, 32)
rand.Read(UID)
return b64(UID)
}
func generateKeyPair() (string, string) {
ec := ecdh.NewCurve25519ECDH()
staticPv, staticPub, _ := ec.GenerateKey(rand.Reader)
marshPub := ec.Marshal(staticPub)
marshPv := staticPv.(*[32]byte)[:]
return b64(marshPub), b64(marshPv)
}