From a9e9c4acfa90fc15a8a4b6b5ea6e1c2814ce940e Mon Sep 17 00:00:00 2001 From: sarthurdev <965089+sarthurdev@users.noreply.github.com> Date: Wed, 21 Jul 2021 14:36:48 +0200 Subject: pki: openvpn: T3642: Migrate OpenVPN to PKI and refactor --- python/vyos/template.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'python/vyos/template.py') diff --git a/python/vyos/template.py b/python/vyos/template.py index 0d2bd39e7..6902d3720 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -439,3 +439,32 @@ def get_uuid(interface): """ Get interface IP addresses""" from uuid import uuid1 return uuid1() + +openvpn_translate = { + 'des': 'des-cbc', + '3des': 'des-ede3-cbc', + 'bf128': 'bf-cbc', + 'bf256': 'bf-cbc', + 'aes128gcm': 'aes-128-gcm', + 'aes128': 'aes-128-cbc', + 'aes192gcm': 'aes-192-gcm', + 'aes192': 'aes-192-cbc', + 'aes256gcm': 'aes-256-gcm', + 'aes256': 'aes-256-cbc' +} + +@register_filter('openvpn_cipher') +def get_openvpn_cipher(cipher): + if cipher in openvpn_translate: + return openvpn_translate[cipher].upper() + return cipher.upper() + +@register_filter('openvpn_ncp_ciphers') +def get_openvpn_ncp_ciphers(ciphers): + out = [] + for cipher in ciphers: + if cipher in openvpn_translate: + out.append(openvpn_translate[cipher]) + else: + out.append(cipher) + return ':'.join(out).upper() -- cgit v1.2.3