From 316d7db89d69209dc13a135cdca971e88bb64566 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sun, 10 Oct 2021 14:50:59 +0200 Subject: [PATCH] wip --- libs/wireguard.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/wireguard.py b/libs/wireguard.py index 9f63e61..283f561 100644 --- a/libs/wireguard.py +++ b/libs/wireguard.py @@ -1,12 +1,16 @@ import base64 from nacl.public import PrivateKey from nacl.encoding import Base64Encoder +from functools import cache +@cache def privkey(id): return str(repo.vault.random_bytes_as_base64_for(f"wireguard privkey {id}")) +@cache def pubkey(id): return PrivateKey(base64.b64decode(privkey(id))).public_key.encode(encoder=Base64Encoder).decode('ascii') +@cache def psk(id1, id2): return repo.vault.random_bytes_as_base64_for(f"wireguard psk {' '.join(sorted([id1, id2]))}")