mirror of
https://github.com/cbeuw/Cloak.git
synced 2024-11-01 21:40:27 +00:00
22 lines
543 B
Go
22 lines
543 B
Go
package main
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
"github.com/cbeuw/Cloak/internal/common"
|
|
"github.com/cbeuw/Cloak/internal/ecdh"
|
|
)
|
|
|
|
func generateUID() string {
|
|
UID := make([]byte, 16)
|
|
common.CryptoRandRead(UID)
|
|
return base64.StdEncoding.EncodeToString(UID)
|
|
}
|
|
|
|
func generateKeyPair() (string, string) {
|
|
staticPv, staticPub, _ := ecdh.GenerateKey(rand.Reader)
|
|
marshPub := ecdh.Marshal(staticPub)
|
|
marshPv := staticPv.(*[32]byte)[:]
|
|
return base64.StdEncoding.EncodeToString(marshPub), base64.StdEncoding.EncodeToString(marshPv)
|
|
}
|