5 years agoike-sa-manager: Allow plugins to provide IKE SPIs via a callback
Tobias Brunner [Mon, 9 Nov 2015 14:55:41 +0000 (15:55 +0100)]
ike-sa-manager: Allow plugins to provide IKE SPIs via a callback

Plugins must depend on `libcharon-sa-managers` to ensure the manager

5 years agolibcharon: Publish IKE_SA/CHILD_SA managers as custom plugin feature
Tobias Brunner [Mon, 9 Nov 2015 14:54:48 +0000 (15:54 +0100)]
libcharon: Publish IKE_SA/CHILD_SA managers as custom plugin feature

5 years agoikev1: Also use message hashes for Quick Mode for the early retransmission check
Tobias Brunner [Mon, 9 Nov 2015 16:07:25 +0000 (17:07 +0100)]
ikev1: Also use message hashes for Quick Mode for the early retransmission check

We already did so during Phase 1 but because all three Quick Mode
message have the same message ID we occasionally dropped the third
message as retransmit, so we do it there too.  For INFORMATIONAL
and TRANSACTION exchanges we don't expect more than one inbound message
with the same message ID so we still use them there.

Fixes #1198.

5 years agotesting: Check for leases in swanctl/ip-pool scenario
Andreas Steffen [Wed, 11 Nov 2015 07:43:43 +0000 (08:43 +0100)]
testing: Check for leases in swanctl/ip-pool scenario

5 years agoVersion bump to 5.3.4dr3 5.3.4dr3
Andreas Steffen [Tue, 10 Nov 2015 10:48:32 +0000 (11:48 +0100)]
Version bump to 5.3.4dr3

5 years agotesting: Fixed some more timing issues
Andreas Steffen [Mon, 9 Nov 2015 17:48:30 +0000 (18:48 +0100)]
testing: Fixed some more timing issues

5 years agokernel-netlink: Allow IPsec policies to replace shunt policies
Tobias Brunner [Mon, 5 Oct 2015 12:36:29 +0000 (14:36 +0200)]
kernel-netlink: Allow IPsec policies to replace shunt policies

Shunt policies don't have a reqid set, so we allow unequal reqids in
this particular case (i.e. if one of the reqids is 0).

5 years agokernel-pfkey: Make absolutely sure we always delete the right policy cache entry
Tobias Brunner [Wed, 16 Sep 2015 15:04:21 +0000 (17:04 +0200)]
kernel-pfkey: Make absolutely sure we always delete the right policy cache entry

5 years agokernel-netlink: Make absolutely sure we always delete the right policy cache entry
Tobias Brunner [Wed, 16 Sep 2015 15:01:00 +0000 (17:01 +0200)]
kernel-netlink: Make absolutely sure we always delete the right policy cache entry

5 years agokernel-interface: Pass the same data to del_policy() that was passed to add_policy()
Tobias Brunner [Wed, 16 Sep 2015 14:44:09 +0000 (16:44 +0200)]
kernel-interface: Pass the same data to del_policy() that was passed to add_policy()

The additional data can be helpful to identify the exact policy to

5 years agokernel-netlink: Remove the unused policy_history flag
Tobias Brunner [Wed, 16 Sep 2015 13:05:10 +0000 (15:05 +0200)]
kernel-netlink: Remove the unused policy_history flag

This was used with pluto, which had its own policy tracking.

5 years agokernel-interface: Return bool for kernel interface registration
Thomas Egerer [Tue, 6 Oct 2015 09:02:45 +0000 (11:02 +0200)]
kernel-interface: Return bool for kernel interface registration

If the (un)registering of a kernel interface (net or ipsec) fails, the
plugin loader will never know, since the appropriate functions always
returns TRUE.  By making the (un)register functions return a boolean
value, the loader can detect a failure during initializing the kernel
interface and abort charon startup if desired.

5 years agotrap-manager: Also clean up remote address in error cases
Tobias Brunner [Tue, 10 Nov 2015 13:00:11 +0000 (14:00 +0100)]
trap-manager: Also clean up remote address in error cases

Fixes #1201.

5 years agotraffic-selector: Don't end printf'ed list of traffic selectors with a space
Tobias Brunner [Wed, 7 Oct 2015 14:25:05 +0000 (16:25 +0200)]
traffic-selector: Don't end printf'ed list of traffic selectors with a space

