Cloak/cmd/ck-server/keygen.go
2019-08-02 15:45:33 +01:00

20 lines
380 B
Go

package main
import (
"crypto/rand"
"github.com/cbeuw/Cloak/internal/ecdh"
)
func generateUID() string {
UID := make([]byte, 16)
rand.Read(UID)
return b64(UID)
}
func generateKeyPair() (string, string) {
staticPv, staticPub, _ := ecdh.GenerateKey(rand.Reader)
marshPub := ecdh.Marshal(staticPub)
marshPv := staticPv.(*[32]byte)[:]
return b64(marshPub), b64(marshPv)
}