aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 20:33:51 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 20:33:51 +0100
commitbebe9a8b1194fa73922bdfbadc845623f8f9fb35 (patch)
tree14faa93d123ab92f2af5c143b1f13fe8176fb487 /ui
parentconf: validate tunnel name (diff)
downloadwireguard-windows-bebe9a8b1194fa73922bdfbadc845623f8f9fb35.tar.xz
wireguard-windows-bebe9a8b1194fa73922bdfbadc845623f8f9fb35.zip
conf: expose base64 key parsing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/ui.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/ui/ui.go b/ui/ui.go
index da4d12cf..2abd6de0 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -6,11 +6,9 @@
package ui
import (
- "encoding/base64"
"fmt"
"github.com/lxn/walk"
"github.com/lxn/win"
- "golang.org/x/crypto/curve25519"
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/service"
"golang.zx2c4.com/wireguard/windows/ui/syntax"
@@ -57,25 +55,9 @@ func RunUI() {
return
}
lastPrivate = privateKey
- key := func() string {
- if privateKey == "" {
- return ""
- }
- decoded, err := base64.StdEncoding.DecodeString(privateKey)
- if err != nil {
- return ""
- }
- if len(decoded) != 32 {
- return ""
- }
- var p [32]byte
- var s [32]byte
- copy(s[:], decoded[:32])
- curve25519.ScalarBaseMult(&p, &s)
- return base64.StdEncoding.EncodeToString(p[:])
- }()
- if key != "" {
- tl.SetText("Public key: " + key)
+ key, err := conf.NewPrivateKeyFromString(privateKey)
+ if err == nil {
+ tl.SetText("Public key: " + key.Public().String())
} else {
tl.SetText("Public key: (unknown)")
}