]> git.ipfire.org Git - thirdparty/strongswan.git/log
thirdparty/strongswan.git
2 months agosmp: Make code that encodes identities more readable
Tobias Brunner [Thu, 14 Mar 2024 12:51:06 +0000 (13:51 +0100)] 
smp: Make code that encodes identities more readable

In particular for static code analyzers.  The previous nesting of case
statements inside of a while loop that's inside a switch statement and
a wrapping block with declaration was quite weird and Coverity didn't
like it (it figured that `type` was uninitialized even when it assumed
that get_type() returned a known type for which a case statement
existed).

2 months agoVersion bump to 5.9.14rc1 5.9.14rc1
Andreas Steffen [Wed, 13 Mar 2024 19:24:54 +0000 (20:24 +0100)] 
Version bump to 5.9.14rc1

2 months agosystime-fix: Fix declaration of validator constructor
Tobias Brunner [Wed, 13 Mar 2024 15:17:44 +0000 (16:17 +0100)] 
systime-fix: Fix declaration of validator constructor

2 months agounit-tests: Point out if ECDSA public key was rejected after private keys was not
Tobias Brunner [Wed, 13 Mar 2024 14:34:48 +0000 (15:34 +0100)] 
unit-tests: Point out if ECDSA public key was rejected after private keys was not

AWS-LC rejects public keys with explicitly encoded parameters but allows
private keys that use explicit encodings of the NIST curves.  Since the
more important aspect is that public keys are rejected, this addition to
the warning message points that out.

References strongswan/strongswan#1907

2 months agotesting: Added RFC4806 tests
Andreas Steffen [Fri, 8 Mar 2024 16:15:35 +0000 (17:15 +0100)] 
testing: Added RFC4806 tests

2 months agoAdd support for IKEv2 OCSP extensions (RFC 4806)
Jean-François Hren [Wed, 29 Nov 2023 15:51:48 +0000 (16:51 +0100)] 
Add support for IKEv2 OCSP extensions (RFC 4806)

Closes strongswan/strongswan#2016

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2 months agoMerge branch 'name-constraints'
Tobias Brunner [Wed, 13 Mar 2024 14:05:14 +0000 (15:05 +0100)] 
Merge branch 'name-constraints'

This refactors the name constraints validation in the revocation plugin
so it aligns with what's specified in RFC 5820.

It also expands the subnet/range matching for identities.

Closes strongswan/strongswan#2114

2 months agoconstraints: Properly validate name constraints according to RFC 5280
Tobias Brunner [Fri, 23 Feb 2024 16:44:44 +0000 (17:44 +0100)] 
constraints: Properly validate name constraints according to RFC 5280

The previous code was in a way too simple which resulted in it being too
strict.  For instance, it enforced that intermediate CA certificates
inherited the name constraints of their parents.  That's not required by
RFC 5280 and prevented e.g. adding constraints in an intermediate CA
certificate that's followed by another that doesn't contain any
name constraints.  That's perfectly fine as the set of constraints
specified by the parent continue to apply to that CA certificate and
the children it issues.

Name constraints were previously also applied to all identities of a
matching type, which is way too strict except for some very simple
cases.  It basically prevented multiple constraints of the same type
as e.g. an intermediate CA certificate that has permitted name constraints
for example.org and example.com couldn't issue acceptable certificates
because any SAN with one domain would get rejected by the other
constraint.  According to RFC 5280 matching one constraint is enough.

Also fixed is an issue with name constraints for IP addresses which were
previously only supported for a single level.

2 months agoidentification: Add support to match subnets/ranges against each other
Tobias Brunner [Fri, 23 Feb 2024 15:19:19 +0000 (16:19 +0100)] 
identification: Add support to match subnets/ranges against each other

Previously, it was only possible to match addresses against subnets and
ranges, but not the other way around or subnets and ranges against each
other.

