Commit Graph

11567 Commits

Author SHA1 Message Date
Tobias Brunner 4de361d92c ikev1: Fix handling of overlapping Quick Mode exchanges
In some cases the third message of a Quick Mode exchange might arrive
after the first message of a subsequent Quick Mode exchange.  Previously
these messages were handled incorrectly and the second Quick Mode
exchange failed.

Some implementations might even try to establish multiple Quick Modes
simultaneously, which is explicitly allowed in RFC 2409.  We don't fully
support that, though, in particular in case of retransmits.

Fixes #1076.
2015-08-20 19:13:45 +02:00
Tobias Brunner e2a252a86f kernel-pfkey: Add support for AES-GCM
The next release of FreeBSD will support this.

While Linux defines constants for AES-GCM in pfkeyv2.h since 2.6.25 it
does not actually support it.  When SAs are installed via PF_KEY only a
lookup in XFRM's list of encryption algorithms is done, but AES-GCM is in
a different table for AEAD algorithms (there is currently no lookup
function to find algorithms in that table via PF_KEY identifier).
2015-08-20 18:55:45 +02:00
Tobias Brunner e79b0e07e4 auth-cfg: Don't enforce EAP_DYNAMIC
We now store the actual method on the auth config, which won't match
anymore if rightauth=eap-dynamic is configured.
2015-08-20 18:38:16 +02:00
Tobias Brunner 5fee79d854 ikev2: Compare initiator flag again, partially reverts 17ec1c74de
We should ignore messages that have the flag set incorrectly.
This restores RFC compliance which was broken since the mentioned commit.
2015-08-20 16:58:09 +02:00
Tobias Brunner 47a340e1f7 ikev2: Drop IKE_SA_INIT messages that don't have the initiator flag set
While this doesn't really create any problems it is not 100% correct to
accept such messages because, of course, the sender of an IKE_SA_INIT
request is always the original initiator of an IKE_SA.

We currently don't check the flag later, so we wouldn't notice if the
peer doesn't set it in later messages (ike_sa_id_t.equals doesn't
compare it anymore since we added support for IKEv1, in particular since
17ec1c74de).
2015-08-20 16:05:02 +02:00
Tobias Brunner 47ee60177e ikev1: Pass current auth-cfg when looking for key to determine auth method
If multiple certificates use the same subjects we might choose the wrong
one otherwise. This way we use the one referenced with leftcert and
stored in the auth-cfg and we actually do the same thing later in the
pubkey authenticator.

Fixes #1077.
2015-08-19 17:39:01 +02:00
Tobias Brunner 49a20ef019 ikev2: Store outer EAP method used to authenticate remote peer in auth-cfg
This allows symmetric configuration of EAP methods (i.e. the same value
in leftauth and rightauth) when mutual EAP-only authentication is used.
Previously the client had to configure rightauth=eap or rightauth=any,
which prevented it from using this same config as responder.
2015-08-19 16:19:05 +02:00
Tobias Brunner 64bef354d4 imc: get_default_pwd_status(), as it currently is, works on Windows too
This fixes the build on Windows.
2015-08-19 12:10:09 +02:00
Tobias Brunner 2d14cb4d6c ike: Use the original port when remote resolves to %any
When reestablishing the IKE_SA we should still use the original port
when right resolves to %any as some implementations might not like
initial IKE messages on port 4500 (especially for IKEv1).
2015-08-19 11:34:25 +02:00
Tobias Brunner 301a0bad09 trap-manager: Enable auto=route with right=%any for transport mode connections
Fixes #196.
2015-08-19 11:31:58 +02:00
Andreas Steffen b19ef52d51 Added reason string support to HCD IMV 2015-08-18 21:25:39 +02:00
Andreas Steffen 627e4b9659 Fixed patches format delimited by CR/LF 2015-08-18 21:25:39 +02:00
Andreas Steffen 18472ac21c Use PWG HCD PA-TNC subtypes to transport HCD attributes 2015-08-18 21:25:39 +02:00
Andreas Steffen 6b68719dd3 Add default password determination capability to os_info 2015-08-18 21:25:39 +02:00
Andreas Steffen 9e13c2b2cc Reintroduced ietf_attr_fwd_enabled() 2015-08-18 21:25:39 +02:00
Andreas Steffen 860df6bf75 Defined PWG HCD PA-TNC subtypes 2015-08-18 21:25:39 +02:00
Andreas Steffen 9c2e0a50a3 Added os_info support to HCD IMC 2015-08-18 21:25:38 +02:00
Andreas Steffen 9e88bb987d Subscribed Scanner IMC/IMV to IETF_FIREWALL PA subtype 2015-08-18 21:25:38 +02:00
Andreas Steffen b48ffcb1b3 Implemented HCD IMC and IMV 2015-08-18 21:25:38 +02:00
Andreas Steffen 92a9c99c38 Defined HCD PA subtype in PWG namespace 2015-08-18 21:25:38 +02:00
Andreas Steffen 21b8051c10 Completed implementation of PWG HCD attributes 2015-08-18 21:25:38 +02:00
Andreas Steffen 981653a437 Defined generic non-nul terminated string PA-TNC attribute 2015-08-18 21:25:38 +02:00
Andreas Steffen 6a11c8a3f3 Support of HCD Firewall Setting PA-TNC attribute 2015-08-18 21:25:38 +02:00
Andreas Steffen abb8a1ecd2 Defined generic boolean PA-TNC attribute 2015-08-18 21:25:38 +02:00
Andreas Steffen 5e1b06ff08 Defined PWG HCD IF-M attributes 2015-08-18 21:25:38 +02:00
Andreas Steffen 10f25a3dd9 Fixed the implemention of the IF-M segmentation protocol
The first segment only fit if the segmentation envelope attribute
was preceded by a Max Attribute Size Response attribute. The
improved implementation fills up the first PA-TNC message with
the first segment up to the maximum message size.
2015-08-18 21:24:26 +02:00
Tobias Brunner 6bd1216e7a kernel-netlink: Avoid route dump if routing rule excludes traffic with a certain mark
If the routing rule we use to direct traffic to our own routing table
excludes traffic with a certain mark (fwmark = !<mark>) we can simplify
the route lookup and avoid dumping all routes by passing the mark to the
request.  That way our own routes are ignored and we get the preferred
route back without having to dump and analyze all routes, which is quite a
burden on hosts with lots of routes.
2015-08-18 12:06:08 +02:00
Tobias Brunner 7ff7ce3ed6 include: Update (rt)netlink.h to the latest UAPI version 2015-08-18 12:06:08 +02:00
Tobias Brunner 6927d6224e sql: Also do a reversed ID match
This is required for the case where IDr is not sent (i.e. is %any).
The backend manager does the same.

