]> git.ipfire.org Git - people/ms/strongswan.git/log
people/ms/strongswan.git
9 years agopki: Add --dn command to extract the subject DN of a certificate
Tobias Brunner [Thu, 6 Aug 2015 16:04:38 +0000 (18:04 +0200)] 
pki: Add --dn command to extract the subject DN of a certificate

9 years agoscripts: Add script to extract the ASN.1 subject DN from a certificate
Tobias Brunner [Fri, 17 Jul 2015 09:46:16 +0000 (11:46 +0200)] 
scripts: Add script to extract the ASN.1 subject DN from a certificate

This can be useful if the subject DN has to be configured with the
asn1dn: prefix in ipsec.conf (e.g. because the actual encoding can't be
created by strongSwan's string parser/encoder).

9 years agoplugin-feature: Add vendor specific EAP method registration macros
Tobias Brunner [Thu, 25 Jun 2015 15:41:09 +0000 (17:41 +0200)] 
plugin-feature: Add vendor specific EAP method registration macros

Vendor specific EAP methods may be registered with:

    PLUGIN_CALLBACK(eap_method_register, <constructor>),
        PLUGIN_PROVIDE(EAP_SERVER_VENDOR, <type>, <vendor>),

Same for client implementations via EAP_PEER_VENDOR.

References #969.

9 years agoeap-radius: Use Framed-IPv6-Address attributes to send IPv6 VIPs in accounting messages
Tobias Brunner [Mon, 29 Jun 2015 08:43:19 +0000 (10:43 +0200)] 
eap-radius: Use Framed-IPv6-Address attributes to send IPv6 VIPs in accounting messages

This attribute is more appropriate for single IPv6 virtual IPs than the
Framed-IPv6-Prefix attribute.

Fixes #1001.

9 years agoeap-radius: Add support for some basic IPv6-specific RADIUS attributes
Tobias Brunner [Mon, 22 Jun 2015 09:36:15 +0000 (11:36 +0200)] 
eap-radius: Add support for some basic IPv6-specific RADIUS attributes

These are defined in RFC 6911.

Fixes #1001.

9 years agoutils: Check for dirfd(3)
Tobias Brunner [Tue, 4 Aug 2015 17:17:37 +0000 (19:17 +0200)] 
utils: Check for dirfd(3)

Not all POSIX compatible systems might provide it yet.  If not, we close
the lowest FD to close and hope it gets reused by opendir().

9 years agoutils: Directly use syscall() to close open FDs in closefrom()
Tobias Brunner [Thu, 11 Jun 2015 10:19:56 +0000 (12:19 +0200)] 
utils: Directly use syscall() to close open FDs in closefrom()

This avoids any allocations, since calling malloc() after fork() is
potentially unsafe.

Fixes #990.

9 years agoutils: Don't use directory enumerator to close open FDs in closefrom()
Tobias Brunner [Tue, 4 Aug 2015 12:43:26 +0000 (14:43 +0200)] 
utils: Don't use directory enumerator to close open FDs in closefrom()

Calling malloc() after fork() is potentially unsafe, so we should avoid
it if possible.  opendir() will still require an allocation but that's
less than the variant using the enumerator wrapper, thus, decreasing
the conflict potential.  This way we can also avoid closing the
FD for the enumerated directory itself.

References #990.

9 years agoMerge branch 'vici-updown'
Tobias Brunner [Mon, 17 Aug 2015 09:13:37 +0000 (11:13 +0200)] 
Merge branch 'vici-updown'

Documents the ike/child-updown events and adds a ike/child-rekey event
and a new listen() method in the Python VICI bindings to listen for
arbitrary events (similar to the listen_events() method in the Ruby
bindings).

9 years agovici: Add listen methods to receive arbitrary events in Python library
Tobias Brunner [Thu, 6 Aug 2015 12:51:21 +0000 (14:51 +0200)] 
vici: Add listen methods to receive arbitrary events in Python library

9 years agovici: Move event (un-)registration to a helper method in Python library
Tobias Brunner [Thu, 6 Aug 2015 12:41:54 +0000 (14:41 +0200)] 
vici: Move event (un-)registration to a helper method in Python library

Also make sure events are unregistered in case of exceptions in
streamed_request().

9 years agovici: Add ike/child-rekey events
Tobias Brunner [Mon, 1 Jun 2015 13:36:21 +0000 (15:36 +0200)] 
vici: Add ike/child-rekey events

9 years agovici: Document the ike/child-updown events
Tobias Brunner [Fri, 29 May 2015 16:43:15 +0000 (18:43 +0200)] 
vici: Document the ike/child-updown events

9 years agovici: Don't include a child-sas section in ike-updown event
Tobias Brunner [Fri, 29 May 2015 16:38:47 +0000 (18:38 +0200)] 
vici: Don't include a child-sas section in ike-updown event

This makes it clearer that only the data concerning the IKE_SA is
transmitted (there could be CHILD_SAs e.g. during IKEv1
reauthentication).

9 years agovici: Explicitly notify listeners of the type of ike/child-updown event
Tobias Brunner [Fri, 29 May 2015 16:38:28 +0000 (18:38 +0200)] 
vici: Explicitly notify listeners of the type of ike/child-updown event

9 years agoVersion bump to 5.3.3dr5
Andreas Steffen [Sun, 16 Aug 2015 07:04:42 +0000 (09:04 +0200)] 
Version bump to 5.3.3dr5

9 years agoFixed AR identities in mutual TNC measurements case
Andreas Steffen [Sat, 15 Aug 2015 20:46:21 +0000 (22:46 +0200)] 
Fixed AR identities in mutual TNC measurements case

9 years agokernel-pfroute: Don't install virtual IPs if charon.install_virtual_ip is disabled
Tobias Brunner [Thu, 13 Aug 2015 13:52:50 +0000 (15:52 +0200)] 
kernel-pfroute: Don't install virtual IPs if charon.install_virtual_ip is disabled

9 years agoload-tester: Include string.h for strcmp() on some platforms
Tobias Brunner [Thu, 13 Aug 2015 13:10:34 +0000 (15:10 +0200)] 
load-tester: Include string.h for strcmp() on some platforms

9 years agoInitialize variables that some compilers seem to warn about
Tobias Brunner [Thu, 13 Aug 2015 13:09:00 +0000 (15:09 +0200)] 
Initialize variables that some compilers seem to warn about

9 years agoFixed some typos
Tobias Brunner [Thu, 13 Aug 2015 13:03:50 +0000 (15:03 +0200)] 
Fixed some typos

9 years agokernel-netlink: When adding a policy do an update if it already exists
Tobias Brunner [Wed, 3 Jun 2015 15:31:30 +0000 (17:31 +0200)] 
kernel-netlink: When adding a policy do an update if it already exists

This may be the case when SAs are reestablished after a crash of the
IKE daemon.

We could actually always do updates.  The kernel doesn't care, the only
difference is the possible EEXIST if XFRM_MSG_NEWPOLICY is used.  The
advantage of not doing this, though, is that we get a warning in the log
if a policy already exists, as that should usually not be the case.

9 years agokernel-pfkey: When adding policies do an update if they already exist
Tobias Brunner [Wed, 3 Jun 2015 15:17:15 +0000 (17:17 +0200)] 
kernel-pfkey: When adding policies do an update if they already exist

This may be the case when SAs are reestablished after a crash of the
IKE daemon.

9 years agopki: Optionally extract public key from given private key in --issue
Tobias Brunner [Tue, 7 Jul 2015 08:53:22 +0000 (10:53 +0200)] 
pki: Optionally extract public key from given private key in --issue

Fixes #618.

9 years agoconf: Clarify resolution for two time settings
Tobias Brunner [Mon, 10 Aug 2015 10:01:24 +0000 (12:01 +0200)] 
conf: Clarify resolution for two time settings

Fixes #1061.

9 years agoVersion bump to 5.3.3dr4
Andreas Steffen [Mon, 10 Aug 2015 05:48:14 +0000 (07:48 +0200)] 
Version bump to 5.3.3dr4

9 years agoidentification: Use UTF8String instead of the legacy T61String to encode DNs
Tobias Brunner [Thu, 11 Jun 2015 15:43:49 +0000 (17:43 +0200)] 
identification: Use UTF8String instead of the legacy T61String to encode DNs

When strings in RDNs contain characters outside the character set for
PrintableString use UTF8String as the passed string is most likely in
that encoding (RFC 5280 actually recommends to use only those two
string types).

9 years agowhitelist: Use hash() method so DNs with different string types match
Tobias Brunner [Thu, 11 Jun 2015 15:40:10 +0000 (17:40 +0200)] 
whitelist: Use hash() method so DNs with different string types match

strongSwan uses PrintableString when encoding DNs from strings (if the
character set permits it, otherwise T61String is currently used) but
certificates might be encoded with UTF8String even for simple ASCII strings.
By ignoring this string type when hashing RDNs we make sure the same hash
results in this case as long as the actual string values are the same.

Fixes #991.

9 years agoidentification: Add hash() method
Tobias Brunner [Thu, 11 Jun 2015 15:38:46 +0000 (17:38 +0200)] 
identification: Add hash() method

Compared to hashing the encoding we can ignore string types of RDNs when
hashing DNs, making hash() compatible to equals() that does the same.

Fixes #991.

9 years agopkcs11: Fix encoding of RSA keys if unnecessarily zero prefixed
Tobias Brunner [Thu, 2 Jul 2015 13:58:01 +0000 (15:58 +0200)] 
pkcs11: Fix encoding of RSA keys if unnecessarily zero prefixed

Some tokens/libraries seem to prefix all numbers with zero bytes even
if not necessary (e.g. the default exponent 0x010001).  If we don't fix
that, the fingerprints calculated based on the retrieved values will be
incorrect.

Even if the pkcs1 plugin can properly handle numbers that are not in
two's complement since a81bd670b086 ("Added PUBKEY_RSA_MODULUS
encoding type") we prefix them with zero if necessary as other encoders
might expect them in two's complement.

Fixes #1012.

9 years agoupdown: Pass virtual IPs assigned to a peer to the updown script
Tobias Brunner [Thu, 25 Jun 2015 15:19:12 +0000 (17:19 +0200)] 
updown: Pass virtual IPs assigned to a peer to the updown script

Previously only received virtual IPs were available.

References #1008.

9 years agoeap-radius: Don't send RADIUS Accounting Start messages twice
Tobias Brunner [Tue, 2 Jun 2015 13:18:52 +0000 (15:18 +0200)] 
eap-radius: Don't send RADIUS Accounting Start messages twice

If a client does Mode Config during reauthentication the assign_vips()
event might be triggered twice, we should not send another Start message
in that case.

Fixes #937.

9 years agoeap-radius: Change trigger for Accounting Start messages for IKEv1
Tobias Brunner [Tue, 2 Jun 2015 12:48:31 +0000 (14:48 +0200)] 
eap-radius: Change trigger for Accounting Start messages for IKEv1

Some clients won't do Mode Config or XAuth during reauthentication.
Because Start messages previously were triggered by TRANSACTION exchanges
none were sent for new SAs of such clients, while Stop messages were still
sent for the old SAs when they were destroyed.  This resulted in an
incorrect state on the RADIUS server.

Since 31be582399 the assign_vips() event is also triggered during
reauthentication if the client does not do a Mode Config exchange.
So instead of waiting for a TRANSACTION exchange we trigger the Start
message when a virtual IP is assigned to a client.

With this the charon.plugins.eap-radius.accounting_requires_vip option
would not have any effect for IKEv1 anymore.  However, it previously also
only worked if the client did an XAuth exchange, which is probably
rarely used without virtual IPs, so this might not be much of a
regression.

Fixes #937.

9 years agotesting: Update AAA certificate on Freeradius as well
Andreas Steffen [Wed, 5 Aug 2015 08:01:21 +0000 (10:01 +0200)] 
testing: Update AAA certificate on Freeradius as well

9 years agotesting: Updated expired AAA server certificate
Andreas Steffen [Tue, 4 Aug 2015 19:50:01 +0000 (21:50 +0200)] 
testing: Updated expired AAA server certificate

9 years agoconfigure: Explicitly disable unused parameter warnings in qsort_r test
Tobias Brunner [Tue, 4 Aug 2015 17:08:30 +0000 (19:08 +0200)] 
configure: Explicitly disable unused parameter warnings in qsort_r test

When compiling with -Wextra (and without disabling these warnings
globally) the tests would otherwise fail due to the unused arguments in
the cmp() functions.

Fixes #1053.

9 years agoprintf-hook-builtin: Fix invalid memory access
Tobias Brunner [Mon, 27 Jul 2015 09:18:53 +0000 (11:18 +0200)] 
printf-hook-builtin: Fix invalid memory access

When precision is given for a string, we must not run unbounded
strlen() as it will read beyond the given length. It might even cause
a crash if the given pointer is near end of heap or mapping.

Fixes numerous valgrind errors such as:

==19215== Invalid read of size 1
==19215==    at 0x52D36C6: builtin_vsnprintf (printf_hook_builtin.c:853)
==19215==    by 0x52D40A8: builtin_snprintf (printf_hook_builtin.c:1084)
==19215==    by 0x52CE464: dntoa (identification.c:337)
==19215==    by 0x52CE464: identification_printf_hook (identification.c:837)
==19215==    by 0x52D3DAA: builtin_vsnprintf (printf_hook_builtin.c:1010)
==19215==    by 0x57040EB: vlog (bus.c:388)
==19215==    by 0x570427D: log_ (bus.c:430)
==19215==    by 0xA8445D3: load_x509_ca (stroke_cred.c:416)
==19215==    by 0xA8445D3: load_certdir (stroke_cred.c:537)
==19215==    by 0xA846A95: load_certs (stroke_cred.c:1353)
==19215==    by 0xA846A95: stroke_cred_create (stroke_cred.c:1475)
==19215==    by 0xA84073E: stroke_socket_create (stroke_socket.c:782)
==19215==    by 0xA83F27C: register_stroke (stroke_plugin.c:53)
==19215==    by 0x52C3125: load_feature (plugin_loader.c:716)
==19215==    by 0x52C3125: load_provided (plugin_loader.c:778)
==19215==    by 0x52C3A20: load_features (plugin_loader.c:799)
==19215==    by 0x52C3A20: load_plugins (plugin_loader.c:1159)
==19215==  Address 0x50cdb42 is 0 bytes after a block of size 2 alloc'd
==19215==    at 0x4C919FE: malloc (vg_replace_malloc.c:296)
==19215==    by 0x52CD198: chunk_printable (chunk.c:759)
==19215==    by 0x52CE442: dntoa (identification.c:334)
==19215==    by 0x52CE442: identification_printf_hook (identification.c:837)
==19215==    by 0x52D3DAA: builtin_vsnprintf (printf_hook_builtin.c:1010)
==19215==    by 0x57040EB: vlog (bus.c:388)
==19215==    by 0x570427D: log_ (bus.c:430)
==19215==    by 0xA8445D3: load_x509_ca (stroke_cred.c:416)
==19215==    by 0xA8445D3: load_certdir (stroke_cred.c:537)
==19215==    by 0xA846A95: load_certs (stroke_cred.c:1353)
==19215==    by 0xA846A95: stroke_cred_create (stroke_cred.c:1475)
==19215==    by 0xA84073E: stroke_socket_create (stroke_socket.c:782)
==19215==    by 0xA83F27C: register_stroke (stroke_plugin.c:53)
==19215==    by 0x52C3125: load_feature (plugin_loader.c:716)
==19215==    by 0x52C3125: load_provided (plugin_loader.c:778)
==19215==    by 0x52C3A20: load_features (plugin_loader.c:799)
==19215==    by 0x52C3A20: load_plugins (plugin_loader.c:1159)

9 years agokernel-netlink: Use PAGE_SIZE as default size for the netlink receive buffer
Tobias Brunner [Thu, 16 Jul 2015 09:50:22 +0000 (11:50 +0200)] 
kernel-netlink: Use PAGE_SIZE as default size for the netlink receive buffer

The kernel uses NLMSG_GOODSIZE as default buffer size, which defaults to
the PAGE_SIZE if it is lower than 8192 or to that value otherwise.

In some cases (e.g. for dump messages) the kernel might use up to 16k
for messages, which might require increasing this value.

9 years agokernel-netlink: Actually verify if the netlink message exceeds the buffer size
Tobias Brunner [Thu, 16 Jul 2015 09:43:44 +0000 (11:43 +0200)] 
kernel-netlink: Actually verify if the netlink message exceeds the buffer size

It might equal it and that's fine. With MSG_TRUNC we get the actual
message size and can only report an error if we haven't received the
complete message.

9 years agoha: Properly initialize algo variables when installing CHILD_SAs
Tobias Brunner [Mon, 3 Aug 2015 11:30:11 +0000 (13:30 +0200)] 
ha: Properly initialize algo variables when installing CHILD_SAs

If AEAD algorithms are used no integrity algorithm will be received from
the other HA node.  But since AUTH_UNDEFINED is 1024 and not 0 this value
was incorrectly added to the proposal, resulting in a failure during key
derivation.  The variables are now explicitly initialized to 0, as already
was the case for the IKE SAs.

Fixes #1051.

9 years agoha: Sync remote address in HA_IKE_ADD, too
Thomas Egerer [Fri, 24 Apr 2015 11:43:18 +0000 (13:43 +0200)] 
ha: Sync remote address in HA_IKE_ADD, too

When the IKE_SA is synced without the remote address, after a
reauthentication charon is not able to find it in its connected_peers
table since the destination host will be %any (it's missing in the
message, hence the default from the newly created ike_sa_t -- %any --
will be used).
By adding the value to the HA_IKE_ADD message, we should be able to
solve this problem.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
9 years agojobs: Don't execute rekey CHILD_SA job on passive IKE_SAs
Thomas Egerer [Fri, 24 Apr 2015 11:43:14 +0000 (13:43 +0200)] 
jobs: Don't execute rekey CHILD_SA job on passive IKE_SAs

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
9 years agoike: Disable NAT keepalives in state PASSIVE
Thomas Egerer [Fri, 24 Apr 2015 11:43:11 +0000 (13:43 +0200)] 
ike: Disable NAT keepalives in state PASSIVE

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
9 years agotesting: Don't run do-tests when hosts are not running
Tobias Brunner [Mon, 3 Aug 2015 11:34:05 +0000 (13:34 +0200)] 
testing: Don't run do-tests when hosts are not running

running_any is satisfied if at least one host is running.  We could
easily add a running_all() helper to check if all hosts are running if
it turns out that's not strong enough.

9 years agotesting: Suppress errors when checking for running hosts
Tobias Brunner [Mon, 3 Aug 2015 10:54:09 +0000 (12:54 +0200)] 
testing: Suppress errors when checking for running hosts

If libvirt is not running virsh can't connect to it and will complain that
the socket does not exist.

9 years agoVersion bump to 5.3.3dr3
Andreas Steffen [Fri, 31 Jul 2015 15:47:14 +0000 (17:47 +0200)] 
Version bump to 5.3.3dr3

9 years agotesting: Adapted ha/both-active scenario to new jhash values
Andreas Steffen [Fri, 31 Jul 2015 12:43:40 +0000 (14:43 +0200)] 
testing: Adapted ha/both-active scenario to new jhash values

9 years agotesting: Fix initial kernel build
Tobias Brunner [Fri, 31 Jul 2015 10:22:55 +0000 (12:22 +0200)] 
testing: Fix initial kernel build

The directory does not exist yet if the kernel was never built.

Fixes: a4a13d0be29b ("testing: Extract and patch each kernel version only once")
9 years agoha: Use the same init values for jhash() as Linux 4.1
Tobias Brunner [Wed, 29 Jul 2015 15:04:33 +0000 (17:04 +0200)] 
ha: Use the same init values for jhash() as Linux 4.1

9 years agokernel-netlink: Unlock mutex in del_policy() if mark can't be added to message
Tobias Brunner [Fri, 31 Jul 2015 09:20:24 +0000 (11:20 +0200)] 
kernel-netlink: Unlock mutex in del_policy() if mark can't be added to message

9 years agosql: Fix memory leak in SQL logger
Tobias Brunner [Tue, 28 Jul 2015 12:53:14 +0000 (14:53 +0200)] 
sql: Fix memory leak in SQL logger

9 years agoVersion bump to 5.3.3dr2
Andreas Steffen [Tue, 28 Jul 2015 12:28:13 +0000 (14:28 +0200)] 
Version bump to 5.3.3dr2

9 years agoandroid: New release fixing roaming on 5+ and adding new advanced options
Tobias Brunner [Tue, 28 Jul 2015 11:57:13 +0000 (13:57 +0200)] 
android: New release fixing roaming on 5+ and adding new advanced options

9 years agoMerge branch 'android-updates'
Tobias Brunner [Tue, 28 Jul 2015 11:29:03 +0000 (13:29 +0200)] 
Merge branch 'android-updates'

Fixes the roaming behavior on Android 5+, a linker issue on Android M,
a few bugs, and adds several new advanced options for VPN profile (MTU,
server port, split tunneling).

Also adds methods and a constructor to parse settings_t from a string
instead of a file.

Fixes #782, #847, #865.

9 years agoandroid: Keep NDK API level at 19
Tobias Brunner [Mon, 27 Jul 2015 15:46:06 +0000 (17:46 +0200)] 
android: Keep NDK API level at 19

The headers/libraries changed a lot with level 21 so that our app won't
run on devices with Android < 5 when built against it.  We currently
don't need any new native APIs so that should be fine.

9 years agoandroid: Apply split tunneling options when creating TUN device
Tobias Brunner [Fri, 24 Jul 2015 12:14:07 +0000 (14:14 +0200)] 
android: Apply split tunneling options when creating TUN device

Android blocks traffic for address families for which no IPs, DNS servers
or routes are installed via VpnService.Builder.  Since Android 5+ (API
level 21) it is possible to explicitly allow such traffic to bypass the VPN.

So for proper split tunneling we note whether we saw a VIP and/or DNS
server of a specific family, and if not, allow traffic of that family
to bypass the VPN using the new API (on older systems there is no change
and such traffic will still be blocked).  Otherwise, we do what we did so
far, that is, simply install the received routes (traffic selectors), all
other traffic will not be directed to the TUN device and use the underlying
network instead.

If traffic for a family should be blocked we install a default route via
TUN device even if we received more specific traffic selectors from the
server.  libipsec will use the actual traffic selectors as IPsec policies
and drop any packets it received that don't match them.  We only do this
if we saw any VIPs or DNS servers of a family.  Otherwise the traffic for
that family is blocked anyway.

9 years agoinclude: Remove linux/types.h header
Tobias Brunner [Tue, 21 Jul 2015 09:57:56 +0000 (11:57 +0200)] 
include: Remove linux/types.h header

This conflicts with the headers of the android-21 target.  Hopefully
headers on current Linux distros are recent enough.

9 years agoandroid: Build against the android-21 target
Tobias Brunner [Tue, 21 Jul 2015 09:37:33 +0000 (11:37 +0200)] 
android: Build against the android-21 target

9 years agoandroid: Extend GUI so the split tunneling options can be set
Tobias Brunner [Fri, 24 Jul 2015 09:47:53 +0000 (11:47 +0200)] 
android: Extend GUI so the split tunneling options can be set

9 years agoandroid: Add field for split tunneling config to data model
Tobias Brunner [Fri, 24 Jul 2015 09:33:07 +0000 (11:33 +0200)] 
android: Add field for split tunneling config to data model

9 years agoandroid: Retrigger a roam event if reportedly connected but no source address found
Tobias Brunner [Tue, 21 Jul 2015 09:14:53 +0000 (11:14 +0200)] 
android: Retrigger a roam event if reportedly connected but no source address found

In dual-stack environments the IPv6 connectivity (via autoconfiguration)
might be established before the IPv4 connectivity (via DHCP).  It seems
Android triggers the CONNECTIVITY_ACTION broadcast already when the first
family is fully configured.  At that time we might not be able to find an
IPv4 source address.  And since Android does not trigger the broadcast
again if IPv4 connectivity is established, the connection is broken
afterwards.

So we store the connectivity state and if we are reportedly connected but
still find no source address we trigger a roam event to recheck for an IPv4
address.  This will cause regular rechecks if a device enters an IPv6-only
network, but I guess that's rare (otherwise we could limit the number of
rechecks done between connectivity changes).

