|
47 | 47 | esp_group = 'MyESPGroup' |
48 | 48 | ike_group = 'MyIKEGroup' |
49 | 49 | secret = 'MYSECRETKEY' |
| 50 | +ppk_secret_hex = '55c2ebca1bada7ac0e4e1390a8dbb563cefea0c7bd59f4f2c86a627f5927fb90' |
50 | 51 | PROCESS_NAME = 'charon-systemd' |
51 | 52 | regex_uuid4 = '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}' |
52 | 53 |
|
@@ -668,6 +669,104 @@ def test_site_to_site_vti_ts_afi(self): |
668 | 669 | for line in swanctl_conf_lines: |
669 | 670 | self.assertIn(line, swanctl_conf) |
670 | 671 |
|
| 672 | + def test_site_to_site_nist_800_77_cnsa_1_with_ppk(self): |
| 673 | + # Setup IKE group |
| 674 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'key-exchange', 'ikev2']) |
| 675 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'lifetime', '86400']) |
| 676 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'proposal', '10', 'dh-group', '20']) |
| 677 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'proposal', '10', 'encryption', 'aes256gcm128']) |
| 678 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'proposal', '10', 'hash', 'sha384']) |
| 679 | + self.cli_set(base_path + ['ike-group', 'cnsa1-ike', 'proposal', '10', 'prf', 'prfsha384']) |
| 680 | + |
| 681 | + # Setup ESP group |
| 682 | + self.cli_set(base_path + ['esp-group', 'cnsa1-esp', 'lifetime', '28800']) |
| 683 | + self.cli_set(base_path + ['esp-group', 'cnsa1-esp', 'mode', 'tunnel']) |
| 684 | + self.cli_set(base_path + ['esp-group', 'cnsa1-esp', 'pfs', 'dh-group20']) |
| 685 | + self.cli_set(base_path + ['esp-group', 'cnsa1-esp', 'proposal', '10', 'encryption', 'aes256gcm128']) |
| 686 | + self.cli_set(base_path + ['esp-group', 'cnsa1-esp', 'proposal', '10', 'hash', 'sha384']) |
| 687 | + |
| 688 | + local_address = '192.0.2.10' |
| 689 | + |
| 690 | + # vpn ipsec auth psk <tag> id <x.x.x.x> |
| 691 | + self.cli_set(base_path + ['authentication', 'psk', connection_name, 'id', local_id]) |
| 692 | + self.cli_set(base_path + ['authentication', 'psk', connection_name, 'id', remote_id]) |
| 693 | + self.cli_set(base_path + ['authentication', 'psk', connection_name, 'id', local_address]) |
| 694 | + self.cli_set(base_path + ['authentication', 'psk', connection_name, 'id', peer_ip]) |
| 695 | + self.cli_set(base_path + ['authentication', 'psk', connection_name, 'secret', secret]) |
| 696 | + |
| 697 | + # vpn ipsec auth ppk <tag> id <name> |
| 698 | + self.cli_set(base_path + ['authentication', 'ppk', connection_name, 'id', 'ppk-test']) |
| 699 | + self.cli_set(base_path + ['authentication', 'ppk', connection_name, 'secret', ppk_secret_hex]) |
| 700 | + self.cli_set(base_path + ['authentication', 'ppk', connection_name, 'secret-type', 'hex']) |
| 701 | + |
| 702 | + # Site to site |
| 703 | + peer_base_path = base_path + ['site-to-site', 'peer', connection_name] |
| 704 | + |
| 705 | + self.cli_set(peer_base_path + ['authentication', 'mode', 'pre-shared-secret']) |
| 706 | + |
| 707 | + # Set childless IKE_INIT to prefer |
| 708 | + self.cli_set(peer_base_path + ['childless', 'prefer']) |
| 709 | + |
| 710 | + self.cli_set(peer_base_path + ['default-esp-group', 'cnsa1-esp']) |
| 711 | + self.cli_set(peer_base_path + ['ike-group', 'cnsa1-ike']) |
| 712 | + self.cli_set(peer_base_path + ['local-address', local_address]) |
| 713 | + |
| 714 | + # Require use of valid PPK |
| 715 | + self.cli_set(peer_base_path + ['ppk', 'id', 'ppk-test']) |
| 716 | + self.cli_set(peer_base_path + ['ppk', 'required']) |
| 717 | + |
| 718 | + self.cli_set(peer_base_path + ['remote-address', peer_ip]) |
| 719 | + self.cli_set(peer_base_path + ['tunnel', '1', 'local', 'prefix', '172.16.10.0/24']) |
| 720 | + self.cli_set(peer_base_path + ['tunnel', '1', 'remote', 'prefix', '172.17.10.0/24']) |
| 721 | + |
| 722 | + self.cli_commit() |
| 723 | + |
| 724 | + # Verify strongSwan configuration |
| 725 | + swanctl_conf = read_file(swanctl_file) |
| 726 | + swanctl_conf_lines = [ |
| 727 | + f'ppk_id = ppk-test', |
| 728 | + f'ppk_required = yes', |
| 729 | + f'childless = prefer', |
| 730 | + f'version = 2', |
| 731 | + f'auth = psk', |
| 732 | + f'rekey_time = 86400s', |
| 733 | + f'proposals = aes256gcm128-sha384-prfsha384-ecp384', |
| 734 | + f'esp_proposals = aes256gcm128-sha384-ecp384', |
| 735 | + f'life_time = 28800s', # default value |
| 736 | + f'local_addrs = {local_address} # dhcp:no', |
| 737 | + f'remote_addrs = {peer_ip}', |
| 738 | + f'mode = tunnel', |
| 739 | + f'{connection_name}-tunnel-1', |
| 740 | + f'local_ts = 172.16.10.0/24', |
| 741 | + f'remote_ts = 172.17.10.0/24', |
| 742 | + f'mode = tunnel', |
| 743 | + f'replay_window = 32', |
| 744 | + ] |
| 745 | + for line in swanctl_conf_lines: |
| 746 | + self.assertIn(line, swanctl_conf) |
| 747 | + |
| 748 | + # if dpd is not specified it should not be enabled (see T6599) |
| 749 | + swanctl_unexpected_lines = [ |
| 750 | + 'dpd_timeout', |
| 751 | + 'dpd_delay', |
| 752 | + ] |
| 753 | + |
| 754 | + for unexpected_line in swanctl_unexpected_lines: |
| 755 | + self.assertNotIn(unexpected_line, swanctl_conf) |
| 756 | + |
| 757 | + swanctl_secrets_lines = [ |
| 758 | + f'id-{regex_uuid4} = "{local_id}"', |
| 759 | + f'id-{regex_uuid4} = "{remote_id}"', |
| 760 | + f'id-{regex_uuid4} = "{local_address}"', |
| 761 | + f'id-{regex_uuid4} = "{peer_ip}"', |
| 762 | + f'secret = "{secret}"', |
| 763 | + f'ppk-{connection_name}', |
| 764 | + f'id-{regex_uuid4} = "ppk-test"', |
| 765 | + f'secret = 0x{ppk_secret_hex}' |
| 766 | + ] |
| 767 | + for line in swanctl_secrets_lines: |
| 768 | + self.assertRegex(swanctl_conf, fr'{line}') |
| 769 | + |
671 | 770 |
|
672 | 771 | def test_dmvpn(self): |
673 | 772 | ike_lifetime = '3600' |
|
0 commit comments