5 years agoswanctl: Add option to query leases with --get-pools
Tobias Brunner [Mon, 19 Oct 2015 13:42:57 +0000 (15:42 +0200)]
swanctl: Add option to query leases with --get-pools

5 years agovici: Add option to query leases of pools
Tobias Brunner [Mon, 19 Oct 2015 13:35:51 +0000 (15:35 +0200)]
vici: Add option to query leases of pools

We could later perhaps add filter parameters similar to those of the
`ipsec leases` command (pool name/virtual IP).

5 years agoswanctl: List virtual IPs in --list-sas
Tobias Brunner [Mon, 19 Oct 2015 14:07:39 +0000 (16:07 +0200)]
swanctl: List virtual IPs in --list-sas

5 years agovici: Return local and remote virtual IPs when listing SAs
Tobias Brunner [Mon, 19 Oct 2015 14:05:47 +0000 (16:05 +0200)]
vici: Return local and remote virtual IPs when listing SAs

5 years agosocket-dynamic: Refactor setting source address when sending messages
Tobias Brunner [Tue, 3 Nov 2015 14:35:16 +0000 (15:35 +0100)]
socket-dynamic: Refactor setting source address when sending messages

Basically the same change as the one for the socket-default plugin.

5 years agosocket-default: Refactor setting source address when sending messages
Tobias Brunner [Mon, 2 Nov 2015 15:22:38 +0000 (16:22 +0100)]
socket-default: Refactor setting source address when sending messages

This ensures we don't pass data (via msg_control) defined in a different
scope to sendmsg().  Actually, some compilers (e.g. GCC 5.2.1) might
optimize the memcpy() call away causing the packets not to get sent from
the intended source address.

It also makes the code clearer than with all these ifdefs.

Fixes #1171.

5 years agosocket-default: Refactor retrieval of destination address of received packets
Tobias Brunner [Mon, 2 Nov 2015 15:16:56 +0000 (16:16 +0100)]
socket-default: Refactor retrieval of destination address of received packets

This makes the code a bit clearer than with the interleaved ifdefs.

5 years agoMerge branch 'medsrv-js-css'
Tobias Brunner [Mon, 9 Nov 2015 15:37:02 +0000 (16:37 +0100)]
Merge branch 'medsrv-js-css'

Removes the outdated version of MooTools and actually all
JavaScript code as that stuff can now be done with CSS directly.

Fixes #1190.

5 years agomedsrv: Replace remaining JavaScript code with CSS
Tobias Brunner [Wed, 4 Nov 2015 13:47:40 +0000 (14:47 +0100)]
medsrv: Replace remaining JavaScript code with CSS

5 years agomedsrv: Replace the JavaScript focus() calls with HTML5's autofocus
Tobias Brunner [Wed, 4 Nov 2015 13:30:18 +0000 (14:30 +0100)]
medsrv: Replace the JavaScript focus() calls with HTML5's autofocus

5 years agoconftest: Add configuration option to report milliseconds in file logger
Tobias Brunner [Mon, 9 Nov 2015 11:44:29 +0000 (12:44 +0100)]
conftest: Add configuration option to report milliseconds in file logger

5 years agofile-logger: Add option to print milliseconds within the current second after timestamp
Tobias Brunner [Mon, 9 Nov 2015 11:30:26 +0000 (12:30 +0100)]
file-logger: Add option to print milliseconds within the current second after timestamp

For this to look right time_format should end with %S or %T.

Closes strongswan/strongswan#18.

5 years agoike-natd: Create fake NAT-D payloads in a more static way
Tobias Brunner [Fri, 25 Sep 2015 17:24:44 +0000 (19:24 +0200)]
ike-natd: Create fake NAT-D payloads in a more static way

In some scenarios an IKE_SA might get restarted multiple times (e.g.
due to retransmits and delayed INVALID_KE_PAYLOAD notifies) so that
two IKE_SA_INIT messages might be sent that only differ in the
previously randomly generated NAT_DETECTION_SOURCE_IP payload.
This could cause an authentication failure on the responder if the two
peers don't use the same IKE_SA_INIT message in their InitiatorSignedOctets.