Fixes #1044.
2015-08-17 18:58:14 +02:00
Tobias Brunner fffee7c759 ha: Recreate the control FIFO if the file exists but is not a FIFO
This may happen if something like `echo ... > /path/to/fifo` is used
before the plugin was able to create the FIFO. In that case we'd end
up in a loop always reading the same values from the static file.
2015-08-17 17:51:20 +02:00
Tobias Brunner 636b2e9b2a ikev1: Assume a default key length of 128-bit for AES-CBC
Some implementations don't send a Key Length attribute for AES-128.
This was allowed for IKE in early drafts of RFC 3602, however, some
implementations also seem to do it for ESP, where it never was allowed.
And the final version of RFC 3602 demands a Key Length attribute for both
phases so they shouldn't do it anymore anyway.

Fixes #1064.
2015-08-17 17:13:50 +02:00
Tobias Brunner 774c8c3847 auth-cfg: Matching one CA should be enough, similar to peer certificates
Not sure if defining multiple CA constraints and enforcing _all_ of them,
i.e. the previous behavior, makes even sense.  To ensure a very specific
chain it should be enough to define the last intermediate CA.  On the
other hand, the ability to define multiple CAs could simplify configuration.

This can currently only be used with swanctl/VICI based configs as `rightca`
only takes a single DN.
2015-08-17 14:04:19 +02:00
Tobias Brunner 9322e5b398 vici: Add option to disable policy installation for CHILD_SAs 2015-08-17 12:01:36 +02:00
Tobias Brunner 3665adef19 child-sa: Fix refcounting of allocated reqids
During a rekeying we want to reuse the current reqid, but if the new SA
does not allocate it via kernel-interface the state there will disappear
when the old SA is destroyed after the rekeying.  When the IKE_SA is
later reauthenticated with make-before-break reauthentication the new
CHILD_SAs there will get new reqids as no existing state is found in the
kernel-interface, breaking policy installation in the kernel.

Fixes: a49393954f ("child-sa: Use any fixed reqid configured on the CHILD_SA config")
2015-08-17 11:59:15 +02:00
Tobias Brunner 017dbb1c5e identification: Remove unused ID_USER_ID type 2015-08-17 11:49:12 +02:00
Tobias Brunner 6ef4668626 pki: Add --dn command to extract the subject DN of a certificate 2015-08-17 11:34:01 +02:00
Tobias Brunner d6f70ff689 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.
2015-08-17 11:28:08 +02:00
Tobias Brunner 39afe6e9d0 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.
2015-08-17 11:23:41 +02:00
Tobias Brunner ec490e68ae eap-radius: Add support for some basic IPv6-specific RADIUS attributes
These are defined in RFC 6911.

Fixes #1001.
2015-08-17 11:23:33 +02:00
Tobias Brunner 6d9cd1d66b 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().
2015-08-17 11:19:48 +02:00
Tobias Brunner f25f4192c7 utils: Directly use syscall() to close open FDs in closefrom()
This avoids any allocations, since calling malloc() after fork() is
potentially unsafe.

