Commit Graph
4359 Commits
Author SHA1 Message Date
Tobias Brunner e334bd46b1 ike-auth: Move packet collection to post_build() method
This way we avoid having to pre-generate the message when it could
theoretically still get modified by a task that follows or from a plugin
via message() hook.
2022-06-29 10:28:50 +02:00
Tobias Brunner 44629bbadb ikev2: Delay IKE key derivation until next message
In particular as responder, this delays costly cryptographic operations
until the IKE_AUTH request is received, which is preferable to reduce
the impact of DoS attacks.

Another advantage is that the key material is not changed until all tasks
built or processed a message.
2022-06-29 10:28:50 +02:00
Tobias Brunner 2a9323a18a ikev2: Use hashes to detect retransmits
This way we avoid parsing messages with unexpected message IDs, which
might not even be possible if we don't have the keys anymore.  However,
the next commit should avoid the latter and this way we avoid deriving
keys for retransmits or unexpected messages.

This also changes how retransmits for fragmented messages are triggered.
Previously, we waited for all fragments and reconstructed the message
before retransmitting the response.  Now we only track the first
fragment and if we receive a retransmit of it respond immediately
without waiting for other fragments (which are now ignored).  This is in
compliance with RFC 7383, section 2.6.1, and can avoid issues if there
are lots of fragments.
2022-06-29 10:28:50 +02:00
Tobias Brunner 639af09b2e child-sa: Cache and forward actual initiator flag for outbound SA
Kernel interfaces (e.g. TKM) might rely on this flag to be correct.
2022-06-29 10:28:50 +02:00
Tobias Brunner 8d6ed71a55 ikev2: Send deletes also for rekeyed SAs
This way we can use the IKE_REKEYED state for both redundant and old SAs
to suppress ike_updown().