9 years agoandroid: Add method to check for connectivity to NetworkManager
Tobias Brunner [Tue, 21 Jul 2015 09:05:10 +0000 (11:05 +0200)] 
android: Add method to check for connectivity to NetworkManager

9 years agoandroid: Fix kernel-net implementation on Android 4.3 and earlier
Tobias Brunner [Mon, 22 Jun 2015 15:15:33 +0000 (17:15 +0200)] 
android: Fix kernel-net implementation on Android 4.3 and earlier

Before fwmarks were used protected sockets were bound to the outbound
interface via SO_BINDTODEVICE.  This does not always seem to work well
together with our connect()/getsockname() trick if the server is covered
by the traffic selectors.  Calling protect() again after disconnecting
the socket seems to help, but if there is no connectivity at all we still
get the virtual IP back (maybe protect() does not bind the socket to any
interface then).

9 years agoandroid: Add a custom kernel-net implementation to replace kernel-netlink
Tobias Brunner [Wed, 17 Jun 2015 15:21:21 +0000 (17:21 +0200)] 
android: Add a custom kernel-net implementation to replace kernel-netlink

When roaming from a mobile network to WiFi on Android 5.x the event
received via ConnectivityManager is triggered before the mobile
connection is fully torn down (i.e. before the interface is disabled and
the routes disappear).  So for strongSwan the current path still seems
valid and since no roam event is triggered later the daemon never switches
to WiFi and the connection is broken afterwards.