2 months agoconfigure: Load constraints plugin in pki
Tobias Brunner [Fri, 23 Feb 2024 10:18:11 +0000 (11:18 +0100)] 
configure: Load constraints plugin in pki

This allows --verify to check e.g. name constraints.

2 months agogithub: Add AWS-LC CI job
Gerardo Ravago [Thu, 22 Feb 2024 18:47:58 +0000 (13:47 -0500)] 
github: Add AWS-LC CI job

AWS-LC is an OpenSSL derivative which can be used with the openssl plugin.
This adds a CI job that resembles the openssl-3 test case. It downloads
the source tarball for an AWS-LC release, builds that source using
CMake/Ninja, and then builds/tests strongSwan using the same technique
used by openssl-3.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2151

2 months agostarter: Use correct type for uniqueids field
Etay Bogner [Wed, 6 Mar 2024 22:40:51 +0000 (00:40 +0200)] 
starter: Use correct type for uniqueids field

Enum arguments (ARG_ENUM with .list != LST_bool) are assumed to be of
type/size int in assign_args() in args.c.

Fixes: 0644ebd3de62 ("implemented IKE_SA uniqueness using ipsec.conf uniqueids paramater additionally supports a "keep" value to keep the old IKE_SA")
Closes strongswan/strongswan#2148

2 months agoleak-detective: Add whitelist entries for AWS-LC
Gerardo Ravago [Wed, 6 Mar 2024 15:45:00 +0000 (10:45 -0500)] 
leak-detective: Add whitelist entries for AWS-LC

AWS-LC (and likely BoringSSL) uses thread specific data to store internal
library state which gets freed via a registered destructor when the thread
terminates. If this thread happens to be the main thread, which runs the
leak-detective evaluation, the detective won't observe the corresponding free
of the related memory and erroneously reports it as a leak.

The two places this happens are:
- `RAND_bytes` for storing internal RNG state.
- `ERR_put_error` for storing the per-thread OpenSSL error queue.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2147

2 months agoopenssl: Handle BoringSSL-style ASN1_INTEGERs in cert serials
Gerardo Ravago [Mon, 4 Mar 2024 15:25:12 +0000 (10:25 -0500)] 
openssl: Handle BoringSSL-style ASN1_INTEGERs in cert serials

