Compare commits

...

839 Commits

Author SHA1 Message Date
Tobias Brunner
404111b46f Merge branch 'vici-alerts'
Exposes alerts via vici protocol.

Closes strongswan/strongswan#2894
2025-10-02 10:22:51 +02:00
Martin Willi
f5f04b7d20 bus: Clarify that ALERT_TS_NARROWED is issued for local narrowing as well 2025-10-02 10:22:36 +02:00
Martin Willi
86a50d1618 child-create: Raise an ALERT_TS_MISMATCH when receiving TS_UNACCEPTABLE
When sending a TS_UNACCEPTABLE notify, a ALERT_TS_MISMATCH is sent, but
not when receiving one. This seems inconsistent compared to proposal
mismatch handling, so extend the child_create task to raise such an alert.
2025-10-02 10:22:36 +02:00
Martin Willi
d46529fe2d vici: Raise alert events from the bus alert listener hook
The bus alert infrastructure is currently exposed through the error-notify
plugin using a dedicated socket using a rather archaic message format.
Vici clients would need a dedicated socket connection just to receive such
alert messages, making their implementation more complex.

With vici, it is rather trivial to expose bus alerts through a dedicated
event message that vici clients may subscribe to. Add such an "alert"
event type to vici. Alert names are mapped to strings for simple consumption by
clients.

For now, the error-notify string message is omitted from events, as it mostly
contains static information without much value; instead add the IKE_SA details
for alerts associated to an IKE_SA. Other alert specific data may be added in
the future if needed; preferably using a structured format instead of the
arbitrary string messages used by error-notify. To allow future extensions,
wrap IKE_SA details under a dedicated "ike-sa" property.
2025-10-02 10:22:32 +02:00
Tobias Brunner
b83aed1362 libtls: Use correct constant in error message
Closes strongswan/strongswan#2896

Fixes: e7313962808c ("tls-server: Check if peer sent hash and signature algorithms")
2025-10-02 10:02:49 +02:00
Tobias Brunner
eb2d8768d8 github: Use OpenSSL 3 for macOS builds and enable additional plugins
The Homebrew formula has been using OpenSSL 3 for a while.  The eap-peap
and pkcs11 plugins also have been enabled in the formula.  The dhcp plugin
is enabled to test the port (the farp plugin was already enabled since
its port to FreeBSD/macOS).  The drbg plugin is enabled to run the ML-KEM
test vectors.
2025-10-02 09:03:37 +02:00
Tobias Brunner
6a55de1fa2 github: Build on macOS 14 instead of the deprecated macOS 13
While macos-13 was running on Intel, both macos-latest (macOS 15) and
macos-14 run on ARM64.  While there are Intel-based images for 14 and 15,
they will only be available until August 2027 (and there aren't any Intel
devices anymore anyway).
2025-10-01 19:08:51 +02:00
Tobias Brunner
d0770e5362 github: Use OpenSSL 3.6.0 for tests 2025-10-01 19:08:49 +02:00
Tobias Brunner
61daa338c7 vici: Remove deprecated license classifier in Python metadata 2025-10-01 19:08:34 +02:00
Tobias Brunner
bfed29705e Merge branch 'android-updates'
This fixes GUI-related compatibility issues with Android 16 and allows
(pre-)selecting on-device certificates/keys with managed profiles.  Also
fixes a typo in the managed config description that prevented
split-tunneling settings from working.
2025-10-01 15:19:18 +02:00
Tobias Brunner
74a4700b6d android: New release after updating target SDK and allowing cert selection in managed profiles 2025-10-01 15:18:27 +02:00
Tobias Brunner
ce8b5ff394 android: Fix typo for split-tunneling settings in managed config description
We use the American spelling "tunneling" throughout the app.
2025-10-01 14:47:02 +02:00
Tobias Brunner
cde39f4c1a android: Make a certificate alias pre-selectable in managed profiles
This allows associating a pre-installed certificate/key with a VPN
profile.  For instance, one locally generated on the device via
SCEP/ETS by the MDM.  It only works if the app is granted access to the
certificate/key (alias) by the MDM.

For now, users may still select a different certificate if one is
available (since this requires the certificate to be installed as
user-selectable there might not be).
2025-09-30 16:51:08 +02:00
Tobias Brunner
11f043c3de android: Prompt the user to edit the profile if no certificate is selected 2025-09-30 16:51:08 +02:00
Tobias Brunner
1a16b2c0cb android: Don't print "null" if no user certificate is selected 2025-09-30 11:26:41 +02:00
Tobias Brunner
4918e681ee android: Allow selecting a user certificate for managed profiles
This is only enabled for profiles that are not distributed with a
certificate.
2025-09-30 11:26:41 +02:00
Tobias Brunner
eac76a1a5a android: Explicitly pull in androidx.localbroadcastmanager
Seems to not get pulled in automatically anymore.  This has actually been
deprecated for years apparently.  Unfortunately, it's not that easy to
replace, so keep it for now.
2025-09-30 11:26:41 +02:00
Tobias Brunner
e26d974fe3 android: Remove redundant namespace and fix indentation in state fragment layout 2025-09-30 11:26:40 +02:00
Tobias Brunner
357b93e99d android: Use correct title for proxy server port field in managed configs 2025-09-30 11:26:40 +02:00
Tobias Brunner
3bf34f1cd5 android: Simplify theme definition due to minSdkVersion 2025-09-30 11:26:40 +02:00
Tobias Brunner
13426bd2ea android: Remove obsolete TargetApi attribute 2025-09-30 11:26:40 +02:00
Tobias Brunner
59b74c767a android: Update syntax for three values Gradle warns about
Others seem to be fine or even get an explicit error if changed, like
targetSdkVersion.
2025-09-30 11:26:40 +02:00
Tobias Brunner
19ef347628 android: Increase targetSdkVersion to 36 (Android 16) 2025-09-30 11:26:40 +02:00
Tobias Brunner
86508cdf2b android: Update NDK version 2025-09-30 11:26:40 +02:00
Tobias Brunner
2404b2bee6 android: Apply UI changes for edge-to-edge views in Android 15+
When targeting Android 15, edge-to-edge is the default and when targeting
Android 16, apps can't opt-out from this anymore.  So we update our views
and enable edge-to-edge also for older versions (avoids the black bar
behind the system UI at the bottom).  For most views we just use automatic
margins via android:fitsSystemWindows (or programmatically via
setDecorFitsSystemWindows).  However, for the profile lists and log views,
we take some extra measures that allow the lists to go behind the bottom
system UI.  Appropriate padding is applied at the bottom of the lists so
the last item(s) can be scrolled into full view.
2025-09-30 11:26:40 +02:00
Tobias Brunner
216a9dbb8d android: Avoid crash if read-only profile selection dialog is hidden 2025-09-30 11:26:40 +02:00
Tobias Brunner
3eb2f58a51 android: Update dependencies 2025-09-30 11:26:40 +02:00
Tobias Brunner
ff5fc29285 android: Update Gradle plugin 2025-09-30 11:26:40 +02:00
Tobias Brunner
b1275f26a6 github: Use latest SonarQube action
Updating this although the fixed security issue only affects Windows
builds.
2025-09-26 15:34:28 +02:00
Tobias Brunner
b3011e8e87 Remove support for MD2
No part of IKE/IPsec or X.509 uses MD2 anymore, so there really is no
reason to still support it (unlike MD4 that is used in EAP-MSCHAPv2,
MD5 that's used in EAP-MD5, or SHA-1 that's used for e.g. NAT-D hashes).

It caused test vectors to fail on systems where OpenSSL is built with
MD2 support but has it disabled at runtime.
2025-09-23 15:59:35 +02:00
Andreas Steffen
2b13873c0f Version bump to 6.0.3dr1 2025-09-22 18:57:54 +02:00
Tobias Brunner
7af0caeee1 Merge branch 'testing-trixie'
Use Debian trixie as base image for testing.
2025-09-18 11:27:38 +02:00
Tobias Brunner
1043fa32de testing: Add delay after qemu-nbd -c
Seems that there is a delay before the disk can be used when using newer
QEMU versions (e.g. on Debian trixie). We get errors like these:

  sfdisk: cannot open /dev/nbd0: Inappropriate ioctl for device

or

  mount: /srv/strongswan-testing/build/loop: special device /dev/nbd0p1 does not exist.

A sleep before the next command seems to help.

Also see [1].

[1] https://gitlab.com/qemu-project/qemu/-/issues/1413
2025-09-18 11:13:32 +02:00
Tobias Brunner
e9ebe49d44 testing: Add option to run tests without leak detective
This new option allows to disable leak detective to reduce the runtime
during development.  Either only for the command line (swanctl, pki etc.)
or optionally also for the daemon(s).

Disabling leak detective only for the CLI tools already brings a
considerable reduction in runtime (from 48m to 38m on my dev host) as
there are many such calls in the post-test stage.  Any leaks in those
tools are also a lot less of an issue than leaks in the daemon.  So using
this during development should be fine as long as a full test run is done
regularly (in particular before releases).  Disabling leak detective
completely further reduces the runtime (to 30m on my dev host). But that
should probably only be used for functional regression tests after
verifying new code didn't introduce new leaks.

This also fixes the service script which is used for charon-tkm since
16fcdb460afd ("charon-tkm: Don't use starter/stroke with charon-tkm anymore").
2025-09-18 11:13:32 +02:00
Tobias Brunner
906205b7ee testing: Use Debian trixie to test TKM 2025-09-18 11:13:32 +02:00
Tobias Brunner
a0a5bd7669 testing: Use Debian trixie 2025-09-18 11:13:32 +02:00
Tobias Brunner
f3cc9bec18 testing: Use proper directory for slapd PID files 2025-09-18 11:13:32 +02:00
Tobias Brunner
d8a1747fa1 libimcv: Add Debian 13 (trixie) to database 2025-09-18 11:13:32 +02:00
Tobias Brunner
3aa7e1d418 testing: Increase memory for guest hosts to run Debian trixie
While some increase was necessary anyway because the idle system requires
about 5-10 MiB more memory, the main issue is resolving the code line and
function name in case of a memory leak.  Calling addr2line requires a lot
more memory than before.  Using backtraces via libbfd doesn't help either
because the trigger is the bfd_find_nearest_line() call we use as well.
And because we'd try to resolve all symbols that way (for whitelisting),
the memory overhead would be even higher and affect every shutdown, even
if no leak occurred.  It also causes a significant time overhead (running
all tests took 75m instead of 48m).

I also tested switching to ASAN/LSAN.  The peak memory usage is slightly
higher than when using libbfd, but enabling it also increased the runtime
overhead a lot (the daemon and swanctl both required about 10-20 MiB more
memory, not just during the shutdown).
2025-09-18 11:13:32 +02:00
Tobias Brunner
1767ba2a13 testing: Add support for Debian trixie base images 2025-09-18 11:13:32 +02:00
Tobias Brunner
518b8e4286 testing: Use pipx to install swidGenerator on Debian trixie
We could use the same approach on bookworm (if the base image is updated),
but just use the old approach there for now.
2025-09-18 11:13:32 +02:00
Tobias Brunner
fa1cd74712 testing: Install required packages in venv of updated strongTNC
Update revision for some dependency updates.  While python3-setuptools is
installed on the system, the venv apparently can't use it.  legacy-cgi is
required to use that old Django version with newer Python releases.
2025-09-18 11:13:32 +02:00
Tobias Brunner
ecc2e35713 testing: Update TKM RPC to be compatible with newer compilers 2025-09-18 11:13:32 +02:00
Tobias Brunner
b4a51f1719 testing: Use newer version of TKM on trixie
The API for libgmpada has change with 1.6 in a way that's not
backwards-compatible.  So we use a different revision that includes
the required changes depending on the Debian version.

This also adds support for esa_select(), to support seamless rekeyings,
which requires updating xfrm-ada as well.
2025-09-18 11:13:32 +02:00
Tobias Brunner
ddeb3c463e testing: Run commands in chroot in a login shell
Similar to the previous commit, this ensures we have the same environment
we do later on the system.
2025-09-18 11:13:32 +02:00
Tobias Brunner
870aa75eed testing: Start a login shell in chroot script
This ensures we have the same environment (e.g. stuff from /etc/profile.d)
as when logging in via SSH later.
2025-09-18 11:13:32 +02:00
Tobias Brunner
b998695344 testing: Ignore unknown memory in leak detective
This is set in two locations for systemd services and login shells. The
memory is freed by OPENSSL_cleanup().
2025-09-18 11:13:32 +02:00
Tobias Brunner
0e768233f2 leak-detective: Include OpenSSL symbol seen on Debian trixie 2025-09-18 11:13:32 +02:00
Tobias Brunner
a9e3db6b79 testing: Pass base image codename to application Makefiles
Some might require it to use different revisions or commands.
2025-09-18 11:13:32 +02:00
Tobias Brunner
b51731e197 testing: Mount /proc in the chroot to make systemctl happy 2025-09-18 11:13:27 +02:00
Tobias Brunner
a418666f59 testing: Use new recommended approach to install key for custom apt repository
apt-key add is deprecated (and not available in trixie) as it makes the
available for all sources.  The recommended approach makes the key very
specifically available for just our repository.
2025-09-18 11:12:22 +02:00
Tobias Brunner
2025f630df testing: Remove unnecessary workaround for DHCP 2025-09-18 11:12:22 +02:00
Tobias Brunner
acaf4b2d17 testing: Move sysctl settings to sysctl.d and add some memory settings
Debian trixie doesn't provide a 99-sysctl.conf symlink in that directory
anymore.  The memory settings are also useful there as the default of
one changed and overbooking helps when forking a process with large
memory footprint (e.g. the IKE daemon).
2025-09-18 11:12:22 +02:00
Tobias Brunner
5e85ce17a2 testing: Remove xconsole config for rsyslogd
This produces a warning and we don't have X.
2025-09-18 11:12:22 +02:00
Tobias Brunner
2eef6b242b github: Use AWS-LC 1.61.1 for tests 2025-09-18 08:29:39 +02:00
Tobias Brunner
ac0272cad1 host: Don't try to resolve %any* keywords with mismatched address family
While host_create_from_string_and_family() usually replaces %any*
keywords, this fails if the address family doesn't match (e.g. %any4 with
AF_INET6).  There is no point in trying to resolve these keywords via
DNS as % is no valid character for host names.

Closes strongswan/strongswan#2880
2025-09-16 10:14:26 +02:00
Tobias Brunner
e33dddffea github: Use latest SonarQube action 2025-09-15 17:46:03 +02:00
Tobias Brunner
45f5a7a698 curl: Fix types enforced by compiler check in newer libcurl headers 2025-09-15 16:51:42 +02:00
Tobias Brunner
cfb5e46a98 Merge branch 'plugin-versions'
This adds a symbol with the current version number to all existing
plugins (the PLUGIN_DEFINE() macro makes this easy).  The version is
checked when a plugin is loaded from a file in order to prevent loading
old plugins from any previous build, which could cause all sorts of
issues.

References strongswan/strongswan#2835
2025-08-22 16:49:31 +02:00
Tobias Brunner
c4b32aab04 plugin-loader: Check version of loaded plugins
This prevents loading plugins from older builds that can cause all sorts
of issues as they might access struct members in different locations.

We don't check the version for statically linked plugins.
2025-08-22 15:32:39 +02:00
Tobias Brunner
5cab5672e7 Define plugin version in all existing plugins 2025-08-22 15:32:39 +02:00
Tobias Brunner
d087c349b4 plugin: Add macro to define plugin version and constructor 2025-08-22 15:32:39 +02:00
Tobias Brunner
1b551a9bfd plugin-loader: Don't prevent dynamic linking in addition to static constructors
When built with static plugins and constructors, we might still want to
be able to load external plugins.

Fixes: d860c26e9533 ("plugin-loader: Properly support compilation without dlopen()/dlsym() etc.")
2025-08-22 15:32:39 +02:00
Tobias Brunner
e9fa338e23 pkcs11: Improve detection of already unwrapped CKA_EC_POINTs
If an uncompressed point is already unwrapped (incorrect but some tokens/
modules do this) and therefore still looks like an ASN.1 octet string,
there could be false positives with the previous checks that lead to
mangled points.

By ensuring that we unwrapped the complete ASN.1 chunk, we can already
reduce the false positive rate when the assumed length is smaller than
the chunk, which we previously accepted but isn't the case in correctly
encoded points.

And while we already checked that the first byte indicates a valid point
type/encoding, there could still be false positives.  We can avoid those
with some checks on the length of the unwrapped point.  In particular,
enforcing a multiple of 4/8 should fail for valid unwrapped points where
three bytes were removed in the process (ASN.1 tag and length, point
encoding).

Closes strongswan/strongswan#2872
2025-08-22 15:31:25 +02:00
Tobias Brunner
abadd47736 charon-cmd: Cache shared secret under identities if available
We won't have identities for private key passwords, but we do for EAP
identities and they might get reused if redirected.
2025-08-22 15:27:00 +02:00
Tobias Brunner
d662a69d9d ike-sa-manager: Avoid deadlock due to race condition during shutdown
If an entry is added while we wait for a checked out SA in flush() (e.g.
due to an action performed by that SA), new entries might get inserted
before the one we wait for.  If that was the first entry in the row, we
didn't correctly update the table and the new entries were basically lost
by overwriting the first entry in the row.  As the SA count was still
increased but the new entries couldn't get enumerated, the daemon wasn't
terminated properly but was stuck in the loop in flush().
2025-08-22 15:26:59 +02:00
Tobias Brunner
3e0123526f trap-manager: Migrate tracked IKE SA in case of redirect during IKE_AUTH 2025-08-22 15:26:59 +02:00
Tobias Brunner
ee668ae91e controller: Migrate tracked IKE SA in case of redirect during IKE_AUTH 2025-08-22 15:26:59 +02:00
Tobias Brunner
3a9120373d ike-sa: Avoid reusing established IKE_SAs that got redirected
These will get terminated by the peer after a while.  So we don't want
to reuse them.
2025-08-22 15:26:59 +02:00
Tobias Brunner
2f0a0fef3d vici: Fix indentation for some add_kv() calls 2025-08-22 15:22:33 +02:00
Mathias Aerts
a24dc2e9ad vici: Include configured local and remote ports in list-conns
Closes strongswan/strongswan#2869
2025-08-22 15:22:13 +02:00
Tobias Brunner
b36da850b5 github: Only run CI for latest commit in a branch, cancel old runs 2025-08-22 12:21:50 +02:00
Tobias Brunner
7b90dc93c0 libipsec: Run unit tests with TESTS_PLUGINS if specified 2025-08-22 12:11:11 +02:00
Tobias Brunner
9da68ec9f5 libtls: Fix double-free when enumerating private keys 2025-08-22 12:07:55 +02:00
Tobias Brunner
dcb53e076b testing: Disable deprecated features in Botan
We keep MD5 enabled for now as we need it for TLS 1.0/1.1.  Once we
remove that we can reconsider (although, it's also needed for EAP-MD5
and since MD4 is disabled as well, which means EAP-MSCHAPv2 won't
be available, we'd be left with only EAP-GTC for simple username/password
authentication, which nobody else supports).
2025-08-22 12:07:55 +02:00
Tobias Brunner
8139256aae botan: Replace calls to deprecated botan_privkey|pubkey_export() 2025-08-22 11:52:51 +02:00
Tobias Brunner
5e4ff88849 github: Use OpenSSL 3.5.2 for tests 2025-08-21 16:44:01 +02:00
Tobias Brunner
d973106eed github: Use AWS-LC 1.58.1 for tests 2025-08-21 16:44:01 +02:00
Tobias Brunner
052a939553 openssl: Add support for Ed25519 via AWS-LC 2025-08-21 16:44:01 +02:00
Tobias Brunner
4096a911a0 github: Check active transforms against reference files
Also collect current results so we can update reference files easily.

Enabled AES-CFB in wolfSSL as we have already support for it in the
plugin.
2025-08-21 16:16:01 +02:00
Tobias Brunner
545eb2416a unit-tests: Add option to collect active crypto transforms
This will allow us to compare new library versions against previous ones,
so we don't suddenly loose some algorithms like it happened with KDFs
recently after updating OpenSSL to 3.5.1.
2025-08-21 16:16:01 +02:00
Tobias Brunner
4c85b9d21b credential-factory: Avoid deadlock during unit tests
If a unit test times out while generating a private key (e.g. because of
a lack of entropy), this avoids a deadlock by still releasing the read
lock that'd prevent acquiring the write lock when plugins are unloaded.

Closes strongswan/strongswan#2850
2025-08-21 16:13:24 +02:00
Tobias Brunner
135ed6aada openssl: Simplify wrapping private key objects 2025-08-21 16:11:13 +02:00
Tobias Brunner
0391450376 openssl: Support EdDSA keys in PKCS#12 containers
References strongswan/strongswan#2848
2025-08-21 16:10:58 +02:00
Tobias Brunner
f02033664e vici: Add support for P-CSCF server attributes
Was apparently forgotten when support was added to the attr plugin
with 98a3ba8a5a16 ("attr: Add p-cscf keyword for P-CSCF server addresses").

For consistency, using an underscore like the `split*` options and not a
dash like in the attr plugin.

References strongswan/strongswan#2396
2025-08-21 16:04:39 +02:00
Tobias Brunner
ea05033319 eap-authenticator: Assume IKE identity as EAP-Identity if client doesn't send one
Apparently, some clients (e.g. native Android) just send an empty
EAP-Identity response.  We silently ignored that previously and then
used the IKE identity for the actual EAP method.  This change tries to
do something similar (i.e. don't fail if the response is empty), but by
assuming the IKE identity as EAP-Identity, we match that and possibly
can switch configs.

Closes strongswan/strongswan#2833
Fixes: 2f2e4abe3c52 ("ikev2: Add support to switch peer configs based on EAP-Identities")
2025-08-21 16:02:36 +02:00
Tobias Brunner
2560146204 github: Use provided actions for SonarQube installation and scan
Also switch to the cloud cache (which doesn't seem to work either way
anyway).
2025-08-05 10:27:32 +02:00
Tobias Brunner
ff06159099 certexpire: Double size of internal buffer for identities
The error-notify, lookip, and whitelist (previous commit) plugins already
use the same buffer size for identities.
2025-07-23 18:50:53 +02:00
seantywork
ae2e0b6cf2 whitelist: Double the length of the id field in the messages
Closes strongswan/strongswan#2842
2025-07-23 18:50:33 +02:00
Tobias Brunner
6c813ddc13 Use wolfSSL 5.8.2 for tests 2025-07-19 12:11:29 +02:00
Tobias Brunner
011c346b00 wolfssl: Store RNG on object for curve25519
5.8.2 enables blinding for curve25519 by default, so the RNG set when
making the key is also used later on.
2025-07-19 12:10:25 +02:00
Rob Shearman
1b62e88980 ml: Disable versioning for shared object
Avoid generating versioned shared objects which would need to be
installed along with the version-independent symlink by specifying
"-avoid-version" in the libtool LDFLAGS for the plugin. Avoid any
unwanted surprises by also specifying the "-module" option, making the
LDFLAGS consistent with all other libstrongswan plugins.

Closes strongswan/strongswan#2844
2025-07-18 16:30:50 +02:00
Tobias Brunner
58c567da74 Merge branch 'whitelist-watcher'
Use watcher and non-blocking I/O for client connections to avoid issues
with clients that stay connected for a long time.

Closes strongswan/strongswan#2827
2025-07-18 16:16:17 +02:00
Tobias Brunner
85ebf6abd4 whitelist: Add error handling to socket reads and fix a memory leak
This now adds some state (basically a message buffer), but simplifies
error handling as we don't have to handle two potential failure paths
and could avoid some potential issues by still calling the blocking
read_all().

It also fixes a memory leak when clients disconnect.
2025-07-18 12:07:45 +02:00
Rob Shearman
412231eecd whitelist: Use a watcher for control socket reading rather than blocking
Performing a stream read_all call (which is a blocking read) from
within the accept callback has the issue that if a whitelist client is
still connected whilst a shutdown of the charon deamon is triggered
then that shutdown won't complete gracefully due to the accept task
never exiting.

So fix shutting down gracefully by using the socket watcher rather than
a blocking read upon connection accept. Fall back to a blocking read
for partial messages to avoid the complexity associated (i.e. storing
state) for incomplete reads, which shouldn't block and cause the
original problem if the client only sends whole messages.
2025-07-15 14:50:56 +02:00
Tobias Brunner
e98ea89d99 nm: Version bump to 1.6.3 2025-07-14 11:01:14 +02:00
Andreas Steffen
23eb1e0945 Version bump to 6.0.2 2025-07-13 09:56:49 +02:00
Tobias Brunner
4c54550352 testing: Use alternative approach for retransmits in ikev1/dpd-restart scenario
With a long delay, the retransmit might not get sent before further tests
are evaluated on faster machines, while more retransmits should still allow
the scenario to succeed on slower ones.
2025-07-11 14:15:40 +02:00
Tobias Brunner
bab415ec0a child-cfg: Actually force narrowing TS in transport mode only as initiator
Closes strongswan/strongswan#2830

Fixes: ad1ad2159f0b ("child-cfg: Use traffic selector list")
2025-07-11 14:15:06 +02:00
Tobias Brunner
43b805b2da openssl: Don't allocate salt if PRF/hash is unknown
This can happen if e.g. AES-XCBC is selected.

Fixes: 2dbeecfc029b ("openssl: Fix testing KDF_PRF in the constructor with OpenSSL 3.5.1")
2025-07-11 11:47:51 +02:00
Tobias Brunner
2c32412594 github: Shorten name for crypto-plugin job and reverse matrix arguments
This gives us more readable names in the UI.  Instead of

  crypto-plugins (ubuntu-latest, b...
  crypto-plugins (ubuntu-latest, b...
  crypto-plugins (ubuntu-latest, ...
  crypto-plugins (ubuntu-latest, ...
  crypto-plugins (ubuntu-latest, o...
  crypto-plugins (ubuntu-latest, o...

we now get

  crypto (botan, ubuntu-latest, no)
  crypto (botan, ubuntu-latest, yes)
  crypto (wolfssl, ubuntu-latest, no)
  crypto (wolfssl, ubuntu-latest, yes)
  crypto (openssl, ubuntu-latest, no)
  crypto (openssl, ubuntu-latest, yes)
2025-07-10 19:23:02 +02:00
Tobias Brunner
2dbeecfc02 openssl: Fix testing KDF_PRF in the constructor with OpenSSL 3.5.1
Setting the salt to NULL now fails, so we set it to hash length's zeroes,
which is the default value for HKDF-Extract if no salt is passed.

Fixes strongswan/strongswan#2828
2025-07-10 19:22:22 +02:00
Tobias Brunner
a8c2d125f1 Doxyfile: Don't hide set_seed() method 2025-07-08 13:13:06 +02:00
Tobias Brunner
f88d824114 Fixed some typos, courtesy of codespell 2025-07-08 10:54:49 +02:00
Andreas Steffen
bd65a21ce0 Version bump to 6.0.2rc1 2025-07-07 18:25:37 +02:00
Tobias Brunner
85c6473a5e NEWS: Add news for 6.0.2 2025-07-07 18:04:34 +02:00
Tobias Brunner
36f7c98f4e github: Use AWS-LC 1.55.0 for tests 2025-07-07 18:04:19 +02:00
Tobias Brunner
b46960d80c github: Use OpenSSL 3.5.1 for tests 2025-07-07 18:04:19 +02:00
Thomas Egerer
a339468c93 vici: Allow backlog size configuration via compile option
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-07-07 14:20:13 +02:00
Tobias Brunner
9eb5fcd6b6 github: Make sure at least one run with the same content is not skipped 2025-07-07 11:55:01 +02:00
Andreas Steffen
1f42640c43 Version bump to 6.0.2dr3 2025-07-03 11:43:53 +02:00
orbea
979c57fc30 nm: Don't set DL_LIBS to 'none required' in configure script
This copies the AC_SEARCH_LIBS check from the main strongSwan
configure.ac.

When building networkmanager-strongswan with slibtool if fails.

  ld: cannot find none: No such file or directory
  ld: cannot find required: No such file or directory

This is because configure.ac uses AC_SEARCH_LIBS to find dlopen which
sets the value of $ac_cv_search_dlopen to 'none required' which then
gets set in DL_LIBS and passed to slibtool.

With GNU libtool it silently ignores the unknown arguments.

Gentoo issue: https://bugs.gentoo.org/914100

Closes strongswan/strongswan#2141

Signed-off-by: orbea <orbea@riseup.net>
2025-07-01 07:45:12 +02:00
Tobias Brunner
a666944e65 Merge branch 'android-http-proxy'
Adds support for HTTP proxy server.

Closes strongswan/strongswan#2789
2025-06-27 09:13:38 +02:00
Tobias Brunner
bd4cee82ac android: New release after adding HTTP proxy configuration 2025-06-27 08:57:45 +02:00
Tobias Brunner
dbcba117ae android: Apply proxy server setting when creating TUN device
This is only available with Android 10+ (SDK 29+).
2025-06-27 08:57:45 +02:00
Tobias Brunner
b944159fcf android: Avoid proxy settings in the internal fetcher 2025-06-27 08:57:45 +02:00
Tobias Brunner
c7307ccc52 android: Allow setting proxy settings in managed profiles 2025-06-27 08:57:45 +02:00
Tobias Brunner
0f2cd032e1 android: Import proxy server settings 2025-06-27 08:57:45 +02:00
Tobias Brunner
c80819c0ad android: Make proxy server configurable 2025-06-27 08:57:45 +02:00
Tobias Brunner
a7cb2fcbf6 android: Add properties to VPN profiles for proxy server configuration 2025-06-27 08:57:45 +02:00
Tobias Brunner
059c70e556 android: Don't mention IKEv1 and L2TP in app description
Also removed on Play so the app does not show up when people search
for these keywords (they tend to not read the actual description and
then are surprised that neither protocol is supported).
2025-06-27 08:57:45 +02:00
Tobias Brunner
4143e47462 android: Update dependencies 2025-06-27 08:57:38 +02:00
Tobias Brunner
a153626af7 identification: Clarify that ID_USER_FQDN is just an alias for ID_RFC822_ADDR
This means userfqdn: is a valid prefix for regular expressions.
2025-06-20 10:37:40 +02:00
Tobias Brunner
e58ef258b5 swanctl: Document that IP-TFS mode is subject to mode negotiation 2025-06-20 10:37:35 +02:00
Tobias Brunner
9a6aa2530e testing: Make sure ML-KEM scenarios use our ml plugin
We now support OpenSSL's implementation in the openssl plugin.  This
makes sure our plugin is used on at least one of the hosts if we ever
switch to an OpenSSL version that supports ML-KEM.

In the ikev2/rw-mlkem scenario the logic is reversed.  There the ml plugin
is preferred on moon to test the responder side (and carol for the
initiator) and dave will switch to OpenSSL if it ever provides ML-KEM.
2025-06-20 10:37:24 +02:00
Andreas Steffen
faf7ad2331 Version bump to 6.0.2dr2 2025-06-05 13:43:21 +02:00
Andreas Steffen
f9985d72e4 testing: soup plugin removed from test environment 2025-06-05 13:42:41 +02:00
Andreas Steffen
2fa8f4a90f Version bump to 6.0.2dr1 2025-06-04 19:58:23 +02:00
Tobias Brunner
b39311e19e Merge branch 'libsoup3'
Ports the soup plugin to libsoup 3.

Closes strongswan/strongswan#2788
2025-06-04 19:09:33 +02:00
Tobias Brunner
b8108a4c3c github: Use libsoup 3 for tests
Requires installing libxml2-dev explicitly for the alpine build as
libsoup-dev had a dependency on it.
2025-06-04 19:08:57 +02:00
Tobias Brunner
9dbb15dea9 leak-detective: Remove whitelisted libsoup2.x functions
As mentioned in 0f141fb095a41a9fdfe5c111269eb643dc643494, we can't
really whitelist the "leaks" in GLib, so don't even try to do anything
with libsoup3.x.
2025-06-04 19:08:57 +02:00
Mike Gorse
6ddabf52d5 soup: Port to libsoup 3 2025-06-04 19:08:07 +02:00
Tobias Brunner
e864b8a8b1 fetcher: Remove unused FETCH_HTTP_VERSION_1_0 option
Was only used by the removed scepclient and does not serve any purpose
nowadays anyway.
2025-06-04 19:07:22 +02:00
Tobias Brunner
82adb5ce0f unit-tests: Serial number tests depend on X.509 certificate parsing
Requires additional plugin features, but if this is available, the
others are usually as well.
2025-06-04 19:07:22 +02:00
Tobias Brunner
71f1091129 wolfssl: Fix build if wolfSSL was built in OpenSSL-compat mode 2025-06-04 19:07:13 +02:00
Tobias Brunner
3d426cbfee Merge branch 'wolfssl-fips'
Fixes various issues when building the wolfssl plugin against wolfSSL's
FIPS module.

References strongswan/strongswan#2603
Closes strongswan/strongswan#2771
2025-06-02 11:31:03 +02:00
Juliusz Sosinowicz
f38bb91654 wolfssl: Unlock keys if necessary when using FIPS module
Wrap the functions that require it in PRIVATE_KEY_UNLOCK/PRIVATE_KEY_LOCK.
This can't be done at plugin initialization because it needs to be done
for every thread. strongSwan currently doesn't provide on-thread-create
callbacks for plugins so we need to wrap each direct call. Another reason
to do so is that some functions we call (e.g. wc_EccKeyToDer) internally
call PRIVATE_KEY_UNLOCK/PRIVATE_KEY_LOCK and would leave the keys locked
for that particular thread.
2025-06-02 09:15:05 +02:00
Juliusz Sosinowicz
85eb5c7812 wolfssl: Properly initialize ECC private key object 2025-06-02 09:15:05 +02:00
Tobias Brunner
879e3ce05a wolfssl: Set a dummy key when testing KDF implementations
In FIPS mode, wolfSSL enforces a minimum key size for these algorithms.
2025-06-02 09:15:05 +02:00
Tobias Brunner
757e00c0ae test-vectors: Remove HMAC PRF test vectors with key size 4
Some implementations enforce a minimum key size (e.g. wolfSSL in FIPS
mode) and in practice, the keys will be longer anyway (e.g. our nonces
are 32 bytes).
2025-06-02 09:15:05 +02:00
Tobias Brunner
d0292a6f50 wolfssl: Include settings.h in case WOLFSSL_USER_SETTINGS is defined 2025-06-02 09:15:05 +02:00
Tobias Brunner
217049606b wolfssl: Use consistent defines for ECC public/private key loading
HAVE_ECC_KEY_IMPORT can be defined while HAVE_ECC_SIGN is not.
So just use the same defines we use when defining the load functions.
2025-06-02 09:15:04 +02:00
Tobias Brunner
7bfd81d78a wolfssl: Call wc_SetSeed_Cb() as required for FIPS-mode 2025-06-02 09:15:04 +02:00
Tobias Brunner
3a5f203958 Merge branch 'iptfs'
This adds basic support for IP-TFS/AGGFRAG (RFC 9347).  The Linux kernel,
since 6.14, only supports aggregation/fragmentation so far.  The actual
TFS features will get added later.
2025-05-28 16:48:42 +02:00
Tobias Brunner
dc4fef146a testing: Add ikev2/net2net-iptfs scenario 2025-05-28 16:37:47 +02:00
Tobias Brunner
b4a0eb3603 testing: Add config for Linux 6.14
This has IP-TFS enabled.
2025-05-28 16:37:46 +02:00
Tobias Brunner
a7a3c4a22a conf: Document global IP-TFS settings 2025-05-28 16:37:46 +02:00
Tobias Brunner
46525cdc4f child-create: Negotiate IP-TFS mode if configured 2025-05-28 16:37:46 +02:00
Tobias Brunner
f5f7424e1d notify-payload: Add notify type for IP-TFS/AGGFRAG 2025-05-28 16:37:46 +02:00
Tobias Brunner
6372b2890f kernel-netlink: Support IPTFS mode and attributes 2025-05-28 16:37:46 +02:00
Tobias Brunner
f32773b3a8 child-sa: Allow disabling fragmenting packets across AGGFRAG payloads
This is necessary if the peer isn't able to handle such fragments.
2025-05-28 16:37:46 +02:00
Tobias Brunner
33db7a200f kernel-ipsec: Add flag to disable sending fragments across AGGFRAG payloads
We have to set this if the peer indicates that it doesn't support
handling such fragments in the notify.
2025-05-28 16:37:46 +02:00
Tobias Brunner
1afc76dd56 vici: Make IP-TFS mode configurable 2025-05-28 16:37:46 +02:00
Tobias Brunner
e175abaf89 include: Add XFRM mode and attributes for IP-TFS 2025-05-28 16:37:46 +02:00
Tobias Brunner
419528f2ac ipsec-types: Add new mode for IP-TFS
Added at the end as the numeric mode is e.g. used in SQL databases.
2025-05-28 16:37:27 +02:00
Tobias Brunner
72e3b7dcc8 Merge branch 'per-cpu-sas'
This adds support for per-CPU SAs (RFC 9611).
2025-05-28 16:36:10 +02:00
Tobias Brunner
b7d3349000 testing: Add ikev2/per-cpu-sas-encap-transport scenario
Tests transport mode and UDP encapsulation with random source ports.
Interestingly, the responder always uses the same SA to respond (maybe
due to the cache on the policy).
2025-05-28 16:35:27 +02:00
Tobias Brunner
3b2f8cf282 testing: Add ikev2/per-cpu-sas-encap scenario
Basically the same as the one without UDP encapsulation, but here the
outbound SAs use random source ports.
2025-05-28 16:35:27 +02:00
Tobias Brunner
d83fbe82e4 kernel-netlink: Suppress NAT mapping updates for per-CPU SAs
As we set the remote port to 0, we'd get a mapping change message with
every packet. Setting the threshold avoids all kernel messages after the
first, which we suppress explicitly as well.
2025-05-28 16:35:27 +02:00
Tobias Brunner
14e1ec2b77 child-sa: Configure UDP encapsulation for per-CPU SAs
As the kernel does not support processing UDP-encapsulated and plain ESP
for the same SA, we require forcing UDP encapsulation if there is no NAT.
2025-05-28 16:35:27 +02:00
Tobias Brunner
73083503f2 vici: Make UDP encapsulation for per-CPU SAs configurable 2025-05-28 16:35:27 +02:00
Tobias Brunner
d594171d9e child-cfg: Add flag to enable UDP encapsulation for per-CPU SAs 2025-05-28 16:35:27 +02:00
Tobias Brunner
bf34484d24 testing: Add per-CPU SA test scenario 2025-05-28 16:35:27 +02:00
Tobias Brunner
e24edb2991 testing: Configure multiple virtual CPUs for moon and sun
This allows testing per-CPU SAs by e.g. pinging over a specific CPU
via taskset.
2025-05-28 16:35:27 +02:00
Tobias Brunner
0edaadfc94 testing: Enable SMP support for latest kernels 2025-05-28 16:35:27 +02:00
Tobias Brunner
f95bdb6fb0 swanctl: Report per-CPU information in --list-sas 2025-05-28 16:35:27 +02:00
Tobias Brunner
c176d32a73 vici: Report per-CPU SA information 2025-05-28 16:35:27 +02:00
Tobias Brunner
fbfae44dd1 vici: Make per-CPU CHILD_SAs configurable 2025-05-28 16:35:27 +02:00
Tobias Brunner
a950ca3ec2 kernel-netlink: Forward CPU ID from acquires 2025-05-28 16:35:27 +02:00
Tobias Brunner
4a595508b7 trap-manager: Add support to handle acquires for per-CPU SAs 2025-05-28 16:35:27 +02:00
Tobias Brunner
65b7f9d563 kernel-handler: Log CPU ID that's passed with an acquire 2025-05-28 16:35:27 +02:00
Tobias Brunner
d6eed3979b kernel-interface: Optionally pass CPU ID for which an acquire was triggered 2025-05-28 16:35:27 +02:00
Tobias Brunner
2082fa5dd2 ike-sa: Accept optional CPU ID when initiating CHILD_SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner
8e7f379f71 ike-sa: Sort CHILD_SAs by CPU ID
This might make debugging easier and also ensures that a possible
fallback SA without CPU ID is established first when reestablishing
an IKE_SA.  Because even if such an SA is established first initially,
that might change later depending on when per-CPU SAs are rekeyed.
2025-05-28 16:35:26 +02:00
Tobias Brunner
af34b5b1dc child-rekey: Maintain per-CPU values during rekeying 2025-05-28 16:35:26 +02:00
Tobias Brunner
bdf882d3af child-create: Add support to negotiate per-CPU SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner
3a8bb93761 updown: Don't call the script for per-CPU SAs
Rules are installed for the fallback SA that has no CPU ID assigned.
2025-05-28 16:35:26 +02:00
Tobias Brunner
297be45275 ha: Ignore per-CPU CHILD_SAs
These only work on initiators (with trap policies), which is something
the plugin doesn't support.
2025-05-28 16:35:26 +02:00
Tobias Brunner
17f2188756 forecast: Ignore per-CPU CHILD_SAs
Not sure if this combination does make sense as the plugin itself would
be a major bottleneck.

Similar to the connmark plugin, PREROUTING rules list SPIs or UDP ports,
which would be necessary for all SAs while the OUTPUT rules would only be
required once.
2025-05-28 16:35:26 +02:00
Tobias Brunner
5faf884285 connmark: Ignore per-CPU CHILD_SAs
The combination probably doesn't make much sense.

The OUTPUT rules would definitely only be required once, while the INPUT
and PREROUTING rules list individual SPIs and/or UDP ports, which would
be necessary for all SAs.

By the way, the rules in PREROUTING might actually not be necessary
anymore if the set_mark_in option was used for such SAs.
2025-05-28 16:35:26 +02:00
Tobias Brunner
a505f4b9b0 child-sa: Add support for per-CPU SAs
The CPU ID is also set on inbound SAs as it can be used to configure RSS
or some eBPF program.
2025-05-28 16:35:26 +02:00
Tobias Brunner
bdfcfea1f2 kernel-netlink: Add support to enable per-CPU acquires on policies 2025-05-28 16:35:26 +02:00
Tobias Brunner
53be94d06c kernel-netlink: Add support to set CPU ID on SA 2025-05-28 16:35:26 +02:00
Tobias Brunner
12395cedf3 ipsec-types: Add identifier for the maximum (=no) CPU ID 2025-05-28 16:35:26 +02:00
Tobias Brunner
aa1322aed5 include: Add XFRM identifiers for per-CPU SAs/acquires 2025-05-28 16:35:26 +02:00
Tobias Brunner
d4575da53c child-cfg: Add flag to enable per-CPU SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner
749814a75f notify-payload: Add notify types for per-resource CHILD_SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner
8f6e3c164a testing: Include the kernel build number 2025-05-28 16:35:26 +02:00
Tobias Brunner
b6a4cfc705 Merge branch 'acquires-seq'
This uses the sequence number from acquires when installing the SA. This
allows handling narrowing properly by changing the reqid and still
removing the temporary state in the kernel.  It also changes that
traffic selectors are reused during rekeying/recreation/reauthentication,
so narrowed selectors won't return to the wider configured TS because
there won't be any TS from triggering packets to narrow again.
2025-05-28 16:30:56 +02:00
Tobias Brunner
8cb5918b0c testing: Add ikev2/net2net-route-narrow scenario 2025-05-28 16:01:00 +02:00
Tobias Brunner
6c7c539eaf child-create: Consider previous TS when checking for duplicates 2025-05-28 16:01:00 +02:00
Tobias Brunner
58d6778adb child-sa: Add helper to check if a list of TS match negotiated TS 2025-05-28 16:01:00 +02:00
Tobias Brunner
e7fc7a4ecc child-create: Maintain traffic selectors during rekeying/reauthentication
If we don't do this, narrowed SAs would default to the wide configured
traffic selectors and the peer won't know if/how to narrow.
2025-05-28 16:01:00 +02:00
Tobias Brunner
9205458355 child-create: Use more generic method to pass information from previous SA
Besides the previous key exchange method, this will allow us to also
reuse the previous traffic selectors.  Some data is still passed in
separate methods as some are set even when there is no previous SA and
others are not set in all cases.

The interface for queue_child() now optionally takes the previous
Child SA to handle both recreations and initiations from scratch.
2025-05-28 11:06:19 +02:00
Tobias Brunner
ad1ad2159f child-cfg: Use traffic selector list 2025-05-28 11:06:19 +02:00
Tobias Brunner
4b468126ca traffic-selector-list: Add helper class to manage a collection of TS
Provides functions to optionally resolve dynamic TS and to narrow
them based on a list of supplied TS.
2025-05-28 11:06:19 +02:00
Tobias Brunner
79815b4e67 trap-manager: Set seq. no. for CHILD_SAs not initiated by an acquire
This fixes cases where `start_action = trap|start` is used and an acquire
is triggered while the SA is initiated (granted if narrowing is expected,
that's not a recommended configuration as the responder can only use
the first config when there is no packet TS).  The resulting second
create-child task will potentially get dropped by the duplicate check,
so the temporary state won't get removed and traffic is blocked until
that expires, neither can acquires get triggered for traffic that doesn't
match the initial SA's policies.
2025-05-28 10:11:53 +02:00
Tobias Brunner
ac0c73a412 child-create: Trigger CHILD_INSTALLING event after setting traffic selectors
This was the case before bce0c5fd74a0 ("child-create: Update CHILD_SA IP
addresses before installation") and allows listeners to consider the
traffic selectors of the SA that's about to get installed.
2025-05-28 10:11:53 +02:00
Tobias Brunner
5bb6f636ad child-create: Use helper to compare packet TS against CHILD_SAs 2025-05-28 10:11:53 +02:00
Tobias Brunner
769d9a12aa child-sa: Add helper to check if two TS match negotiated TS 2025-05-28 10:11:53 +02:00
Tobias Brunner
65b810e9b0 acquire-job: Use helpers to manage acquire data 2025-05-28 10:11:53 +02:00
Tobias Brunner
c563b0d930 kernel-listener: Add helpers to clone/destroy acquire data 2025-05-28 10:11:53 +02:00
Tobias Brunner
6ae29af18b child-create: Consider triggering TS when checking for duplicate 2025-05-28 10:11:53 +02:00
Tobias Brunner
6e274271af vici: Include reqid when listing trap policies 2025-05-28 10:11:53 +02:00
Tobias Brunner
5624f7ffaa kernel-pfkey: Don't use TS from acquire in tunnel mode
The addresses are actually the endpoints of the SA, not information on
the matched packet (except that the RFC says to set the ports and
protocol of the packet in the source address, which the Linux kernel
doesn't do).  So these are useless, unless transport mode is used, where
the addresses are needed for the wildcard trap policy use case.

The RFC mentions a PROXY address (a single one, not two), that could
apparently be something like the source address in tunnel mode.
However, the description of how this is used in the RFC is quite weird
and neither Linux nor FreeBSD send such an attribute in SADB_ACQUIRE.
2025-05-28 10:11:53 +02:00
Tobias Brunner
b024b7e9a6 kernel-netlink: Add support for acquire sequence numbers
Note that while PF_KEYv2 also uses sequence numbers to identify acquires,
which we currently don't use correctly by the way, it does not include
information about the packet that triggered an acquire.  What we receive
in src and dst, and currently forward as traffic selectors, are actually
the designated endpoints of the SA. So especially in tunnel mode this is
useless to do narrowing on the responder (these addresses might not even
match the configured TS).
2025-05-28 10:01:19 +02:00
Tobias Brunner
46c338a78f kernel-interface: Change reqid if seq. nos. are supported and narrowing occurred
With the sequence numbers we don't have to maintain the reqid to delete
the temporary state.

One exception is with labels.  There we currently only install trap
policies with the generic label.  SAs created from those don't have
policies installed, so we have to reuse the reqid of the trap even if
narrowing occurs.

And as before, we reuse the reqid without checking traffic selectors if
sequence numbers are not supported.

Note that if a CHILD_SA is manually initiated (i.e. has no sequence
number assigned) right before an acquire is triggered, there are several
possible outcomes depending on whether narrowing occurs.  If there is no
narrowing, the same reqid is assigned and the kernel will remove the
temporary SA when the SA is installed (no seq => reqid match).
Afterwards, the queued duplicate CHILD_SA is destroyed and the acquire
state in the trap manager gets removed.  If there is narrowing, a new
reqid is allocated, so the installation of the SA will not remove the
temporary state.  However, due to the narrowing, the duplicate check
fails and when the duplicate is installed (with sequence number), the
temporary state is deleted (as is the state in the trap manager).
2025-05-28 10:01:19 +02:00
Tobias Brunner
c5b2a8eaa3 child-cfg: Use separate method to get configured traffic selectors
Optionally with "dynamic" traffic selectors resolved.  A new method
is added for those cases where we actually want to select potentially
narrowed traffic selectors using a supplied list.  The latter now also
always logs details, while the former does not.
2025-05-28 10:01:19 +02:00
Tobias Brunner
84da416082 trap-manager: Use sequence numbers to identify acquires
Either use the sequence number from the kernel (and potentially update
it if the acquire was retriggered), or generate our own sequence
numbers, which simplifies matching acquires to established/destroyed
CHILD_SAs.
2025-05-28 10:01:19 +02:00
Tobias Brunner
82c82cbbd6 ike: Support optional acquire sequence numbers when creating CHILD_SAs 2025-05-28 10:01:19 +02:00
Tobias Brunner
0c9bac73d9 child-sa: Store and propagate optional acquire sequence number 2025-05-28 10:01:19 +02:00
Tobias Brunner
3e6d7db5e3 kernel-interface: Add members for optional acquire sequence number 2025-05-28 10:01:19 +02:00
Tobias Brunner
301887b865 Merge branch 'regex-ids'
Adds support for POSIX regular expressions in configured identities,
which makes matching remote identities more flexible.
2025-05-28 09:58:46 +02:00
Tobias Brunner
981c82ab50 vici: Add support for POSIX regular expressions in identity fields 2025-05-28 09:58:17 +02:00
Tobias Brunner
10c2985cdd conf: Escape " and \ in man page output 2025-05-28 09:58:17 +02:00
Tobias Brunner
7de05b918c identification: Add support for POSIX regular expressions
When cross-compiling for Windows on Ubuntu, we don't have POSIX regular
expressions available (there does not seem to be any alternative libraries
either), but since the tests are not executed that's OK.  On AppVeyor,
MSYS2 has libgnurx installed, which works fine but requires explicit
linking with `-lregex`.

This is loosely based on a patch by Thomas Egerer.
2025-05-28 09:58:17 +02:00
Tobias Brunner
2b1f0e8c6e debug: Use separate log group for watcher_t
This component produces a lot of messages that make debugging job
handling difficult.
2025-05-27 17:41:02 +02:00
Tobias Brunner
4703ef00ce github: Use AWS-LC 1.52.0 for tests 2025-05-27 17:38:32 +02:00
Tobias Brunner
29986dd1e5 wolfssl: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner
e3fa72b81a ml: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner
07a9926464 botan: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner
37ec770758 pki: Reduce indentation in usage output and print command description
Also print error message at the end of the output.
2025-05-27 17:38:32 +02:00
Tobias Brunner
5f4988eb7c swanctl: Reduce indentation in usage output and print command descriptions
Also print error message at the end of the output.
2025-05-27 17:38:24 +02:00
Tobias Brunner
9a9d0a0bf7 swanctl: Document maximum log level of messages received by --log 2025-05-22 14:24:43 +02:00
Tobias Brunner
362fa94ef5 vici: Document that the log event only receives messages on level 0 and 1 2025-05-22 14:05:51 +02:00
Tobias Brunner
688b9e27d5 Merge branch 'initiate-cancel'
Allow proper shutdown if a deadlock is caused by too many concurrent
blocking initiation requests.

References strongswan/strongswan#2776
2025-05-19 17:21:57 +02:00
Tobias Brunner
f8e5e38b12 vici: Make threads handling requests get canceled explicitly
Threads initiating SAs can get stuck on the semaphore in
wait_for_listener() during shutdown if the corresponding job is never
executed.  A particular case when this can happen is if more initiations
are triggered than worker threads are available.  This causes a (known)
deadlock as no workers are free anymore to process jobs (for inbound
messages or timeouts etc.), including the one to initiate an SA.
This change at least allows a proper shutdown.
2025-05-19 17:20:59 +02:00
Tobias Brunner
8d3855ba31 vici: Don't pass stack variable to thread cleanup handler
The variable seems to get overwritten during cleanup, causing a
segmentation fault because either the pointer and/or the length is
invalid.
2025-05-19 17:19:20 +02:00
Tobias Brunner
367e782054 controller: Avoid memory leak if initiate job is never executed
This can happen if the daemon is terminated while an initiation is
pending.
2025-05-19 17:19:20 +02:00
Tobias Brunner
94cc07cab4 uci: Remove obsolete and broken plugin
The plugin was apparently broken for years because it uses functions that
don't exist anymore.  It was quite limited anyway, so it was never really
used in OpenWrt to begin with (instead they generate configs in a custom
init script).
2025-05-19 17:17:45 +02:00
Tobias Brunner
2b3a5172d8 configure: Add missing dependency of lib-prefix.m4
Fixes: 7ec0101250bf ("Include lib-prefix.m4 directly and remove gettext dependency")
2025-05-13 18:45:45 +02:00
Tobias Brunner
e8e5e2d441 configure: Simplify inclusion of M4 macros 2025-05-13 18:45:45 +02:00
Gerardo Ravago
99fda969b4 openssl: Fix AWS-LC build
The `crypt` functions defined here conflict with the `crypt` function
defined in `unistd.h` and trigger compilation errors when building
against the latest version of AWS-LC, which introduced a new transitive
include of `unistd.h` via `bio.h`.

This simply renames the function to avoid the error.

Closes strongswan/strongswan#2786
2025-05-13 17:16:07 +02:00
Tobias Brunner
7ec0101250 Include lib-prefix.m4 directly and remove gettext dependency
A recent gettext release (0.25 via Homebrew) installs the M4 macros in a
different location (<prefix>/share/gettext/m4 instead of
<prefix>/share/aclocal). According to the commit messages to avoid "bad
interactions between autoreconf and autopoint".  Since we only depend
on gettext for that macro and this move makes it complicated, we can also
just integrate the macro from gnulib directly (which gettext 0.18+ relies
on anyway).
2025-05-13 17:15:23 +02:00
Tobias Brunner
198d112745 github: Use AWS-LC 1.51.2 for tests 2025-05-13 17:15:15 +02:00
Tobias Brunner
2ee768ec4e ha: Fix arguments in debug statement when destroying incomplete IKE_SAs
Closes strongswan/strongswan#2781

Fixes: 97bd0e2297ed ("ha: Destroy incomplete IKE_SAs after de-/activating a segment")
2025-05-13 17:15:05 +02:00
Tobias Brunner
a1a477528f Use wolfSSL 5.8.0 for tests 2025-05-13 17:14:54 +02:00
Tobias Brunner
5863b8d89b wolfssl: Update ML-KEM API for wolfSSL 5.8.0 release 2025-05-13 17:14:54 +02:00
Tobias Brunner
4249d721ec testing: Add rw-eap-id-switch scenario 2025-04-14 12:18:24 +02:00
Tobias Brunner
2f2e4abe3c ikev2: Add support to switch peer configs based on EAP-Identities
This changes how EAP identities are used from the config. Instead of
setting a statically configured identity != %any, an EAP-Identity
exchange is now always initiated (and required).  If the received identity
doesn't match, the peer config is switched to one with a matching
identity (wildcards are supported for that match).  This allows switching
to a config with a different EAP method or child settings based on the
EAP identity.

There is currently no "best" match.  The configs are evaluated based on
the order returned from the initial peer config lookup.

References strongswan/strongswan#2702
2025-04-14 12:05:24 +02:00
Tobias Brunner
651a5b0ded android: Only select default ABIs when building OpenSSL
This skips the experimental RISC-V ABI in newer NDKs.
2025-04-14 11:54:42 +02:00
Tobias Brunner
09edb565ba android: Skip unknown ABIs when building OpenSSL
Newer NDKs have RISC-V as experimental ABI (not enabled by default, see
next commit).  If we don't have a mapping for a specific target, OpenSSL
falls back to 'android-arm', so that won't really work (interestingly,
it does build).
2025-04-14 11:54:42 +02:00
Tobias Brunner
0f1f375a21 android: Protect but don't keep track of sockets used for source address lookups
These sockets are closed immediately again, so no need to re-protect them
during roaming events.

References strongswan/strongswan#1691

Fixes: 6d87a8651068 ("android: Use new sockets to determine source IP")
2025-04-14 11:54:42 +02:00
Tobias Brunner
77f99df656 android: Remove special handling of legacy Android versions in native code
Since minSdkVersion has been 21 for a while, we can remove some code
that was necessary for older versions.
2025-04-14 11:54:42 +02:00
Tobias Brunner
523067e6db init: Only install legacy service unit if starter/stroke is enabled
Closes strongswan/strongswan#2722
2025-04-14 11:54:42 +02:00
Tobias Brunner
8ae00c334a charon-nm: Mark VPN connection as persistent
If this is not set, it looks like NM shuts down the VPN connection and
calls disconnect() if there is any connectivity change.

References strongswan/strongswan#2707
2025-04-14 11:40:59 +02:00
Tobias Brunner
57e74f64b3 kernel-netlink: Enable UDP GRO
This enables GRO offload for inbound ESP-in-UDP packets if the
esp4|6_offload modules are loaded.  Note that inbound ESP or ESP-in-UDP
packets won't be visible on layer 3 in Netfilter or tcpdump.
2025-04-14 11:39:44 +02:00
Tobias Brunner
d54a29cc5c github: Use OpenSSL 3.5.0 to test ML-KEM 2025-04-14 11:38:48 +02:00
Tobias Brunner
b914333ab4 openssl: Add support for ML-KEM with OpenSSL 3.5 2025-04-14 11:38:48 +02:00
Tobias Brunner
f2e88b169f leak-detective: Whitelist OpenSSL 3.5 functions 2025-04-14 11:38:48 +02:00
Tobias Brunner
fd17d154e5 github: Build OpenSSL from the Git repository instead of a tarball
This is more flexible and allows test builds against branches.
2025-04-14 11:38:48 +02:00
Tobias Brunner
defbabd724 tty: Produce colored output in CI environments 2025-04-10 09:33:19 +02:00
Tobias Brunner
245ea0597d vici: Increase buffer to hold uint64_t when parsing packet limits 2025-04-10 08:31:10 +02:00
Thomas Egerer
ed8c08fbe7 vici: Improve byte lifetime parsing
Increase buffer to 32 bytes to hold uint64_t completely and check for
overflows after multiplication with size modifiers.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-04-10 08:31:10 +02:00
Tobias Brunner
9fe58c83fb proposal: Add supported KE methods to default ESP/AH proposals, but optional
This allows accepting clients that send proposals with non-optional KE
methods during rekeying, while still accepting clients that use the
previous non-KE default proposals.
2025-04-10 08:31:10 +02:00
Tobias Brunner
8cb36be188 swanctl: Document "none" keyword for ESP proposals 2025-04-10 08:31:10 +02:00
Tobias Brunner
46674e64c1 ha: Support sync of private IKE_SA extensions and conditions
This requires a new protocol version as private extensions would enable
unrelated regular extensions, even when sending the private extension
as second attribute (which would work for conditions as they are
explicitly enabled/disabled).
2025-04-10 08:31:09 +02:00
Tobias Brunner
8679d91c81 ike-sa: Remove redundant setting of IKE_SA conditions after a rekeying
This was originally added with b0e40caafbd7 ("NAT-T conditions were not
inherited during IKE_SA rekeying") in 2008 when there was only a single
inherit() method.  Later the inherit_pre() method was added and then
with 094963d1b160 ("ikev2: Apply extensions and conditions before
starting rekeying") in 2014 the extensions and conditions were set
already there.
2025-04-10 08:31:09 +02:00
Tobias Brunner
07978c16b3 ike-sa: Add possibility to store private extensions/conditions
This avoids conflicts with upstream changes if patched versions of
strongSwan require a number of private extensions and conditions.  For
example, the following extensions can be used as usual via the
`enable|supports_extension()` methods:

	#define PRIVATE_EXT_1 (EXT_PRIVATE_MARKER | (1<<0))
	#define PRIVATE_EXT_2 (EXT_PRIVATE_MARKER | (1<<1))

Defining an enum would also be possible but because the type won't match
the values would have to be cast to `ike_extension_t` when using the
methods.

Similarly, `COND_PRIVATE_MARKER` may be used to define private conditions
that can be used with the `set|has_condition()` methods.

Because the MSB is explicitly not set in `private_extensions|conditions`,
these members may directly be checked against private values, e.g.:

	if (this->private_extensions & PRIVATE_EXT_1)
	{
	}
2025-04-10 08:31:09 +02:00
Tobias Brunner
6ed63be612 peer-cfg: Use flags for boolean options
Makes it potentially easier to add new flags.

The mediation flag is not converted as the #ifdefs make it awkward.
2025-04-10 08:31:09 +02:00
Tobias Brunner
b0a4b7f2dd daemon: Add facility to register custom init/deinit functions
Same as the previous commit but with access to the daemon.
2025-04-10 08:31:09 +02:00
Tobias Brunner
a6f4146f45 library: Add facility to register custom init/deinit functions
These can be linked into the application to do initialization/cleanup
without having to modify the source code.
2025-04-10 08:31:09 +02:00
Tobias Brunner
1a20502573 github: Add compile test with --without-testable-ke option 2025-04-10 08:31:09 +02:00
Tobias Brunner
6cbd93838b Add configure option to disable testing key exchange methods
If this is used, the functionality to set a private key/value/seed for
key exchange methods is removed (including from the interface to avoid
accidentally forgetting to wrap implementations and uses of set_seed()).

The set_seed() method is assigned outside the INIT() macro to avoid
potentially undefined behavior (preprocessing directives in macro
arguments).

The test done by the crypto tester is a simple functionality test.
2025-04-10 08:31:09 +02:00
Thomas Egerer
a7c285bc50 auth-cfg: Add lower case enum names for auth_rule_t
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-04-10 08:31:09 +02:00
Thomas Egerer
af9095fdd9 ldap: Use timeout value for synchronous calls
So far, the timeout value was only used as connect timeout while a
malicious server could accept the connection and then starve us. So use
the timeout for LDAP_OPT_TIMEOUT, too, which affects all synchronous
calls.  In particular, ldap_simple_bind_s(), which has no timeout
argument like ldap_search_st().

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-04-10 08:31:09 +02:00
Thomas Egerer
ee4e93419b gitignore: Add *.i and *.s files
Ignore a couple of compiler generated temp files.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-04-10 08:31:09 +02:00
Tobias Brunner
0bccc287d6 Doxyfile: Exclude OpenSSL sources of Android app
They can produce warnings and we don't want to include documentation for
these anyway.
2025-04-10 08:31:09 +02:00
Tobias Brunner
cdefe52494 github: Set type in issue templates 2025-04-10 08:31:09 +02:00
Tobias Brunner
d7305a556f testing: Use blockdev instead of partprobe to load partitions
This avoids a dependency on parted as blockdev is in util-linux on
Debian/Ubuntu, which is installed by default.  And it might work more
reliably.
2025-04-10 08:31:09 +02:00
Tobias Brunner
353d5c130b testing: Use tar instead of recursive scp
It seems that scp is sometimes very slow (unclear what causes it as it's
not always the same).  Packing up the files with tar performs a lot
better in these situations.  And copying the files to multiple hosts
in parallel additionally helps to reduce the time required for these
steps.

Using --overwrite and -h preserves existing symlinks (e.g. for the users
file in /etc/freeradius/3.0) and overwrites the target file instead.
The -m option ignores timestamps when extracting the files as some target
files will be newer than the source.  Using -h when packing up files in
load-testconfig allows using symlinks in the test config dirs to files
on the host running the tests.
2025-04-07 14:54:48 +02:00
Tobias Brunner
d7eb3ed92e testing: Make ocsp.cgi in ikev2-multi-ca/ocsp-signers scenario executable 2025-04-07 14:54:48 +02:00
Tobias Brunner
a1ab256756 testing: Add some network utilities to the base image 2025-04-04 12:06:59 +02:00
Tobias Brunner
022f2d5f30 testing: Add option for a quick rebuild of strongSwan
This shaves off about 1 minute of build time on my machine.  We also
don't need the separate build step and can just run `make install`.
2025-04-04 12:06:59 +02:00
Tobias Brunner
02c43fa6e4 testing: Move removal of charon.pid into posttest section
Fixes: a103f3a2849f ("testing: Add options to only run pre- or posttest scripts of a scenario")
2025-04-04 12:06:59 +02:00
Tobias Brunner
08428f6b5d testing: Fix loading test config for tests that were never run
The file won't exist in the previous location until load-testconfig was
executed once.  Since it's not modified by the script it's fine to
load it directly from the original location.

Fixes: a103f3a2849f ("testing: Add options to only run pre- or posttest scripts of a scenario")
2025-04-04 12:06:59 +02:00
Tobias Brunner
5e4dedfc20 Merge branch 'android-always-on-managed'
Fixes an issue with initiating managed profiles as Always-on VPN.

Closes strongswan/strongswan#2756
2025-04-04 08:57:12 +02:00
Tobias Brunner
8036b3f932 android: New release after fixing Always-on VPN with managed profiles 2025-04-03 16:35:47 +02:00
Tobias Brunner
d87be9b981 android: Fix starting a managed profile as Always-on VPN
The callbacks provided via ProcessLifecycleOwner are only triggered when
Activities are started.  However, when Android triggers the Always-on
VPN it directly starts our VpnService subclass, no Activity.  So the
configs were not loaded and the VPN couldn't be initiated with a managed
profile.  This ensures the config is loaded right from the start of
the app.  And by registering for modifications in onCreate() we can also
use the correct config if the app is never started in-between changes to
the managed profiles and triggering the Always-on VPN.
2025-04-03 16:19:53 +02:00
Tobias Brunner
11978ddd39 Cast uses of return_*(), nop() and enumerator_create_empty()
As described in the previous commit, GCC 15 uses C23 by default and that
changes the meaning of such argument-less function declarations.  So
whenever we assign such a function to a pointer that expects a function
with arguments it causes an incompatible pointer type warning.  We
could define dedicated functions/callbacks whenever necessary, but this
seems like the simpler approach for now (especially since most uses of
these functions have already been cast).
2025-03-19 10:22:37 +01:00
Tobias Brunner
d5d2568ff0 callback-job: Replace return_false() in constructors with dedicated function
Besides being clearer, this fixes issues with GCC 15.  The latter uses
C23 by default, which changes the meaning of function declarations
without parameters such as

	bool return false();

Instead of "this function takes an unknown number of arguments", this
now equals (void), that is, "this function takes no arguments".  So we
run into incompatible pointer type warnings all over when using such
functions.  They could be cast to (void*) but this seems the cleaner
solution for this use case.
2025-03-19 10:22:37 +01:00
Tobias Brunner
38d89f57f0 charon-nm: Use CALLBACK macro for callback job's cancel implementation
Casting to this specific function type doesn't work anymore if C23 is
used as the types mismatch.
2025-03-19 10:22:37 +01:00
Tobias Brunner
a7b5de5690 pki: Fix signature of help() to match that of a callback in command_t 2025-03-19 10:22:37 +01:00
Tobias Brunner
2553357f85 github: Use AWS-LC 1.48.5 for tests 2025-03-18 08:32:52 +01:00
Tobias Brunner
1f222f5dfb testing: Install iperf3 instead of iperf 2025-03-14 11:49:48 +01:00
Tobias Brunner
a103f3a284 testing: Add options to only run pre- or posttest scripts of a scenario
This allows to manually do some testing without having to type commands
to set up a scenario.

Also changes how arguments are parsed (allowing to pass options mixed
with test dirs) and adds some usage output.
2025-03-14 11:49:42 +01:00
Tobias Brunner
25ec2bc43d Don't reference 5.9 in URLs to docs.strongswan.org 2025-03-11 10:26:31 +01:00
Tobias Brunner
378c75cb2e nm: Version bump to 1.6.2 2025-03-11 09:57:54 +01:00
Andreas Steffen
1e8cca4004 Version bump to 6.0.1 2025-03-10 19:19:37 +01:00
Andreas Steffen
5a74d796a8 testing: Adapted ha/active-passive tests 2025-03-10 19:18:40 +01:00
Tobias Brunner
fcaee9e123 vici: Document ICMP type/code traffic selector restrictions 2025-03-05 10:55:51 +01:00
Tobias Brunner
3c3a545bfe NEWS: Add news for 6.0.1 2025-03-05 08:50:44 +01:00
Tobias Brunner
4e2cf58961 receiver: Properly clean up if hasher or RNG can't be created 2025-03-04 15:30:25 +01:00
Tobias Brunner
380ec66c92 winhttp: Properly destroy linked list if connection can't be opened 2025-03-04 15:27:53 +01:00
Tobias Brunner
a70ba4d600 pkcs11: Free copied name of PKCS#11 module in error cases 2025-03-04 14:48:42 +01:00
Tobias Brunner
8fc09ae158 stream-service: Avoid FD leak during deinitialization 2025-03-04 14:41:03 +01:00
Tobias Brunner
3b0f260b40 gcm: Properly clean up IV generator if crypter can't be created 2025-03-04 14:37:44 +01:00
Tobias Brunner
2cf94745de daemon: Properly clean up logger entries in error cases
The copied target string was not freed.
2025-03-04 14:33:36 +01:00
Tobias Brunner
e6b9f82a87 swanctl: Fix memory leak in --load-creds if --clear fails 2025-03-04 14:30:35 +01:00
Tobias Brunner
938f6d3777 testing: Update build recipe after changing Python build
Fixes: 3babf1f7108d ("vici: Update Python build")
2025-03-04 13:52:30 +01:00
Tobias Brunner
251582d0b6 vici: Update docs after changing Python build
Fixes: 3babf1f7108d ("vici: Update Python build")
2025-03-04 13:52:24 +01:00
Tobias Brunner
511add2111 Fixed some typos, courtesy of codespell 2025-03-04 13:43:31 +01:00
Andreas Steffen
61c0006002 Version bump to 6.0.1rc1 2025-03-03 10:10:03 +01:00
Tobias Brunner
8c1714ba12 Revert "kernel-netlink: Don't fallback to peer address as gateway"
This reverts commit f717bb5249caea550bc6e2baeb09ca309ad83b39.

Causes issues in our testing environment. Default route via host is
preferred if no gateway is set in the installed routes.  Needs some
investigation.

References strongswan/strongswan#2548
2025-03-03 09:46:14 +01:00
Tobias Brunner
de30b6b385 charon-nm: Lower default retransmission settings to restore SAs more quickly
These are the same values we use for the Android app.

References strongswan/strongswan#2696
2025-02-28 16:47:05 +01:00
Tobias Brunner
8e97e20642 charon-nm: Use a DPD to check the current path
If the client's network goes down for a while but the same IP address
is assigned later, it won't be aware if the server killed the IKE_SA
while it wasn't reachable.  This way, a DPD is triggered and the client
can reestablish the SA if necessary.  When roaming to a different IP,
a MOBIKE update is triggered with the same effect.

References strongswan/strongswan#2696
2025-02-28 16:46:50 +01:00
Tobias Brunner
af0535894c conf: Document some global options for charon-nm
These have specific values for charon-nm's use case but might have to be
changed for special setups or because of conflicts.

References strongswan/strongswan#2683
2025-02-28 16:46:43 +01:00
Tobias Brunner
7205d02360 conf: Add missing modules to install config snippets
In particular the one for charon-nm was missing.

References strongswan/strongswan#2683
2025-02-28 16:45:33 +01:00
Tobias Brunner
069a81e69a ikev2: Trigger ike_reestablish_pre|post events for make-before-break reauth
Listeners can't track those IKE_SAs otherwise.  For break-before-make
reauthentications, these events are already triggered because that is
implemented by calling reestablish() on the old IKE_SA.
2025-02-28 16:27:10 +01:00
Tobias Brunner
660e06b048 ike-sa: Fix check for make-before-break when handling DELETE failure
Fixes: a5e80cf5e451 ("libcharon: Enable make_before_break option by default")
2025-02-28 16:27:10 +01:00
michael-dev
bff500dfd0 ike-natd: Float to the NAT-T port early when not connecting to port 500
When using port 4500 for IKE_SA_INIT, Windows Server 2016, 2025 and
possibly others send back all packets to the port initially used by the
client, not the one floated to before sending IKE_AUTH. So if UDP
encapsulation is used, no traffic can be received as the initial socket
can't have UDP decapsulation enabled.

tcpdump output:
```
IP <client-ip>.47547 > <server-ip>.4500: UDP-encap: ESP(spi=0xfd4e5fc2,seq=...)
IP <server-ip>.4500 > <client-ip>.57962: UDP-encap: ESP(spi=0xccc5e213,seq=...)
```

Avoid this by floating early if a non-default destination port is used.
This also ensures we don't send packets from port 500 (without non-ESP
marker) if ephemeral source ports are not used.

Closes strongswan/strongswan#2664

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2025-02-28 16:25:32 +01:00
Tobias Brunner
882b19c1df ike-sa: Only query last use time of CHILD_SAs if UDP-encap is used
Without UDP-encapsulation, the IKE and ESP traffic is not directly related
(other than via IPs), so firewalls might no keep the state for IKE traffic
alive if there is no IKE traffic for a while and constant ESP traffic
prevents DPDs from being exchanged because inbound ESP traffic is
considered.

Closes strongswan/strongswan#1759
2025-02-28 16:19:02 +01:00
Tobias Brunner
57703fa089 eap-radius: Add support to specify and bind a specific source address
Using a specific address can be useful in scenarios where dynamic routing
could change the path to the RADIUS server and a changing source address
is a problem for the server.

Closes strongswan/strongswan#2598
2025-02-28 16:16:48 +01:00
Tobias Brunner
c3ae859b9b Merge branch 'ha-multi-ke'
Adds support for multiple key exchanges to the ha plugin.  Also,
because of the delayed key derivation and the not synced IntAuth
values, incomplete IKE_SAs are now destroyed during a failover.

Closes strongswan/strongswan#2550
2025-02-28 16:11:59 +01:00
Tobias Brunner
97bd0e2297 ha: Destroy incomplete IKE_SAs after de-/activating a segment
The node that gets activated usually won't be able to complete the
IKE_SA mainly because the IKE keys are now derived delayed, so the key
material required to process a message often won't be available (only
later IKE_AUTH messages and retransmits of earlier messages that the
active node already received and synced the keys for may be decrypted).

A second issue affects IKE_SAs with multiple key exchanges.  Because the
IntAuth value(s) are currently not synced, which are necessary to
verify/create the AUTH payloads, the IKE_AUTH exchange couldn't be
completed.
2025-02-28 16:02:41 +01:00
Jean-François Hren
fd6ac87fc3 testing: Add ha/active-passive-multi-ke scenario 2025-02-28 16:02:41 +01:00
Tobias Brunner
e7848e36fa ha: Add support to sync IKE and Child SAs with multiple key exchanges
Synchronization for the additional transforms in the IKE and Child SA
proposals is added.  Details of the IKE_SA synchronization are changed
to support IKE_INTERMEDIATE exchanges that cause multiple HA_IKE_ADD
messages and key derivations.  The cache has been extended to handle
multiple such messages.

Co-authored-by: Thomas Egerer <thomas.egerer@secunet.com>
2025-02-28 16:02:41 +01:00
Tobias Brunner
f717bb5249 kernel-netlink: Don't fallback to peer address as gateway
This doesn't really seem useful (perhaps it was before we started to
configure the outbound interface on our routes). And it can actually
cause the route installation to fail e.g. for routes over point-to-point
interfaces where we'd get "Error: Nexthop has invalid gateway" errors.

Closes strongswan/strongswan#2548
2025-02-28 16:01:49 +01:00
Tobias Brunner
9c97ecbb31 scripts: Add support for out-of-tree builds to test script
Can be useful when using the script locally.
2025-02-28 14:21:49 +01:00
Tobias Brunner
e385a83f5e vici: Fix out-of-tree builds with Perl module enabled
Not really building it out-of-tree for now, though.
2025-02-28 14:21:49 +01:00
Tobias Brunner
fad99c7a88 github: Explicitly install required packages for Linux builds
The runner images have some software pre-installed, which isn't the
case on regular Ubuntu images.
2025-02-28 14:21:41 +01:00
Tobias Brunner
8e4ea2cbbd github: Use all available CPU cores when building 2025-02-28 12:55:12 +01:00
Tobias Brunner
8c4e9f8c7b github: Call Botan configure script directly
This should find the required Python binary automatically (`python` might
not be available if not explicitly installed).
2025-02-28 12:55:12 +01:00
Tobias Brunner
f740faccac github: Don't use pip3 to install Python packages anymore
Currently, the runner images enable break-system-packages globally.
However, this workaround will be removed by the end of March.  So
we switch to installing these packages as intended via distro (the
alternative would be to use pipx, at least for tox).
2025-02-28 12:55:12 +01:00
Tobias Brunner
0bce9839c9 Merge branch 'android-reauth-fix'
Fixes issues with reauthentication, in particular, to reestablish the
SA if MOBIKE is disabled.  The app currently can't handle
make-before-break reauthentication.  In part because necessary events are
currently not triggered.  So for now, we switch back to the classic
reauthentication approach.
2025-02-27 11:23:52 +01:00
Tobias Brunner
a299a4d3ce android: New release after fixing reauthentication regression 2025-02-25 15:21:56 +01:00
Tobias Brunner
40a37b6ffc android: Disable make-before-break reauthentication
The service implementation with its handling of reauth callbacks and
no-DNS TUN device etc. can't handle make-before-break reauthentication
at the moment.
2025-02-25 14:57:00 +01:00
Tobias Brunner
9d4decbde8 github: Remove runs on Ubuntu 20.04
They will start to fail on certain days in March before the images are
removed on April 1st.
2025-02-21 14:46:08 +01:00
Tobias Brunner
5468759c71 github: Check test vectors with output in crypto plugin tests
This way we see what was actually tested. Increasing the verbosity for
the general test run produces too much output.
2025-02-21 14:13:26 +01:00
Tobias Brunner
31c44a758f test-vectors: Add a soft dependency on DRBG used for KEM tests
Depending on the loaded plugins, it's not necessary. So it's not a hard
dependency.
2025-02-21 11:06:17 +01:00
Tobias Brunner
e12540025d gmp: Declare dependency on DRBG to generate private keys 2025-02-21 11:06:02 +01:00
Tobias Brunner
ff50db8758 cirrus: Use FreeBSD 13.4 and 14.2 2025-02-20 16:30:11 +01:00
Tobias Brunner
1f0dd8d585 github: Use OpenSSL 3.4.1 for tests
There was an issue with OPENSSL_armcap_P in Android's static build for
OpenSSL 3.1.1+. This was finally fixed with this release (and was also
backported to older versions).
2025-02-20 16:30:11 +01:00
Tobias Brunner
827c572efd github: Use AWS-LC 1.46.1 for tests 2025-02-20 11:59:55 +01:00
Tobias Brunner
e4d6bcef48 android: Move annotation to method where startActivityAndCollapse() is called
Fixes: 5237bf3a5c6f ("android: Suppress deprecation warning because of startActivityAndCollapse()")
2025-02-20 11:59:55 +01:00
Tobias Brunner
b93141985b Merge branch 'android-passwords'
Adds support to import passwords via managed configuration and profile
files. Also fixes several deprecation warnings.

Closes strongswan/strongswan#2589
Closes strongswan/strongswan#2642
Closes strongswan/strongswan#2643
2025-02-20 11:08:29 +01:00
Tobias Brunner
f0f986c55d android: New release after adding support for passwords in managed configs and profile files
Also fixes some bugs and deprecation warnings.
2025-02-18 14:19:40 +01:00
Tobias Brunner
a47e282d09 android: Imported VPN profile files may contain passwords
A warning is displayed to the users, reminding them that there is a
cleartext password in the file.
2025-02-18 14:12:43 +01:00
Tobias Brunner
0b6d42661d android: Consistently use *Start/End in layouts and remove redundant old settings 2025-02-18 14:12:43 +01:00
Tobias Brunner
b021406f6b android: Suppress deprecation warning because of stopForeground() 2025-02-18 14:12:43 +01:00
Tobias Brunner
5237bf3a5c android: Suppress deprecation warning because of startActivityAndCollapse() 2025-02-18 14:12:43 +01:00
Tobias Brunner
4e2c88f7ed android: Handle deprecated getParcelable* and getSerializable methods 2025-02-18 14:12:43 +01:00
Tobias Brunner
288bd41aca android: Suppress warning in implementation only used for Android < 33 2025-02-18 14:12:43 +01:00
Tobias Brunner
26eef1f095 android: Replace deprecated onBackPressed() and enable predictive back gestures
Doesn't really make a difference it seems.
2025-02-18 14:12:43 +01:00
Tobias Brunner
9a92088bb4 android: Replace deprecated fragment menu APIs 2025-02-18 14:12:43 +01:00
Tobias Brunner
10d8b66f05 android: Ignore empty strings for settings in managed profiles
Unspecified settings should be set to null, while some MDMs might send
them as empty strings, which could cause issues (like an empty password
or trying to parse an empty DNS server address).
2025-02-18 14:12:43 +01:00
Tobias Brunner
4f808cb2b0 android: Allow setting the password in managed profiles
To avoid complicated changes in the UI, users can still update it.  But
the default, if they clear the field, will be the managed password.
2025-02-18 14:12:43 +01:00
Tobias Brunner
87610799f2 android: Properly deinit library if parsing an IP fails
This can happen with empty strings, which might be set for managed
profiles, which caused the refcounting to be askew and the resolver not
to work after connecting once because it was flushed and disabled.
2025-02-18 14:12:43 +01:00
Tobias Brunner
ff2010c8da android: Update NDK version and enable support for 16KiB page tables 2025-02-18 14:12:43 +01:00
Tobias Brunner
e6b040265d android: Fix updating password for managed profiles
Without data source set on the profile, this caused the app to crash
with a null pointer dereference when it is updated.
2025-02-18 14:12:43 +01:00
Tobias Brunner
19925fd893 unit-tests: Document additional supported env variables 2025-02-10 15:41:52 +01:00
Tobias Brunner
e0fc0adc93 Merge branch 'nm-gui-ts'
Adds fields for local and remote TS to the GUI.

Closes strongswan/strongswan#2580
2025-02-07 13:27:37 +01:00
Tobias Brunner
4e634f4511 nm: Add German translation for traffic selector fields 2025-02-07 12:01:00 +01:00
Jiří Matěják
418ef2a7a1
nm: Expose local-ts
Signed-off-by: Jiří Matěják <matejak@merica.cz>
2025-02-06 21:01:50 +01:00
Jiří Matěják
d0dd7b561b
nm: Expose remote-ts
Signed-off-by: Jiří Matěják <matejak@merica.cz>
2025-02-06 21:00:48 +01:00
Tobias Brunner
9aa2be8411 charon-nm: Add option to configure local traffic selectors
Closes strongswan/strongswan#2084
2025-02-06 17:20:25 +01:00
Tobias Brunner
941b7194a5 github: Use AWS-LC 1.45.0 for tests 2025-02-06 08:29:09 +01:00
Tobias Brunner
36c1cb4f8c Use Botan 3.7.1 for tests 2025-02-05 14:14:40 +01:00
Tobias Brunner
c2e5c00df3 Merge branch 'dhcp-receive'
This fixes a regression introduced with pf_handler_t in 5.9.14.  It also
binds the packet sockets correctly to the configured interface, and adds
an option for the dhcp plugin that allows binding the send and receive
sockets to different interfaces.
2025-01-31 11:21:04 +01:00
Tobias Brunner
a50ed3006e dhcp: Add option to bind the receive socket to a different interface
This can be useful if the DHCP server runs on the same server. On Linux,
the response is then sent via `lo`, so packets won't be received if both
sockets are bound to e.g. a bridge interface.
2025-01-31 11:20:42 +01:00
Tobias Brunner
00d8c36d6f pf-handler: Correctly bind packet socket to an interface
Binding such sockets via SO_BINDTODEVICE does not work at all. Instead,
bind() has to be used, as described in the packet(7) man page.
2025-01-31 11:20:32 +01:00
Tobias Brunner
abbf9d28b0 pf-handler: Accept loopback interfaces as packet source
In some setups the responses from the DHCP server are sent via lo, which
does not have an address of type `ARPHRD_ETHER` (the address length is
the same, though, just all zeros, by default).  Note that the dhcp plugin
doesn't actually care for the MAC address or interface details, that's
only used by the farp plugin.

Fixes: 187c72d1afdc ("dhcp: Port the plugin to FreeBSD/macOS")
2025-01-31 11:19:42 +01:00
Nathan Tran
543a4c86f9 ikev2: Handle INVALID_SYNTAX after IKE_AUTH by deleting IKE_SA
When serving as a responder and receiving an INFORMATIONAL exchange
containing INVALID_SYNTAX after IKE_AUTH, the IKE_SA should be deleted.
Currently, it only gets deleted after receiving AUTHENTICATION_FAILED.
RFC7296 section 2.21.2 says:

 In an IKE_AUTH exchange, or in the INFORMATIONAL exchange immediately
 following it (in case an error happened when processing a response to
 IKE_AUTH), the UNSUPPORTED_CRITICAL_PAYLOAD, INVALID_SYNTAX, and
 AUTHENTICATION_FAILED notifications are the only ones to cause the
 IKE SA to be deleted or not created, without a Delete payload.

Closes strongswan/strongswan#2636
2025-01-29 17:31:40 +01:00
Tobias Brunner
d38eaa6dd7 sonarcloud: Ignore that we don't define loop variables inside the loop
Also add the official description for the other ignored rules.
2025-01-21 15:16:33 +01:00
Nathan Tran
1d5c5a1d72 openssl: Require min version 3.0.0 for HKDF to support larger MODP groups and nonces
Also enables the `kdf` plugin automatically if building against an older
version of OpenSSL.

Closes strongswan/strongswan#2602

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2025-01-15 18:11:18 +01:00
Tobias Brunner
d860c26e95 plugin-loader: Properly support compilation without dlopen()/dlsym() etc.
This only works if plugins are built monolithically and linked statically.

Closes strongswan/strongswan#2615
2025-01-13 17:51:14 +01:00
Tobias Brunner
41538cf259 sw-collector: Fix build with DEBUG_LEVEL < 1 2025-01-13 15:33:33 +01:00
Tobias Brunner
0784ebdd2d pts: Fix build with DEBUG_LEVEL < 1 2025-01-13 15:04:13 +01:00
Tobias Brunner
e248f0f3c2 libtnccs: Fix build with DEBUG_LEVEL < 1 2025-01-13 15:04:13 +01:00
Tobias Brunner
47d5adc96a eap-sim-file: Fix build with DEBUG_LEVEL < 1 2025-01-13 15:04:13 +01:00
Tobias Brunner
52771c1392 simaka-manager: Fix build with DEBUG_LEVEL < 1 2025-01-13 12:02:17 +01:00
Tobias Brunner
a0353af6df gmp: Fix build with DEBUG_LEVEL < 1 2025-01-13 11:36:32 +01:00
Tobias Brunner
504e6033d9 optionsfrom: Fix build with DEBUG_LEVEL < 1 2025-01-10 18:53:57 +01:00
Tobias Brunner
4cf0a5b631 credential-factory: Fix build with DEBUG_LEVEL < 1
Newer versions of clang complain here.
2025-01-10 18:53:57 +01:00
Tobias Brunner
227d7ef9a2 tnc-imv: Add missing argument to IMV recommendations constructor
This avoids the following warning/error:

tnc_imv_manager.c:244:39: error: passing arguments to 'tnc_imv_recommendations_create' without a prototype is deprecated in all versions of C and is not supported in C23 [-Werror,-Wdeprecated-non-prototype]
  244 |         return tnc_imv_recommendations_create(this->imvs);
      |                                              ^
2025-01-10 18:53:57 +01:00
Tobias Brunner
f1f0bd9de6 ctr: Remove parameter-less constructor prototype
Useless and causes a compiler warning/error:

  error: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent declaration [-Werror,-Wdeprecated-non-prototype]
2025-01-10 18:53:57 +01:00
Tobias Brunner
7af260a5f1 coverage: Exclude generated static proposal keywords
The lines in the gperf-generated proposal_keywords_static.c are now
mapped to the (much shorter) .txt source file, which causes mismatches
like these:

  genhtml: ERROR: no data for line:190, TLA:GNC, file:/home/runner/work/strongswan/strongswan/src/libstrongswan/crypto/proposal/proposal_keywords_static.txt

We could ignore "unmapped" errors in genhtml, but since the file is
generated anyway, we can also exclude it from the results and still
get such errors in case this happens for other files.  Another alternative
would be to remove the `#line` macros in the generated file.  Then the
coverage of the actual C file would get reported (but again, it's
generated, so there isn't much value in it).

Also updated the branch coverage option as the one with `lcov_` prefix
is deprecated.
2025-01-10 18:53:57 +01:00
Tobias Brunner
71f4c3dc4e coverage: Use atomic profiling updates to avoid issues with multi-threaded test cases 2025-01-10 18:53:39 +01:00
Tobias Brunner
24c20803a3 library: Exclude the check_memwipe() function from AddressSanitizer
Newer versions of AddressSanitizer (e.g. in Ubuntu 24.04) will report
this now as stack-use-after-return.
2025-01-10 16:53:37 +01:00
Tobias Brunner
6f912345c1 github: Don't install the NDK as root
On the Ubuntu 24.04 image, this causes the /home/runner/.config/.android
directory to be owned by root, which lets the build fail later.
2025-01-10 16:53:37 +01:00
Tobias Brunner
90dac35927 github: Enable SRP in OpenSSL build for clang AddressSanitizer build
On Ubuntu 24.04, llvm-symbolizer-18, which is used to resolve symbols
in backtraces, links libcurl.so.4 for some reason.  And that in turn
requires SRP.  If our custom build doesn't provide it, we get stuff
like this

  /usr/bin/llvm-symbolizer-18: symbol lookup error: /lib/x86_64-linux-gnu/libcurl.so.4: undefined symbol: SSL_CTX_set_srp_password, version OPENSSL_3.0.0

and the symbols are not resolved and can't be whitelisted.

This also makes sure ASan is actually disabled if our own leak-detective
is used.
2025-01-10 16:52:39 +01:00
Tobias Brunner
9d29d522e5 github: Adapt to switch to Ubuntu 24.04 for ubuntu-latest 2025-01-10 16:14:03 +01:00
Tobias Brunner
95dbd5c858 constraints: Exclude self-signed root CAs without policies from policy validation
Self-signed trust anchors are not part of the certificate path validation
according to RFC 8280, section 6.1:

  When the trust anchor is provided in the form of a self-signed
  certificate, this self-signed certificate is not included as part of
  the prospective certification path.

But policies in them could still be used, as stated in section 6.2:

  Where a CA distributes self-signed certificates to specify trust
  anchor information, certificate extensions can be used to specify
  recommended inputs to path validation.  For example, a policy
  constraints extension could be included in the self-signed
  certificate to indicate that paths beginning with this trust anchor
  should be trusted only for the specified policies.  [...]
  Implementations that use self-signed certificates to specify trust
  anchor information are free to process or ignore such information.

So unconditionally enforcing that self-signed root certificates contain
the policies is probably too strict.  Often they won't contain the
extension at all.  With this change, we allow that but still enforce the
policies in case such a certificate contains them.  The other
policy-related constraints are also enforced still should they be
contained.

Closes strongswan/strongswan#2601
2025-01-09 13:51:11 +01:00
Tobias Brunner
cc8c86c673 github: Use AWS-LC 1.41.1 for tests 2024-12-11 17:21:16 +01:00
Tobias Brunner
ad3106d4f6 vici: Add pyproject.toml file to declare build backend 2024-12-11 17:21:16 +01:00
Tobias Brunner
00b209be8d cirrus: Fix vici Python build on Alpine 2024-12-11 17:21:16 +01:00
Tobias Brunner
b0fcae3ea1 testing: Ignore errors when dumping our routing table
Some scenarios disable route installation and if they are executed before
any scenarios that don't, there won't be a rule for table 220 and we get
"FIB table does not exist" errors.
2024-12-11 15:18:09 +01:00
Tobias Brunner
3babf1f710 vici: Update Python build
Directly calling setup.py is deprecated (apparently has been for a while,
but now we get large warnings).  Direct installation is also discouraged.
So this removes that option.  The built wheel (the old egg format is not
used/built anymore) can be installed manually in a venv or the like.
2024-12-11 15:18:09 +01:00
Tobias Brunner
d6a0de0837 vici: Update supported Python versions 2024-12-11 15:18:09 +01:00
Tobias Brunner
a465c54805 github: Update chunk_from_chars() CodeQL query to new data flow API 2024-12-11 15:17:37 +01:00
Tobias Brunner
ddd1126e96 pubkey: Remove unused set_subject() method
If not properly used (i.e. before sharing the object), this was not
thread-safe.  So better remove it and force users to create immutable
objects.
2024-12-10 09:09:29 +01:00
Tobias Brunner
65e121b498 vici: Delay creation of raw public keys until we know the identity
The previous approach had two drawbacks:

First, it caused duplicate public keys because when the `certificate_t`
object was created and added to the credential set it had no subject
assigned yet.  So it defaulted to the key ID.  However, all previously
loaded keys had their subject already changed to an identity, so there
never was a match and new objects were always added whenever a config
with raw public keys was loaded.

Second, the subject was replaced in a way that's not thread-safe on an
object that's already shared in the public credential set.  So other
threads could potentially access the `identification_t` object that's
destroyed during that process.

References strongswan/strongswan#853
Closes strongswan/strongswan#2561
2024-12-10 09:08:05 +01:00
Andreas Steffen
24a9c32a43 testing: Include ML-KEM crypto tests rw-cert scenario 2024-12-06 14:39:20 +01:00
Rob Shearman
caf81bc05c child-create: Fix double free of list of labels after migrate
If a migrate of a child-create occurs then labels_i and labels_r are
freed, but the pointers are left set. If the task is subsequently
destroyed without being reused, then both of these will be double
freed.

Fix this by setting labels_i and labels_r to NULL in the migrate
method after freeing, similar to other fields that are freed.

Closes strongswan/strongswan#2552

Fixes: f9b895b49f49 ("child-create: Add support to handle security labels")
2024-12-05 08:47:52 +01:00
Tobias Brunner
c8f16d18d8 swanctl: Document keX_ prefix and replace DH with KE 2024-12-04 17:59:27 +01:00
Tobias Brunner
c6ca688441 nm: Version bump to 1.6.1 2024-12-03 14:37:26 +01:00
Tobias Brunner
bea1f1100e file-logger: Don't log <> if ike_name is disabled and no IKE_SA is available
Fixes: a2fba6db4a17 ("file-logger: Add option to log messages as JSON objects")
2024-12-03 09:04:34 +01:00
Tobias Brunner
832c811598 testing: Use a single scp command to restore defaults
This is a bit faster than two sequential calls.
2024-12-03 08:43:45 +01:00
Tobias Brunner
3615e907f5 testing: Improve replacing IP addresses in test files
There are a lot of files without patterns and running them all through
sed is quite slow.  Using grep first makes this quicker (about 0.5s per
test).  Ignoring PEM files is also helpful.
2024-12-03 08:43:45 +01:00
Tobias Brunner
1c053bc3f0 testing: Log timestamps relative to the start of the test
Makes it easier to compare multiple runs against each other.
2024-12-03 08:43:45 +01:00
Tobias Brunner
9e88c3f32e testing: Collect test results with an on-guest script in parallel
In particular the swanctl calls all take a while and this allows doing
them in parallel if multiple hosts are involved. This reduces the runtime
of each test by 1-3 seconds.
2024-12-03 08:43:45 +01:00
Tobias Brunner
b3a72c7994 testing: Use an on-guest script to cleanup/initialize and run them in parallel
This is a bit quicker than doing this with separate SSH calls for each
host sequentially (up to half a second per test).
2024-12-03 08:43:45 +01:00
Tobias Brunner
c8cfeeff54 testing: Always use immediate mode for tcpdump
We don't use versions that don't support this anymore and sometimes the
detection didn't work properly and a run without it would get started.
2024-12-03 08:43:45 +01:00
Andreas Steffen
cf9b174dfe Remove two files to be ignored 2024-12-02 23:13:10 +01:00
Andreas Steffen
c86f709b4b Version bump to 6.0.0 2024-12-02 14:21:53 +01:00
Thomas Egerer
fefea48724 child-sa: Update status flags based on success of SA addition
Both variables `inbound_installed` and `outbound_state` are used in
`child_sa_t::destroy()` to determine whether inbound and outbound state
have to be deleted. They are assigned prior to the call to
`kernel_interface_t::add_sa()`. As this call may fail, the destructor may
try to delete a state which it has not been added.
By making the assignment of these variables dependent on the success of
the state addition, we can make sure, a `child_sa_t::destroy()` only
deletes states it has added.

Also removed the redundant checks for `my_spi` and `other_spi` being set
along with the check for the above flags. It seems that when the flags
are set, the SPIs *must* be set.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-11-29 13:46:12 +01:00
Tobias Brunner
8b69327ad2 NEWS: Add news for 6.0.0 2024-11-27 11:38:54 +01:00
Tobias Brunner
6cf84547d7 swanctl: Update note about reauth approaches for reauth_time 2024-11-27 11:08:05 +01:00
Tobias Brunner
ac7500cccd github: Use AWS-LC 1.40.0 for tests 2024-11-27 10:13:36 +01:00
Tobias Brunner
b1858a9b9b scripts: Use correct type for length when printing count for KEM KATs 2024-11-27 10:12:56 +01:00
Andreas Steffen
4de6bb3feb Version bump to 6.0.0rc2 2024-11-26 08:21:20 +01:00
Andreas Steffen
f59ca9698a cert-enroll: Support three generations of CA certificates
If the lifetime of an issuing or sub CA is twice the lifetime of
the end entity certificates issued by it and the renewal cycle of
the issuing CAs is a little shorter than the validity of the end
entity certificates then three generations of CA certificates have
to be handled by the cert-enroll scripts.
2024-11-26 08:15:09 +01:00
Tobias Brunner
559298b53e x509: Use SHA-256 as default hash/signature algorithm for attribute certificates
References strongswan/strongswan#2523
2024-11-25 16:52:35 +01:00
Tobias Brunner
5b677e612d unit-tests: Remove RSA/ECDSA schemes with weak hash algorithms (MD5/SHA-1)
These have been discouraged for a long time and there are now more and
more crypto libraries that have them disabled by default.  However, for
some we only can detect this at runtime, in particular in FIPS mode, so
tests would fail as the plugins would still announce them.  So instead
we just remove the schemes from these tests for now (at least for RSA,
removing signatures with SHA-1 completely isn't an option yet as that's
still the default with some clients).

Closes strongswan/strongswan#2523
2024-11-25 16:52:21 +01:00
Tobias Brunner
5217920967 github: Run apidoc test on Ubuntu 24.04 image
The Doxygen version on 22.04 doesn't understand some of the new directives.
2024-11-25 16:09:29 +01:00
Tobias Brunner
799b3076ab apidoc: Update Doxyfile.in
The only actual change is disabling timestamps (makes it easier to
compare).
2024-11-25 12:22:25 +01:00
Tobias Brunner
17bc5166d4 Fixed some typos, courtesy of codespell 2024-11-25 12:06:54 +01:00
Tobias Brunner
7e310e3425 testing: Make timing for TKM rekey scenarios a bit more stable
In particular for the first one randomization could trigger an additional
rekeying, which let the "Adding ESA ..." check fail.  But even without
randomization (could be seen in the second scenario that already uses
`rand_time=0`) 4 seconds can apparently be too low some time.
2024-11-25 11:44:04 +01:00
Andreas Steffen
af28aac85f Version bump to 6.0.0rc1 2024-11-25 11:11:17 +01:00
Andreas Steffen
2c18e87b25 testing: Added ML-KEM test cases 2024-11-23 16:53:02 +01:00
Andreas Steffen
def312d200 testing: Fixed typos 2024-11-23 15:06:37 +01:00
Tobias Brunner
36d9b88837 github: Install pkgconf instead of pkg-config on macOS
The package was apparently renamed/transitioned, but that doesn't really
work properly (causes a symlink issue when installing via pkg-config).
2024-11-22 15:19:04 +01:00
Tobias Brunner
5f31d6a9fc ml: Fix compilation with some compilers
Some (older) compilers complain that "variable-sized object may not be
initialized".
2024-11-22 14:43:57 +01:00
Tobias Brunner
a42e24b762 fuzz: Fix build after changing default plugins 2024-11-22 14:41:19 +01:00
Tobias Brunner
f462e4b9ee traffic-selector: Add workaround for possibly bogus warning with GCC 14
When compiling with -O3 with GCC 14, we get the following warning/error:

/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: '__builtin_memcpy' offset [0, 3] is out of the bounds [0, 0] [-Werror=array-bounds=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~

Which seems completely bogus as that array has a fixed size of 16 and
some weird workarounds remove the warning (e.g. adding an assignment
to `subset->netbits` before the `memcpy()`).  This is also the only
place GCC complains about and we use `memcpy()` all over the place
in this file to set those addresses.

Closes strongswan/strongswan#2509
2024-11-22 14:31:13 +01:00
Tobias Brunner
b2210f446e NEWS: Add some news for 6.0.0 2024-11-22 14:19:54 +01:00
Andreas Steffen
a5e80cf5e4 libcharon: Enable make_before_break option by default 2024-11-22 14:18:39 +01:00
Tobias Brunner
e69e7c86e7 Merge commit 'default-plugins'
Changes the default crypto plugins from the built-in ones to openssl.
2024-11-22 14:17:17 +01:00
Andreas Steffen
6735c3d7ca Define new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
558529afe2 testing: Migrated wolfssl scenarios 2024-11-22 14:14:53 +01:00
Andreas Steffen
2e4c062512 testing: Migrated tnc scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
11bb0a73b8 testing: Migrated tkm scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
89acb24bd7 testing: Migrated sql scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
b891da52b4 testing: Migrated route-based scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
8fc6340c05 testing: Migrated pfkey scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
93b6162d74 testing: Migrated p2pnat scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
bd93dfb09b testing: Migrated libipsec scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
0cf08b45dd testing: Migrated ha scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
dc69cf2f65 testing: Migrated gcrypt-ikev2 scenarios 2024-11-22 14:14:53 +01:00
Andreas Steffen
b9e5764b75 testing: Migrated botan scenarios 2024-11-22 14:14:53 +01:00
Andreas Steffen
17e0f20f57 testing: Migrated af-alg scenarios 2024-11-22 14:14:53 +01:00
Andreas Steffen
fdc9e69523 testing: Migrated ike scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
6ae40ac581 testing: Migrated ikev1-stroke to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
950d4fe7a0 testing: Migrated ikev2-stroke scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
2dbcb15338 testing: Migrated ipv6-stroke scenarios to new default plugins 2024-11-22 14:14:53 +01:00
Andreas Steffen
38bacea63b testing: Migrated ipv6 scenarios to new default plugins 2024-11-22 14:14:52 +01:00
Andreas Steffen
e7166c342b testing: Distributed openssl-ikev1 scenarios 2024-11-22 14:14:52 +01:00
Andreas Steffen
c9883d612b testing: Migrated ikev1-algs scenarios to new default plugins 2024-11-22 14:14:52 +01:00
Andreas Steffen
8060541f53 testing: Migrated ikev1 scenarios to new default plugins 2024-11-22 14:14:52 +01:00
Andreas Steffen
4df94b56c0 testing: Distributed openssl-ikev2 scenarios 2024-11-22 14:14:52 +01:00
Andreas Steffen
f766a7ed49 testing: Migrated ikev2-algs scenarios to new default plugins 2024-11-22 14:14:52 +01:00
Andreas Steffen
2099a52618 testing: Migrated ikev2 scenarios to new default plugins 2024-11-22 14:14:52 +01:00
Tobias Brunner
9de4efb1ae ml: Store decoded public/private key and matrix A on initiator
While this does require quite a bit of memory, on initiators there are
usually fewer concurrent SAs getting created so this should be less of
an issue than on a gateway that handles lots of SAs as responder.

The speed up is about 30% on the initiator during the decapsulation,
while the key generation does take a bit more time (about 3%).
2024-11-22 14:14:10 +01:00
Tobias Brunner
89f4b345e3 ml: Add software implementation of ML-KEM
This follows FIPS 203 relatively closely but takes some ideas from the
reference implementation.  In particular, how to avoid potential
side-channels via direct C division/modulo operations.  However, it just
uses Barrett reduction (no Montgomery reduction) and no negative
coefficients to avoid number format conversions and keep the
implementation clearer.
2024-11-22 14:14:08 +01:00
Tobias Brunner
930381228b memory: Add helper function to conditionally copy data in constant time 2024-11-22 14:09:53 +01:00
Andreas Steffen
3b7c49bc31 mgf1: Support of RSA PSS with SHA3 hash 2024-11-22 14:05:36 +01:00
Andreas Steffen
1265d78cac ntru: Remove legacy NTRU key exchange method 2024-11-22 14:05:36 +01:00
Andreas Steffen
8e3a373e18 newhope: Remove legacy Newhope key exchange method 2024-11-22 14:05:36 +01:00
Andreas Steffen
4833f29b15 bliss: Remove legacy BLISS signatures 2024-11-22 14:05:36 +01:00
Gerardo Ravago
ec982171d9 openssl: Add ML-KEM support with AWS-LC
This registers support for the ML_KEM_{512,768,1024} key exchange
algorithms in the `openssl` plugin when built using AWS-LC as the
libcrypto. To do this, we introduce the `openssl_kem` source files
which implement the key exchange algorithm using the Key Encapsulation
Mechanism (KEM) API. Future KEM algorithms can be implemented
generically using this interface by substituting the appropriate NIDs.

It also supports both seeded (via DRBG) and unseeded modes depending
on the user's requirements for KATs or entropy sources.

It should be noted that this does not add support for KEM algorithms
within upstream OpenSSL and is API incompatible. Future work will need
to condition out the incompatibilities as-appropriate. However, the
high-level logic should be the same for all KEMs and KEM APIs.

References strongswan/strongswan#2228
Closes strongswan/strongswan#2490
2024-11-22 14:04:02 +01:00
Tobias Brunner
d14bb3881b botan: Add support for ML-KEM 2024-11-22 14:03:17 +01:00
Tobias Brunner
974f9c37df Use Botan 3.6.1 for tests
With 3.6.0 support for ML-KEM was added.
2024-11-22 14:03:17 +01:00
Tobias Brunner
ebdaab6861 botan: Add support for AES in ECB mode to support DRBG_CTR_AES
This DRBG is used to test ML-KEM.
2024-11-22 14:03:17 +01:00
Tobias Brunner
0a3889086d botan: Fix include issue that prevented parsing public keys
Botan stopped including build.h in ffi.h with 3.4.0, so we have to
add this here explicitly to check for the enabled key types.
2024-11-22 14:03:17 +01:00
Tobias Brunner
1bb6f1dd73 wolfssl: Add support for ML-KEM 2024-11-22 14:03:17 +01:00
Tobias Brunner
307dea6b5f Use wolfSSL 5.7.4 for tests
This adds support for ML-KEM etc.
2024-11-22 14:03:17 +01:00
Tobias Brunner
cc53a04c7a test-vectors: Add ML-KEM test vectors
The vectors are generated using the `kat_kem` utility of the liboqs
project and then converted using the `nist_kem_kat` script.
2024-11-22 14:03:16 +01:00
Andreas Steffen
ee19c3e7dd scripts: Add script formatting NIST KEM KAT records into ke_test vectors 2024-11-22 14:03:16 +01:00
Tobias Brunner
f58fdcddad dh-speed: Use method call order compatible with KEMs
Also prints the speed of the derivation (or decapsulation) for the
initiator.
2024-11-22 14:03:16 +01:00
Tobias Brunner
09636199e6 key-exchange: Document how the interface is used with KEMs 2024-11-21 14:26:35 +01:00
Andreas Steffen
40676786aa key-exchange: Joint ke_test_vector format for DH and KEM
Both Diffie-Hellman (DH) and Key Encapsulation Mechanism (KEM) based
key exchange methods use a common ke_test_vector format. The
set_seed() function is used to provide deterministic private key
material for the crypto tests.
2024-11-21 14:26:35 +01:00
Tobias Brunner
47de9ef9a1 key-exchange: Add identifiers for ML-KEM algorithms 2024-11-21 14:26:35 +01:00
Tobias Brunner
8ea6997482 swanctl: Document soft lifetime defaults if hard lifetimes are configured 2024-10-30 12:07:04 +01:00
Tobias Brunner
d4a0dd9f93 mem-pool: Fix issue with make-before-break reauth and multiple IKE_SAs
If uniqueness checks are disabled and multiple IKE_SAs with the same
identities are created, an offline lease could have gotten reassigned
during a make-before-break reauthentication if such an SA was closed
earlier.  Checking for an online lease for the same client (IP/port)
first ensures that the correct IP is reassigned during the
reauthentication.

References strongswan/strongswan#2472
2024-10-25 14:52:46 +02:00
Tobias Brunner
f09b8203d3 file-logger: Take options as a struct and combine ms/us suffix options
References strongswan/strongswan#2475
2024-10-25 14:49:11 +02:00
Tobias Brunner
768fec23bc file-logger: Add support to log timestamp in microseconds
Closes strongswan/strongswan#2475
2024-10-25 14:48:17 +02:00
Tobias Brunner
a2fba6db4a file-logger: Add option to log messages as JSON objects
Closes strongswan/strongswan#2222
2024-10-25 14:45:12 +02:00
Tobias Brunner
c87aae300a socket-default: Always open IPv4 sockets before IPv6 sockets
Since we now open sockets for each address family independently (via
IPV6_V6ONLY) and without SO_REUSEADDR, it could happen with the previous
order on Linux that opening the port that was allocated as ephemeral
port for IPv6 was already used by a different process for IPv4.

Most IPv6 sockets on ephemeral ports will not have IPV6_V6ONLY set, so
the same port is also reserved for IPv4.  Therefore, it's save to assume
that any ephemeral port we first get for IPv4 is free for IPv6.

References strongswan/strongswan#2494
2024-10-25 14:40:35 +02:00
Tobias Brunner
3d0f6958a9 openssl: Add support for new API to squeeze data from XOFs
This new API doesn't require a temporary buffer and generating a lot
of already consumed output.
2024-10-25 14:28:40 +02:00
Tobias Brunner
bee06c9ec5 leak-detective: Whitelist OpenSSL 3.2 function 2024-10-25 14:28:35 +02:00
Andreas Steffen
0be6fd7735 certificate_printer: Fix spacing for additional CRL/OCSP URIs
Multiple occurences of CRL and OCSP URIs where not indented correctly.
2024-10-18 15:45:07 +02:00
Tobias Brunner
5019e3ece0 nm: Update build files and switch from intltool to gettext
gnome-common has been deprecated, so has intltool.  This follows GNOME's
recommended migration paths.
2024-10-16 08:16:43 +02:00
Tobias Brunner
faf40b8d74 Revert "conf: Add support for escaping dots in section/option names"
This reverts commit 84a3077e780e7b25bf536da42a583bdc18448362.

Support for dots in names of settings was removed quite a while ago and
now the \. sequence caused `SyntaxWarning: invalid escape sequence`.
2024-10-15 12:59:41 +02:00
Tobias Brunner
60336ceecb wolfssl: Don't undef PARSE_ERROR as headers included later might refer to it 2024-10-15 11:14:35 +02:00
Tobias Brunner
8e020bc9e3 vici-config: Same order for default ESP proposals if unset or set to "default"
The order was different when not setting `esp_proposals` or explicitly
configuring `default`.

Fixes: 33412158f58c ("ike: Send AEAD ESP default proposal first")
2024-10-02 10:33:05 +02:00
Tobias Brunner
089977b69d generator: Make debug log for payload substructure rules more clear
Similar to the previous commit.  Instead of

  generating rule 10 (1258)

followed by (or not if the list is empty)

  generating payload of type PROPOSAL_SUBSTRUCTURE

we now get

  generating rule 10 LIST of PROPOSAL_SUBSTRUCTURE

in the debug log.
2024-10-02 10:08:51 +02:00
Tobias Brunner
2ec6d50a3c parser: Make debug log for payload substructure rules more clear
Instead of this

  parsing rule 10 (1258)

we now see this

  parsing rule 10 LIST of PROPOSAL_SUBSTRUCTURE

in the debug log. Particularly useful if the list is empty as there won't
be a message like this following it:

  x bytes left, parsing recursively PROPOSAL_SUBSTRUCTURE
2024-10-02 10:07:36 +02:00
Tobias Brunner
be0af46d89 Merge branch 'tun-device-ipv6'
Adds support for IPv6 addresses on TUN devices, in particular, to support
virtual IPv6 addresses on FreeBSD/macOS.

Closes strongswan/strongswan#2465
2024-09-25 16:12:49 +02:00
Tobias Brunner
bf165afb78 kernel-pfroute: Route via interface if we don't have a next hop
Compared to RTA_IFP, the format is different when passing an interface
as RTA_GATEWAY, it requires the interface's address and not its name.
2024-09-25 16:12:34 +02:00
Tobias Brunner
fccc76449d tun-device: Fix handling of IPv6 addresses
struct ifreq can't be used for IPv6 as the ifr_addr member is not large
enough.  Actually, configuring an IPv6 address via an AF_INET socket won't
work anyway.  And unfortunately, it's not standardized how IPv6 addresses
are installed, so we have to do this quite differently on Linux and on BSD.
However, we already use SIOCAIFADDR for IPv4 on newer FreeBSD systems,
which wasn't the case when this patch was originally created in 2014.
2024-09-25 15:45:32 +02:00
Tobias Brunner
74208e2cc3 Merge branch 'tkm-multi-ke'
Adds support for multiple key exchanges to charon-tkm.
2024-09-19 15:20:31 +02:00
Tobias Brunner
2b1885b892 testing: Add TKM scenarios with multiple key exchanges 2024-09-19 14:39:13 +02:00
Tobias Brunner
5a8f0767b8 charon-tkm: Add tests with multiple key exchanges 2024-09-19 14:39:13 +02:00
Stefan Berghofer
7975a0cfa4 charon-tkm: Adapt to interface changes to support multiple key exchanges
Also includes ESA flags.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2024-09-19 14:39:13 +02:00
Tobias Brunner
301abbeaff Merge branch 'vici-reload-tasks'
Consider queued child-creating tasks when reloading configs that have
`start` as start action.  Besides some possible corner cases it fixes
handling IKE_SAs that are current getting established and have no
established CHILD_SAs yet.

Closes strongswan/strongswan#2418
2024-09-19 10:11:49 +02:00
Tobias Brunner
a4a3dcf6c2 vici-config: Consider queued tasks when terminating IKE/CHILD_SAs
This is particularly important for IKE_SAs that are not yet established,
which would get terminated as they have no established CHILD_SAs yet.

Fixes: 72f9a21b22e9 ("Merge branch 'vici-reload-actions'")
2024-09-18 11:53:17 +02:00
Tobias Brunner
961763b84d quick-mode: Allow "aborting" task if it's currently active
Basically the same as the previous commit.
2024-09-18 11:53:17 +02:00
Tobias Brunner
e81cf3bd36 child-create: Allow "aborting" task if it's currently active
We can't actually abort an active exchange, but we can delete the SA
immediately after its creation.
2024-09-18 11:53:17 +02:00
Tobias Brunner
cf3c90dba6 quick-mode: Add getter for child config 2024-09-18 11:53:17 +02:00
Tobias Brunner
04c9316db5 child-create: Add getter for child config 2024-09-18 11:53:17 +02:00
Tobias Brunner
9d4c7bebfc checksum: Avoid compiler warning/error when building monolithic
References strongswan/strongswan#2446
2024-09-18 11:49:35 +02:00
Tobias Brunner
decccd4f63 github: Update AWS-LC to 1.35.0 for tests 2024-09-18 08:49:52 +02:00
Thomas Egerer
cf7fb47788 array: Don't use realloc() with zero size in array_compress()
The behavior of realloc(3) with zero size was apparently implementation
defined.  While glibc documents the behavior as equivalent to free(3),
that might not apply to other C libraries.  With C17, this behavior has
been deprecated, and with C23, the behavior is now undefined.  It's also
why valgrind warns about this use.

Hence, when array_compress() would call realloc() with a zero size, we
now call free() explicitly and set the pointer to NULL.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-09-12 08:53:26 +02:00
Andreas Steffen
957aae8f64 cert-enroll: Fixed typo
This typo prevented the cert-enroll script from successfully
signalling a detected change of the sub CA certificate.
2024-09-07 17:17:07 +02:00
Tobias Brunner
55a660d9f7 github: Use more verbose output for apt-get calls
With -qq we don't see any detailed error messages.
2024-09-05 10:59:20 +02:00
Tobias Brunner
6928709886 ike-cfg: Only consider port information if the IP matches
Otherwise, all configs would be considered to even some degree as the
ports usually match.

Closes strongswan/strongswan#2441

Fixes: 9228a5109b8d ("ike-cfg: Consider port information in IKE config match")
2024-09-05 10:22:25 +02:00
Tobias Brunner
12d2b6e2b4 key-exchange: Pass prefix array directly, not a pointer to it 2024-08-08 11:19:16 +02:00
Tobias Brunner
8e2fde6230 child-create: Remove redundant variable assignment 2024-08-08 11:18:24 +02:00
Tobias Brunner
3a850ae191 Merge branch 'multi-ke'
This adds support for multiple key exchanges (no KEMs yet as none are
standardized so far).  Work on this started over five years ago and went
through multiple iterations (first our own protocol, then standardized
extensions in different variations).

IKE_INTERMEDIATE exchanges, defined RFC 9242, are used to transport
multiple KE payloads between the IKE_SA_INIT and IKE_AUTH exchanges.
To rekey IKE and CHILD_SAs with multiple key exchanges, IKE_FOLLOWUP_KE
exchanges are used, as defined in RFC 9370.

In proposals, additional key exchange methods are configured via `keX_`
prefix, where X is a number between 1 and 7.  For example, `ke1_ecp256`
adds ECP_256 as additional KE method.  As with regular key exchanges,
peers have to agree on a method for each round unless no algorithms are
defined by both or `keX_none` is configured to make that round explicitly
optional.

Also changed is how rekey collisions are handled, which makes CHILD_SAs
properly trackable via child_rekey() hook.
2024-08-07 16:20:42 +02:00
Tobias Brunner
f3c7e5227c testing: Add ikev2/rw-cert-multi-ke scenario 2024-08-07 16:20:19 +02:00
Tobias Brunner
ddb9b274c2 unit-tests: Ensure listeners can track SAs via ike/child_updown/rekey()
Previously, it could happen that child_rekey() was triggered twice for
the same "old" SA.  For listeners that would mean they'd loose track as
they'd be tracking a new SA that wasn't relevant anymore and for which
no updown event would ever get triggered (it was the redundant SA in a
collision).  This new assert ensures that events are triggered in a
predictable way and listeners can track SAs properly.
2024-08-07 16:20:19 +02:00
Tobias Brunner
d2b2e1b3fa ikev2: Make CHILD_SAs properly trackable during rekey collisions
As the winner of a rekey collision, we previously always triggered the
child_rekey() event once when creating the redundant SA on behalf of the
peer in the passive child-rekey task and then a second time when
creating the winning SA in the active task.  However, both calls passed
the replaced CHILD_SA as "old". This made tracking CHILD_SAs impossible
because there was no transition from the redundant, "new" SA of the
first event to the "new", winning SA of the second.  Of course, when the
second event was triggered, the redundant SA might not have existed
anymore because the peer is expected to delete it, which could happen
before the CREATE_CHILD_SA response arrives at the initiator.

This refactoring ensures that the child_rekey() event is triggered in
a way that makes the CHILD_SAs trackable in all reasonable (and even
some unreasonable) scenarios.  The event is generally only triggered
once after installing the outbound SA for the new/winning CHILD_SA.
This can be when processing the CREATE_CHILD_SA in the active child-rekey
task, or when processing the DELETE for the old SA in a passive
child-delete task.  There are some cases where the event is still
triggered twice, but it is now ensured that listeners can properly
transition to the winning SA.

Some corner cases are now also handled correctly, e.g. if a responder's
DELETE for the new CHILD_SA arrives before its CREATE_CHILD_SA response
that actually creates it on the initiator.  Also handled properly are
responders of rekeyings that incorrectly send a DELETE for the old
CHILD_SA (previously this caused both, the new and the old SA, to get
deleted).
2024-08-07 16:20:19 +02:00
Tobias Brunner
7ad610a140 ike-init: Indicate support for IKE_INTERMEDIATE 2024-08-07 16:20:19 +02:00
Tobias Brunner
012d99ecf4 proposal: Prevent selection of duplicate key exchange methods
All additional (and the initial) key exchanges must use a different method.
2024-08-07 16:20:19 +02:00
Tobias Brunner
1d5e921911 proposal: Add helper to check if additional key exchanges are contained 2024-08-07 16:20:19 +02:00
Tobias Brunner
882ff93bfd proposal: Accept NONE for additional key exchanges also for IKE proposals 2024-08-07 16:20:19 +02:00
Tobias Brunner
33e421320a unit-tests: Add tests for CHILD_SA rekeying with multiple key exchanges 2024-08-07 16:20:19 +02:00
Tobias Brunner
37eeafa37f unit-tests: Add tests for CHILD_SA creation with multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
329a7b331d unit-tests: Add tests for IKE_SA rekeying with multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
37c56affa1 unit-tests: Support multiple proposals in exchange tests 2024-08-07 16:20:18 +02:00
Andreas Steffen
d4fb07911f vici: Increase maximum proposal length 2024-08-07 16:20:18 +02:00
Andreas Steffen
355f917532 vici: List additional key exchanges
Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2024-08-07 16:20:18 +02:00
Tobias Brunner
c5a6938b9e proposal: Add prefix for additional key exchanges when logging proposals 2024-08-07 16:20:18 +02:00
Tobias Brunner
e05d86b27a key-exchange: Add dynamic parser for additional key exchange methods 2024-08-07 16:20:18 +02:00
Tobias Brunner
95275d2fe5 child-rekey: Support CHILD_SA rekeying with multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
c200bd1668 unit-tests: Fix CHILD_SA rekey tests after INVALID_KE_PAYLOAD handling changed
The responder doesn't create a CHILD_SA and allocate an SPI anymore
when responding with an INVALID_KE_PAYLOAD notify.
2024-08-07 16:20:18 +02:00
Tobias Brunner
d7760416d6 child-create: Add support for multiple key exchanges
It also changes that payloads are built before installing the CHILD_SA
on the responder, that is, the KE payload is generated before keys are
derived, so that key_exchange_t::get_public_key() is called before
get_shared_secret(), or its internal equivalent, which could be relevant
for KE implementations that want to ensure that the key can't be
accessed again after the key derivation.
2024-08-07 16:20:18 +02:00
Tobias Brunner
ca3e6d2d14 ike-rekey: Support IKE_SA rekeying with multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
0d49ddec2e ike-init: Add support for multiple key exchanges
Initially, this is handled with a key derivation for each
IKE_INTERMEDIATE exchange.  When rekeying, the keys are derived only
once all IKE_FOLLOWUP_KE exchanges are done.
2024-08-07 16:20:18 +02:00
Tobias Brunner
eff0c43a17 bus: Support multiple key exchanges in ike/child_keys() events 2024-08-07 16:20:18 +02:00
Tobias Brunner
c14e4ab2a8 keymat_v2: Support key derivation with multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
c36eaf42da key-exchange: Add helper to concatenate shared secrets of several key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
ec0ec55070 keymat_v2: Proper cleanup if derive_ike_keys() is called multiple times 2024-08-07 16:20:18 +02:00
Tobias Brunner
f6b2e6a21f ike-auth: Calculate and collect IntAuth for IKE_INTERMEDIATE exchanges
The message ID of the first IKE_AUTH exchange is a safe-guard against
potential truncation attacks if IKE_INTERMEDIATE exchanges are not used
for multiple key exchanges but some other future use where the number of
exchanges might not depend on the selected proposal.
2024-08-07 16:20:18 +02:00
Tobias Brunner
1212780b32 pubkey-authenticator: Handle IntAuth data 2024-08-07 16:20:18 +02:00
Tobias Brunner
c4dac17d8c psk-authenticator: Handle IntAuth data 2024-08-07 16:20:18 +02:00
Tobias Brunner
5c69262ce6 eap-authenticator: Handle IntAuth data 2024-08-07 16:20:18 +02:00
Tobias Brunner
e5828d26ea keymat_v2: Include optional IntAuth in signed octets 2024-08-07 16:20:18 +02:00
Tobias Brunner
91f09b8d25 authenticator: Add optional method to set IntAuth data 2024-08-07 16:20:18 +02:00
Tobias Brunner
515b9303de message: Store original encrypted payload when generating fragments
If we don't do this, get_plain() will fail after generating the message
fragmented unless it was generated non-fragmented previously.
2024-08-07 16:20:18 +02:00
Tobias Brunner
b9c69f9080 message: Add method to generate data to authenticate IKE_INTERMEDIATE exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
5c439bb8a3 generator: Make pointer to length field optional
Only useful if we generate an IKE header.
2024-08-07 16:20:18 +02:00
Tobias Brunner
a24993213e keymat_v2: Add method to calculate IntAuth for IKE_INTERMEDIATE exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
b8358936aa message: Add rules for IKE_FOLLOWUP_KE exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
414db6cab1 ike-header: Add IKE_FOLLOWUP_KE exchange type 2024-08-07 16:20:18 +02:00
Tobias Brunner
041358976b notify-payload: Add notify types for multiple key exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
aedf73f7cf ikev2: Reject IKE_INTERMEDIATE requests after IKE_AUTH
We currently only support these exchanges for additional key exchanges,
so once we have the final keys derived and the ike-init task is removed,
we don't expect any more of them.
2024-08-07 16:20:18 +02:00
Tobias Brunner
25f2cdfc56 message: Add rules for IKE_INTERMEDIATE exchanges 2024-08-07 16:20:18 +02:00
Tobias Brunner
a45d454e94 ike-header: Add IKE_INTERMEDIATE exchange type 2024-08-07 16:20:18 +02:00
Tobias Brunner
cc9ab450d6 notify-payload: Add notify type for IKE_INTERMEDIATE exchange 2024-08-07 16:20:18 +02:00
Tobias Brunner
3e0495745c proposal-substructure: Encode additional key exchange methods 2024-08-07 16:20:18 +02:00
Tobias Brunner
9cc5f4a511 proposal: Make all key exchange transforms optional in ESP/AH proposals 2024-08-07 16:20:18 +02:00
Tobias Brunner
fb6b8c833b proposal: Skip all KE transforms if PROPOSAL_SKIP_KE given 2024-08-07 16:20:18 +02:00
Tobias Brunner
2e059e0c27 transform: Add helper to check if transform type negotiates key exchange 2024-08-07 16:20:18 +02:00
Tobias Brunner
22550bd262 transform: Add additional key exchange transform types 2024-08-07 16:20:18 +02:00
Tobias Brunner
a7f617ab33 kernel-pfkey: Fix list of extension type names on FreeBSD
The list was extended earlier this year.
2024-08-07 15:09:45 +02:00
Tobias Brunner
abdc7878a4 Merge branch 'sa-dir'
Configures the direction of IPsec SAs in the Linux kernel if
possible (6.10+).
2024-08-07 15:00:56 +02:00
Tobias Brunner
22eded1da4 kernel-netlink: Set replay window 0 if kernel supports SA direction attribute
The kernel now allows a 0 replay window with ESN for SAs that are
explicitly tagged as outbound SAs.  But not just that, it actually
rejects outbound SAs with replay windows > 0.  So we add a version check
to control the replay window size.  Note that adding the attribute
unconditionally would be fine even for older kernels, but if somebody
backports the direction patches, the installation of outbound SAs might
fail if the replay window is not adjusted accordingly.
2024-08-07 14:41:28 +02:00
Tobias Brunner
661f6bd0ad kernel-netlink: Add SA direction attribute 2024-08-07 14:41:28 +02:00
Tobias Brunner
2601fabbb4 kernel-netlink: Only disable DF-flag copying on outbound SAs
This will cause errors on inbound SAs if the SA direction attribute is
used.
2024-08-07 14:41:28 +02:00
Tobias Brunner
dc8fa1b3e8 kernel-netlink: Add missing names for XFRM message types and attributes 2024-08-07 14:41:28 +02:00
Tobias Brunner
b05628dd2d include: Update XFRM header for SA direction attribute 2024-08-07 14:41:28 +02:00
Thomas Egerer
84bd011752 ike-sa: Add address family specific configuration of fragment size
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-08-07 14:19:41 +02:00
Tobias Brunner
9b9cf2001f android: Fix import of an already existing VPN profile 2024-08-07 08:58:12 +02:00
Tobias Brunner
740cbb2c0a Merge branch 'android-14'
Updates target SDK to Android 14 (34) and fixes compatibility issues.
2024-08-06 18:02:18 +02:00
Tobias Brunner
fe1c9dedb7 android: New release after updating target SDK and fixing some compatibility issues 2024-08-06 18:01:54 +02:00
Tobias Brunner
6064209872 android: Increase targetSdkVersion to 34 (Android 14) 2024-08-06 18:01:54 +02:00
Tobias Brunner
880e273985 android: Avoid using deprecated ViewCompat methods 2024-08-06 18:01:54 +02:00
Tobias Brunner
01c81ca15f android: Replace deprecated Observer/Observable with PropertyChangeListener etc.
Kinda misusing the interface as there is no specific property, but
otherwise seems like a 1:1 replacement.
2024-08-06 18:01:54 +02:00
Tobias Brunner
51f746161d android: Add workaround for a bug preventing background service starts from TileService
When targeting Android 14, we get a "Background activity launch blocked!"
exception when trying to start the connection in the background (closing
the drawer works).  Which is apparently a bug:

  https://issuetracker.google.com/issues/305035828

The workaround here is kinda ugly.  In particular, because it's not
possible anymore since a few versions to open a dialog that allows users
to directly grant the required permission to the app.  We can only open
the generic settings dialog where users have to search for the app and
grant the permission themselves (we could add a dialog with an explanation
similar to the one for the power whitelist if necessary).  Hopefully this
gets fixed at some point (the current beta of Android 15 still has the
same bug, though).
2024-08-06 18:01:54 +02:00
Tobias Brunner
3286f75ffe android: Use PendingIntent-version of startActivityAndCollapse()
The other version has been deprecated and throws an exception when
targeting Android 14+.
2024-08-06 18:01:54 +02:00
Tobias Brunner
38160c5cb7 android: Explicitly mark receiver as not exported during registration 2024-08-06 18:01:54 +02:00
Tobias Brunner
9c4ceced1c android: Declare foreground service type for VpnService instance
Required for Android 14 (34).  Since no other type fits we use specialUse,
which also requires a new permission and a description for why we use it.
2024-08-06 18:01:54 +02:00
Tobias Brunner
4f2e65f3d0 android: Fix label for name field in managed profiles
The field is not actually optional.
2024-08-06 18:01:54 +02:00
Tobias Brunner
81041b55d2 android: Fix crash when opening list of apps for new profiles
Fixes: 150dc5ab6401 ("android: Make selected apps read-only")
2024-08-06 18:01:54 +02:00
Tobias Brunner
8a14c20ec7 android: Update dependencies 2024-08-06 18:01:54 +02:00
Tobias Brunner
7b78e35ff6 android: Update Gradle plugin 2024-08-06 18:01:54 +02:00
Matteo Carnelos
bed04baf21 init: Add Wants= dependencies to systemd units
If no other units have dependencies on network-online.target or
syslog.target they might not get initialized resulting in a possibly
non-ideal startup order.

Closes strongswan/strongswan#2279
2024-08-06 15:16:30 +02:00
Tobias Brunner
59a4c9c416 ike-auth: Default IDi/IDr to subject DN instead of IP if a certificate is available
This avoids sending a likely unconfirmed identity if no identity is
configured and received (in case of IDr).

Closes strongswan/strongswan#2353
2024-07-30 14:27:15 +02:00
Tobias Brunner
e9a7c9822d ike-sa: Assign function pointers for mediation extension separately
Using preprocessor directives in calls of function-like macros is
not recommended as it might lead to undefined behavior.
2024-07-30 10:29:36 +02:00
Tobias Brunner
72f9a21b22 Merge branch 'vici-reload-actions'
This improves the behavior when reloading or unloading connections that
have `start` included in their `start_actiton`.

Closes strongswan/strongswan#2324
2024-07-30 10:27:50 +02:00
Tobias Brunner
56b6eeb385 testing: Add ikev2/start-action-start scenario
This tests the behavior for configs with start_action=start during
reloads of the config (updates/removal).
2024-07-26 16:56:32 +02:00
Tobias Brunner
7bfaa9acb6 vici: Improve handling of start action when reloading configs
The previous code had some issues because it handled each child config
separately.  Not only was this quite inefficient because all IKE_SAs had
to be enumerated for every config, it also caused problems with the check
for other CHILD_SAs in order to decide whether to delete the IKE_SA or
not.  Because CHILD_SAs are deleted with an INFORMATIONAL exchange, they
are not immediately gone.  This caused a race condition and with more
than one child config and SAs the IKE_SA could be kept because it
could appear as if other, unrelated CHILD_SAs were still there.

Another race condition, which is fixed by the previous commit, occurred
when only changing child configs.  Then it could happen that the code
deemed the IKE_SA empty and a delete for it was queued.  If that happened
while the IKE_SA was deleting one of the CHILD_SAs (or was busy with some
other exchange), the IKE_SA was not switched to IKE_DELETING.  So it
looked usable and create-child tasks for the updated configs might have
gotten queued.  Unfortunately, once the ike-delete task is eventually
executed, these tasks would be gone and the replacement CHILD_SAs never
created.  This commit additionally avoids actually deleting the IKE_SA
even if all child configs change or get removed if any new CHILD_SAs are
to be initiated.
2024-07-26 16:40:57 +02:00
Tobias Brunner
da00a04f60 ike-sa-manager: Avoid initiating CHILD_SAs on IKE_SAs with queued DELETE
The IKE_SA might be busy with a different task while a request to
terminate it is getting queued, we don't want to use such an IKE_SA to
initiate new CHILD_SAs as these tasks will get lost once the IKE_SA is
terminated.
2024-07-26 11:34:44 +02:00
Tobias Brunner
07ce6b44c5 testing: Enable IPv6 guest-to-guest communication
Not sure what changed, but without this setting, ND packets would not
get through to other hosts connected to the same bridge.
2024-07-26 11:34:44 +02:00
Tobias Brunner
0602ed1043 unit-tests: Fix compiler warning with empty message assertion
The empty array of rules for `assert_message_empty()` and the resulting
size 0 triggers warnings like these:

  allocation of insufficient size '0' for type 'listener_message_rule_t' with size '12'

Using calloc() with `nmemb` set to 0 triggers the same warning.
2024-07-15 16:55:29 +02:00
Tobias Brunner
6eec5cc07d daemon: Use correct argument order for calloc() to fix compiler warning
The number of elements is the first argument, their size the second.
The previous code triggered the following warning:

  'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument
2024-07-12 14:00:15 +02:00
Tobias Brunner
574bfad1c0 backtrace: Fix compiler warning on Windows
This change avoids a "variable 'got' might be clobbered by 'longjmp' or
'vfork'" warning with -Wextra.
2024-07-12 11:48:03 +02:00
Tobias Brunner
d759bd9efa Use wolfSSL 5.7.2 for tests 2024-07-11 15:57:12 +02:00
Tobias Brunner
c4bce2b79b testing: Enable mgf1 plugin for scenarios where FreeRADIUS uses PSS signatures
Looks like a cipher suite without DHE was selected previously.

Could be a side-effect of dc1085734f34 ("testing: Remove unnecessary
FreeRADIUS dh_file option as recommended in the log").
2024-06-26 14:56:22 +02:00
Tobias Brunner
a9ced3ccb4 testing: Fix IP pool scenarios after changing base address
Fixes: 2b11764b705d ("mem-pool: Adjust the base address if it's the network ID")
2024-06-26 14:56:22 +02:00
Maxim Uvarov
dd256e730d testing: Enable error code checks for load-testconfig
Errors in load-testconfig are hidden due to not checking scp
return code and mute all errors. Add -e to trap script on
any errors in this script.

References strongswan/strongswan#2310

Signed-off-by: Maxim Uvarov <muvarov@gmail.com>
2024-06-26 14:55:52 +02:00
Maxim Uvarov
d8c6fa3b9a testing: Enable sftp subsystem in default sshd_config
OpenSSH defaults have changed and scp stopped to work with newer versions.
There are 2 options to fix it, either use -O (legacy scp protocol)
with scp, or enable the sftp subsystem in the SSH server config.
This fix uses the second variant.

Closes strongswan/strongswan#2310

Signed-off-by: Maxim Uvarov <muvarov@gmail.com>
2024-06-26 14:54:38 +02:00
Tobias Brunner
710973f0b0 cirrus: Use FreeBSD 13.3 and 14.1 2024-06-18 16:25:08 +02:00
Tobias Brunner
d02aea9c2c quick-mode: Get a reference when adopting the reqid of a rekeyed CHILD_SA 2024-06-17 14:58:47 +02:00
Tobias Brunner
2b11764b70 mem-pool: Adjust the base address if it's the network ID
Instead of just adding the offset internally, this way the reported
base address is always the first assignable address (e.g. for
192.168.0.0/24 vs. 192.168.0.1/24).

Closes strongswan/strongswan#2264
2024-06-17 14:55:43 +02:00
Tobias Brunner
1cbcf198ab testing: Make RADIUS server enforce client identity in certificate's CN 2024-06-17 14:47:11 +02:00
Tobias Brunner
dc1085734f testing: Remove unnecessary FreeRADIUS dh_file option as recommended in the log 2024-06-17 14:47:11 +02:00
Tobias Brunner
49cb7b016f charon-nm: Use a different routing table than the regular IKE daemon
If the regular daemon is running, it creates an unconditional routing
rule for the routing table.  The rule that charon-nm tries to create,
which excludes marked IKE/ESP traffic to avoid a routing loop, then
can't be installed and we'd end up with said loop.

Closes strongswan/strongswan#2230
2024-06-17 14:45:52 +02:00
Tobias Brunner
59587783ff cirrus: Explicitly install tpm2-tss-sys package on Alpine
The libraries were previously shipped with the -dev package.
2024-05-27 14:08:08 +02:00
Tobias Brunner
fc6556fd18 github: Use AWS-LC 1.28.0 for tests 2024-05-27 10:42:37 +02:00
Tobias Brunner
8e88d56206 x509: Encode challenge passwords as PrintableString if possible
As recommended by RFC 2985, section 5.4.1:

  ChallengePassword attribute values generated in accordance with this
  version of this document SHOULD use the PrintableString encoding
  whenever possible.  If internationalization issues make this
  impossible, the UTF8String alternative SHOULD be used.

Even though the RFC continues with

  PKCS #9-attribute processing systems MUST be able to recognize and
  process all string types in DirectoryString values.

there might be older SCEP server implementations that don't accept
UTF8String-encoded passwords.  In particular because previous versions of
PKCS#9 defined this attribute's type as a CHOICE between PrintableString
and T61String.

References strongswan/strongswan#1831
2024-05-17 14:04:20 +02:00
Tobias Brunner
f8c6ff1fc1 streams: Add ability to listen on any VSOCK CID
Can be useful if the CID inside the VM is not known.

The \htmlonly\endhtmlonly hack is used to avoid compiler warnings due
to /* inside a block comment.
2024-05-17 14:00:12 +02:00
Thomas Egerer
3d7d527ad9 streams: Add support for AF_VSOCK sockets on Linux
These allow, for instance, a vici client on a host to communicate with
an IKE daemon running in a VM.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-05-17 14:00:12 +02:00
Thomas Egerer
9228a5109b ike-cfg: Consider port information in IKE config match
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-05-17 13:53:00 +02:00
Tobias Brunner
287ef047a9 github: Use tpm2-tss 3.2.3 for tests 2024-04-29 16:10:39 +02:00
Tobias Brunner
059249bae7 configure: Enable counters plugin also if vici is enabled but stroke is disabled 2024-04-18 08:59:18 +02:00
Tobias Brunner
f8e6fd30de gitignore: Don't ignore proposal_keywords.c
If somebody copies our .gitignore and tries to import the source code,
the proposal_keywords.c file will not be added as it's ignored by the
`*keywords.c` pattern we use to ignore gperf-generated source files.

Closes strongswan/strongswan#2014
2024-04-15 18:29:42 +02:00
Tobias Brunner
5f99a28381 mem-pool: Reject the creation of unintentionally empty pools
If a base address is configured, we don't expect the pool to be empty,
so reject the creation (e.g. with the broadcast address as base).

References strongswan/strongswan#2205
2024-04-15 09:50:41 +02:00
Tobias Brunner
afeac365fd swanctl: Document possibility of non-zero base addresses for in-memory pools
References strongswan/strongswan#2205
2024-04-15 09:50:34 +02:00
Tobias Brunner
907079bd13 Use AWS-LC 1.24.0 for tests 2024-04-12 14:59:32 +02:00
Tobias Brunner
3a20170324 github: Don't search for coverage results
We explicitly pass the final .info file prepared with lcov, so there is
no need to search for other files (that then won't work anyway).  The
search also finds the uncleaned .info file, which includes the test code.

The latter should have gotten ignored anyway, but the patterns are
apparently not correct anymore. So fixing that as well just to be sure.
2024-04-04 15:00:13 +02:00
Tobias Brunner
75c5c5667d github: Update coverage data upload to Codecov
Since the script and action have issues with the directory structure, we
upload the lcov results instead.
2024-04-04 09:25:12 +02:00
Tobias Brunner
9c208c4e46 Merge branch 'openwrt-fixes'
Closes strongswan/strongswan#2185
2024-04-03 11:28:24 +02:00
Philip Prindeville
e5bc3a50f6 wolfssl: Avoid conflict with RNG when built without EdDSA or FIPS enabled
There are definitions of RNG in <wolfssl/wolfcrypt/settings.h> and
<wolfssl/wolfcrypt/random.h> that play havoc with the literal RNG being
used in the expansions of PLUGIN_*(RNG, ...) when ##-concatenated to
build the enum value FEATURE_RNG.

The #undef in wolfssl_cmmon.h only had an effect if wolfSSL was built
with EdDSA or FIPS enabled, otherwise, the headers that define RNG were
not pulled in before it.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2024-04-03 08:48:46 +02:00
Noel Kuntze
1b19053919 uci: Upstream patch to adapt to option datatype abstraction
This is a patch from the OpenWrt package sources necessary to adapt to
changes from 2008 that abstracted the option datatype (added a list
type).

Signed-off-by: Noel Kuntze <noel.kuntze@thermi.consulting>
Reviewed-by: Philip Prindeville <philipp@redfish-solutions.com>
2024-04-03 08:41:42 +02:00
Tobias Brunner
b73a476c1f cirrus: Add build on Alpine Linux with musl C library 2024-04-02 14:21:56 +02:00
Tobias Brunner
56f4b2096a sha3: Fix Keccak when compiled with GCC 13.x
With GCC 13, the compiler apparently applies new aliasing optimizations
when compiled with -O2 and without -fno-strict-aliasing.  This caused
the application of the second padding bit, where the state was accessed
via uint8_t[], to be moved before the loop that absorbs the buffer into
the state, where the state is accessed via uint64_t[], resulting in
incorrect output.  By only accessing the state via uint64_t[] here the
compiler won't reorder the instructions.
2024-04-02 14:19:40 +02:00
Tobias Brunner
ac713746c9 unit-tests: Adhere to TESTS_NO_IPV6 in HTTP fetcher test suite 2024-04-02 14:18:49 +02:00
Tobias Brunner
9ac6c469a5 bliss: Fix build with built-in printf-specifiers
This won't work for monolithic builds because the plugin and the
executable are built before libstrongswan.
2024-04-02 14:18:43 +02:00
Tobias Brunner
84166508f8 Use wolfSSL 5.7.0 for tests 2024-03-22 11:43:39 +01:00
Tobias Brunner
540881627f farp: Fix build with musl C library
Same issue as described in the previous commit.

Fixes: 187c72d1afdc ("dhcp: Port the plugin to FreeBSD/macOS")
2024-03-22 11:41:13 +01:00
Tobias Brunner
f5b1ca4ef6 pf-handler: Fix build with musl C library
musl's headers define a lot of networking structs.  For some, the
definition in the Linux UAPI headers is then suppressed by e.g.
__UAPI_DEF_ETHHDR.

Since we included musl's net/ethernet.h, which includes netinet/if_ether.h
that defines `struct ethhdr` (and the above constant), **after** we
include linux/if_ether.h, there was a compilation error because the
struct was defined multiple times.

However, simply moving that include doesn't fix the problem because for
ARP-specific structs the Linux headers don't provide __UAPI_DEF* checks.
So instead of directly including the linux/ headers, we include those
provided by the C library.  For glibc these usually just include the
Linux headers, but for musl this allows them to define the struct
directly.  We also need to move if.h and add packet.h, which define
other structs (or include headers that do so) that we use.

Fixes: 187c72d1afdc ("dhcp: Port the plugin to FreeBSD/macOS")
2024-03-22 11:40:15 +01:00
Thomas Egerer
f3c8e02c69 ike-sa-manager: Unlock mutex if allocating SPI fails to avoid lock contention
Fixes: 5d91d8c46937 ("Check rng return value when generating SPIs in ike_sa_manager_t")
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-03-20 13:18:57 +01:00
Andreas Steffen
dea8493f3a Version bump to 5.9.14 2024-03-19 11:56:44 +01:00
Tobias Brunner
470ead96ea github: Use AWS-LC 1.23.0 for tests 2024-03-18 09:00:38 +01:00
Wataru Ashihara
c3f8642e72 save-keys: Fix Wireshark algorithm identifier for 3DES
Wireshark has shown the following error dialogue because the identifier
was incorrect [1]:

Error loading table 'ESP SAs': esp_sa:18: invalid value: TripleDes-CBC [RFC2451]

[1] 3757f42e5f/epan/dissectors/packet-ipsec.c (L203)

Closes strongswan/strongswan#2013
2024-03-18 08:54:41 +01:00
Tobias Brunner
9acd90575a ike-cfg: Change how OCSP certificate requests are enabled
The previous option caused such requests to be enabled if not explicitly
disabled, which only the vici plugin did, for all other backends requests
would have been sent.

References strongswan/strongswan#2016
2024-03-15 15:38:19 +01:00
Tobias Brunner
cfc7be004d peer-cfg: Renumber ocsp_policy_t values so the same default applies for all backends
Only the vici plugin previously set OCSP_SEND_REPLY explicitly, all other
backends would have defaulted to OCSP_SEND_BOTH.

References strongswan/strongswan#2016
2024-03-15 15:37:50 +01:00
Tobias Brunner
a2ace8a6bb kernel-pfroute: Log ignored interfaces when listing known interfaces 2024-03-15 13:47:23 +01:00
Tobias Brunner
e9df6f5c3d kernel-netlink: Log ignored interfaces when listing known interfaces 2024-03-15 13:45:08 +01:00
Tobias Brunner
dad4624756 NEWS: Add news for 5.9.14 2024-03-14 17:33:56 +01:00
Tobias Brunner
b2f957f5f1 pkcs11: Fix cleanup when verifying signature fails because scheme isn't supported
Fixes: 49769fff53f3 ("pkcs11: Support RSA-PSS signatures")
2024-03-14 13:58:02 +01:00
Tobias Brunner
c035e4ca93 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).
2024-03-14 13:51:06 +01:00
Andreas Steffen
91f209b878 Version bump to 5.9.14rc1 2024-03-13 20:24:54 +01:00
Tobias Brunner
500207e35c systime-fix: Fix declaration of validator constructor 2024-03-13 16:50:46 +01:00
Tobias Brunner
6628c523c2 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
2024-03-13 16:47:20 +01:00
Andreas Steffen
6f8275abab testing: Added RFC4806 tests 2024-03-13 15:11:00 +01:00
Jean-François Hren
15612b3a42 Add support for IKEv2 OCSP extensions (RFC 4806)
Closes strongswan/strongswan#2016

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2024-03-13 15:10:50 +01:00
Tobias Brunner
ddd926b698 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
2024-03-13 15:05:14 +01:00
Tobias Brunner
b29be6029e 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.
2024-03-12 09:14:44 +01:00
Tobias Brunner
ea6a6344d3 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.
2024-03-12 09:14:44 +01:00
Tobias Brunner
bb67838c53 configure: Load constraints plugin in pki
This allows --verify to check e.g. name constraints.
2024-03-08 11:16:48 +01:00
Gerardo Ravago
1301c762d4 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
2024-03-08 11:14:39 +01:00
Etay Bogner
fac42f7168 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
2024-03-07 15:08:00 +01:00
Gerardo Ravago
8237968c2c 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
2024-03-07 15:06:40 +01:00
Gerardo Ravago
44e241fccc 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] bdc35b6361
[2] https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2
2024-03-05 08:51:16 +01:00
Andreas Steffen
06afb5f109 cert-enroll: add init.d support to cert-install-sssd 2024-03-03 17:12:48 +01:00
Tobias Brunner
f994e0a428 utils: Define ignore_result() so it requires a semicolon
It previously also added its own empty statement.
2024-02-29 16:02:28 +01:00
Tobias Brunner
6dee8587f0 Remove obvious empty statements (i.e. stray semicolons) 2024-02-29 15:30:40 +01:00
Tobias Brunner
9d1f325a77 github: Update GitHub-provided actions for Node.js update 2024-02-29 09:06:59 +01:00
Tobias Brunner
a380dc4989 utils: Define DESTROY_*_IF() macros without terminating semicolon
This avoids double semicolons (i.e. empty statements) and is how
DESTROY_IF() is already defined.
2024-02-29 09:06:43 +01:00
Tobias Brunner
b21178b43c android: New release after adding fix for existing shortcuts/Intents 2024-02-26 11:14:14 +01:00
Tobias Brunner
45371da846 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")
2024-02-26 11:01:55 +01:00
Tobias Brunner
1f5aa8017f 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
2024-02-23 18:00:32 +01:00
Andreas Steffen
f566a85fcf Version bump to 5.9.14dr1 2024-02-22 15:51:24 +01:00
Tobias Brunner
b7fdc10a3c Use Botan 3.3.0 for tests 2024-02-22 13:49:46 +01:00
Tobias Brunner
4be75c5ab1 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.
2024-02-22 13:37:01 +01:00
Tobias Brunner
7db629e4bc android: New release after adding support for managed configurations 2024-02-21 12:24:53 +01:00
Tobias Brunner
51a5d96b36 android: Add translations for managed configuration strings
Not actually translating anything, but making the linter happy.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
8c6b3019a7 android: Update managed certificates if config changes 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
b0ba845e27 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
aa06d75491 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
9cb23f650a 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).
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
97cb35afe5 android: Add repository for managed user certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
99dfa8cb0e android: Add repository for managed trusted certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
a04798a796 android: Add base repository for installed managed certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
cd67c30fd1 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
fb302d967c android: Add installer for managed trusted certificates
This installs a configured CA or server certificate into the app's local
key store.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
e2f505350e android: Add database migration for managed certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
6882f17741 android: Add trusted and user certificates to ManagedVpnProfile 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
9cbc03e84f android: Add entities for CA/server and user certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
22bce57e4c android: Add utility that parses a PKCS#12 container and extracts a KeyPair 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
4ac9fc327e android: Add utility that converts a Base64 string to a X509Certificate 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
afcb56400e android: Add utility class that pairs a certificate with a private key 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
8a50651212 android: Add password for client certificate to managed config 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
9a917252e2 android: Provide global database helper instance 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
861ac0109a android: Extend database helper with table definition
This simplifies database migration.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
802047cae8 android: Move database helper into separate class
Reduce strong coupling between database helper and VPN profiles, to
prepare for the addition of other tables.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
42626c1dd8 android: Hide unmanaged profiles by default
Such profiles could exist if a user already had strongSwan installed.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
0af501ef26 android: Disable access to settings depending on managed configuration 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
fe13782e3c android: Hide menu items depending on managed configuration
Hide and disable menu items when disabled by the managed configuration.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
4bfeb3b000 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.
2024-02-21 12:24:53 +01:00
Tobias Brunner
8f04d15dfd 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
36f62585bb 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
8796e9bb31 android: Add ManagedConfigurationService and related classes
Add service that provides access to managed configurations.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
c2007d5b09 android: Add managed_configuration.xml
Add managed configuration and associated English strings.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
01ea7b92bd android: Make VpnType#fromIdentifier null-safe 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
a5167a69e0 android: Add data source to VpnProfile 2024-02-21 12:24:53 +01:00
Markus Pfeiffer
5f9f279a33 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
c9c65a94c9 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
d3f5c3a760 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
150dc5ab64 android: Make selected apps read-only
Also prevent users from changing selected apps in read-only VPN profiles.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
3391f7a465 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.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer
9618c83c03 android: Add read-only flag to VpnProfile 2024-02-21 12:24:52 +01:00
Markus Pfeiffer
8e3b921abe 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.
2024-02-21 12:24:52 +01:00
Markus Pfeiffer
d629e1d358 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.
2024-02-21 12:24:52 +01:00
Markus Pfeiffer
7c8773dea5 android: Add interface for VPN data source
Change VPN profile source to an interface. Preparation to allow managed
configurations as a second source.
2024-02-21 12:24:52 +01:00
Markus Pfeiffer
b687f0c22f android: Use try-with-resources for IO 2024-02-21 12:24:52 +01:00
Markus Pfeiffer
73af77709a android: Remove unnecessary @TargetApi
The minSdkVersion is 21, remove unnecessary @TargetApi annotations.
2024-02-21 12:24:52 +01:00
Markus Pfeiffer
a3e895b4d8 android: Remove unnecessary API checks
The minSdkVersion is 21, remove unnecessary checks and code that target
older API versions.
2024-02-21 12:24:52 +01:00
Markus Pfeiffer
5d192246e8 android: Remove AndroidX legacy support 2024-02-21 12:24:52 +01:00
Markus Pfeiffer
ff6b6b5b49 Add ._.DS_Store to .gitignore 2024-02-21 12:24:52 +01:00
Andreas Steffen
ad08ced8b2 pki: Added key and cert handles to --ocsp command 2024-02-21 12:22:33 +01:00
Andreas Steffen
49769fff53 pkcs11: Support RSA-PSS signatures 2024-02-21 11:22:33 +01:00
Andreas Steffen
f739657aac pkcs11: Updated pkcs11.h header file based on OpenSC 2024-02-21 11:22:33 +01:00
Gerardo Ravago
e56b597af1 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
2024-02-21 08:42:48 +01:00
Gerardo Ravago
7f1ba3cc68 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
2024-02-19 10:01:51 +01:00
Tobias Brunner
a7493ab57d pf-handler: Always free the object even if no socket has been opened yet 2024-02-19 09:49:08 +01:00
Dan James
187c72d1af 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>
2024-02-19 09:17:53 +01:00
Tobias Brunner
10a876d54c github: Use new property to pass token for sonarcloud
sonar.login is deprecated.
2024-02-16 14:50:16 +01:00
Tobias Brunner
b940ce25e9 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
2024-02-16 14:06:17 +01:00
Martin Willi
1a740bf3f3 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.
2024-02-16 14:04:17 +01:00
Martin Willi
dde40bcb9e 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.
2024-02-16 10:42:43 +01:00
Martin Willi
4aac88fadd 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().
2024-02-16 10:11:11 +01:00
Martin Willi
f634a3300c 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().
2024-02-16 10:11:11 +01:00
Martin Willi
cdf865e0b8 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.
2024-02-16 10:11:11 +01:00
Martin Willi
0cd46df377 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.
2024-02-16 10:11:11 +01:00
Gerardo Ravago
31f55ba6e9 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
2024-02-14 17:57:41 +01:00
Florian Bezannier
e6176bf19c auth-cfg: Improve log message for identity constraint mismatch error
Closes strongswan/strongswan#2088
2024-02-12 10:25:23 +01:00
Tobias Brunner
0d61efdf02 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.
2024-01-16 11:01:01 +01:00
Tobias Brunner
980491ebcd 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
1cab544c75 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
be832378db github: Also run tests on macOS 13
Uses a newer version of clang and doesn't seem to have the issue with
process_t.
2024-01-16 11:00:29 +01:00
Tobias Brunner
2b74b63691 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).
2024-01-16 11:00:29 +01:00
Tobias Brunner
798e25f313 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
fea02fb297 simaka-crypto: Fix constructor declaration
Prototype didn't match the implementation.
2024-01-16 11:00:29 +01:00
Tobias Brunner
cb139ce4b3 cirrus: Use FreeBSD 14.0
FreeBSD 12.4 has been removed.
2024-01-16 11:00:29 +01:00
Tobias Brunner
52d6189892 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
bf017a9d17 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
67f0990530 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.
2024-01-16 11:00:29 +01:00
Tobias Brunner
22fc539edd 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
2024-01-16 10:59:59 +01:00
Tobias Brunner
f3578d3de8 Merge branch 'linux-strongswan'
Closes strongswan/strongswan#2026
2023-12-14 11:30:08 +01:00
Tobias Brunner
fff2996a22 ipsec: Remove mention of NETKEY stack 2023-12-14 11:27:25 +01:00
Tobias Brunner
7550463d51 Replace some other mentions of "Linux strongSwan" 2023-12-14 11:27:19 +01:00
Jose Luis Duran
454069e094 ipsec: strongSwan is not exclusive to Linux kernels
The project is now called "the strongSwan project" rather than "Linux
strongSwan" to better reflect this.
2023-12-09 18:42:27 +00:00
Andreas Steffen
c8ef91c786 Version bump to 5.9.13 2023-12-01 07:26:22 +01:00
Andreas Steffen
04794e703d Version bump to 5.9.13rc1 2023-11-25 17:16:59 +01:00
Tobias Brunner
b4a9058b61 Merge branch 'ocsp-fixes'
Fixes a regression with handling OCSP error responses and adds a new
option to specify the length of nonces in OCSP requests.  Also adds some
other improvements for OCSP handling and fuzzers for OCSP
requests/responses.

Closes strongswan/strongswan#2011
2023-11-24 17:44:45 +01:00
Tobias Brunner
9c4846cdbe x509: Make sure the status in OCSP responses has the correct length 2023-11-24 17:41:18 +01:00
Tobias Brunner
ebf5afcefa fuzz: Add fuzzing targets for OCSP requests/responses 2023-11-24 17:41:18 +01:00
Tobias Brunner
f3af1704d9 x509: Make length of nonces in OCSP requests configurable
Some servers might not support a length of 32 and return a malformed
request error. Lowering the value to the previous default of 16 could
help in that case.
2023-11-24 17:41:18 +01:00
Tobias Brunner
945be4ece5 pki: Generate internal error OCSP response if no signer certificate is found
That can happen if a request is sent to the wrong OCSP server.
2023-11-24 17:41:18 +01:00
Tobias Brunner
05a1f5b9c5 certificate-printer: Add some output for empty OCSP responses 2023-11-24 17:41:18 +01:00
Tobias Brunner
6d345b3dde revocation: Reject OCSP error responses
Otherwise, there is lengthy code that tries to validate such responses,
even though they don't contain any signatures.
2023-11-24 17:41:18 +01:00
Tobias Brunner
b3e66aca5c x509: Add getter for status of OCSP responses 2023-11-24 17:41:18 +01:00
Tobias Brunner
e7a58f46f9 x509: Correctly parse responderId as ASN.1 CHOICE in OCSP response
The two OPTs that were used previously allowed to omit it completely (hence
the fallback to ID_ANY), but that's invalid, so it's better to fail
parsing.
2023-11-24 17:41:18 +01:00
Tobias Brunner
585c40095a x509: Correctly handle missing responder ID when parsing OCSP response errors
The has_issuer() and issued_by() methods relied on it to be defined, so
if the OCSP response wasn't successful (i.e. OCSP status indicates an
error and no OCSP response is parsed), a null-pointer dereference was
caused if the caller checked if the OCSP response was issued by a
specific certificate.

That's a side-effect of the referenced commit.  Previously, error codes
caused the OCSP response to not get parsed successfully, which technically
wasn't correct as it's well formed and successfully parsed, it's just
indicating an error state.

Fixes: 00ab8d62c089 ("x509: Support generation of OCSP responses")
2023-11-24 17:41:18 +01:00
Andreas Steffen
da45cf9f38 cert-enroll: Set the environment variables needed by cert-install-ssl 2023-11-23 19:05:22 +01:00
Andreas Steffen
11dbc8e7f2 Version bumpt to 5.9.12 2023-11-20 12:10:34 +01:00
Tobias Brunner
46aa264430 NEWS: Add info about CVE-2023-41913 2023-11-17 17:24:35 +01:00
Tobias Brunner
96d7937189 charon-tkm: Validate DH public key to fix potential buffer overflow
Seems this was forgotten in the referenced commit and actually could lead
to a buffer overflow.  Since charon-tkm is untrusted this isn't that
much of an issue but could at least be easily exploited for a DoS attack
as DH public values are set when handling IKE_SA_INIT requests.

Fixes: 0356089d0f94 ("diffie-hellman: Verify public DH values in backends")
Fixes: CVE-2023-41913
2023-11-17 17:24:34 +01:00
Tobias Brunner
74ae71d2b8 x509: Ensure extensions are encoded even if others are missing
As with the previous commit, this is probably never an issue in practice
as most certificates contain at least one SAN.
2023-11-15 17:08:46 +01:00
Tobias Brunner
ba08e01b86 x509: Also encode extendedKeyUsage in cert requests if there are no SANs or certificate type
Probably never was an issue in practice as most certificates contain at
least one SAN.
2023-11-15 17:01:02 +01:00
Tobias Brunner
14cc5b845e pki: Mention --index in description 2023-11-15 15:16:51 +01:00
Tobias Brunner
0dbb6867d8 NEWS: Add news for 5.9.12 2023-11-15 14:14:49 +01:00
Tobias Brunner
724e64cac4 Move ocsp_responder_t interface as it's not a certificate 2023-11-14 10:35:47 +01:00
Tobias Brunner
14bd0bc743 Fixed some typos, courtesy of codespell 2023-11-14 10:11:16 +01:00
Andreas Steffen
02a4c8cfa9 Version bump to 5.9.12rc1 2023-11-14 08:12:00 +01:00
Andreas Steffen
6941dcb17a x509: Fix regression introduced by commit a22147a
Instead of the CA certificate's subjectKeyIdentifier erroneously
the CA's authorityKeyIdentifier was used as the authorityKeyIdentfier
of the certificate to be issued. This might work with a root CA
where the authorityKeyIdentifier equals its subjectKeyIdentfier
but introduces a severe regression when an intermediate CA is used.
2023-11-14 08:00:27 +01:00
Tobias Brunner
a1224b6c80 Merge branch 'ocsp-responder-index'
Adds support for multiple OCSP responders in `pki --ocsp` and one that
is based on OpenSSL-style index.txt files.  The parser for these files
also accepts simplified files that only specify the status, serial number
and optional revocation date/reason.  The OCSP test scenarios are also
updated to use this OCSP responder including one that shows the multi-CA
capabilities of the --ocsp command and the --index option.
2023-11-13 12:55:49 +01:00
Tobias Brunner
801c6c32e5 testing: Use a single OCSP responder for ikev2-multi-ca/ocsp-signers scenario
This demonstrates the multi-CA capabilities of the pki --ocsp command.
2023-11-13 12:50:47 +01:00
Tobias Brunner
c10a13589e testing: Use pki --ocsp as OCSP responder
The only exception is the ikev2/ocsp-no-signer-cert scenario as the
pki command won't sign an OCSP response with a certificate that isn't
the CA certificate or marked as an OCSP signer.
2023-11-13 12:50:47 +01:00
Tobias Brunner
5764e1e506 pki: Pre-process common arguments
This way the position of --debug doesn't matter for it to apply to the
parsing of all command-specific arguments.
2023-11-13 12:50:47 +01:00
Tobias Brunner
95c7d49954 pki: Add option to load certificate status information from index.txt
Each index.txt is associated with the most recently loaded CA
certificate.
2023-11-13 12:50:47 +01:00
Tobias Brunner
f26ca67d8c pki: Add index.txt-based OCSP responder 2023-11-13 12:50:47 +01:00
Tobias Brunner
1e8a72e7a0 chunk: Add helper to hash chunks via pointer 2023-11-13 12:50:47 +01:00
Tobias Brunner
3e42b2f5cb pki: Drop legacy registration for OCSP responders 2023-11-13 12:50:45 +01:00
Tobias Brunner
efac611566 openxpki: Register as OCSP responder 2023-11-13 12:50:24 +01:00
Tobias Brunner
515cecfe3e pki: Use OCSP responder manager for --ocsp --respond 2023-11-13 12:50:22 +01:00
Tobias Brunner
dab7c893a6 library: Add manager for OCSP responders
Registered OCSP responders should return VALIDATION_SKIPPED for issuer
certificates they are not responsible for. However, VALIDATION_FAILED is
currently treated the same way, so that's fine as well.
2023-11-13 12:45:54 +01:00
Tobias Brunner
3197523bd5 Merge branch 'ocsp-responder'
Implements a new --ocsp command for the pki tool that can produce OCSP
responses based on information provided by a plugin.  A first plugin
that accesses the OpenXPKI database is also added.

Closes strongswan/strongswan#1958
2023-11-13 12:42:00 +01:00
Andreas Steffen
821d7784a3 man: Extended pki man page and added pki --ocsp man page 2023-11-13 12:40:58 +01:00
Andreas Steffen
a0c9f9b842 pki: Added ocsp command
The pki --ocsp command implements an OCSP responder.
2023-11-13 12:40:58 +01:00
Andreas Steffen
ec325b4c09 pki: Added ocsp-req and ocsp-rsp types to pki --print 2023-11-13 12:40:58 +01:00
Andreas Steffen
a0f672d3d1 unit-tests: Update test_serial_gen suite 2023-11-13 12:40:55 +01:00
Andreas Steffen
00ab8d62c0 x509: Support generation of OCSP responses 2023-11-13 12:40:55 +01:00
Andreas Steffen
aa0fe149d6 certificates: Added ocsp_single_response object 2023-11-13 12:40:55 +01:00
Andreas Steffen
199c7083e1 openxpki: OCSP responder plugin accessing OpenXPKI
The openxpki plugin directly access the certificates table in
the OpenXPKI's MariaDB in order to retrieve the status of an
issued X.509 certificate based on its serial number.
2023-11-13 12:40:55 +01:00
Andreas Steffen
24d45de633 crl-reason: Fixed typo 2023-11-13 12:40:52 +01:00
Andreas Steffen
d72d0c0dfa utils: Added chunk_to_dec() function 2023-11-13 12:39:10 +01:00
Andreas Steffen
9381559754 x509: Support parsing of OCSP requests 2023-11-13 12:39:10 +01:00
Andreas Steffen
09e2a9ff50 pki --pkcs7: Set default to res = 1 2023-11-13 12:39:10 +01:00
Tobias Brunner
3cb8434367 kernel-netlink: Don't add replay state twice when updating SAs
The kernel includes the XFRMA_REPLAY_ESN_VAL attribute when dumping
SAs since it was added with 2.6.39.  So we basically added this attribute
twice to the message sent to the kernel, potentially exceeding the
message buffer if the window size is large.

The XFRMA_REPLAY_VAL attribute is only dumped since 3.19, so that might
still be relevant (Google seems to maintain a 3.18 kernel) and since we
have to query the current lifetime stats anyway, we can just avoid adding
this attribute twice.

Closes strongswan/strongswan#1967
2023-11-13 12:36:57 +01:00
Tobias Brunner
b345eb3051 Merge branch 'uri-san'
Adds support to encode SANs of type uniformResourceIdentifier in
certificates.  They currently don't have any use in strongSwan, but
might be required for other applications.

Closes strongswan/strongswan#1983
2023-11-13 12:34:32 +01:00
Tobias Brunner
9c2ca27b62 identification: Support explicit uri: prefix for SANs of type uniformResourceIdentifier 2023-11-13 12:33:39 +01:00
Tobias Brunner
500cacf6d8 x509: Add support to encode SANs of type uniformResourceIdentifier 2023-11-13 12:33:39 +01:00
Tobias Brunner
a22147a1b2 x509: Use issuer certificate's subjectKeyIdentifier if available
Instead of just generating an authorityKeyIdentifier based on the
issuer's public key, this allows CA certificates to be issued by a
different tool that doesn't use a SHA-1 hash of the subjectPublicKey
for the subjectKeyIdentifier.

Closes strongswan/strongswan#1992
References strongswan/strongswan#1975
2023-11-13 12:32:32 +01:00
Tobias Brunner
1a1dcf93a5 Merge branch 'pkcs12-no-pw'
This adds support for password-less PKCS#12 containers and PKCS#8 files.

A new option for charon-cmd also allows loading private keys of any
type (previously only RSA keys were supported).

References strongswan/strongswan#1955
2023-11-13 12:27:31 +01:00
Tobias Brunner
8581a19dd7 charon-cmd: Add support for key types other than RSA 2023-11-13 12:26:07 +01:00
Tobias Brunner
799511d90f pkcs12: Add support for PKCS#12 containers with empty or no password 2023-11-13 12:26:07 +01:00
Tobias Brunner
bdd8f14354 pkcs7: Add supported for unprotected PKCS#7 encrypted-data 2023-11-13 12:26:07 +01:00
Tobias Brunner
dc704cf206 pkcs8: Add support for unprotected PKCS#8 containers 2023-11-13 12:26:07 +01:00
Tobias Brunner
ad804fa036 pkcs12: Treat empty string and no password differently
When deriving the PKCS#12 key, the empty string should result in a
non-zero length Unicode string (two bytes for the 0 terminator).
2023-11-13 12:26:07 +01:00
Tobias Brunner
7bb6aed5ab openssl: Add support for unprotected PKCS#12 containers 2023-11-13 12:26:07 +01:00
Tobias Brunner
bae841ea04 Merge branch 'x509-ipaddress-constraints'
Adds support for nameConstraints of type iPAddress, which represent a
subnet, to the x509, openssl and constraints plugins.  SANs of type
iPAddress are matched against such constraints.

Closes strongswan/strongswan#1991
2023-11-13 12:24:31 +01:00
Tobias Brunner
1589f2d9ae constraints: Add support for IP address nameConstraints 2023-11-13 12:23:33 +01:00
Tobias Brunner
1c3096fe50 openssl: Add support for IP address nameConstraints 2023-11-13 12:23:33 +01:00
Tobias Brunner
ede96fe3db x509: Add support for IP address nameConstraints
According to RFC 5280, section 4.2.1.10, these are encoded as address
followed by a network mask of the same length.
2023-11-13 12:23:33 +01:00
Tobias Brunner
f781b9d326 openssl: Add support for nameConstraints X.509 extension
Closes strongswan/strongswan#1990
2023-11-13 12:23:02 +01:00
Tobias Brunner
ed2d548fee Merge branch 'reqid-refcount'
This fixes issues with CHILD_SAs getting reestablished concurrently.
We intend to reuse the reqid of the previous CHILD_SA, however, previously
the reqids were released and up for reassignment to any other CHILD_SA
or trap policy.  This could cause the reqid to get associated with
completely different traffic selectors, as the reestablished CHILD_SA
would eventually get the requested reqid because the traffic selectors
explicitly don't have to match (to allow narrowing for CHILD_SAs based
on trap policies).

Closes strongswan/strongswan#1855
2023-11-13 12:02:25 +01:00
Tobias Brunner
00d054aae5 ikev2: Correctly maintain allocated reqid during make-before-break reauth 2023-11-13 12:02:11 +01:00
Tobias Brunner
04bfe83f71 trap-manager: Maintain allocated reqids when handling acquires 2023-11-13 12:02:11 +01:00
Tobias Brunner
f9a9188a36 quick-delete: Correctly maintain allocated reqid when recreating CHILD_SA 2023-11-13 12:02:11 +01:00
Tobias Brunner
c923022733 child-delete: Correctly maintain allocated reqid when recreating CHILD_SA
The old CHILD_SA is destroyed even before the new task is queued, this
makes sure we always maintain a reference to the reqid.
2023-11-13 12:02:11 +01:00
Tobias Brunner
c2a4c8e38a ike-sa: Correctly maintain allocated reqid when recreating CHILD_SA
Maintaining the reqid when recreating a CHILD_SA from scratch night not
strictly be necessary as we usually don't have to replace any temporary
states in the kernel.  However, there could be concurrent acquires that
might actually make it necessary (we use the reqid to keep track of
acquires and it's also part of the duplicate check).
2023-11-13 12:02:11 +01:00
Tobias Brunner
f2bc526dbb ikev1: Only set reqid on rekeyed CHILD_SA if it was allocated dynamically 2023-11-13 12:02:11 +01:00
Tobias Brunner
bc39a3aecb child-rekey: Only set reqid on new CHILD_SA if it was allocated dynamically
Keeping a reference ensures that if the old SA expires before the new
one is installed, the previous reqid isn't reallocated to a concurrently
established CHILD_SA with different selectors.
2023-11-13 12:02:11 +01:00
Tobias Brunner
4ea739baf4 quick-mode: Maintain reference to reqid while CHILD_SA is established 2023-11-13 12:02:11 +01:00
Tobias Brunner
4bfd93b8db child-create: Maintain reference to reqid while CHILD_SA is established 2023-11-13 12:02:11 +01:00
Tobias Brunner
ff269f7f1f child-sa: Add method that returns a reference to an allocated reqid 2023-11-13 12:02:11 +01:00
Tobias Brunner
13771206d4 child-sa: Keep a reference to the previous reqid
The reference is kept until the reqid is either confirmed (i.e.
re-allocated) or replaced by a different reqid, which happens only once
we know the final traffic selectors, or the SA is destroyed without
installing it.
2023-11-13 12:02:11 +01:00
Tobias Brunner
e623f5792b kernel-interface: Add method to increase refcount for allocated reqid 2023-11-13 12:02:11 +01:00
Tobias Brunner
02180ae2ff kernel-interface: Remove unnecessary parameters for release_reqid()
These are not included in the initial lookup anymore. Also simplified
the implementation as we always add the same entry to the two hash
tables.
2023-11-13 12:02:11 +01:00
Tobias Brunner
90cf0078e1 kernel-interface: Use reqid as sole key in hash table
Every reqid is allocated once, we don't store the same reqid with e.g.
different marks or interface IDs that would make it necessary to make
them part of the key in that table (that's different in the other table).

To preserve the current behavior, that is, allocating a new reqid if e.g.
the marks are different, the additional selector values (which will
result in an additional policy in the Linux kernel) are compared after
the initial lookup.
2023-11-13 12:02:11 +01:00
Tobias Brunner
04c17ab56a credential-manager: Add option to reject trusted end-entity certificates
This allows preventing peers from authenticating with certificates
that are locally trusted, in particular, our own local certificate (which
safeguards against accidental reuse of certificates on multiple peers).

On the other hand, if this option is enabled, end-entity certificates
for peers can't be configured anymore explicitly (e.g. via remote.certs
in swanctl.conf).
2023-11-13 12:01:41 +01:00
Andreas Steffen
28ccdff692 cert-enroll: Preventing some errors that might occur 2023-11-13 11:57:51 +01:00
Andreas Steffen
f328ef0e04 cert-enroll: Install TLS client/server credentials
Install the generated key, host certificate and associated CA certificates
as credentials for a TLS-protected client-server connection.
2023-11-13 11:57:51 +01:00
Tobias Brunner
b5e4bf4b6c tls-server: Also change DH group when selecting a different EC curve
If we initially selected a group the peer doesn't support (e.g. because
curve25519 is the first ECDH group provided by plugins), then found
a supported curve, we previously still instantiated a DH object for the
original group and might have formatted the parameters incorrectly.
2023-11-06 11:00:51 +01:00
Tobias Brunner
595fa077b6 ike-sa: Fix handling of redirects during IKE_AUTH
Since the referenced commit, the state switch to IKE_ESTABLISHED doesn't
happen immediately after completing the authentication but only after
the remaining tasks have finished.  Due to that redirects during IKE_AUTH
were treated like those during IKE_SA_INIT causing the IKE_SA and task
manager to get reset.  However, unlike the ike-init task, the ike-auth
task returned SUCCESS and, therefore, got destroyed, while a different
task was removed from the array that was modified during the reset.
This later caused a dereference of the freed ike-auth task and a crash.

Fixes: 5ce1c91b58a2 ("ikev2: Trigger ike_updown() event after all IKE-specific tasks ran")
2023-11-06 10:41:57 +01:00
Tobias Brunner
46c012b664 github: Use latest Sonar scanner 2023-11-03 09:28:51 +01:00
Tobias Brunner
eda91911fa Use wolfSSL 5.6.4 for tests 2023-11-03 09:28:51 +01:00
Andreas Steffen
51872a0a0c Version bump to 5.9.12dr2 2023-10-30 22:42:55 +01:00
Andreas Steffen
d6bfdf2b2b cert-enroll: Pack all source files into EXTRA_DIST 2023-10-26 15:15:37 +02:00
Tobias Brunner
b576024387 Merge branch 'reject-explicit-ecdsa'
There is a relatively recent NIAP requirement to reject certificates with
ECDSA keys that explicitly encode the curve parameters (TD0527, Test 8b).

Since explicit encoding is pretty rare (if used at all and e.g. wolfSSL
already rejects it, by default), we should follow that requirement and
just reject such keys/certificates completely.

This currently can be enforced in all crypto plugins except when using
older versions of OpenSSL (< 1.1.1h) and Botan (< 3.2.0).

Closes strongswan/strongswan#1949
References strongswan/strongswan#1796
2023-10-13 09:12:02 +02:00
Tobias Brunner
bb14a28671 unit-tests: Add a test case for explicit ECDSA parameters
Currently only warns about it as older OpenSSL versions (AppVeyor)
don't reject them.
2023-10-13 09:10:46 +02:00
Tobias Brunner
578b561a22 Use Botan 3.2.0 for tests
This includes a change that allows checking EC keys for explicit
param encoding.
2023-10-13 09:10:46 +02:00
Tobias Brunner
0b989c7b20 botan: Reject EC keys with explicitly encoded parameters
This requires a function that will be added in the upcoming Botan 3.2
release.
2023-10-13 09:10:46 +02:00
Tobias Brunner
2bccdefc2c openssl: Reject EC keys with explicitly encoded parameters
EC_KEY_decoded_from_explicit_params() was added with 1.1.1h but has been
deprecated with 3.0.
2023-10-13 09:10:46 +02:00
Tobias Brunner
a69184fb9d wolfssl: Reject EC keys with explicitly encoded parameters
These are not allowed in X.509 certificates according to RFC 5480 and
some newer validations apparently explicitly check for this.

Note that WolfSSL rejects such keys, by default.  Only when compiled with
WOLFSSL_NO_ASN_STRICT are they accepted.
2023-10-13 09:10:46 +02:00
Andreas Steffen
6f0cd19fd6 cert-enroll: Fixed path in cert-install-openxpki 2023-10-12 08:14:38 +02:00
Tobias Brunner
b56c264041 cirrus: Use FreeBSD 12.4
FreeBSD 12.3 is officially EOL.
2023-10-09 15:22:41 +02:00
Tobias Brunner
7e2e463285 cirrus: Use FreeBSD 13.2
This should fix an error thrown by bison:

 ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/bin/bison not found
2023-10-09 15:22:41 +02:00
Andreas Steffen
7dfb88ead2 Version bump to 5.9.12dr2 2023-10-04 08:15:54 +02:00
Andreas Steffen
cbfc12b330 cert-enroll: certificate checking and enrollment
The cert-enroll script handles the initial enrollment of an X.509
host certificate with a PKI server via the EST or SCEP protocols.

Run as a systemd timer or via a crontab entry the script daily
checks the expiration date of the host certificate. When a given
deadline is reached, the host certificate is automatically renewed
via EST or SCEP re-enrollment based on the possession of the old
private key and the matching certificate.
2023-10-03 08:45:22 +02:00
Tobias Brunner
80e27fe9fd ike-sa: Destroy CHILD_SAs in order
This works around an issue that occurs when recreating an IKE_SA with
multiple CHILD_SAs that use dynamically allocated reqids.

We currently try to preserve the reqid when reestablishing, so the
create-child task gets the reqid of the previous CHILD_SA and will try
to reallocate that once the CHILD_SA is installed.  Before that, the old
CHILD_SA is destroyed and the reqid is released and added to the array
of reqids to get reused.  However, because of the reverse order used here,
the first reqid in the array is the one of the last CHILD_SA.

So it can happen that a newly created CHILD_SA gets a reqid reassigned
that a later CHILD_SA will then also claim for itself and get assigned
because an entry with that reqid exists.  So multiple CHILD_SAs with
different traffic selectors could then share the same reqid.

References strongswan/strongswan#1855
2023-09-28 09:41:53 +02:00
Boi Sletterink
190d8cbe19 libipsec: Also install routes without preferred source to forward traffic
Fixes a problem installing policies with source traffic selectors that do
not contain/match any of the local addresses.

When installing a route for a source TS that does contain one or more
local addresses, a preferred source address should be set in the route
(analogous to the `src` option in `ip route add`). This address is used
when the host itself sends traffic via that route (in contrast to
forwarding it).

When the source TS does not encompass any of the local addresses, the
host is not allowed to send traffic via this route and does not need to
set the preferred source address. However, the code would just return a
failure because it could not find a matching local address. This commit
changes this so routes without preferred source IP are installed to
allow non-local traffic to get forwarded via TUN device.

Closes strongswan/strongswan#1766
2023-09-04 16:54:37 +02:00
Antony Antony
cdc34ddea2 configure: Fix in6_pktinfo auto detection
This commit fixes auto detection of in6_pktinfo.
When negotiating an IPv6 IKE session charon reported an error

"Jun 30 16:42:49 03[NET] error reading IP header"

The cause of error was missing in6_pktinfo declaration, which is
auto detected. This auto detection may fail with an error depending
on compiler flags:

configure:19850: checking for in6_pktinfo
configure:19870: gcc -c -g -O0 -Wall -Wno-format -Wno-format-security
-Wno-pointer-sign -Werror -Wfatal-errors -Wno-error=stringop-truncation
conftest.c >&5
conftest.c: In function 'main':
conftest.c:73:11: error: 'pi.ipi6_ifindex' is used uninitialized in this
function [-Werror=uninitialized]
   73 |     if (pi.ipi6_ifindex)
      |         ~~^~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors

Signed-off-by: Antony Antony <antony.antony@secunet.com>
2023-09-04 14:31:19 +02:00
Tobias Brunner
0bff5c98bc vici: Fix connecting to socket in Python bindings on Windows
socket.connect() takes a single argument with the address that depends
on the address family, for TCP it's a tuple with IP and port.

Fixes: 00a75e332f29 ("vici: Create default TCP socket on Windows in Python bindings")
Closes strongswan/strongswan#1874
2023-08-31 11:39:52 +02:00
2334 changed files with 74669 additions and 30744 deletions

View File

@ -1,11 +1,11 @@
task:
freebsd_task:
matrix:
- name: FreeBSD 13.0
- name: FreeBSD 14.2
freebsd_instance:
image_family: freebsd-13-0
- name: FreeBSD 12.3
image_family: freebsd-14-2
- name: FreeBSD 13.4
freebsd_instance:
image_family: freebsd-12-3
image_family: freebsd-13-4
env:
TESTS_REDUCED_KEYLENGTHS: yes
@ -16,3 +16,18 @@ task:
install_script: ./scripts/test.sh deps
script: ./scripts/test.sh
alpine_task:
container:
image: alpine:latest
env:
TESTS_REDUCED_KEYLENGTHS: yes
TESTS_NO_IPV6: yes
LEAK_DETECTIVE: no
MONOLITHIC: no
TEST: alpine
OS_NAME: alpine
install_script: ./scripts/test.sh deps
script: ./scripts/test.sh

View File

@ -1,3 +1,3 @@
ignore:
- "*/suites/*"
- "*/tests/*"
- "**/suites/"
- "**/tests/"

View File

@ -2,6 +2,7 @@
name: "🐛 Bug report"
about: Report a reproducible bug or regression
labels: bug, new
type: Bug
---
<!--

View File

@ -2,6 +2,7 @@
name: Feature request
about: Suggest an idea for this project
labels: enhancement, new
type: Feature
---
<!--

View File

@ -5,9 +5,6 @@ runs:
- name: "Install Dependencies"
run: ./scripts/test.sh deps
shell: bash
- name: "Install Python Dependencies"
run: ./scripts/test.sh pydeps
shell: bash
- name: "Build Dependencies"
run: ./scripts/test.sh build-deps
shell: bash

102
.github/active-transforms/botan vendored Normal file
View File

@ -0,0 +1,102 @@
AES_ECB[botan]
AES_ECB[botan]
AES_ECB[botan]
AES_CBC[botan]
AES_CBC[botan]
AES_CBC[botan]
AES_CFB[botan]
AES_CFB[botan]
AES_CFB[botan]
AES_GCM_16[botan]
AES_GCM_16[botan]
AES_GCM_16[botan]
AES_GCM_12[botan]
AES_GCM_12[botan]
AES_GCM_12[botan]
AES_GCM_8[botan]
AES_GCM_8[botan]
AES_GCM_8[botan]
AES_CCM_16[botan]
AES_CCM_16[botan]
AES_CCM_16[botan]
AES_CCM_12[botan]
AES_CCM_12[botan]
AES_CCM_12[botan]
AES_CCM_8[botan]
AES_CCM_8[botan]
AES_CCM_8[botan]
CHACHA20_POLY1305[botan]
HMAC_SHA1_96[botan]
HMAC_SHA1_96[hmac]
HMAC_SHA1_128[botan]
HMAC_SHA1_128[hmac]
HMAC_SHA1_160[botan]
HMAC_SHA1_160[hmac]
HMAC_SHA2_256_128[botan]
HMAC_SHA2_256_128[hmac]
HMAC_SHA2_256_256[botan]
HMAC_SHA2_256_256[hmac]
HMAC_SHA2_384_192[botan]
HMAC_SHA2_384_192[hmac]
HMAC_SHA2_384_384[botan]
HMAC_SHA2_384_384[hmac]
HMAC_SHA2_512_256[botan]
HMAC_SHA2_512_256[hmac]
HMAC_SHA2_512_512[botan]
HMAC_SHA2_512_512[hmac]
HMAC_MD5_96[hmac]
HMAC_MD5_128[hmac]
HASH_MD5[botan]
HASH_SHA1[botan]
HASH_SHA2_224[botan]
HASH_SHA2_256[botan]
HASH_SHA2_384[botan]
HASH_SHA2_512[botan]
HASH_SHA3_224[botan]
HASH_SHA3_256[botan]
HASH_SHA3_384[botan]
HASH_SHA3_512[botan]
HASH_IDENTITY[botan]
PRF_HMAC_SHA1[botan]
PRF_HMAC_SHA1[hmac]
PRF_HMAC_SHA2_256[botan]
PRF_HMAC_SHA2_256[hmac]
PRF_HMAC_SHA2_384[botan]
PRF_HMAC_SHA2_384[hmac]
PRF_HMAC_SHA2_512[botan]
PRF_HMAC_SHA2_512[hmac]
PRF_HMAC_MD5[hmac]
KDF_PRF[botan]
KDF_PRF_PLUS[botan]
DRBG_CTR_AES256[drbg]
DRBG_CTR_AES128[drbg]
DRBG_CTR_AES192[drbg]
DRBG_HMAC_SHA1[drbg]
DRBG_HMAC_SHA256[drbg]
DRBG_HMAC_SHA384[drbg]
DRBG_HMAC_SHA512[drbg]
RNG_WEAK[botan]
RNG_STRONG[botan]
RNG_TRUE[botan]
MODP_3072[botan]
MODP_4096[botan]
MODP_6144[botan]
MODP_8192[botan]
MODP_2048[botan]
MODP_2048_224[botan]
MODP_2048_256[botan]
MODP_1536[botan]
MODP_1024[botan]
MODP_1024_160[botan]
MODP_768[botan]
MODP_CUSTOM[botan]
ECP_256[botan]
ECP_384[botan]
ECP_521[botan]
ECP_256_BP[botan]
ECP_384_BP[botan]
ECP_512_BP[botan]
CURVE_25519[botan]
ML_KEM_512[botan]
ML_KEM_768[botan]
ML_KEM_1024[botan]

81
.github/active-transforms/gcrypt vendored Normal file
View File

@ -0,0 +1,81 @@
AES_CTR[gcrypt]
AES_CTR[gcrypt]
AES_CTR[gcrypt]
AES_CBC[gcrypt]
AES_CBC[gcrypt]
AES_CBC[gcrypt]
AES_ECB[gcrypt]
AES_ECB[gcrypt]
AES_ECB[gcrypt]
AES_CFB[gcrypt]
AES_CFB[gcrypt]
AES_CFB[gcrypt]
BLOWFISH_CBC[gcrypt]
CAMELLIA_CTR[gcrypt]
CAMELLIA_CTR[gcrypt]
CAMELLIA_CTR[gcrypt]
CAMELLIA_CBC[gcrypt]
CAMELLIA_CBC[gcrypt]
CAMELLIA_CBC[gcrypt]
CAST_CBC[gcrypt]
3DES_CBC[gcrypt]
DES_CBC[gcrypt]
DES_ECB[gcrypt]
SERPENT_CBC[gcrypt]
SERPENT_CBC[gcrypt]
SERPENT_CBC[gcrypt]
TWOFISH_CBC[gcrypt]
TWOFISH_CBC[gcrypt]
AES_GCM_8[gcm]
AES_GCM_8[gcm]
AES_GCM_8[gcm]
AES_GCM_12[gcm]
AES_GCM_12[gcm]
AES_GCM_12[gcm]
AES_GCM_16[gcm]
AES_GCM_16[gcm]
AES_GCM_16[gcm]
HMAC_SHA1_96[hmac]
HMAC_SHA1_128[hmac]
HMAC_SHA1_160[hmac]
HMAC_MD5_96[hmac]
HMAC_MD5_128[hmac]
HMAC_SHA2_256_128[hmac]
HMAC_SHA2_256_256[hmac]
HMAC_SHA2_384_192[hmac]
HMAC_SHA2_384_384[hmac]
HMAC_SHA2_512_256[hmac]
HMAC_SHA2_512_512[hmac]
HASH_MD4[gcrypt]
HASH_MD5[gcrypt]
HASH_SHA1[gcrypt]
HASH_SHA2_224[gcrypt]
HASH_SHA2_256[gcrypt]
HASH_SHA2_384[gcrypt]
HASH_SHA2_512[gcrypt]
HASH_IDENTITY[curve25519]
PRF_HMAC_SHA1[hmac]
PRF_HMAC_MD5[hmac]
PRF_HMAC_SHA2_256[hmac]
PRF_HMAC_SHA2_384[hmac]
PRF_HMAC_SHA2_512[hmac]
KDF_PRF[kdf]
KDF_PRF_PLUS[kdf]
RNG_WEAK[gcrypt]
RNG_STRONG[gcrypt]
RNG_STRONG[random]
RNG_TRUE[gcrypt]
RNG_TRUE[random]
MODP_3072[gcrypt]
MODP_4096[gcrypt]
MODP_6144[gcrypt]
MODP_8192[gcrypt]
MODP_2048[gcrypt]
MODP_2048_224[gcrypt]
MODP_2048_256[gcrypt]
MODP_1536[gcrypt]
MODP_1024[gcrypt]
MODP_1024_160[gcrypt]
MODP_768[gcrypt]
MODP_CUSTOM[gcrypt]
CURVE_25519[curve25519]

108
.github/active-transforms/openssl vendored Normal file
View File

@ -0,0 +1,108 @@
AES_ECB[openssl]
AES_ECB[openssl]
AES_ECB[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CTR[openssl]
CAMELLIA_CTR[openssl]
CAMELLIA_CTR[openssl]
CAST_CBC[openssl]
BLOWFISH_CBC[openssl]
3DES_CBC[openssl]
DES_CBC[openssl]
DES_ECB[openssl]
NULL[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
CHACHA20_POLY1305[openssl]
HMAC_MD5_96[openssl]
HMAC_MD5_128[openssl]
HMAC_SHA1_96[openssl]
HMAC_SHA1_128[openssl]
HMAC_SHA1_160[openssl]
HMAC_SHA2_256_128[openssl]
HMAC_SHA2_256_256[openssl]
HMAC_SHA2_384_192[openssl]
HMAC_SHA2_384_384[openssl]
HMAC_SHA2_512_256[openssl]
HMAC_SHA2_512_512[openssl]
HASH_MD4[openssl]
HASH_MD5[openssl]
HASH_SHA1[openssl]
HASH_SHA2_224[openssl]
HASH_SHA2_256[openssl]
HASH_SHA2_384[openssl]
HASH_SHA2_512[openssl]
HASH_SHA3_224[openssl]
HASH_SHA3_256[openssl]
HASH_SHA3_384[openssl]
HASH_SHA3_512[openssl]
HASH_IDENTITY[openssl]
PRF_KEYED_SHA1[openssl]
PRF_HMAC_MD5[openssl]
PRF_HMAC_SHA1[openssl]
PRF_HMAC_SHA2_256[openssl]
PRF_HMAC_SHA2_384[openssl]
PRF_HMAC_SHA2_512[openssl]
XOF_SHAKE128[openssl]
XOF_SHAKE256[openssl]
KDF_PRF[openssl]
KDF_PRF_PLUS[openssl]
DRBG_CTR_AES256[drbg]
DRBG_CTR_AES128[drbg]
DRBG_CTR_AES192[drbg]
DRBG_HMAC_SHA1[drbg]
DRBG_HMAC_SHA256[drbg]
DRBG_HMAC_SHA384[drbg]
DRBG_HMAC_SHA512[drbg]
RNG_WEAK[openssl]
RNG_STRONG[openssl]
MODP_3072[openssl]
MODP_4096[openssl]
MODP_6144[openssl]
MODP_8192[openssl]
MODP_2048[openssl]
MODP_2048_224[openssl]
MODP_2048_256[openssl]
MODP_1536[openssl]
MODP_1024[openssl]
MODP_1024_160[openssl]
MODP_768[openssl]
MODP_CUSTOM[openssl]
ECP_256[openssl]
ECP_384[openssl]
ECP_521[openssl]
ECP_224[openssl]
ECP_192[openssl]
ECP_256_BP[openssl]
ECP_384_BP[openssl]
ECP_512_BP[openssl]
ECP_224_BP[openssl]
CURVE_25519[openssl]
CURVE_448[openssl]

111
.github/active-transforms/openssl-3 vendored Normal file
View File

@ -0,0 +1,111 @@
AES_ECB[openssl]
AES_ECB[openssl]
AES_ECB[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CBC[openssl]
CAMELLIA_CTR[openssl]
CAMELLIA_CTR[openssl]
CAMELLIA_CTR[openssl]
CAST_CBC[openssl]
BLOWFISH_CBC[openssl]
3DES_CBC[openssl]
DES_CBC[openssl]
DES_ECB[openssl]
NULL[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
CHACHA20_POLY1305[openssl]
HMAC_MD5_96[openssl]
HMAC_MD5_128[openssl]
HMAC_SHA1_96[openssl]
HMAC_SHA1_128[openssl]
HMAC_SHA1_160[openssl]
HMAC_SHA2_256_128[openssl]
HMAC_SHA2_256_256[openssl]
HMAC_SHA2_384_192[openssl]
HMAC_SHA2_384_384[openssl]
HMAC_SHA2_512_256[openssl]
HMAC_SHA2_512_512[openssl]
HASH_MD4[openssl]
HASH_MD5[openssl]
HASH_SHA1[openssl]
HASH_SHA2_224[openssl]
HASH_SHA2_256[openssl]
HASH_SHA2_384[openssl]
HASH_SHA2_512[openssl]
HASH_SHA3_224[openssl]
HASH_SHA3_256[openssl]
HASH_SHA3_384[openssl]
HASH_SHA3_512[openssl]
HASH_IDENTITY[openssl]
PRF_KEYED_SHA1[openssl]
PRF_HMAC_MD5[openssl]
PRF_HMAC_SHA1[openssl]
PRF_HMAC_SHA2_256[openssl]
PRF_HMAC_SHA2_384[openssl]
PRF_HMAC_SHA2_512[openssl]
XOF_SHAKE128[openssl]
XOF_SHAKE256[openssl]
KDF_PRF[openssl]
KDF_PRF_PLUS[openssl]
DRBG_CTR_AES256[drbg]
DRBG_CTR_AES128[drbg]
DRBG_CTR_AES192[drbg]
DRBG_HMAC_SHA1[drbg]
DRBG_HMAC_SHA256[drbg]
DRBG_HMAC_SHA384[drbg]
DRBG_HMAC_SHA512[drbg]
RNG_WEAK[openssl]
RNG_STRONG[openssl]
MODP_3072[openssl]
MODP_4096[openssl]
MODP_6144[openssl]
MODP_8192[openssl]
MODP_2048[openssl]
MODP_2048_224[openssl]
MODP_2048_256[openssl]
MODP_1536[openssl]
MODP_1024[openssl]
MODP_1024_160[openssl]
MODP_768[openssl]
MODP_CUSTOM[openssl]
ML_KEM_512[openssl]
ML_KEM_768[openssl]
ML_KEM_1024[openssl]
ECP_256[openssl]
ECP_384[openssl]
ECP_521[openssl]
ECP_224[openssl]
ECP_192[openssl]
ECP_256_BP[openssl]
ECP_384_BP[openssl]
ECP_512_BP[openssl]
ECP_224_BP[openssl]
CURVE_25519[openssl]
CURVE_448[openssl]

98
.github/active-transforms/openssl-awslc vendored Normal file
View File

@ -0,0 +1,98 @@
AES_ECB[openssl]
AES_ECB[openssl]
AES_ECB[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CBC[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CTR[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
AES_CFB[openssl]
BLOWFISH_CBC[openssl]
3DES_CBC[openssl]
DES_CBC[openssl]
DES_ECB[openssl]
NULL[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_16[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_12[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_GCM_8[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_16[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_12[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
AES_CCM_8[openssl]
CHACHA20_POLY1305[openssl]
HMAC_MD5_96[openssl]
HMAC_MD5_128[openssl]
HMAC_SHA1_96[openssl]
HMAC_SHA1_128[openssl]
HMAC_SHA1_160[openssl]
HMAC_SHA2_256_128[openssl]
HMAC_SHA2_256_256[openssl]
HMAC_SHA2_384_192[openssl]
HMAC_SHA2_384_384[openssl]
HMAC_SHA2_512_256[openssl]
HMAC_SHA2_512_512[openssl]
HASH_MD4[openssl]
HASH_MD5[openssl]
HASH_SHA1[openssl]
HASH_SHA2_224[openssl]
HASH_SHA2_256[openssl]
HASH_SHA2_384[openssl]
HASH_SHA2_512[openssl]
HASH_SHA3_224[openssl]
HASH_SHA3_256[openssl]
HASH_SHA3_384[openssl]
HASH_SHA3_512[openssl]
HASH_IDENTITY[openssl]
PRF_KEYED_SHA1[openssl]
PRF_HMAC_MD5[openssl]
PRF_HMAC_SHA1[openssl]
PRF_HMAC_SHA2_256[openssl]
PRF_HMAC_SHA2_384[openssl]
PRF_HMAC_SHA2_512[openssl]
XOF_SHAKE128[openssl]
XOF_SHAKE256[openssl]
KDF_PRF[openssl]
KDF_PRF_PLUS[openssl]
DRBG_CTR_AES256[drbg]
DRBG_CTR_AES128[drbg]
DRBG_CTR_AES192[drbg]
DRBG_HMAC_SHA1[drbg]
DRBG_HMAC_SHA256[drbg]
DRBG_HMAC_SHA384[drbg]
DRBG_HMAC_SHA512[drbg]
RNG_WEAK[openssl]
RNG_STRONG[openssl]
MODP_3072[openssl]
MODP_4096[openssl]
MODP_6144[openssl]
MODP_8192[openssl]
MODP_2048[openssl]
MODP_2048_224[openssl]
MODP_2048_256[openssl]
MODP_1536[openssl]
MODP_1024[openssl]
MODP_1024_160[openssl]
MODP_768[openssl]
MODP_CUSTOM[openssl]
ML_KEM_512[openssl]
ML_KEM_768[openssl]
ML_KEM_1024[openssl]
ECP_256[openssl]
ECP_384[openssl]
ECP_521[openssl]
ECP_224[openssl]
CURVE_25519[openssl]

103
.github/active-transforms/wolfssl vendored Normal file
View File

@ -0,0 +1,103 @@
AES_ECB[wolfssl]
AES_ECB[wolfssl]
AES_ECB[wolfssl]
AES_CTR[wolfssl]
AES_CTR[wolfssl]
AES_CTR[wolfssl]
AES_CBC[wolfssl]
AES_CBC[wolfssl]
AES_CBC[wolfssl]
AES_CFB[wolfssl]
AES_CFB[wolfssl]
AES_CFB[wolfssl]
CAMELLIA_CBC[wolfssl]
CAMELLIA_CBC[wolfssl]
CAMELLIA_CBC[wolfssl]
3DES_CBC[wolfssl]
DES_CBC[wolfssl]
DES_ECB[wolfssl]
NULL[wolfssl]
AES_GCM_16[wolfssl]
AES_GCM_16[wolfssl]
AES_GCM_16[wolfssl]
AES_GCM_12[wolfssl]
AES_GCM_12[wolfssl]
AES_GCM_12[wolfssl]
AES_GCM_8[wolfssl]
AES_GCM_8[wolfssl]
AES_GCM_8[wolfssl]
AES_CCM_16[wolfssl]
AES_CCM_16[wolfssl]
AES_CCM_16[wolfssl]
AES_CCM_12[wolfssl]
AES_CCM_12[wolfssl]
AES_CCM_12[wolfssl]
AES_CCM_8[wolfssl]
AES_CCM_8[wolfssl]
AES_CCM_8[wolfssl]
CHACHA20_POLY1305[wolfssl]
HMAC_MD5_96[wolfssl]
HMAC_MD5_128[wolfssl]
HMAC_SHA1_96[wolfssl]
HMAC_SHA1_128[wolfssl]
HMAC_SHA1_160[wolfssl]
HMAC_SHA2_256_128[wolfssl]
HMAC_SHA2_256_256[wolfssl]
HMAC_SHA2_384_192[wolfssl]
HMAC_SHA2_384_384[wolfssl]
HMAC_SHA2_512_256[wolfssl]
HMAC_SHA2_512_512[wolfssl]
HASH_MD5[wolfssl]
HASH_SHA1[wolfssl]
HASH_SHA2_224[wolfssl]
HASH_SHA2_256[wolfssl]
HASH_SHA2_384[wolfssl]
HASH_SHA2_512[wolfssl]
HASH_SHA3_224[wolfssl]
HASH_SHA3_256[wolfssl]
HASH_SHA3_384[wolfssl]
HASH_SHA3_512[wolfssl]
HASH_IDENTITY[wolfssl]
PRF_KEYED_SHA1[wolfssl]
PRF_HMAC_MD5[wolfssl]
PRF_HMAC_SHA1[wolfssl]
PRF_HMAC_SHA2_256[wolfssl]
PRF_HMAC_SHA2_384[wolfssl]
PRF_HMAC_SHA2_512[wolfssl]
XOF_SHAKE256[wolfssl]
KDF_PRF[wolfssl]
KDF_PRF_PLUS[wolfssl]
DRBG_CTR_AES256[drbg]
DRBG_CTR_AES128[drbg]
DRBG_CTR_AES192[drbg]
DRBG_HMAC_SHA1[drbg]
DRBG_HMAC_SHA256[drbg]
DRBG_HMAC_SHA384[drbg]
DRBG_HMAC_SHA512[drbg]
RNG_WEAK[wolfssl]
RNG_STRONG[wolfssl]
ECP_256[wolfssl]
ECP_384[wolfssl]
ECP_521[wolfssl]
ECP_224[wolfssl]
ECP_256_BP[wolfssl]
ECP_384_BP[wolfssl]
ECP_512_BP[wolfssl]
ECP_224_BP[wolfssl]
MODP_3072[wolfssl]
MODP_4096[wolfssl]
MODP_6144[wolfssl]
MODP_8192[wolfssl]
MODP_2048[wolfssl]
MODP_2048_224[wolfssl]
MODP_2048_256[wolfssl]
MODP_1536[wolfssl]
MODP_1024[wolfssl]
MODP_1024_160[wolfssl]
MODP_768[wolfssl]
MODP_CUSTOM[wolfssl]
ML_KEM_512[wolfssl]
ML_KEM_768[wolfssl]
ML_KEM_1024[wolfssl]
CURVE_25519[wolfssl]
CURVE_448[wolfssl]

View File

@ -10,8 +10,7 @@
* @precision very-high
*/
import cpp
import DataFlow::PathGraph
import semmle.code.cpp.dataflow.DataFlow
import semmle.code.cpp.dataflow.new.DataFlow
class ChunkFromChars extends Expr {
ChunkFromChars() {
@ -23,29 +22,30 @@ class ChunkFromChars extends Expr {
}
}
class ChunkFromCharsUsage extends DataFlow::Configuration {
ChunkFromCharsUsage() { this = "ChunkFromCharsUsage" }
override predicate isSource(DataFlow::Node source) {
module ChunkFromCharsConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof ChunkFromChars
}
override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
exists(sink.asExpr())
}
override predicate isBarrierOut(DataFlow::Node node) {
predicate isBarrierOut(DataFlow::Node node) {
/* don't track beyond function calls */
exists(FunctionCall fc | node.asExpr().getParent*() = fc)
}
}
module ChunkFromCharsFlow = DataFlow::Global<ChunkFromCharsConfig>;
import ChunkFromCharsFlow::PathGraph
BlockStmt enclosingBlock(BlockStmt b) {
result = b.getEnclosingBlock()
}
from ChunkFromCharsUsage usage, DataFlow::PathNode source, DataFlow::PathNode sink
from ChunkFromCharsFlow::PathNode source, ChunkFromCharsFlow::PathNode sink
where
usage.hasFlowPath(source, sink)
ChunkFromCharsFlow::flowPath(source, sink)
and not source.getNode().asExpr().getEnclosingBlock() = enclosingBlock*(sink.getNode().asExpr().getEnclosingBlock())
select source, source, sink, "Invalid use of chunk_from_chars() result in sibling/parent block."

View File

@ -2,6 +2,10 @@ name: Android
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
@ -18,7 +22,7 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
android:
needs: pre-check
@ -26,28 +30,39 @@ jobs:
runs-on: ubuntu-latest
env:
TEST: android
# since the NDK is newly installed every time, we have to use this to avoid cache misses
# since the NDK might be newly installed, we have to use this to avoid cache misses
CCACHE_COMPILERCHECK: content
steps:
# we currently don't specify a specific NDK version in our gradle files,
# so we load the version the Gradle Plugin uses as default but which is
# not installed anymore in the image
- uses: actions/checkout@v4
# make sure the NDK we reference is installed and exported so we can use it to build OpenSSL
- name: Install NDK
run: yes | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;23.1.7779620'
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: ndk-install
run: |
NDK_VERSION=$(grep "ndkVersion" src/frontends/android/app/build.gradle | sed -e 's/.*"\(.*\)"/\1/')
echo Using NDK ${NDK_VERSION}
yes | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${NDK_VERSION}"
echo "ANDROID_NDK_ROOT=${ANDROID_HOME}/ndk/${NDK_VERSION}" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-android-${{ github.sha }}
restore-keys: |
ccache-android-
# necessary for newer versions of the Gradle plugin
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
env:
ANDROID_NDK_ROOT: ${{ steps.ndk-install.outputs.ANDROID_NDK_ROOT }}
- run: ccache -s
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Lint Results
path: src/frontends/android/app/build/reports/lint-results*.xml

View File

@ -2,6 +2,10 @@ name: "CodeQL"
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
@ -19,7 +23,7 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
analyze:
needs: pre-check
@ -34,20 +38,20 @@ jobs:
matrix:
language: [ 'cpp', 'python', 'ruby' ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/config.yml
- if: matrix.language == 'python' || matrix.language == 'ruby'
name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3
# this follows the steps of the Linux workflow
- if: matrix.language == 'cpp'
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-ubuntu-latest-gcc-codeql-${{ github.sha }}
@ -69,6 +73,6 @@ jobs:
run: ccache -s
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

View File

@ -2,6 +2,10 @@ name: Linux
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# this test case does not actually test anything but tries to access system
# directories that might be inaccessible on build hosts
@ -21,12 +25,12 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
latest:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
matrix:
test: [ all, default, printf-builtin ]
@ -48,6 +52,9 @@ jobs:
- test: no-dbg
- test: no-dbg
compiler: clang
- test: no-testable-ke
- test: no-testable-ke
compiler: clang
- test: fuzzing
compiler: clang
monolithic: yes
@ -57,8 +64,8 @@ jobs:
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
# with regards to ccache, monolithic builds don't differ from regular
@ -76,38 +83,47 @@ jobs:
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ success() && matrix.test == 'coverage' }}
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v4
with:
disable_search: true
fail_ci_if_error: true
file: coverage/coverage.cleaned.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5
crypto-plugins:
crypto:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, ubuntu-20.04 ]
test: [ botan, wolfssl, openssl, openssl-3, gcrypt ]
test: [ botan, wolfssl, openssl, openssl-3, openssl-awslc, gcrypt ]
os: [ ubuntu-latest, ubuntu-22.04 ]
leak-detective: [ no, yes ]
exclude:
# test custom-built libs only on one platform
- os: ubuntu-20.04
# test custom-built libs only on the latest platform
- os: ubuntu-22.04
test: botan
- os: ubuntu-20.04
- os: ubuntu-22.04
test: wolfssl
- os: ubuntu-20.04
- os: ubuntu-22.04
test: openssl-3
- os: ubuntu-22.04
test: openssl-awslc
env:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
ACTIVE_TRANSFORMS_REF: .github/active-transforms/${{ matrix.test }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
# path is different on newer systems
path: |
@ -123,10 +139,20 @@ jobs:
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
echo "TESTS_ACTIVE_TRANSFORMS=$HOME/active-transforms.log" >> $GITHUB_ENV
- uses: ./.github/actions/default
- name: Upload active transforms
uses: actions/upload-artifact@v4
with:
name: active-transforms-${{ matrix.test }}-${{ matrix.os }}-${{ matrix.leak-detective }}
path: ${{ env.TESTS_ACTIVE_TRANSFORMS }}
retention-days: 5
- name: Verify active transforms
run: |
test ! -f $ACTIVE_TRANSFORMS_REF || diff -u --color=always $ACTIVE_TRANSFORMS_REF $TESTS_ACTIVE_TRANSFORMS
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Logs ${{ github.job }}
path: config.log
@ -138,7 +164,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04 ]
os: [ ubuntu-22.04 ]
test: [ all, nm ]
compiler: [ gcc, clang ]
exclude:
@ -148,13 +174,14 @@ jobs:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
# LSan causes spurious SIGSEGV after tests due to DTLS handling by glibc
ASAN_OPTIONS: intercept_tls_get_addr=0
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.ccache
# path is different on newer systems
path: |
~/.cache/ccache
~/.ccache
key: ccache-${{ matrix.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.sha }}
restore-keys: |
ccache-${{ matrix.os }}-${{ env.CC }}-${{ matrix.test }}-
@ -166,7 +193,7 @@ jobs:
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Logs ${{ github.job }}
path: config.log

View File

@ -2,6 +2,10 @@ name: macOS
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }}
@ -18,18 +22,21 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
macos:
strategy:
matrix:
os: [macos-latest, macos-14]
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: macos-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 20
env:
TEST: macos
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/Library/Caches/ccache
key: ccache-${{ runner.os }}-${{ github.sha }}
@ -44,7 +51,7 @@ jobs:
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Logs ${{ github.job }}
path: config.log

View File

@ -2,6 +2,10 @@ name: SonarCloud
on: [push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
@ -17,7 +21,7 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
sonarcloud:
needs: pre-check
@ -26,14 +30,13 @@ jobs:
env:
TEST: sonarcloud
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cache/ccache
~/.sonar-cache
key: ccache-sonarcloud-${{ github.sha }}
restore-keys: |
ccache-sonarcloud-
@ -41,24 +44,17 @@ jobs:
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
# using SonarSource/sonarcloud-github-action is currently not recommended
# for C builds, so we follow the "any CI" instructions
- name: Install sonar-scanner
- uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6.0.0
- run: |
echo "BUILD_WRAPPER_OUT_DIR=$HOME/bw-output" >> $GITHUB_ENV
- uses: ./.github/actions/default
- uses: SonarSource/sonarqube-scan-action@v6.0.0
env:
SONAR_SCANNER_VERSION: 4.6.2.2472
run: |
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ github.run_id }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }}
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
uses: ./.github/actions/default
with:
args: >
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT }}
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.cfamily.threads=2
-Dsonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json
- run: ccache -s

View File

@ -2,6 +2,10 @@ name: TKM
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_CONTAINER: /root/.ccache
@ -18,7 +22,7 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
tkm:
needs: pre-check
@ -27,8 +31,8 @@ jobs:
env:
TEST: tkm
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-tkm-${{ github.sha }}

View File

@ -2,6 +2,10 @@ name: Windows
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }}
@ -21,7 +25,7 @@ jobs:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
concurrent_skipping: 'same_content_newer'
cross-compile:
needs: pre-check
@ -34,8 +38,8 @@ jobs:
OS_NAME: linux
TEST: ${{ matrix.test }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ runner.os }}-${{ matrix.test }}-${{ github.sha }}
@ -48,7 +52,7 @@ jobs:
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Logs ${{ github.job }}
path: config.log

3
.gitignore vendored
View File

@ -27,6 +27,7 @@ libtool
y.tab.[ch]
lex.yy.c
*keywords.c
!proposal_keywords.c
plugin_constructors.c
Doxyfile
apidoc/
@ -38,6 +39,7 @@ fuzzing-corpora/
*.tar.bz2
*.tar.gz
.DS_Store
._.DS_Store
coverage/
*.gcno
*.gcda
@ -53,3 +55,4 @@ coverage/
/*.includes
test-driver
nbproject/
*.[si]

View File

@ -1,3 +1,3 @@
Please refer to the [developer documentation](https://docs.strongswan.org/docs/5.9/devs/devs.html)
Please refer to the [developer documentation](https://docs.strongswan.org/docs/latest/devs/devs.html)
in our documentation for details regarding **code style** and
[**contribution requirements**](https://docs.strongswan.org/docs/5.9/devs/contributions.html).
[**contribution requirements**](https://docs.strongswan.org/docs/latest/devs/contributions.html).

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@ the code, you need the following tools:
- autoconf
- libtool
- pkg-config
- gettext
- perl
- python
- lex/flex

View File

@ -144,4 +144,4 @@ Contents
For a more up-to-date list of recommended modules refer to:
* https://docs.strongswan.org/docs/5.9/install/kernelModules.html
* https://docs.strongswan.org/docs/latest/install/kernelModules.html

View File

@ -65,10 +65,11 @@ cov-reset: cov-reset-common
cov-report:
@mkdir $(top_builddir)/coverage
lcov -c -o $(top_builddir)/coverage/coverage.info -d $(top_builddir) \
--rc lcov_branch_coverage=1
--rc branch_coverage=1
lcov -r $(top_builddir)/coverage/coverage.info '*/tests/*' '*/suites/*' '/usr*' \
'*proposal_keywords_static.*' \
-o $(abs_top_builddir)/coverage/coverage.cleaned.info \
--rc lcov_branch_coverage=1
--rc branch_coverage=1
genhtml --num-spaces 4 --legend --branch-coverage --ignore-errors source \
-t "$(PACKAGE_STRING)" \
-o $(top_builddir)/coverage/html \

224
NEWS
View File

@ -1,3 +1,223 @@
strongswan-6.0.2
----------------
- Support for per-CPU SAs (RFC 9611) has been added (Linux 6.13+).
- Basic support for AGGFRAG mode (RFC 9347) has been added (Linux 6.14+).
- POSIX regular expressions can be used to match remote identities.
- Switching configs based on EAP-Identities is supported. Setting
`remote.eap_id` now always initiates an EAP-Identity exchange.
- On Linux, sequence numbers from acquires are used when installing SAs. This
allows handling narrowing properly.
- During rekeying, the narrowed traffic selectors are now proposed instead of
the configured ones.
- The default AH/ESP proposals contain all supported key exchange methods plus
`none` to make PFS optional and accept proposals of older peers.
- GRO for ESP in enabled for NAT-T UDP sockets, which can improve performance
if the esp4|6_offload modules are loaded.
- charon-nm sets the VPN connection as persistent, preventing NetworkManager
from tearing down the connection if the network connectivity changes.
- ML-KEM is supported via OpenSSL 3.5+.
- The wolfssl plugin is now compatible to wolfSSL's FIPS module.
- The libsoup plugin has been migrated to libsoup 3, libsoup 2 is not supported
anymore.
- The long defunct uci plugin has been removed.
- Log messages by watcher_t are now logged in a separate log group (`wch`).
strongswan-6.0.1
----------------
- The ha plugin supports IKE and Child SAs with multiple key exchanges.
Incomplete IKE_SAs are now destroyed during a failover.
- The new `interface_receive` option for the dhcp plugin allows binding the
receive socket to a different interface than the send socket. Also fixed a
regression if the DHCP server is running on the same host.
- The new `source` option for the eap-radius plugin allows sending RADIUS
messages from a specific IP address.
- Self-signed root CAs without policies are now excluded from policy validation.
- Inbound traffic on IPsec SAs is now ignored when sending DPDs unless
UDP-encapsulation is used.
- Send IKE_SA_INIT from NAT-T socket if not connecting to port 500.
- Local traffic selectors can be configured for charon-nm. Its default
retransmission settings have been set to those of the Android app.
- The vici Python wheel is now built via `build` frontend instead of calling
setup.py directly if --enable-python-wheels is used (the option to build eggs
has been removed). There is no option to automatically install the wheel (use
pip instead) and the --enable-python-eggs-install option has been removed.
strongswan-6.0.0
----------------
- Support of multiple post-quantum (and classic) key exchanges using the
IKE_INTERMEDIATE exchange (RFC 9242) and the Additional Key Exchange
transform types 1..7 (RFC 9370).
- ML-KEM is provided by the botan, wolfssl, openssl (only via AWS-LC) and the
new ml plugins.
- Handling of CHILD_SA rekey collisions has been improved, which makes CHILD_SAs
properly trackable via chiled_rekey() hook.
- The behavior when reloading or unloading connections that include `start` in
their `start_action` has been improved.
- The default identity is now the subject DN instead of the IP address if a
certificate is available.
- The file logger supports logging as JSON objects and can add timestamps
in microseconds.
- The cert-enroll script now supports three generations of CA certificates.
- charon-nm uses a different routing table than the regular IKE daemon to avoid
conflicts if both are running.
- AF_VSOCK sockets are supported on Linux to communicate with a daemon that runs
in a VM.
- TUN devices can properly handle IPv6 addresses.
- For compatibility with older SCEP implementations, challenge passwords in
PKCS#10 containers are again encoded as PrintableString if possible.
- The legacy stroke plugin is no longer enabled by default.
- The openssl plugin is now enabled by default, while the following crypto
plugins are no longer enabled by default: aes, curve25519, des, fips-prf, gmp,
hmac, md5, pkcs12, rc2, sha1, sha2.
- The following deprecated plugins have been removed: bliss, newhope, ntru.
- charon.make_before_break is now enabled by default.
strongswan-5.9.14
-----------------
- Support for the IKEv2 OCSP extensions (RFC 4806) has been added, which allows
peers to request and send OCSP responses directly in IKEv2.
- Validation of X.509 name constraints in the constraints plugin has been
refactored to align with RFC 5280.
- The dhcp plugin has been ported to FreeBSD/macOS.
- The openssl plugin is now compatible with AWS-LC.
- Overflows of unique identifiers (e.g. Netlink sequence numbers or reqids) are
now handled gracefully.
- Updated the pkcs11.h header based on the latest OpenSC version in order to
include new algorithm and struct definitions for the pkcs11 plugin.
Added support for PSS padding in smartcard-based RSA signatures using either
on-chip or external data hashing.
- Added keyid and certid handles in the pki --ocsp command so that keys and/or
certificates can be stored on a smartcard or in a TPM 2.0 device.
- Fail SA installation on Linux if replay protection is disabled while ESN is
enabled, which the kernel currently doesn't support.
strongswan-5.9.13
-----------------
- Fixes a regression with handling OCSP error responses and adds a new
option to specify the length of nonces in OCSP requests. Also adds some
other improvements for OCSP handling and fuzzers for OCSP
requests/responses.
strongswan-5.9.12
-----------------
- Fixed a vulnerability in charon-tkm related to processing DH public values
that can lead to a buffer overflow and potentially remote code execution.
This vulnerability has been registered as CVE-2023-41913.
- The new `pki --ocsp` command produces OCSP responses based on certificate
status information provided by plugins.
Two sources are currently available, the openxpki plugin that directly
accesses the OpenXPKI database and the `--index` argument, which reads
certificate status information from OpenSSL-style index.txt files.
- The cert-enroll script handles the initial enrollment of an X.509 host
certificate with a PKI server via the EST or SCEP protocols.
Run as a systemd timer or via a crontab entry the script daily checks the
expiration date of the host certificate. When a given deadline is reached,
the host certificate is automatically renewed via EST or SCEP re-enrollment
based on the possession of the old private key and the matching certificate.
- The --priv argument for charon-cmd allows using any type of private key.
- Support for nameConstraints of type iPAddress has been added (the openssl
plugin previously didn't support nameConstraints at all).
- SANs of type uniformResourceIdentifier can now be encoded in certificates.
- Password-less PKCS#12 and PKCS#8 files are supported.
- A new global option allows preventing peers from authenticating with trusted
end-entity certificates (i.e. local certificates).
- ECDSA public keys that encode curve parameters explicitly are now rejected by
all plugins that support ECDSA.
- charon-nm now actually uses the XFRM interfaces added with 5.9.10, it can
also use the name in connection.interface-name.
- The resolve plugin tries to maintain the order of installed DNS servers.
- The kernel-libipsec plugin always installs routes even if no address is found
in the local traffic selectors.
- Increased the default receive buffer size for Netlink sockets to 8 MiB and
simplified its configuration.
- Copy the issuer's subjectKeyIdentifier as authorityKeyIdentifier instead of
always generating a hash of the subjectPublicKey.
- Fixed issues while reestablishing multiple CHILD_SAs (e.g. after a DPD
timeout) that could cause a reqid to get assigned to multiple CHILD_SAs with
unrelated traffic selectors.
- Fixed a possible infinite loop issue in watcher_t and removed WATCHER_EXCEPT,
instead callbacks are always invoked even if only errors are signaled.
- Fixed a regression in the IKE_SA_INIT tracking code added with 5.9.6 when
handling invalid messages.
- Fixed adding the XFRMA_REPLAY_ESN_VAL attribute twice when updating SAs.
- Correctly encode SPI from REKEY_SA notify in CHILD_SA_NOT_FOUND notify if
CHILD_SA is not found during rekeying.
- The testing environment is now based on Debian 12 (bookworm), by default.
strongswan-5.9.11
-----------------
@ -256,7 +476,7 @@ strongswan-5.9.4
salt lengths.
This vulnerability has been registered as CVE-2021-41990.
- Fixed a denial-of-service vulnerabililty in the in-memory certificate cache
- Fixed a denial-of-service vulnerability in the in-memory certificate cache
if certificates are replaced and a very large random value caused an integer
overflow.
This vulnerability has been registered as CVE-2021-41991.
@ -1668,7 +1888,7 @@ strongswan-5.0.3
PT-TLS (RFC 6876), a Posture Transport Protocol over TLS.
- The charon systime-fix plugin can disable certificate lifetime checks on
embedded systems if the system time is obviously out of sync after bootup.
embedded systems if the system time is obviously out of sync after boot-up.
Certificates lifetimes get checked once the system time gets sane, closing
or reauthenticating connections using expired certificates.

View File

@ -566,7 +566,7 @@ to generate a traditional 3072 bit RSA key and store it in binary DER format.
As an alternative a **TPM 2.0** *Trusted Platform Module* available on every
recent Intel platform could be used as a virtual smartcard to securely store an
RSA or ECDSA private key. For details, refer to the TPM 2.0
[HOWTO](https://docs.strongswan.org/docs/5.9/tpm/tpm2.html).
[HOWTO](https://docs.strongswan.org/docs/latest/tpm/tpm2.html).
In a next step the command

View File

@ -16,6 +16,7 @@ options = \
options/charon-systemd.opt \
options/imcv.opt \
options/imv_policy_manager.opt \
options/iptfs.opt \
options/manager.opt \
options/medsrv.opt \
options/pki.opt \
@ -31,7 +32,6 @@ plugins = \
plugins/android_log.opt \
plugins/attr.opt \
plugins/attr-sql.opt \
plugins/bliss.opt \
plugins/botan.opt \
plugins/bypass-lan.opt \
plugins/certexpire.opt \
@ -77,8 +77,8 @@ plugins = \
plugins/kernel-pfroute.opt \
plugins/load-tester.opt \
plugins/lookip.opt \
plugins/ntru.opt \
plugins/openssl.opt \
plugins/openxpki.opt \
plugins/osx-attr.opt \
plugins/p-cscf.opt \
plugins/pkcs11.opt \

View File

@ -55,14 +55,6 @@ man pages) the following format can be used:
full.section.name.include files/to/include
Description of this include statement
Dots in section/option names may be escaped with a backslash. For instance,
with the following section description
charon.filelog./var/log/daemon\.log {}
Section to define logging into /var/log/daemon.log
/var/log/daemon.log will be the name of the last section.
"""
import sys
@ -74,10 +66,10 @@ from functools import cmp_to_key, total_ordering
@total_ordering
class ConfigOption:
"""Representing a configuration option or described section in strongswan.conf"""
def __init__(self, path, default = None, section = False, commented = False, include = False):
self.path = path
self.name = path[-1]
self.fullname = '.'.join(path)
def __init__(self, fullname, default = None, section = False, commented = False, include = False):
self.path = fullname.split('.')
self.name = self.path[-1]
self.fullname = fullname
self.default = default
self.section = section
self.commented = commented
@ -141,8 +133,7 @@ class Parser:
if m:
if self.__current:
self.__add_option(self.__current)
path = self.__split_name(m.group('name'))
self.__current = ConfigOption(path, m.group('default'),
self.__current = ConfigOption(m.group('name'), m.group('default'),
commented = not m.group('assign'))
return
# section definition
@ -150,8 +141,7 @@ class Parser:
if m:
if self.__current:
self.__add_option(self.__current)
path = self.__split_name(m.group('name'))
self.__current = ConfigOption(path, section = True,
self.__current = ConfigOption(m.group('name'), section = True,
commented = m.group('comment'))
return
# include definition
@ -159,8 +149,7 @@ class Parser:
if m:
if self.__current:
self.__add_option(self.__current)
path = self.__split_name(m.group('name'))
self.__current = ConfigOption(path, m.group('pattern'), include = True)
self.__current = ConfigOption(m.group('name'), m.group('pattern'), include = True)
return
# paragraph separator
m = re.match(r'^\s*$', line)
@ -171,10 +160,6 @@ class Parser:
if m and self.__current:
self.__current.add(m.group('text'))
def __split_name(self, name):
"""Split the given full name in a list of section/option names"""
return [x.replace('\.', '.') for x in re.split(r'(?<!\\)\.', name)]
def __add_option(self, option):
"""Adds the given option to the abstract storage"""
option.desc = [desc for desc in option.desc if len(desc)]
@ -194,12 +179,14 @@ class Parser:
"""Searches/Creates the option (section) based on a list of section names"""
option = None
options = self.options
for i, name in enumerate(path, 1):
fullname = ""
for name in path:
fullname += '.' + name if len(fullname) else name
option = next((x for x in options if x.name == name and x.section), None)
if not option:
if not create:
break
option = ConfigOption(path[:i], section = True)
option = ConfigOption(fullname, section = True)
options.append(option)
if self.sort:
options.sort()
@ -208,7 +195,7 @@ class Parser:
def get_option(self, name):
"""Retrieves the option with the given name"""
return self.__get_option(self.__split_name(name))
return self.__get_option(name.split('.'))
class TagReplacer:
"""Replaces formatting tags in text"""
@ -254,6 +241,7 @@ class GroffTagReplacer(TagReplacer):
if not punct:
punct = ''
text = re.sub(r'[\r\n\t]', ' ', m.group('text'))
text = re.sub(r'"', '""', text)
return '{0}.R{1} "{2}" "{3}" "{4}"\n'.format(nl, format, brack, text, punct)
return replacer
@ -318,7 +306,8 @@ class ManFormatter:
def __groffize(self, text):
"""Encode text as groff text"""
text = self.__tags.replace(text)
text = re.sub(r'(?<!\\)-', r'\\-', text)
text = re.sub(r'\\(?!-)', '\\[rs]', text)
text = re.sub(r'(?<!\\)-', '\\-', text)
# remove any leading whitespace
return re.sub(r'^\s+', '', text, flags = re.MULTILINE)

View File

@ -26,8 +26,18 @@ charon.filelog.<name>.flush_line = no
Enabling this option disables block buffering and enables line buffering.
charon.filelog.<name>.ike_name = no
Prefix each log entry with the connection name and a unique numerical
identifier for each IKE_SA.
Add the connection name and a unique numerical identifier for the current
IKE_SA to each log entry if available.
charon.filelog.<name>.json = no
If enabled, each log entry is written to the file as a JSON object.
Enables writing each log entry as a JSON object to the file. The properties
are "time" (if `time_format` is set), "thread", "group", "level" and "msg".
Newlines, double quotes and backslashes are escaped in the latter. If
`ike_name` is enabled, "ikesa-uniqueid" and "ikesa-name" are added to the
object if available. The `log_level` option does not apply if this is
enabled.
charon.filelog.<name>.log_level = no
Add the log level of each message after the subsystem (e.g. [IKE2]).
@ -36,9 +46,10 @@ charon.filelog.<name>.time_format
Prefix each log entry with a timestamp. The option accepts a format string
as passed to **strftime**(3).
charon.filelog.<name>.time_add_ms = no
Adds the milliseconds within the current second after the timestamp
(separated by a dot, so _time_format_ should end with %S or %T).
charon.filelog.<name>.time_precision =
Add the milliseconds (_ms_) or microseconds (_us_) within the current second
after the timestamp (separated by a dot, so _time_format_ should end
with %S or %T). By default, nothing is added.
charon.syslog {}
Section to define syslog loggers, see LOGGER CONFIGURATION in

View File

@ -1,6 +1,55 @@
charon-nm {}
Section with settings specific to the NetworkManager backend `charon-nm`.
Settings from the `charon` section are not inherited, but many can be used
here as well. Defaults for some settings are chosen very deliberately and
should only be changed in case of conflicts.
charon-nm.ca_dir = <default>
Directory from which to load CA certificates if no certificate is
configured.
charon-nm.install_virtual_ip_on = lo
Interface on which virtual IP addresses are installed. Note that NM
also installs the virtual IPs on the XFRM interface.
charon-nm.mtu = 1400
MTU for XFRM interfaces created by the NM plugin.
charon-nm.port = 0
Source port when sending packets to port 500. Defaults to an ephemeral
port. May be set to 500 if firewall rules require a static port.
charon-nm.port_nat_t = 0
Source port when sending packets to port 4500 or a custom server port.
Defaults to an ephemeral port. May be set to e.g. 4500 if firewall rules
require a static port.
charon-nm.retransmit_base = 1.4
Base to use for calculating exponential back off, see IKEv2 RETRANSMISSION
in **strongswan.conf**(5). Default retransmission settings for charon-nm are
deliberately lower to fail and possibly reestablish SAs more quickly.
charon-nm.retransmit_timeout = 2.0
Timeout in seconds before sending first retransmit.
charon-nm.retransmit_tries = 3
Number of times to retransmit a packet before giving up.
charon-nm.routing_table = 210
Table where routes via XFRM interface are installed. Should be different
than the table used for the regular IKE daemon due to the mark.
charon-nm.routing_table_prio = 210
Priority of the routing table. Higher than the default priority used for the
regular IKE daemon.
charon-nm.plugins.kernel-netlink.fwmark = !210
Make packets with this mark ignore the routing table. Must be the same mark
set in charon-nm.plugins.socket-default.fwmark.
charon-nm.plugins.socket-default.fwmark = 210
Mark applied to IKE and ESP packets to ignore the routing table and avoid
routing loops when using XFRM interfaces.
charon-nm.syslog.daemon.default = 1
Default to logging via syslog's daemon facility on level 1.

View File

@ -154,8 +154,16 @@ charon.fragment_size = 1280
Maximum size (complete IP datagram size in bytes) of a sent IKE fragment
when using proprietary IKEv1 or standardized IKEv2 fragmentation, defaults
to 1280 (use 0 for address family specific default values, which uses a
lower value for IPv4). If specified this limit is used for both IPv4 and
IPv6.
lower value for IPv4). Unless overridden, this limit is used for both IPv4
and IPv6 if specified.
charon.fragment_size_v4 = charon.fragment_size
Maximum size (complete IPv4 datagram size in bytes) of a sent IKE fragment
when using proprietary IKEv1 or standardized IKEv2 fragmentation.
charon.fragment_size_v6 = charon.fragment_size
Maximum size (complete IPv6 datagram size in bytes) of a sent IKE fragment
when using proprietary IKEv1 or standardized IKEv2 fragmentation.
charon.group
Name of the group the daemon changes to after startup.
@ -283,7 +291,7 @@ charon.max_ikev1_exchanges = 3
charon.max_packet = 10000
Maximum packet size accepted by charon.
charon.make_before_break = no
charon.make_before_break = yes
Initiate IKEv2 reauthentication with a make-before-break scheme.
Initiate IKEv2 reauthentication with a make-before-break instead of a
@ -302,6 +310,13 @@ charon.nbns1
charon.nbns2
WINS servers assigned to peer via configuration payload (CP).
charon.ocsp_nonce_len = 32
Length of nonces in OCSP requests (1-32).
Length of nonces in OCSP requests. According to RFC 8954, valid values are
between 1 and 32, with new clients required to use 32. Some servers might
not support that so lowering the value to e.g. 16 might be necessary.
charon.port = 500
UDP port used locally. If set to 0 a random port will be allocated.
@ -372,6 +387,10 @@ charon.receive_delay_request = yes
charon.receive_delay_type = 0
Specific IKEv2 message type to delay, 0 for any.
charon.reject_trusted_end_entity = no
Reject peers that use trusted end-entity certificates (i.e. local
certificates).
charon.replay_window = 32
Size of the AH/ESP replay window, in packets.

38
conf/options/iptfs.opt Normal file
View File

@ -0,0 +1,38 @@
charon.iptfs {}
Global settings for IP-TFS (RFC 9347). The Linux kernel supports this mode
since 6.14. However, it currently only supports aggregation/fragmentation of
tunneled IP packets in ESP/AGGFRAG packets. It doesn't yet support other
IP-TFS features like sending packets at a constant rate or congestion control.
charon.iptfs.drop_time = 1000000
Time in microseconds to wait for out-of-order packets when processing
inbound traffic.
charon.iptfs.reorder_window = 3
Number of packets that may arrive out of order when processing inbound
traffic.
charon.iptfs.init_delay = 0
Time in microseconds to wait for subsequent packets to aggregate together
when sending outbound traffic. Only relevant if no packets are already
queued to be sent.
charon.iptfs.max_queue_size = 1048576
Maximum number of bytes allowed to be queued for sending on the tunnel
(default 1 MiB). If the queue is full, packets are dropped.
charon.iptfs.packet_size = 0
Maximum outer packet size (layer 3) when sending packets. The default of 0
will use the PMTU as packet size. Note that the kernel currently doesn't
pad smaller packets.
charon.iptfs.accept_fragments = yes
Whether fragments of inner packets across multiple AGGFRAG payloads are
accepted. This is an IKEv2 option, so if the peer doesn't adhere to this
request and still sends such fragments, they will be processed by the
kernel.
charon.iptfs.dont_frag = no
Force disabling fragmenting inner packets across multiple AGGFRAG payloads
when sending outbound traffic (fragmentation is automatically disabled if
the peer indicates that it doesn't support handling such packets).

View File

@ -1,2 +0,0 @@
charon.plugins.bliss.use_bliss_b = yes
Use the enhanced BLISS-B key generation and signature algorithm.

View File

@ -36,3 +36,13 @@ charon.plugins.dhcp.interface
Interface name the plugin uses for address allocation. The default is to
bind to any (0.0.0.0) and let the system decide which way to route the
packets to the DHCP server.
charon.plugins.dhcp.interface_receive = charon.plugins.dhcp.interface
Interface name the plugin uses to bind its receive socket.
Interface name the plugin uses to bind its receive socket. The default is
to use the same interface as the send socket. Set it to the empty string
to avoid binding the receive socket to any interface while the send socket
is bound to one. If the server runs on the same host and the send socket is
bound to an interface, it might be necessary to set this to `lo` or the
empty string.

View File

@ -84,6 +84,9 @@ charon.plugins.eap-radius.secret =
charon.plugins.eap-radius.server =
IP/Hostname of RADIUS server.
charon.plugins.eap-radius.source =
Optional specific source IP to use.
charon.plugins.eap-radius.retransmit_base = 1.4
Base to use for calculating exponential back off.
@ -96,12 +99,12 @@ charon.plugins.eap-radius.retransmit_tries = 4
charon.plugins.eap-radius.servers {}
Section to specify multiple RADIUS servers.
Section to specify multiple RADIUS servers. The **nas_identifier**,
**secret**, **sockets** and **port** (or **auth_port**) options can be
specified for each server. A server's IP/Hostname can be configured using
the **address** option. The **acct_port** [1813] option can be used to
specify the port used for RADIUS accounting. For each RADIUS server a
priority can be specified using the **preference** [0] option. The
Section to specify multiple RADIUS servers. The **source**,
**nas_identifier**, **secret**, **sockets** and **port** (or **auth_port**)
options can be specified for each server. A server's IP/Hostname can be
configured using the **address** option. The **acct_port** [1813] option can
be used to specify the port used for RADIUS accounting. For each RADIUS
server a priority can be specified using the **preference** [0] option. The
retransmission time for each server can set set using **retransmit_base**,
**retransmit_timeout** and **retransmit_tries**.

View File

@ -1,4 +0,0 @@
charon.plugins.ntru.parameter_set = optimum
The following parameter sets are available: **x9_98_speed**,
**x9_98_bandwidth**, **x9_98_balance** and **optimum**, the last set not
being part of the X9.98 standard but having the best performance.

View File

@ -0,0 +1,4 @@
charon.plugins.openxpki.database =
Database URI connecting to the OpenXPKI **certificate** database. If it
contains a password, make sure to adjust the permissions of the config
file accordingly.

View File

@ -30,3 +30,8 @@ charon.plugins.pkcs11.use_pubkey = no
charon.plugins.pkcs11.use_rng = no
Whether the PKCS#11 modules should be used as RNG.
charon.plugins.pkcs11.use_rsa_pss_hashers = no
Whether the PKCS#11 modules should try to use internal hashing for RSA-PSS
signatures (some PKCS#11 libraries don't implement internal hashing
in conjunction with RSA-PSS correctly).

View File

@ -20,7 +20,7 @@
# initialize & set some vars
# ============================
AC_INIT([strongSwan],[5.9.11])
AC_INIT([strongSwan],[6.0.3dr1])
AM_INIT_AUTOMAKE(m4_esyscmd([
echo tar-ustar
echo subdir-objects
@ -33,21 +33,18 @@ AM_INIT_AUTOMAKE(m4_esyscmd([
esac
]))
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
AC_CONFIG_MACRO_DIR([m4/config])
AC_CONFIG_MACRO_DIRS([m4/config m4/macros])
AC_CONFIG_HEADERS([config.h])
AC_DEFINE([CONFIG_H_INCLUDED], [], [defined if config.h included])
AC_DISABLE_STATIC
PKG_PROG_PKG_CONFIG
m4_include(m4/macros/split-package-version.m4)
SPLIT_PACKAGE_VERSION
# =================================
# check --enable-xxx & --with-xxx
# =================================
m4_include(m4/macros/with.m4)
ARG_WITH_SUBST([random-device], [/dev/random], [set the device to read real random data from])
ARG_WITH_SUBST([urandom-device], [/dev/urandom], [set the device to read pseudo random data from])
ARG_WITH_SUBST([strongswan-conf], [${sysconfdir}/strongswan.conf], [set the strongswan.conf file location])
@ -70,7 +67,7 @@ ARG_WITH_SET([mpz_powm_sec], [yes], [use the more side-channel resistant
ARG_WITH_SET([dev-headers], [no], [install strongSwan development headers to directory.])
ARG_WITH_SET([printf-hooks], [auto], [force the use of a specific printf hook implementation (auto, builtin, glibc, vstr).])
ARG_WITH_SET([rubygemdir], ["gem environment gemdir"], [path to install ruby gems to])
ARG_WITH_SET([pythoneggdir], ["main site-packages directory"], [path to install python eggs to to])
ARG_WITH_SET([testable-ke], [yes], [make key exchange implementations testable by providing a set_seed() method])
if test -n "$PKG_CONFIG"; then
systemdsystemunitdir_default=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
@ -129,42 +126,38 @@ fi
# convert script name to uppercase
AC_SUBST(ipsec_script_upper, [`echo -n "$ipsec_script" | tr a-z A-Z`])
m4_include(m4/macros/enable-disable.m4)
# crypto plugins
ARG_DISBL_SET([aes], [disable AES software implementation plugin.])
ARG_ENABL_SET([aes], [enable AES software implementation plugin.])
ARG_ENABL_SET([af-alg], [enable AF_ALG crypto interface to Linux Crypto API.])
ARG_ENABL_SET([bliss], [enable BLISS software implementation plugin.])
ARG_ENABL_SET([blowfish], [enable Blowfish software implementation plugin.])
ARG_ENABL_SET([botan], [enables the Botan crypto plugin.])
ARG_ENABL_SET([ccm], [enables the CCM AEAD wrapper crypto plugin.])
ARG_ENABL_SET([chapoly], [enables the ChaCha20/Poly1305 AEAD plugin.])
ARG_DISBL_SET([cmac], [disable CMAC crypto implementation plugin.])
ARG_ENABL_SET([ctr], [enables the Counter Mode wrapper crypto plugin.])
ARG_DISBL_SET([des], [disable DES/3DES software implementation plugin.])
ARG_ENABL_SET([des], [enable DES/3DES software implementation plugin.])
ARG_DISBL_SET([drbg], [disable the NIST Deterministic Random Bit Generator plugin.])
ARG_DISBL_SET([fips-prf], [disable FIPS PRF software implementation plugin.])
ARG_DISBL_SET([gcm], [disable the GCM AEAD wrapper crypto plugin.])
ARG_ENABL_SET([fips-prf], [enable FIPS PRF software implementation plugin.])
ARG_ENABL_SET([gcm], [enable the GCM AEAD wrapper crypto plugin.])
ARG_ENABL_SET([gcrypt], [enables the libgcrypt plugin.])
ARG_DISBL_SET([gmp], [disable GNU MP (libgmp) based crypto implementation plugin.])
ARG_DISBL_SET([curve25519], [disable Curve25519 Diffie-Hellman plugin.])
ARG_DISBL_SET([hmac], [disable HMAC crypto implementation plugin.])
ARG_ENABL_SET([gmp], [enable GNU MP (libgmp) based crypto implementation plugin.])
ARG_ENABL_SET([curve25519], [enable Curve25519 Diffie-Hellman plugin.])
ARG_ENABL_SET([hmac], [enable HMAC crypto implementation plugin.])
ARG_DISBL_SET([kdf], [disable KDF (prf+) implementation plugin.])
ARG_ENABL_SET([md4], [enable MD4 software implementation plugin.])
ARG_DISBL_SET([md5], [disable MD5 software implementation plugin.])
ARG_ENABL_SET([md5], [enable MD5 software implementation plugin.])
ARG_ENABL_SET([mgf1], [enable the MGF1 software implementation plugin.])
ARG_ENABL_SET([newhope], [enable New Hope crypto plugin.])
ARG_ENABL_SET([ml], [enable Module-Lattice-based crypto (ML-KEM) plugin.])
ARG_DISBL_SET([nonce], [disable nonce generation plugin.])
ARG_ENABL_SET([ntru], [enables the NTRU crypto plugin.])
ARG_ENABL_SET([openssl], [enables the OpenSSL crypto plugin.])
ARG_DISBL_SET([openssl], [disable the OpenSSL crypto plugin.])
ARG_ENABL_SET([wolfssl], [enables the wolfSSL crypto plugin.])
ARG_ENABL_SET([padlock], [enables VIA Padlock crypto plugin.])
ARG_DISBL_SET([random], [disable RNG implementation on top of /dev/(u)random.])
ARG_DISBL_SET([rc2], [disable RC2 software implementation plugin.])
ARG_ENABL_SET([rc2], [enable RC2 software implementation plugin.])
ARG_ENABL_SET([rdrand], [enable Intel RDRAND random generator plugin.])
ARG_ENABL_SET([aesni], [enable Intel AES-NI crypto plugin.])
ARG_DISBL_SET([sha1], [disable SHA1 software implementation plugin.])
ARG_DISBL_SET([sha2], [disable SHA256/SHA384/SHA512 software implementation plugin.])
ARG_ENABL_SET([sha1], [enable SHA1 software implementation plugin.])
ARG_ENABL_SET([sha2], [enable SHA256/SHA384/SHA512 software implementation plugin.])
ARG_ENABL_SET([sha3], [enable SHA3_224/SHA3_256/SHA3_384/SHA3_512 software implementation plugin.])
ARG_DISBL_SET([xcbc], [disable xcbc crypto implementation plugin.])
# encoding/decoding plugins
@ -174,10 +167,11 @@ ARG_DISBL_SET([pgp], [disable PGP key decoding plugin.])
ARG_DISBL_SET([pkcs1], [disable PKCS1 key decoding plugin.])
ARG_DISBL_SET([pkcs7], [disable PKCS7 container support plugin.])
ARG_DISBL_SET([pkcs8], [disable PKCS8 private key decoding plugin.])
ARG_DISBL_SET([pkcs12], [disable PKCS12 container support plugin.])
ARG_ENABL_SET([pkcs12], [enable PKCS12 container support plugin.])
ARG_DISBL_SET([pubkey], [disable RAW public key support plugin.])
ARG_DISBL_SET([sshkey], [disable SSH key decoding plugin.])
ARG_DISBL_SET([x509], [disable X509 certificate implementation plugin.])
ARG_ENABL_SET([openxpki], [enable OCSP responder accessing OpenXPKI certificate database.])
# fetcher/resolver plugins
ARG_ENABL_SET([curl], [enable CURL fetcher plugin to fetch files via libcurl. Requires libcurl.])
ARG_ENABL_SET([files], [enable simple file:// URI fetcher.])
@ -236,10 +230,9 @@ ARG_DISBL_SET([socket-default], [disable default socket implementation for charo
ARG_ENABL_SET([socket-dynamic], [enable dynamic socket implementation for charon])
ARG_ENABL_SET([socket-win], [enable Winsock2 based socket implementation for charon])
# configuration/control plugins
ARG_DISBL_SET([stroke], [disable charons stroke configuration backend.])
ARG_ENABL_SET([stroke], [enable the stroke configuration backend.])
ARG_ENABL_SET([smp], [enable SMP configuration and control interface. Requires libxml.])
ARG_ENABL_SET([sql], [enable SQL database configuration backend.])
ARG_ENABL_SET([uci], [enable OpenWRT UCI configuration plugin.])
ARG_DISBL_SET([vici], [disable strongSwan IKE generic IPC interface plugin.])
# attribute provider/consumer plugins
ARG_ENABL_SET([android-dns], [enable Android specific DNS handler.])
@ -307,6 +300,7 @@ ARG_ENABL_SET([svc], [enable charon Windows service.])
ARG_ENABL_SET([systemd], [enable systemd specific IKE daemon charon-systemd.])
ARG_DISBL_SET([swanctl], [disable swanctl configuration and control tool.])
ARG_ENABL_SET([tkm], [enable Trusted Key Manager support.])
ARG_ENABL_SET([cert-enroll], [enable automatic certificate enrollment via EST or SCEP.])
# optional features
ARG_ENABL_SET([bfd-backtraces], [use binutils libbfd to resolve backtraces for memory leaks and segfaults.])
ARG_ENABL_SET([dbghelp-backtraces],[use dbghlp.dll on Windows to create and print backtraces for memory leaks and segfaults.])
@ -318,13 +312,14 @@ ARG_ENABL_SET([mediation], [enable IKEv2 Mediation Extension.])
ARG_ENABL_SET([unwind-backtraces],[use libunwind to create backtraces for memory leaks and segfaults.])
ARG_ENABL_SET([ruby-gems], [enable build of provided ruby gems.])
ARG_ENABL_SET([ruby-gems-install],[enable installation of provided ruby gems.])
ARG_ENABL_SET([python-eggs], [enable build of provided python eggs.])
ARG_ENABL_SET([python-eggs-install],[enable installation of provided python eggs.])
ARG_ENABL_SET([python-wheels], [enable build of provided python wheels.])
ARG_ENABL_SET([python-eggs], [legacy alias for --enable-python-wheels.])
ARG_ENABL_SET([perl-cpan], [enable build of provided perl CPAN module.])
ARG_ENABL_SET([perl-cpan-install],[enable installation of provided CPAN module.])
ARG_ENABL_SET([selinux], [enable SELinux support for labeled IPsec.])
ARG_ENABL_SET([tss-trousers], [enable the use of the TrouSerS Trusted Software Stack])
ARG_ENABL_SET([tss-tss2], [enable the use of the TSS 2.0 Trusted Software Stack])
ARG_ENABL_SET([cert-enroll-timer],[enable installation of cert-enroll as a systemd timer.])
# compile options
ARG_ENABL_SET([asan], [enable build with AddressSanitizer (ASan).])
@ -467,6 +462,10 @@ if test x$fips_prf = xtrue; then
fi
fi
if test x$pkcs12 = xtrue; then
rc2=true;
fi
if test x$swanctl = xtrue; then
vici=true
fi
@ -492,8 +491,8 @@ if test x$ruby_gems_install = xtrue; then
ruby_gems=true
fi
if test x$python_eggs_install = xtrue; then
python_eggs=true
if test x$python_eggs = xtrue; then
python_wheels=true
fi
if test x$perl_cpan_install = xtrue; then
@ -508,24 +507,41 @@ if test x$tpm = xtrue; then
tss_tss2=true
fi
if test x$gmp = xtrue -o x$ntru = xtrue -o x$bliss = xtrue; then
if test x$gmp = xtrue; then
mgf1=true
fi
if test x$stroke = xtrue; then
if test x$stroke = xtrue -o x$vici = xtrue; then
counters=true
fi
if test x$cert_enroll = xtrue; then
pki=true
fi
if test x$kdf = xfalse; then
openssl_hkdf=false
if test x$openssl = xtrue; then
AC_MSG_CHECKING(for OpenSSL >= 3.0 for HKDF)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <openssl/opensslv.h>]],
[[#if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined(OPENSSL_IS_AWSLC)
#error OpenSSL version unusable
#endif]])],
[AC_MSG_RESULT([yes]); openssl_hkdf=true],
[AC_MSG_RESULT([no])]
)
fi
if test x$aesni = xtrue -o x$cmac = xtrue -o x$xcbc = xtrue; then
AC_MSG_WARN(m4_normalize([
kdf plugin is required for possible use of PRF_AES128_XCBC/CMAC
by one of these plugins: aesni, cmac, xcbc]))
kdf=true
elif test x$botan = xfalse -a x$openssl = xfalse -a x$wolfssl = xfalse; then
elif test x$botan = xfalse -a x$openssl_hkdf = xfalse -a x$wolfssl = xfalse; then
AC_MSG_WARN(m4_normalize([
kdf plugin is required because none of the following plugins is
enabled: botan, openssl, wolfssl]))
enabled or usable: botan, openssl, wolfssl]))
kdf=true
fi
fi
@ -588,6 +604,10 @@ AC_LINK_IFELSE(
AC_SUBST(ATOMICLIB)
LIBS=$saved_LIBS
# Some platforms require explicit linking to use POSIX regular expressions
AC_SEARCH_LIBS([regcomp], [regex], [AC_DEFINE([HAVE_REGEX], [], [have regcomp() etc.])])
# ------------------------------------------------------
AC_MSG_CHECKING(for dladdr)
@ -706,6 +726,11 @@ AC_CHECK_HEADERS([netinet/ip6.h linux/fib_rules.h], [], [],
#include <sys/types.h>
#include <netinet/in.h>
])
AC_CHECK_HEADERS([linux/vm_sockets.h], [have_vm_sockets=true], [],
[
#include <sys/socket.h>
])
AM_CONDITIONAL(USE_VM_SOCKETS, [test "x$have_vm_sockets" = xtrue])
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [],
[
@ -744,7 +769,7 @@ AC_COMPILE_IFELSE(
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>]],
[[struct in6_pktinfo pi;
[[struct in6_pktinfo pi = {};
if (pi.ipi6_ifindex)
{
return 0;
@ -1019,7 +1044,7 @@ if test x$unbound = xtrue; then
fi
if test x$soup = xtrue; then
PKG_CHECK_MODULES(soup, [libsoup-2.4])
PKG_CHECK_MODULES(soup, [libsoup-3.0])
AC_SUBST(soup_CFLAGS)
AC_SUBST(soup_LIBS)
fi
@ -1030,14 +1055,16 @@ if test x$xml = xtrue; then
AC_SUBST(xml_LIBS)
fi
if test x$systemd = xtrue; then
if test x$systemd = xtrue -o x$cert_enroll_timer = xtrue; then
AC_MSG_CHECKING([for systemd system unit directory])
if test -n "$systemdsystemunitdir" -a "x$systemdsystemunitdir" != xno; then
AC_MSG_RESULT([$systemdsystemunitdir])
else
AC_MSG_ERROR([not found (try --with-systemdsystemunitdir)])
fi
fi
if test x$systemd = xtrue; then
PKG_CHECK_MODULES(systemd, [libsystemd >= 209],
[AC_SUBST(systemd_CFLAGS)
AC_SUBST(systemd_LIBS)],
@ -1207,15 +1234,10 @@ if test x$botan = xtrue; then
AC_SUBST(botan_LIBS)
saved_LIBS=$LIBS
LIBS="$botan_LIBS"
AC_CHECK_FUNCS(botan_rng_init_custom)
AC_CHECK_FUNCS(botan_rng_init_custom botan_pubkey_ecc_key_used_explicit_encoding)
LIBS=$saved_LIBS
fi
if test x$uci = xtrue; then
AC_CHECK_LIB([uci],[uci_alloc_context],[LIBS="$LIBS"],[AC_MSG_ERROR([UCI library libuci not found])],[])
AC_CHECK_HEADER([uci.h],,[AC_MSG_ERROR([UCI header uci.h not found!])])
fi
if test x$android_dns = xtrue; then
AC_CHECK_LIB([cutils],[property_get],[LIBS="$LIBS"],[AC_MSG_ERROR([Android library libcutils not found])],[])
AC_CHECK_HEADER([cutils/properties.h],,[AC_MSG_ERROR([Android header cutils/properties.h not found!])])
@ -1323,6 +1345,10 @@ if test x$unwind_backtraces = xtrue; then
AC_SUBST(UNWINDLIB)
fi
if test "x$testable_ke" = xyes; then
AC_DEFINE([TESTABLE_KE], [1], [Define to 1 if key exchange methods should be testable.])
fi
AM_CONDITIONAL(USE_DEV_HEADERS, [test "x$dev_headers" != xno])
if test x$dev_headers = xyes; then
dev_headers="$includedir/strongswan"
@ -1346,7 +1372,7 @@ if test x$coverage = xtrue; then
AC_MSG_ERROR([genhtml not found])
fi
COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage -fprofile-update=atomic"
COVERAGE_LDFLAGS="-fprofile-arcs"
AC_SUBST(COVERAGE_CFLAGS)
AC_SUBST(COVERAGE_LDFLAGS)
@ -1412,24 +1438,12 @@ if test x$ruby_gems = xtrue; then
fi
AM_CONDITIONAL(RUBY_GEMS_INSTALL, [test "x$ruby_gems_install" = xtrue])
if test x$python_eggs = xtrue; then
if test x$python_wheels = xtrue; then
PYTHON_PACKAGE_VERSION=`echo "$PACKAGE_VERSION" | $SED 's/dr/.dev/'`
AC_SUBST([PYTHON_PACKAGE_VERSION])
if test x$python_eggs_install = xtrue; then
AC_PATH_PROG([EASY_INSTALL], [easy_install], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
if test x$EASY_INSTALL = x; then
AC_MSG_ERROR(Python easy_install not found)
fi
fi
if test "x$pythoneggdir" = "xmain site-packages directory"; then
AC_SUBST(PYTHONEGGINSTALLDIR, "")
else
AC_SUBST(PYTHONEGGINSTALLDIR, "--install-dir $pythoneggdir")
fi
AC_PATH_PROG([TOX], [tox], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
AC_PATH_PROG([PY_TEST], [py.test], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
fi
AM_CONDITIONAL(PYTHON_EGGS_INSTALL, [test "x$python_eggs_install" = xtrue])
AM_CONDITIONAL(PERL_CPAN_INSTALL, [test "x$perl_cpan_install" = xtrue])
@ -1501,8 +1515,6 @@ CFLAGS="$WARN_CFLAGS $CFLAGS"
# collect plugin list for strongSwan components
# ===============================================
m4_include(m4/macros/add-plugin.m4)
# plugin lists for all components
charon_plugins=
pool_plugins=
@ -1544,7 +1556,7 @@ ADD_PLUGIN([random], [s charon pki scripts manager medsrv attest n
ADD_PLUGIN([nonce], [s charon nm cmd aikgen])
ADD_PLUGIN([x509], [s charon pki scripts attest nm cmd aikgen fuzz])
ADD_PLUGIN([revocation], [s charon pki nm cmd])
ADD_PLUGIN([constraints], [s charon nm cmd])
ADD_PLUGIN([constraints], [s charon pki nm cmd])
ADD_PLUGIN([acert], [s charon])
ADD_PLUGIN([pubkey], [s charon pki cmd aikgen])
ADD_PLUGIN([pkcs1], [s charon pki scripts manager medsrv attest nm cmd aikgen fuzz])
@ -1576,16 +1588,15 @@ ADD_PLUGIN([kdf], [s charon pki scripts nm cmd])
ADD_PLUGIN([ctr], [s charon scripts nm cmd])
ADD_PLUGIN([ccm], [s charon scripts nm cmd])
ADD_PLUGIN([gcm], [s charon scripts nm cmd])
ADD_PLUGIN([ntru], [s charon scripts nm cmd])
ADD_PLUGIN([ml], [s charon scripts nm cmd])
ADD_PLUGIN([drbg], [s charon pki scripts nm cmd])
ADD_PLUGIN([newhope], [s charon scripts nm cmd])
ADD_PLUGIN([bliss], [s charon pki scripts nm cmd])
ADD_PLUGIN([curl], [s charon pki scripts nm cmd])
ADD_PLUGIN([files], [s charon pki scripts nm cmd])
ADD_PLUGIN([winhttp], [s charon pki scripts])
ADD_PLUGIN([soup], [s charon pki scripts nm cmd])
ADD_PLUGIN([mysql], [s charon pool manager medsrv attest])
ADD_PLUGIN([sqlite], [s charon pool manager medsrv attest])
ADD_PLUGIN([mysql], [s charon pki pool manager medsrv attest])
ADD_PLUGIN([sqlite], [s charon pki pool manager medsrv attest])
ADD_PLUGIN([openxpki], [s pki])
ADD_PLUGIN([attr], [c charon])
ADD_PLUGIN([attr-sql], [c charon])
ADD_PLUGIN([load-tester], [c charon])
@ -1659,7 +1670,6 @@ ADD_PLUGIN([led], [c charon])
ADD_PLUGIN([duplicheck], [c charon])
ADD_PLUGIN([coupling], [c charon])
ADD_PLUGIN([radattr], [c charon])
ADD_PLUGIN([uci], [c charon])
ADD_PLUGIN([addrblock], [c charon])
ADD_PLUGIN([unity], [c charon])
ADD_PLUGIN([counters], [c charon])
@ -1720,6 +1730,7 @@ AM_CONDITIONAL(USE_PKCS1, test x$pkcs1 = xtrue)
AM_CONDITIONAL(USE_PKCS7, test x$pkcs7 = xtrue)
AM_CONDITIONAL(USE_PKCS8, test x$pkcs8 = xtrue)
AM_CONDITIONAL(USE_PKCS12, test x$pkcs12 = xtrue)
AM_CONDITIONAL(USE_OPENXPKI, test x$openxpki = xtrue)
AM_CONDITIONAL(USE_PGP, test x$pgp = xtrue)
AM_CONDITIONAL(USE_DNSKEY, test x$dnskey = xtrue)
AM_CONDITIONAL(USE_SSHKEY, test x$sshkey = xtrue)
@ -1744,10 +1755,8 @@ AM_CONDITIONAL(USE_CTR, test x$ctr = xtrue)
AM_CONDITIONAL(USE_CCM, test x$ccm = xtrue)
AM_CONDITIONAL(USE_GCM, test x$gcm = xtrue)
AM_CONDITIONAL(USE_AF_ALG, test x$af_alg = xtrue)
AM_CONDITIONAL(USE_NTRU, test x$ntru = xtrue)
AM_CONDITIONAL(USE_NEWHOPE, test x$newhope = xtrue)
AM_CONDITIONAL(USE_BLISS, test x$bliss = xtrue)
AM_CONDITIONAL(USE_DRBG, test x$drbg = xtrue)
AM_CONDITIONAL(USE_ML, test x$ml = xtrue)
# charon plugins
# ----------------
@ -1755,7 +1764,6 @@ AM_CONDITIONAL(USE_STROKE, test x$stroke = xtrue)
AM_CONDITIONAL(USE_VICI, test x$vici = xtrue)
AM_CONDITIONAL(USE_MEDSRV, test x$medsrv = xtrue)
AM_CONDITIONAL(USE_MEDCLI, test x$medcli = xtrue)
AM_CONDITIONAL(USE_UCI, test x$uci = xtrue)
AM_CONDITIONAL(USE_OSX_ATTR, test x$osx_attr = xtrue)
AM_CONDITIONAL(USE_P_CSCF, test x$p_cscf = xtrue)
AM_CONDITIONAL(USE_ANDROID_DNS, test x$android_dns = xtrue)
@ -1842,6 +1850,7 @@ AM_CONDITIONAL(USE_ATTR, test x$attr = xtrue)
AM_CONDITIONAL(USE_ATTR_SQL, test x$attr_sql = xtrue)
AM_CONDITIONAL(USE_COUNTERS, test x$counters = xtrue)
AM_CONDITIONAL(USE_SELINUX, test x$selinux = xtrue)
AM_CONDITIONAL(USE_PF_HANDLER, test x$dhcp = xtrue -o x$farp = xtrue)
# other options
# ---------------
@ -1865,7 +1874,6 @@ AM_CONDITIONAL(USE_CONFTEST, test x$conftest = xtrue)
AM_CONDITIONAL(USE_LIBSTRONGSWAN, test x$charon = xtrue -o x$pki = xtrue -o x$conftest = xtrue -o x$fast = xtrue -o x$imcv = xtrue -o x$nm = xtrue -o x$tkm = xtrue -o x$cmd = xtrue -o x$tls = xtrue -o x$tnc_tnccs = xtrue -o x$aikgen = xtrue -o x$svc = xtrue -o x$systemd = xtrue)
AM_CONDITIONAL(USE_LIBCHARON, test x$charon = xtrue -o x$conftest = xtrue -o x$nm = xtrue -o x$tkm = xtrue -o x$cmd = xtrue -o x$svc = xtrue -o x$systemd = xtrue)
AM_CONDITIONAL(USE_LIBIPSEC, test x$libipsec = xtrue)
AM_CONDITIONAL(USE_LIBNTTFFT, test x$bliss = xtrue -o x$newhope = xtrue)
AM_CONDITIONAL(USE_LIBTNCIF, test x$tnc_tnccs = xtrue -o x$imcv = xtrue)
AM_CONDITIONAL(USE_LIBTNCCS, test x$tnc_tnccs = xtrue)
AM_CONDITIONAL(USE_LIBPTTLS, test x$tnc_tnccs = xtrue)
@ -1893,8 +1901,10 @@ AM_CONDITIONAL(USE_SWANCTL, test x$swanctl = xtrue)
AM_CONDITIONAL(USE_SVC, test x$svc = xtrue)
AM_CONDITIONAL(USE_SYSTEMD, test x$systemd = xtrue)
AM_CONDITIONAL(USE_LEGACY_SYSTEMD, test -n "$systemdsystemunitdir" -a "x$systemdsystemunitdir" != xno)
AM_CONDITIONAL(USE_CERT_ENROLL, test x$cert_enroll = xtrue)
AM_CONDITIONAL(USE_CERT_ENROLL_TIMER, test x$cert_enroll_timer = xtrue)
AM_CONDITIONAL(USE_RUBY_GEMS, test x$ruby_gems = xtrue)
AM_CONDITIONAL(USE_PYTHON_EGGS, test x$python_eggs = xtrue)
AM_CONDITIONAL(USE_PYTHON_WHEELS, test x$python_wheels = xtrue)
AM_CONDITIONAL(USE_PERL_CPAN, test x$perl_cpan = xtrue)
AM_CONDITIONAL(USE_TOX, test "x$TOX" != x)
AM_CONDITIONAL(USE_PY_TEST, test "x$PY_TEST" != x -a "x$TOX" = x)
@ -1939,14 +1949,16 @@ strongswan_options=
AM_COND_IF([USE_AIKGEN], [strongswan_options=${strongswan_options}" aikgen"])
AM_COND_IF([USE_ATTR_SQL], [strongswan_options=${strongswan_options}" pool"])
AM_COND_IF([USE_CHARON], [strongswan_options=${strongswan_options}" charon charon-logging"])
AM_COND_IF([USE_CHARON], [strongswan_options=${strongswan_options}" charon charon-logging iptfs"])
AM_COND_IF([USE_FILE_CONFIG], [strongswan_options=${strongswan_options}" starter"])
AM_COND_IF([USE_IMV_ATTESTATION], [strongswan_options=${strongswan_options}" attest"])
AM_COND_IF([USE_IMCV], [strongswan_options=${strongswan_options}" imcv"])
AM_COND_IF([USE_IMCV], [strongswan_options=${strongswan_options}" imcv imv_policy_manager"])
AM_COND_IF([USE_IMC_SWIMA], [strongswan_options=${strongswan_options}" sw-collector"])
AM_COND_IF([USE_IMV_SWIMA], [strongswan_options=${strongswan_options}" sec-updater"])
AM_COND_IF([USE_LIBTNCCS], [strongswan_options=${strongswan_options}" tnc"])
AM_COND_IF([USE_MANAGER], [strongswan_options=${strongswan_options}" manager"])
AM_COND_IF([USE_MEDSRV], [strongswan_options=${strongswan_options}" medsrv"])
AM_COND_IF([USE_NM], [strongswan_options=${strongswan_options}" charon-nm"])
AM_COND_IF([USE_PKI], [strongswan_options=${strongswan_options}" pki"])
AM_COND_IF([USE_SWANCTL], [strongswan_options=${strongswan_options}" swanctl"])
AM_COND_IF([USE_SYSTEMD], [strongswan_options=${strongswan_options}" charon-systemd"])
@ -1968,8 +1980,6 @@ AC_CONFIG_FILES([
src/Makefile
src/include/Makefile
src/libstrongswan/Makefile
src/libstrongswan/math/libnttfft/Makefile
src/libstrongswan/math/libnttfft/tests/Makefile
src/libstrongswan/plugins/aes/Makefile
src/libstrongswan/plugins/cmac/Makefile
src/libstrongswan/plugins/des/Makefile
@ -2000,6 +2010,7 @@ AC_CONFIG_FILES([
src/libstrongswan/plugins/pkcs7/Makefile
src/libstrongswan/plugins/pkcs8/Makefile
src/libstrongswan/plugins/pkcs12/Makefile
src/libstrongswan/plugins/openxpki/Makefile
src/libstrongswan/plugins/pgp/Makefile
src/libstrongswan/plugins/dnskey/Makefile
src/libstrongswan/plugins/sshkey/Makefile
@ -2026,11 +2037,7 @@ AC_CONFIG_FILES([
src/libstrongswan/plugins/gcm/Makefile
src/libstrongswan/plugins/af_alg/Makefile
src/libstrongswan/plugins/drbg/Makefile
src/libstrongswan/plugins/ntru/Makefile
src/libstrongswan/plugins/bliss/Makefile
src/libstrongswan/plugins/bliss/tests/Makefile
src/libstrongswan/plugins/newhope/Makefile
src/libstrongswan/plugins/newhope/tests/Makefile
src/libstrongswan/plugins/ml/Makefile
src/libstrongswan/plugins/test_vectors/Makefile
src/libstrongswan/tests/Makefile
src/libipsec/Makefile
@ -2111,7 +2118,6 @@ AC_CONFIG_FILES([
src/libcharon/plugins/medcli/Makefile
src/libcharon/plugins/addrblock/Makefile
src/libcharon/plugins/unity/Makefile
src/libcharon/plugins/uci/Makefile
src/libcharon/plugins/ha/Makefile
src/libcharon/plugins/kernel_netlink/Makefile
src/libcharon/plugins/kernel_pfkey/Makefile
@ -2167,6 +2173,7 @@ AC_CONFIG_FILES([
src/sw-collector/Makefile
src/sec-updater/Makefile
src/swanctl/Makefile
src/cert-enroll/Makefile
src/xfrmi/Makefile
scripts/Makefile
testing/Makefile
@ -2190,6 +2197,7 @@ AC_CONFIG_FILES([
src/pki/man/pki---gen.1
src/pki/man/pki---issue.1
src/pki/man/pki---keyid.1
src/pki/man/pki---ocsp.1
src/pki/man/pki---pkcs12.1
src/pki/man/pki---pkcs7.1
src/pki/man/pki---print.1
@ -2206,6 +2214,7 @@ AC_CONFIG_FILES([
src/pt-tls-client/pt-tls-client.1
src/sw-collector/sw-collector.8
src/sec-updater/sec-updater.8
src/cert-enroll/cert-enroll.8
])
AC_OUTPUT

2
fuzz/.gitignore vendored
View File

@ -1,5 +1,7 @@
fuzz_certs
fuzz_crls
fuzz_ocsp_req
fuzz_ocsp_rsp
fuzz_ids
fuzz_pa_tnc
fuzz_pb_tnc

View File

@ -11,7 +11,7 @@ AM_CPPFLAGS = @CPPFLAGS@ \
fuzz_ldflags = ${libfuzzer} \
$(top_builddir)/src/libstrongswan/.libs/libstrongswan.a \
-Wl,-Bstatic -lgmp -Wl,-Bdynamic \
-Wl,-Bstatic -lcrypto -Wl,-Bdynamic \
@FUZZING_LDFLAGS@
pa_tnc_ldflags = \
@ -25,7 +25,8 @@ pb_tnc_ldflags = \
$(top_builddir)/src/libtncif/.libs/libtncif.a \
$(fuzz_ldflags)
FUZZ_TARGETS=fuzz_certs fuzz_crls fuzz_ids fuzz_pa_tnc fuzz_pb_tnc
FUZZ_TARGETS=fuzz_certs fuzz_crls fuzz_ocsp_req fuzz_ocsp_rsp \
fuzz_ids fuzz_pa_tnc fuzz_pb_tnc
all-local: $(FUZZ_TARGETS)
@ -37,6 +38,12 @@ fuzz_certs: fuzz_certs.c ${libfuzzer}
fuzz_crls: fuzz_crls.c ${libfuzzer}
$(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
fuzz_ocsp_req: fuzz_ocsp_req.c ${libfuzzer}
$(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
fuzz_ocsp_rsp: fuzz_ocsp_rsp.c ${libfuzzer}
$(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
fuzz_ids: fuzz_ids.c ${libfuzzer}
$(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 Andreas Steffen
* Copyright (C) 2023 Tobias Brunner
*
* Copyright (C) secunet Security Networks AG
*
@ -14,30 +14,28 @@
* for more details.
*/
#include "bliss_huffman_code.h"
#include <library.h>
#include <utils/debug.h>
extern bliss_huffman_code_t bliss_huffman_code_1;
extern bliss_huffman_code_t bliss_huffman_code_3;
extern bliss_huffman_code_t bliss_huffman_code_4;
/**
* See header.
*/
bliss_huffman_code_t* bliss_huffman_code_get_by_id(bliss_param_set_id_t id)
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
{
switch (id)
{
case BLISS_I:
case BLISS_B_I:
return &bliss_huffman_code_1;
case BLISS_III:
case BLISS_B_III:
return &bliss_huffman_code_3;
case BLISS_IV:
case BLISS_B_IV:
return &bliss_huffman_code_4;
default:
return NULL;
}
}
certificate_t *cert;
chunk_t chunk;
dbg_default_set_level(-1);
library_init(NULL, "fuzz_ocsp_req");
plugin_loader_add_plugindirs(PLUGINDIR, PLUGINS);
if (!lib->plugins->load(lib->plugins, PLUGINS))
{
return 1;
}
chunk = chunk_create((u_char*)buf, len);
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_REQUEST,
BUILD_BLOB, chunk, BUILD_END);
DESTROY_IF(cert);
lib->plugins->unload(lib->plugins);
library_deinit();
return 0;
}

41
fuzz/fuzz_ocsp_rsp.c Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 Tobias Brunner
*
* Copyright (C) secunet Security Networks AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <library.h>
#include <utils/debug.h>
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
{
certificate_t *cert;
chunk_t chunk;
dbg_default_set_level(-1);
library_init(NULL, "fuzz_ocsp_rsp");
plugin_loader_add_plugindirs(PLUGINDIR, PLUGINS);
if (!lib->plugins->load(lib->plugins, PLUGINS))
{
return 1;
}
chunk = chunk_create((u_char*)buf, len);
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_RESPONSE,
BUILD_BLOB, chunk, BUILD_END);
DESTROY_IF(cert);
lib->plugins->unload(lib->plugins);
library_deinit();
return 0;
}

View File

@ -2,10 +2,12 @@
SUBDIRS =
if USE_LEGACY_SYSTEMD
if USE_FILE_CONFIG
if USE_CHARON
SUBDIRS += systemd-starter
endif
endif
endif
if USE_SYSTEMD
if USE_SWANCTL

View File

@ -1,6 +1,7 @@
[Unit]
Description=strongSwan IPsec IKEv1/IKEv2 daemon using ipsec.conf
After=syslog.target network-online.target
Wants=syslog.target network-online.target
[Service]
ExecStart=@SBINDIR@/@IPSEC_SCRIPT@ start --nofork

View File

@ -1,6 +1,7 @@
[Unit]
Description=strongSwan IPsec IKEv1/IKEv2 daemon using swanctl
After=network-online.target
Wants=network-online.target
[Service]
Type=notify

532
m4/macros/host-cpu-c-abi.m4 Normal file
View File

@ -0,0 +1,532 @@
# host-cpu-c-abi.m4
# serial 20
dnl Copyright (C) 2002-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Bruno Haible and Sam Steingold.
dnl Sets the HOST_CPU variable to the canonical name of the CPU.
dnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its
dnl C language ABI (application binary interface).
dnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in
dnl config.h.
dnl
dnl This canonical name can be used to select a particular assembly language
dnl source file that will interoperate with C code on the given host.
dnl
dnl For example:
dnl * 'i386' and 'sparc' are different canonical names, because code for i386
dnl will not run on SPARC CPUs and vice versa. They have different
dnl instruction sets.
dnl * 'sparc' and 'sparc64' are different canonical names, because code for
dnl 'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code
dnl contains 32-bit instructions, whereas 'sparc64' code contains 64-bit
dnl instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit
dnl mode, but not both.
dnl * 'mips' and 'mipsn32' are different canonical names, because they use
dnl different argument passing and return conventions for C functions, and
dnl although the instruction set of 'mips' is a large subset of the
dnl instruction set of 'mipsn32'.
dnl * 'mipsn32' and 'mips64' are different canonical names, because they use
dnl different sizes for the C types like 'int' and 'void *', and although
dnl the instruction sets of 'mipsn32' and 'mips64' are the same.
dnl * The same canonical name is used for different endiannesses. You can
dnl determine the endianness through preprocessor symbols:
dnl - 'arm': test __ARMEL__.
dnl - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL.
dnl - 'powerpc64': test __BIG_ENDIAN__ vs. __LITTLE_ENDIAN__.
dnl * The same name 'i386' is used for CPUs of type i386, i486, i586
dnl (Pentium), AMD K7, Pentium II, Pentium IV, etc., because
dnl - Instructions that do not exist on all of these CPUs (cmpxchg,
dnl MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your
dnl assembly language source files use such instructions, you will
dnl need to make the distinction.
dnl - Speed of execution of the common instruction set is reasonable across
dnl the entire family of CPUs. If you have assembly language source files
dnl that are optimized for particular CPU types (like GNU gmp has), you
dnl will need to make the distinction.
dnl See <https://en.wikipedia.org/wiki/X86_instruction_listings>.
AC_DEFUN([gl_HOST_CPU_C_ABI],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_C_ASM])
AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi],
[case "$host_cpu" in
changequote(,)dnl
i[34567]86 )
changequote([,])dnl
gl_cv_host_cpu_c_abi=i386
;;
x86_64 )
# On x86_64 systems, the C compiler may be generating code in one of
# these ABIs:
# - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64.
# - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64
# with native Windows (mingw, MSVC).
# - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32.
# - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if (defined __x86_64__ || defined __amd64__ \
|| defined _M_X64 || defined _M_AMD64)
int ok;
#else
error fail
#endif
]])],
[AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __ILP32__ || defined _ILP32
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=x86_64-x32],
[gl_cv_host_cpu_c_abi=x86_64])],
[gl_cv_host_cpu_c_abi=i386])
;;
changequote(,)dnl
alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
changequote([,])dnl
gl_cv_host_cpu_c_abi=alpha
;;
arm* | aarch64 )
# Assume arm with EABI.
# On arm64 systems, the C compiler may be generating code in one of
# these ABIs:
# - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64.
# - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32.
# - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifdef __aarch64__
int ok;
#else
error fail
#endif
]])],
[AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __ILP32__ || defined _ILP32
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=arm64-ilp32],
[gl_cv_host_cpu_c_abi=arm64])],
[# Don't distinguish little-endian and big-endian arm, since they
# don't require different machine code for simple operations and
# since the user can distinguish them through the preprocessor
# defines __ARMEL__ vs. __ARMEB__.
# But distinguish arm which passes floating-point arguments and
# return values in integer registers (r0, r1, ...) - this is
# gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which
# passes them in float registers (s0, s1, ...) and double registers
# (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer
# sets the preprocessor defines __ARM_PCS (for the first case) and
# __ARM_PCS_VFP (for the second case), but older GCC does not.
echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c
# Look for a reference to the register d0 in the .s file.
AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1
if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then
gl_cv_host_cpu_c_abi=armhf
else
gl_cv_host_cpu_c_abi=arm
fi
rm -fr conftest*
])
;;
hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
# On hppa, the C compiler may be generating 32-bit code or 64-bit
# code. In the latter case, it defines _LP64 and __LP64__.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifdef __LP64__
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=hppa64],
[gl_cv_host_cpu_c_abi=hppa])
;;
ia64* )
# On ia64 on HP-UX, the C compiler may be generating 64-bit code or
# 32-bit code. In the latter case, it defines _ILP32.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifdef _ILP32
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=ia64-ilp32],
[gl_cv_host_cpu_c_abi=ia64])
;;
mips* )
# We should also check for (_MIPS_SZPTR == 64), but gcc keeps this
# at 32.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64)
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=mips64],
[# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but
# may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIN32.
# In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but
# may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIO32.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if (_MIPS_SIM == _ABIN32)
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=mipsn32],
[gl_cv_host_cpu_c_abi=mips])])
;;
powerpc* )
# Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD.
# No need to distinguish them here; the caller may distinguish
# them based on the OS.
# On powerpc64 systems, the C compiler may still be generating
# 32-bit code. And on powerpc-ibm-aix systems, the C compiler may
# be generating 64-bit code.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
#endif
]])],
[# On powerpc64, there are two ABIs on Linux: The AIX compatible
# one and the ELFv2 one. The latter defines _CALL_ELF=2.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined _CALL_ELF && _CALL_ELF == 2
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=powerpc64-elfv2],
[gl_cv_host_cpu_c_abi=powerpc64])
],
[gl_cv_host_cpu_c_abi=powerpc])
;;
rs6000 )
gl_cv_host_cpu_c_abi=powerpc
;;
riscv32 | riscv64 )
# There are 2 architectures (with variants): rv32* and rv64*.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if __riscv_xlen == 64
int ok;
#else
error fail
#endif
]])],
[cpu=riscv64],
[cpu=riscv32])
# There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d.
# Size of 'long' and 'void *':
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __LP64__
int ok;
#else
error fail
#endif
]])],
[main_abi=lp64],
[main_abi=ilp32])
# Float ABIs:
# __riscv_float_abi_double:
# 'float' and 'double' are passed in floating-point registers.
# __riscv_float_abi_single:
# 'float' are passed in floating-point registers.
# __riscv_float_abi_soft:
# No values are passed in floating-point registers.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __riscv_float_abi_double
int ok;
#else
error fail
#endif
]])],
[float_abi=d],
[AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __riscv_float_abi_single
int ok;
#else
error fail
#endif
]])],
[float_abi=f],
[float_abi=''])
])
gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}"
;;
s390* )
# On s390x, the C compiler may be generating 64-bit (= s390x) code
# or 31-bit (= s390) code.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __LP64__ || defined __s390x__
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=s390x],
[gl_cv_host_cpu_c_abi=s390])
;;
sparc | sparc64 )
# UltraSPARCs running Linux have `uname -m` = "sparc64", but the
# C compiler still generates 32-bit code.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#if defined __sparcv9 || defined __arch64__
int ok;
#else
error fail
#endif
]])],
[gl_cv_host_cpu_c_abi=sparc64],
[gl_cv_host_cpu_c_abi=sparc])
;;
*)
gl_cv_host_cpu_c_abi="$host_cpu"
;;
esac
])
dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same.
HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'`
HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi"
AC_SUBST([HOST_CPU])
AC_SUBST([HOST_CPU_C_ABI])
# This was
# AC_DEFINE_UNQUOTED([__${HOST_CPU}__])
# AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__])
# earlier, but KAI C++ 3.2d doesn't like this.
sed -e 's/-/_/g' >> confdefs.h <<EOF
#ifndef __${HOST_CPU}__
#define __${HOST_CPU}__ 1
#endif
#ifndef __${HOST_CPU_C_ABI}__
#define __${HOST_CPU_C_ABI}__ 1
#endif
EOF
AH_TOP([/* CPU and C ABI indicator */
#ifndef __i386__
#undef __i386__
#endif
#ifndef __x86_64_x32__
#undef __x86_64_x32__
#endif
#ifndef __x86_64__
#undef __x86_64__
#endif
#ifndef __alpha__
#undef __alpha__
#endif
#ifndef __arm__
#undef __arm__
#endif
#ifndef __armhf__
#undef __armhf__
#endif
#ifndef __arm64_ilp32__
#undef __arm64_ilp32__
#endif
#ifndef __arm64__
#undef __arm64__
#endif
#ifndef __hppa__
#undef __hppa__
#endif
#ifndef __hppa64__
#undef __hppa64__
#endif
#ifndef __ia64_ilp32__
#undef __ia64_ilp32__
#endif
#ifndef __ia64__
#undef __ia64__
#endif
#ifndef __loongarch32__
#undef __loongarch32__
#endif
#ifndef __loongarch64__
#undef __loongarch64__
#endif
#ifndef __m68k__
#undef __m68k__
#endif
#ifndef __mips__
#undef __mips__
#endif
#ifndef __mipsn32__
#undef __mipsn32__
#endif
#ifndef __mips64__
#undef __mips64__
#endif
#ifndef __powerpc__
#undef __powerpc__
#endif
#ifndef __powerpc64__
#undef __powerpc64__
#endif
#ifndef __powerpc64_elfv2__
#undef __powerpc64_elfv2__
#endif
#ifndef __riscv32__
#undef __riscv32__
#endif
#ifndef __riscv64__
#undef __riscv64__
#endif
#ifndef __riscv32_ilp32__
#undef __riscv32_ilp32__
#endif
#ifndef __riscv32_ilp32f__
#undef __riscv32_ilp32f__
#endif
#ifndef __riscv32_ilp32d__
#undef __riscv32_ilp32d__
#endif
#ifndef __riscv64_ilp32__
#undef __riscv64_ilp32__
#endif
#ifndef __riscv64_ilp32f__
#undef __riscv64_ilp32f__
#endif
#ifndef __riscv64_ilp32d__
#undef __riscv64_ilp32d__
#endif
#ifndef __riscv64_lp64__
#undef __riscv64_lp64__
#endif
#ifndef __riscv64_lp64f__
#undef __riscv64_lp64f__
#endif
#ifndef __riscv64_lp64d__
#undef __riscv64_lp64d__
#endif
#ifndef __s390__
#undef __s390__
#endif
#ifndef __s390x__
#undef __s390x__
#endif
#ifndef __sh__
#undef __sh__
#endif
#ifndef __sparc__
#undef __sparc__
#endif
#ifndef __sparc64__
#undef __sparc64__
#endif
])
])
dnl Sets the HOST_CPU_C_ABI_32BIT variable to 'yes' if the C language ABI
dnl (application binary interface) is a 32-bit one, to 'no' if it is a 64-bit
dnl one.
dnl This is a simplified variant of gl_HOST_CPU_C_ABI.
AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([32-bit host C ABI], [gl_cv_host_cpu_c_abi_32bit],
[case "$host_cpu" in
# CPUs that only support a 32-bit ABI.
arc \
| bfin \
| cris* \
| csky \
| epiphany \
| ft32 \
| h8300 \
| m68k \
| microblaze | microblazeel \
| nds32 | nds32le | nds32be \
| nios2 | nios2eb | nios2el \
| or1k* \
| or32 \
| sh | sh[1234] | sh[1234]e[lb] \
| tic6x \
| xtensa* )
gl_cv_host_cpu_c_abi_32bit=yes
;;
# CPUs that only support a 64-bit ABI.
changequote(,)dnl
alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
| mmix )
changequote([,])dnl
gl_cv_host_cpu_c_abi_32bit=no
;;
*)
if test -n "$gl_cv_host_cpu_c_abi"; then
dnl gl_HOST_CPU_C_ABI has already been run. Use its result.
case "$gl_cv_host_cpu_c_abi" in
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | loongarch32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
gl_cv_host_cpu_c_abi_32bit=yes ;;
x86_64 | alpha | arm64 | aarch64c | hppa64 | ia64 | loongarch64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
gl_cv_host_cpu_c_abi_32bit=no ;;
*)
gl_cv_host_cpu_c_abi_32bit=unknown ;;
esac
else
gl_cv_host_cpu_c_abi_32bit=unknown
fi
if test $gl_cv_host_cpu_c_abi_32bit = unknown; then
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[int test_pointer_size[sizeof (void *) - 5];
]])],
[gl_cv_host_cpu_c_abi_32bit=no],
[gl_cv_host_cpu_c_abi_32bit=yes])
fi
;;
esac
])
HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit"
])

334
m4/macros/lib-prefix.m4 Normal file
View File

@ -0,0 +1,334 @@
# lib-prefix.m4
# serial 23
dnl Copyright (C) 2001-2005, 2008-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Bruno Haible.
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH([lib-prefix],
[[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir]],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_saved_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_saved_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_saved_prefix="$prefix"
prefix="$acl_final_prefix"
acl_saved_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_saved_exec_prefix"
prefix="$acl_saved_prefix"
])
dnl AC_LIB_PREPARE_MULTILIB creates
dnl - a function acl_is_expected_elfclass, that tests whether standard input
dnl; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
dnl the basename of the libdir to try in turn, either "lib" or "lib64" or
dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
[
dnl There is no formal standard regarding lib, lib32, and lib64.
dnl On most glibc systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
dnl We determine the compiler's default mode by looking at the compiler's
dnl library search path. If at least one of its elements ends in /lib64 or
dnl points to a directory whose absolute pathname ends in /lib64, we use that
dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default,
dnl namely "lib".
dnl On Solaris systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
[AC_EGREP_CPP([Extensible Linking Format],
[#if defined __ELF__ || (defined __linux__ && (defined __EDG__ || defined __SUNPRO_C))
Extensible Linking Format
#endif
],
[gl_cv_elf=yes],
[gl_cv_elf=no])
])
if test $gl_cv_elf = yes; then
# Extract the ELF class of a file (5th byte) in decimal.
# Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
if od -A x < /dev/null >/dev/null 2>/dev/null; then
# Use POSIX od.
func_elfclass ()
{
od -A n -t d1 -j 4 -N 1
}
else
# Use BSD hexdump.
func_elfclass ()
{
dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
echo
}
fi
# Use 'expr', not 'test', to compare the values of func_elfclass, because on
# Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002,
# not 1 or 2.
changequote(,)dnl
case $HOST_CPU_C_ABI_32BIT in
yes)
# 32-bit ABI.
acl_is_expected_elfclass ()
{
expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null
}
;;
no)
# 64-bit ABI.
acl_is_expected_elfclass ()
{
expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null
}
;;
*)
# Unknown.
acl_is_expected_elfclass ()
{
:
}
;;
esac
changequote([,])dnl
else
acl_is_expected_elfclass ()
{
:
}
fi
dnl Allow the user to override the result by setting acl_cv_libdirstems.
AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
[acl_cv_libdirstems],
[dnl Try 'lib' first, because that's the default for libdir in GNU, see
dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
acl_libdirstem=lib
acl_libdirstem2=
acl_libdirstem3=
case "$host_os" in
solaris*)
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
dnl symlink is missing, so we set acl_libdirstem2 too.
if test $HOST_CPU_C_ABI_32BIT = no; then
acl_libdirstem2=lib/64
case "$host_cpu" in
sparc*) acl_libdirstem3=lib/sparcv9 ;;
i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
esac
fi
;;
netbsd*)
dnl On NetBSD/sparc64, there is a 'sparc' subdirectory that contains
dnl 32-bit libraries.
if test $HOST_CPU_C_ABI_32BIT != no; then
case "$host_cpu" in
sparc*) acl_libdirstem2=lib/sparc ;;
esac
fi
;;
*)
dnl If $CC generates code for a 32-bit ABI, the libraries are
dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
dnl Find the compiler's search path. However, non-system compilers
dnl sometimes have odd library search paths. But we can't simply invoke
dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
| sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
if test $HOST_CPU_C_ABI_32BIT != no; then
# 32-bit or unknown ABI.
if test -d /usr/lib32; then
acl_libdirstem2=lib32
fi
fi
if test $HOST_CPU_C_ABI_32BIT != yes; then
# 64-bit or unknown ABI.
if test -d /usr/lib64; then
acl_libdirstem3=lib64
fi
fi
if test -n "$searchpath"; then
acl_saved_IFS="${IFS= }"; IFS=":"
for searchdir in $searchpath; do
if test -d "$searchdir"; then
case "$searchdir" in
*/lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
*/lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
*/../ | */.. )
# Better ignore directories of this form. They are misleading.
;;
*) searchdir=`cd "$searchdir" && pwd`
case "$searchdir" in
*/lib32 ) acl_libdirstem2=lib32 ;;
*/lib64 ) acl_libdirstem3=lib64 ;;
esac ;;
esac
fi
done
IFS="$acl_saved_IFS"
if test $HOST_CPU_C_ABI_32BIT = yes; then
# 32-bit ABI.
acl_libdirstem3=
fi
if test $HOST_CPU_C_ABI_32BIT = no; then
# 64-bit ABI.
acl_libdirstem2=
fi
fi
;;
esac
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
])
dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
dnl acl_libdirstem3.
changequote(,)dnl
acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
changequote([,])dnl
])

1
scripts/.gitignore vendored
View File

@ -17,3 +17,4 @@ thread_analysis
tls_test
timeattack
os_info
nist_kem_kat

View File

@ -7,7 +7,7 @@ AM_CPPFLAGS = \
noinst_PROGRAMS = bin2array bin2sql id2sql key2keyid keyid2sql oid2der \
thread_analysis dh_speed pubkey_speed crypt_burn hash_burn fetch \
dnssec malloc_speed aes-test settings-test timeattack
dnssec malloc_speed aes-test settings-test timeattack nist_kem_kat
if USE_TLS
noinst_PROGRAMS += tls_test
@ -31,6 +31,7 @@ malloc_speed_SOURCES = malloc_speed.c
fetch_SOURCES = fetch.c
dnssec_SOURCES = dnssec.c
timeattack_SOURCES = timeattack.c
nist_kem_kat_SOURCES = nist_kem_kat.c
id2sql_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
key2keyid_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
@ -46,6 +47,7 @@ dnssec_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
aes_test_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
settings_test_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
timeattack_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(RTLIB)
nist_kem_kat_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
if USE_IMCV
AM_CPPFLAGS += -I$(top_srcdir)/src/libimcv

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Tobias Brunner
* Copyright (C) 2023-2024 Tobias Brunner
* Copyright (C) 2009 Martin Willi
*
* Copyright (C) secunet Security Networks AG
@ -56,13 +56,14 @@ static void run_test(key_exchange_method_t method, int rounds)
method);
return;
}
assert(r[0]->get_public_key(r[0], &rpublic[0]));
for (round = 1; round < rounds; round++)
{
r[round] = lib->crypto->create_ke(lib->crypto, method);
assert(r[round]->get_public_key(r[round], &rpublic[round]));
}
/* make sure to use the method call order documented in the
* key_exchange_t header file */
printf("%N:\t", key_exchange_method_names, method);
start_timing(&timing);
@ -73,12 +74,14 @@ static void run_test(key_exchange_method_t method, int rounds)
}
printf("A = g^a/s: %8.1f", rounds / end_timing(&timing));
start_timing(&timing);
for (round = 0; round < rounds; round++)
{
assert(r[round]->set_public_key(r[round], lpublic[round]));
assert(r[round]->get_public_key(r[round], &rpublic[round]));
assert(r[round]->get_shared_secret(r[round], &rsecret[round]));
chunk_free(&lpublic[round]);
}
printf(" | S = A^b/s: %8.1f", rounds / end_timing(&timing));
start_timing(&timing);
for (round = 0; round < rounds; round++)
@ -93,6 +96,7 @@ static void run_test(key_exchange_method_t method, int rounds)
assert(chunk_equals(rsecret[round], lsecret[round]));
chunk_free(&lsecret[round]);
chunk_free(&rsecret[round]);
chunk_free(&lpublic[round]);
chunk_free(&rpublic[round]);
l[round]->destroy(l[round]);
r[round]->destroy(r[round]);

189
scripts/nist_kem_kat.c Normal file
View File

@ -0,0 +1,189 @@
/*
* Copyright (C) 2019-2020 Andreas Steffen
*
* Copyright (C) secunet Security Networks AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <library.h>
static void usage(FILE *out, char *name)
{
fprintf(out, "Convert NIST KEM KAT file into struct\n");
fprintf(out, "%s [OPTIONS]\n\n", name);
fprintf(out, "Options:\n");
fprintf(out, " -h, --help print this help.\n");
fprintf(out, " -m, --method KEM method.\n");
fprintf(out, " -c, --count number of structs (default 4).\n");
fprintf(out, " -i, --in=FILE request file (default STDIN).\n");
fprintf(out, " -o, --out=FILE response file (default STDOUT).\n");
fprintf(out, "\n");
}
int main(int argc, char *argv[])
{
FILE *in = stdin;
FILE *out = stdout;
char line[90000], *method = "", *pos, *eol, *param, *value;
size_t param_len, value_len;
int count = 4, n;
library_init(NULL, "nist-kem-kat");
atexit(library_deinit);
while (true)
{
struct option long_opts[] = {
{"help", no_argument, NULL, 'h' },
{"method", required_argument, NULL, 'm' },
{"count", required_argument, NULL, 'c' },
{"in", required_argument, NULL, 'i' },
{"out", required_argument, NULL, 'o' },
{0,0,0,0 },
};
switch (getopt_long(argc, argv, "h:m:c:i:o:", long_opts, NULL))
{
case EOF:
break;
case 'h':
usage(stdout, argv[0]);
return 0;
case 'm':
method = optarg;
continue;
case 'c':
count = atoi(optarg);
continue;
case 'i':
in = fopen(optarg, "r");
if (!in)
{
fprintf(stderr, "failed to open '%s': %s\n", optarg,
strerror(errno));
usage(stderr, argv[0]);
return 1;
}
continue;
case 'o':
out = fopen(optarg, "w");
if (!out)
{
fprintf(stderr, "failed to open '%s': %s\n", optarg,
strerror(errno));
usage(stderr, argv[0]);
return 1;
}
continue;
default:
usage(stderr, argv[0]);
return 1;
}
break;
}
while (fgets(line, sizeof(line), in))
{
pos = strchr(line, '=');
if (!pos)
{
continue;
}
/*remove preceding whitespace from value */
value = pos + 1;
eol = strchr(value, '\n');
if (!eol)
{
fprintf(stderr, "eol not found\n");
break;
}
value_len = eol - value;
while (value_len && *value == ' ')
{
value++;
value_len--;
}
/* remove trailing whitespace from param */
param = line;
param_len = pos - line;
while (param_len && *(--pos) == ' ')
{
param_len--;
}
param[param_len] = '\0';
if (streq(param, "sk"))
{
continue;
}
if (streq(param, "count"))
{
if (count == 0)
{
break;
}
fprintf(out, "/** count = %.*s */\n", (int)value_len, value);
fprintf(out, "{\n");
fprintf(out, "\t.method = %s,\n", method);
count--;
}
else
{
fprintf(out, "\t.%s = chunk_from_chars(", param);
n = 0;
while (value_len > 1)
{
if (n > 0)
{
fprintf(out, ",");
if (n % 100 == 0)
{
fprintf(out, " /* %d */\n", n);
}
}
if (n % 10 == 0)
{
fprintf(out, "\n\t\t");
}
fprintf(out, "0x%.2s", value);
value += 2;
value_len -= 2;
n++;
}
fprintf(out, "),\n");
if (streq(param, "ss"))
{
fprintf(out, "},\n");
}
}
}
if (in != stdin)
{
fclose(in);
}
if (out != stdout)
{
fclose(out);
}
return 0;
}

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[])
printf("creating signature failed\n");
exit(1);
}
};
}
printf("sign()/s: %8.1f ", rounds / end_timing(&timing));
public = private->get_public_key(private);

View File

@ -4,7 +4,7 @@
build_botan()
{
# same revision used in the build recipe of the testing environment
BOTAN_REV=3.1.1
BOTAN_REV=3.7.1
BOTAN_DIR=$DEPS_BUILD_DIR/botan
if test -d "$BOTAN_DIR"; then
@ -21,15 +21,17 @@ build_botan()
BOTAN_CONFIG="--without-os-features=threads
--disable-modules=locking_allocator"
fi
# disable some larger modules we don't need for the tests
# disable some larger modules we don't need for the tests and deprecated
# ones, except for MD5, which we need for TLS 1.0/1.1
BOTAN_CONFIG="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss
--disable-deprecated-features --enable-modules=md5
--prefix=$DEPS_PREFIX"
git clone https://github.com/randombit/botan.git $BOTAN_DIR &&
cd $BOTAN_DIR &&
git checkout -qf $BOTAN_REV &&
python ./configure.py --amalgamation $BOTAN_CONFIG &&
make -j4 libs >/dev/null &&
./configure.py --amalgamation $BOTAN_CONFIG &&
make -j$(nproc) libs >/dev/null &&
sudo make install >/dev/null &&
sudo ldconfig || exit $?
cd -
@ -37,7 +39,7 @@ build_botan()
build_wolfssl()
{
WOLFSSL_REV=v5.6.3-stable
WOLFSSL_REV=v5.8.2-stable
WOLFSSL_DIR=$DEPS_BUILD_DIR/wolfssl
if test -d "$WOLFSSL_DIR"; then
@ -47,21 +49,22 @@ build_wolfssl()
echo "$ build_wolfssl()"
WOLFSSL_CFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB -DHAVE_AES_ECB \
-DHAVE_ECC_BRAINPOOL -DWOLFSSL_MIN_AUTH_TAG_SZ=8"
-DHAVE_ECC_BRAINPOOL -DWOLFSSL_MIN_AUTH_TAG_SZ=8 \
-DRSA_MIN_SIZE=1024"
WOLFSSL_CONFIG="--prefix=$DEPS_PREFIX
--disable-crypttests --disable-examples
--enable-aesccm --enable-aesctr --enable-camellia
--enable-aesccm --enable-aesctr --enable-aescfb --enable-camellia
--enable-curve25519 --enable-curve448 --enable-des3
--enable-ecccustcurves --enable-ed25519 --enable-ed448
--enable-keygen --with-max-rsa-bits=8192 --enable-md4
--enable-rsapss --enable-sha3 --enable-shake256"
--enable-keygen --enable-mlkem --with-max-rsa-bits=8192
--enable-md4 --enable-rsapss --enable-sha3 --enable-shake256"
git clone https://github.com/wolfSSL/wolfssl.git $WOLFSSL_DIR &&
cd $WOLFSSL_DIR &&
git checkout -qf $WOLFSSL_REV &&
./autogen.sh &&
./configure C_EXTRA_FLAGS="$WOLFSSL_CFLAGS" $WOLFSSL_CONFIG &&
make -j4 >/dev/null &&
make -j$(nproc) >/dev/null &&
sudo make install >/dev/null &&
sudo ldconfig || exit $?
cd -
@ -69,7 +72,7 @@ build_wolfssl()
build_tss2()
{
TSS2_REV=3.2.2
TSS2_REV=3.2.3
TSS2_PKG=tpm2-tss-$TSS2_REV
TSS2_DIR=$DEPS_BUILD_DIR/$TSS2_PKG
TSS2_SRC=https://github.com/tpm2-software/tpm2-tss/releases/download/$TSS2_REV/$TSS2_PKG.tar.gz
@ -83,7 +86,7 @@ build_tss2()
curl -L $TSS2_SRC | tar xz -C $DEPS_BUILD_DIR &&
cd $TSS2_DIR &&
./configure --prefix=$DEPS_PREFIX --disable-doxygen-doc &&
make -j4 >/dev/null &&
make -j$(nproc) >/dev/null &&
sudo make install >/dev/null &&
sudo ldconfig || exit $?
cd -
@ -91,26 +94,30 @@ build_tss2()
build_openssl()
{
SSL_REV=3.1.1
SSL_PKG=openssl-$SSL_REV
SSL_DIR=$DEPS_BUILD_DIR/$SSL_PKG
SSL_SRC=https://www.openssl.org/source/$SSL_PKG.tar.gz
SSL_REV=openssl-3.6.0
SSL_DIR=$DEPS_BUILD_DIR/openssl
SSL_INS=$DEPS_PREFIX/ssl
SSL_OPT="-d shared no-dtls no-ssl3 no-zlib no-idea no-psk no-srp
SSL_OPT="-d shared no-dtls no-ssl3 no-zlib no-idea no-psk
no-tests enable-rfc3779 enable-ec_nistp_64_gcc_128"
if test -d "$SSL_DIR"; then
return
fi
# insist on compiling with gcc and debug information as symbols are otherwise not found
if test "$LEAK_DETECTIVE" = "yes"; then
SSL_OPT="$SSL_OPT CC=gcc -d"
# insist on compiling with gcc and debug information as symbols are
# otherwise not found, but we can disable SRP (see below)
SSL_OPT="$SSL_OPT no-srp CC=gcc -d"
elif test "$CC" != "clang"; then
# when using ASan with clang, llvm-symbolizer is used to resolve symbols
# and this tool links libcurl, which in turn requires SRP, so we can
# only disable it when not building with clang
SSL_OPT="$SSL_OPT no-srp"
fi
echo "$ build_openssl()"
curl -L $SSL_SRC | tar xz -C $DEPS_BUILD_DIR || exit $?
git clone https://github.com/openssl/openssl.git --depth 1 -b $SSL_REV $SSL_DIR || exit $?
if [ "$TEST" = "android" ]; then
OPENSSL_SRC=${SSL_DIR} \
@ -118,20 +125,49 @@ build_openssl()
else
cd $SSL_DIR &&
./config --prefix=$SSL_INS --openssldir=$SSL_INS --libdir=lib $SSL_OPT &&
make -j4 >/dev/null &&
make -j$(nproc) >/dev/null &&
sudo make install_sw >/dev/null &&
sudo ldconfig || exit $?
cd -
fi
}
build_awslc()
{
LC_REV=1.61.1
LC_PKG=aws-lc-$LC_REV
LC_DIR=$DEPS_BUILD_DIR/$LC_PKG
LC_SRC=https://github.com/aws/aws-lc/archive/refs/tags/v${LC_REV}.tar.gz
LC_BUILD=$LC_DIR/build
LC_INS=$DEPS_PREFIX/ssl
mkdir -p $LC_BUILD
echo "$ build_awslc()"
curl -L $LC_SRC | tar xz -C $DEPS_BUILD_DIR || exit $?
cd $LC_BUILD &&
cmake -GNinja -DCMAKE_INSTALL_PREFIX=$LC_INS .. &&
ninja &&
sudo ninja install || exit $?
cd -
}
use_custom_openssl()
{
CFLAGS="$CFLAGS -I$DEPS_PREFIX/ssl/include"
export LDFLAGS="$LDFLAGS -L$DEPS_PREFIX/ssl/lib"
export LD_LIBRARY_PATH="$DEPS_PREFIX/ssl/lib:$LD_LIBRARY_PATH"
if test "$1" = "build-deps"; then
build_openssl
case "$TEST" in
openssl-awslc)
build_awslc
;;
*)
build_openssl
;;
esac
fi
}
@ -143,7 +179,7 @@ system_uses_openssl3()
prepare_system_openssl()
{
# On systems that ship OpenSSL 3 (e.g. Ubuntu 22.04), we require debug
# On systems that ship OpenSSL 3 (e.g. Ubuntu 22.04+), we require debug
# symbols to whitelist leaks
if test "$1" = "deps"; then
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted
@ -151,19 +187,24 @@ prepare_system_openssl()
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt-get install -qq ubuntu-dbgsym-keyring
DEPS="$DEPS libssl3-dbgsym"
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "24.04" ]; then
DEPS="$DEPS libssl3t64-dbgsym"
else
DEPS="$DEPS libssl3-dbgsym"
fi
fi
if test "$LEAK_DETECTIVE" = "yes"; then
# make sure we can properly whitelist functions with leak detective
DEPS="$DEPS binutils-dev"
CONFIG="$CONFIG --enable-bfd-backtraces"
else
elif [ "$ID" = "ubuntu" -a "$VERSION_ID" != "24.04" ]; then
# with ASan we have to use the (extremely) slow stack unwind as the
# shipped version of the library is built with -fomit-frame-pointer
export ASAN_OPTIONS=fast_unwind_on_malloc=0
fi
}
: ${SRC_DIR=$PWD}
: ${BUILD_DIR=$PWD}
: ${DEPS_BUILD_DIR=$BUILD_DIR/..}
: ${DEPS_PREFIX=/usr/local}
@ -184,16 +225,25 @@ case "$TEST" in
default)
# should be the default, but lets make sure
CONFIG="--with-printf-hooks=glibc"
if system_uses_openssl3; then
prepare_system_openssl $1
fi
;;
openssl*)
CONFIG="--disable-defaults --enable-pki --enable-openssl --enable-pem"
export TESTS_PLUGINS="test-vectors openssl! pem"
CONFIG="--disable-defaults --enable-pki --enable-openssl --enable-pem --enable-drbg"
export TESTS_PLUGINS="test-vectors openssl! pem drbg"
DEPS="libssl-dev"
if test "$TEST" = "openssl-3"; then
DEPS=""
use_custom_openssl $1
elif test "$TEST" = "openssl-awslc"; then
DEPS="cmake ninja-build golang"
use_custom_openssl $1
elif system_uses_openssl3; then
prepare_system_openssl $1
else
# the kdf plugin is necessary to build against older OpenSSL versions
TESTS_PLUGINS="$TESTS_PLUGINS kdf"
fi
;;
gcrypt)
@ -202,16 +252,16 @@ gcrypt)
DEPS="libgcrypt20-dev"
;;
botan)
CONFIG="--disable-defaults --enable-pki --enable-botan --enable-pem --enable-hmac --enable-x509 --enable-constraints"
export TESTS_PLUGINS="test-vectors botan! pem hmac x509 constraints"
CONFIG="--disable-defaults --enable-pki --enable-botan --enable-pem --enable-hmac --enable-x509 --enable-constraints --enable-drbg"
export TESTS_PLUGINS="test-vectors botan! pem hmac x509 constraints drbg"
DEPS=""
if test "$1" = "build-deps"; then
build_botan
fi
;;
wolfssl)
CONFIG="--disable-defaults --enable-pki --enable-wolfssl --enable-pem --enable-pkcs1 --enable-pkcs8 --enable-x509 --enable-constraints"
export TESTS_PLUGINS="test-vectors wolfssl! pem pkcs1 pkcs8 x509 constraints"
CONFIG="--disable-defaults --enable-pki --enable-wolfssl --enable-pem --enable-pkcs1 --enable-pkcs8 --enable-x509 --enable-constraints --enable-drbg"
export TESTS_PLUGINS="test-vectors wolfssl! pem pkcs1 pkcs8 x509 constraints drbg"
# build with custom options to enable all the features the plugin supports
DEPS=""
if test "$1" = "build-deps"; then
@ -220,15 +270,11 @@ wolfssl)
;;
printf-builtin)
CONFIG="--with-printf-hooks=builtin"
;;
all|codeql|coverage|sonarcloud|no-dbg)
if [ "$TEST" = "sonarcloud" ]; then
if [ -z "$SONAR_PROJECT" -o -z "$SONAR_ORGANIZATION" -o -z "$SONAR_TOKEN" ]; then
echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
"environment variables are required to run this test"
exit 1
fi
if system_uses_openssl3; then
prepare_system_openssl $1
fi
;;
all|alpine|codeql|coverage|sonarcloud|no-dbg|no-testable-ke)
if [ "$TEST" = "codeql" ]; then
# don't run tests, only analyze built code
TARGET=
@ -239,33 +285,50 @@ all|codeql|coverage|sonarcloud|no-dbg)
CONFIG="--enable-all --disable-android-dns --disable-android-log
--disable-kernel-pfroute --disable-keychain
--disable-lock-profiler --disable-padlock --disable-fuzzing
--disable-osx-attr --disable-tkm --disable-uci
--disable-osx-attr --disable-tkm
--disable-unwind-backtraces
--disable-svc --disable-dbghelp-backtraces --disable-socket-win
--disable-kernel-wfp --disable-kernel-iph --disable-winhttp
--disable-python-eggs-install"
--disable-kernel-wfp --disable-kernel-iph --disable-winhttp"
# not enabled on the build server
CONFIG="$CONFIG --disable-af-alg"
# unable to build Botan on Ubuntu 20.04
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "20.04" ]; then
CONFIG="$CONFIG --disable-botan"
fi
if test "$TEST" != "coverage"; then
CONFIG="$CONFIG --disable-coverage"
else
# not actually required but configure checks for it
DEPS="$DEPS lcov"
TARGET="coverage"
fi
DEPS="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
if [ "$TEST" = "no-testable-ke" ]; then
CONFIG="$CONFIG --without-testable-ke"
fi
DEPS="$DEPS libcurl4-gnutls-dev libsoup-3.0-dev libunbound-dev libldns-dev
libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
libldap2-dev libpcsclite-dev libpam0g-dev binutils-dev libnm-dev
libgcrypt20-dev libjson-c-dev python3-pip libtspi-dev libsystemd-dev
libselinux1-dev libiptc-dev"
PYDEPS="tox"
libgcrypt20-dev libjson-c-dev libtspi-dev libsystemd-dev
libselinux1-dev libiptc-dev ruby-rubygems python3-build tox"
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "22.04" -a "$1" = "build-deps" ]; then
# python3-build is broken on 22.04 with venv (https://bugs.launchpad.net/ubuntu/+source/python-build/+bug/1992108)
# while installing python3-virtualenv should help, it doesn't. as even
# after uninstalling python3-venv, build prefers the latter
sudo python3 -m pip install --upgrade build
fi
if [ "$TEST" = "alpine" ]; then
# override the whole list for alpine
DEPS="git gmp-dev openldap-dev curl-dev ldns-dev unbound-dev libsoup3-dev
libxml2-dev tpm2-tss-dev tpm2-tss-sys mariadb-dev wolfssl-dev
libgcrypt-dev botan3-dev pcsc-lite-dev networkmanager-dev
linux-pam-dev iptables-dev libselinux-dev binutils-dev libunwind-dev
ruby py3-setuptools py3-build py3-tox"
# musl does not provide backtrace(), so use libunwind
CONFIG="$CONFIG --enable-unwind-backtraces"
# alpine doesn't have systemd
CONFIG="$CONFIG --disable-systemd --disable-cert-enroll-timer"
# no TrouSerS either
CONFIG="$CONFIG --disable-tss-trousers --disable-aikgen"
# and no Clearsilver
CONFIG="$CONFIG --disable-fast --disable-manager --disable-medsrv"
fi
if test "$1" = "build-deps"; then
if [ "$ID" = "ubuntu" -a "$VERSION_ID" != "20.04" ]; then
build_botan
fi
build_botan
build_wolfssl
build_tss2
fi
@ -288,13 +351,6 @@ win*)
TARGET=
else
CONFIG="$CONFIG --enable-openssl"
case "$IMG" in
2015|2017)
# old OpenSSL versions don't provide HKDF
CONFIG="$CONFIG --enable-kdf"
;;
esac
CFLAGS="$CFLAGS -I$OPENSSL_DIR/include"
LDFLAGS="-L$OPENSSL_DIR/lib"
case "$IMG" in
@ -332,19 +388,19 @@ macos)
# use the same options as in the Homebrew Formula
CONFIG="--disable-defaults --enable-charon --enable-cmd --enable-constraints
--enable-curl --enable-eap-gtc --enable-eap-identity
--enable-eap-md5 --enable-eap-mschapv2 --enable-farp --enable-ikev1
--enable-ikev2 --enable-kernel-libipsec --enable-kernel-pfkey
--enable-eap-md5 --enable-eap-mschapv2 --enable-eap-peap
--enable-dhcp --enable-farp --enable-ikev1 --enable-ikev2
--enable-kernel-libipsec --enable-kernel-pfkey
--enable-kernel-pfroute --enable-nonce --enable-openssl
--enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
--enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
--enable-socket-default --enable-sshkey --enable-stroke
--enable-swanctl --enable-unity --enable-updown
--enable-x509 --enable-xauth-generic"
DEPS="automake autoconf libtool bison gettext pkg-config openssl@1.1 curl"
--enable-pkcs8 --enable-pkcs11 --enable-pki --enable-pubkey
--enable-revocation --enable-socket-default --enable-sshkey
--enable-stroke --enable-swanctl --enable-unity --enable-updown
--enable-x509 --enable-xauth-generic --enable-drbg"
DEPS="automake autoconf libtool bison gperf pkgconf openssl@3 curl"
BREW_PREFIX=$(brew --prefix)
export PATH=$BREW_PREFIX/opt/bison/bin:$PATH
export ACLOCAL_PATH=$BREW_PREFIX/opt/gettext/share/aclocal:$ACLOCAL_PATH
for pkg in openssl@1.1 curl
for pkg in openssl@3 curl
do
PKG_CONFIG_PATH=$BREW_PREFIX/opt/$pkg/lib/pkgconfig:$PKG_CONFIG_PATH
CPPFLAGS="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
@ -397,7 +453,11 @@ fuzzing)
;;
nm)
DEPS="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
cd src/frontends/gnome
ORIG_SRC_DIR="$SRC_DIR"
SRC_DIR="$ORIG_SRC_DIR/src/frontends/gnome"
if [ "$ORIG_SRC_DIR" = "$BUILD_DIR" ]; then
BUILD_DIR="$SRC_DIR"
fi
# don't run ./configure with ./autogen.sh
export NOCONFIGURE=1
;;
@ -419,8 +479,12 @@ case "$1" in
deps)
case "$OS_NAME" in
linux)
sudo apt-get update -qq && \
sudo apt-get install -qq bison flex gperf gettext $DEPS
sudo apt-get update -y && \
sudo apt-get install -y automake autoconf libtool pkgconf bison flex gperf $DEPS
;;
alpine)
apk add --no-cache build-base automake autoconf libtool pkgconfig && \
apk add --no-cache bison flex gperf tzdata $DEPS
;;
macos)
brew update && \
@ -428,15 +492,11 @@ deps)
;;
freebsd)
pkg install -y automake autoconf libtool pkgconf && \
pkg install -y bison flex gperf gettext $DEPS
pkg install -y bison flex gperf $DEPS
;;
esac
exit $?
;;
pydeps)
test -z "$PYDEPS" || pip3 -q install --user $PYDEPS
exit $?
;;
build-deps)
exit
;;
@ -452,21 +512,28 @@ CONFIG="$CONFIG
--enable-leak-detective=${LEAK_DETECTIVE-no}"
case "$TEST" in
codeql|coverage|freebsd|fuzzing|sonarcloud|win*)
alpine|codeql|coverage|freebsd|fuzzing|sonarcloud|win*)
# don't use AddressSanitizer if it's not available or causes conflicts
CONFIG="$CONFIG --disable-asan"
;;
*)
if [ "$LEAK_DETECTIVE" != "yes" ]; then
CONFIG="$CONFIG --enable-asan"
else
CONFIG="$CONFIG --disable-asan"
fi
;;
esac
echo "$ ./autogen.sh"
./autogen.sh || exit $?
cd $SRC_DIR
if [ ! -f ./configure ]; then
echo "$ ./autogen.sh"
./autogen.sh || exit $?
fi
cd $BUILD_DIR
echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG || exit $?
CC="$CC" CFLAGS="$CFLAGS" $SRC_DIR/configure $CONFIG || exit $?
case "$TEST" in
apidoc)
@ -481,10 +548,10 @@ case "$TEST" in
sonarcloud)
# without target, coverage is currently not supported anyway because
# sonarqube only supports gcov, not lcov
build-wrapper-linux-x86-64 --out-dir bw-output make -j4 || exit $?
build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR make -j$(nproc) || exit $?
;;
*)
make -j4 $TARGET || exit $?
make -j$(nproc) $TARGET || exit $?
;;
esac
@ -496,23 +563,9 @@ apidoc)
fi
rm make.warnings
;;
sonarcloud)
sonar-scanner \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.projectKey=${SONAR_PROJECT} \
-Dsonar.organization=${SONAR_ORGANIZATION} \
-Dsonar.login=${SONAR_TOKEN} \
-Dsonar.projectVersion=$(git describe --exclude 'android-*')+${BUILD_NUMBER} \
-Dsonar.sources=. \
-Dsonar.cfamily.threads=2 \
-Dsonar.cfamily.analysisCache.mode=fs \
-Dsonar.cfamily.analysisCache.path=$HOME/.sonar-cache \
-Dsonar.cfamily.build-wrapper-output=bw-output || exit $?
rm -r bw-output .scannerwork
;;
android)
rm -r strongswan-*
cd src/frontends/android
cd $SRC_DIR/src/frontends/android
echo "$ ./gradlew build"
NDK_CCACHE=ccache ./gradlew build --info || exit $?
;;
@ -520,6 +573,7 @@ android)
;;
esac
cd $SRC_DIR
# ensure there are no unignored build artifacts (or other changes) in the Git repo
unclean="$(git status --porcelain)"
if test -n "$unclean"; then

View File

@ -1,3 +1,5 @@
sonar.sources=.
# exclude these files completely
sonar.exclusions=\
src/manager/templates/static/jquery.js, \
@ -29,16 +31,25 @@ sonar.issue.ignore.allfile.a2.fileRegexp=made by GNU Bison
sonar.issue.ignore.allfile.a3.fileRegexp=produced by gperf
# ignore some rules
sonar.issue.ignore.multicriteria=m1,m2,m3,m4,m5,m6
sonar.issue.ignore.multicriteria=m1,m2,m3,m4,m5,m6,m7
# Multiple variables should not be declared on the same line
sonar.issue.ignore.multicriteria.m1.ruleKey=c:S1659
sonar.issue.ignore.multicriteria.m1.resourceKey=**/*
# Functions should not be defined with a variable number of arguments
sonar.issue.ignore.multicriteria.m2.ruleKey=c:S923
sonar.issue.ignore.multicriteria.m2.resourceKey=**/*
# Function names should be used either as a call with a parameter list or with the "&" operator
sonar.issue.ignore.multicriteria.m3.ruleKey=c:S936
sonar.issue.ignore.multicriteria.m3.resourceKey=**/*
# Unused function parameters should be removed
sonar.issue.ignore.multicriteria.m4.ruleKey=c:S1172
sonar.issue.ignore.multicriteria.m4.resourceKey=**/*
# Single line comments should start with "--"
sonar.issue.ignore.multicriteria.m5.ruleKey=plsql:SingleLineCommentsSyntaxCheck
sonar.issue.ignore.multicriteria.m5.resourceKey=**/*
# User-defined types should not be passed as variadic arguments
sonar.issue.ignore.multicriteria.m6.ruleKey=c:S5270
sonar.issue.ignore.multicriteria.m6.resourceKey=**/*
# Loop variables should be declared in the minimal possible scope
sonar.issue.ignore.multicriteria.m7.ruleKey=c:S5955
sonar.issue.ignore.multicriteria.m7.resourceKey=**/*

View File

@ -142,3 +142,7 @@ endif
if USE_LIBTPMTSS
SUBDIRS += tpm_extendpcr
endif
if USE_CERT_ENROLL
SUBDIRS += cert-enroll
endif

5
src/cert-enroll/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
cert-enroll
cert-enroll.8
cert-enroll.service
cert-install-swanctl
cert-install-ipsec

View File

@ -0,0 +1,61 @@
REPLACE_TARGETS = \
cert-enroll \
cert-install-swanctl \
cert-install-ipsec \
cert-enroll.service
$(REPLACE_TARGETS) : Makefile
$(AM_V_GEN) \
sed \
-e "s:@SYSCONFDIR@:$(sysconfdir):" \
-e "s:@SBINDIR@:$(sbindir):" \
-e "s:@BINDIR@:$(bindir):" \
-e "s:@IPSEC_SCRIPT@:$(ipsec_script):" \
$(srcdir)/$@.in > $@
sbin_SCRIPTS = cert-enroll
cert-enroll : cert-enroll.in
cert_enrolldir = $(sysconfdir)/cert-enroll.d
cert_enroll_DATA = cert-enroll.conf
install-data-local:
test -e "$(DESTDIR)$(cert_enrolldir)/cert-install.d" || \
$(INSTALL) -d "$(DESTDIR)$(cert_enrolldir)/cert-install.d" || true
cert_install_availabledir = $(sysconfdir)/cert-enroll.d/cert-install-available
cert_install_available_DATA = \
cert-install-ssl \
cert-install-sssd \
cert-install-ldaputils \
cert-install-cockpit \
cert-install-dirsrv \
cert-install-lighttpd \
cert-install-openxpki \
cert-install-gitea \
cert-install-ipsec \
cert-install-swanctl
cert-install-swanctl : cert-install-swanctl.in
cert-install-ipsec : cert-install-ipsec.in
EXTRA_DIST = \
cert-enroll.conf cert-enroll.in cert-enroll.service.in cert-enroll.timer \
cert-install-cockpit cert-install-dirsrv cert-install-gitea \
cert-install-ipsec.in cert-install-ldaputils cert-install-lighttpd \
cert-install-openxpki cert-install-ssl cert-install-sssd \
cert-install-swanctl.in
man8_MANS = cert-enroll.8
CLEANFILES = cert-enroll cert-install-swanctl cert-install-ipsec
if USE_CERT_ENROLL_TIMER
systemdsystemunit_DATA = cert-enroll.service cert-enroll.timer
cert-enroll.service : cert-enroll.service.in
CLEANFILES += cert-enroll.service
endif

View File

@ -0,0 +1,86 @@
.TH CERT-ENROLL 8 "2023-09-01" "@PACKAGE_VERSION@" "strongSwan"
.
.SH "NAME"
.
cert-enroll \- Requests X.509 certificates from a PKI via EST or SCEP protocols
.
.SH "SYNOPSIS"
.
.SY "cert-enroll"
.OP \-c "file
.OP \-i "directory"
.YS
.
.SY "cert-enroll"
.B \-h
.YS
.
.SH "DESCRIPTION"
.
.B cert-enroll
uses the strongSwan
.BR pki
command to request an initial X.509 certificate from a PKI server using either
the EST (Enrollment over Secure Transport) or the SCEP (Simple Certificate
Enrollment Protocol) certificate enrollment protocol. After having received the
host certificate, its expiration date can be monitored periodically and a new
certificate will be automatically requested when a predefined deadline of
remaining validity days is reached. The availability of new CA certificates is
also monitored periodically. The generated RSA or EDCSA private key, the
downloaded X.509 certificate and the current set of CA certificates can then be
installed in specific places on the host via a selection of installation scripts.
.
.SH "OPTIONS"
.
.TP
.B "\-h"
Prints usage information and a short summary of the available commands.
.TP
.BI "\-c " file
Path to the optional local configuration file that can be used to overwrite
parameters in the default configuration file
@sysconfdir@/cert-enroll.d/cert-enroll.conf.
Defaults to @sysconfdir@/cert-enroll.d/cert-enroll.conf.local.
.TP
.BI "\-i " directory
Path to the installation script directory. Defaults to
@sysconfdir@/cert-enroll.d/cert-install.d. This directory will contain dynamic
links to selected installation scripts available in the
@sysconfdir@/cert-enroll.d/cert-install-available directory.
.
.SH "CONFIGURATION"
.
The configuration parameters for the
.BR cert-enroll
script are defined in
.BR cert-enroll.conf.
and selected parameters can be overwritten with the local configuration file
.BR cert-enroll.conf.local.
.
.SH FILES
.
.nf
.na
@sysconfdir@/cert-enroll/cert-enroll.conf default configuration file
.ad
.fi
.nf
.na
@sysconfdir@/cert-enroll/cert-enroll.conf.local optional local configuration file
.ad
.fi
.nf
.na
@sysconfdir@/cert-enroll/cert-install.d default installation script directory
.ad
.fi
.nf
.na
@sysconfdir@/cert-enroll/cert-install-available selection of available installation scripts
.ad
.fi
.nf
.na
/root/certificates/ default certificate directory
.ad
.fi

View File

@ -0,0 +1,81 @@
#!/bin/bash
# Global configuration file for the strongSwan cert-enroll script
#
# This default configuration file should not be edited as the changes
# might get overwritten by software updates. If you just want to adapt
# a few parameters, do this in a 'cert-enroll.conf.local' file which
# will overload the corresponding default values.
# Minimum number of days when a new certificate will be requested
: ${MIN_DAYS=42}
# Interval in days for checking CA certificate changes
: ${CA_CHECK_INTERVAL=7}
# Directory where the certificates and keys will be stored
: ${CERTDIR=/root/certificates}
# Key and certificate names
: ${HOSTKEY=key.pem}
: ${HOSTCERT=cert.pem}
: ${CERTREQ=req.pem}
: ${CAOUT=cacert}
: ${ROOTCA=$CAOUT.pem}
: ${OLDROOTCA=$CAOUT-old.pem}
: ${OLDERROOTCA=$CAOUT-older.pem}
: ${SUBCA=$CAOUT-1.pem}
: ${OLDSUBCA=$CAOUT-1-old.pem}
: ${OLDERSUBCA=$CAOUT-1-older.pem}
: ${RAOUT=racert}
: ${RACERT=$RAOUT.pem}
# TLS root CA certificate required by EST
# (might also be a Let's Encrypt or other third party root CA certificate)
: ${TLSROOTCA=$CERTDIR/$ROOTCA}
# Private key type (either "ECDSA", "RSA", "ED25519" or "ED448")
: ${KEYTYPE=ECDSA}
# RSA private key size in bits
: ${RSA_SIZE=3072}
# ECDSA private key size in bits
: ${ECDSA_SIZE=256}
# User group to be assigned to the private key (used by cert-install-ssl)
: ${USER_GROUP=systemd-journal-upload}
# Systemd service using the private key (used by cert-install-ssl)
: ${SERVICE=systemd-journal-upload}
# Fully Qualified Domain Name and Distinguished Name
: ${FQDN=`hostname`}
: ${DN="C=CH, O=Example Company, CN=$FQDN"}
# Subject Alternative Name (SAN)
: ${SAN=--san $FQDN}
# Optional additional Subject Alternative Names (fill in and uncomment)
: ${ADD_SANS=()}
# ADD_SANS+=(--san )
# Certificate profile (one of "client", "server", "dual" or "ocsp")
: ${PROFILE=dual}
# Enrollment protocol (either "EST" or "SCEP")
: ${PROTOCOL=EST}
# Protocol for fetching CA certificates (either "EST" or "SCEP")
: ${CA_PROTOCOL=$PROTOCOL}
# URL of the EST enrollment server
: ${EST_URL=https://pki.example.com}
# URL of the SCEP enrollment server
: ${SCEP_URL=http://pki.example.com/scep}
# Maximum poll time in seconds for EST enrollment process
: ${EST_MAX_POLL_TIME=28800}
# Maximum poll time in seconds for SCEP enrollment process
: ${SCEP_MAX_POLL_TIME=28800}

View File

@ -0,0 +1,422 @@
#!/bin/bash
# Enroll or re-enroll X.509 certificates via EST or SCEP protocols using
# the strongSwan pki tool. Install the certificates via the install scripts
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set default configuration and installation scripts
#
CONFIG_DIR="@SYSCONFDIR@/cert-enroll.d"
CONFIG_SCRIPT="$CONFIG_DIR/cert-enroll.conf"
CONFIG_SCRIPT_LOCAL="$CONFIG_DIR/cert-enroll.conf.local"
INSTALL_SCRIPT_DIR="$CONFIG_DIR/cert-install.d"
##############################################################################
# Parse optional arguments
#
function help()
{
echo "Usage:"
echo "cert-enroll [-c filename] [-i directory]"
echo "Options:"
echo " -h print usage information"
echo " -c local configuration file, defaults to $CONFIG_SCRIPT_LOCAL"
echo " -i installation script directory, defaults to $INSTALL_SCRIPT_DIR"
}
while getopts "c:i:h" opt
do
case "$opt" in
c)
CONFIG_SCRIPT_LOCAL=${OPTARG}
;;
i)
INSTALL_SCRIPT_DIR=${OPTARG}
;;
h)
help; exit 0
;;
esac
done
##############################################################################
# Set optional local configuration parameters, overwriting default parameters
#
if [ -f $CONFIG_SCRIPT_LOCAL ]
then
. $CONFIG_SCRIPT_LOCAL
fi
##############################################################################
# Set default configuration parameters
#
if [ -f $CONFIG_SCRIPT ]
then
. $CONFIG_SCRIPT
elif [ -f $CONFIG_SCRIPT_LOCAL ]
then
echo "Warning: default configuration file '$CONFIG_SCRIPT' not found," \
"depending on local configuration '$CONFIG_SCRIPT_LOCAL' only"
else
echo "Error: neither '$CONFIG_SCRIPT' nor '$CONFIG_SCRIPT_LOCAL'" \
"configuration files found"
exit 1
fi
# Path to the strongSwan pki command
PKI="@BINDIR@/pki"
##############################################################################
# Define some local functions
#
function gen_private_key()
{
status=0
$PKI --gen --type $key_type --size $size --outform pem > "$1" || status=$?
if [ $status -ne 0 -o ! -s $1 ]
then
echo "Error: generation of $size bit $KEYTYPE private key failed"
exit 1
fi
chmod 600 $1
echo " generated $size bit $KEYTYPE private key '$1'"
}
function gen_cert_request()
{
status=0
$PKI --req --in "$1/$HOSTKEY" --type $in_type --dn "$DN" \
$SAN "${ADD_SANS[@]}" \
--profile $PROFILE --outform pem > "$1/$CERTREQ" || status=$?
if [ $status -ne 0 -o ! -s $1 ]
then
echo "Error: generation of PKCS#10 certificate request failed"
exit 1
fi
chmod 600 $1
echo " generated PKCS#10 certificate request"
}
function get_ca_certs()
{
cd $1
status=0
if [ $CA_PROTOCOL == "EST" ]
then
$PKI --estca --url $EST_URL --cacert $TLSROOTCA --caout $CAOUT \
--outform pem --force || status=$?
if [ $status -ne 0 -o ! -s $ROOTCA -o ! -s $SUBCA ]
then
echo "Error: download of CA certificates via EST failed"
exit 1
fi
echo " downloaded CA certificates via EST"
else
$PKI --scepca --url $SCEP_URL --caout $CAOUT --raout $RAOUT \
--outform pem --force || status=$?
if [ $status -ne 0 -o ! -s $ROOTCA -o ! -s $SUBCA -o ! -s $RACERT ]
then
echo "Error: download of CA or RA certificates via SCEP failed"
exit 1
fi
echo " downloaded CA and RA certificates via SCEP"
fi
cd $CERTDIR
}
function check_ca_certs()
{
get_ca_certs "$CERTDIR/new"
ROOTCA_CHANGED=0
cmp -s $ROOTCA new/$ROOTCA || ROOTCA_CHANGED=$?
if [ $ROOTCA_CHANGED -ne 0 ]
then
echo "Warning: '$ROOTCA' has changed"
if [ -s old/$ROOTCA ]
then
mv old/$ROOTCA older
fi
mv $ROOTCA old
mv new/$ROOTCA .
fi
SUBCA_CHANGED=0
cmp -s $SUBCA new/$SUBCA || SUBCA_CHANGED=$?
if [ $SUBCA_CHANGED -ne 0 ]
then
echo "Warning: '$SUBCA' has changed"
if [ -s old/$SUBCA ]
then
mv old/$SUBCA older
fi
mv $SUBCA old
mv new/$SUBCA .
fi
if [ $CA_PROTOCOL == "SCEP" ]
then
mv new/$RACERT .
fi
if [ $ROOTCA_CHANGED -eq 0 -a $SUBCA_CHANGED -eq 0 ]
then
echo "Ok: '$ROOTCA' and '$SUBCA' are unchanged"
rm new/$ROOTCA new/$SUBCA
return 0
else
return 1
fi
}
function install_certs()
{
for script in $INSTALL_SCRIPT_DIR/*
do
status=0
echo " executing '$script'"
KEYTYPE="$KEYTYPE" CERTDIR="$CERTDIR" HOSTKEY="$HOSTKEY" \
HOSTCERT="$HOSTCERT" ROOTCA="$ROOTCA" SUBCA="$SUBCA" \
OLDROOTCA="$OLDROOTCA" OLDSUBCA="$OLDSUBCA" \
OLDERROOTCA="$OLDERROOTCA" OLDERSUBCA="$OLDERSUBCA" \
USER_GROUP="$USER_GROUP" SERVICE="$SERVICE" \
/bin/bash $script || status=$?
if [ $status -ne 0 ]
then
echo "Error: executing '$script' failed"
fi
done
}
##############################################################################
# SCEP certificate enrollment protocol requires RSA
#
if [ $PROTOCOL == "SCEP" -a $KEYTYPE != "RSA" ]
then
echo "Warning: the SCEP protocol does not support $KEYTYPE keys," \
"switched to RSA key"
KEYTYPE="RSA"
fi
##############################################################################
# Select key size
#
case $KEYTYPE in
RSA)
key_type="rsa"
in_type="rsa"
size=$RSA_SIZE
;;
ECDSA)
key_type="ecdsa"
in_type="ecdsa"
size=$ECDSA_SIZE
;;
ED25519)
key_type="ed25519"
in_type="priv"
size="256"
;;
ED448)
key_type="ed448"
in_type="priv"
size="456"
;;
*)
echo "Error: $KEYTYPE key type unknown"
exit 1
;;
esac
##############################################################################
# Create and change into certificates directory
#
mkdir -p $CERTDIR/new $CERTDIR/old $CERTDIR/older
cd $CERTDIR
echo " changed into the '$CERTDIR' directory"
#############################################################################
# Fetch the CA certificates with the selected enrollment protocol if possible
#
if [ $CA_PROTOCOL == "EST" -a ! -s $TLSROOTCA ]
then
echo " no TLS root CA certificate for EST available," \
"revert to SCEP CA protocol"
CA_PROTOCOL="SCEP"
fi
##############################################################################
# Check if non-empty certificate already exists
#
if [ -s $HOSTCERT ]
then
##############################################################################
# Determine the remaining validity of the certificate in days
#
DAYS=$($PKI --print --in $HOSTCERT | awk '/not after/ {
if (($7 == "ok") && ($11 == "days)")) {
print $10
} else {
printf("0")
}
}' -)
if [ $DAYS -ge $MIN_DAYS ]
then
echo "Ok: validity of '$HOSTCERT' is $DAYS days," \
"more than the minimum of $MIN_DAYS days"
if [ $(expr $DAYS % $CA_CHECK_INTERVAL) -eq 0 ]
then
check_ca_certs && exit 0
# update CA certificates if any of them changed
install_certs
fi
exit 0
fi
echo "Warning: validity of '$HOSTCERT' is only $DAYS days," \
"less than the minimum of $MIN_DAYS days"
##############################################################################
# Check if non-empty private key already exists
#
if [ -s "new/$HOSTKEY" ]
then
echo "Warning: 'new/$HOSTKEY' already exists," \
"resuming $PROTOCOL re-enrollment"
else
##############################################################################
# Generate new private key
#
gen_private_key "new/$HOSTKEY"
fi
##############################################################################
# Get and check CA and RA certificates via SCEP or EST
#
check_ca_certs
##############################################################################
# Re-enroll certificate via SCEP or EST
#
status=0
if [ $PROTOCOL == "SCEP" ]
then
$PKI --scep --url $SCEP_URL --in new/$HOSTKEY --key $HOSTKEY \
--cert $HOSTCERT --dn "$DN" $SAN "${ADD_SANS[@]}" \
--cacert-sig $SUBCA --cacert-enc $RACERT --cacert $ROOTCA \
--maxpolltime $SCEP_MAX_POLL_TIME --profile $PROFILE \
--outform pem > new/$HOSTCERT || status=$?
else
gen_cert_request "$CERTDIR/new"
$PKI --est --url $EST_URL --in new/$CERTREQ --cacert $ROOTCA \
--cacert $SUBCA --cacert $TLSROOTCA --key $HOSTKEY \
--cert $HOSTCERT --maxpolltime $EST_MAX_POLL_TIME \
--outform pem > new/$HOSTCERT || status=$?
fi
if [ $status -ne 0 -o ! -s $HOSTCERT ]
then
echo "Error: re-enrollment via $PROTOCOL failed"
exit 1
fi
echo "Ok: successfully re-enrolled '$HOSTCERT' via $PROTOCOL"
##############################################################################
# Replace old key and certificate
#
mv $HOSTKEY $HOSTCERT old
mv new/$HOSTKEY new/$HOSTCERT .
if [ $PROTOCOL == "EST" ]
then
mv $CERTREQ old
mv new/$CERTREQ .
fi
echo " replaced old '$HOSTKEY' and '$HOSTCERT'"
##############################################################################
# Install keys and certificates
#
install_certs
exit 0
else
##############################################################################
# No certificate exists yet
#
echo " '$HOSTCERT' doesn't exist yet"
##############################################################################
# Check if non-empty private key already exists
#
if [ -s "$HOSTKEY" ]
then
echo "Warning: '$HOSTKEY' already exists, resuming $PROTOCOL enrollment"
else
##############################################################################
# Generate private key
#
gen_private_key "$HOSTKEY"
fi
##############################################################################
# Get CA and RA certificates via SCEP
#
get_ca_certs "$CERTDIR"
##############################################################################
# Enroll certificate via SCEP or EST
#
status=0
if [ $PROTOCOL == "SCEP" ]
then
$PKI --scep --url $SCEP_URL --in $HOSTKEY --dn "$DN" $SAN "${ADD_SANS[@]}" \
--cacert-sig $SUBCA --cacert-enc $RACERT --cacert $ROOTCA \
--profile $PROFILE --maxpolltime $SCEP_MAX_POLL_TIME \
--outform pem > $HOSTCERT || status=$?
else
gen_cert_request "$CERTDIR"
$PKI --est --url $EST_URL --in $CERTREQ \
--cacert $ROOTCA --cacert $SUBCA --cacert $TLSROOTCA \
--maxpolltime $EST_MAX_POLL_TIME \
--outform pem > $HOSTCERT || status=$?
fi
if [ $status -ne 0 -o ! -s $HOSTCERT ]
then
echo "Error: enrollment via $PROTOCOL failed"
exit 1
fi
echo "Ok: successfully enrolled '$HOSTCERT' via $PROTOCOL"
##############################################################################
# Install keys and certificates
#
install_certs
exit 0
fi

View File

@ -0,0 +1,9 @@
[Unit]
Description=X.509 certificate checking (re-enrollment if necessary)
Documentation=man:cert-enroll(8)
[Service]
Type=oneshot
User=root
ExecStart=@SBINDIR@/cert-enroll
SuccessExitStatus=1

View File

@ -0,0 +1,12 @@
[Unit]
Description=daily check of the remaining X.509 certificate lifetime
Documentation=man:cert-enroll(8)
[Timer]
# The cert-enroll script should be run once a day.
OnCalendar=*-*-* 02:00:00
RandomizedDelaySec=7200
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -0,0 +1,50 @@
#!/bin/bash
# Install the generated key and certificate as TLS credentials for the Cockpit
# management interface.
#
# Copyright (C) 2024 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set local paths
#
# Path to the cockpit credentials
COCKPIT="/etc/cockpit/ws-certs.d"
##############################################################################
# Change into the certificates directory
#
cd $CERTDIR
##############################################################################
# Install the private key and certificate
#
cp $HOSTKEY $COCKPIT/ldap.key
cp $HOSTCERT $COCKPIT/ldap.crt
##############################################################################
# Restart the cockpit systemd service
#
/usr/bin/systemctl restart cockpit.service
exit 0

View File

@ -0,0 +1,113 @@
#!/bin/bash
# Install the private key, the server certificate and the CA certificates in
# the NSS key (key4.db) and certificate (cert9.db) databases used by the 389
# directory server to identify itself via TLS.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set some local paths
#
# Path to the NSS directory
NSS_DIR="/etc/dirsrv/slapd-localhost"
# Path to openssl command
OPENSSL=/usr/bin/openssl
# Path to certutil command
CERTUTIL=/usr/bin/certutil
# Path to pk12util command
PK12UTIL=/usr/bin/pk12util
# Path to dsctl command
DSCTL=/usr/sbin/dsctl
##############################################################################
# Go to the NSS directory, create a new build subdirectory and change into it
#
rm -r -f $NSS_DIR/build && mkdir $NSS_DIR/build && cd $NSS_DIR/build
##############################################################################
# Generate a new random password into passwd.txt and also store it in pin.txt
#
$OPENSSL rand -base64 48 > passwd.txt
echo "Internal (Software) Token:$(cat passwd.txt)" > pin.txt
chmod 600 passwd.txt pin.txt
##############################################################################
# Pack the private key and host certificate into a PKCS#12 container
#
$OPENSSL pkcs12 -export -name "Server-Cert" -passout file:passwd.txt \
-in $CERTDIR/$HOSTCERT -inkey $CERTDIR/$HOSTKEY \
-out Server-Cert.p12
##############################################################################
# Create a new password-protected NSS store and import the PKCS#12 file
#
$CERTUTIL -d . -N -f passwd.txt
$PK12UTIL -d . -i Server-Cert.p12 -w passwd.txt -k passwd.txt
##############################################################################
# Install the CA certificates
#
$CERTUTIL -d . -A -t "CT,," -n "Root CA" -i $CERTDIR/$ROOTCA \
-f passwd.txt
$CERTUTIL -d . -A -t "CT,," -n "Sub CA" -i $CERTDIR/$SUBCA \
-f passwd.txt
if [ -s $CERTDIR/old/$ROOTCA ]
then
$CERTUTIL -d . -A -t "CT,," -n "Old Root CA" -i $CERTDIR/old/$ROOTCA \
-f passwd.txt
fi
if [ -s $CERTDIR/old/$SUBCA ]
then
$CERTUTIL -d . -A -t "CT,," -n "Old Sub CA" -i $CERTDIR/old/$SUBCA \
-f passwd.txt
fi
if [ -s $CERTDIR/older/$ROOTCA ]
then
$CERTUTIL -d . -A -t "CT,," -n "Older Root CA" -i $CERTDIR/older/$ROOTCA \
-f passwd.txt
fi
if [ -s $CERTDIR/older/$SUBCA ]
then
$CERTUTIL -d . -A -t "CT,," -n "Older Sub CA" -i $CERTDIR/older/$SUBCA \
-f passwd.txt
fi
##############################################################################
# Move the generated credentials to the correct place and delete the build dir
#
mv key4.db cert9.db passwd.txt pin.txt ..
rm -r $NSS_DIR/build
##############################################################################
# Restart the 389 directory server
#
$DSCTL localhost restart
exit 0

View File

@ -0,0 +1,49 @@
#!/bin/bash
# Install the generated key and certificate as TLS credentials for the Gitea
# web server.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set local paths
#
# Path to the Gitea credentials
GITEA="/var/lib/gitea/custom"
##############################################################################
# Change into the certificates directory
#
cd $CERTDIR
##############################################################################
# Install the private key and certificate
#
cp $HOSTKEY $HOSTCERT $GITEA/
##############################################################################
# Restart the gitea systemd service
#
/usr/bin/systemctl restart gitea.service
exit 0

View File

@ -0,0 +1,81 @@
#!/bin/bash
# Install the generated key as well as host an CA certificates on a host running
# strongSwan via the legacy ipsec command line tool.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set some local paths
#
# Path to the strongSwan ipsec command
IPSEC="@SBINDIR@/@IPSEC_SCRIPT@"
# Path to the strongSwan ipsec.d directory
IPSECDIR="@SYSCONFDIR@/ipsec.d"
##############################################################################
# Change into the certificates directory
#
cd $CERTDIR
##############################################################################
# Install the private key
#
cp $HOSTKEY $IPSECDIR/private
##############################################################################
# Install the certificate
#
cp $HOSTCERT $IPSECDIR/certs
##############################################################################
# Install the CA certificates
#
cp $ROOTCA $SUBCA $IPSECDIR/cacerts
if [ -s old/$ROOTCA ]
then
cp old/$ROOTCA $IPSECDIR/cacerts/$OLDROOTCA
fi
if [ -s old/$SUBCA ]
then
cp old/$SUBCA $IPSECDIR/cacerts/$OLDSUBCA
fi
if [ -s older/$ROOTCA ]
then
cp older/$ROOTCA $IPSECDIR/cacerts/$OLDERROOTCA
fi
if [ -s older/$SUBCA ]
then
cp older/$SUBCA $IPSECDIR/cacerts/$OLDERSUBCA
fi
##############################################################################
# Reload the strongSwan charon daemon if it is running
#
if [ -e /var/run/charon.pid ]
then
$IPSEC rereadall
$IPSEC reload
fi
exit 0

View File

@ -0,0 +1,64 @@
#!/bin/bash
# Concatenate the present and past CA certificates into a single TLS_CACERT
# file defined by ldap.conf so that the ldap-utils can verify the LDAP server
# certificate.
#
# Copyright (C) 2024 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set some local paths
#
# Path to the LDAP configuration file
LDAP_CONF="/etc/ldap/ldap.conf"
# Extract or set path to the LDAP TLS CA cert directory
LDAP_TLS_CACERTS=$(awk '/TLS_CACERT/ {print $2}' $LDAP_CONF)
##############################################################################
# Change into the certificate directory
#
cd $CERTDIR
##############################################################################
# Concatenate the CA certificates into a single file
#
cat $ROOTCA $SUBCA > $LDAP_TLS_CACERTS
if [ -s old/$ROOTCA ]
then
cat old/$ROOTCA >> $LDAP_TLS_CACERTS
fi
if [ -s old/$SUBCA ]
then
cat old/$SUBCA >> $LDAP_TLS_CACERTS
fi
if [ -s older/$ROOTCA ]
then
cat older/$ROOTCA >> $LDAP_TLS_CACERTS
fi
if [ -s older/$SUBCA ]
then
cat older/$SUBCA >> $LDAP_TLS_CACERTS
fi
exit 0

View File

@ -0,0 +1,48 @@
#!/bin/bash
# Install the generated key and certificate as TLS credentials for a web server
# based based on the lighttpd daemon.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Change into the certificates directory
#
cd $CERTDIR
##############################################################################
# Install the web server's TLS key and certificate in single file
#
cat $HOSTKEY $HOSTCERT > /etc/lighttpd/https-cert.pem
##############################################################################
# Restart the lighttpd daemon
#
test -f /usr/bin/systemctl && /usr/bin/systemctl list-unit-files lighttpd.service | \
grep -q "lighttpd.service enabled" && status=$? || status=$?
if [ $status -eq 0 ]
then
/usr/bin/systemctl restart lighttpd.service
else
/etc/init.d/lighttpd reload
fi
exit 0

View File

@ -0,0 +1,74 @@
#!/bin/bash
# Install the generated key and host certificate as well as the CA certificates
# as TLS credentials for the Apache2-based OpenXPKI web server.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set local paths
#
# Path to the OpenXPKI TLS credentials
OPENXPKI_TLS="/etc/openxpki/tls"
##############################################################################
# Change into the certificates directory
#
cd $CERTDIR
##############################################################################
# Install the private key and certificate
#
cp $HOSTKEY $OPENXPKI_TLS/private/openxpki.pem
cp $HOSTCERT $OPENXPKI_TLS/endentity/openxpki.crt
##############################################################################
# Install and rehash the CA certificates
#
cp $ROOTCA $SUBCA $OPENXPKI_TLS/chain
if [ -s old/$ROOTCA ]
then
cp old/$ROOTCA $OPENXPKI_TLS/chain/$OLDROOTCA
fi
if [ -s old/$SUBCA ]
then
cp old/$SUBCA $OPENXPKI_TLS/chain/$OLDSUBCA
fi
if [ -s older/$ROOTCA ]
then
cp older/$ROOTCA $OPENXPKI_TLS/chain/$OLDERROOTCA
fi
if [ -s older/$SUBCA ]
then
cp older/$SUBCA $OPENXPKI_TLS/chain/$OLDERSUBCA
fi
rm -f $OPENXPKI_TLS/chain/*.0
/usr/bin/openssl rehash $OPENXPKI_TLS/chain
##############################################################################
# Restart the apache2 systemd service
#
/usr/bin/systemctl restart apache2.service
exit 0

View File

@ -0,0 +1,69 @@
#!/bin/bash
# Install the generated key, host certificate and associated CA certificates
# as credentials for a TLS-protected client-server connection.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set local paths
#
# Path to the SSL credentials directory
SSL_DIR="/etc/ssl/$USER_GROUP"
##############################################################################
# Create a credentials directory with given user group settings
#
mkdir -p $SSL_DIR
chgrp $USER_GROUP $SSL_DIR
chmod g+s $SSL_DIR
cp $CERTDIR/{$HOSTKEY,$HOSTCERT} $SSL_DIR
chmod g+r $SSL_DIR/$HOSTKEY
cat $CERTDIR/{$ROOTCA,$SUBCA} > $SSL_DIR/trusted.pem
if [ -s $CERTDIR/old/$ROOTCA ]
then
cat $CERTDIR/old/$ROOTCA >> $SSL_DIR/trusted.pem
fi
if [ -s $CERTDIR/old/$SUBCA ]
then
cat $CERTDIR/old/$SUBCA >> $SSL_DIR/trusted.pem
fi
if [ -s $CERTDIR/older/$ROOTCA ]
then
cat $CERTDIR/older/$ROOTCA >> $SSL_DIR/trusted.pem
fi
if [ -s $CERTDIR/older/$SUBCA ]
then
cat $CERTDIR/older/$SUBCA >> $SSL_DIR/trusted.pem
fi
##############################################################################
# Restart the systemd service if it is active
#
if /usr/bin/systemctl -q is-active $SERVICE
then
/usr/bin/systemctl restart $SERVICE
fi
exit 0

View File

@ -0,0 +1,78 @@
#!/bin/bash
# Install the present and past CA certificates in the ldap_tls_cacertdir
# directory defined by sssd.conf, followed by the execution of the
# openssl_rehash command in that directory so that the SSSD daemon can verify
# the LDAP server certificate.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set some local paths
#
# Path to the SSSD configuration file
SSSD_CONF="/etc/sssd/sssd.conf"
# Extract or set path to the LDAP TLS CA cert directory
LDAP_TLS_CACERTDIR=$(awk '/ldap_tls_cacertdir/ {print $3}' $SSSD_CONF)
##############################################################################
# Change into the certificate directory
#
cd $CERTDIR
##############################################################################
# Install and rehash the CA certificates
#
cp $ROOTCA $SUBCA $LDAP_TLS_CACERTDIR
if [ -s old/$ROOTCA ]
then
cp old/$ROOTCA $LDAP_TLS_CACERTDIR/$OLDROOTCA
fi
if [ -s old/$SUBCA ]
then
cp old/$SUBCA $LDAP_TLS_CACERTDIR/$OLDSUBCA
fi
if [ -s older/$ROOTCA ]
then
cp older/$ROOTCA $LDAP_TLS_CACERTDIR/$OLDERROOTCA
fi
if [ -s older/$SUBCA ]
then
cp older/$SUBCA $LDAP_TLS_CACERTDIR/$OLDERSUBCA
fi
rm -f $LDAP_TLS_CACERTDIR/*.0
/usr/bin/openssl rehash $LDAP_TLS_CACERTDIR
##############################################################################
# Restart the SSSD daemon
#
if [ -f /usr/bin/systemctl ]
then
/usr/bin/systemctl restart sssd.service
else
/etc/init.d/sssd restart
fi
exit 0

View File

@ -0,0 +1,89 @@
#!/bin/bash
# Install the generated key and certificates on the host running strongSwan
# as a systemd service and managed via the swanctl command line tool.
#
# Copyright (C) 2023 Andreas Steffen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
set -e
##############################################################################
# Set some local paths
#
# Path to the strongSwan swanctl command
SWANCTL="@SBINDIR@/swanctl"
# Path to the strongSwan swanctl directory
SWANCTLDIR="@SYSCONFDIR@/swanctl"
##############################################################################
# Change to the certificate directory
#
cd $CERTDIR
##############################################################################
# Install the private key
#
if [ $KEYTYPE == "RSA" ]
then
cp $HOSTKEY ${SWANCTLDIR}/rsa
elif [ $KEYTYPE == "ECDSA" ]
then
cp $HOSTKEY ${SWANCTLDIR}/ecdsa
else
cp $HOSTKEY ${SWANCTLDIR}/private
fi
##############################################################################
# Install the certificate
#
cp $HOSTCERT ${SWANCTLDIR}/x509
##############################################################################
# Install the CA certificates
#
cp $ROOTCA $SUBCA ${SWANCTLDIR}/x509ca
if [ -s old/$ROOTCA ]
then
cp old/$ROOTCA ${SWANCTLDIR}/x509ca/$OLDROOTCA
fi
if [ -s old/$SUBCA ]
then
cp old/$SUBCA ${SWANCTLDIR}/x509ca/$OLDSUBCA
fi
if [ -s older/$ROOTCA ]
then
cp older/$ROOTCA ${SWANCTLDIR}/x509ca/$OLDERROOTCA
fi
if [ -s older/$SUBCA ]
then
cp older/$SUBCA ${SWANCTLDIR}/x509ca/$OLDERSUBCA
fi
##############################################################################
# Reload the strongswan systemd service if it is running
#
if /usr/bin/systemctl -q is-active strongswan.service
then
$SWANCTL --load-creds --noprompt
$SWANCTL --load-conns
fi
exit 0

View File

@ -95,6 +95,10 @@ options can be used.
.TP
.BI "\-\-rsa " path
RSA private key to use for authentication (if a password is required, it will
be requested on demand). For other key types use \fI\-\-priv\fR.
.TP
.BI "\-\-priv " path
Private key to use for authentication (if a password is required, it will
be requested on demand).
.TP
.BI "\-\-p12 " path

View File

@ -170,7 +170,7 @@ static peer_cfg_t* create_peer_cfg(private_cmd_connection_t *this)
case PROF_V1_XAUTH_AM:
case PROF_V1_XAUTH_PSK_AM:
case PROF_V1_HYBRID_AM:
peer.aggressive = TRUE;
peer.options |= OPT_IKEV1_AGGRESSIVE;
/* FALL */
case PROF_V1_PUB:
case PROF_V1_XAUTH:
@ -499,6 +499,7 @@ METHOD(cmd_connection_t, handle, bool,
this->xautheap = arg;
break;
case CMD_OPT_RSA:
case CMD_OPT_PRIV:
case CMD_OPT_AGENT:
case CMD_OPT_PKCS12:
this->key_seen = TRUE;
@ -584,7 +585,7 @@ cmd_connection_t *cmd_connection_create()
lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create_with_prio(
(callback_job_cb_t)initiate, this, NULL,
(callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL));
callback_job_cancel_thread, JOB_PRIO_CRITICAL));
return &this->public;
}

View File

@ -71,6 +71,7 @@ static shared_key_t* callback_shared(private_cmd_creds_t *this,
id_match_t *match_me, id_match_t *match_other)
{
shared_key_t *shared;
linked_list_t *owners;
char *label, *pwd = NULL;
if (type == this->prompted)
@ -113,7 +114,16 @@ static shared_key_t* callback_shared(private_cmd_creds_t *this,
shared = shared_key_create(type, chunk_clone(chunk_from_str(pwd)));
memwipe(pwd, strlen(pwd));
/* cache password in case it is required more than once */
this->creds->add_shared(this->creds, shared, NULL);
owners = linked_list_create();
if (me)
{
owners->insert_last(owners, me->clone(me));
}
if (other && other->get_type(other) != ID_ANY)
{
owners->insert_last(owners, other->clone(other));
}
this->creds->add_shared_list(this->creds, shared, owners);
return shared->get_ref(shared);
}
@ -237,6 +247,9 @@ METHOD(cmd_creds_t, handle, bool,
case CMD_OPT_RSA:
load_key(this, KEY_RSA, arg);
break;
case CMD_OPT_PRIV:
load_key(this, KEY_ANY, arg);
break;
case CMD_OPT_PKCS12:
load_pkcs12(this, arg);
break;

View File

@ -43,6 +43,8 @@ cmd_option_t cmd_options[CMD_OPT_COUNT] = {
"certificate for authentication or trust chain validation", {}},
{ CMD_OPT_RSA, "rsa", required_argument, "path",
"RSA private key to use for authentication", {}},
{ CMD_OPT_PRIV, "priv", required_argument, "path",
"Private key to use for authentication", {}},
{ CMD_OPT_PKCS12, "p12", required_argument, "path",
"PKCS#12 file with private key and certificates to use for ", {
"authentication and trust chain validation"

View File

@ -40,6 +40,7 @@ enum cmd_option_type_t {
CMD_OPT_REMOTE_IDENTITY,
CMD_OPT_CERT,
CMD_OPT_RSA,
CMD_OPT_PRIV,
CMD_OPT_PKCS12,
CMD_OPT_AGENT,
CMD_OPT_LOCAL_TS,

View File

@ -205,11 +205,29 @@ int main(int argc, char *argv[])
/* install routes via XFRM interfaces, if we can use them */
lib->settings->set_default_str(lib->settings,
"charon-nm.plugins.kernel-netlink.install_routes_xfrmi", "yes");
/* bypass IKE traffic from these routes in case traffic selectors conflict */
/* use a separate routing table to avoid conflicts with regular charon */
lib->settings->set_default_str(lib->settings,
"charon-nm.plugins.socket-default.fwmark", "220");
"charon-nm.routing_table", "210");
/* use the same value as priority (higher than charon's default) */
lib->settings->set_default_str(lib->settings,
"charon-nm.plugins.kernel-netlink.fwmark", "!220");
"charon-nm.routing_table_prio", "210");
/* bypass IKE/ESP from these routes in case traffic selectors conflict */
lib->settings->set_default_str(lib->settings,
"charon-nm.plugins.socket-default.fwmark", "210");
lib->settings->set_default_str(lib->settings,
"charon-nm.plugins.kernel-netlink.fwmark", "!210");
/* trigger a DPD to verify the current path is working */
lib->settings->set_default_str(lib->settings,
"charon-nm.check_current_path", "yes");
/* fail more quickly so users don't have to wait too long for a new SA */
lib->settings->set_default_str(lib->settings,
"charon-nm.retransmit_tries", "3");
lib->settings->set_default_str(lib->settings,
"charon-nm.retransmit_timeout", "2.0");
lib->settings->set_default_str(lib->settings,
"charon-nm.retransmit_base", "1.4");
DBG1(DBG_DMN, "Starting charon NetworkManager backend (strongSwan "VERSION")");
if (lib->integrity)

View File

@ -78,7 +78,8 @@ static job_requeue_t run(nm_backend_t *this)
/**
* Cancel the GLib Main Event Loop
*/
static bool cancel(nm_backend_t *this)
CALLBACK(cancel, bool,
nm_backend_t *this)
{
if (this->loop)
{
@ -152,7 +153,7 @@ static bool nm_backend_init()
lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create_with_prio((callback_job_cb_t)run, this,
NULL, (callback_job_cancel_t)cancel, JOB_PRIO_CRITICAL));
NULL, cancel, JOB_PRIO_CRITICAL));
return TRUE;
}

View File

@ -195,7 +195,7 @@ nm_handler_t *nm_handler_create()
.public = {
.handler = {
.handle = _handle,
.release = nop,
.release = (void*)nop,
.create_attribute_enumerator = _create_attribute_enumerator,
},
.create_enumerator = _create_enumerator,

View File

@ -214,6 +214,10 @@ static void signal_ip_config(NMVpnServicePlugin *plugin,
handler = priv->handler;
/* we can reconnect automatically if interfaces change */
g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CAN_PERSIST,
g_variant_new_boolean (TRUE));
/* NM apparently requires to know the gateway (it uses it to install a
* direct route via physical interface if conflicting routes are passed) */
other = ike_sa->get_other_host(ike_sa);
@ -674,6 +678,51 @@ static bool add_auth_cfg_pw(NMStrongswanPluginPrivate *priv,
return TRUE;
}
/**
* Add traffic selectors to the given config, optionally parse them from a
* semicolon-separated list.
*/
static bool add_traffic_selectors(child_cfg_t *child_cfg, bool local,
const char *list, GError **err)
{
enumerator_t *enumerator;
traffic_selector_t *ts;
char *token;
if (list && strlen(list))
{
enumerator = enumerator_create_token(list, ";", "");
while (enumerator->enumerate(enumerator, &token))
{
ts = traffic_selector_create_from_cidr(token, 0, 0, 65535);
if (!ts)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
"Invalid %s traffic selector '%s'.",
local ? "local" : "remote", token);
enumerator->destroy(enumerator);
return FALSE;
}
child_cfg->add_traffic_selector(child_cfg, local, ts);
}
enumerator->destroy(enumerator);
}
else if (local)
{
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
}
else
{
ts = traffic_selector_create_from_cidr("0.0.0.0/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
ts = traffic_selector_create_from_cidr("::/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
}
return TRUE;
}
/**
* Connect function called from NM via DBUS
*/
@ -692,7 +741,6 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
ike_cfg_t *ike_cfg;
peer_cfg_t *peer_cfg;
child_cfg_t *child_cfg;
traffic_selector_t *ts;
ike_sa_t *ike_sa;
auth_cfg_t *auth;
certificate_t *cert = NULL;
@ -912,10 +960,9 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
if (priv->xfrmi_id)
{ /* set the same mark as for IKE packets on the ESP packets so no routing
* loop is created if the TS covers the VPN server's IP */
child.set_mark_out = (mark_t){
.value = 220,
.mask = 0xffffffff,
};
mark_from_string(lib->settings->get_str(lib->settings,
"charon-nm.plugins.socket-default.fwmark", NULL),
MARK_OP_NONE, &child.set_mark_out);
child.if_id_in = child.if_id_out = priv->xfrmi_id;
}
@ -946,36 +993,22 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
child_cfg->add_proposal(child_cfg, proposal_create_default_aead(PROTO_ESP));
child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
}
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
str = nm_setting_vpn_get_data_item(vpn, "local-ts");
if (!add_traffic_selectors(child_cfg, TRUE, str, err))
{
child_cfg->destroy(child_cfg);
peer_cfg->destroy(peer_cfg);
return FALSE;
}
str = nm_setting_vpn_get_data_item(vpn, "remote-ts");
if (str && strlen(str))
if (!add_traffic_selectors(child_cfg, FALSE, str, err))
{
enumerator = enumerator_create_token(str, ";", "");
while (enumerator->enumerate(enumerator, &str))
{
ts = traffic_selector_create_from_cidr((char*)str, 0, 0, 65535);
if (!ts)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
"Invalid remote traffic selector.");
enumerator->destroy(enumerator);
child_cfg->destroy(child_cfg);
peer_cfg->destroy(peer_cfg);
return FALSE;
}
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
}
enumerator->destroy(enumerator);
}
else
{
ts = traffic_selector_create_from_cidr("0.0.0.0/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
ts = traffic_selector_create_from_cidr("::/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
child_cfg->destroy(child_cfg);
peer_cfg->destroy(peer_cfg);
return FALSE;
}
peer_cfg->add_child_cfg(peer_cfg, child_cfg);
/**

View File

@ -37,7 +37,7 @@
#include "tkm.h"
#include "tkm_nonceg.h"
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
#include "tkm_keymat.h"
#include "tkm_listener.h"
#include "tkm_kernel_ipsec.h"
@ -318,9 +318,9 @@ int main(int argc, char *argv[])
lib->plugins->add_static_features(lib->plugins, "tkm-backend", features,
countof(features), TRUE, NULL, NULL);
if (!register_dh_mapping())
if (!register_ke_mapping())
{
DBG1(DBG_DMN, "no DH group mapping defined - aborting %s", dmn_name);
DBG1(DBG_DMN, "no KE group mapping defined - aborting %s", dmn_name);
goto deinit;
}
@ -410,7 +410,7 @@ int main(int argc, char *argv[])
lib->encoding->remove_encoder(lib->encoding, tkm_encoder_encode);
deinit:
destroy_dh_mapping();
destroy_ke_mapping();
destroy_ca_mapping();
libcharon_deinit();
tkm_deinit();

View File

@ -25,7 +25,9 @@
void charon_esa_acquire(result_type *res, const sp_id_type sp_id)
{
kernel_acquire_data_t data = {};
kernel_acquire_data_t data = {
.cpu = CPU_ID_MAX,
};
DBG1(DBG_KNL, "ees: acquire received for reqid %u", sp_id);
charon->kernel->acquire(charon->kernel, sp_id, &data);

View File

@ -83,9 +83,10 @@ bool tkm_init()
}
/* get limits from tkm */
if (ike_tkm_limits(&max_requests, &limits[TKM_CTX_NONCE], &limits[TKM_CTX_DH],
if (ike_tkm_limits(&max_requests, &limits[TKM_CTX_NONCE], &limits[TKM_CTX_KE],
&limits[TKM_CTX_CC], &limits[TKM_CTX_AE],
&limits[TKM_CTX_ISA], &limits[TKM_CTX_ESA]) != TKM_OK)
&limits[TKM_CTX_ISA], &limits[TKM_CTX_ESA],
&limits[TKM_CTX_BLOB]) != TKM_OK)
{
ees_server_finalize();
tkmlib_final();

View File

@ -20,14 +20,15 @@
#include <utils/debug.h>
#include <threading/rwlock.h>
ENUM_BEGIN(tkm_context_kind_names, TKM_CTX_NONCE, TKM_CTX_ESA,
ENUM_BEGIN(tkm_context_kind_names, TKM_CTX_NONCE, TKM_CTX_BLOB,
"NONCE_CONTEXT",
"DH_CONTEXT",
"CC_CONTEXT",
"ISA_CONTEXT",
"AE_CONTEXT",
"ESA_CONTEXT");
ENUM_END(tkm_context_kind_names, TKM_CTX_ESA);
"ESA_CONTEXT",
"BLOB_CONTEXT");
ENUM_END(tkm_context_kind_names, TKM_CTX_BLOB);
typedef struct private_tkm_id_manager_t private_tkm_id_manager_t;

View File

@ -34,8 +34,8 @@ typedef enum tkm_context_kind_t tkm_context_kind_t;
enum tkm_context_kind_t {
/** Nonce context */
TKM_CTX_NONCE,
/** Diffie-Hellman context */
TKM_CTX_DH,
/** Key Exchange context */
TKM_CTX_KE,
/** Certificate chain context */
TKM_CTX_CC,
/** IKE SA context */
@ -44,6 +44,8 @@ enum tkm_context_kind_t {
TKM_CTX_AE,
/** ESP SA context */
TKM_CTX_ESA,
/** Blob context */
TKM_CTX_BLOB,
/** helper to determine the number of elements in this enum */
TKM_CTX_MAX,

View File

@ -93,6 +93,7 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
kernel_ipsec_add_sa_t *data)
{
esa_info_t esa;
esa_flags_type flags;
esp_spi_type spi_loc, spi_rem;
host_t *local, *peer;
chunk_t *nonce_loc, *nonce_rem;
@ -107,31 +108,31 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
}
esa = *(esa_info_t *)(data->enc_key.ptr);
/* only handle the case where we have both distinct ESP spi's available */
if (esa.spi_r == id->spi)
/* only handle the case where we have both distinct ESP SPIs available,
* which is always the outbound SA */
if (esa.spi_l == id->spi)
{
chunk_free(&esa.nonce_i);
chunk_free(&esa.nonce_r);
return SUCCESS;
}
spi_loc = esa.spi_l;
spi_rem = id->spi;
local = id->src;
peer = id->dst;
if (data->initiator)
{
spi_loc = id->spi;
spi_rem = esa.spi_r;
local = id->dst;
peer = id->src;
nonce_loc = &esa.nonce_i;
nonce_rem = &esa.nonce_r;
flags = TKM_ESA_INITIATOR;
}
else
{
spi_loc = esa.spi_r;
spi_rem = id->spi;
local = id->src;
peer = id->dst;
nonce_loc = &esa.nonce_r;
nonce_rem = &esa.nonce_i;
flags = 0;
}
esa_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_ESA);
@ -150,24 +151,24 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
/*
* creation of first CHILD SA:
* no nonce and no dh contexts because the ones from the IKE SA are re-used
* no nonce and no ke contexts because the ones from the IKE SA are re-used
*/
nonce_loc_id = tkm->chunk_map->get_id(tkm->chunk_map, nonce_loc);
if (nonce_loc_id == 0 && esa.dh_id == 0)
if (nonce_loc_id == 0 && esa.ke_ids.size == 0)
{
if (ike_esa_create_first(esa_id, esa.isa_id, data->reqid, 1, spi_loc,
spi_rem) != TKM_OK)
if (ike_esa_create_first(esa_id, esa.isa_id, data->reqid, 1, flags,
spi_loc, spi_rem) != TKM_OK)
{
DBG1(DBG_KNL, "child SA (%llu, first) creation failed", esa_id);
goto failure;
}
}
/* creation of child SA without PFS: no dh context */
else if (nonce_loc_id != 0 && esa.dh_id == 0)
/* creation of child SA without PFS: no ke context */
else if (nonce_loc_id != 0 && esa.ke_ids.size == 0)
{
chunk_to_sequence(nonce_rem, &nc_rem, sizeof(nonce_type));
if (ike_esa_create_no_pfs(esa_id, esa.isa_id, data->reqid, 1,
nonce_loc_id, nc_rem, data->initiator,
nonce_loc_id, nc_rem, flags,
spi_loc, spi_rem) != TKM_OK)
{
DBG1(DBG_KNL, "child SA (%llu, no PFS) creation failed", esa_id);
@ -176,12 +177,12 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
tkm->chunk_map->remove(tkm->chunk_map, nonce_loc);
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_NONCE, nonce_loc_id);
}
/* creation of subsequent child SA with PFS: nonce and dh context are set */
/* creation of subsequent child SA with PFS: nonce and ke context are set */
else
{
chunk_to_sequence(nonce_rem, &nc_rem, sizeof(nonce_type));
if (ike_esa_create(esa_id, esa.isa_id, data->reqid, 1, esa.dh_id,
nonce_loc_id, nc_rem, data->initiator, spi_loc,
if (ike_esa_create(esa_id, esa.isa_id, data->reqid, 1, esa.ke_ids,
nonce_loc_id, nc_rem, flags, spi_loc,
spi_rem) != TKM_OK)
{
DBG1(DBG_KNL, "child SA (%llu) creation failed", esa_id);

View File

@ -20,87 +20,110 @@
#include "tkm.h"
#include "tkm_utils.h"
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
#include <daemon.h>
#include <collections/hashtable.h>
typedef struct private_tkm_diffie_hellman_t private_tkm_diffie_hellman_t;
typedef struct private_tkm_key_exchange_t private_tkm_key_exchange_t;
static hashtable_t *group_map = NULL;
static hashtable_t *method_map = NULL;
/**
* Private data of a tkm_diffie_hellman_t object.
* Private data of a tkm_key_exchange_t object.
*/
struct private_tkm_diffie_hellman_t {
struct private_tkm_key_exchange_t {
/**
* Public tkm_diffie_hellman_t interface.
* Public tkm_key_exchange_t interface.
*/
tkm_diffie_hellman_t public;
tkm_key_exchange_t public;
/**
* Diffie-Hellman group number.
* Key exchange method identifier.
*/
key_exchange_method_t group;
key_exchange_method_t method;
/**
* Diffie-Hellman public value.
* Key exchange algorithm ID corresponding to method.
*/
dh_pubvalue_type pubvalue;
uint64_t kea_id;
/**
* Context id.
*/
dh_id_type context_id;
ke_id_type context_id;
};
METHOD(key_exchange_t, get_public_key, bool,
private_tkm_diffie_hellman_t *this, chunk_t *value)
private_tkm_key_exchange_t *this, chunk_t *value)
{
sequence_to_chunk(this->pubvalue.data, this->pubvalue.size, value);
return TRUE;
blob_id_type pubvalue_id;
blob_length_type pubvalue_length;
bool ret = FALSE;
pubvalue_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_BLOB);
if (pubvalue_id)
{
ret = ike_ke_get(this->context_id, this->kea_id, pubvalue_id,
&pubvalue_length) == TKM_OK &&
blob_to_chunk(pubvalue_id, pubvalue_length, value);
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_BLOB, pubvalue_id);
}
return ret;
}
METHOD(key_exchange_t, get_shared_secret, bool,
private_tkm_diffie_hellman_t *this, chunk_t *secret)
private_tkm_key_exchange_t *this, chunk_t *secret)
{
*secret = chunk_empty;
return TRUE;
}
METHOD(key_exchange_t, set_public_key, bool,
private_tkm_diffie_hellman_t *this, chunk_t value)
private_tkm_key_exchange_t *this, chunk_t value)
{
dh_pubvalue_type othervalue;
othervalue.size = value.len;
memcpy(&othervalue.data, value.ptr, value.len);
blob_id_type pubvalue_id;
bool ret = FALSE;
return ike_dh_generate_key(this->context_id, othervalue) == TKM_OK;
if (!key_exchange_verify_pubkey(this->method, value))
{
return FALSE;
}
pubvalue_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_BLOB);
if (pubvalue_id)
{
ret = chunk_to_blob(pubvalue_id, &value) &&
ike_ke_set(this->context_id, this->kea_id, pubvalue_id) == TKM_OK;
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_BLOB, pubvalue_id);
}
return ret;
}
METHOD(key_exchange_t, get_method, key_exchange_method_t,
private_tkm_diffie_hellman_t *this)
private_tkm_key_exchange_t *this)
{
return this->group;
return this->method;
}
METHOD(key_exchange_t, destroy, void,
private_tkm_diffie_hellman_t *this)
private_tkm_key_exchange_t *this)
{
if (ike_dh_reset(this->context_id) != TKM_OK)
if (ike_ke_reset(this->context_id) != TKM_OK)
{
DBG1(DBG_LIB, "failed to reset DH context %d", this->context_id);
DBG1(DBG_LIB, "failed to reset KE context %d", this->context_id);
}
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_DH, this->context_id);
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_KE, this->context_id);
free(this);
}
METHOD(tkm_diffie_hellman_t, get_id, dh_id_type,
private_tkm_diffie_hellman_t *this)
METHOD(tkm_key_exchange_t, get_id, ke_id_type,
private_tkm_key_exchange_t *this)
{
return this->context_id;
}
@ -119,7 +142,7 @@ static bool equals(void *key, void *other_key)
/*
* Described in header.
*/
int register_dh_mapping()
int register_ke_mapping()
{
int count, i;
char *iana_id_str, *tkm_id_str;
@ -132,7 +155,7 @@ int register_dh_mapping()
(hashtable_equals_t)equals, 16);
enumerator = lib->settings->create_key_value_enumerator(lib->settings,
"%s.dh_mapping",
"%s.ke_mapping",
lib->ns);
while (enumerator->enumerate(enumerator, &iana_id_str, &tkm_id_str))
@ -148,7 +171,7 @@ int register_dh_mapping()
count = map->get_count(map);
plugin_feature_t f[count + 1];
f[0] = PLUGIN_REGISTER(KE, tkm_diffie_hellman_create);
f[0] = PLUGIN_REGISTER(KE, tkm_key_exchange_create);
i = 1;
enumerator = map->create_enumerator(map);
@ -159,12 +182,12 @@ int register_dh_mapping()
}
enumerator->destroy(enumerator);
lib->plugins->add_static_features(lib->plugins, "tkm-dh", f, countof(f),
lib->plugins->add_static_features(lib->plugins, "tkm-ke", f, countof(f),
TRUE, NULL, NULL);
if (count > 0)
{
group_map = map;
method_map = map;
}
else
{
@ -177,32 +200,33 @@ int register_dh_mapping()
/*
* Described in header.
*/
void destroy_dh_mapping()
void destroy_ke_mapping()
{
enumerator_t *enumerator;
char *key, *value;
if (group_map)
if (method_map)
{
enumerator = group_map->create_enumerator(group_map);
enumerator = method_map->create_enumerator(method_map);
while (enumerator->enumerate(enumerator, &key, &value))
{
free(key);
free(value);
}
enumerator->destroy(enumerator);
group_map->destroy(group_map);
method_map->destroy(method_map);
method_map = NULL;
}
}
/*
* Described in header.
*/
tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group)
tkm_key_exchange_t *tkm_key_exchange_create(key_exchange_method_t method)
{
private_tkm_diffie_hellman_t *this;
private_tkm_key_exchange_t *this;
if (!group_map)
if (!method_map)
{
return NULL;
}
@ -218,8 +242,8 @@ tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group)
},
.get_id = _get_id,
},
.group = group,
.context_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_DH),
.method = method,
.context_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_KE),
);
if (!this->context_id)
@ -228,18 +252,14 @@ tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group)
return NULL;
}
uint64_t *dha_id = group_map->get(group_map, &group);
if (!dha_id)
uint64_t *kea_id_ptr = method_map->get(method_map, &method);
if (!kea_id_ptr)
{
free(this);
return NULL;
}
if (ike_dh_create(this->context_id, *dha_id, &this->pubvalue) != TKM_OK)
{
free(this);
return NULL;
}
this->kea_id = *kea_id_ptr;
return &this->public;
}

View File

@ -16,14 +16,14 @@
*/
/**
* @defgroup tkm-dh diffie hellman
* @defgroup tkm-ke key exchange
* @{ @ingroup tkm
*/
#ifndef TKM_DIFFIE_HELLMAN_H_
#define TKM_DIFFIE_HELLMAN_H_
#ifndef TKM_KEY_EXCHANGE_H_
#define TKM_KEY_EXCHANGE_H_
typedef struct tkm_diffie_hellman_t tkm_diffie_hellman_t;
typedef struct tkm_key_exchange_t tkm_key_exchange_t;
#include <library.h>
#include <tkm/types.h>
@ -31,7 +31,7 @@ typedef struct tkm_diffie_hellman_t tkm_diffie_hellman_t;
/**
* key_exchange_t implementation using the trusted key manager.
*/
struct tkm_diffie_hellman_t {
struct tkm_key_exchange_t {
/**
* Implements key_exchange_t interface.
@ -39,33 +39,33 @@ struct tkm_diffie_hellman_t {
key_exchange_t ke;
/**
* Get Diffie-Hellman context id.
* Get Key Exchange context id.
*
* @return id of this DH context.
* @return id of this KE context.
*/
dh_id_type (*get_id)(tkm_diffie_hellman_t * const this);
ke_id_type (*get_id)(tkm_key_exchange_t * const this);
};
/**
* Loads IANA DH group identifier to TKM id mapping from config and registers
* the corresponding DH features.
* Loads IANA KE method identifier to TKM id mapping from config and registers
* the corresponding KE plugin features.
*
* @return number of registered mappings
*/
int register_dh_mapping();
int register_ke_mapping();
/**
* Destroy IANA DH group identifier to TKM id mapping.
* Destroy IANA KE method identifier to TKM id mapping.
*/
void destroy_dh_mapping();
void destroy_ke_mapping();
/**
* Creates a new tkm_diffie_hellman_t object.
* Creates a new tkm_key_exchange_t object.
*
* @param group Diffie Hellman group number to use
* @return tkm_diffie_hellman_t object, NULL if not supported
* @param method Key exchange method to use
* @return tkm_key_exchange_t object, NULL if not supported
*/
tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group);
tkm_key_exchange_t *tkm_key_exchange_create(key_exchange_method_t method);
#endif /** TKM_DIFFIE_HELLMAN_H_ @}*/
#endif /** TKM_KEY_EXCHANGE_H_ @}*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Tobias Brunner
* Copyright (C) 2015-2020 Tobias Brunner
* Copyright (C) 2012 Reto Buerki
* Copyright (C) 2012 Adrian-Ken Rueegsegger
*
@ -24,7 +24,7 @@
#include "tkm.h"
#include "tkm_types.h"
#include "tkm_utils.h"
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
#include "tkm_keymat.h"
#include "tkm_aead.h"
@ -94,33 +94,50 @@ METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
return lib->crypto->create_nonce_gen(lib->crypto);
}
/**
* Concatenate the TKM KE IDs of the passed key exchanges
*/
static bool concat_ke_ids(array_t *kes, ke_ids_type *ids)
{
tkm_key_exchange_t *tkm_ke;
uint32_t i;
memset(ids, 0, sizeof(*ids));
ids->size = array_count(kes);
if (!ids->size || ids->size > 8)
{
return FALSE;
}
for (i = 0; i < ids->size; i++)
{
array_get(kes, i, &tkm_ke);
ids->data[i] = tkm_ke->get_id(tkm_ke);
}
return TRUE;
}
METHOD(keymat_v2_t, derive_ike_keys, bool,
private_tkm_keymat_t *this, proposal_t *proposal, key_exchange_t *ke,
private_tkm_keymat_t *this, proposal_t *proposal, array_t *kes,
chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
pseudo_random_function_t rekey_function, chunk_t rekey_skd)
{
uint64_t nc_id, spi_loc, spi_rem;
uint64_t nc_id = 0, spi_loc, spi_rem;
chunk_t *nonce;
tkm_diffie_hellman_t *tkm_dh;
dh_id_type dh_id;
ke_ids_type ke_ids;
nonce_type nonce_rem;
result_type res;
block_len_type block_len;
icv_len_type icv_len;
iv_len_type iv_len;
/* Acquire nonce context id */
nonce = this->initiator ? &nonce_i : &nonce_r;
nc_id = tkm->chunk_map->get_id(tkm->chunk_map, nonce);
if (!nc_id)
if (!concat_ke_ids(kes, &ke_ids))
{
DBG1(DBG_IKE, "unable to acquire context id for nonce");
return FALSE;
}
/* Get DH context id */
tkm_dh = (tkm_diffie_hellman_t *)ke;
dh_id = tkm_dh->get_id(tkm_dh);
nonce = this->initiator ? &nonce_i : &nonce_r;
if (this->initiator)
{
@ -137,16 +154,24 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
if (rekey_function == PRF_UNDEFINED)
{
/* Acquire nonce context id */
nc_id = tkm->chunk_map->get_id(tkm->chunk_map, nonce);
if (!nc_id)
{
DBG1(DBG_IKE, "unable to acquire context id for nonce");
return FALSE;
}
this->ae_ctx_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_AE);
if (!this->ae_ctx_id)
{
DBG1(DBG_IKE, "unable to acquire ae context id");
return FALSE;
}
DBG1(DBG_IKE, "deriving IKE keys (nc: %llu, dh: %llu, spi_loc: %llx, "
"spi_rem: %llx)", nc_id, dh_id, spi_loc, spi_rem);
res = ike_isa_create(this->isa_ctx_id, this->ae_ctx_id, 1, dh_id, nc_id,
nonce_rem, this->initiator, spi_loc, spi_rem,
DBG1(DBG_IKE, "deriving IKE keys (nc: %llu, ke: %llu, spi_loc: %llx, "
"spi_rem: %llx)", nc_id, ke_ids.data[0], spi_loc, spi_rem);
res = ike_isa_create(this->isa_ctx_id, this->ae_ctx_id, 1, ke_ids.data[0],
nc_id, nonce_rem, this->initiator, spi_loc, spi_rem,
&block_len, &icv_len, &iv_len);
}
else
@ -159,77 +184,103 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
return FALSE;
}
isa_info = *((isa_info_t *)(rekey_skd.ptr));
DBG1(DBG_IKE, "deriving IKE keys (parent_isa: %llu, ae: %llu, nc: %llu,"
" dh: %llu, spi_loc: %llx, spi_rem: %llx)", isa_info.parent_isa_id,
isa_info.ae_id, nc_id, dh_id, spi_loc, spi_rem);
if (!tkm->idmgr->acquire_ref(tkm->idmgr, TKM_CTX_AE, isa_info.ae_id))
if (this->ae_ctx_id == isa_info.ae_id)
{
DBG1(DBG_IKE, "deriving IKE keys (parent_isa: %llu, ae: %llu, "
"ke: %llu, spi_loc: %llx, spi_rem: %llx)", isa_info.parent_isa_id,
isa_info.ae_id, ke_ids.data[0], spi_loc, spi_rem);
res = ike_isa_update(this->isa_ctx_id, ke_ids.data[0]);
}
else if (!(nc_id = tkm->chunk_map->get_id(tkm->chunk_map, nonce)))
{
DBG1(DBG_IKE, "unable to acquire context id for nonce");
return FALSE;
}
else if (!tkm->idmgr->acquire_ref(tkm->idmgr, TKM_CTX_AE, isa_info.ae_id))
{
DBG1(DBG_IKE, "unable to acquire reference for ae: %llu",
isa_info.ae_id);
return FALSE;
}
this->ae_ctx_id = isa_info.ae_id;
res = ike_isa_create_child(this->isa_ctx_id, isa_info.parent_isa_id, 1,
dh_id, nc_id, nonce_rem, this->initiator,
spi_loc, spi_rem, &block_len, &icv_len,
&iv_len);
else
{
DBG1(DBG_IKE, "deriving IKE keys (parent_isa: %llu, ae: %llu, nc: %llu, "
"ke: %llu, spi_loc: %llx, spi_rem: %llx)", isa_info.parent_isa_id,
isa_info.ae_id, nc_id, ke_ids.data[0], spi_loc, spi_rem);
this->ae_ctx_id = isa_info.ae_id;
res = ike_isa_create_child(this->isa_ctx_id, isa_info.parent_isa_id, 1,
ke_ids, nc_id, nonce_rem, this->initiator,
spi_loc, spi_rem, &block_len, &icv_len,
&iv_len);
}
chunk_free(&rekey_skd);
}
if (nc_id)
{
tkm->chunk_map->remove(tkm->chunk_map, nonce);
if (ike_nc_reset(nc_id) != TKM_OK)
{
DBG1(DBG_IKE, "failed to reset nonce context %llu", nc_id);
}
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_NONCE, nc_id);
}
if (res != TKM_OK)
{
DBG1(DBG_IKE, "key derivation failed (isa: %llu)", this->isa_ctx_id);
return FALSE;
}
this->aead = tkm_aead_create(this->isa_ctx_id, block_len, icv_len, iv_len);
if (!this->aead)
{
this->aead = tkm_aead_create(this->isa_ctx_id, block_len, icv_len,
iv_len);
}
/* TODO: Add failure handler (see keymat_v2.c) */
tkm->chunk_map->remove(tkm->chunk_map, nonce);
if (ike_nc_reset(nc_id) != TKM_OK)
{
DBG1(DBG_IKE, "failed to reset nonce context %llu", nc_id);
}
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_NONCE, nc_id);
return TRUE;
}
METHOD(keymat_v2_t, derive_child_keys, bool,
private_tkm_keymat_t *this, proposal_t *proposal, key_exchange_t *ke,
private_tkm_keymat_t *this, proposal_t *proposal, array_t *kes,
chunk_t nonce_i, chunk_t nonce_r, chunk_t *encr_i, chunk_t *integ_i,
chunk_t *encr_r, chunk_t *integ_r)
{
esa_info_t *esa_info_i, *esa_info_r;
dh_id_type dh_id = 0;
ke_ids_type ke_ids = {};
if (ke)
if (kes && !concat_ke_ids(kes, &ke_ids))
{
dh_id = ((tkm_diffie_hellman_t *)ke)->get_id((tkm_diffie_hellman_t *)ke);
return FALSE;
}
INIT(esa_info_i,
.isa_id = this->isa_ctx_id,
.spi_r = proposal->get_spi(proposal),
.spi_l = proposal->get_spi(proposal),
.nonce_i = chunk_clone(nonce_i),
.nonce_r = chunk_clone(nonce_r),
.is_encr_r = FALSE,
.dh_id = dh_id,
.ke_ids = ke_ids,
);
INIT(esa_info_r,
.isa_id = this->isa_ctx_id,
.spi_r = proposal->get_spi(proposal),
.spi_l = proposal->get_spi(proposal),
.nonce_i = chunk_clone(nonce_i),
.nonce_r = chunk_clone(nonce_r),
.is_encr_r = TRUE,
.dh_id = dh_id,
.ke_ids = ke_ids,
);
DBG1(DBG_CHD, "passing on esa info (isa: %llu, spi_r: %x, dh_id: %llu)",
esa_info_i->isa_id, ntohl(esa_info_i->spi_r), esa_info_i->dh_id);
DBG1(DBG_CHD, "passing on esa info (isa: %llu, spi_l: %x, "
"ke_id[%llu]: %llu)", esa_info_i->isa_id, ntohl(esa_info_i->spi_l),
esa_info_i->ke_ids.size, esa_info_i->ke_ids.data[0]);
/* store ESA info in encr_i/r, which is passed to add_sa */
*encr_i = chunk_create((u_char *)esa_info_i, sizeof(esa_info_t));
@ -246,10 +297,30 @@ METHOD(keymat_t, get_aead, aead_t*,
return this->aead;
}
METHOD(keymat_v2_t, get_int_auth, bool,
private_tkm_keymat_t *this, bool verify, chunk_t data, chunk_t prev,
chunk_t *auth)
{
blob_id_type data_id;
bool ret = FALSE;
*auth = chunk_empty;
data_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_BLOB);
if (data_id)
{
ret = chunk_to_blob(data_id, &data) &&
ike_isa_int_auth(this->isa_ctx_id, verify, data_id) == TKM_OK;
tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_BLOB, data_id);
}
return ret;
}
METHOD(keymat_v2_t, get_auth_octets, bool,
private_tkm_keymat_t *this, bool verify, chunk_t ike_sa_init,
chunk_t nonce, chunk_t ppk, identification_t *id, char reserved[3],
chunk_t *octets, array_t *schemes)
chunk_t nonce, chunk_t int_auth, chunk_t ppk, identification_t *id,
char reserved[3], chunk_t *octets, array_t *schemes)
{
sign_info_t *sign;
@ -279,6 +350,12 @@ METHOD(keymat_v2_t, get_skd, pseudo_random_function_t,
{
isa_info_t *isa_info;
if (!this->ae_ctx_id)
{
*skd = chunk_empty;
return PRF_UNDEFINED;
}
INIT(isa_info,
.parent_isa_id = this->isa_ctx_id,
.ae_id = this->ae_ctx_id,
@ -291,8 +368,8 @@ METHOD(keymat_v2_t, get_skd, pseudo_random_function_t,
METHOD(keymat_v2_t, get_psk_sig, bool,
private_tkm_keymat_t *this, bool verify, chunk_t ike_sa_init, chunk_t nonce,
chunk_t secret, chunk_t ppk, identification_t *id, char reserved[3],
chunk_t *sig)
chunk_t int_auth, chunk_t secret, chunk_t ppk, identification_t *id,
char reserved[3], chunk_t *sig)
{
return FALSE;
}
@ -388,6 +465,7 @@ tkm_keymat_t *tkm_keymat_create(bool initiator)
.derive_ike_keys_ppk = (void*)return_false,
.derive_child_keys = _derive_child_keys,
.get_skd = _get_skd,
.get_int_auth = _get_int_auth,
.get_auth_octets = _get_auth_octets,
.get_psk_sig = _get_psk_sig,
.add_hash_algorithm = _add_hash_algorithm,

View File

@ -49,9 +49,9 @@ struct esa_info_t {
isa_id_type isa_id;
/**
* Responder SPI of child SA.
* Local SPI of child SA.
*/
esp_spi_type spi_r;
esp_spi_type spi_l;
/**
* Initiator nonce.
@ -70,9 +70,9 @@ struct esa_info_t {
bool is_encr_r;
/**
* Diffie-Hellman context id.
* Key Exchange context ids.
*/
dh_id_type dh_id;
ke_ids_type ke_ids;
};

View File

@ -17,6 +17,9 @@
#include <utils/debug.h>
#include <tkm/client.h>
#include <tkm/constants.h>
#include "tkm_utils.h"
/* Generic variable-length sequence */
@ -52,3 +55,48 @@ void chunk_to_sequence(const chunk_t * const chunk, void *sequence,
}
memcpy(seq->data, chunk->ptr, seq->size);
}
bool blob_to_chunk(blob_id_type id, blob_length_type len, chunk_t * const chunk)
{
blob_offset_type offset = 0;
bool ret = TRUE;
*chunk = chunk_alloc(len);
while (len > 0 && ret)
{
blob_out_bytes_type blob_data;
blob_length_type slice_len = min(len, sizeof(blob_data.data));
ret = ike_blob_read(id, offset, slice_len, &blob_data) == TKM_OK;
memcpy(chunk->ptr + offset, blob_data.data, slice_len);
offset += slice_len;
len -= slice_len;
}
ike_blob_reset(id);
return ret;
}
bool chunk_to_blob(blob_id_type id, const chunk_t * const chunk)
{
blob_length_type len = chunk->len;
blob_offset_type offset = 0;
bool ret;
ret = ike_blob_create(id, len) == TKM_OK;
while (len > 0 && ret)
{
blob_in_bytes_type blob_data;
blob_length_type slice_len = min(len, sizeof(blob_data.data));
memcpy(blob_data.data, chunk->ptr + offset, slice_len);
blob_data.size = slice_len;
ret = ike_blob_write(id, offset, blob_data) == TKM_OK;
offset += slice_len;
len -= slice_len;
}
return ret;
}

View File

@ -46,4 +46,21 @@ void sequence_to_chunk(const byte_t * const first, const uint32_t len,
void chunk_to_sequence(const chunk_t * const chunk, void *sequence,
const uint32_t typelen);
/**
* Convert blob to chunk and reset the blob.
*
* @param id id of blob
* @param len length of blob
* @param chunk pointer to chunk struct
*/
bool blob_to_chunk(blob_id_type id, blob_length_type len, chunk_t * const chunk);
/**
* Convert chunk to newly created blob.
*
* @param id id of blob
* @param chunk pointer to chunk struct
*/
bool chunk_to_blob(blob_id_type id, const chunk_t * const chunk);
#endif /** TKM_UTILS_H_ @}*/

View File

@ -19,7 +19,7 @@
#include "tkm_id_manager.h"
static const tkm_limits_t limits = {125, 100, 55, 30, 200, 42};
static const tkm_limits_t limits = {125, 100, 55, 30, 200, 42, 21};
START_TEST(test_id_mgr_creation)
{

View File

@ -18,31 +18,31 @@
#include <daemon.h>
#include <tests/test_suite.h>
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
START_TEST(test_dh_creation)
START_TEST(test_ke_creation)
{
tkm_diffie_hellman_t *dh = NULL;
tkm_key_exchange_t *ke = NULL;
dh = tkm_diffie_hellman_create(MODP_768_BIT);
fail_if(dh, "MODP_768 created");
ke = tkm_key_exchange_create(MODP_768_BIT);
fail_if(ke, "MODP_768 created");
dh = tkm_diffie_hellman_create(MODP_4096_BIT);
fail_if(!dh, "MODP_4096 not created");
fail_if(!dh->get_id(dh), "Invalid context id (0)");
ke = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke, "MODP_4096 not created");
fail_if(!ke->get_id(ke), "Invalid context id (0)");
dh->ke.destroy(&dh->ke);
ke->ke.destroy(&ke->ke);
}
END_TEST
START_TEST(test_dh_get_my_pubvalue)
START_TEST(test_ke_get_my_pubvalue)
{
tkm_diffie_hellman_t *dh = tkm_diffie_hellman_create(MODP_4096_BIT);
fail_if(!dh, "Unable to create DH");
tkm_key_exchange_t *ke = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke, "Unable to create KE");
chunk_t value;
ck_assert(dh->ke.get_public_key(&dh->ke, &value));
dh->ke.destroy(&dh->ke);
ck_assert(ke->ke.get_public_key(&ke->ke, &value));
ke->ke.destroy(&ke->ke);
fail_if(value.ptr == NULL, "Pubvalue is NULL");
fail_if(value.len != 512, "Pubvalue size mismatch");
@ -51,19 +51,19 @@ START_TEST(test_dh_get_my_pubvalue)
}
END_TEST
Suite *make_diffie_hellman_tests()
Suite *make_key_exchange_tests()
{
Suite *s;
TCase *tc;
s = suite_create("Diffie-Hellman");
s = suite_create("key exchange");
tc = tcase_create("creation");
tcase_add_test(tc, test_dh_creation);
tcase_add_test(tc, test_ke_creation);
suite_add_tcase(s, tc);
tc = tcase_create("get_my_pubvalue");
tcase_add_test(tc, test_dh_get_my_pubvalue);
tcase_add_test(tc, test_ke_get_my_pubvalue);
suite_add_tcase(s, tc);
return s;

View File

@ -24,7 +24,7 @@
#include "tkm.h"
#include "tkm_nonceg.h"
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
#include "tkm_keymat.h"
#include "tkm_types.h"
@ -47,17 +47,20 @@ START_TEST(test_derive_ike_keys)
fail_unless(ng->nonce_gen.allocate_nonce(&ng->nonce_gen, 32, &nonce),
"Unable to allocate nonce");
tkm_diffie_hellman_t *dh = tkm_diffie_hellman_create(MODP_4096_BIT);
fail_if(!dh, "Unable to create DH");
tkm_key_exchange_t *ke = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke, "Unable to create KE");
/* Use the same pubvalue for both sides */
chunk_t pubvalue;
ck_assert(dh->ke.get_public_key(&dh->ke, &pubvalue));
ck_assert(dh->ke.set_public_key(&dh->ke, pubvalue));
ck_assert(ke->ke.get_public_key(&ke->ke, &pubvalue));
ck_assert(ke->ke.set_public_key(&ke->ke, pubvalue));
array_t *kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke);
fail_unless(keymat->keymat_v2.derive_ike_keys(&keymat->keymat_v2, proposal,
&dh->ke, nonce, nonce, ike_sa_id, PRF_UNDEFINED, chunk_empty),
kes, nonce, nonce, ike_sa_id, PRF_UNDEFINED, chunk_empty),
"Key derivation failed");
array_destroy(kes);
chunk_free(&nonce);
aead_t * const aead = keymat->keymat_v2.keymat.get_aead(&keymat->keymat_v2.keymat, TRUE);
@ -70,17 +73,132 @@ START_TEST(test_derive_ike_keys)
ng->nonce_gen.destroy(&ng->nonce_gen);
proposal->destroy(proposal);
dh->ke.destroy(&dh->ke);
ke->ke.destroy(&ke->ke);
ike_sa_id->destroy(ike_sa_id);
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
chunk_free(&pubvalue);
}
END_TEST
START_TEST(test_derive_ike_keys_multi_ke)
{
proposal_t *proposal = proposal_create_from_string(PROTO_IKE,
"aes256-sha512-modp3072-ke1_modp4096");
fail_if(!proposal, "Unable to create proposal");
ike_sa_id_t *ike_sa_id = ike_sa_id_create(IKEV2_MAJOR_VERSION,
123912312312, 32312313122, TRUE);
fail_if(!ike_sa_id, "Unable to create IKE SA ID");
tkm_keymat_t *keymat = tkm_keymat_create(TRUE);
fail_if(!keymat, "Unable to create keymat");
fail_if(!keymat->get_isa_id(keymat), "Invalid ISA context id (0)");
chunk_t nonce;
tkm_nonceg_t *ng = tkm_nonceg_create();
fail_if(!ng, "Unable to create nonce generator");
fail_unless(ng->nonce_gen.allocate_nonce(&ng->nonce_gen, 32, &nonce),
"Unable to allocate nonce");
tkm_key_exchange_t *ke = tkm_key_exchange_create(MODP_3072_BIT);
fail_if(!ke, "Unable to create first KE");
/* Use the same pubvalue for both sides */
chunk_t pubvalue;
ck_assert(ke->ke.get_public_key(&ke->ke, &pubvalue));
ck_assert(ke->ke.set_public_key(&ke->ke, pubvalue));
chunk_free(&pubvalue);
array_t *kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke);
fail_unless(keymat->keymat_v2.derive_ike_keys(&keymat->keymat_v2, proposal,
kes, nonce, nonce, ike_sa_id, PRF_UNDEFINED, chunk_empty),
"Key derivation failed");
array_destroy(kes);
ke->ke.destroy(&ke->ke);
const aead_t *aead = keymat->keymat_v2.keymat.get_aead(&keymat->keymat_v2.keymat, TRUE);
fail_if(!aead, "AEAD is NULL");
/* single KE during IKE_INTERMEDIATE on the same keymat with same nonces */
pseudo_random_function_t prf;
chunk_t skd;
prf = keymat->keymat_v2.get_skd(&keymat->keymat_v2, &skd);
fail_if(prf != PRF_HMAC_SHA2_512, "PRF incorrect");
ke = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke, "Unable to create second KE");
ck_assert(ke->ke.get_public_key(&ke->ke, &pubvalue));
ck_assert(ke->ke.set_public_key(&ke->ke, pubvalue));
chunk_free(&pubvalue);
kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke);
fail_unless(keymat->keymat_v2.derive_ike_keys(&keymat->keymat_v2, proposal,
kes, nonce, nonce, ike_sa_id, prf, skd),
"Second key derivation failed");
array_destroy(kes);
ke->ke.destroy(&ke->ke);
chunk_free(&nonce);
aead = keymat->keymat_v2.keymat.get_aead(&keymat->keymat_v2.keymat, TRUE);
fail_if(!aead, "AEAD is NULL");
ng->nonce_gen.destroy(&ng->nonce_gen);
ike_sa_id->destroy(ike_sa_id);
/* rekeying uses a new keymat/SA/nonce and multiple KEs */
ike_sa_id = ike_sa_id_create(IKEV2_MAJOR_VERSION,
34912312312, 612313122, TRUE);
fail_if(!ike_sa_id, "Unable to create IKE SA ID");
tkm_keymat_t *keymat2 = tkm_keymat_create(TRUE);
fail_if(!keymat2, "Unable to create keymat");
fail_if(!keymat2->get_isa_id(keymat2), "Invalid ISA context id (0)");
ng = tkm_nonceg_create();
fail_if(!ng, "Unable to create nonce generator");
fail_unless(ng->nonce_gen.allocate_nonce(&ng->nonce_gen, 32, &nonce),
"Unable to allocate nonce");
tkm_key_exchange_t *ke1 = tkm_key_exchange_create(MODP_3072_BIT);
fail_if(!ke1, "Unable to create first KE");
ck_assert(ke1->ke.get_public_key(&ke1->ke, &pubvalue));
ck_assert(ke1->ke.set_public_key(&ke1->ke, pubvalue));
chunk_free(&pubvalue);
tkm_key_exchange_t *ke2 = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke2, "Unable to create second KE");
ck_assert(ke2->ke.get_public_key(&ke2->ke, &pubvalue));
ck_assert(ke2->ke.set_public_key(&ke2->ke, pubvalue));
chunk_free(&pubvalue);
prf = keymat->keymat_v2.get_skd(&keymat->keymat_v2, &skd);
fail_if(prf != PRF_HMAC_SHA2_512, "PRF incorrect");
kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke1);
array_insert_create(&kes, ARRAY_TAIL, ke2);
fail_unless(keymat2->keymat_v2.derive_ike_keys(&keymat2->keymat_v2, proposal,
kes, nonce, nonce, ike_sa_id, prf, skd),
"Rekey key derivation failed");
array_destroy(kes);
ke1->ke.destroy(&ke1->ke);
ke2->ke.destroy(&ke2->ke);
chunk_free(&nonce);
aead = keymat2->keymat_v2.keymat.get_aead(&keymat2->keymat_v2.keymat, TRUE);
fail_if(!aead, "AEAD is NULL");
ng->nonce_gen.destroy(&ng->nonce_gen);
proposal->destroy(proposal);
ike_sa_id->destroy(ike_sa_id);
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
keymat2->keymat_v2.keymat.destroy(&keymat2->keymat_v2.keymat);
}
END_TEST
START_TEST(test_derive_child_keys)
{
tkm_diffie_hellman_t *dh = tkm_diffie_hellman_create(MODP_4096_BIT);
fail_if(!dh, "Unable to create DH object");
tkm_key_exchange_t *ke = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke, "Unable to create DH object");
proposal_t *proposal = proposal_create_from_string(PROTO_ESP,
"aes256-sha512-modp4096");
fail_if(!proposal, "Unable to create proposal");
@ -90,28 +208,33 @@ START_TEST(test_derive_child_keys)
fail_if(!keymat, "Unable to create keymat");
chunk_t encr_i, encr_r, integ_i, integ_r;
chunk_t nonce = chunk_from_chars("test chunk");
chunk_t nonce_i = chunk_from_chars("test chunk 1"),
nonce_r = chunk_from_chars("test chunk 2");
array_t *kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke);
fail_unless(keymat->keymat_v2.derive_child_keys(&keymat->keymat_v2, proposal,
&dh->ke,
nonce, nonce, &encr_i,
kes, nonce_i, nonce_r, &encr_i,
&integ_i, &encr_r, &integ_r),
"Child key derivation failed");
array_destroy(kes);
esa_info_t *info = (esa_info_t *)encr_i.ptr;
fail_if(!info, "encr_i does not contain esa information");
fail_if(info->isa_id != keymat->get_isa_id(keymat),
"Isa context id mismatch (encr_i)");
fail_if(info->spi_r != 42,
fail_if(info->spi_l != 42,
"SPI mismatch (encr_i)");
fail_unless(chunk_equals(info->nonce_i, nonce),
fail_unless(chunk_equals(info->nonce_i, nonce_i),
"nonce_i mismatch (encr_i)");
fail_unless(chunk_equals(info->nonce_r, nonce),
fail_unless(chunk_equals(info->nonce_r, nonce_r),
"nonce_r mismatch (encr_i)");
fail_if(info->is_encr_r,
"Flag is_encr_r set for encr_i");
fail_if(info->dh_id != dh->get_id(dh),
"DH context id mismatch (encr_i)");
fail_if(info->ke_ids.size != 1,
"KE context number mismatch (encr_i)");
fail_if(info->ke_ids.data[0] != ke->get_id(ke),
"KE context id mismatch (encr_i)");
chunk_free(&info->nonce_i);
chunk_free(&info->nonce_r);
@ -119,21 +242,101 @@ START_TEST(test_derive_child_keys)
fail_if(!info, "encr_r does not contain esa information");
fail_if(info->isa_id != keymat->get_isa_id(keymat),
"Isa context id mismatch (encr_r)");
fail_if(info->spi_r != 42,
fail_if(info->spi_l != 42,
"SPI mismatch (encr_r)");
fail_unless(chunk_equals(info->nonce_i, nonce),
fail_unless(chunk_equals(info->nonce_i, nonce_i),
"nonce_i mismatch (encr_r)");
fail_unless(chunk_equals(info->nonce_r, nonce),
fail_unless(chunk_equals(info->nonce_r, nonce_r),
"nonce_r mismatch (encr_r)");
fail_unless(info->is_encr_r,
"Flag is_encr_r set for encr_r");
fail_if(info->dh_id != dh->get_id(dh),
"DH context id mismatch (encr_i)");
fail_if(info->ke_ids.size != 1,
"KE context number mismatch (encr_i)");
fail_if(info->ke_ids.data[0] != ke->get_id(ke),
"KE context id mismatch (encr_i)");
chunk_free(&info->nonce_i);
chunk_free(&info->nonce_r);
proposal->destroy(proposal);
dh->ke.destroy(&dh->ke);
ke->ke.destroy(&ke->ke);
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
chunk_free(&encr_i);
chunk_free(&encr_r);
}
END_TEST
START_TEST(test_derive_child_keys_multi_ke)
{
tkm_key_exchange_t *ke1 = tkm_key_exchange_create(MODP_3072_BIT);
fail_if(!ke1, "Unable to create DH object");
tkm_key_exchange_t *ke2 = tkm_key_exchange_create(MODP_4096_BIT);
fail_if(!ke2, "Unable to create DH object");
proposal_t *proposal = proposal_create_from_string(PROTO_ESP,
"aes256-sha512-modp4096");
fail_if(!proposal, "Unable to create proposal");
proposal->set_spi(proposal, 42);
tkm_keymat_t *keymat = tkm_keymat_create(TRUE);
fail_if(!keymat, "Unable to create keymat");
chunk_t encr_i, encr_r, integ_i, integ_r;
chunk_t nonce_i = chunk_from_chars("test chunk 1"),
nonce_r = chunk_from_chars("test chunk 2");
array_t *kes = NULL;
array_insert_create(&kes, ARRAY_TAIL, ke1);
array_insert_create(&kes, ARRAY_TAIL, ke2);
fail_unless(keymat->keymat_v2.derive_child_keys(&keymat->keymat_v2, proposal,
kes, nonce_i, nonce_r, &encr_i,
&integ_i, &encr_r, &integ_r),
"Child key derivation failed");
array_destroy(kes);
esa_info_t *info = (esa_info_t *)encr_i.ptr;
fail_if(!info, "encr_i does not contain esa information");
fail_if(info->isa_id != keymat->get_isa_id(keymat),
"Isa context id mismatch (encr_i)");
fail_if(info->spi_l != 42,
"SPI mismatch (encr_i)");
fail_unless(chunk_equals(info->nonce_i, nonce_i),
"nonce_i mismatch (encr_i)");
fail_unless(chunk_equals(info->nonce_r, nonce_r),
"nonce_r mismatch (encr_i)");
fail_if(info->is_encr_r,
"Flag is_encr_r set for encr_i");
fail_if(info->ke_ids.size != 2,
"KE context number mismatch (encr_i)");
fail_if(info->ke_ids.data[0] != ke1->get_id(ke1),
"KE context id mismatch (encr_i)");
fail_if(info->ke_ids.data[1] != ke2->get_id(ke2),
"KE context id mismatch (encr_i)");
chunk_free(&info->nonce_i);
chunk_free(&info->nonce_r);
info = (esa_info_t *)encr_r.ptr;
fail_if(!info, "encr_r does not contain esa information");
fail_if(info->isa_id != keymat->get_isa_id(keymat),
"Isa context id mismatch (encr_r)");
fail_if(info->spi_l != 42,
"SPI mismatch (encr_r)");
fail_unless(chunk_equals(info->nonce_i, nonce_i),
"nonce_i mismatch (encr_r)");
fail_unless(chunk_equals(info->nonce_r, nonce_r),
"nonce_r mismatch (encr_r)");
fail_unless(info->is_encr_r,
"Flag is_encr_r set for encr_r");
fail_if(info->ke_ids.size != 2,
"KE context number mismatch (encr_i)");
fail_if(info->ke_ids.data[0] != ke1->get_id(ke1),
"KE context id mismatch (encr_i)");
fail_if(info->ke_ids.data[1] != ke2->get_id(ke2),
"KE context id mismatch (encr_i)");
chunk_free(&info->nonce_i);
chunk_free(&info->nonce_r);
proposal->destroy(proposal);
ke1->ke.destroy(&ke1->ke);
ke2->ke.destroy(&ke2->ke);
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
chunk_free(&encr_i);
chunk_free(&encr_r);
@ -149,10 +352,12 @@ Suite *make_keymat_tests()
tc = tcase_create("derive IKE keys");
tcase_add_test(tc, test_derive_ike_keys);
tcase_add_test(tc, test_derive_ike_keys_multi_ke);
suite_add_tcase(s, tc);
tc = tcase_create("derive CHILD keys");
tcase_add_test(tc, test_derive_child_keys);
tcase_add_test(tc, test_derive_child_keys_multi_ke);
suite_add_tcase(s, tc);
return s;

View File

@ -23,7 +23,7 @@
#include "tkm.h"
#include "tkm_nonceg.h"
#include "tkm_diffie_hellman.h"
#include "tkm_key_exchange.h"
#include "tkm_kernel_ipsec.h"
/* declare test suite constructors */
@ -75,11 +75,11 @@ static bool test_runner_init(bool init)
lib->plugins->add_static_features(lib->plugins, "tkm-tests", features,
countof(features), TRUE, NULL, NULL);
lib->settings->set_int(lib->settings, "%s.dh_mapping.%d", 1,
lib->settings->set_int(lib->settings, "%s.ke_mapping.%d", 1,
lib->ns, MODP_3072_BIT);
lib->settings->set_int(lib->settings, "%s.dh_mapping.%d", 2,
lib->settings->set_int(lib->settings, "%s.ke_mapping.%d", 2,
lib->ns, MODP_4096_BIT);
register_dh_mapping();
register_ke_mapping();
plugin_loader_add_plugindirs(BUILDDIR "/src/libstrongswan/plugins",
PLUGINS);
@ -100,7 +100,7 @@ static bool test_runner_init(bool init)
result = FALSE;
}
destroy_dh_mapping();
destroy_ke_mapping();
libcharon_deinit();
return result;
}

View File

@ -19,6 +19,6 @@ TEST_SUITE(make_id_manager_tests)
TEST_SUITE(make_chunk_map_tests)
TEST_SUITE(make_utility_tests)
TEST_SUITE_DEPEND(make_nonceg_tests, CUSTOM, "tkm")
TEST_SUITE_DEPEND(make_diffie_hellman_tests, CUSTOM, "tkm")
TEST_SUITE_DEPEND(make_key_exchange_tests, CUSTOM, "tkm")
TEST_SUITE_DEPEND(make_keymat_tests, CUSTOM, "tkm")
TEST_SUITE(make_kernel_sad_tests)

Some files were not shown because too many files have changed in this diff Show More