A possible solution to this is enabling roam events in the kernel-netlink
plugin.  That would trigger an event when the device is finally disconnected
from the mobile network.  However, this could actually take a some time,
during which traffic continues to be sent via mobile network instead of WiFi.
That's because Android now uses multiple routing tables, routing rules and
fwmarks to direct traffic to the appropriate interface/table, but in our
plugin we don't have the information available that would allow us to make
the switch to a different network/routing table earlier (and we actually
prefer the current path if it is still valid).  Additionally, the plugin
produces quite a bit more events than ConnectivityManager (which was one
of the reasons to use the latter in the first place).

This custom kernel-net implementation is now specifically tailored for
Android.  Roam events are still triggered via ConnectivityManager but
the source address is determined via connect()/getsockname() on a VPN
excluded UDP socket, which does use the correct routing table as intended
by Android.  That way the daemon immediately sees a different source IP
when connectivity changes even if the device is connected to multiple
networks concurrently.

9 years agoandroid: Manually load libraries with dlopen() and RTLD_GLOBAL on Android M
Tobias Brunner [Wed, 17 Jun 2015 13:31:24 +0000 (15:31 +0200)] 
android: Manually load libraries with dlopen() and RTLD_GLOBAL on Android M

This fixes an issue when using the Android M preview.  Bionic's dynamic
linker was changed so that symbols in libraries loaded with RTLD_LOCAL
were not found anymore in dlsym(RTLD_DEFAULT, ...).  This is the case
for libraries loaded with System.loadLibrary(), therefore, the plugin
loader in libstrongswan was not able to resolve any symbols defined in
other libraries loaded later.  While this seems to have been broken
unintentionally for existing apps (fix at [1]), it will again be a
problem whenever we decide to increase targetSdkVersion beyond 22 (or
until that fix makes it into the system/emulator images).

