aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/embeddable-dll-service/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'embeddable-dll-service/main.go')
-rw-r--r--embeddable-dll-service/main.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/embeddable-dll-service/main.go b/embeddable-dll-service/main.go
index a8ce7c10..edf72fba 100644
--- a/embeddable-dll-service/main.go
+++ b/embeddable-dll-service/main.go
@@ -7,10 +7,16 @@ package main
import (
"C"
+
+ "golang.org/x/crypto/curve25519"
+
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/tunnel"
+
+ "crypto/rand"
"log"
"path/filepath"
+ "unsafe"
)
//export WireGuardTunnelService
@@ -24,4 +30,18 @@ func WireGuardTunnelService(confFile string) bool {
return err == nil
}
+//export WireGuardGenerateKeypair
+func WireGuardGenerateKeypair(publicKey *byte, privateKey *byte) {
+ publicKeyArray := (*[32]byte)(unsafe.Pointer(publicKey))
+ privateKeyArray := (*[32]byte)(unsafe.Pointer(privateKey))
+ n, err := rand.Read(privateKeyArray[:])
+ if err != nil || n != len(privateKeyArray) {
+ panic("Unable to generate random bytes")
+ }
+ privateKeyArray[0] &= 248
+ privateKeyArray[31] = (privateKeyArray[31] & 127) | 64
+
+ curve25519.ScalarBaseMult(publicKeyArray, privateKeyArray)
+}
+
func main() {}