OpenSSL stores the serial number for an X509 certificate as an
`ASN1_INTEGER` type. Within BoringSSL (and AWS-LC), the library
represents the value of zero as an empty array [1] which is different
from OpenSSL which represents it as the 1-byte array [0x00]. Though the
value of zero for the certificate serial number is illegal under
X.509 [2], we need to handle/encode it consistently within strongSwan.
From 18082ce2b061 ("certificates: Retrieve serial numbers in canonical
form"), we infer that the canonical representation of the zero serial
is [0x00]. To do this, we introduce `openssl_asn1_int2chunk` to
complement the existing string version that allows us to handle the
special case for zero instead of always returning a reference to the
library-dependent encodings.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2138

[1] https://github.com/google/boringssl/commit/bdc35b63617f78037768f4897d8835696f02181a
[2] https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2

2 months agocert-enroll: add init.d support to cert-install-sssd
Andreas Steffen [Sun, 3 Mar 2024 16:12:48 +0000 (17:12 +0100)] 
cert-enroll: add init.d support to cert-install-sssd

2 months agoutils: Define ignore_result() so it requires a semicolon
Tobias Brunner [Thu, 29 Feb 2024 15:02:28 +0000 (16:02 +0100)] 
utils: Define ignore_result() so it requires a semicolon

It previously also added its own empty statement.

2 months agoRemove obvious empty statements (i.e. stray semicolons)
Tobias Brunner [Thu, 29 Feb 2024 14:10:59 +0000 (15:10 +0100)] 
Remove obvious empty statements (i.e. stray semicolons)

2 months agogithub: Update GitHub-provided actions for Node.js update
Tobias Brunner [Wed, 28 Feb 2024 14:21:29 +0000 (15:21 +0100)] 
github: Update GitHub-provided actions for Node.js update

2 months agoutils: Define DESTROY_*_IF() macros without terminating semicolon
Tobias Brunner [Wed, 28 Feb 2024 13:40:56 +0000 (14:40 +0100)] 
utils: Define DESTROY_*_IF() macros without terminating semicolon

This avoids double semicolons (i.e. empty statements) and is how
DESTROY_IF() is already defined.

2 months agoandroid: New release after adding fix for existing shortcuts/Intents android-2.5.1
Tobias Brunner [Mon, 26 Feb 2024 10:14:14 +0000 (11:14 +0100)] 
android: New release after adding fix for existing shortcuts/Intents

2 months agoandroid: Add fallback for the old name of the profile ID extra
Tobias Brunner [Mon, 26 Feb 2024 10:01:55 +0000 (11:01 +0100)] 
android: Add fallback for the old name of the profile ID extra

This fixes existing shortcuts and automation via Intents.

Fixes: 8e3b921abed7 ("android: Always use UUID to access profiles")
2 months agoRevert "kernel-netlink: Never use XFRMA_REPLAY_ESN_VAL to configure zero replay windows"
Tobias Brunner [Fri, 23 Feb 2024 16:55:41 +0000 (17:55 +0100)] 
Revert "kernel-netlink: Never use XFRMA_REPLAY_ESN_VAL to configure zero replay windows"

This reverts commit 8b9b11919d92e9738bb52901c9dbcc72e35b9fed.

Since ESN was negotiated via proposal, just configuring the SA without
ESN won't work as the ICV will be incorrect if the peer enabled ESN
on its SA.  While the Linux kernel currently doesn't support disabling
replay protection for SAs that use ESN, this at least gets users an
explicit error not just dropped packets, and it will automatically work
if the kernel supports this combination at some point.

References strongswan/strongswan#2117

2 months agoVersion bump to 5.9.14dr1 5.9.14dr1
Andreas Steffen [Thu, 22 Feb 2024 14:51:24 +0000 (15:51 +0100)] 
Version bump to 5.9.14dr1

2 months agoUse Botan 3.3.0 for tests
Tobias Brunner [Wed, 21 Feb 2024 15:16:24 +0000 (16:16 +0100)] 
Use Botan 3.3.0 for tests

2 months agoMerge branch 'android-managed-configurations' android-2.5.0
Tobias Brunner [Thu, 22 Feb 2024 12:37:01 +0000 (13:37 +0100)] 
Merge branch 'android-managed-configurations'

This adds support for managed configurations via enterprise mobility
management (EMM) systems. Also changes details regarding the SQL data
source.

2 months agoandroid: New release after adding support for managed configurations
Tobias Brunner [Wed, 21 Feb 2024 07:29:54 +0000 (08:29 +0100)] 
android: New release after adding support for managed configurations

2 months agoandroid: Add translations for managed configuration strings
Tobias Brunner [Tue, 30 Jan 2024 17:57:43 +0000 (18:57 +0100)] 
android: Add translations for managed configuration strings

Not actually translating anything, but making the linter happy.

2 months agoandroid: Update managed certificates if config changes
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)] 
android: Update managed certificates if config changes

2 months agoandroid: Add manager for managed user certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)] 
android: Add manager for managed user certificates

This can be used to install, replace or delete currently installed user
certificates based on the app's current managed configuration.

2 months agoandroid: Add manager for managed trusted certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)] 
android: Add manager for managed trusted certificates

This is used to install, replace or delete currently installed trusted
certificates based on the app's current managed configuration.

Certificates that are shared between multiple profiles are protected
and not uninstalled if a profile that uses it remains.

2 months agoandroid: Add utility class to determine differences in two lists of objects
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)] 
android: Add utility class to determine differences in two lists of objects

This allows determining the difference between two lists in the form of
inserts, updates and deletes (and unchanged elements).

