18881 Commits

Author SHA1 Message Date
Tobias Brunner
dfbafffc45 android: Increase compile-/targetSdkVersion to 33 (Android 13) 2023-08-29 18:03:30 +02:00
Tobias Brunner
ddf84c165d android: Request permission to display notifications on Android 13
Note that displaying the notification for the background service is
apparently not strictly necessary.  So it's fine if the user wants to
hide it.  That the service is running can still be seen in the task
manager (pull down the status drawer twice, there is a bullet with a number
at the bottom if the service is running).

Simply use the system dialog.  If the user denies it twice, it won't show
up again.  The explanation dialog would not show up the first time (i.e.
shouldShowRequestPermissionRationale() returns false), only once the user
denied the permission once.  Currently seems like a bit much work
as we don't need the user to allow notifications.
2023-08-29 18:03:30 +02:00
Tobias Brunner
3839bcfe87 android: Compile OpenSSL with hardware acceleration 2023-08-29 18:03:30 +02:00
Tobias Brunner
6d87a86510 android: Use new sockets to determine source IP
Particularly on Samsung devices, the connect() call to dissolve the
previous connection on an existing socket via AF_UNSPEC does fail in
some situations with ECONNREFUSED:

  [KNL] failed to disconnect socket: Connection refused

While creating a new socket is potentially a bit more overhead, this
should avoid the issue.

Closes strongswan/strongswan#1691
2023-08-29 18:03:30 +02:00
Tobias Brunner
5005c2e4ab testing: Use pip from venv to download dependencies
pip3 isn't installed in the base image anymore since 21bf3e41f94a
("testing: Use venv for strongTNC").
2023-08-28 17:49:26 +02:00
Tobias Brunner
a619356b5f kernel-pfroute: Maintain virtual flag when repopulating interface addrs
When adding a virtual IP on a TUN interface, the interface might get
activated (in terms of receiving the event) after we've already set the
virtual flag for the added address.  As the activation repopulates the
addresses on the interface, this cleared the flag and the address would
no longer be treated as virtual IP when installing routes for CHILD_SAs
that reference it in their local traffic selectors.

Closes strongswan/strongswan#1807
2023-07-27 08:21:26 +02:00
Tobias Brunner
006839b06a Merge branch 'netlink-buf'
Fixes an infinite loop if e.g. Netlink event sockets get too many
packets queued and poll() just returns POLLERR for the socket.  Also
increases the default receive buffer size for Netlink sockets to better
support systems with lots of route updates.