In the ike-delete task we don't suppress events in state IKE_REKEYING as
that's the case when we delete an SA the peer is currently rekeying with
multiple key exchanges.
2022-06-29 10:28:50 +02:00
Tobias Brunner b6652ababe ikev2: Let ike/child-rekey tasks indicate if the passive task was adopted
This gives us more flexibility with tasks that return NEED_MORE (currently
none of the colliding tasks do, but that will change with multi-KE
rekeyings).  The active task has to check itself if the passive task is
done and should be removed from the task manager.
2022-06-29 10:28:50 +02:00
Tobias Brunner 7ffeed01c0 ike-rekey: Remove collision task type checks
Since f67199378d ("ike-rekey: Handle undetected collisions also if
delete is delayed") we only ever track tasks of type TASK_IKE_REKEY, so
there is no need to check the type or use the generic task_t interface.

Also changed some of the comments to clarify collision handling.
2022-06-29 10:28:50 +02:00
Tobias Brunner 87a86e9c98 ike-rekey: Don't actively rekey already rekeyed SAs
If the peer successfully rekeyed the SA it gets marked as IKE_REKEYED
and it remains until the peer deletes it (or a timeout).  There is no
point in rekeying such SAs again.

IKE_REKEYING will be relevant if we have multi-KE rekeyings and are
waiting for followup key exchanges for a passive rekeying.
2022-06-29 10:28:50 +02:00
Tobias Brunner 39c66693a0 ike-init: Ignore COOKIE payloads during rekeying
This ensures that process_i() only returns NEED_MORE due to multiple
key exchanges or an INVALID_KE_PAYLOAD notify.
2022-06-29 10:28:50 +02:00
Tobias Brunner e5bf9b23b2 ike-sa-manager: Log SPIs when checking in an IKE_SA 2022-06-29 10:28:50 +02:00
Tobias Brunner c1987aefbe message: Fix payload type in last unprotected payload of a fragmented message 2022-06-29 10:28:50 +02:00
Tobias Brunner ba348b4799 ike-rekey: Reset IKE_SA after processing CREATE_CHILD_SA request
This probably didn't cause any problems, as there wasn't really anything
happening between the calls, but reset it anyway, just to be safe.
2022-06-29 10:28:50 +02:00
Tobias Brunner 36312808d1 ikev2: Allow tasks to do work after processing requests/responses 2022-06-29 10:28:50 +02:00
Tobias Brunner 210e2177aa task: Add optional post_process() method
This will allows tasks to do some work after a message has been
processed.
2022-06-29 10:28:50 +02:00
Tobias Brunner 1719e0f0aa ikev2: Allow tasks to do work after generating requests/responses 2022-06-29 10:28:50 +02:00
Tobias Brunner 87caf36bb9 task: Add optional post_build() method
This will allow tasks to do some work after the message has been
generated.
2022-06-29 10:28:50 +02:00
Tobias Brunner 28b33d7cac ike-auth: Support exchange between IKE_SA_INIT and IKE_AUTH 2022-06-29 10:28:50 +02:00
Tobias Brunner 09a4aed3a2 child-create: Support exchange between IKE_SA_INIT and IKE_AUTH 2022-06-29 10:28:50 +02:00
Tobias Brunner 3a8ea08686 ike-mobike: Support exchange between IKE_SA_INIT and IKE_AUTH
This changes the MID of the first IKE_AUTH message.
2022-06-29 10:28:50 +02:00
Tobias Brunner 366fce8f03 ike-config: Support exchange between IKE_SA_INIT and IKE_AUTH
This changes the MID of the first IKE_AUTH message.
2022-06-29 10:28:50 +02:00
Tobias Brunner 09d4497536 ike-cert-post: Make absolutely sure certificates are only added to IKE_AUTH
The AUTH payload check in build_certs() should be fine, but add some
extra checks just to make really sure and also for clarification.
2022-06-29 10:28:50 +02:00
Tobias Brunner f2e79bf334 ike-cert-pre: Support exchange between IKE_SA_INIT and IKE_AUTH
The first IKE_AUTH does not have MID 1 if that's the case.
2022-06-29 10:28:50 +02:00
Tobias Brunner f00e80d759 status: Add return_need_more() utility function 2022-06-29 10:28:50 +02:00
Tobias Brunner ec350ebb78 child-cfg: Generalize get_ke_method() method 2022-06-29 10:28:50 +02:00
Tobias Brunner 093fc1ac63 ike-cfg: Generalize get_ke_method() method 2022-06-29 10:28:50 +02:00
Tobias Brunner 3bebf5bf8d proposal: Generalize KE methods 2022-06-29 10:28:50 +02:00
Andreas Steffen b7c167f972 Rename MODP_NONE to KE_NONE 2022-06-29 10:28:50 +02:00
Tobias Brunner 3af7c6db87 Rename diffie_hellman_t to key_exchange_t and change the interface etc.
This makes it more generic so we can use it for QSKE methods.
2022-06-29 10:28:50 +02:00
Tobias Brunner df18934d20 Replace or remove wiki.strongswan.org URLs 2022-06-28 13:33:51 +02:00
Tobias Brunner 19ef2aec15 Update copyright headers after acquisition by secunet 2022-06-28 10:22:56 +02:00
Tobias Brunner 64d73235c4 adopt-children-job: Avoid reordering CHILD_SAs
References strongswan/strongswan#1041
2022-05-10 09:08:17 +02:00
Xiao Liang 3b742c75ab quick-mode: Remove outbound SA/policy of rekeyed CHILD_SA
Remove outbound SA and policy of rekeyed CHILD_SA since only one is valid.
Otherwise, during update-SA job (when NAT mapping changed), CHILD_SA are
updated and installed one by one, leaving a window where old SAs are being
used. There are also circumstances where the new SA is not processed last.

Closes strongswan/strongswan#1041
2022-05-10 09:07:37 +02:00
Tobias Brunner 4de8b81dea keymat_v2: Fix error message if KDF can't be created
Fixes: f619b833ac ("keymat_v2: Use plugin-provided KDF_PRF to derive SKEYSEED")
References strongswan/strongswan#1026
2022-05-06 11:45:10 +02:00
Tobias Brunner c9d471091f Use mallinfo2() if available
mallinfo() is deprecated because it uses `int` for the members of the
returned struct, whereas mallinfo2() uses `size_t`.  It's available
since glibc 2.33.
2022-04-25 14:16:20 +02:00
Tobias Brunner f4d6539b49 ikev2: Maintain labels during make-before-break reauthentication 2022-04-20 14:45:41 +02:00
Tobias Brunner f619b833ac keymat_v2: Use plugin-provided KDF_PRF to derive SKEYSEED 2022-04-14 19:02:56 +02:00
Tobias Brunner 743b486118 unit-tests: Hand out an actual shared secret and pubkey in mock KE implementation
Makes this a bit more realistic and makes key derivation via OpenSSL's
HKDF work during tests.
2022-04-14 19:02:56 +02:00
Tobias Brunner 9cb3c10418 keymat_v1: Derive CHILD_SA keys without using prf_plus_t
We already expand skeyid_e in a similar fashion so do this analogous
without relying on prf_plus_t.
2022-04-14 19:02:56 +02:00
Tobias Brunner 7161c87617 keymat_v2: Use plugin-provided prf+ to derive keys 2022-04-14 19:02:56 +02:00
Tobias Brunner 742134c112 keymat_v2: Refactor CHILD_SA key derivation so it only needs one prf+ call 2022-04-14 18:54:24 +02:00
Tobias Brunner 00cfc05467 keymat_v2: Refactor IKE key derivation so it only needs one prf+ call 2022-04-14 18:54:24 +02:00
Tobias Brunner ec17fa2fef vici: Report registered KDFs 2022-04-14 18:54:24 +02:00
Tobias Brunner 07bf428ad1 stroke: List registered KDFs 2022-04-14 18:54:24 +02:00
Tobias Brunner b1c7fac768 vici: Add options to only return specific CHILD_SAs in list-sas() 2022-04-14 18:42:01 +02:00
Tobias Brunner 2994347d18 vici: Report security label on CHILD_SA, policies and configs 2022-04-14 18:42:01 +02:00
Tobias Brunner 7cf6f29ac5 vici: Make security labels and mode configurable 2022-04-14 18:42:01 +02:00
Tobias Brunner f52e565ad3 kernel-netlink: Forward labels from acquires 2022-04-14 18:42:01 +02:00
Tobias Brunner 0a673794d8 trap-manager: Add support to handle acquires with security labels 2022-04-14 18:42:01 +02:00
Tobias Brunner 81c362829e kernel-handler: Log security label received with acquire 2022-04-14 18:42:01 +02:00
Tobias Brunner 52a05d7f6c kernel-interface: Optionally pass security label with an acquire 2022-04-14 18:42:01 +02:00