2 months agoandroid: Add repository for managed user certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add repository for managed user certificates

2 months agoandroid: Add repository for managed trusted certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add repository for managed trusted certificates

2 months agoandroid: Add base repository for installed managed certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add base repository for installed managed certificates

2 months agoandroid: Add installer for managed user certificates/keys
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add installer for managed user certificates/keys

This installs the configured user certificate into Android's key store
using the DevicePolicyManager.

This is only accessible if the app is installed on an enrolled device and
has been granted the CERT_INSTALL delegate scope.

2 months agoandroid: Add installer for managed trusted certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add installer for managed trusted certificates

This installs a configured CA or server certificate into the app's local
key store.

2 months agoandroid: Add database migration for managed certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add database migration for managed certificates

2 months agoandroid: Add trusted and user certificates to ManagedVpnProfile
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add trusted and user certificates to ManagedVpnProfile

2 months agoandroid: Add entities for CA/server and user certificates
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add entities for CA/server and user certificates

2 months agoandroid: Add utility that parses a PKCS#12 container and extracts a KeyPair
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add utility that parses a PKCS#12 container and extracts a KeyPair

2 months agoandroid: Add utility that converts a Base64 string to a X509Certificate
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add utility that converts a Base64 string to a X509Certificate

2 months agoandroid: Add utility class that pairs a certificate with a private key
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add utility class that pairs a certificate with a private key

2 months agoandroid: Add password for client certificate to managed config
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Add password for client certificate to managed config

2 months agoandroid: Provide global database helper instance
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Provide global database helper instance

2 months agoandroid: Extend database helper with table definition
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:23 +0000 (15:37 +0100)] 
android: Extend database helper with table definition

This simplifies database migration.

2 months agoandroid: Move database helper into separate class
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Move database helper into separate class

Reduce strong coupling between database helper and VPN profiles, to
prepare for the addition of other tables.

2 months agoandroid: Hide unmanaged profiles by default
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Hide unmanaged profiles by default

Such profiles could exist if a user already had strongSwan installed.

2 months agoandroid: Disable access to settings depending on managed configuration
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Disable access to settings depending on managed configuration

2 months agoandroid: Hide menu items depending on managed configuration
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Hide menu items depending on managed configuration

Hide and disable menu items when disabled by the managed configuration.

2 months agoandroid: Add data source for managed VPN profiles
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add data source for managed VPN profiles

Include the managed VPN profile data source in the profile source,
to show profiles from both sources in the UI.

2 months agoandroid: Expose static instance for Application object
Tobias Brunner [Fri, 19 Jan 2024 17:29:20 +0000 (18:29 +0100)] 
android: Expose static instance for Application object

While it seems to be possible to cast Context.getApplicationContext()
to the application class, there really is no documented reason why that
should actually be the same object.

2 months agoandroid: Expose managed configuration globally and notify listeners on changes
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Expose managed configuration globally and notify listeners on changes

Triggers a broadcast if the configuration changed and updates the
profile list accordingly (previously only handled removal of multiple
profiles).

If the app resumes, the configuration is also loaded and listeners are
notified in case the config was updated while the app was in the
background.

2 months agoandroid: Add ManagedConfigurationService and related classes
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add ManagedConfigurationService and related classes

Add service that provides access to managed configurations.

2 months agoandroid: Add managed_configuration.xml
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add managed_configuration.xml

Add managed configuration and associated English strings.

2 months agoandroid: Make VpnType#fromIdentifier null-safe
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)] 
android: Make VpnType#fromIdentifier null-safe

2 months agoandroid: Add data source to VpnProfile
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add data source to VpnProfile

2 months agoandroid: Show warning message for read-only profiles in detail view
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Show warning message for read-only profiles in detail view

Show a message explaining that a managed profile can't be edited in
its detail view.

2 months agoandroid: Add label to read-only profiles in list
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Add label to read-only profiles in list