Closes strongswan/strongswan#1757
2023-07-26 15:16:57 +02:00
Tobias Brunner
ba9228ab00 watcher: Change handling of POLLERR and remove WATCHER_EXCEPT
We can't actually explicitly listen for errors by passing POLLERR in
`events` (the man page for poll() clearly states it's ignored).  On the
other hand, POLLERR can be returned for any FD and, even worse, it might
be the only event indicated.

The latter caused an infinite loop as we didn't notify the callback nor
clear the error by calling `getsockopt(..., SOL_SOCKET, SO_ERROR, ...)`.
And while the latter would be able to reset the state to break the loop,
it seems to leave the FD in a defunct state where no further events will
be returned by poll().  Notifying the callback works better (the error
is then reported by e.g. recvfrom()) and automatically happened already
if POLLERR was returned together with e.g. POLLIN.

So we now treat POLLERR like the other error indicators we handle (POLLHUP
and POLLINVAL) and just notify the callbacks.
2023-07-26 15:14:50 +02:00
Tobias Brunner
5971fc36c9 kernel-netlink: Also set the receive buffer size on event sockets
This was weirdly overlooked and could cause issues e.g. on hosts with
lots of route changes.
2023-07-26 15:14:50 +02:00
Tobias Brunner
714c939018 kernel-netlink: Increase the default receive buffer size
Also simplify how we try to exceed the system-wide maximum.  We basically
just try to force the value and simply fall back to the regular call.
The kernel actually won't let the latter fail if the value is too big,
it just caps it at the internal maximum.
2023-07-26 15:14:50 +02:00
Tobias Brunner
0b47357091 ike: Fix untracking IKE_SA_INITs with non-zero MIDs and SPIs as half-open SAs
We track all IKE_SA_INIT requests as half-open IKE_SAs but didn't
correctly untrack them if their message ID or responder SPI was non-zero.

References strongswan/strongswan#1775

Fixes: b866ee88bf54 ("ike: Track unprocessed initial IKE messages like half-open IKE_SAs")
2023-07-26 15:13:43 +02:00
Tobias Brunner
849c2c9707 child-rekey: Correctly encode protocol/SPI in CHILD_SA_NOT_FOUND notify
As specified in RFC 7296, section 2.25:

   The SA that the initiator attempted to rekey is indicated by the SPI
   field in the Notify payload, which is copied from the SPI field in
   the REKEY_SA notification.

So we copy that and the protocol verbatim.
2023-07-26 15:09:49 +02:00
Tobias Brunner
10a3c44a41 notify-payload: Add methods to simplify encoding and retrieving IKE SPIs
The get_spi_data() method is currently not used, so that has been
simplified so it can be used for any protocol type and any SPI length.
Same for set_spi_data(), which is currently used for IKEv1 to encode
two SPIs.
2023-07-26 15:09:49 +02:00
Tobias Brunner
e0e99c1dd3 sha3: Make sure to wipe the internal Keccak state 2023-07-26 15:08:33 +02:00
Tobias Brunner
b7d7a6be3a pki: Make sure to wipe decrypted PKCS#7 data 2023-07-26 15:08:33 +02:00
Tobias Brunner
bbbd15dd5c pkcs12: Make sure to wipe potentially decrypted PKCS#7 data 2023-07-26 15:08:33 +02:00
Tobias Brunner
b4694aef49 pkcs7: Make sure to wipe decrypted content 2023-07-26 15:08:33 +02:00
Tobias Brunner
ad8484a6cc aesni: Make sure to wipe salt 2023-07-26 15:08:33 +02:00
Tobias Brunner
9bda4a4415 ccm: Make sure to wipe salt 2023-07-26 15:08:33 +02:00
Tobias Brunner
0abb37b830 gcm: Make sure to wipe salt and H 2023-07-26 15:08:33 +02:00
Tobias Brunner
e8f8d32494 charon-nm: Use configured interface name if available
If connection.interface-name is configured, we use that instead of the
randomly generated name.

References strongswan/strongswan#1747
2023-07-26 15:07:36 +02:00
Tobias Brunner
27a7537d10 charon-nm: Also log basic connection details 2023-07-26 15:07:22 +02:00
Tobias Brunner
69e0c1161d charon-nm: Actually use the created XFRM interface
The created XFRM interface was not actually used (no interface IDs on the
SAs, no routes via interface).  It was basically treated like the dummy
TUN device.  To actually install the routes via XFRM interface, we have
to create it before we install the SAs and policies, signal_ip_config()
happens too late.  We also have to mark the ESP packets the same as IKE
the packets to avoid a routing loop if the server's IP is included in
the remote traffic selector (in particular if it's 0.0.0.0/0 or ::/0).

Fixes: 58f278f93239 ("charon-nm: Use an XFRM interface if available")
2023-07-26 15:07:22 +02:00
Tobias Brunner
36b1a6d76c Use Botan 3.1.1 for tests
The all-zero Ed25519 public key is rejected by botan_pubkey_check_key()
when the key is loaded.

Note that Botan 3 requires GCC 11 or CLANG 14, i.e. can't easily be built
on Debian bullseye or Ubuntu 20.04.

The thread-local storage function gets flagged via various botan FFI
functions when using Botan 3, whitelist that instead of all of them.
2023-07-26 13:09:22 +02:00
Tobias Brunner
1762040ef8 Merge branch 'testing-bookworm'
Use Debian bookworm as base image for testing.
2023-07-26 13:07:37 +02:00
Tobias Brunner
4ba857930c testing: Format total time in a more readable way 2023-07-26 13:06:40 +02:00
Tobias Brunner
99bd7ca2fd testing: Change memory allocation for alice and winnetou and switch to MiB
The services running on alice seem to require a bit more memory with
Debian bookworm, so increase the memory allocation.  But at the same
time reduce winnetou's allocation by the same amount as it really doesn't
require that much memory.

The unit change makes it easier to read.
2023-07-20 15:59:49 +02:00
Tobias Brunner
732909ce1e testing: Hardcode /testresults mount point in winnetou's fstab
Because do-tests runs the restore-defaults script, fstab would get reset
to the default version and the mount point wouldn't be available anymore
after stopping and restarting the guests (unless the guest images were
rebuilt in between).
2023-07-20 15:59:21 +02:00
Tobias Brunner
872781734d testing: Copy guest-specific files after default files
This allows overriding some files per guest.
2023-07-20 15:59:21 +02:00
Tobias Brunner
79ad33bfba testing: Use Debian 12 (bookworm) 2023-07-13 12:41:51 +02:00
Tobias Brunner
043e10ebb8 testing: Use Debian bookworm to test TKM 2023-07-13 12:41:51 +02:00
Tobias Brunner
dee9bfb682 testing: Update TKM dependencies to fix compilation with newer GNAT versions 2023-07-13 10:48:53 +02:00
Tobias Brunner
6f7fdcadd1 testing: Add support for Debian bookworm base images
By default, rsyslog is not installed anymore to avoid storing everything
twice (since journald is the default).  If this becomes an issue, we
could delete /var/log/journal to only log via rsyslog.
2023-07-13 10:48:53 +02:00
Tobias Brunner
21bf3e41f9 testing: Use venv for strongTNC
Also updated to a newer version to fix dependency issues.
2023-07-13 10:48:53 +02:00
Tobias Brunner
9b8f26b407 testing: Install python-daemon via Debian package
System-wide installation via pip isn't easily possible anymore on Debian
bookworm, so just use the Debian package for this (is available in old
releases as well).
2023-07-13 10:48:53 +02:00
Tobias Brunner
55273157b0 libimcv: Add Debian 12 (bookworm) to database
Because libcrypto and libssl are measured, we need a new group for Debian
versions with OpenSSL 3 (I've rather added a suffix to the old group as
that could eventually get removed, although we might need a 3.1 variant
in the future - maybe we should measure some other files?).
2023-07-13 10:48:53 +02:00
Tobias Brunner
995d7785b9 testing: Fix vici updown script on Debian bookworm
OOM-killer is now already triggered with `import daemon`, so set the
limit before that.  Also some PEP8 fixes (including an exclusion for
the above fix as that causes imports to not be at the beginning of the
file).
2023-07-13 10:48:53 +02:00
Tobias Brunner
744955f8ce testing: Whitelist all Git repositories in the root image
Without this, Git refuses to operate on the build dirs that are mounted
with weird ownership.  When running as root in the chroot, Git checks
SUDO_UID, which won't match.
2023-07-13 10:48:53 +02:00
Tobias Brunner
e0f0f812c7 testing: Create traditional RSA keys with OpenSSL 3
This is necessary because TKM can't read PKCS#8 files and in some
scenarios we don't have the pkcs8 plugin loaded that would be required
to read/decrypt the non-traditional files.
2023-07-13 10:48:53 +02:00
Tobias Brunner
6b8b67be81 testing: Fix systemctl wrapper and adapt enabling services on winnetou
The wrapper called the command twice for any unit but "strongswan" and
it didn't return the correct exit code.  This was noticed when an
if-updown script tried to check if systemd-resolved is active and always
succeeded, which caused failing attempts to configure it.

But now that the return code is correct, trying to enable bind9 won't
fail silently anymore if the unit doesn't exist (similar on older systems
for named), so this is adapted.
2023-07-13 10:48:53 +02:00
Tobias Brunner
c1dbce29ed testing: Remove support for Debian stretch 2023-07-13 10:48:53 +02:00
Tobias Brunner
fbc25f1c25 leak-detective: Whitelist C++'s __cxa_get_globals() 2023-07-13 10:48:53 +02:00
Tobias Brunner
e604947df8 testing: Switch to MDB backend for OpenLDAP (slapd)
The BDB and HDB backends were long deprecated and have finally been
removed with OpenLDAP 2.5 that's shipped with Debian bookworm.
2023-07-13 10:48:53 +02:00
Tobias Brunner
ab13c1c808 testing: Configure curve25519-sha256 as key exchange for SSH
With Debian bookworm, the PQC KE sntrup761x25519-sha512 is negotiated, by
default.  This increases the overhead significantly, in particular, the
size of the KE message, which wouldn't get through IPsec tunnels without
MSS clamping.
2023-07-13 10:48:53 +02:00
Tobias Brunner
0e621f60f8 sonarcloud: Update filter rules as recommended 2023-07-12 11:21:27 +02:00
Tobias Brunner
46d98bc249 testing: Fix example configure options for charon-tkm Docker build
Fixes: b1ce8772367f ("charon-tkm: Use built-in plugins instead of OpenSSL")
2023-07-11 18:02:13 +02:00
Tobias Brunner
4c2747fbfc Use wolfSSL 5.6.3 for tests 2023-06-21 15:31:53 +02:00
Tobias Brunner
2e88ab0069 dhcp: Fix warning with newer compilers 2023-06-19 14:56:24 +02:00
Tobias Brunner
8238ad480a resolve: Maintain order of DNS servers also when installing in resolv.conf
This always writes the complete set of DNS servers to make modifications
simpler.
2023-06-19 14:56:24 +02:00
Tobias Brunner
6440975bb4 resolve: Try to maintain the order of DNS servers if using resolvconf
Since 17fd304e60df ("resolve: Don't install individual servers via
resolvconf"), DNS servers were sorted if getting installed via resolvconf.
In some setups the order might be important (even though relying on it
isn't a good idea in general as stub resolvers are free to use all of
the servers as they please).
2023-06-19 14:56:24 +02:00