Fixes #990.
2015-08-17 11:19:44 +02:00
Tobias Brunner b410d7f8ff 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.
2015-08-17 11:19:32 +02:00
Tobias Brunner b3d91cc64e vici: Add listen methods to receive arbitrary events in Python library 2015-08-17 11:12:18 +02:00
Tobias Brunner cf4cefee42 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().
2015-08-17 11:12:17 +02:00
Tobias Brunner 65ac0851c0 vici: Add ike/child-rekey events 2015-08-17 11:12:17 +02:00
Tobias Brunner 7f21363ee5 vici: Document the ike/child-updown events 2015-08-17 11:12:17 +02:00
Tobias Brunner 22842cce0d 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).
2015-08-17 11:12:17 +02:00
Tobias Brunner 085b8f4fb0 vici: Explicitly notify listeners of the type of ike/child-updown event 2015-08-17 11:12:12 +02:00
Andreas Steffen a330f72ecf Fixed AR identities in mutual TNC measurements case 2015-08-15 22:46:21 +02:00
Tobias Brunner df085a158a kernel-pfroute: Don't install virtual IPs if charon.install_virtual_ip is disabled 2015-08-13 15:52:50 +02:00
Tobias Brunner 98c09357d5 load-tester: Include string.h for strcmp() on some platforms 2015-08-13 15:12:42 +02:00
Tobias Brunner 6967948241 Initialize variables that some compilers seem to warn about 2015-08-13 15:12:38 +02:00
Tobias Brunner f809e485fb Fixed some typos 2015-08-13 15:12:34 +02:00
Tobias Brunner dc2fa791e4 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.
2015-08-13 10:49:16 +02:00
Tobias Brunner 695112d7b8 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.
2015-08-13 10:49:16 +02:00
Tobias Brunner 1bc2549914 pki: Optionally extract public key from given private key in --issue
Fixes #618.
2015-08-10 12:33:02 +02:00
Tobias Brunner 9593b57ca3 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).
2015-08-06 17:25:07 +02:00
Tobias Brunner 6fe8fe0cfd 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.
2015-08-06 17:24:04 +02:00
Tobias Brunner 520fba4899 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.
2015-08-06 17:22:32 +02:00
Tobias Brunner b2efc61818 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 a81bd670b0 ("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.
2015-08-06 17:15:25 +02:00
Tobias Brunner 1de31bcc2b updown: Pass virtual IPs assigned to a peer to the updown script
Previously only received virtual IPs were available.

References #1008.
2015-08-06 16:30:08 +02:00
Tobias Brunner d04b093374 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.
2015-08-06 14:57:47 +02:00
Tobias Brunner 186d25cbe6 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.
2015-08-06 14:57:26 +02:00
Tobias Brunner 7be8965225 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)
2015-08-04 14:19:26 +02:00
Tobias Brunner 197de6e66b 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.
2015-08-04 14:15:19 +02:00
Tobias Brunner a6896b6149 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.
2015-08-04 14:15:18 +02:00
Tobias Brunner a7f381ef00 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.
2015-08-04 11:23:27 +02:00
Thomas Egerer 3434709460 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>
2015-08-04 11:21:54 +02:00
Thomas Egerer e095d87bb6 jobs: Don't execute rekey CHILD_SA job on passive IKE_SAs
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2015-08-04 11:16:13 +02:00
Thomas Egerer edaba56ec7 ike: Disable NAT keepalives in state PASSIVE
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2015-08-04 11:16:13 +02:00
Tobias Brunner 93caf23e1b ha: Use the same init values for jhash() as Linux 4.1 2015-07-31 12:34:44 +02:00
Tobias Brunner 1ce32c9cdc kernel-netlink: Unlock mutex in del_policy() if mark can't be added to message 2015-07-31 11:20:24 +02:00
Tobias Brunner 36bc52b441 sql: Fix memory leak in SQL logger 2015-07-28 15:35:11 +02:00
Tobias Brunner 1d3e69c6da android: New release fixing roaming on 5+ and adding new advanced options 2015-07-28 13:57:13 +02:00
Tobias Brunner 1e323dc1b7 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.
2015-07-28 13:27:34 +02:00
Tobias Brunner acc8948fa5 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.
2015-07-28 13:27:34 +02:00
Tobias Brunner 3390092c76 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.
2015-07-28 13:27:34 +02:00
Tobias Brunner bb40498df3 android: Build against the android-21 target 2015-07-28 13:27:34 +02:00
Tobias Brunner 3ee84fa976 android: Extend GUI so the split tunneling options can be set 2015-07-28 13:27:33 +02:00
Tobias Brunner f3d8da7644 android: Add field for split tunneling config to data model 2015-07-28 13:27:33 +02:00
Tobias Brunner 030bcee1b0 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).
2015-07-28 13:27:33 +02:00
Tobias Brunner 41b59a3443 android: Add method to check for connectivity to NetworkManager 2015-07-28 13:27:33 +02:00
Tobias Brunner 5da31733de 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).
2015-07-28 13:27:33 +02:00
Tobias Brunner 1082372448 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.
2015-07-28 13:27:33 +02:00
Tobias Brunner 69e0215b9d 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
2015-07-28 13:27:33 +02:00
Tobias Brunner cda167c8c4 android: Apply configured server port 2015-07-28 13:27:33 +02:00
Tobias Brunner 6c0ec35c53 android: Extend GUI so the server port can be entered 2015-07-28 13:27:33 +02:00
Tobias Brunner 5b11855f26 android: Add field for server port to data model 2015-07-28 13:27:33 +02:00
Tobias Brunner 4d02c49ead 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.
2015-07-28 13:27:33 +02:00
Tobias Brunner c682205113 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.
2015-07-28 13:27:32 +02:00
Tobias Brunner 7e2a6c4a41 android: Add field for MTU to data model 2015-07-28 13:27:32 +02:00
Tobias Brunner 6830cb1c1b android: Set preferred language for remediation instructions 2015-07-28 13:27:32 +02:00
Tobias Brunner 79af70c66e android: Encode connection settings as single Java string argument
This makes adding new configuration settings easier.
2015-07-28 13:27:32 +02:00
Tobias Brunner fd16adb765 android: Add simple utility class to generate settings_t compatible config snippets 2015-07-28 13:27:32 +02:00
Tobias Brunner d29a4a5e20 unit-tests: Add unit tests for settings_t.load_string[_section] 2015-07-28 13:27:32 +02:00
Tobias Brunner 08b45fc516 settings: Add methods and a constructor to parse settings from strings 2015-07-28 13:27:32 +02:00
Tobias Brunner 0dba2690c4 settings: Extend parser so we can parse settings from a string 2015-07-28 13:27:32 +02:00
Tobias Brunner 019ebdafae starter: Add support for multi-line strings in ipsec.conf 2015-07-28 13:27:32 +02:00
Tobias Brunner 764960e8b9 settings: Add support for multi-line strings
Unterminated strings are now an error.
2015-07-28 13:27:32 +02:00
Tobias Brunner d918410add starter: Don't replace rarely used special characters in strings in ipsec.conf 2015-07-28 13:27:32 +02:00
Tobias Brunner 9577b2d148 settings: Don't replace rarely used special characters 2015-07-28 13:27:31 +02:00
Tobias Brunner 41594a7bb7 android: Don't pass null as root view to inflate() 2015-07-28 13:27:31 +02:00
Tobias Brunner 16e9efc092 android: Fix a potential NullPointerException in the IMC state fragment 2015-07-28 13:27:31 +02:00
Tobias Brunner 4dc6275be5 android: EAP-TNC does not require a client certificate
Was incorrectly changed with the refactoring in a64089738d ("android:
Change how features of VPN types are stored and checked").
2015-07-28 13:27:31 +02:00
Tobias Brunner 9d957bacfc android: Enable charon.initiator_only option 2015-07-28 13:27:31 +02:00
Tobias Brunner 5f613590b0 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.
2015-07-28 13:27:31 +02:00
Andreas Steffen e57190c312 Use MGF1 with SHA-512 as BLISS random oracle 2015-07-27 22:09:08 +02:00
Markku-Juhani Olavi Saarinen 7b7c510eec 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.
2015-07-27 19:51:51 +02:00
Markku-Juhani Olavi Saarinen 68d8a16830 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.
2015-07-27 19:51:50 +02:00
Tobias Brunner faebdeac8e ike: Fix memory leak if remote address is kept 2015-07-27 19:38:59 +02:00
Tobias Brunner 81f1aa8dc3 ike-rekey: Fix cleanup() call 2015-07-27 15:20:01 +02:00
Tobias Brunner 2efcc95867 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.
2015-07-27 14:45:00 +02:00
Tobias Brunner 86d20b0b40 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.
2015-07-27 14:44:32 +02:00
Tobias Brunner c04345d5ed daemon: Flush shunts before unloading plugins 2015-07-27 13:51:17 +02:00
Tobias Brunner bc36530670 shunt-manager: Add flush() method to properly uninstall shunts
This will allow us to uninstall shunts before unloading the
kernel-interface plugins.
2015-07-27 13:51:10 +02:00
Tobias Brunner 616ff9a236 shunt-manager: Remove stored entries if installation fails 2015-07-27 13:51:07 +02:00
Tobias Brunner f3d39666e0 shunt-manager: Add a lock to safely access the list of shunt policies 2015-07-27 13:50:52 +02:00
Tobias Brunner 12b3cdba76 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).
2015-07-27 13:50:19 +02:00
Tobias Brunner a229bdce62 trap-manager: Changed how acquires we acted on are tracked
This fixes potential race conditions in case complete() or flush() is
executed before or concurrently with a thread that handles an acquire.
It will also simplify tracking multiple acquires created for the same
trap policy in the future.