Unfortunately, the dynamic loader in releases prior to Android 4.3 can't
load libandroidbridge without also loading its dependencies.

[1] https://github.com/android/platform_bionic/commit/1913352c6b

9 years agoandroid: Apply configured server port
Tobias Brunner [Tue, 16 Jun 2015 14:44:29 +0000 (16:44 +0200)] 
android: Apply configured server port

9 years agoandroid: Extend GUI so the server port can be entered
Tobias Brunner [Tue, 16 Jun 2015 14:42:40 +0000 (16:42 +0200)] 
android: Extend GUI so the server port can be entered

9 years agoandroid: Add field for server port to data model
Tobias Brunner [Tue, 16 Jun 2015 14:39:08 +0000 (16:39 +0200)] 
android: Add field for server port to data model

9 years agoandroid: Apply configured MTU
Tobias Brunner [Tue, 16 Jun 2015 14:06:13 +0000 (16:06 +0200)] 
android: Apply configured MTU

While it is stored as property of individual profiles it is really a
global setting because we currently don't support more than one
connection.

9 years agoandroid: Extend GUI so the MTU can be entered
Tobias Brunner [Mon, 15 Jun 2015 14:59:12 +0000 (16:59 +0200)] 
android: Extend GUI so the MTU can be entered

This also adds a new area for advanced settings that is only displayed
if the user requests it (or if advanced settings already have been set).

