From 5b158d2d9723c9d014c5b608e522f0cd7a684cee Mon Sep 17 00:00:00 2001 From: Matt Dunwoodie Date: Sun, 19 May 2019 16:08:29 +1000 Subject: Add retrieval of private key from device Before mdlayher notified me that wg(8) actually can view the device private key (with `WG_HIDE_KEYS=never wg`), I did not have a need for it. It was straight forward to add in kernel. This functionality will also be implemented in wgctrl-go. --- src/tools/ipc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/ipc.c b/src/tools/ipc.c index f54ca90..fb9cc90 100644 --- a/src/tools/ipc.c +++ b/src/tools/ipc.c @@ -1015,6 +1015,11 @@ static int openbsd_get_device(struct wgdevice **device, const char *interface) dev->flags |= WGDEVICE_HAS_PUBLIC_KEY; } + if (!IS_NULL_KEY(wgs.gs_privkey)) { + memcpy(dev->private_key, wgs.gs_privkey, WG_KEY_SIZE); + dev->flags |= WGDEVICE_HAS_PRIVATE_KEY; + } + dev->first_peer = dev->last_peer = NULL; for (size_t i = 0; i < wgs.gs_num_peers; i++) { -- cgit v1.2.3-59-g8ed1b