Show "Managed profile" in the list of VPN profiles, to make it
immediately obvious that a profile is managed/read-only.

2 months agoandroid: Disable copy/delete for read-only profiles
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Disable copy/delete for read-only profiles

If a profile is marked as read-only, do not allow users to copy or
delete the profile.

2 months agoandroid: Make selected apps read-only
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Make selected apps read-only

Also prevent users from changing selected apps in read-only VPN profiles.

2 months agoandroid: Prevent editing of read-only profiles
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Prevent editing of read-only profiles

Do not allow users to edit read-only VPN profiles, with the exception of
the profile's password.

2 months agoandroid: Add read-only flag to VpnProfile
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add read-only flag to VpnProfile

2 months agoandroid: Always use UUID to access profiles
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Always use UUID to access profiles

Use the UUID rather than the ID to ensure there are no conflicts between
profiles from the database and managed profiles.

2 months agoandroid: Fix version number on port column
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)] 
android: Fix version number on port column

The onUpgrade method creates this column for database version 6. Update
the DbColumn definition to match that version number.

2 months agoandroid: Add interface for VPN data source
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Add interface for VPN data source

Change VPN profile source to an interface. Preparation to allow managed
configurations as a second source.

2 months agoandroid: Use try-with-resources for IO
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Use try-with-resources for IO

2 months agoandroid: Remove unnecessary @TargetApi
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Remove unnecessary @TargetApi

The minSdkVersion is 21, remove unnecessary @TargetApi annotations.

2 months agoandroid: Remove unnecessary API checks
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Remove unnecessary API checks

The minSdkVersion is 21, remove unnecessary checks and code that target
older API versions.

2 months agoandroid: Remove AndroidX legacy support
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)] 
android: Remove AndroidX legacy support

2 months agoAdd ._.DS_Store to .gitignore
Markus Pfeiffer [Tue, 21 Nov 2023 14:37:20 +0000 (15:37 +0100)] 
Add ._.DS_Store to .gitignore

2 months agopki: Added key and cert handles to --ocsp command 2090/head
Andreas Steffen [Wed, 7 Feb 2024 06:55:10 +0000 (07:55 +0100)] 
pki: Added key and cert handles to --ocsp command

2 months agopkcs11: Support RSA-PSS signatures 2082/head
Andreas Steffen [Fri, 26 Jan 2024 18:58:23 +0000 (19:58 +0100)] 
pkcs11: Support RSA-PSS signatures

2 months agopkcs11: Updated pkcs11.h header file based on OpenSC
Andreas Steffen [Thu, 25 Jan 2024 17:51:51 +0000 (18:51 +0100)] 
pkcs11: Updated pkcs11.h header file based on OpenSC

2 months agoopenssl: Condition out unsupported curves for AWS-LC
Gerardo Ravago [Tue, 20 Feb 2024 16:54:01 +0000 (11:54 -0500)] 
openssl: Condition out unsupported curves for AWS-LC

AWS-LC lacks support for a number of elliptic curve algorithms so this
adds some conditional macros to avoid registering the related plugin
features. Support for curves ed448 and x448 is completely absent and are
not planned for implementation as they are no longer recommended for use.
While ed25519 is supported by the library, a single missing API for
ASN.1 DER encoding of its private keys is missing which prevents its
use in strongSwan. Future work may remove this limitation, but for now
we will disable the functionality.

Closes strongswan/strongswan#2109

2 months agoopenssl: Add conditional macros around SHA_CTX for AWS-LC
Gerardo Ravago [Thu, 15 Feb 2024 15:42:36 +0000 (10:42 -0500)] 
openssl: Add conditional macros around SHA_CTX for AWS-LC

AWS-LC is a BoringSSL-based libcrypto implementation. SHA_CTX is declared with
the hash data specified as an array rather than as a field in upstream OpenSSL.
Since AWS-LC builds against C99, we are unable to handle this with anonymous
unions like BoringSSL. The workaround I propose is to add these conditional
macros around the accessors within openssl_sha1_prf. After this change,
everything builds successfully with AWS-LC headers.