The min. MTU for IPv6 is 1280, anything lower lets the TUN device
creation fail if an IPv6 address has been assigned.  If lower MTUs are
necessary we might be able to catch that later when setting the MTU and
just use at least 1280 if an IPv6 address was assigned, but let's keep
it simple for now.

9 years agoandroid: Add field for MTU to data model
Tobias Brunner [Mon, 15 Jun 2015 13:36:46 +0000 (15:36 +0200)] 
android: Add field for MTU to data model

9 years agoandroid: Set preferred language for remediation instructions
Tobias Brunner [Fri, 12 Jun 2015 12:14:46 +0000 (14:14 +0200)] 
android: Set preferred language for remediation instructions

9 years agoandroid: Encode connection settings as single Java string argument
Tobias Brunner [Wed, 10 Jun 2015 12:59:48 +0000 (14:59 +0200)] 
android: Encode connection settings as single Java string argument

This makes adding new configuration settings easier.

9 years agoandroid: Add simple utility class to generate settings_t compatible config snippets
Tobias Brunner [Fri, 5 Jun 2015 14:01:31 +0000 (16:01 +0200)] 
android: Add simple utility class to generate settings_t compatible config snippets

9 years agounit-tests: Add unit tests for settings_t.load_string[_section]
Tobias Brunner [Thu, 23 Oct 2014 15:03:52 +0000 (17:03 +0200)] 
unit-tests: Add unit tests for settings_t.load_string[_section]

