]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
testing: Add ikev2/rw-cert-multi-ke scenario
authorTobias Brunner <tobias@strongswan.org>
Thu, 6 Jun 2024 15:48:38 +0000 (17:48 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 7 Aug 2024 14:20:19 +0000 (16:20 +0200)
testing/tests/ikev2/rw-cert-multi-ke/description.txt [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/evaltest.dat [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/strongswan.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/strongswan.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/strongswan.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/posttest.dat [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/pretest.dat [new file with mode: 0755]
testing/tests/ikev2/rw-cert-multi-ke/test.conf [new file with mode: 0755]

diff --git a/testing/tests/ikev2/rw-cert-multi-ke/description.txt b/testing/tests/ikev2/rw-cert-multi-ke/description.txt
new file mode 100755 (executable)
index 0000000..3532dfe
--- /dev/null
@@ -0,0 +1,12 @@
+The roadwarriors <b>carol</b> and <b>dave</b> set up a connection each
+to gateway <b>moon</b>. The authentication is based on <b>X.509 certificates</b>.
+To test multiple key exchanges (RFC 9370) and IKE_INTERMEDIATE exchanges (RFC 9242),
+<b>carol</b> proposes MODP_2048 for the key exchange and CURVE_25519 for the
+additional key exchange whereas <b>dave</b> proposes MODP_3072 and ECP_384,
+respectively. The IKE and ESP SAs are then rekeyed using the same proposals.
+One set of SAs is rekeyed from <b>carol</b> and another from <b>moon</b>.
+<p/>
+Upon the successful establishment of the IPsec tunnels, the updown script
+automatically inserts iptables-based firewall rules that let pass the tunneled traffic.
+In order to test both tunnel and firewall, both <b>carol</b> and <b>dave</b> ping
+the client <b>alice</b> behind the gateway <b>moon</b>.
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/evaltest.dat b/testing/tests/ikev2/rw-cert-multi-ke/evaltest.dat
new file mode 100755 (executable)
index 0000000..5fdda3e
--- /dev/null
@@ -0,0 +1,32 @@
+carol::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=192.168.0.100 local-port=4500 local-id=carol@strongswan.org remote-host=192.168.0.1 remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_2048 ake1=CURVE_25519.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[192.168.0.100/32] remote-ts=\[10.1.0.0/16]::YES
+dave:: swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=192.168.0.200 local-port=4500 local-id=dave@strongswan.org remote-host=192.168.0.1 remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_3072 ake1=ECP_384.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[192.168.0.200/32] remote-ts=\[10.1.0.0/16]::YES
+moon:: swanctl --list-sas --ike-id 1 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.100 remote-port=4500 remote-id=carol@strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_2048 ake1=CURVE_25519.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.100/32]::YES
+moon:: swanctl --list-sas --ike-id 2 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.200 remote-port=4500 remote-id=dave@strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_3072 ake1=ECP_384.*child-sas.*net.*reqid=2 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.200/32]::YES
+alice::ping -c 1 192.168.0.100::64 bytes from 192.168.0.100: icmp_.eq=1::YES
+alice::ping -c 1 192.168.0.200::64 bytes from 192.168.0.200: icmp_.eq=1::YES
+# rekey with carol from moon (original responder), first the IKE_SA then the CHILD_SA using the new IKE_SA
+moon::swanctl --rekey --ike-id 1
+moon::sleep 1
+alice::ping -c 1 192.168.0.100::64 bytes from 192.168.0.100: icmp_.eq=1::YES
+moon::swanctl --rekey --child-id 1
+moon::sleep 1
+alice::ping -c 1 192.168.0.100::64 bytes from 192.168.0.100: icmp_.eq=1::YES
+# rekey from dave (original initiator)
+dave::swanctl --rekey --ike home
+dave::sleep 1
+alice::ping -c 1 192.168.0.200::64 bytes from 192.168.0.200: icmp_.eq=1::YES
+dave::swanctl --rekey --child home
+dave::sleep 1
+alice::ping -c 1 192.168.0.200::64 bytes from 192.168.0.200: icmp_.eq=1::YES
+moon::tcpdump::IP moon.strongswan.org > carol.strongswan.org: ESP::YES
+moon::tcpdump::IP carol.strongswan.org > moon.strongswan.org: ESP::YES
+moon::tcpdump::IP moon.strongswan.org > dave.strongswan.org: ESP::YES
+moon::tcpdump::IP dave.strongswan.org > moon.strongswan.org: ESP::YES
+moon:: swanctl --list-sas --ike-id 3 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.100 remote-port=4500 remote-id=carol@strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_2048 ake1=CURVE_25519.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128 dh-group=MODP_2048 ake1=CURVE_25519.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.100/32]::YES
+moon:: swanctl --list-sas --ike-id 4 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.200 remote-port=4500 remote-id=dave@strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_3072 ake1=ECP_384.*child-sas.*net.*reqid=2 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128 dh-group=MODP_3072 ake1=ECP_384.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.200/32]::YES
+# from the rekeyings with carol
+moon::cat /var/log/daemon.log::parsed IKE_INTERMEDIATE request 1 \[ KE \]::2
+moon::cat /var/log/daemon.log::parsed IKE_FOLLOWUP_KE response 1 \[ KE \]::2
+# from the rekeyings with dave
+moon::cat /var/log/daemon.log::parsed IKE_FOLLOWUP_KE request 4 \[ KE N(ADD_KE) \]::1
+moon::cat /var/log/daemon.log::parsed IKE_FOLLOWUP_KE request 1 \[ KE N(ADD_KE) \]::1
\ No newline at end of file
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/strongswan.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/strongswan.conf
new file mode 100755 (executable)
index 0000000..83612c9
--- /dev/null
@@ -0,0 +1,9 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce openssl pem pkcs1 x509 revocation constraints curl kernel-netlink socket-default updown vici
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/carol/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..2c0d964
--- /dev/null
@@ -0,0 +1,35 @@
+connections {
+
+   home {
+      local_addrs  = 192.168.0.100
+      remote_addrs = 192.168.0.1
+
+      local {
+         auth = pubkey
+         certs = carolCert.pem
+         id = carol@strongswan.org
+      }
+      remote {
+         auth = pubkey
+         id = moon.strongswan.org
+      }
+      children {
+         home {
+            remote_ts = 10.1.0.0/16
+
+            updown = /usr/local/libexec/ipsec/_updown iptables
+            esp_proposals = aes128gcm128-modp2048-ke1_x25519
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-modp2048-ke1_x25519
+   }
+}
+
+secrets {
+
+   rsa-carol {
+      file = carolKey.pem
+      secret = "nH5ZQEWtku0RJEZ6"
+   }
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/strongswan.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/strongswan.conf
new file mode 100755 (executable)
index 0000000..83612c9
--- /dev/null
@@ -0,0 +1,9 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce openssl pem pkcs1 x509 revocation constraints curl kernel-netlink socket-default updown vici
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/dave/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..695d707
--- /dev/null
@@ -0,0 +1,27 @@
+connections {
+
+   home {
+      local_addrs  = 192.168.0.200
+      remote_addrs = 192.168.0.1
+
+      local {
+         auth = pubkey
+         certs = daveCert.pem
+         id = dave@strongswan.org
+      }
+      remote {
+         auth = pubkey
+         id = moon.strongswan.org
+      }
+      children {
+         home {
+            remote_ts = 10.1.0.0/16
+
+            updown = /usr/local/libexec/ipsec/_updown iptables
+            esp_proposals = aes128gcm128-modp3072-ke1_ecp384
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-modp3072-ke1_ecp384
+   }
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/strongswan.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/strongswan.conf
new file mode 100755 (executable)
index 0000000..83612c9
--- /dev/null
@@ -0,0 +1,9 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce openssl pem pkcs1 x509 revocation constraints curl kernel-netlink socket-default updown vici
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-cert-multi-ke/hosts/moon/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..bbd05a4
--- /dev/null
@@ -0,0 +1,25 @@
+connections {
+
+   rw {
+      local_addrs  = 192.168.0.1
+
+      local {
+         auth = pubkey
+         certs = moonCert.pem
+         id = moon.strongswan.org
+      }
+      remote {
+         auth = pubkey
+      }
+      children {
+         net {
+            local_ts  = 10.1.0.0/16
+
+            updown = /usr/local/libexec/ipsec/_updown iptables
+            esp_proposals = aes128gcm128-modp2048-modp3072-ke1_x25519-ke1_ecp384
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-modp2048-modp3072-ke1_x25519-ke1_ecp384
+   }
+}
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/posttest.dat b/testing/tests/ikev2/rw-cert-multi-ke/posttest.dat
new file mode 100755 (executable)
index 0000000..eb21008
--- /dev/null
@@ -0,0 +1,8 @@
+carol::swanctl --terminate --ike home
+dave::swanctl --terminate --ike home
+carol::systemctl stop strongswan
+dave::systemctl stop strongswan
+moon::systemctl stop strongswan
+moon::iptables-restore < /etc/iptables.flush
+carol::iptables-restore < /etc/iptables.flush
+dave::iptables-restore < /etc/iptables.flush
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/pretest.dat b/testing/tests/ikev2/rw-cert-multi-ke/pretest.dat
new file mode 100755 (executable)
index 0000000..3d37a86
--- /dev/null
@@ -0,0 +1,11 @@
+moon::iptables-restore < /etc/iptables.rules
+carol::iptables-restore < /etc/iptables.rules
+dave::iptables-restore < /etc/iptables.rules
+moon::systemctl start strongswan
+carol::systemctl start strongswan
+dave::systemctl start strongswan
+moon::expect-connection rw
+carol::expect-connection home
+carol::swanctl --initiate --child home 2> /dev/null
+dave::expect-connection home
+dave::swanctl --initiate --child home 2> /dev/null
diff --git a/testing/tests/ikev2/rw-cert-multi-ke/test.conf b/testing/tests/ikev2/rw-cert-multi-ke/test.conf
new file mode 100755 (executable)
index 0000000..1227b9d
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# This configuration file provides information on the
+# guest instances used for this test
+
+# All guest instances that are required for this test
+#
+VIRTHOSTS="alice moon carol winnetou dave"
+
+# Corresponding block diagram
+#
+DIAGRAM="a-m-c-w-d.png"
+
+# Guest instances on which tcpdump is to be started
+#
+TCPDUMPHOSTS="moon"
+
+# Guest instances on which IPsec is started
+# Used for IPsec logging purposes
+#
+IPSECHOSTS="moon carol dave"
+
+# charon controlled by swanctl
+#
+SWANCTL=1