Closes strongswan/strongswan#2103

2 months agopf-handler: Always free the object even if no socket has been opened yet
Tobias Brunner [Mon, 19 Feb 2024 08:49:08 +0000 (09:49 +0100)] 
pf-handler: Always free the object even if no socket has been opened yet

3 months agodhcp: Port the plugin to FreeBSD/macOS
Dan James [Fri, 24 Nov 2023 15:54:04 +0000 (10:54 -0500)] 
dhcp: Port the plugin to FreeBSD/macOS

This also refactors the BPF handling so it can be shared between the
dhcp and farp plugins.  The latter is adapted accordingly.

Closes strongswan/strongswan#2047

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
3 months agogithub: Use new property to pass token for sonarcloud
Tobias Brunner [Fri, 16 Feb 2024 13:48:44 +0000 (14:48 +0100)] 
github: Use new property to pass token for sonarcloud

sonar.login is deprecated.

3 months agoMerge branch 'ref-overflows'
Tobias Brunner [Fri, 16 Feb 2024 13:04:45 +0000 (14:04 +0100)] 
Merge branch 'ref-overflows'

Different users in the strongSwan code base use the refcount helpers to
allocate incrementing unique values. So far the risk of overflows for
these unsigned 32-bit values has been considered mostly theoretical, as
it requires a longer uptime and a lot of activity to hit such an overflow.

At least for the Netlink sequence numbers, this is not only theoretical,
though, and an overflow has been hit on a productive setup. Unfortunately,
the consequences are rather unpleasant, as the response with a zero
sequence number can't be matched to the request. This results in the
offending thread to block indefinitely while holding the Netlink mutex.

So add a helper to allocate incrementing unique identifiers that checks
for overflows and never returns 0. Use it for Netlink sequence numbers
and some other potential users affected, namely those allocating
IKE_SA/CHILD_SA unique identifiers, marks and interface identifiers.

Closes strongswan/strongswan#2062

3 months agochild-sa: Handle refcount overflow for unique mark/if_id allocation gracefully
Martin Willi [Fri, 16 Feb 2024 09:59:11 +0000 (10:59 +0100)] 
child-sa: Handle refcount overflow for unique mark/if_id allocation gracefully

The refcount_t for allocating unique marks and interface IDs may overflow or
hit the special value for unique marks/if_ids, in the worst case not setting it
on CHILD_SAs that should have one.

As (potentially two) marks/if_ids are allocated only for newly created CHILD_SAs,
but not for rekeying, this not very likely. Still, if a setup uses
aggressive re-authentication and or re-creates CHILD_SAs every minute,
a gateway with 100'000 tunnels may hit the overflow within a month uptime.

3 months agochild-sa: Move unique mark allocation to a separate helper function
Martin Willi [Fri, 16 Feb 2024 09:42:43 +0000 (10:42 +0100)] 
child-sa: Move unique mark allocation to a separate helper function

This aligns the code with unique interface ID allocation, which uses a helper
function for the same purpose and mechanic as well.

3 months agochild-sa: Handle CHILD_SA unique identifier refcount overflow gracefully
Martin Willi [Wed, 10 Jan 2024 16:31:49 +0000 (17:31 +0100)] 
child-sa: Handle CHILD_SA unique identifier refcount overflow gracefully

CHILD_SA unique identifier allocation starts at 1. If the counter overflows,
a unique ID of 0 is assigned to an CHILD_SA, which may have unclear
consequences.

Overflowing the unique ID counter is theoretical for most setups, but on
a Gateway terminating 100'000 tunnels and rekeying CHILD_SAs every 60s
overflows the counter after a month uptime. So avoid a 0 unique identifier
by using ref_get_nonzero().