While the payload is generated in a reproducible way it will still change
when the daemon is restarted, which should make detecting the payloads
as fake a bit harder (compared to e.g. just using as address).

Fixes #1131.

5 years agotesting: Added Debian 7.9 to IMV database 5.3.4dr2
Andreas Steffen [Sat, 7 Nov 2015 12:13:49 +0000 (13:13 +0100)]
testing: Added Debian 7.9 to IMV database

5 years agotesting: Reduce runtime of all tests that use SQLite databases by storing them in...
Tobias Brunner [Fri, 6 Nov 2015 16:27:45 +0000 (17:27 +0100)]
testing: Reduce runtime of all tests that use SQLite databases by storing them in ramfs

5 years agotesting: tnc/tnccs-20-hcd-eap scenario does not use SWID IMV/strongTNC
Tobias Brunner [Fri, 6 Nov 2015 17:27:30 +0000 (18:27 +0100)]
testing: tnc/tnccs-20-hcd-eap scenario does not use SWID IMV/strongTNC

5 years agotesting: Add test config to create and remove a directory for DBs stored in ramfs
Tobias Brunner [Fri, 6 Nov 2015 16:26:42 +0000 (17:26 +0100)]
testing: Add test config to create and remove a directory for DBs stored in ramfs

5 years agotesting: Improve runtime of TNC tests by storing the SQLite DB in ramfs
Tobias Brunner [Fri, 6 Nov 2015 15:00:29 +0000 (16:00 +0100)]
testing: Improve runtime of TNC tests by storing the SQLite DB in ramfs

This saves about 50%-70% of the time needed for scenarios that use a DB.

5 years agotesting: Fix test constraints in ikev2/rw-ntru-bliss scenario
Tobias Brunner [Fri, 6 Nov 2015 16:21:11 +0000 (17:21 +0100)]
testing: Fix test constraints in ikev2/rw-ntru-bliss scenario

