From 65566c37caec653bd91f488083f95387e9fbc1f3 Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Thu, 18 Dec 2014 11:49:05 +0100 Subject: [PATCH] testing: Add tkm xfrmproxy-expire test This test asserts that the handling of XFRM expire messages from the kernel are handled correctly by the xfrm-proxy and the Esa Event Service (EES) in charon-tkm. --- .../tkm/xfrmproxy-expire/description.txt | 6 +++++ .../tests/tkm/xfrmproxy-expire/evaltest.dat | 22 ++++++++++++++++++ .../hosts/moon/etc/strongswan.conf | 8 +++++++ .../hosts/moon/etc/tkm/moonKey.der | Bin 0 -> 1191 bytes .../hosts/moon/etc/tkm/strongswanCert.der | Bin 0 -> 956 bytes .../hosts/moon/etc/tkm/tkm.conf | 21 +++++++++++++++++ .../xfrmproxy-expire/hosts/sun/etc/ipsec.conf | 21 +++++++++++++++++ .../hosts/sun/etc/strongswan.conf | 5 ++++ .../tests/tkm/xfrmproxy-expire/posttest.dat | 5 ++++ .../tests/tkm/xfrmproxy-expire/pretest.dat | 12 ++++++++++ testing/tests/tkm/xfrmproxy-expire/test.conf | 21 +++++++++++++++++ 11 files changed, 121 insertions(+) create mode 100644 testing/tests/tkm/xfrmproxy-expire/description.txt create mode 100644 testing/tests/tkm/xfrmproxy-expire/evaltest.dat create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/strongswan.conf create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/moonKey.der create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/strongswanCert.der create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/tkm.conf create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/ipsec.conf create mode 100644 testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/strongswan.conf create mode 100644 testing/tests/tkm/xfrmproxy-expire/posttest.dat create mode 100644 testing/tests/tkm/xfrmproxy-expire/pretest.dat create mode 100644 testing/tests/tkm/xfrmproxy-expire/test.conf diff --git a/testing/tests/tkm/xfrmproxy-expire/description.txt b/testing/tests/tkm/xfrmproxy-expire/description.txt new file mode 100644 index 0000000000..9578cd8f3c --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/description.txt @@ -0,0 +1,6 @@ +A transport connection between the hosts moon and sun is set up. +The host moon starts the Trusted Key Manager (TKM) and the Ada XFRM +proxy, which relays XFRM kernel messages to charon. The authentication is based +on X.509 certificates. The connection is initiated by a ping from moon +to sun. The test asserts that XFRM expire messages from the kernel are +handled correctly. diff --git a/testing/tests/tkm/xfrmproxy-expire/evaltest.dat b/testing/tests/tkm/xfrmproxy-expire/evaltest.dat new file mode 100644 index 0000000000..96b486a075 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/evaltest.dat @@ -0,0 +1,22 @@ +moon::ipsec stroke status 2> /dev/null::conn1.*ESTABLISHED.*moon.strongswan.org.*sun.strongswan.org::YES +sun::ipsec status 2> /dev/null::host-host.*ESTABLISHED.*sun.strongswan.org.*moon.strongswan.org::YES +moon::ipsec stroke status 2> /dev/null::conn1.*INSTALLED, TRANSPORT::YES +sun::ipsec status 2> /dev/null::host-host.*INSTALLED, TRANSPORT::YES +moon::ping -c 1 PH_IP_SUN::64 bytes from PH_IP_SUN: icmp_req=1::YES +sun::tcpdump::IP moon.strongswan.org > sun.strongswan.org: ESP::YES +sun::tcpdump::IP sun.strongswan.org > moon.strongswan.org: ESP::YES +moon::cat /var/log/daemon.log::ees: acquire received for reqid 1::YES +moon::cat /var/log/daemon.log::ees: expire received for reqid 1, spi.*, dst 192.168.0.2::YES +moon::cat /var/log/daemon.log::creating rekey job for CHILD_SA ESP/0x.*/192.168.0.2::YES +moon::cat /var/log/daemon.log::deleting child SA (esa: 1, spi:.*)::YES +moon::cat /tmp/tkm.log::RSA private key '/etc/tkm/moonKey.der' loaded::YES +moon::cat /tmp/tkm.log::Adding policy \[ 1, 192.168.0.1 <-> 192.168.0.2 \]::YES +moon::cat /tmp/tkm.log::Checked CA certificate of CC context 1::YES +moon::cat /tmp/tkm.log::Authentication of ISA context 1 successful::YES +moon::cat /tmp/tkm.log::Creating first new ESA context with ID 1 (Isa 1, Sp 1, Ea 1, Initiator TRUE, spi_loc.*, spi_rem.*)::YES +moon::cat /tmp/tkm.log::Creating ESA context with ID 2 (Isa 1, Sp 1, Ea 1, Dh_Id 1, Nc_Loc_Id 1, Initiator TRUE, spi_loc.*, spi_rem.*)::YES +moon::cat /tmp/tkm.log | grep 'Adding SA \[ 1, 192.168.0.1 <-> 192.168.0.2, SPI_in.*, SPI_out.*, soft 2, hard 60 \]' | wc -l::2::YES +moon::cat /tmp/tkm.log::Resetting ESA context 1::YES +moon::cat /tmp/tkm.log::Deleting SA \[ 1, 192.168.0.1 <=> 192.168.0.2, SPI_in.*, SPI_out.* \]::YES +moon::cat /tmp/xfrm_proxy.log::Initiating ESA acquire for reqid 1::YES +moon::cat /tmp/xfrm_proxy.log::Initiating ESA expire (reqid 1, proto 50, SPI.*, hard FALSE)::YES diff --git a/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/strongswan.conf b/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/strongswan.conf new file mode 100644 index 0000000000..cc9d6e0724 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/strongswan.conf @@ -0,0 +1,8 @@ +# /etc/strongswan.conf - strongSwan configuration file + +charon-tkm { + dh_mapping { + 15 = 1 + 16 = 2 + } +} diff --git a/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/moonKey.der b/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/moonKey.der new file mode 100644 index 0000000000000000000000000000000000000000..d3748930a7da99c460214bae2eedf2d58d011de0 GIT binary patch literal 1191 zc-jG{1X%kpf&`-i0RRGm0RaG{dhq;DHNNyXk+g2SP10pz-}d5!ZX^}-fB~=0%k+>hYo3H0fFe-KhVf{#Rk8{q z6eVTP653)g0c{C$p(dV!Z}vWg{?$YG?yB$B*P(tUHAFmNsr5=!aKU zg`u9IZmDf7DZD)e&O{2N17$cW|K+)DR~eg}ckLtl1_t#I7>1?ibCDD1;8$OgE21=@ z0v3oWRN97VV8AV>wXr&QEC7~75yrqLO1I0TV z^mG+CxWmlkKE8dnUOwPZAtS)K0)c@5*hXNw?8$c&NLUo7BP{6)H|m=~Aj!I3F5*>x zHKl7zidc?-c(_(_zq_N=1oCi@9arBXxFcFiBXjh*797I$HWD6_+VL~sd9=_gg>jt! zP?8_lMv`L+s0s2-jAB=ZV-~&uq%Z$&ayAm(qX`X1NR-w_;%S6QF#Q&a048(=0)c@5 z!m?gta=>c?q-s({FjVa=dn#m4bxd3gx75&|JggXf(ChC_`mCu-l7f29xzp;PuK-m> zWKDBevC35FKX7yera3r2!NAOQFZ|Lwe0w8?Lu$aT-+Z>ZL5p!zv9A=*OlMv3_(X|Q zwFoubGfzK}Cy;ASJtxfKV{<;>(A3{KCP)z7P| zFWi{5=Xc&KHp;JLZmi6myO05bk%yoj^aIhm0(Krd$a)yvr3)XN)UWvRWH1toJAEDZ4?<WeaP3qCjNe!i8&xoYjClnj9{Oy<~0Uu)pa zIqlTCe_|Y*k8t zNrNw+8fCkXXBpCzo&!&pII!KwF;kq^9!$Rifq;9R0iy4Uf+(aKSj_7R*y}`}qfqTE z2hbA4Qt3y^#)qk?`JhZ@Ggjtd=&vw0J%&9PEpRyQypSC{c)T7>zjVm_x)d9wYYO&n zp~Mbd@8|6}F2D%MkGG!_o<_^bR}B#j$deD&_@CU}q94bQ)C8aMPyT{%O_DUFVI+`H FH`OpGI1&H= literal 0 Hc-jL100001 diff --git a/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/strongswanCert.der b/testing/tests/tkm/xfrmproxy-expire/hosts/moon/etc/tkm/strongswanCert.der new file mode 100644 index 0000000000000000000000000000000000000000..a5a631f4b5f8b29a990ab4b075e44e0d961c6286 GIT binary patch literal 956 zc-k{)V%}lU#I#@mGZP~d6C;BGFB_*;n@8JsUPeZ4Rt5uCLv903Hs(+kHen`b4?{@< zaS(?~SimPUue3s;xTGjQFFm+CG0#xiKoTUyEG&c&R0zt?FHvxIG>{YLH83%-G&C?Y zFfcTDv^20ZFo$xfWla;K60!#vSs9p{82K51;#^EkjEoHXKgB1#vJK0N*nFbO z^VH`xiRV`)mlylC=x+Y;H*bOR_YJ~&X=(vNhQ)0~b8>5(s(R;(RX?=VzefAhadKI39x5R2?=w-4vf zAAEA&`ChEORYZC6`j=|;!5hV9ZdUU@8WY(0HAACNEN5pk`&8D<6#2#czXR?G`@hwn zZu4HsQbWB>`^eo@(|2zWae6fQh(N)GB9$xq+}EiGzt(>1eel-AV|~XPjwJE(GchwV zFfMM~WYDYi`Q-MsbbgM?RlzV8ikLDI@BX$C0`SQRYvT;fipcx}Q+m&~BpRGu_zA>$UIi(i+P z2P<@Z;@s>$W4Ye-y_v4py;o?~j{RQg#;w^d>F+$o`mh?jcp~Cv%z9 zWL8+2=<&rqzhYxv;%9$uv1GZzDZ!R2@25Q5_nKEl+-<{7?fQ)jJ{&K)f4=s4#&0Jw zCGGReKlU^BJn{VE@$*XRQ|-tP0&+>r=hyOfJ~HL}#bWCt#3a{mw6Au@rnkFprO2kN zl44n(vgloOqgScz^=yO3_gFq3+a{Ry%;<-iZ{T@zgOy=kzLR$<)o5&(%^y1TrdG0k z(Z7IMLUUHW3%Re&cPGczBFtYvHSf=jeNCI*q)e}~%8&an + + moon.strongswan.org + moonCert.pem + + + transport + + 1 + 192.168.0.1 + + + sun.strongswan.org + 192.168.0.2 + + + 2 + 60 + + + diff --git a/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/ipsec.conf b/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/ipsec.conf new file mode 100644 index 0000000000..e52a04f428 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/ipsec.conf @@ -0,0 +1,21 @@ +# /etc/ipsec.conf - strongSwan IPsec configuration file + +config setup + +conn %default + ikelifetime=60m + keylife=20m + rekeymargin=3m + keyingtries=1 + keyexchange=ikev2 + +conn host-host + left=PH_IP_SUN + leftcert=sunCert.pem + leftid=sun.strongswan.org + right=PH_IP_MOON + rightid=moon.strongswan.org + ike=aes256-sha512-modp4096! + esp=aes256-sha512-modp4096! + type=transport + auto=add diff --git a/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/strongswan.conf b/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/strongswan.conf new file mode 100644 index 0000000000..f585edfca2 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/hosts/sun/etc/strongswan.conf @@ -0,0 +1,5 @@ +# /etc/strongswan.conf - strongSwan configuration file + +charon { + load = aes des sha1 sha2 md5 pem pkcs1 gmp random nonce x509 curl revocation hmac xcbc stroke kernel-netlink socket-default updown +} diff --git a/testing/tests/tkm/xfrmproxy-expire/posttest.dat b/testing/tests/tkm/xfrmproxy-expire/posttest.dat new file mode 100644 index 0000000000..99efe7b004 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/posttest.dat @@ -0,0 +1,5 @@ +moon::DAEMON_NAME=charon-tkm ipsec stop +moon::killall xfrm_proxy +moon::killall tkm_keymanager +moon::rm -f /tmp/tkm.rpc.ike /tmp/tkm.rpc.ees /tmp/tkm.log /tmp/xfrm_proxy.log +sun::ipsec stop diff --git a/testing/tests/tkm/xfrmproxy-expire/pretest.dat b/testing/tests/tkm/xfrmproxy-expire/pretest.dat new file mode 100644 index 0000000000..d645ddbfe9 --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/pretest.dat @@ -0,0 +1,12 @@ +sun::ipsec start +moon::rm /etc/ipsec.secrets +moon::tkm_cfgtool -c /etc/tkm/tkm.conf -i /etc/ipsec.conf -t /etc/tkm/tkm.bin -s /usr/local/share/tkm/tkmconfig.xsd +moon::cat /etc/ipsec.conf +moon::tkm_keymanager -c /etc/tkm/tkm.bin -k /etc/tkm/moonKey.der -r /etc/tkm/strongswanCert.der >/tmp/tkm.log 2>&1 & +moon::expect-file /tmp/tkm.rpc.ike +moon::DAEMON_NAME=charon-tkm ipsec start +moon::expect-file /tmp/tkm.rpc.ees +moon::xfrm_proxy >/tmp/xfrm_proxy.log 2>&1 & +moon::DAEMON_NAME=charon-tkm expect-connection conn1 +sun::expect-connection host-host +moon::ping -c 3 192.168.0.2 diff --git a/testing/tests/tkm/xfrmproxy-expire/test.conf b/testing/tests/tkm/xfrmproxy-expire/test.conf new file mode 100644 index 0000000000..9647dc6a2a --- /dev/null +++ b/testing/tests/tkm/xfrmproxy-expire/test.conf @@ -0,0 +1,21 @@ +#!/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="moon winnetou sun" + +# Corresponding block diagram +# +DIAGRAM="m-w-s.png" + +# Guest instances on which tcpdump is to be started +# +TCPDUMPHOSTS="sun" + +# Guest instances on which IPsec is started +# Used for IPsec logging purposes +# +IPSECHOSTS="moon sun" -- 2.47.2