18369 Commits

Author SHA1 Message Date
Andreas Steffen
1e444454e1 Version bump to 5.9.7rc1 5.9.7rc1 2022-07-23 14:38:36 +02:00
Andreas Steffen
c01d765c11 testing: Increased memory of KVM instance sun 2022-07-23 14:36:50 +02:00
Andreas Steffen
67f7d8fe8a testing: Replace deprecated tempfile command by mktemp 2022-07-23 11:28:08 +02:00
Tobias Brunner
77553bfee6 dhcp: Fix retransmission timeouts
The previous code did not ensure that there was a delay of at least
`try` seconds after each sent request.  Instead, whenever the condvar was
signaled, which could be due to retransmitted responses or messages for
unrelated transactions (there could even be spurious wakeups), the counter
was increased and a retransmit sent.  So instead of actually waiting for
15 seconds for a response (and sending 4 retransmits over that timespan),
it could happen that all five messages were sent within a second without
enough time to actually receive a response.

Using an absolute timeout that we reuse as long as there was no timeout
and the condvar was signaled for something unrelated, should ensure we
wait at least the intended delay after each sent message.

Closes strongswan/strongswan#1154
2022-07-22 07:20:30 +02:00
Tobias Brunner
44ab5533b0 connmark: Consider configured mask in installed firewall rules
This allows using the upper parts of the marks for other purposes.  For
instance, with `mark_in=mark_out=%unique/0x0000ffff` mark values in the
upper two bytes would not get reset by the rules installed by this plugin.
However, note that in this example the daemon would have to get restarted
after 65'535 CHILD_SAs to reset the counter for unique marks, which is a
global 32-bit counter that's unaware of any masks.

Closes strongswan/strongswan#1087
2022-07-18 15:05:51 +02:00
Tobias Brunner
42ed6b44b2 af-alg: Fix "'strncpy' specified bound equals destination size" warnings 2022-07-18 14:49:12 +02:00
Tobias Brunner
112bb465fb openssl: Add support for AES and Camellia in CTR mode 2022-07-18 13:01:22 +02:00
Tobias Brunner
3d966d6d0a aggressive-mode: Determine local identity before deriving keys
This might require a PSK, for which the local identity might be necessary.
2022-07-18 12:56:20 +02:00
Tobias Brunner
833333eae9 child-cfg: Skip non-matching TS instead of replacing them for transport mode
get_traffic_selectors() is called the same way also as responder when
selecting child configs via peer_cfg_t::select_child_cfg().  Replacing
TS for all child configs could lead to selecting one that later fails
to actually narrow the traffic selectors.  Ignoring non-matching TS also
helps if we have a trap config with multiple remote subnets (otherwise,
we'd have to filter duplicates afterwards).

When installing traps, the hosts might be %any, in which case we allow
the configured (technically non-matching) TS for the wildcard use case.

Fixes: da82786b2d8c ("child-cfg: Always apply hosts to traffic selectors if proposing transport mode")
Closes strongswan/strongswan#1143
2022-07-18 12:44:20 +02:00
Tobias Brunner
1f242e772b configure: Add option to build with extended compiler warnings and -Werror
Setting -Werror in CFLAGS passed to configure is not ideal as that affects
all the checks performed by the script.

This caused an issue with newer versions of Autoconf and the AC_PROG_LEX
macro that insisted on finding a lexer library.  But due to warnings from
the generated test lexer (misleading indentation) that got turned into
errors no library was found (none would have been necessary), so LEX was
not set and no lexers were built.

With this option enabled, we add -Werror to CFLAGS after all tests ran.
It also enables additional warnings via -Wextra.

The option is auto-enabled when building from the repository.
2022-07-18 12:42:24 +02:00
Tobias Brunner
9c86787de5 libfast: Fix incompatible function types warning 2022-07-18 12:42:24 +02:00
Tobias Brunner
36d16e5b24 forecast: Fix incompatible function types warning 2022-07-18 12:42:24 +02:00
Tobias Brunner
b37a3e249a test-runner: Fix compiler warning
Making the variable volatile avoids a "variable ‘failure’ might be
clobbered by ‘longjmp’" warning (or error when compiling with
-Werror) that's triggered via -Wextra.
2022-07-18 12:42:24 +02:00
Tobias Brunner
1656e3806b configure: Add noyywrap option to AC_PROG_LEX for Autoconf 2.70+
FreeBSD packages 2.71 and that spits out a deprecation warning if we
don't set this.
2022-07-18 12:42:24 +02:00
Tobias Brunner
eae30af029 Use wolfSSL 5.4.0 for tests
The 5.4.0 update changed the default bignum implementation to what
could explicitly be enabled via `--enable-sp-math-all`.  Since this uses
fixed-sized buffers sufficient for key sizes of SP_INT_BITS, with a default
of 4096, modp6144 and modp8192 didn't work anymore (wc_DhGenerateKeyPair()
returned MP_EXPTMOD_E).  So we have to adapt the feature checks for this.