9 years agosettings: Add methods and a constructor to parse settings from strings
Tobias Brunner [Thu, 23 Oct 2014 14:57:47 +0000 (16:57 +0200)] 
settings: Add methods and a constructor to parse settings from strings

9 years agosettings: Extend parser so we can parse settings from a string
Tobias Brunner [Thu, 23 Oct 2014 14:57:24 +0000 (16:57 +0200)] 
settings: Extend parser so we can parse settings from a string

9 years agostarter: Add support for multi-line strings in ipsec.conf
Tobias Brunner [Mon, 8 Jun 2015 15:49:02 +0000 (17:49 +0200)] 
starter: Add support for multi-line strings in ipsec.conf

9 years agosettings: Add support for multi-line strings
Tobias Brunner [Mon, 8 Jun 2015 15:47:51 +0000 (17:47 +0200)] 
settings: Add support for multi-line strings

Unterminated strings are now an error.

9 years agostarter: Don't replace rarely used special characters in strings in ipsec.conf
Tobias Brunner [Fri, 5 Jun 2015 13:49:39 +0000 (15:49 +0200)] 
starter: Don't replace rarely used special characters in strings in ipsec.conf

9 years agosettings: Don't replace rarely used special characters
Tobias Brunner [Fri, 5 Jun 2015 13:42:58 +0000 (15:42 +0200)] 
settings: Don't replace rarely used special characters