3 months agoike-sa: Handle IKE_SA unique identifier refcount overflow gracefully
Martin Willi [Wed, 10 Jan 2024 16:27:00 +0000 (17:27 +0100)] 
ike-sa: Handle IKE_SA unique identifier refcount overflow gracefully

IKE_SA unique identifier allocation starts at 1. If the counter overflows,
a unique ID of 0 is assigned to an IKE_SA, which may have unclear consequences.

Overflowing the unique ID counter is theoretical for most setups, but on
a Gateway terminating 100'000 tunnels and rekeying the IKE_SA every 60s
overflows the counter after a month uptime. So avoid a 0 unique identifier
by using ref_get_nonzero().

3 months agokernel-netlink: Handle Netlink sequence number counter overflows gracefully
Martin Willi [Wed, 10 Jan 2024 15:54:17 +0000 (16:54 +0100)] 
kernel-netlink: Handle Netlink sequence number counter overflows gracefully

A refcount variable is used to allocate sequential unique identifiers for
Netlink sequence numbers, subject to overflows. The risk of an overflow
has so far not been considered practical, as it requires 2^32 netlink
requests.

It seems that this issue is not only theoretical. A host with thousands
of tunnels doing aggressive rekeying and/or aggressive status checking
(via vici list-sas) may trigger the overflow after a few weeks uptime.

The consequences are rather devastating: Once the refcount overflows, a
Netlink request is sent with sequence number 0. This request is answered
by the kernel, but can't be matched to the request, resulting in the error:
"received unknown netlink seq 0, ignored". Without Netlink timeouts, the
thread indefinitely waits for a response while holding the Netlink mutex,
bringing all threads to a halt.

So at all costs avoid zero sequence numbers. Also, start at sequence number
1 instead of the arbitrary 201, so the same range is used on start and after
an overflow.

3 months agoatomics: Add a ref_get() variant returning non-zero on overflows
Martin Willi [Wed, 10 Jan 2024 15:38:54 +0000 (16:38 +0100)] 
atomics: Add a ref_get() variant returning non-zero on overflows

This is useful for users using ref_get() for unique identifier allocation,
but the zero value has special meaning.

3 months agoopenssl: Add missing error checking when encoding ED private key
Gerardo Ravago [Tue, 13 Feb 2024 15:24:33 +0000 (10:24 -0500)] 
openssl: Add missing error checking when encoding ED private key

This applies the same logic found in other private key implementations
like that for ECDSA.

Closes strongswan/strongswan#2097

3 months agoauth-cfg: Improve log message for identity constraint mismatch error
Florian Bezannier [Thu, 1 Feb 2024 15:43:35 +0000 (16:43 +0100)] 
auth-cfg: Improve log message for identity constraint mismatch error

Closes strongswan/strongswan#2088

4 months agogithub: Use NDK version in build.gradle to build OpenSSL
Tobias Brunner [Tue, 12 Dec 2023 17:08:05 +0000 (18:08 +0100)] 
github: Use NDK version in build.gradle to build OpenSSL

Also fix the path to the sdkmanager (the old one was removed in the latest
images and the incorrect path caused a weird sudo error) and install
Java 17 as that's necessary for newer versions of the Gradle plugin.

4 months agoandroid: Replace PowerMock with mechanism provided by newer Mockito versions
Tobias Brunner [Tue, 12 Dec 2023 18:41:47 +0000 (19:41 +0100)] 
android: Replace PowerMock with mechanism provided by newer Mockito versions

PowerMock isn't maintained anymore and causes issues with newer Java
versions.  We only used it to mock static methods, which Mockito now
supports as well.  Instead of using the try-with-resources construct,
this uses a @Before and @After method so we don't have to change all the
test methods.

4 months agoandroid: Update Gradle plugin and build scripts and dependencies
Tobias Brunner [Tue, 12 Dec 2023 16:19:18 +0000 (17:19 +0100)] 
android: Update Gradle plugin and build scripts and dependencies

This also references the NDK via ndkVersion and replaces the custom
ndk-build tasks.  It also replaces the deprecated compileSdkVersion and
increases it because dependencies of updated dependencies require that.

