Commit Graph

1243 Commits

Author SHA1 Message Date
Tobias Brunner 7a0fdbab42 shunt-manager: Add an optional namespace for each shunt
This will allow us to reuse the names of child configs e.g. when they
are defined in different connections.
2017-02-16 19:24:07 +01:00
Eyal Birger 067fd2c69c child-sa: Do not install mark on inbound kernel SA
The SA ID (src, dst, proto, spi) is unique on ingress.

As such, explicit inbound marking is not needed to match an SA.

On the other hand, requiring inbound SAs to use marks forces the
installation of a mechanism for marking traffic (e.g. iptables) based
on some criteria.

Defining the criteria becomes complicated, for example when required to
support multiple SAs from the same src, especially when traffic is UDP
encapsulated.

This commit removes the assignment of the child_sa mark_in to the inbound SA.

Policies can be arbitrated by existing means - e.g, via netfilter policy
matching or using VTI interfaces - without the need to classify the flows prior
to state matching.

Since the reqid allocator regards the mark value, there is no risk of matching
the wrong policy.

And as explicit marking was required for route-based VPN to work before this
change, it should not cause regressions in existing setups.

Closes strongswan/strongswan#59.
2017-02-14 18:34:15 +01:00
Tobias Brunner cbb6885e9b ikev2: Ignore IKEV2_MESSAGE_ID_SYNC notifies if extension is disabled
If this is the first message by the peer, i.e. we expect MID 0, the
message is not pre-processed in the task manager so we ignore it in the
task.

We also make sure to ignore such messages if the extension is disabled
and the peer already sent us one INFORMATIONAL, e.g. a DPD (we'd otherwise
consider the message with MID 0 as a retransmit).
2017-02-08 15:10:51 +01:00
Tobias Brunner c3d98d298e ikev2: Don't increase expected MID after handling MID sync message
If the responder never sent a message the expected MID is 0.  While
the sent MID (M1) SHOULD be increased beyond the known value, it's
not necessarily the case.
Since M2 - 1 would then equal UINT_MAX setting that MID would get ignored
and while we'd return 0 in the notify we'd actually expect 1 afterwards.
2017-02-08 15:03:26 +01:00
Tobias Brunner fb57904cbf ikev2: Don't cache response to MID sync request 2017-02-08 15:03:25 +01:00
Tobias Brunner 3abc104f7e ikev2: Accept INFORMATIONAL messages with MID 0 if used to sync MIDs
We are very picky to only allow MID 0 for these messages (while we
currently don't support IPSEC_REPLAY_COUNTER_SYNC notifies we accept
them).
2017-02-08 15:03:25 +01:00
Tobias Brunner d6ffa85fea ikev2: Negotiate support for IKE message ID synchronisation during IKE_AUTH 2017-02-08 15:03:25 +01:00
Tobias Brunner 5ab59221d2 ikev2: Add task to handle IKEV2_MESSAGE_ID_SYNC notifies as responder 2017-02-08 15:03:25 +01:00
Tobias Brunner 347c403cf6 ike: Publish getter for the current message ID on IKE_SA 2017-02-08 15:03:25 +01:00
Tobias Brunner 05a2be82c2 ike: Add getter for the current message ID to task manager 2017-02-08 15:03:25 +01:00
Tobias Brunner aeaab528e8 ikev1: Factor out IV and QM management
This simplifies implementing a custom keymat_v1_t.
2017-02-08 10:33:07 +01:00
Thomas Egerer 267c1f7083 keymat: Allow keymat to modify signature scheme(s)
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-02-08 10:32:17 +01:00
Tobias Brunner 2f95c55271 ike-auth: Don't send INITIAL_CONTACT if remote ID contains wildcards
Such an identity won't equal an actual peer's identity resulting in
sending an INITIAL_CONTACT notify even if there might be an existing
IKE_SA.
2017-02-06 11:16:53 +01:00
Andreas Steffen f2eb367adc Implemented EdDSA for IKEv2 using a pro forma Identity hash function 2016-12-14 11:15:48 +01:00
Thomas Egerer 8c50bb6c36 ikev1: Minor code optimization in task manager
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2016-12-07 10:37:46 +01:00
Thomas Egerer 1042b9194f child-sa: Use single return statement in update_usebytes()
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2016-11-18 11:58:14 +01:00
Tobias Brunner 0ddda7ca56 task-manager: Only trigger retransmit cleared alert if there was at least one retransmit
The counter is already increased when sending the original message.