To support the larger DH groups we can either increase the buffer size
via `--with-max-rsa-bits` or add `--enable-heapmath` so buffers get
(re-)allocated as needed.  We go with the latter for now.
2022-07-18 12:42:24 +02:00
Andreas Steffen
110e8e6608 doc: Removed the standards directory
This collection of Internet standards and drafts hadn't been
updated for a long time and the documents are readily available
on the Internet anyway. The strongSwan documentation page

  https://docs.strongswan.org/docs/5.9/features/ietf.html

specifies which standards are currently supported.
2022-07-12 10:24:42 +02:00
Andreas Steffen
2b474073d9 pem: Support PEM-encoded PKCS#7 container 2022-07-06 20:38:00 +02:00
Andreas Steffen
e8c2ae3c54 Version bump to 5.9.7dr2 5.9.7dr2 2022-06-29 11:33:34 +02:00
Tobias Brunner
30faf04e92 Merge branch 'multi-ke-backport'
This merge includes changes that were created for the upcoming IKEv2
extension for multiple key exchanges over the last four years, but which
are not directly related to the actual protocol changes.

Changes include renaming diffie_hellman_t to the more generic
key_exchange_t (also renamed are some of the interface's methods),
making utility functions that deal with DH groups more generic, and let
tasks handle the first IKE_AUTH message more reliably by not depending
on e.g. specific message IDs.

One significant change is delaying the IKEv2 key derivation until
the keys are actually needed to process or send the next message.  So
instead of deriving the keys directly while processing an IKE_SA_INIT
request (which could come from a spoofed address), this is delayed until
the corresponding IKE_AUTH request is received.  Implementations of the
key_exchange_t interface are now expected to do the key derivation and
any costly public key validation in get_shared_secret() and not
set_public_key().

Sent IKE_SA_INIT messages are now also not pre-generated anymore to collect
their encoding for the authentication.  Instead, a new post_build() hook
allows the ike-auth task to do so after the actual message has been built,
which allows later tasks and plugins (via message() hook) to modify the
message (e.g. add notifies) after the ike-auth task's build() method
already ran.

Also changed is how inbound requests are processed and retransmits are
detected.  Instead of parsing all inbound messages right away (which
might trigger a key derivation or require keys we don't have anymore in
the multi-KE use case), we now first check a request's message ID and
compare its hash to that of the previous request to decide if it's a
valid retransmit.  For fragmented messages, we only keep track of the
first fragment so we can send the corresponding response immediately if
a retransmit of it is received, instead of waiting for all fragments
and reconstructing the message, which we did before.
2022-06-29 11:18:28 +02:00
Tobias Brunner
23b0220b1c unit-tests: Allow configuring log levels for individual groups 2022-06-29 10:28:50 +02:00
Tobias Brunner
35edbc4048 debug: Support configuring different log levels for groups in default logger 2022-06-29 10:28:50 +02:00
Tobias Brunner
4e5a2037e7 wolfssl: Move shared secret calculation to get_shared_secret()
The ECDH implementation gets a bit simpler since we removed the
ecp_x_coordinate_only option a while ago.

Also added calls to verify public keys.
2022-06-29 10:28:50 +02:00
Tobias Brunner
26ca0c9f70 pkcs11: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner
d95082ce0d gcrypt: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner
ed3494ef7b curve25519: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner
31f467d70b botan: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner
0e82d5cc2c gmp: Move shared secret calculation to get_shared_secret()
This avoids doing costly operations when just setting the public key.
For the same reason the optional extended public key check is moved.
2022-06-29 10:28:50 +02:00
Tobias Brunner
0351b5af3b key-exchange: Warn about costly operations in set_public_key() 2022-06-29 10:28:50 +02:00
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 f67199378df9 ("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