diff options
author | Daniil Baturin <daniil@vyos.io> | 2023-12-09 16:31:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-09 16:31:44 +0000 |
commit | 48e512ffec259d8753a8fd5a0a6a961f332ab8c1 (patch) | |
tree | 43a1213ffb6d4ed5550aaf6397d51752c7082a13 /python | |
parent | 5d42ac22b2dd152327ed7c12d13faf01268dd363 (diff) | |
parent | 2c1c3613567e23e14ce89bbf872e6e9dee16badb (diff) | |
download | vyos-1x-48e512ffec259d8753a8fd5a0a6a961f332ab8c1.tar.gz vyos-1x-48e512ffec259d8753a8fd5a0a6a961f332ab8c1.zip |
Merge pull request #2540 from aapostoliuk/T5413-equuleus
wireguard: T5413: Blocked adding the peer with the router's public key
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/validate.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/python/vyos/validate.py b/python/vyos/validate.py index 83862b722..a28cbc3d4 100644 --- a/python/vyos/validate.py +++ b/python/vyos/validate.py @@ -1,4 +1,4 @@ -# Copyright 2018-2021 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2018-2023 VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -297,3 +297,20 @@ def has_vrf_configured(conf, intf): conf.set_level(old_level) return ret + +def is_wireguard_key_pair(private_key: str, public_key:str) -> bool: + """ + Checks if public/private keys are keypair + :param private_key: Wireguard private key + :type private_key: str + :param public_key: Wireguard public key + :type public_key: str + :return: If public/private keys are keypair returns True else False + :rtype: bool + """ + from vyos.util import cmd + gen_public_key = cmd('wg pubkey', input=private_key) + if gen_public_key == public_key: + return True + else: + return False
\ No newline at end of file |