Martin Willi [Thu, 5 Feb 2015 08:13:57 +0000 (09:13 +0100)]
libtls: Don't send TLS close notifies in EAP after application succeeds
With the introduction of PT-TLS, we started sending TLS close notifies after
the application layer completes (7bbf7aa9). While this makes sense for TCP based
transports, it is not required in EAP methods. In EAP, handshake completion
can be directly signaled using the outer EAP-SUCCESS message. This also saves
one round-trip in the EAP exchange.
Windows 7/8 does not seem to like TLS close notifies at all in EAP, and either
stalls (EAP-TTLS) or disconnects (PEAP).
Thomas Egerer [Wed, 4 Feb 2015 11:47:03 +0000 (12:47 +0100)]
ha: Perform child rekeying outside of CHILD_SA enumerator
When rekey_child_sa is called while enumerating the children of an IKE_SA, and
the child to be rekeyed is redundant a QUICK_DELETE task is queued instead of a
QUICK_MODE task. This alters the IKE_SA's list of children (ike_sa_t::child_sas)
invalidating the current element of the child_sa_enumerator. The enumerate
function of linked_list_t will then advance to an element with unpredictable
contents most likely resulting in an segmentation violation. A similar behavior
should be observed when delete_child_sa is called.
This patch creates a list of protocol/spi values while holding the
child_sa_enumerator and performs the rekeying (deletion of redundant) chlidren
after releasing the enumerator.
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
Tobias Brunner [Tue, 10 Feb 2015 15:08:09 +0000 (16:08 +0100)]
configure: Load SQL backends after crypto plugins
If the MySQL client library is linked against OpenSSL the mysql plugin
will cause a segmentation fault when it is unloaded after the openssl
plugin has already been deinitialized. This is very similar to the issues
with curl (see 44b6a34d438f).
Martin Willi [Thu, 8 Jan 2015 10:06:45 +0000 (11:06 +0100)]
libtls: Check for CHANGE_CIPHER_SPEC type only if upper layer returns NEED_MORE
A type is returned only if upper layers successfully created a record, that is
returns NEED_MORE. If we do not check for the return value, we might check a
previous record or the uninitialized type variable and falsely reset the
sequence number.
Tobias Brunner [Mon, 15 Dec 2014 17:55:03 +0000 (18:55 +0100)]
bliss: Remove unnecessary cast to double
Coverity is still not happy when the result of an integer division is
assigned to a double (without e.g. casting the result to an int first to
indicate the intent). The shift should avoid this issue.
Tobias Brunner [Mon, 1 Dec 2014 16:21:59 +0000 (17:21 +0100)]
crypto: Define MODP_CUSTOM outside of IKE DH range
Before this fix it was possible to crash charon with an IKE_SA_INIT
message containing a KE payload with DH group MODP_CUSTOM(1025).
Defining MODP_CUSTOM outside of the two byte IKE DH identifier range
prevents it from getting negotiated.
Martin Willi [Tue, 16 Dec 2014 15:55:29 +0000 (16:55 +0100)]
apple: Redefine some additional clashing Mach types
While they usually are not included in a normal strongSwan build, the XPC
header indirectly defines these Mach types. To build charon-xpc, which uses
both XPC and strongSwan includes, we have to redefine these types.
Martin Willi [Fri, 24 Oct 2014 13:21:11 +0000 (15:21 +0200)]
kernel-pfroute: If a new interface appears, slightly delay address enumeration
On OS X 10.10, when installing a virtual IP on a tun device, there is a chance
that a RTM_IFANNOUNCE is sent before the IP is ready on that link when calling
getifaddrs(). As we don't get an RTM_NEWADDR event either, that race lets us
miss the virtual IP install event, failing the add_ip() call.
Tobias Brunner [Thu, 4 Dec 2014 15:21:45 +0000 (16:21 +0100)]
kernel-pfkey: Fix replay window size on FreeBSD and Mac OS X
The FreeBSD and Mac OS X kernels interpret sadb_sa_replay as the size of the
replay window in bytes. Linux on the other hand does the same for PF_KEY it
does for XFRM so sadb_sa_replay denotes the number of packets/bits in the
window. Similarly, the window size on Linux is limited to 32 by the four
byte default bitmap used for IPsec SAs (may only be changed with
XFRMA_REPLAY_ESN_VAL), which is not the case on the other platforms.
Martin Willi [Tue, 9 Dec 2014 13:19:39 +0000 (14:19 +0100)]
pem: Handle BER indefinite length encoding as binary ASN.1
While our ASN.1 parser can't handle BER indefinite length encoding, the OpenSSL
backend can. Some PKCS#12 containers get encoded this way, so we should
support loading such files in the pem plugin.
Tobias Brunner [Fri, 12 Dec 2014 11:39:44 +0000 (12:39 +0100)]
ike: Allow creation of internally used payloads
Since 42e0a317c64b ("ike: Only parse payloads valid for the current IKE
version") payload types are checked before creating objects. This check
failed for internally used payload types (e.g. proposal substructures),
which have a type >= 256, i.e. outside the IKE payload type range.
Martin Willi [Fri, 12 Dec 2014 11:05:24 +0000 (12:05 +0100)]
apple: Use precancelable poll() to wrap accept/recvmsg calls
To make accept/recvmsg cancelable, we wrap them with poll. As poll itself
does not honor pending cancellations when entering the function, we use our
variant that checks for pending cancellation requests before entering poll().
Tobias Brunner [Fri, 5 Dec 2014 15:36:13 +0000 (16:36 +0100)]
bliss: Fix monolithic build
This requires moving test files so that the Makefile for the tests can be
included after building libstrongswan, which requires the plugin when
building monolithically. Due to this a static helper library is required
as directly referring to object files (or source files) is not possible.
It's also necessary to avoid any link-time dependency on libstrongswan in
bliss_huffman, to avoid circular dependencies (bliss_huffman -> libstrongswan
-> bliss -> bliss_huffman).
Tobias Brunner [Fri, 5 Dec 2014 15:37:10 +0000 (16:37 +0100)]
bliss: Fix compilation warning with certain GCC versions
Theoretically, n could be zero and these variables are then used
uninitialized. Older GCC versions warn about this and on Travis where we
compile with -Werror this causes the tests to fail.
Martin Willi [Wed, 10 Dec 2014 13:26:14 +0000 (14:26 +0100)]
dumm: Fix -Wformat warning in ruby extension
In recent ruby versions, extensions get built with -Wformat. As we use custom
printf specifiers, that does not work for us. As there does not seem to be a
reliable way to override -Wformat, we use a variable for the format string,
which prevents gcc from doing the -Wformat check in that particular situation.
Tobias Brunner [Mon, 24 Nov 2014 16:28:27 +0000 (17:28 +0100)]
ikev1: Use same map for AH and ESP authentication algorithms
The transform identifier used in AH transforms is not the same as the
authentication algorithm identifier used in the transform attributes in
AH (and ESP) transforms.
Tobias Brunner [Fri, 17 Oct 2014 10:33:14 +0000 (12:33 +0200)]
asn1: Add OID for Blowfish CBC
The OID (1.3.6.1.4.1.3029.1.2) is technically not correct, the correct
one is (1.3.6.1.4.1.3029.1.1.2). Every other library or tool (like OpenSSL)
uses the incorrect one so we do the same.
Martin Willi [Fri, 5 Dec 2014 12:48:51 +0000 (13:48 +0100)]
diffie-hellman: Handle dh_exponent_ansi_x9_42 as a boolean setting
While it was always documented as boolean setting, the option is currently
handled as integer value, for which yes/no values do not work. Instead the
default of TRUE is used for a no value.
The option has been moved a lot during the last years, and in some locations
was handled as bool, in some as integer. In the latest codebase it
congruently used integer, which is actually not what is documented and used
in testing.
Tobias Brunner [Thu, 16 Oct 2014 14:16:48 +0000 (16:16 +0200)]
unity: Only do narrowing of responder's TS if we received 0.0.0.0/0
iOS and Mac OS X clients establish individual IPsec SAs for the traffic
selectors received in Split-Include attributes (might have been different
in earlier releases). If we return 0.0.0.0/0 as TSr that either results
in a bunch of Quick Mode exchanges (for each TS), or with the latest
client releases an error notify (ATTRIBUTES_NOT_SUPPORTED).
We also can't install the IPsec SA with all configured subnets as that
would cause conflicts if the client later negotiates SAs for other subnets,
which iOS 8 does based on traffic to such subnets.
For Shrew and the Cisco client, which propose 0.0.0.0/0, we still need to
override the narrowed TS with 0.0.0.0/0, as they otherwise won't accept
the Quick Mode response. Likewise, we also have to narrow the TS before
installing the IPsec SAs and policies.
So we basically have to follow the client's proposal and only modify TSr
if we received 0.0.0.0/0. Since we don't get the original TS in the
narrow hook we handle the inbound QM messages and make note of IKE_SAs on
which we received a TSr of 0.0.0.0/0.
Martin Willi [Fri, 28 Nov 2014 08:39:40 +0000 (09:39 +0100)]
kernel-wfp: Install outbound ALE connect rules for IPsec
Similar to the inbound rules, the ALE filter processes IP-in-IP packets for
outbound tunnel mode traffic. When using an outbound default-drop policy,
Windows does not allow connection initiation without these explicit rules.
Martin Willi [Thu, 27 Nov 2014 18:19:09 +0000 (19:19 +0100)]
kernel-wfp: Install inbound ALE IP-in-IP filters
When processing inbound tunnel mode packets, Windows decrypts packets and
filters them as IP-in-IP packets. We therefore require an ALE filter that
calls the FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_ALE_ACCEPT callout to allow them
when using a default-drop policy.
Without these rules, any outbound packet created an ALE state that allows
inbound packets as well. Processing inbound packets without any outbound
traffic fails without these rules.
Martin Willi [Wed, 19 Nov 2014 13:20:47 +0000 (14:20 +0100)]
vici: Make sure to send/recv all requested bytes over socket
As the underlying C functions, send/recv on ruby sockets are not guaranteed
to send/recv all requested bytes. Use wrapper functions to make sure we get
all bytes needed.
Andreas Steffen [Mon, 10 Nov 2014 06:56:28 +0000 (07:56 +0100)]
Implemented get_byte() method for mgf1_bitspender class
The new get_byte() method returns a pseudo-random byte at a time.
Changed the get_bits() interface to the same interface as get_byte().
Updated the mgf1 unit-tests accordingly.