Commit Graph
19030 Commits
Author SHA1 Message Date
Tobias Brunner 58f278f932 charon-nm: Use an XFRM interface if available
This allows NM more freedom in regards to how it wants to use the passed
device.  In particular, if dnsmasq is used with NM as that binds to the
interface to send requests via VPN.

Installing the VIPs on lo avoids weird address removal/addition events
that happen for IPv6 on the physical interface (which would cause the VIP
to get incorrectly detected as non-VIP address and ignored during
deletion).

We could let NM install routes via XFRM interface, however, that causes
problems with e.g. the bypass-lan plugin (the throw routes in table 220
wouldn't have any effect).  We could let it install regular routes in
the main table, but determining the physical interface would be tricky
as the routes installed by NM, also in the main table, would conflict.

So instead we let the kernel-netlink interface install routes via XFRM
interface and to avoid routing the IKE traffic that way, we set a mark
on the IKE socket and exclude traffic with that mark from our routing
table.
2023-02-22 13:43:17 +01:00
Tobias Brunner 04486507b2 kernel-netlink: Add an option to install routes for SAs with XFRM interfaces
Since these might conflict with IKE traffic, this requires special care.
One option is to install bypass policies for the peer, which install
appropriate (throw) routes.  However, that won't work if the traffic to
the gateway itself should be protected, in particular, for host-to-host
tunnels.  So an alternative is to set a mark for the IKE socket and then
exclude that traffic from table 220 via the kernel-netlink plugin's
fwmark option.
2023-02-22 13:37:45 +01:00
Tobias Brunner 0cc780d317 kernel-netlink: Automatically bring up XFRM interfaces after creation 2023-02-22 13:37:45 +01:00
Tobias Brunner e1ff1eefcf kernel-netlink: Add manager for XFRM interfaces
The manager will allow charon-nm to create XFRM interfaces if supported
by the kernel instead of creating an unused dummy TUN interface.

The xfrmi tool is mostly obsolete nowadays as iproute2 supports creating
XFRM interfaces since 5.1.0 (2019-05).  Older Debians don't ship that and
early versions didn't list the interface IDs.  So there might still be
some uses for this tool.
2023-02-22 13:37:45 +01:00
Tobias Brunner 85d56b1c6a charon-nm: Tie lifetime of dummy TUN device to connection
NM doesn't terminate charon-nm after disconnecting, so the TUN device
previously stayed around even if no connection was established.  This
might be a bit more what users expect.
2023-02-22 13:37:45 +01:00
Tobias Brunner 5401a74d36 eap-tls: Add support for TLS 1.3
As defined in RFC 9190, a "protected success indication" (0x00) is sent
from the server to the client over the TLS connection when using TLS 1.3.

The client responds with an empty EAP message, which is interpreted as
acknowledgement in our stack.

If we ever support session resumption with tunneled methods such as
EAP-TTLS, we'd have to send such an indication there too.
2023-02-22 13:34:53 +01:00
Tobias Brunner 06abdf1d31 tls-crypto: Fix MSK calculation for TLS 1.3
As noted in 121ac4b9e3 ("tls-crypto: Generate MSK for TLS 1.3"), the
calculation was only preliminary.  It is now fixed according to RFC 9190
and draft-ietf-emu-tls-eap-types (soon to become an RFC, currently in
the RFC editor queue).

Fixes: 121ac4b9e3 ("tls-crypto: Generate MSK for TLS 1.3")
2023-02-22 13:34:31 +01:00
Tobias Brunner 5a512ff56b Merge branch 'kernel-netlink-sa-lastused'
Adds support for a change in Linux kernel 6.2 that allows retrieving
the last use time of an SA from the SA itself instead of having to query
the policies.
2023-02-22 13:21:31 +01:00
Tobias Brunner 346a050c36 kernel-netlink: Increase log level for dumped Netlink messages
Some of these contain key material so they should be logged on level 4.
2023-02-22 13:20:10 +01:00
Tobias Brunner 1138b629fb android: Announce support for TFC padding
Has been supported by libipsec for a long time (since 5.1.1).  UDP encap
is already enforced via config, this just makes the flags the same as
in kernel-libipsec.
2023-02-22 13:20:10 +01:00
Tobias Brunner e21290ec30 kernel-netlink: Read last use time from SA if possible
Since 6.2 the Linux kernel updates the last use time per SA.  In
previous releases the attribute was only updated and reported for
specific outbound IPv6 SAs.

Using this reduces the number of kernel queries per CHILD_SA: for DPDs
from two policy queries (IN/FWD) to a single query of the inbound SA,
and for status reports the three policy queries (IN/FWD/OUT) can be
omitted and only the two SAs have to be queried.  For NAT keepalives the
number of queries doesn't change but a policy query (OUT) is replaced by
a query for the outbound SA.

While we could use the existence of the attribute as indicator for its
support, we don't know this until we queried an SA.  By using a version
check we can announce the feature from the start.
2023-02-22 13:20:10 +01:00
Tobias Brunner 6301b880df child-sa: Query policies only if querying SAs doesn't update the use time 2023-02-22 13:20:10 +01:00
Tobias Brunner b9131c34d3 kernel-interface: Add feature to indicate if query_sa() returns last use time
Currently supported by libipsec and PF_KEY on macOS (FreeBSD, like Linux,
reports the time the SA was first used in sadb_lifetime_usetime - it also
triggers rekeyings based on that, which Linux doesn't, it also triggers
them if an SA is never used).
2023-02-22 13:20:10 +01:00
Tobias Brunner 1efdb0f791 ikev2: Add option to prefer childless IKE_SAs as initiator 2023-02-22 13:19:46 +01:00
Tobias Brunner 4784c92c55 swanctl: Terminate --monitor-sa command if daemon closes connection 2023-02-22 11:44:14 +01:00
Tobias Brunner 9e5533fef9 libvici: Add callback invoked if connection is closed by daemon 2023-02-22 11:44:14 +01:00
Tobias Brunner 2b206eaf6a github: Explicitly install pkg-config in macOS build
Apparently not installed anymore in the latest build image.  If it's
missing, we see errors like these:

  configure.ac:38: error: possibly undefined macro: AC_DEFINE
2023-02-20 14:50:02 +01:00
Tobias Brunner cbd69ec732 android: Update the README for the build via NDK 2023-02-20 14:11:59 +01:00
Tobias Brunner af93db93e6 android: New release after OpenSSL plugin fix 2023-02-17 16:59:13 +01:00
Tobias Brunner 48ef9bfbb6 openssl: Fix size of plugin feature array
Fixes: 312847e1a3 ("openssl: Add curve25519 and curve448 after ECDH groups")
2023-02-17 16:58:19 +01:00
Tobias Brunner 27d41a2442 android: New release after fixing interoperability issue with Zyxel firewalls 2023-02-17 16:42:42 +01:00
Tobias Brunner 312847e1a3 openssl: Add curve25519 and curve448 after ECDH groups
This was the order before 46a6b06282 ("openssl: Only announce ECDH
groups actually supported by OpenSSL") but that's not really the reason
for this change.  It's related to the Android app, where we previously
didn't support these DH groups in BoringSSL and added the curve25519
plugin after the openssl plugin instead.  This resulted in the same
order, i.e. ECDH groups before curve25519.  With the switch to OpenSSL
and the mentioned commit, this changed and curve25519 was now the first
group that was proposed and used for the KE payload.  Not really an
issue you'd think, however, there are apparently Zyxel Firewalls with
older firmware versions (some forum posts mentioned a fix in V5.31) that
can't handle KE payloads with DH groups > 21 (ecp521). So with
curve25519 (31) proposed in the KE payload, they silently dropped the
IKE_SA_INIT request and no connection could be established.
2023-02-17 16:40:59 +01:00
Tobias Brunner 4d3fc90caf libtls: Fix double-free for untrusted peer certificates
`public` is returned, but previously only if a trusted key was found.
We obviously don't want to return untrusted keys and since the reference
was correctly destroyed after determining the key type, this later caused
a double-free.

Fixes: 63fd718915 ("libtls: call create_public_enumerator() with key_type")
2023-02-17 15:11:43 +01:00
Tobias BrunnerandThomas Egerer 0de42047a9 enum: Add functions to add and remove mappings from enum names
Co-authored-by: Thomas Egerer <thomas.egerer@secunet.com>
2023-02-17 13:37:38 +01:00
Tobias Brunner 3cf5653640 Merge branch 'hw-packet-offload'
This adds support for the new "packet" hardware offload feature that's
added to the Linux kernel with 6.2.  In this mode, the device handles
the complete framing of the ESP packet as well as the policy checks,
in addition to the crypto.

For the IKE sockets, port-based bypass policies are automatically
offloaded to devices that support it.

Closes strongswan/strongswan#1462
2023-02-17 13:29:56 +01:00
Tobias Brunner 15c6360145 kernel-netlink: Offload bypass policies for IKE ports on interfaces
While this uses the same mechanism, it's not necessary to explicitly
enable port_bypass, the regular socket policies work fine to bypass any
software policies.
2023-02-16 14:45:57 +01:00
Tobias Brunner 77a5c9514c kernel-netlink: Use event socket wrapper for XFRM and networking events 2023-02-16 13:25:35 +01:00
Tobias Brunner cb0bdb847d kernel-netlink: Add simple wrapper for Netlink event sockets 2023-02-16 13:25:35 +01:00
Tobias Brunner e323539428 kernel-pfkey: Always register for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner 30cb3bd4d5 kernel-pfroute: Always listen for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner d7ccb44354 kernel-netlink: Always register for events
The starter-specific code path isn't necessary anymore since
d8fdd1018e ("starter: Don't flush SAs in the kernel").
2023-02-16 13:25:35 +01:00
Tobias Brunner 4e91ff7d8c starter: Remove starter-specific plugin lists
It hasn't loaded any plugins since d8fdd1018e ("starter: Don't flush
SAs in the kernel"), which was released with 5.3.3.
2023-02-16 13:25:34 +01:00
Tobias Brunner 68ccb1930c kernel-netlink: Fallback to configured interface when HW offloading policies
This allows offloading bypass and drop policies to a specific interface
by configuring `interface` and `hw_offload=packet` (`auto` works too).
2023-02-16 13:25:34 +01:00
Tobias Brunner 763014c028 shunt-manager: Pass HW offload mode when installing policies 2023-02-16 13:25:34 +01:00
Tobias Brunner 2b8f26308f vici: Update offloading configuration for full packet HW offloading 2023-02-16 13:25:34 +01:00
Tobias Brunner 55719d7de5 kernel-netlink: Add support for full packet and policy HW offloading 2023-02-16 13:25:34 +01:00
Tobias Brunner 46cfebe4ab child-sa: Pass HW offload mode for policies 2023-02-16 13:25:34 +01:00
Tobias Brunner af1eeda08b kernel-ipsec: Add HW offload mode to policies 2023-02-16 13:25:34 +01:00
Tobias Brunner 056f3e7742 Merge branch 'android-updates'
Switched from BoringSSL to OpenSSL. A script is provided to build the
library as needed.
2023-02-15 14:50:12 +01:00
Tobias Brunner 5390da1412 android: New release after switching to OpenSSL 2023-02-13 15:46:53 +01:00
Tobias Brunner 65aff933f1 android: Use correct language code for Ukrainian
While UA is the country code, the language code is apparently uk.
2023-02-13 15:46:53 +01:00
Tobias Brunner 937f726154 android: Clean up plugin list after switching to OpenSSL
Keep the kdf plugin because of AES-XCBC (and CAMELLIA-XCBC, which is now
supported due to OpenSSL).  Other plugins like fips-prf, pubkey or pkcs8
were never actually used by the app.  The random plugin might have been
necessary with early versions.
2023-02-13 15:30:58 +01:00
Tobias Brunner eac27ce677 android: Use custom-built OpenSSL for GH action 2023-02-13 15:30:58 +01:00
Tobias Brunner f959157d31 android: Increase minSdkVersion to 21 (Android 5.0)
Newer NDKs haven't supported the version(s) we used for a while. Also,
versions < 21 will be removed with the next version of the NDK.
2023-02-13 15:30:58 +01:00
Tobias Brunner 7e5c4bbb32 android: Add a script to build OpenSSL's libcrypto as needed by the app
The build script requires the paths to the NDK and OpenSSL sources.

It runs the build in a Docker container, by default. But if the required
tools are installed on the system (currently jq, make and perl) it can
also be run directly on the system by defining NO_DOCKER.

A relatively recent version of the NDK is required (the pre-built
toolchains are required).
2023-02-13 15:30:58 +01:00
Tobias Brunner 2fc8b14918 android: Add the application ID to the log 2023-02-10 11:27:44 +01:00
Tobias Brunner 12c925a7e7 android: Update screenshots and add more with advanced settings 2023-02-09 18:04:07 +01:00
Tobias Brunner 7361078d3d android: Update Gradle plugin 2023-02-09 18:04:07 +01:00
Tobias Brunner 77bd5ab1a8 github: Use OpenSSL 3.0.8 for tests 2023-02-07 18:06:16 +01:00
Tobias Brunner 1a8106ee0d github: Use tpm2-tss 3.2.2 for tests 2023-01-31 17:22:44 +01:00