Commit Graph

2940 Commits

Author SHA1 Message Date
Martin Willi 38227d0e08 ike: Maintain per-IKE_SA CHILD_SAs in the global CHILD_SA manager 2015-02-20 13:34:49 +01:00
Martin Willi e732fb11a9 child-sa-manager: Add a global manager storing CHILD_SA relations
To quickly check out IKE_SAs and find associated CHILD_SAs, the
child_sa_manager stores relations between CHILD_SAs and IKE_SAs. It provides
CHILD_SA specific IKE_SA checkout functions wrapping the ike_sa_manager.
2015-02-20 13:34:49 +01:00
Martin Willi 85b238887d child-sa: Replace reqid based marks by "unique" marks
As we now use the same reqid for multiple CHILD_SAs with the same selectors,
having marks based on the reqid makes not that much sense anymore. Instead we
use unique marks that use a custom identifier. This identifier is reused during
rekeying, keeping the marks constant for any rule relying on it (for example
installed by updown).

This also simplifies handling of reqid allocation, as we do not have to query
the marks that is not yet assigned for an unknown reqid.
2015-02-20 13:34:49 +01:00
Martin Willi 4ec397b894 child-sa: Introduce a unique CHILD_SA identifier
As the reqid is not that unique even among multiple IKE_SAs anymore, we need
an identifier to uniquely identify a specific CHILD_SA instance.
2015-02-20 13:34:49 +01:00
Martin Willi 0da97f5060 child-sa: Delegate reqid allocation to the kernel interface 2015-02-20 13:34:49 +01:00
Martin Willi 5499473c33 child-sa: Sort traffic selectors after adding CHILD_SA policies
Having traffic selectors sorted properly makes comparing them much simpler.
2015-02-20 13:34:48 +01:00
Martin Willi 698ed656f7 child-sa: Remove the obsolete update logic
The kernel backend uses an inbound parameter these days, where it makes
no sense to pass the update flag. The kernel backend decides itself how
it handles SA installation based on the inbound flag.
2015-02-20 13:34:48 +01:00
Martin Willi d05d85fe65 kernel-interface: Pass full list of traffic selectors to add_sa()
While we can handle the first selector only in BEET mode in kernel-netlink,
passing the full list gives the backend more flexibility how to handle this
information.
2015-02-20 13:34:47 +01:00
Martin Willi fd9417607c libipsec: Remove unused src/dst_ts parameters from ipsec_sa_mgr_t.add_sa() 2015-02-20 13:34:47 +01:00
Martin Willi 2a1c9e20bd kernel-interface: Remove reqid parameter from get_spi/get_cpi() methods
The reqid is not strictly required, as we set the reqid with the update
call when installing the negotiated SA.

If we don't need a reqid at this stage, we can later allocate the reqid in
the kernel backend once the SA parameters have been fully negotaited. This
allows us to assign the same reqid for the same selectors to avoid conflicts
on backends this is necessary.
2015-02-20 13:34:32 +01:00
Martin Willi 3e779ff555 libipsec: Remove unused reqid parameter from ipsec_sa_mgr_t.get_spi() 2015-02-19 15:42:22 +01:00
Thomas Egerer 875f7be5fc 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>
2015-02-19 10:58:40 +01:00
Martin Willi c8992ea6d2 vici: Fix ruby gem author email 2015-01-22 15:00:45 +01:00
Martin Willi 96df0a0ebd vici: Fix README example encoding element type values, off by one
While we fixed the wrong values in the description with d39e04b5, the example
values are still off by one.