9 years agoandroid: Don't pass null as root view to inflate()
Tobias Brunner [Mon, 22 Jun 2015 15:26:10 +0000 (17:26 +0200)] 
android: Don't pass null as root view to inflate()

9 years agoandroid: Fix a potential NullPointerException in the IMC state fragment
Tobias Brunner [Mon, 22 Jun 2015 15:22:05 +0000 (17:22 +0200)] 
android: Fix a potential NullPointerException in the IMC state fragment

9 years agoandroid: EAP-TNC does not require a client certificate
Tobias Brunner [Fri, 12 Jun 2015 13:13:46 +0000 (15:13 +0200)] 
android: EAP-TNC does not require a client certificate

Was incorrectly changed with the refactoring in a64089738d3e ("android:
Change how features of VPN types are stored and checked").

9 years agoandroid: Enable charon.initiator_only option
Tobias Brunner [Thu, 4 Jun 2015 08:35:03 +0000 (10:35 +0200)] 
android: Enable charon.initiator_only option

9 years agoandroid: Increase the minSdkVersion to 15 and targetSdkVersion to 22
Tobias Brunner [Wed, 10 Jun 2015 13:13:49 +0000 (15:13 +0200)] 
android: Increase the minSdkVersion to 15 and targetSdkVersion to 22

There are no devices anymore that use API level 14 (4.0-4.0.2) and 22 is
the most recent level.

9 years agotesting: Regenerated BLISS certificates due to oracle changes
Andreas Steffen [Mon, 27 Jul 2015 17:51:18 +0000 (19:51 +0200)] 
testing: Regenerated BLISS certificates due to oracle changes

9 years agoUse MGF1 with SHA-512 as BLISS random oracle
Andreas Steffen [Mon, 27 Jul 2015 12:50:14 +0000 (14:50 +0200)] 
Use MGF1 with SHA-512 as BLISS random oracle

9 years agoGeneralize c_indices generation using SHA-512 random oracle.
Markku-Juhani Olavi Saarinen [Thu, 18 Jun 2015 10:46:16 +0000 (12:46 +0200)] 
Generalize c_indices generation using SHA-512 random oracle.

This generalization allows the ring dimension n to be different
from the current n = 512 and allows kappa to be > 56. Also the
hash octets are consumed in a more consistent manner.

9 years agoFixed several bugs in the BLISS signature generation/verification step.
Markku-Juhani Olavi Saarinen [Wed, 17 Jun 2015 10:00:32 +0000 (12:00 +0200)] 
Fixed several bugs in the BLISS signature generation/verification step.

The c_indices derived from the SHA-512 random oracle consist of
nine bits (0..511). The leftmost 8 bits of each index are taken
on an octet-by-octet basis from the 56 leftmost octets of the
SHA-512 hash. The 9th bit needed for the LSB is taken from the
extra_bits 64 bit unsigned integer which consists of the 8 rightmost
octets of the SHA-512 hash (in network order). If more than 56
indices must be derived then additional rounds of the random oracle
are executed until all kappa c_indices have been determined.

The bug fix shifts the extra_bits value by one bit in each loop
iteration so that the LSB of each index is random. Also iterate
through the hash array using the loop variable j not the c_indices
variable i.

9 years agoike: Fix memory leak if remote address is kept
Tobias Brunner [Mon, 27 Jul 2015 17:37:41 +0000 (19:37 +0200)] 
ike: Fix memory leak if remote address is kept

9 years agoike-rekey: Fix cleanup() call
Tobias Brunner [Mon, 27 Jul 2015 13:20:01 +0000 (15:20 +0200)] 
ike-rekey: Fix cleanup() call

9 years agoike-rekey: Reset IKE_SA on bus before sending CREATE_CHILD_SA response
Tobias Brunner [Mon, 15 Jun 2015 09:52:16 +0000 (11:52 +0200)] 
ike-rekey: Reset IKE_SA on bus before sending CREATE_CHILD_SA response

Even when there is no error the CREATE_CHILD_SA response should be sent
in the context of the existing IKE_SA.

9 years agoike-rekey: Reset IKE_SA on the bus after destroying new IKE_SA
Tobias Brunner [Mon, 15 Jun 2015 09:46:33 +0000 (11:46 +0200)] 
ike-rekey: Reset IKE_SA on the bus after destroying new IKE_SA

The destroy() method sets the IKE_SA on the bus to NULL, we reset it to
the current IKE_SA so any events and log messages that follow happen in
the correct context.

A practical example where this is problematic is a DH group mismatch,
which causes the first CREATE_CHILD_SA exchange to fail.  Because the SA
was not reset previously, the message() hook for the CREATE_CHILD_SA
response, for instance, was triggered outside the context of an IKE_SA,
that is, the ike_sa parameter was NULL, which is definitely not expected
by several plugins.

Fixes #862.

9 years agoMerge branch 'trap-shunt-updates'
Tobias Brunner [Mon, 27 Jul 2015 12:00:23 +0000 (14:00 +0200)] 
Merge branch 'trap-shunt-updates'

Changes how acquires are tracked in the trap manager, which fixes
several race conditions.  Also fixes races between threads installing
trap policies and the main thread trying to flush the trap policies.
Similar changes were added to the shunt manager which previously
used no locking at all.

Fixes #1014.

9 years agodaemon: Flush shunts before unloading plugins
Tobias Brunner [Tue, 14 Jul 2015 14:56:33 +0000 (16:56 +0200)] 
daemon: Flush shunts before unloading plugins

9 years agoshunt-manager: Add flush() method to properly uninstall shunts
Tobias Brunner [Tue, 14 Jul 2015 14:55:36 +0000 (16:55 +0200)] 
shunt-manager: Add flush() method to properly uninstall shunts

This will allow us to uninstall shunts before unloading the
kernel-interface plugins.

9 years agoshunt-manager: Remove stored entries if installation fails
Tobias Brunner [Tue, 14 Jul 2015 14:50:32 +0000 (16:50 +0200)] 
shunt-manager: Remove stored entries if installation fails

9 years agoshunt-manager: Add a lock to safely access the list of shunt policies
Tobias Brunner [Tue, 14 Jul 2015 14:35:21 +0000 (16:35 +0200)] 
shunt-manager: Add a lock to safely access the list of shunt policies

9 years agotrap-manager: Resolve race conditions between flush() and install()
Tobias Brunner [Mon, 13 Jul 2015 11:20:14 +0000 (13:20 +0200)] 
trap-manager: Resolve race conditions between flush() and install()

When flush() is called there might be threads in install() waiting for
trap policies to get installed (without holding the lock).  We have to
wait until they updated the entries with the respective CHILD_SAs before
destroying the list.

We also have to prevent further trap policy installations (and wait until
threads in install() are really finished), otherwise we might end up
destroying CHILD_SA objects after the kernel interface implementations
have already been unloaded (avoiding this is the whole point of calling
flush() before unloading the plugins).