Changed with a88d958933ef ("Explicitly mention SHA2 algorithm in BLISS
OIDs and signature schemes").

5 years agotesting: Use sha3 plugin in ikev2/rw-cert scenario
Andreas Steffen [Fri, 6 Nov 2015 15:22:57 +0000 (16:22 +0100)]
testing: Use sha3 plugin in ikev2/rw-cert scenario

5 years agomediation: Reschedule initiate mediation job if SA is not yet found
Tobias Brunner [Fri, 6 Nov 2015 13:45:57 +0000 (14:45 +0100)]
mediation: Reschedule initiate mediation job if SA is not yet found

If the job gets queued for a newly created IKE_SA it might not yet be
checked in when the job is running, reschedule the job in that case.

This should fix the two p2pnat test scenarios, which occasionally
failed because one of the peers did not initiate the connection to
the mediation server.

5 years agotesting: Report the actual strongSwan and kernel versions
Tobias Brunner [Fri, 6 Nov 2015 10:28:34 +0000 (11:28 +0100)]
testing: Report the actual strongSwan and kernel versions

5 years agotesting: Record strongSwan version when building from tarball
Tobias Brunner [Fri, 6 Nov 2015 10:19:40 +0000 (11:19 +0100)]
testing: Record strongSwan version when building from tarball

5 years agotesting: Record strongSwan version when building from source tree
Tobias Brunner [Fri, 6 Nov 2015 10:19:22 +0000 (11:19 +0100)]
testing: Record strongSwan version when building from source tree

5 years agotesting: Report time required for all scenarios on test overview page
Tobias Brunner [Thu, 5 Nov 2015 14:20:46 +0000 (15:20 +0100)]
testing: Report time required for all scenarios on test overview page

5 years agoike-sa-manager: Signal entries that we don't actually check out
Tobias Brunner [Thu, 5 Nov 2015 17:52:27 +0000 (18:52 +0100)]
ike-sa-manager: Signal entries that we don't actually check out

In some cases we call wait_for_entry() but don't actually check out the
entry afterwards (e.g. because it doesn't match certain criteria).  So
there won't be a call to checkin() for such entries causing waiting
threads to get signaled.  Instead, such threads would be blocked until
another thread properly checks out/in the entry (or does a blocking

5 years agoike-sa-manager: Signal waiting threads after check out/in for uniqueness check
Tobias Brunner [Fri, 6 Nov 2015 08:18:44 +0000 (09:18 +0100)]
ike-sa-manager: Signal waiting threads after check out/in for uniqueness check

Fixes 758b1caa0e75 ("ikev1: Prevent deadlock when checking for duplicate IKEv1 SAs")

5 years agotesting: Remove old SWID tags when building from repository
Tobias Brunner [Thu, 5 Nov 2015 16:04:29 +0000 (17:04 +0100)]
testing: Remove old SWID tags when building from repository

This fixes the TNC-PDP scenarios.

5 years agotesting: Don't log anything to the console if auth.log or daemon.log do not exist
Tobias Brunner [Thu, 5 Nov 2015 14:10:26 +0000 (15:10 +0100)]
testing: Don't log anything to the console if auth.log or daemon.log do not exist

5 years agotesting: Simplify fetching of swanctl --list-* output
Tobias Brunner [Thu, 5 Nov 2015 14:07:57 +0000 (15:07 +0100)]
testing: Simplify fetching of swanctl --list-* output

5 years agotesting: Don't run redundant crypto tests in sql/rw-cert scenario
Tobias Brunner [Thu, 5 Nov 2015 14:05:44 +0000 (15:05 +0100)]
testing: Don't run redundant crypto tests in sql/rw-cert scenario

They run in all other rw-cert scenarios but in the SQL version there is
no change in the loaded crypto plugins.

5 years agotesting: Fix CRL URIs in ipv6/net2net-ip4-in-ip6-ikev* scenarios
Tobias Brunner [Thu, 5 Nov 2015 14:04:39 +0000 (15:04 +0100)]
testing: Fix CRL URIs in ipv6/net2net-ip4-in-ip6-ikev* scenarios

5 years agotesting: Speed up OCSP scenarios
Tobias Brunner [Thu, 5 Nov 2015 14:03:06 +0000 (15:03 +0100)]
testing: Speed up OCSP scenarios

Don't make clients wait for the TCP connections to timeout by dropping
packets.  By rejecting them the OCSP requests fail immediately.

5 years agotesting: Speed up ifdown calls in ikev2/mobike scenarios
Tobias Brunner [Thu, 5 Nov 2015 13:59:34 +0000 (14:59 +0100)]
testing: Speed up ifdown calls in ikev2/mobike scenarios

ifdown calls bind's rndc, which tries to access TCP port 953 on lo.
If these packets are dropped by the firewall we have to wait for the TCP
connections to time out, which takes quite a while.

5 years agotesting: Avoid delays with ping by using -W and -i options
Tobias Brunner [Thu, 5 Nov 2015 13:57:07 +0000 (14:57 +0100)]
testing: Avoid delays with ping by using -W and -i options

With -W we reduce timeouts when we don't expect a response.  With -i the
interval between pings is reduced (mostly in case of auto=route where
the first ping yields no reply).

5 years agotesting: Remove nearly all sleep calls from pretest and posttest scripts
Tobias Brunner [Thu, 5 Nov 2015 13:47:58 +0000 (14:47 +0100)]
testing: Remove nearly all sleep calls from pretest and posttest scripts

By consistently using the `expect-connection` helper we can avoid pretty
much all previously needed calls to sleep.

5 years agoikev1: Fix calculation of DPD timeout
Tobias Brunner [Thu, 5 Nov 2015 14:14:56 +0000 (15:14 +0100)]
ikev1: Fix calculation of DPD timeout

A DPD timeout job is queued whenever a DPD is sent, i.e. after the
DPD delay already has elapsed, so we have to compensate for that.

5 years agotesting: Adapt tests to retransmission settings and reduce DPD delay/timeout
Tobias Brunner [Thu, 5 Nov 2015 13:55:14 +0000 (14:55 +0100)]
testing: Adapt tests to retransmission settings and reduce DPD delay/timeout

5 years agoipsec: Quit script quicker for ipsec stop
Tobias Brunner [Tue, 6 Oct 2015 15:21:01 +0000 (17:21 +0200)]
ipsec: Quit script quicker for ipsec stop

It rarely takes 1 second or longer to terminate the daemon.  This
decreases the runtime of the post test step a lot where `ipsec stop`
is called for multiple hosts in each test case (10-15 minutes over all
test cases).

5 years agotesting: Only send two retransmits after 1 second each to fail negative tests earlier
Tobias Brunner [Mon, 21 Sep 2015 17:32:22 +0000 (19:32 +0200)]
testing: Only send two retransmits after 1 second each to fail negative tests earlier

5 years agotesting: Add a base strongswan.conf file used by all hosts in all scenarios
Tobias Brunner [Mon, 21 Sep 2015 09:15:20 +0000 (11:15 +0200)]
testing: Add a base strongswan.conf file used by all hosts in all scenarios

We will use this to set some defaults (e.g. timeouts to make testing
negative tests quicker).  We don't want these settings to show up in the
configs of the actual scenarios though.

5 years agoxauth: Call authorize() hook also when xauth-noauth is used
Tobias Brunner [Thu, 1 Oct 2015 16:15:00 +0000 (18:15 +0200)]
xauth: Call authorize() hook also when xauth-noauth is used

Fixes #1138.

5 years agolibtnccs: Optionally use RTLD_NOW to load IMC/IMVs with dlopen()
Tobias Brunner [Fri, 25 Sep 2015 10:00:58 +0000 (12:00 +0200)]
libtnccs: Optionally use RTLD_NOW to load IMC/IMVs with dlopen()

5 years agoplugin-loader: Optionally use RTLD_NOW with dlopen()
Tobias Brunner [Fri, 25 Sep 2015 09:05:24 +0000 (11:05 +0200)]
plugin-loader: Optionally use RTLD_NOW with dlopen()

This can be useful when writing custom plugins as typos or missing
linker flags that result in unresolved symbols in the shared object
could otherwise cause late crashes.  In particular, if such a symbol
is used in a code path that is rarely executed.  During development
and testing using RTLD_NOW instead of RTLD_LAZY will prevent the
plugin from getting loaded and makes the error visible immediately.

5 years agowindows: Define RTLD_NOW, even if it is not used
Tobias Brunner [Fri, 25 Sep 2015 15:41:31 +0000 (17:41 +0200)]
windows: Define RTLD_NOW, even if it is not used

5 years agokernel-pfkey: Enable ENCR_AES_CTR when it's available
Renato Botelho [Fri, 6 Nov 2015 19:07:38 +0000 (17:07 -0200)]
kernel-pfkey: Enable ENCR_AES_CTR when it's available

Obtained-from: pfSense
Sponsored-by: Rubicon Communications (Netgate)
Closes strongswan/strongswan#17.

5 years agovici: Add NAT information when listing IKE_SAs
Tobias Brunner [Mon, 9 Nov 2015 10:39:54 +0000 (11:39 +0100)]
vici: Add NAT information when listing IKE_SAs

The `nat-local` and `nat-remote` keys contain information on the NAT
status of the local and remote IKE endpoints, respectively.  If a
responder did not detect a NAT but is configured to fake a NAT situation
this is indicated by `nat-fake` (if an initiator fakes a NAT situation
`nat-local` is set).  If any NAT is detected or faked `nat-any` is set.

Closes strongswan/strongswan#16.

5 years agoMerge branch 'iv-gen-null-encr'
Tobias Brunner [Mon, 9 Nov 2015 10:16:12 +0000 (11:16 +0100)]
Merge branch 'iv-gen-null-encr'

Fixes NULL encryption in libipsec.

Fixes #1174.

5 years agotesting: Add libipsec/net2net-null scenario
Tobias Brunner [Fri, 23 Oct 2015 12:47:54 +0000 (14:47 +0200)]
testing: Add libipsec/net2net-null scenario

5 years agoiv-gen: Use NULL IV generator for NULL encryption
Tobias Brunner [Fri, 23 Oct 2015 12:34:54 +0000 (14:34 +0200)]
iv-gen: Use NULL IV generator for NULL encryption

We don't need an IV for NULL encryption, so we wouldn't technically need
an IV generator.  But some of the code currently relies on an IV
generator to be present.  So we don't have to change that code and
handle IV size == 0 specially we use the new NULL IV generator, which
handles this transparently to the existing code.

Before 3c81cb6fc322 ("aead: Create AEAD using traditional transforms
with an explicit IV generator") iv_gen_rand_t was used for NULL
encryption, which would work too but this way it's clearer.

5 years agocrypto: Add NULL IV generator
Tobias Brunner [Fri, 23 Oct 2015 12:16:57 +0000 (14:16 +0200)]
crypto: Add NULL IV generator

This does not actually allocate an IV and only accepts requests
for size == 0.

5 years agoconfigure: Load sha1 and random plugins in manager by default
Tobias Brunner [Thu, 22 Oct 2015 09:05:31 +0000 (11:05 +0200)]
configure: Load sha1 and random plugins in manager by default

If the openssl plugin is not enabled we need these to generate session
IDs and to authenticate the users.

The md4 plugin is not needed in the manager.

Fixes #1168.

5 years agostroke: Make down-nb actually non-blocking
Tobias Brunner [Wed, 4 Nov 2015 15:44:17 +0000 (16:44 +0100)]
stroke: Make down-nb actually non-blocking

Fixes #1191.

5 years agoVersion bump to 5.3.4dr2
Andreas Steffen [Fri, 6 Nov 2015 15:07:04 +0000 (16:07 +0100)]
Version bump to 5.3.4dr2

5 years agotesting: Updated hasher tests
Andreas Steffen [Fri, 6 Nov 2015 15:05:44 +0000 (16:05 +0100)]
testing: Updated hasher tests

5 years agoExplicitly mention SHA2 algorithm in BLISS OIDs and signature schemes
Andreas Steffen [Fri, 6 Nov 2015 13:55:10 +0000 (14:55 +0100)]
Explicitly mention SHA2 algorithm in BLISS OIDs and signature schemes

5 years agoVersion bump to 5.3.4dr1 5.3.4dr1
Andreas Steffen [Wed, 4 Nov 2015 18:42:17 +0000 (19:42 +0100)]
Version bump to 5.3.4dr1

5 years agoUse word-aligned XOR in sha3_absorb()
Andreas Steffen [Tue, 3 Nov 2015 18:06:45 +0000 (19:06 +0100)]
Use word-aligned XOR in sha3_absorb()

5 years agotesting: BLISS CA uses SHA-3 in its CRL
Andreas Steffen [Fri, 30 Oct 2015 06:06:57 +0000 (07:06 +0100)]
testing: BLISS CA uses SHA-3 in its CRL

5 years agoSupport BLISS signatures with SHA-3 hash
Andreas Steffen [Wed, 28 Oct 2015 20:00:31 +0000 (21:00 +0100)]
Support BLISS signatures with SHA-3 hash

5 years agoImplemented SHA-3 hash algorithm including test vectors
Andreas Steffen [Wed, 28 Oct 2015 18:57:14 +0000 (19:57 +0100)]
Implemented SHA-3 hash algorithm including test vectors

5 years agoDefined SHA-3 hashers
Andreas Steffen [Thu, 15 Oct 2015 14:39:50 +0000 (16:39 +0200)]
Defined SHA-3 hashers

5 years agotesting: Update tkm to version 0.1.3
Tobias Brunner [Fri, 30 Oct 2015 10:19:44 +0000 (11:19 +0100)]
testing: Update tkm to version 0.1.3

Adds XFRM state/policy flush when terminating which caused tests to fail
due to the check added with 9086f060d35a ("testing: Let test scenarios
fail if IPsec SAs or policies are not removed").

5 years agolibipsec: Properly support CAMELLIA in CTR mode
Tobias Brunner [Mon, 21 Sep 2015 09:12:14 +0000 (11:12 +0200)]
libipsec: Properly support CAMELLIA in CTR mode

5 years agoikev2: Fix size of key material for CAMELLIA-CTR
Tobias Brunner [Mon, 21 Sep 2015 09:11:33 +0000 (11:11 +0200)]
ikev2: Fix size of key material for CAMELLIA-CTR

Like AES in CTR mode it includes a 4 byte nonce.

5 years agolibipsec: Fix crypter lookup for AES-CTR
Tobias Brunner [Mon, 21 Sep 2015 09:02:45 +0000 (11:02 +0200)]
libipsec: Fix crypter lookup for AES-CTR

Due to the nonce, the ESP key material is four bytes longer than needed for
the actual AES key.  The crypto plugins, however, register their AES-CTR
implementations with the AES key length, so the lookup here failed.

For IKEv2 the key material is allocated after creating a crypter instance
with the negotiated AES key size.  The length of the actual key material is
retrieved via get_key_size(), which adds the four bytes to the AES key length.

Fixes #1124.

5 years agoike-mobike: Send retransmits to the current local and remote addresses
Tobias Brunner [Wed, 23 Sep 2015 08:53:20 +0000 (10:53 +0200)]
ike-mobike: Send retransmits to the current local and remote addresses

These might have changed by a peer-initiated MOBIKE address update.

Fixes #1125.

5 years agoMerge branch 'ikev1-cache-informational'
Tobias Brunner [Fri, 30 Oct 2015 09:33:51 +0000 (10:33 +0100)]
Merge branch 'ikev1-cache-informational'

With these changes an INFORMATIONAL message (e.g. with an INITIAL_CONTACT
notify) that arrives while a responder is waiting for the last Aggressive
Mode request gets queued and delivered later.  Previously such messages
caused the IKE_SA to fail as some tasks waiting for the last AM message
fail when trying to handle the INFORMATIONAL message.  Therefore, all
other messages, such as TRANSACTION and QUICK_MODE requests, are now
dropped until AM is complete.  These don't have to be cached as they get
retransmitted by the other peer.

Fixes #1130.

5 years agoikev1: Handle queued INFORMATIONAL message after receiving the last AM request
Tobias Brunner [Mon, 28 Sep 2015 15:39:54 +0000 (17:39 +0200)]
ikev1: Handle queued INFORMATIONAL message after receiving the last AM request

5 years agoikev1: Queue INFORMATIONAL request if AM is not complete yet
Tobias Brunner [Mon, 28 Sep 2015 15:37:42 +0000 (17:37 +0200)]
ikev1: Queue INFORMATIONAL request if AM is not complete yet

5 years agoikev1: Handle queued TRANSACTION messages only after processing replies
Tobias Brunner [Mon, 28 Sep 2015 15:35:30 +0000 (17:35 +0200)]
ikev1: Handle queued TRANSACTION messages only after processing replies

5 years agoikev1: Extract queueing of TRANSACTIONAL requests when MM is not complete yet
Tobias Brunner [Mon, 28 Sep 2015 15:33:46 +0000 (17:33 +0200)]
ikev1: Extract queueing of TRANSACTIONAL requests when MM is not complete yet

5 years agoikev1: Drop TRANSACTION/QUICK_MODE requests until we received the last AM message
Tobias Brunner [Mon, 28 Sep 2015 15:30:36 +0000 (17:30 +0200)]
ikev1: Drop TRANSACTION/QUICK_MODE requests until we received the last AM message

5 years agoikev1: Make maximum number of IKEv1 phase 2 exchanges we keep state about configurable
Tobias Brunner [Tue, 22 Sep 2015 09:56:44 +0000 (11:56 +0200)]
ikev1: Make maximum number of IKEv1 phase 2 exchanges we keep state about configurable

Fixes #1128.

5 years agoFix typo in error handling for sigwaitinfo() in charon-systemd and charon-tkm
Tobias Brunner [Thu, 29 Oct 2015 16:37:06 +0000 (17:37 +0100)]
Fix typo in error handling for sigwaitinfo() in charon-systemd and charon-tkm

Fixes 858148092d1e ("Replace usages of sigwait(3) with sigwaitinfo(2)")

5 years agorandom: Properly handle errors when reading from /dev/[u]random
Tobias Brunner [Mon, 12 Oct 2015 09:04:55 +0000 (11:04 +0200)]
random: Properly handle errors when reading from /dev/[u]random

If -1 was returned on the first call to read() `done` got SIZE_MAX
and the function returned TRUE even though no actual random data had
been allocated.

Fixes #1156.

5 years agoikev1: Avoid fourth QM message if third QM messages of multiple exchanges are handled...
Tobias Brunner [Wed, 7 Oct 2015 14:08:22 +0000 (16:08 +0200)]
ikev1: Avoid fourth QM message if third QM messages of multiple exchanges are handled delayed

If we haven't received the third QM message for multiple exchanges the
return value of NEED_MORE for passive tasks that are not responsible for
a specific exchange would trigger a fourth empty QM message.

Fixes: 4de361d92c54 ("ikev1: Fix handling of overlapping Quick Mode exchanges")

References #1076.

5 years agoikev1: Prevent deadlock when checking for duplicate IKEv1 SAs
Tobias Brunner [Wed, 2 Sep 2015 10:14:35 +0000 (12:14 +0200)]
ikev1: Prevent deadlock when checking for duplicate IKEv1 SAs

Previously, the current segment was held while checking for duplicate
SAs, which requires acquiring all segments.  If multiple threads did this
concurrently this resulted in a deadlock as they couldn't acquire the
segments held by the other threads attempting to do the same.  With the
default configuration only one segment is used, which prevents the problem
as only one thread can check in an IKE SA concurrently.

Fixes: a064eaa8a63a ("Handling of initial contact")

5 years agoReplace usages of sigwait(3) with sigwaitinfo(2)
Tobias Brunner [Thu, 17 Sep 2015 15:52:14 +0000 (17:52 +0200)]
Replace usages of sigwait(3) with sigwaitinfo(2)

This is basically the same call, but it has the advantage of being
supported by FreeBSD's valgrind, which sigwait() is not.

References #1106.

5 years agotesting: Actually send an uncompressed packet in the ipv6/rw-compress-ikev2 scenario
Tobias Brunner [Mon, 21 Sep 2015 08:12:24 +0000 (10:12 +0200)]
testing: Actually send an uncompressed packet in the ipv6/rw-compress-ikev2 scenario

The default of 56 bytes already exceeds the threshold of 90 bytes (8 bytes
ICMP + 40 bytes IPv6 = 104 bytes).  By reducing the size we make sure the
packet is not compressed (40 + 8 + 40 = 88).

This also fixes a strange failure of this scenario due to the recently
added post-test `ip xfrm state` check.  The kernel stores a reference to
the used SAs on the inbound skbuffs and since these are garbage collected
it could take a while until all references to an SA disappear and the SA
is finally destroyed.  But while SAs might not get destroyed immediately
when we delete them, they are actually marked as dead and therefore won't
show up in `ip xfrm state`.  However, that's not the case for the tunnel
SAs the kernel attaches to IPComp SAs, which we don't explicitly delete,
and which aren't modified by the kernel until the IPComp SA is destroyed.
So what happened when the last ping unintentionally got compressed is that
the skbuff had a reference to the IPComp SA and therefore the tunnel SA.
This skbuff often was destroyed after the `ip xfrm state` check ran and
because the tunnel SA would still get reported the test case failed.

5 years agoupdown: Add rules to allow IP6IP6 traffic used for uncompressed small packets
Tobias Brunner [Mon, 21 Sep 2015 08:12:17 +0000 (10:12 +0200)]
updown: Add rules to allow IP6IP6 traffic used for uncompressed small packets

5 years agoshunt-manager: Resolve %dynamic to %any4/6 before installing policies
Tobias Brunner [Wed, 26 Aug 2015 16:08:14 +0000 (18:08 +0200)]
shunt-manager: Resolve %dynamic to %any4/6 before installing policies

left|rightsubnet default to %dynamic, which is basically until an
address is assigned to it.  So if only one side was undefined and the other
traffic selector was IPv6 an address family mismatch would occur.

References #595.

5 years agoshunt-manager: Don't install policies in case of an address family or IP protocol...
Tobias Brunner [Wed, 26 Aug 2015 16:07:06 +0000 (18:07 +0200)]
shunt-manager: Don't install policies in case of an address family or IP protocol mismatch

References #595.

5 years agoopenssl: Explicitly include openssl/bn.h
Tobias Brunner [Wed, 16 Sep 2015 09:16:59 +0000 (11:16 +0200)]
openssl: Explicitly include openssl/bn.h

If OpenSSL is compiled with OPENSSL_NO_DEPRECATED some of the headers
we include don't include openssl/bn.h anymore.  Therefore, we have to
explicitly include it ourselves where we use BN_* functions.

Fixes #1113.

5 years agounit-tests: Add a test to verify that there is no partial matching of RDNs
Tobias Brunner [Wed, 9 Sep 2015 12:39:26 +0000 (14:39 +0200)]
unit-tests: Add a test to verify that there is no partial matching of RDNs

5 years agoscepclient: Remove copyright and license from man page
Tobias Brunner [Wed, 9 Sep 2015 09:45:17 +0000 (11:45 +0200)]
scepclient: Remove copyright and license from man page