diff options
author | Christian Breunig <christian@breunig.cc> | 2023-08-02 12:22:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 12:22:26 +0200 |
commit | ea30c0307996ec301474820bbcbf90d5eda7fda4 (patch) | |
tree | fcc31bb6f2437e8e7e8e1428166f08a3b789e4ee /python/vyos | |
parent | ad57339e9ce655823e1f8e7ad25dc5560359b8da (diff) | |
parent | fee5669514492e9543b34b3e77e08d1552dee386 (diff) | |
download | vyos-1x-ea30c0307996ec301474820bbcbf90d5eda7fda4.tar.gz vyos-1x-ea30c0307996ec301474820bbcbf90d5eda7fda4.zip |
Merge pull request #2122 from aapostoliuk/T5413
wireguard: T5413: Blocked adding the peer with the router's public key
Diffstat (limited to 'python/vyos')
-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 567f4c972..b149b258f 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 @@ -302,3 +302,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.utils.process import cmd + gen_public_key = cmd('wg pubkey', input=private_key) + if gen_public_key == public_key: + return True + else: + return False |