targetSdkVersion is not yet updated because there might be some work
required for Android 14 compatibility.

4 months agogithub: Also run tests on macOS 13
Tobias Brunner [Mon, 15 Jan 2024 14:56:58 +0000 (15:56 +0100)] 
github: Also run tests on macOS 13

Uses a newer version of clang and doesn't seem to have the issue with
process_t.

4 months agogithub: Increase timeout for process_t tests
Tobias Brunner [Mon, 15 Jan 2024 14:31:21 +0000 (15:31 +0100)] 
github: Increase timeout for process_t tests

This seems to be necessary on macOS 12 for some reason (note that handling
timeouts in these test cases doesn't really work).

4 months agogithub: Use newer gperf version on macOS
Tobias Brunner [Mon, 15 Jan 2024 14:14:46 +0000 (15:14 +0100)] 
github: Use newer gperf version on macOS

The gperf version that's already available on the system generates
function declarations with K&R syntax (separate arguments) for which newer
compilers produce a warning as C23 doesn't support that syntax anymore.

4 months agosimaka-crypto: Fix constructor declaration
Tobias Brunner [Mon, 15 Jan 2024 12:51:19 +0000 (13:51 +0100)] 
simaka-crypto: Fix constructor declaration

Prototype didn't match the implementation.

4 months agocirrus: Use FreeBSD 14.0
Tobias Brunner [Wed, 10 Jan 2024 10:06:09 +0000 (11:06 +0100)] 
cirrus: Use FreeBSD 14.0

FreeBSD 12.4 has been removed.

4 months agounit-tests: Use function pointers to test generic return_* helper functions
Tobias Brunner [Mon, 15 Jan 2024 12:39:32 +0000 (13:39 +0100)] 
unit-tests: Use function pointers to test generic return_* helper functions

These functions are declared without arguments, passing arguments to them
causes warnings such as the following with newer compilers:

  passing arguments to 'return_null' without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]

We only use them via function pointers, which doesn't trigger any warnings
and hopefully continues to work.

4 months agocurl: Fix issue with printf checks in newer curl versions
Tobias Brunner [Wed, 10 Jan 2024 10:17:58 +0000 (11:17 +0100)] 
curl: Fix issue with printf checks in newer curl versions

Newer curl versions (as used on macOS via Homebrew) add attributes like

  __attribute__ ((format(printf, a, b)))

to their `curl_*printf*` functions, which fails if we redefine `printf`
as e.g. `builtin_printf` (pulled in via library.h).  We could disable
these checks via CURL_NO_FMT_CHECKS, but reordering the headers should
do the trick as well.

4 months agoSuppress compiler warnings with specific bison and compiler combinations
Tobias Brunner [Wed, 10 Jan 2024 17:04:32 +0000 (18:04 +0100)] 
Suppress compiler warnings with specific bison and compiler combinations

Bison generates code that only increases the yynerrs counter, it's never
read.  This causes a warning in newer compilers (in particular clang).
Newer versions of bison mark yynerrs with __attribute__((unused)), but
at least on FreeBSD 14 that's not yet available.

4 months agoleak-detective: Add implementation of malloc_usable_size()
Tobias Brunner [Mon, 8 Jan 2024 15:05:20 +0000 (16:05 +0100)] 
leak-detective: Add implementation of malloc_usable_size()

systemd seems to use this and if we indirectly use libraries provided
by it, which can e.g. happen via getgrnam_r() and nss-systemd, this may
be called on pointers returned by leak detective's malloc(), which will
not point to the original start of the block and cause a segmentation
fault.

Closes strongswan/strongswan#2045

5 months agoMerge branch 'linux-strongswan'
Tobias Brunner [Thu, 14 Dec 2023 10:28:41 +0000 (11:28 +0100)] 
Merge branch 'linux-strongswan'

Closes strongswan/strongswan#2026