Skip to content

Commit 42f33f0

Browse files
authored
Merge pull request #4389 from natali-rs1985/T7242
ipsec: T7242: Add a check for encryption algorithms that do not work with VPP
2 parents 4d5783a + 159fcbf commit 42f33f0

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/conf_mode/vpn_ipsec.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def get_config(config=None):
156156
_, vti = get_interface_dict(conf, ['interfaces', 'vti'], vti_interface)
157157
ipsec['vti_interface_dicts'][vti_interface] = vti
158158

159+
ipsec['vpp_ipsec_exists'] = conf.exists(['vpp', 'settings', 'ipsec'])
160+
159161
return ipsec
160162

161163
def get_dhcp_address(iface):
@@ -484,6 +486,17 @@ def verify(ipsec):
484486
else:
485487
raise ConfigError(f"Missing ike-group on site-to-site peer {peer}")
486488

489+
# verify encryption algorithm compatibility for IKE with VPP
490+
if ipsec['vpp_ipsec_exists']:
491+
ike_group = ipsec['ike_group'][peer_conf['ike_group']]
492+
for proposal, proposal_config in ike_group.get('proposal', {}).items():
493+
algs = ['gmac', 'serpent', 'twofish']
494+
if any(alg in proposal_config['encryption'] for alg in algs):
495+
raise ConfigError(
496+
f'Encryption algorithm {proposal_config["encryption"]} cannot be used '
497+
f'for IKE proposal {proposal} for site-to-site peer {peer} with VPP'
498+
)
499+
487500
if 'authentication' not in peer_conf or 'mode' not in peer_conf['authentication']:
488501
raise ConfigError(f"Missing authentication on site-to-site peer {peer}")
489502

@@ -562,7 +575,7 @@ def verify(ipsec):
562575

563576
esp_group_name = tunnel_conf['esp_group'] if 'esp_group' in tunnel_conf else peer_conf['default_esp_group']
564577

565-
if esp_group_name not in ipsec['esp_group']:
578+
if esp_group_name not in ipsec.get('esp_group'):
566579
raise ConfigError(f"Invalid esp-group on tunnel {tunnel} for site-to-site peer {peer}")
567580

568581
esp_group = ipsec['esp_group'][esp_group_name]
@@ -574,6 +587,18 @@ def verify(ipsec):
574587
if ('local' in tunnel_conf and 'prefix' in tunnel_conf['local']) or ('remote' in tunnel_conf and 'prefix' in tunnel_conf['remote']):
575588
raise ConfigError(f"Local/remote prefix cannot be used with ESP transport mode on tunnel {tunnel} for site-to-site peer {peer}")
576589

590+
# verify ESP encryption algorithm compatibility with VPP
591+
# because Marvel plugin for VPP doesn't support all algorithms that Strongswan does
592+
if ipsec['vpp_ipsec_exists']:
593+
for proposal, proposal_config in esp_group.get('proposal', {}).items():
594+
algs = ['aes128', 'aes192', 'aes256', 'aes128gcm128', 'aes192gcm128', 'aes256gcm128']
595+
if proposal_config['encryption'] not in algs:
596+
raise ConfigError(
597+
f'Encryption algorithm {proposal_config["encryption"]} cannot be used '
598+
f'for ESP proposal {proposal} on tunnel {tunnel} for site-to-site peer {peer} with VPP'
599+
)
600+
601+
577602
def cleanup_pki_files():
578603
for path in [CERT_PATH, CA_PATH, CRL_PATH, KEY_PATH, PUBKEY_PATH]:
579604
if not os.path.exists(path):

0 commit comments

Comments
 (0)