Fixes: bd71ba0ffb ("task-manager: Add retransmit cleared alert")
2016-10-05 16:01:14 +02:00
Tobias Brunner fcca7d2904 ikev2: Respond with NO_PROPOSAL_CHOSEN if proposal without DH group was selected
Fixes #2051.
2016-10-05 14:26:50 +02:00
Tobias Brunner 33241871a8 ikev2: Only add NAT-D notifies to DPDs as initiator
If a responder is natted it will usually be a static NAT (unless it's a
mediated connection) in which case adding these notifies makes not much
sense (if the initiator's NAT mapping had changed the responder wouldn't
be able to reach it anyway).  It's also problematic as some clients refuse
to respond to DPDs if they contain such notifies.

Fixes #2126.
2016-10-04 12:16:05 +02:00
Tobias Brunner b56b850251 ikev1: Activate task to delete the IKE_SA in state IKE_REKEYING
It does not have any CHILD_SAs attached at that point.
2016-10-04 10:14:43 +02:00
Tobias Brunner 2e06179f7f ikev1: Delete Quick Mode SAs before the ISAKMP SA
After the ISAKMP_DELETE task has been executed the IKE_SA is destroyed
so we wouldn't be able to send deletes for the Quick Mode SAs.
2016-10-04 10:14:43 +02:00
Tobias Brunner ebc6445de8 ikev1: Send DELETE for rekeyed IKE_SAs
If we silently delete the IKE_SA the other peer might still use it even
if only to send DPDs.  If we don't answer to DPDs that might result in the
deletion of the new IKE_SA too.
2016-10-04 10:14:43 +02:00
Tobias Brunner 0642f42bbe ike: Set default IKE fragment size to 1280
This is the minimum size an IPv6 implementation must support.  This makes
it the default for IPv4 too, which presumably is also generally routable
(otherwise, setting this to 0 falls back to the minimum of 576 for IPv4).
2016-10-04 10:08:21 +02:00
Tobias Brunner 0e80f5c3ff ikev2: Send derived CHILD_SA keys to the bus 2016-10-04 10:01:50 +02:00
Tobias Brunner 4f373c7f20 ikev2: Send derived IKE_SA keys to bus 2016-10-04 10:01:50 +02:00
Tobias Brunner c4a286c88a ikev1: Send derived CHILD_SA keys to the bus 2016-10-04 10:01:49 +02:00
Tobias Brunner a6dc7bf287 ikev1: Send derived IKE_SA keys to bus 2016-10-04 10:01:49 +02:00
Tobias Brunner ad1b53454e child-sa: Only install outbound FWD policies if explicitly configured
They are only required if drop policies would otherwise prevent
forwarding traffic.  This reduces the number of policies and avoids
conflicts e.g. with SPD hash thresholds.
2016-09-28 17:56:44 +02:00
Andreas Steffen 40f2589abf gmp: Support of SHA-3 RSA signatures 2016-09-22 17:34:31 +02:00
Tobias Brunner d9fe0ec712 ikev2: (Re-)Queue tasks used to establish an IKE_SA in reset()
Some tasks might get removed immediately once the IKE_SA_INIT response has
been handled even if there were notifies that require a restart of the
IKE_SA (e.g. COOKIE or INVALID_KE_PAYLOAD).  Such a task is ike_vendor,
which caused vendor IDs not to get sent in a retry.  This change ensures
all required tasks are queued after the reset, which some callers did
already anyway.
2016-09-06 10:09:17 +02:00
Tobias Brunner fd1662cdbd ikev2: Store proposal on IKE_SA before creating DH object
This might be useful for custom implementations of keymat_t.
2016-09-06 09:38:22 +02:00
Tobias Brunner 17ecc104fb ikev1: Ignore the last two bytes of the Cisco Unity vendor ID
These seem to indicate the major and minor version of the protocol, like
e.g. for the DPD vendor ID.  Some implementations seem to send versions
other than 1.0 so we just ignore these for now when checking for known
vendor IDs.

Fixes #2088.
2016-08-24 17:46:05 +02:00
Tobias Brunner 60d0f52fd6 ike1: Flush active queue when queueing a delete of the IKE_SA
By aborting the active task we don't have to wait for potential
retransmits if the other peer does not respond to the current task.
Since IKEv1 has no sequential message IDs and INFORMATIONALs are no real
exchanges this should not be a problem.

Fixes #1537
References #429, #1410
Closes strongswan/strongswan#48
2016-07-19 11:48:17 +02:00
Tobias Brunner 15cea08adc child-rekey: Only rekey installed CHILD_SAs
Depending on the lifetimes a CHILD_SA we rekeyed as responder might
expire shortly afterwards.  We don't want to rekey it again.