Fixes #828.
2015-01-21 09:31:24 +01:00
Tobias Brunner 691d00f166 ikev2: Only touch the DH object if we have a matching proposal 2014-12-23 15:40:01 +01:00
Martin Willi 04337fed02 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.
2014-12-16 17:22:28 +01:00
Tobias Brunner 3000f6aada Fixed some typos, courtesy of codespell 2014-12-15 17:11:14 +01:00
Tobias Brunner 75dd984e9e ike: Allow creation of internally used payloads
Since 42e0a317c6 ("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.
2014-12-12 13:10:26 +01:00
Martin Willi 6855b8b36b vici: Use silent builder destroy function in vici_free_req() 2014-12-12 10:23:59 +01:00
Martin Willi c04ee43af7 vici: Add a destroy method to builder, allowing cancellation without error
When cancelling a builder, finalize throws an error which we might prefer
to avoid.
2014-12-12 10:23:59 +01:00
Martin Willi 971ef077ce eap-radius: Use the single-server legacy server options as fallback 2014-12-12 10:23:59 +01:00
Tobias Brunner 728f529c42 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.
2014-12-09 11:08:14 +01:00
Tobias Brunner 4141f01671 ikev1: Accept IPComp proposals with 4 octet long CPI values
While they SHOULD be sent as 16-bit values according to RFC 3173
a responder MUST be able to accept CPI values encoded in four bytes.
2014-12-05 15:48:52 +01:00
Tobias Brunner 42e0a317c6 ike: Only parse payloads valid for the current IKE version 2014-12-05 15:41:47 +01:00
Tobias Brunner fac310a467 ike: Make check for known payloads depend on IKE version 2014-12-05 15:41:46 +01:00
Tobias Brunner 02df52fd2b 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.

Fixes #737.
2014-12-05 10:12:46 +01:00
Tobias Brunner bf5d0693ef id-payload: Enable multiple calls to get_ts() for subnet traffic selectors
The second call resulted in a /32 subnet previously.
2014-12-05 09:32:38 +01:00
Tobias Brunner 7459f3a5ac ikev2: Fix handling of more than one hash-and-URL certificate payloads 2014-12-04 11:33:38 +01:00
Martin Willi e1a448314f 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.
2014-12-04 11:10:48 +01:00
Martin Willi a8142a17cf 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.
2014-12-04 11:10:48 +01:00
Martin Willi 070461b70d kernel-wfp: Add missing IPsec sublayer GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi a21338a43e kernel-wfp: Define IPsec related ALE layers and callout GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi 4d48dfd6a3 kernel-wfp: Fix logging of MM/QM/EM NetEvent failures 2014-12-04 11:10:48 +01:00
Martin Willi b164cc8e15 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.
2014-12-04 10:42:22 +01:00
Andreas Steffen b6bb32e658 Implemented full BLISS support for IKEv2 public key authentication and the pki tool 2014-11-29 14:51:18 +01:00
Martin Willi f1773fee43 ikev2: Fix ike_rekey switch statement broken with last commit 2014-11-24 10:03:26 +01:00
Martin Willi 8891ed5478 ikev2: Prevent IKE_SA rekeying if we are currently retrying a CHILD_SA rekey 2014-11-21 12:51:20 +01:00
Martin Willi c39b0c883d controller: Keep following initiate() if the first DH guess was wrong 2014-11-21 12:51:19 +01:00
Martin Willi 013857ad79 child-sa: Introduce a CHILD_RETRYING state to detect DH group retries 2014-11-21 12:51:19 +01:00
Martin Willi eeaa6f9b1a kernel-libipsec: Use poll(2) instead of select 2014-11-21 12:02:07 +01:00
Martin Willi ed247660e8 socket-default: Use round-robin selection of sockets to read from
If multiple sockets are ready, we previously preferred the IPv4 non-NAT socket
over others. To handle all with equal priority, use a round-robin selection.
2014-11-21 12:02:07 +01:00
Martin Willi ce13ba62cc socket-default: Use poll(2) instead of select
It is not only simpler, but also allows the use of arbitrary high fd numbers,
which silently fails with select().
2014-11-21 12:02:07 +01:00
Tobias Brunner b1ef481ce1 proposal: Add default PRF for HMAC-MD5-128 and HMAC-SHA1-160 integrity algorithms 2014-10-31 10:09:54 +01:00
Tobias Brunner e0cd3bad3d ike-cfg: Use host_create_from_range() helper 2014-10-30 12:32:45 +01:00
Tobias Brunner 5e92534313 vici: Add support for address range definitions of pools 2014-10-30 12:32:45 +01:00
Tobias Brunner c355e2b2c7 stroke: Add support for address range definitions of in-memory pools 2014-10-30 12:32:45 +01:00
Thomas Egerer 1201ddcbc5 ikev1: Don't inherit children if INITITAL_CONTACT was seen
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-10-30 11:53:56 +01:00
Thomas Egerer 11b42933bf ikev1: Send INITIAL_CONTACT notify in Main Mode
We currently send the notify in Main Mode only, as it is explicitly not allowed
by RFC 2407 to send (unprotected) notifications in Aggressive Mode. To make
that work, we'd need to handle that notify in Aggressive Mode, which could
allow a MitM to inject such notifies and do some harm.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-10-30 11:53:56 +01:00
Tobias Brunner b089169752 message: Include encrypted fragment payload in payload (order) rules
Otherwise fragmented CREATE_CHILD_SA exchanges won't get accepted
because they don't contain an SA payload.

It also prevents a warning when ordering payloads.

Fixes #752.
2014-10-29 15:51:38 +01:00
Martin Willi 4736ba0657 updown: Explicitly pass caller PATH to updown script
When invoking /bin/sh, its default PATH is used. On some systems, that does
not include the PATH where the ipsec script is installed, as charon is invoked
with a custom PATH. Explicitly setting the PATH of charon should fix this
case, properly invoking the (default) updown script.

Fixes #745.
2014-10-22 14:53:36 +02:00