Also fixes the behavior in some error situations.
2015-07-27 13:50:09 +02:00
Tobias Brunner 773fcb1605 trap-manager: Properly check-in IKE_SA if initiating fails
This basically reverts f4e822c1b4 ("trap-manager: don't check-in
nonexisting IKE_SA if acquire fails").  As checkout_by_config() could
return an already existing and established IKE_SA we have to properly
destroy it, for instance, in case other threads are waiting to check
it out.  checkin_and_destroy() should handle the case of a new SA
properly (it produces a log message on level 1, though).
2015-07-27 13:49:26 +02:00
Tobias Brunner 6f7a3b33bc ike: Fall back to the current remote IP if it resolves to %any
In some situations it might be valid for a host that configures
right=%any to reestablish or reauthenticate an IKE_SA. Using %any would
immediately abort the initiation causing the new SA to fail (which
might already have the existing CHILD_SAs assigned).

Fixes #1027.
2015-07-27 13:45:16 +02:00
Tobias Brunner a11048adee ike: Use address family of local address when resolving remote host
If static local addresses are configured we should use their address family
as a hint when resolving the remote address.
We don't do this if %any is configured as this might break existing
configurations (%any4 and %any6 are however used as hint).
2015-07-27 12:09:41 +02:00
Tobias Brunner 834bf7ca5f ike-cfg: Add unit tests for ike_cfg_get_family() helper 2015-07-27 12:08:45 +02:00
Tobias Brunner 6bfa660693 ike-cfg: Add helper function to determine address family of IP addresses
All configured static addresses (hostnames, ranges or subnets are not
considered) must be of the same family, otherwise AF_UNSPEC is returned.
2015-07-27 11:59:37 +02:00
Tobias Brunner 65579569ad host: Properly handle NULL in host_create_from_string[_and_family] 2015-07-27 11:53:26 +02:00
Andreas Steffen 2096d54198 Improved legibility of swanctl CRL listings 2015-07-22 17:46:15 +02:00
Andreas Steffen 63d370387d vici: Certification Authority support added.
CDP and OCSP URIs for a one or multiple certification authorities
can be added via the VICI interface. swanctl allows to read
definitions from a new authorities section.
2015-07-21 13:02:30 +02:00
Andreas Steffen e194349148 vici: Compute rekey_bytes and rekey_packets if life_bytes and life_packets are defined 2015-07-20 21:34:09 +02:00
Tobias Brunner 390ae7a2c2 ike-sa-manager: Safely access the RNG instance with an rwlock
Threads might still be allocating SPIs (e.g. triggered by an acquire or
an inbound message) while the main thread calls flush().  If there is a
context switch right after such a thread successfully checked this->rng
in get_spi() and the main thread destroys the RNG instance right then,
that worker thread will cause a segmentation fault when it continues and
attempts to call get_bytes().

Fixes #1014.
2015-07-14 15:25:23 +02:00
Martin Willi 856ea64129 vici: Asynchronize debug logging
The vici logger uses the listener_t.log() callback to raise vici events.

When doing so, it holds the bus lock as reader while acquiring the vici socket
mutex (1). If at the same time the vici socket enables a writer, that thread
tries to lock the watcher mutex (2). The watcher thread uses debugging while
holding the lock, i.e. acquires the bus read lock (3).

(1) bus.rlock -> vici.lock!
(2) vici.lock -> watcher.lock!
(3) watcher.lock -> bus.rlock!

This all actually would resolve just fine, as we have a shared read lock on the
bus. However, under Windows we seem to have a strict writer preference when
acquiring the rwlock (4). This results in blocking read locks until any pending
write lock can be fulfilled, and makes the constellation deadlock. The relevant
threads are:

Thread (1)
6  0x71313d25 in wait_ at threading/windows/mutex.c:137
7  0x7054c8a2 in find_entry at vici_socket.c:201
8  0x7054d690 in send_ at vici_socket.c:624
9  0x7054f6c1 in send_op at vici_dispatcher.c:119
10 0x705502c1 in raise_event at vici_dispatcher.c:469
12 0x704c3878 in log_cb at bus/bus.c:332
13 0x712c7c3a in invoke_function at collections/linked_list.c:414
14 0x704c3a63 in vlog at bus/bus.c:400
15 0x704c3b36 in log_ at bus/bus.c:430
18 0x70508f1f in process_response at sa/ikev2/task_manager_v2.c:664
20 0x704f5430 in process_message at sa/ike_sa.c:1369
21 0x704e3823 in execute at processing/jobs/process_message_job.c:74
22 0x712e629f in process_job at processing/processor.c:235

Thread (2)
4  0x71313b61 in lock at threading/windows/mutex.c:66
5  0x712e81fd in add at processing/watcher.c:441
6  0x712e1ab9 in add_watcher at networking/streams/stream.c:213
7  0x712e1b4d in on_write at networking/streams/stream.c:237
8  0x7054d606 in _cb_enable_writer at vici_socket.c:609
9  0x712e5e34 in execute at processing/jobs/callback_job.c:77
10 0x712e629f in process_job at processing/processor.c:235

Thread (3)
3  0x71313f38 in read_lock at threading/windows/rwlock.c:74
4  0x704c3971 in vlog at bus/bus.c:373
5  0x704cc156 in dbg_bus at daemon.c:126
6  0x712e7bf9 in watch at processing/watcher.c:316
7  0x712e5e34 in execute at processing/jobs/callback_job.c:77
8  0x712e629f in process_job at processing/processor.c:235

Thread (4)
3  0x71313f70 in write_lock at threading/windows/rwlock.c:82
4  0x704c378b in remove_logger at bus/bus.c:290
5  0x704cb284 in listener_unregister at control/controller.c:166
6  0x713136cd in thread_cleanup_pop at threading/windows/thread.c:558
8  0x704cb94e in initiate at control/controller.c:435
9  0x70553996 in _cb_initiate at vici_control.c:187
12 0x7054d200 in _cb_process_queue at vici_socket.c:508
13 0x712e5e34 in execute at processing/jobs/callback_job.c:77
14 0x712e629f in process_job at processing/processor.c:235

To avoid such a situation, we dissolve the (1) lock sequence. It's actually
never good practice to acquire shared locks during bus hooks, as it is
problematic if we raise bus events while holding the lock. We do so by
raising vici events for log message asynchronously, but of curse must keep
log order as is using a synchronized queue.
2015-07-12 13:57:48 +02:00
Martin Willi c6d60f4808 libipsec: Add a unit-test for ESP encryption using ChaCha20Poly1305 2015-07-12 13:54:08 +02:00
Martin Willi 29e3544f1f libipsec: Add a unit-test test runner 2015-07-12 13:54:08 +02:00
Martin Willi 98aa6aa344 unit-tests: Add a IKEv2 message encryption test case
It uses the ChaCha20Poly1305 test vectors from
draft-ietf-ipsecme-chacha20-poly1305-06.
2015-07-12 13:54:03 +02:00
Martin Willi 80d7f44198 unit-tests: Increase failure message buffer to hold larger hex dumps 2015-07-12 13:25:50 +02:00
Martin Willi ee9f691915 unit-tests: Forward variable argument list in TEST_SUITE_DEPEND
For some plugin features, such as crypters or AEADs, we have some additional
feature arguments, such as the key size.
2015-07-12 13:25:50 +02:00
Martin Willi 88d90c7b4b unit-tests: Load libstrongswan plugins in libcharon tests 2015-07-12 13:25:50 +02:00
Martin Willi fe5d6eaa9f chapoly: Process two Poly1305 blocks in parallel in SSSE3 driver
By using a derived key r^2 we can improve performance, as we can do loop
unrolling and slightly better utilize SIMD instructions.

Overall ChaCha20-Poly1305 performance increases by ~12%.

Converting integers to/from our 5-word representation in SSE does not seem
to pay off, so we work on individual words.
2015-07-12 13:25:50 +02:00
Martin Willi b499777cbf chapoly: Process four ChaCha20 blocks in parallel in SSSE3 driver
As we don't have to shuffle the state in each ChaCha round, overall performance
for ChaCha20-Poly1305 increases by ~40%.
2015-07-12 13:25:36 +02:00
Martin Willi 755dadcfda chapoly: Add an SSSE3 based driver
We always build the driver on x86/x64, but enable it only if SSSE3 support
is detected during runtime.

Poly1305 uses parallel 32-bit multiplication operands yielding a 64-bit result,
for which two can be done in parallel in SSE. This is minimally faster than
multiplication with 64-bit operands, and also works on 32-bit builds not having
a __int128 result type.

On a 32-bit architecture, this is more than twice as fast as the portable
driver, and on 64-bit it is ~30% faster.
2015-06-29 17:32:14 +02:00
Martin Willi bf86fd7ccc chapoly: Add a ChaCha20/Poly1305 driver implemented in portable C 2015-06-29 17:32:14 +02:00
Martin Willi 370fb3feb0 chapoly: Provide a generic ChaCha20/Poly1305 AEAD supporting driver backends 2015-06-29 17:32:14 +02:00
Martin Willi 82f7f5882f test-vectors: Add some initial ChaCha20/Poly1305 AEAD test vector 2015-06-29 17:32:14 +02:00
Martin Willi 405c5dcd82 kernel-netlink: Add ChaCha20-Poly1305 AEAD support 2015-06-29 17:32:14 +02:00
Martin Willi 19e0a71c73 libipsec: Create AEAD with four byte salt for ChaCha20-Poly1305 2015-06-29 17:32:13 +02:00
Martin Willi 6ffaa8626e ikev2: Derive additional 4 byte CHILD_SA nonce keymat for ChaCha20-Poly1305 2015-06-29 17:32:13 +02:00
Martin Willi bbcb76e260 ikev2: Use four byte salt for ChaCha20-Poly1305 AEAD 2015-06-29 17:32:13 +02:00
Martin Willi b211f283b7 proposal: Add a chacha20poly1305 proposal keyword 2015-06-29 17:32:13 +02:00
Martin Willi 9e110cc54c crypter: Define a ChaCha20/Poly1305 AEAD algorithm identifier 2015-06-29 17:32:03 +02:00
Tobias Brunner b01b331afe capabilities: Handle ERANGE in user and group lookups
As it turns out, getpwnam_r, getgrnam_r, and friends will return
ERANGE if _any_ user or group on the system is larger than will fit
into the scratch buffer you pass to them.

This reworks the resolve_uid and resolve_gid methods plus
init_supplementary_groups to use a variable-size buffer that is grown
until the results fit.

Based on a patch by Evan Broder.

Closes strongswan/strongswan#12.
2015-06-23 10:03:38 +02:00
Martin Willi 5fbc709224 osx: Version bump to 5.3.2-1 2015-06-18 10:37:21 +02:00
Martin Willi 88b60c3349 osx: Use CodeSignOnCopy for privileged helper, as suggested by XCode 2015-06-18 10:36:05 +02:00
Martin Willi 0f1d6b34b3 charon-xpc: Use DNS non-append/replace mode in osx-attr plugin 2015-06-18 10:36:04 +02:00
Martin Willi 61d6cdb926 osx-attr: Optionally replace existing DNS server instead of appending them 2015-06-18 10:36:04 +02:00
Tobias Brunner d13c8f8f7f Remove accidentally added stamp-h1
Was added in bc47488323 ("Add a return value to prf_t.get_bytes()").
2015-06-15 14:17:28 +02:00
Tobias Brunner f146104736 settings: Fix out-of-tree build
The header file was created in the source directory before, where it
wasn't found by the generated C files in the build directory.
2015-06-11 12:34:55 +02:00
Tobias Brunner 2d5b3d34ec stroke: Add missing include for UINT16_MAX
Fixes the build on FreeBSD.

Fixes #988.
2015-06-09 10:25:33 +02:00
Martin Willi 0020b25a45 ikev2: Enforce remote authentication config before proceeding with own authentication
Previously the constraints in the authentication configuration of an
initiator were enforced only after all authentication rounds were
complete.  This posed a problem if an initiator used EAP or PSK
authentication while the responder was authenticated with a certificate
and if a rogue server was able to authenticate itself with a valid
certificate issued by any CA the initiator trusted.

Because any constraints for the responder's identity (rightid) or other
aspects of the authentication (e.g. rightca) the initiator had were not
enforced until the initiator itself finished its authentication such a rogue
responder was able to acquire usernames and password hashes from the client.
And if a client supported EAP-GTC it was even possible to trick it into
sending plaintext passwords.

This patch enforces the configured constraints right after the responder's
authentication successfully finished for each round and before the initiator
starts with its own authentication.

Fixes CVE-2015-4171.
2015-06-05 13:44:42 +02:00
Martin Willi a49393954f child-sa: Use any fixed reqid configured on the CHILD_SA config
Global reqid allocation (94eb09ac) broke fixed reqid allocation. Resupport them
by bypassing allocation in the kernel if a fixed reqid has been configured.

Fixes #976.
2015-06-05 13:44:42 +02:00
Tobias Brunner 523ea82ed5 unit-tests: Add tests for iv_gen_seq_t 2015-06-05 13:44:42 +02:00
Martin Willi b756eea4f4 ivgen: Allow reusing the same message ID twice in sequential IV gen
We use the message ID and fragment number as IV generator. As IKEv2 uses
distinct message ID counters for actively and passively initiated exchanges,
each IV would be used twice. As we explicitly reject such message IDs since
d0ed1079, original-responder initiated exchanges fail with counter mode ciphers.

This commit separates IV space in two halves for sequential IVs, and
automatically assigns once reused sequence numbers to the second half.

Fixes #980.
2015-06-05 13:44:42 +02:00
Andreas Steffen bd60bcc3c2 Updated SWID attribute list 2015-06-02 06:51:41 +02:00
Tobias Brunner 541543dbfe message: Log message if unknown/disallowed payload received 2015-06-01 09:42:11 +02:00
Tobias Brunner e67161fe9e message: Log original message type of unknown payloads 2015-06-01 09:42:11 +02:00
Tobias Brunner 1507647434 unknown-payload: Use a new private payload type and make original type available
This fixes a DoS and potential remote code execution vulnerability that was
caused because the original payload type that was returned previously was
used to cast such payload objects to payloads of the indicated type (e.g.
when logging notify payloads with a payload type for the wrong IKE version).

Fixes CVE-2015-3991.
2015-06-01 09:42:11 +02:00
Martin Willi 62e0abe759 ikev2: Include fragment number into message ID passed to IV gen
When using a cipher with sequential IVs, we never must pass an identical IV
to the IV generator. To avoid it when using IKEv2 fragmentation, use the lower
bits of the 64-bit message ID as the fragment number.
2015-06-01 09:42:11 +02:00
Martin Willi ef31254d34 iv-gen: Fail getting shorter IV values than the used counter size
While no algorithm actually uses such short IVs, we add a check here to ensure
we won't return just the lower bits of the counter.
2015-06-01 09:42:10 +02:00
Martin Willi d0ed107910 iv-gen: Ensure external sequential IVs are actually sequential
We allow gaps in IVs, but ensure that an IV is never used more than once.
2015-06-01 09:42:10 +02:00
Martin Willi 823a8a9b46 message: Show the fragmentation numbers in message stringification 2015-06-01 09:42:10 +02:00
Tobias Brunner 711cb586fa ha: Document tunnel parameter 2015-05-27 12:59:39 +02:00
Tobias Brunner 06a5b0e2e8 ha: Skip SA for sync messages when resyncing HA segments 2015-05-26 15:43:46 +02:00
Tobias Brunner 0de116cadc ha: Move plugin initialization from constructor to plugin callback
This fixes support for the secret option, as otherwise the kernel interface
is not registered yet when the trap policy is installed.
2015-05-26 12:47:17 +02:00
Martin Willi 47e96391f2 libtls: As client, reject DH exchanges using primes smaller than 1024 bit
While the server signs the ephemeral DH parameters, it can be tricked to its
lowest supported DH group by a man-in-the-middle:

  https://weakdh.org/imperfect-forward-secrecy.pdf

While we at least use 2048-bit DH groups as server, the client accepts any
DH prime the server sends. If it supports export ciphers, only a 512-bit prime
may be used.

As TLS does not define nor negotiate a DH group for cipher suites, the client
actually must accept what the server offers. To avoid downgrades to weak
DH groups, we must reject what we consider insecure. We set this limit to
1024-bit primes. While this breaks compatibility with TLS servers using weaker
primes, this is what we expect servers at least use. Most browser vendors use
the same limit in a similar fix.
2015-05-26 11:36:24 +02:00
Andreas Steffen dedd0ad07c Check for NULL installed packages enumerator 2015-05-24 11:15:36 +02:00
Andreas Steffen 5d5a74b077 Fixed os_info path in strongswan.conf 2015-05-24 11:13:51 +02:00
Andreas Steffen d6b75c9563 List attribute request entries also during build 2015-05-24 09:17:29 +02:00
Tobias Brunner d8fe354a0e stroke: Dynamically resize stroke messages
The maximum size of a stroke message is currently 64k due to the 2 byte
length field.

Fixes #943.
2015-05-22 10:40:15 +02:00
Tobias Brunner e94aae83d3 vici: Explicitly disable --user-install when installing Ruby Gem
Only one of `--user-install` and `--install-dir` may be set and if
`--user-install` is the default on a system installation will fail
unless we disable it explicitly.

Fixes #914.
2015-05-21 17:22:11 +02:00
Tobias Brunner f16f792e17 vici: Make installation of Ruby Gem and Python Egg optional
Installing them might not work well when building distro packages (e.g.
with DESTDIR installs).  It might be easier to install them later with a
script in the distro package.

When building from source on the local system it could still be useful to
install the packages directly, which can be enabled with separate configure
options.

The main problem with DESTDIR installations of the Python Egg is that
easy_install creates or modifies a file called easy-install.pth in the
installation directory.  So it's not actually possible to simply copy
the results in DESTDIR over to the actual system as that file would have
to be merged with any existing one.

Fixes #914.
2015-05-21 17:22:01 +02:00
Tobias Brunner 5a817407bc vici: Support out-of-tree build of Python Egg
We also don't require setup.py to exist during cleanup, as e.g. with
make distcheck the source directory is not writable when the build directory
is cleaned, so setup.py can't be created (to just get removed again anyway
if VICI and the Python Eggs haven't been enabled previously).
2015-05-21 17:19:09 +02:00
Tobias Brunner 4112ebad4a ikev1: When a reauth is detected explicitly delete the old IKE_SA
Instead of just implicitly destroying the old SA we properly delete it to
notify the other peer (if the other peer keeps the SA up after the
reauthentication and sends DPDs it might consider us dead even though the
new SA is up, that seems to be the case with racoon).  We delay the DELETE
a bit to give the other peer time to get the new SA fully established.

Since DELETE messages are not retransmitted it is still possible that
the other peer misses that we deleted the SA.
2015-05-21 16:00:39 +02:00
Tobias Brunner 240ad7abf5 libipsec: Insert SAs first, so latest SA with the same reqid gets used
This was useful for testing purposes of RADIUS accounting, but OS kernels
generally will use the latest SA, so we do the same.
2015-05-21 15:38:31 +02:00
Tobias Brunner 2b51124026 eap-radius: Keep track of stats for SAs migrated during IKEv1 reauthentication 2015-05-21 15:38:31 +02:00
Tobias Brunner 6a9a69ae58 ikev1: Trigger children_migrate event if CHILD_SAs are adopted 2015-05-21 15:38:31 +02:00
Tobias Brunner 072d9dc3c6 bus: Add new hook called when IKEv1 CHILD_SAs are migrated to a new IKE_SA
The interface is currently not very nice, but if we ever were able to
safely checkout multiple SAs concurrently we could add something similar
to ike_rekey() and call that when we detect a reauthentication.
2015-05-21 15:38:31 +02:00
Tobias Brunner 8dbef6dac8 eap-radius: Remove cache entries for expired SAs during ike/child_rekey 2015-05-21 15:38:31 +02:00
Tobias Brunner 7fbe79bce7 eap-radius: Add cache for usage stats of expired/rekeyed SAs
There are several situations that the previous code didn't handle that
well, for example, interim updates during rekeying (until the rekeyed SA
was deleted the numbers were too high, then suddenly dropped afterwards),
or rekeying for IKEv1 in general because rekeyed IPsec SAs stay installed
until they expire (so if they were still around when the IKE_SA was
terminated, the reported numbers in the Stop message were too high).

If intermediate updates are not used the cache entries for rekeyed
CHILD_SA will accumulate, we can't clean them up as we don't get
child_updown() events for them.
2015-05-21 15:38:25 +02:00
Tobias Brunner d079f6a4f7 libradius: Verify message ID of RADIUS responses
If we sent retransmits for a message and didn't receive a response it might
still arrive later.  Such a message will be queued on the socket.  The next
read will then return not the expected response but the one for the earlier
request.  For this message the verification will fail and the message gets
discarded.  But with the earlier code the actual response was never received.
Instead, a subsequent request resulted in the same failure and so on.

Fixes #838.
2015-05-21 14:30:11 +02:00
Tobias Brunner 6716c6526e kernel-netlink: Ignore unusable routes 2015-05-21 14:19:53 +02:00
Tobias Brunner cc902695e8 kernel-netlink: Make buffer size for received Netlink messages configurable 2015-05-21 10:19:08 +02:00
Andreas Steffen e6952442f2 Exempt ignored PA-TNC attributes from error handling 2015-05-20 06:13:15 +02:00
Tobias Brunner 95faeaa7ed starter: Ensure the daemon executable exists when starting up
The only purpose of starter is to control the IKE daemon, so we
terminate it if the daemon executable is not found (e.g. because
DAEMON_NAME is incorrect).

This removes the charonstart setting (it was not actually configurable
anymore).
2015-05-08 19:05:26 +02:00
Tobias Brunner 5923abc6bf starter: Remove START_CHARON compile flag
Since the removal of pluto this is quite superfluous. The flag itself
might be useful to avoid starting charon if the executable does not
exist for some reason (e.g. if DAEMON_NAME is incorrect).
2015-05-05 17:56:46 +02:00
Tobias Brunner 9b4f6cfa23 charon-nm: Disable leak-detective in charon-nm
It segfaults immediately if it is enabled, at least on Ubuntu 14.04.
2015-05-05 17:53:47 +02:00
Tobias Brunner 32df0d81fb child-create: Destroy nonceg in migrate()
Since another nonce gets allocated later (if any was allocated already)
this would have resulted in a leaked nonce context ID when used in charon-tkm.
2015-05-05 10:55:14 +02:00
Tobias Brunner 252f2ef885 child-create: Fix error handling if nonceg can't be created
As with ike-init we can't return NULL in the task constructor.
2015-05-05 10:55:14 +02:00
Tobias Brunner 59565ebf60 ike-init: Fix error handling if nonceg can't be created
Returning FAILED in the constructor is wrong, but returning NULL doesn't work
either as it's currently assumed tasks always can be created.
Therefore, delay this check until we actually try to allocate a nonce.
2015-05-05 10:55:13 +02:00
Tobias Brunner d648d61375 ike-init: Fix compiler warning 2015-05-05 10:55:13 +02:00
Martin Willi 54d0d20bda swanctl: Fix --uri option
As we now pass the vici connection to the command dispatcher callback, we can't
parse the --uri option to create the connection from the same callback. Instead
pre-process the common command options in a separate loop, and ignore the same
options while processing the actual command.
2015-05-05 10:46:48 +02:00
Adrian-Ken Rueegsegger 38b65d7186 charon-tkm: Also store local SPI in SAD 2015-05-04 18:07:52 +02:00
Reto Buerki 0b308faf6d ike-init: Make nonceg a member of ike_init struct
This allows to control the life-cycle of a nonce in the context of the
ike init task. In the TKM use-case the nonce generator cannot be
destroyed before the ike init task is finalized, otherwise the created
nonce is detected as stale.
2015-05-04 18:07:51 +02:00