When retrying due to an INVALID_KE_PAYLOAD notify the expected state
is CHILD_REKEYING if it is anything else (e.g. due to a collision) we
ignore it.

We also abort the exchange properly if we don't find the CHILD_SA, no
need for an empty INFORMATIONAL exchange anymore.
2016-06-17 18:48:08 +02:00
Tobias Brunner 6d8041d46b child-rekey: Ignore failed colliding CHILD_SA rekeyings
If a passive rekeying fails due to an INVALID_KE_PAYLOAD we don't want
to consider this task later when resolving collisions.  This previously
might have caused the wrong SA to get deleted/installed based on the nonces
in the unsuccessful exchange.
2016-06-17 18:48:08 +02:00
Tobias Brunner b92f11c3bd child-create: Retry creating the CHILD_SA if TEMPORARY_FAILURE is received
We queue a delayed task that is initiated after a while.
2016-06-17 18:48:07 +02:00
Tobias Brunner 208678e6e1 ikev2: Add possibility to delay initiation of a queued task
Such a task is not initiated unless a certain time has passed.  This
allows delaying certain tasks but avoids problems if we'd do this
via a scheduled job (e.g. if the IKE_SA is rekeyed in the meantime).

If the IKE_SA is rekeyed the delay of such tasks is reset when the
tasks are adopted i.e. they get executed immediately on the new IKE_SA.

This hasn't been implemented for IKEv1 yet.
2016-06-17 18:48:07 +02:00
Tobias Brunner 4e2e7d4fec ike: Reduce RETRY_INTERVAL a bit
Retry exchanges between 5 and 15 seconds after a temporary failure.
2016-06-17 18:48:07 +02:00
Tobias Brunner 2045cadc1c ike-rekey: Return TEMPORARY_FAILURE when concurrently creating a CHILD_SA 2016-06-17 18:48:07 +02:00
Tobias Brunner 0a954d6789 ike: Add configuration option to switch to preferring supplied proposals over local ones 2016-06-17 18:48:07 +02:00
Tobias Brunner f2ea230b91 child-cfg: Add option to prefer supplied proposals over locally configured ones 2016-06-17 18:48:07 +02:00
Tobias Brunner 3a40d572c6 ike-cfg: Add option to prefer supplied proposals over locally configured ones 2016-06-17 18:48:07 +02:00
Tobias Brunner 09711198a7 ike-rekey: Make sure to ignore task when detecting collisions if ike-init subtask failed
For instance, if INVALID_KE_PAYLOAD is returned we don't want this task
to affect any active rekeying (no new SA has been established so far).
2016-06-17 18:48:06 +02:00
Tobias Brunner f67199378d ike-rekey: Handle undetected collisions also if delete is delayed
If the peer does not detect the rekey collision and deletes the old
IKE_SA and then receives the colliding rekey request it will respond with
TEMPORARY_FAILURE.  That notify may arrive before the DELETE does, in
which case we may just conclude the rekeying initiated by the peer.

Also, since the IKE_SA is destroyed in any case when we receive a delete
there is no point in storing the delete task in collide() as process_i()
in the ike-rekey task will never be called.
2016-06-17 18:48:06 +02:00
Tobias Brunner 7426576184 ike-rekey: There is no passive reauth task, so it will never collide with one 2016-06-17 18:48:06 +02:00
Tobias Brunner 724d65900c ike-rekey: Ignore colliding rekey tasks that did not create an IKE_SA
This simplifies collision handling and we don't need to know about these
tasks when concluding the rekeying we initiated.
2016-06-17 18:48:06 +02:00
Tobias Brunner 1b989dd4c5 ike-rekey: Properly handle situation if the peer did not notice the rekey collision
We conclude the rekeying before deleting the IKE_SA.  Waiting for the
potential TEMPORARY_FAILURE notify is no good because if that response
does not reach us the peer will not retransmit it upon our retransmits
of the rekey request if it already deleted the IKE_SA after receiving
our response to the delete.
2016-06-17 18:48:06 +02:00
Tobias Brunner 6270bbde6a ike-delete: Handle deletes while rekeying differently if there was a collision
We treat these as if we concluded the rekeying, the active ike-rekey task
will handle the collision afterwards.
2016-06-17 18:48:06 +02:00
Tobias Brunner 13da616118 ike-rekey: Add method to check if there was a rekey collision 2016-06-17 18:48:06 +02:00
Tobias Brunner 1cca20705a ikev2: Check for collisions after handling IKE deletion 2016-06-17 18:48:06 +02:00