Cloak/cmd/ck-server/keygen.go

21 lines
430 B
Go
Raw Normal View History

2018-12-17 22:12:38 +00:00
package main
import (
"crypto/rand"
"github.com/cbeuw/Cloak/internal/ecdh"
2020-02-01 23:46:46 +00:00
"github.com/cbeuw/Cloak/internal/util"
2018-12-17 22:12:38 +00:00
)
func generateUID() string {
2019-06-16 01:08:51 +00:00
UID := make([]byte, 16)
2020-02-01 23:46:46 +00:00
util.CryptoRandRead(UID)
2019-08-02 14:45:33 +00:00
return b64(UID)
2018-12-17 22:12:38 +00:00
}
func generateKeyPair() (string, string) {
staticPv, staticPub, _ := ecdh.GenerateKey(rand.Reader)
marshPub := ecdh.Marshal(staticPub)
2018-12-17 22:12:38 +00:00
marshPv := staticPv.(*[32]byte)[:]
2019-08-02 14:45:33 +00:00
return b64(marshPub), b64(marshPv)
2018-12-17 22:12:38 +00:00
}