2 years agoswanctl: Add missing `extern` for `swanctl_dir` variable in header
Tobias Brunner [Tue, 28 Jan 2020 09:33:55 +0000 (10:33 +0100)]
swanctl: Add missing `extern` for `swanctl_dir` variable in header

This clearly never was correct, but didn't cause problems so far.
However, GCC 10 will default to `-fno-common` instead of
`-fcommon` (, so compilation there fails
with something like:

libtool: link: gcc ... -o .libs/swanctl ...
ld: commands/load_authorities.o:strongswan/src/swanctl/./swanctl.h:33:
  multiple definition of `swanctl_dir'; commands/load_all.o:strongswan/src/swanctl/./swanctl.h:33: first defined here

Fixes: 501bd53a6cce ("swanctl: Make credential directories relative to swanctl.conf")
Closes strongswan/strongswan#163.

2 years agolgtm: Add query to detect problematic uses of chunk_from_chars()
Tobias Brunner [Mon, 27 Jan 2020 14:16:51 +0000 (15:16 +0100)]
lgtm: Add query to detect problematic uses of chunk_from_chars()

GCC 9+ and clang 4+ (partially) optimize out usages of
chunk_from_chars() if the value is read outside of the block where the
macro is used.  For instance:

chunk_t chunk = chunk_empty;
if (...)
chunk = chunk_from_chars(0x01, 0x06);
/* do something with chunk */

The chunk_from_chars() macro expands to a chunk_t declaration, which is
technically only defined inside that block.

Still, with older GCC versions the fourth line was compiled to something
like this:

mov     WORD PTR [rsp+14], 1537 # 0x0106 in little-endian
lea     rdx, [rsp+14]
mov     ecx, 2

However, with GCC 9.1 and -O2 the first instruction might be omitted
(strangely the others usually were not, so the chunk pointed to whatever
was stored on the stack).  It's not easily reproducible, so there are
situations where the seemingly identical code is not optimized in this

This query should detect such problematic uses of the macro (definition
and usage in different blocks).

References #3249.

2 years agolgtm: Add config for a more complete build on
Tobias Brunner [Mon, 27 Jan 2020 14:03:58 +0000 (15:03 +0100)]
lgtm: Add config for a more complete build on

2 years agotravis: Build on ARM64, IBM Power and IBM Z architectures
Tobias Brunner [Wed, 15 Jan 2020 13:57:56 +0000 (14:57 +0100)]
travis: Build on ARM64, IBM Power and IBM Z architectures

IBM Z is big-endian, IBM Power runs in little-endian mode.

Botan requires a fix for issues with GCC and amalgamation enabled (target
pragma ‘*’ is invalid) on ARM64 and IBM Power, while wolfSSL can't be
compiled successfully on IBM Z without an additional patch.

libunwind is not available for x390x, but since we explicitly disable
such backtraces it's not necessary anyway.

2 years agosha3: Fix readLane() macro on big-endian platforms
Tobias Brunner [Thu, 16 Jan 2020 15:06:27 +0000 (16:06 +0100)]
sha3: Fix readLane() macro on big-endian platforms

2 years agoUse Botan 2.13.0 for tests
Tobias Brunner [Wed, 15 Jan 2020 09:23:35 +0000 (10:23 +0100)]
Use Botan 2.13.0 for tests

2 years agoscepclient: Add missing short options (-i, -T)
Tobias Brunner [Wed, 15 Jan 2020 11:00:28 +0000 (12:00 +0100)]
scepclient: Add missing short options (-i, -T)

2 years agoMerge branch 'vici-pytest'
Tobias Brunner [Tue, 14 Jan 2020 15:53:53 +0000 (16:53 +0100)]
Merge branch 'vici-pytest'

Adds tox.ini to test with tox (which is now used on Travis) and includes
the tests in the source distribution.

2 years agovici: Move Python test dir and include it in sdist
Tobias Brunner [Tue, 14 Jan 2020 13:58:01 +0000 (14:58 +0100)]
vici: Move Python test dir and include it in sdist

This is the recommended location and import config as it allows running the
tests against installed versions of the package.  And while the test file
itself is automatically included in the source distribution this way, the file is not, so we still have to update

2 years agotravis: Run python tests with tox
Tobias Brunner [Tue, 14 Jan 2020 10:02:07 +0000 (11:02 +0100)]
travis: Run python tests with tox

2 years agovici: Run Python tests via tox if available
Tobias Brunner [Tue, 14 Jan 2020 10:00:56 +0000 (11:00 +0100)]
vici: Run Python tests via tox if available

Since we use the serial test harness we can't use AM_TESTS_ENVIRONMENT.
The script is necessary for out-of-tree builds.

2 years agovici: Fix several PEP8 issues
Tobias Brunner [Tue, 14 Jan 2020 10:03:07 +0000 (11:03 +0100)]
vici: Fix several PEP8 issues

2 years agovici: Add tox.ini to run tests with tox
Tobias Brunner [Tue, 14 Jan 2020 09:49:47 +0000 (10:49 +0100)]
vici: Add tox.ini to run tests with tox

Some of the interpreters might not be available on the host system, use
--skip-missing-interpreters to not fail in that case.

2 years agovici: List newer Python versions in
Tobias Brunner [Tue, 14 Jan 2020 09:48:53 +0000 (10:48 +0100)]
vici: List newer Python versions in

2 years agotravis: Bump wolfSSL to 4.3.0
Tobias Brunner [Mon, 13 Jan 2020 13:39:21 +0000 (14:39 +0100)]
travis: Bump wolfSSL to 4.3.0

2 years agowolfssl: Undef RSA_PSS_SALT_LEN_DEFAULT as wolfSSL 4.3.0 defines it as enum
Tobias Brunner [Mon, 13 Jan 2020 14:48:47 +0000 (15:48 +0100)]
wolfssl: Undef RSA_PSS_SALT_LEN_DEFAULT as wolfSSL 4.3.0 defines it as enum

2 years agoRevert "travis: Add a workaround for a bug regarding libtool installed via Homebrew"
Tobias Brunner [Thu, 19 Dec 2019 10:41:59 +0000 (11:41 +0100)]
Revert "travis: Add a workaround for a bug regarding libtool installed via Homebrew"

This reverts commit 1806ba0890bc503df3dacf01992ec1bca2b0fbb0 as the
workaround is not required anymore and now actually fails because
pre-installed tools have a dependency on libtool.

2 years agoVersion bump to 5.8.2 5.8.2
Andreas Steffen [Tue, 17 Dec 2019 13:30:41 +0000 (14:30 +0100)]
Version bump to 5.8.2

2 years agoVersion bump to 5.8.2rc2 5.8.2rc2
Andreas Steffen [Mon, 16 Dec 2019 21:11:43 +0000 (22:11 +0100)]
Version bump to 5.8.2rc2

2 years agokernel-netlink: Use correct config option name for HW offloading check
Tobias Brunner [Fri, 13 Dec 2019 16:19:03 +0000 (17:19 +0100)]
kernel-netlink: Use correct config option name for HW offloading check

Fixes: a605452c038e ("kernel-netlink: Check for offloading support in constructor")

2 years agodrbg: Fix Doxygen group in headers
Tobias Brunner [Tue, 10 Dec 2019 16:12:32 +0000 (17:12 +0100)]
drbg: Fix Doxygen group in headers

2 years agoFixed some typos, courtesy of codespell
Tobias Brunner [Tue, 10 Dec 2019 16:06:53 +0000 (17:06 +0100)]
Fixed some typos, courtesy of codespell

2 years agoNEWS: Added some news for 5.8.2
Tobias Brunner [Tue, 10 Dec 2019 14:52:05 +0000 (15:52 +0100)]
NEWS: Added some news for 5.8.2

2 years agoopenssl: Make some additional arguments const
Thomas Egerer [Fri, 29 Nov 2019 18:05:37 +0000 (19:05 +0100)]
openssl: Make some additional arguments const

Related to openssl 1.1.x changes.

Signed-off-by: Thomas Egerer <>
2 years agolibtpmtss: Convert RSA exponent to big-endian when provided by a TPM 2.0
Tobias Brunner [Tue, 10 Dec 2019 09:12:48 +0000 (10:12 +0100)]
libtpmtss: Convert RSA exponent to big-endian when provided by a TPM 2.0

While the TPM expects and returns the data in big-endian, the SAPI
implementation converts it to native-endianness.  As stated in the
SAPI specification (section 3.2):

  8. All SAPI data SHALL be in native-endian format.  This means that
     the SAPI implementation will do any endian conversion required for
     both inputs and outputs.

So to use the exponent in a chunk we have to convert it to big-endian again.

Fixes: 7533cedb9a8a ("libtpmtss: Read RSA public key exponent instead of assuming its value")

2 years agoikev2: Destroy IKE_SA if INVALID_SYNTAX notify is received in response
Tobias Brunner [Mon, 25 Nov 2019 14:55:54 +0000 (15:55 +0100)]
ikev2: Destroy IKE_SA if INVALID_SYNTAX notify is received in response

RFC 7296, section 2.21.3:

   If a peer parsing a request notices that it is badly formatted (after
   it has passed the message authentication code checks and window
   checks) and it returns an INVALID_SYNTAX notification, then this
   error notification is considered fatal in both peers, meaning that
   the IKE SA is deleted without needing an explicit Delete payload.

2 years agoikev2: Destroy IKE_SA when receiving invalid authenticated requests
Tobias Brunner [Mon, 25 Nov 2019 13:43:36 +0000 (14:43 +0100)]
ikev2: Destroy IKE_SA when receiving invalid authenticated requests

RFC 7296, section 2.21.3:

   If a peer parsing a request notices that it is badly formatted (after
   it has passed the message authentication code checks and window
   checks) and it returns an INVALID_SYNTAX notification, then this
   error notification is considered fatal in both peers, meaning that
   the IKE SA is deleted without needing an explicit Delete payload.

2 years agoikev2: Send INVALID_MAJOR_VERSION notify using the same exchange type and MID
Tobias Brunner [Mon, 25 Nov 2019 13:00:40 +0000 (14:00 +0100)]
ikev2: Send INVALID_MAJOR_VERSION notify using the same exchange type and MID

This is per RFC 7296, section 1.5.

2 years agosshkey: Rename variables that conflict with function argument
Tobias Brunner [Mon, 9 Dec 2019 10:34:30 +0000 (11:34 +0100)]
sshkey: Rename variables that conflict with function argument

2 years agochunk: Rename hash key variable to avoid conflicts with function arguments
Tobias Brunner [Mon, 9 Dec 2019 10:22:14 +0000 (11:22 +0100)]
chunk: Rename hash key variable to avoid conflicts with function arguments

2 years agoattr: Remove unused/undeclared argument in provider constructor
Tobias Brunner [Mon, 9 Dec 2019 10:05:25 +0000 (11:05 +0100)]
attr: Remove unused/undeclared argument in provider constructor

2 years agoVersion bump to 5.8.2rc1 5.8.2rc1
Andreas Steffen [Sat, 7 Dec 2019 22:06:22 +0000 (23:06 +0100)]
Version bump to 5.8.2rc1

2 years agoconfigure: Drop unnecessary gperf version check
Tobias Brunner [Thu, 5 Dec 2019 14:50:12 +0000 (15:50 +0100)]
configure: Drop unnecessary gperf version check

While the check probably made sense when strongSwan 4.x was started, gperf
version 3.0.1 was released in 2003, so it's very unlikely that version 2.x
is still around anywhere.

2 years agoconfigure: Abort if gperf is not found but generated files don't exist
Tobias Brunner [Thu, 5 Dec 2019 14:46:15 +0000 (15:46 +0100)]
configure: Abort if gperf is not found but generated files don't exist

When building from a tarball gperf is not required as the generated
files already exist, however, when building from the repository that's
not the case, so warn the user if gperf is not found.

2 years agoconfigure: Declare GPERF and PERL as variables
Tobias Brunner [Thu, 5 Dec 2019 14:45:01 +0000 (15:45 +0100)]
configure: Declare GPERF and PERL as variables

These are documented in --help and will be cached.

2 years agokernel-netlink: Properly compare routes for policies without gateway/netxhop
Tobias Brunner [Thu, 5 Dec 2019 15:15:33 +0000 (16:15 +0100)]
kernel-netlink: Properly compare routes for policies without gateway/netxhop

This happened when installing a duplicate bypass policy for a locally
connected subnet.  The destructor and the kernel-net part already
handle this correctly.

2 years agoopenssl: Ensure underlying hash algorithm is available during HMAC init
Tobias Brunner [Tue, 3 Dec 2019 15:11:39 +0000 (16:11 +0100)]
openssl: Ensure underlying hash algorithm is available during HMAC init

Without this we only would learn that the algorithm isn't actually
available (e.g. due to FIPS mode) when set_key() is called later, so there
isn't any automatic fallback to other implementations.

Fixes #3284.

2 years agoMerge branch 'ca-identity-constraint'
Tobias Brunner [Fri, 6 Dec 2019 09:10:39 +0000 (10:10 +0100)]
Merge branch 'ca-identity-constraint'

This adds a new constraint for vici/swanctl.conf that enforces that the
certificate chain of the remote peer contains a CA certificate with a
specific identity.

This is similar to the existing CA constraints, but doesn't require that
the CA certificate is locally installed, for instance, intermediate CA
certificates received by the peers.

Wildcard identity matching (e.g. "..., OU=Research, CN=*") could also be
used for the latter, but requires trust in the intermediate CA to only
issue certificates with legitimate subject DNs (e.g. the "Sales" CA must
not issue certificates with "OU=Research").  With the new constraint
that's not necessary as long as a path length constraint prevents
intermediate CAs from issuing further intermediate CAs.

2 years agovici: Log certificate constraints for loaded configs
Tobias Brunner [Fri, 29 Nov 2019 11:16:43 +0000 (12:16 +0100)]
vici: Log certificate constraints for loaded configs

2 years agotesting: Use identity based CA restrictions in rw-hash-and-url-multi-level
Martin Willi [Thu, 28 Nov 2019 09:25:20 +0000 (10:25 +0100)]
testing: Use identity based CA restrictions in rw-hash-and-url-multi-level

This is a prominent example where the identity based CA constraint is
benefical. While the description of the test claims a strict binding
of the client to the intermediate CA, this is not fully true if CA operators
are not fully trusted: A rogue OU=Sales intermediate may issue certificates
containing a OU=Research.

By binding the connection to the CA, we can avoid this, and using the identity
based constraint still allows moon to receive the intermediate over IKE
or hash-and-url.

2 years agoswanctl: Include ca_id property in list-conns command
Martin Willi [Thu, 28 Nov 2019 16:04:16 +0000 (17:04 +0100)]
swanctl: Include ca_id property in list-conns command

2 years agoswanctl: Document the remote ca_id option for identity based CA constraints
Martin Willi [Thu, 28 Nov 2019 09:20:50 +0000 (10:20 +0100)]
swanctl: Document the remote ca_id option for identity based CA constraints

2 years agovici: Introduce a ca_id option identity based CA certificate constraints
Martin Willi [Thu, 28 Nov 2019 09:09:30 +0000 (10:09 +0100)]
vici: Introduce a ca_id option identity based CA certificate constraints

2 years agoauth-cfg: Add support for identity based CA authentication constraints
Martin Willi [Thu, 28 Nov 2019 07:14:59 +0000 (08:14 +0100)]
auth-cfg: Add support for identity based CA authentication constraints

Enforcing CA based constraints previously required the CA certificate file
to be locally installed. This is problematic from a maintencance perspective
when having many intermediate CAs, and is actually redundant if the client
sends its intermediate cert in the request.

The alternative was to use Distinguished Name matching in the subject
identity to indirectly check for the issuing CA by some RDN field, such as OU.
However, this requires trust in the intermediate CA to issue only certificates
with legitime subject identities.

This new approach checks for an intermediate CA by comparing the issuing
identity. This does not require trust in the intermediate, as long as
a path len constraint prevents that intermediate to issue further
intermediate certificates.

2 years agofarp: Ignore SAs with remote traffic selector
Tobias Brunner [Tue, 26 Nov 2019 16:43:57 +0000 (17:43 +0100)]
farp: Ignore SAs with remote traffic selector

This is mostly to avoid hijacking the local LAN if the farp plugin is
inadvertently active on a roadwarrior.

Fixes #3116.

2 years agofarp: Only cache IPv4 traffic selectors
Tobias Brunner [Tue, 26 Nov 2019 16:55:47 +0000 (17:55 +0100)]
farp: Only cache IPv4 traffic selectors

Since ARP is IPv4 only there is no point caching IPv6 traffic

2 years agoMerge branch 'ocsp-nonce'
Tobias Brunner [Fri, 6 Dec 2019 08:53:26 +0000 (09:53 +0100)]
Merge branch 'ocsp-nonce'

This makes sure the nonce sent in an OCSP request is contained in the
response (it also fixes parsing the nonce, which didn't matter so far
as it was never used)

2 years agorevocation: Check that nonce in OCSP response matches
Tobias Brunner [Fri, 22 Nov 2019 14:09:55 +0000 (15:09 +0100)]
revocation: Check that nonce in OCSP response matches

2 years agox509: Correctly parse nonce in OCSP response
Tobias Brunner [Fri, 22 Nov 2019 15:36:20 +0000 (16:36 +0100)]
x509: Correctly parse nonce in OCSP response

Fixes: d7dc677ee572 ("x509: Correctly encode nonce in OCSP request")

2 years agox509: Add getter for nonce in OCSP request/response implementations
Tobias Brunner [Fri, 22 Nov 2019 14:04:01 +0000 (15:04 +0100)]
x509: Add getter for nonce in OCSP request/response implementations

2 years agocredentials: Add getter for nonce in OCSP request and response interface
Tobias Brunner [Fri, 22 Nov 2019 13:59:49 +0000 (14:59 +0100)]
credentials: Add getter for nonce in OCSP request and response interface

2 years agodrbg: Don't generate more than 2^16 bytes
Andreas Steffen [Thu, 28 Nov 2019 20:29:26 +0000 (21:29 +0100)]
drbg: Don't generate more than 2^16 bytes

2 years agoMerge branch 'aes-ecb'
Tobias Brunner [Thu, 28 Nov 2019 16:16:36 +0000 (17:16 +0100)]
Merge branch 'aes-ecb'

Adds support for AES in ECB mode (where supported by the underlying
library/API) and uses it for the CTR-DRBG implementation.

2 years agodrbg: Use AES_ECB encryption
Andreas Steffen [Thu, 21 Nov 2019 13:57:57 +0000 (14:57 +0100)]
drbg: Use AES_ECB encryption

2 years agogcrypt: Added AES_ECB support
Andreas Steffen [Sun, 24 Nov 2019 13:05:25 +0000 (14:05 +0100)]
gcrypt: Added AES_ECB support

2 years agoaf-alg: Added AES_ECB support
Andreas Steffen [Fri, 22 Nov 2019 14:28:37 +0000 (15:28 +0100)]
af-alg: Added AES_ECB support

2 years agoaes: Added AES_ECB support
Andreas Steffen [Thu, 21 Nov 2019 20:35:07 +0000 (21:35 +0100)]
aes: Added AES_ECB support

2 years agoopenssl: Added AES_ECB support
Andreas Steffen [Thu, 21 Nov 2019 14:27:59 +0000 (15:27 +0100)]
openssl: Added AES_ECB support

2 years agoaesni: Added AES_ECB support
Andreas Steffen [Thu, 21 Nov 2019 11:58:48 +0000 (12:58 +0100)]
aesni: Added AES_ECB support

2 years agovici: Update Python egg if strongSwan version changed
Tobias Brunner [Thu, 28 Nov 2019 15:37:34 +0000 (16:37 +0100)]
vici: Update Python egg if strongSwan version changed

Mainly useful when using the build-strongswan script of the testing

2 years agodrbg: The drbg instance owns the entropy rng
Andreas Steffen [Fri, 8 Nov 2019 12:16:12 +0000 (13:16 +0100)]
drbg: The drbg instance owns the entropy rng

2 years agoVersion bump to 5.8.2dr2 5.8.2dr2
Andreas Steffen [Tue, 26 Nov 2019 21:36:55 +0000 (22:36 +0100)]
Version bump to 5.8.2dr2

2 years agoMerge branch 'hash-url-multi-level'
Tobias Brunner [Tue, 26 Nov 2019 13:47:14 +0000 (14:47 +0100)]
Merge branch 'hash-url-multi-level'

Adds support to send intermediate CA certificates in hash-and-URL
encoding.  For that it moves the generation of URLs from the config
backends to the ike-cert-post task.

Fixes #3234.

2 years agotesting: Add scenario with hash-and-URL encoding for intermediate CA certificates
Tobias Brunner [Thu, 31 Oct 2019 14:18:17 +0000 (15:18 +0100)]
testing: Add scenario with hash-and-URL encoding for intermediate CA certificates

2 years agostroke: Remove obsolete certificate registration for hash-and-URL
Tobias Brunner [Thu, 31 Oct 2019 08:51:07 +0000 (09:51 +0100)]
stroke: Remove obsolete certificate registration for hash-and-URL

2 years agovici: Remove obsolete certificate registration for hash-and-URL
Tobias Brunner [Thu, 31 Oct 2019 08:49:21 +0000 (09:49 +0100)]
vici: Remove obsolete certificate registration for hash-and-URL

2 years agoike-cert-post: Encode intermediate CA certificates as hash-and-URL if possible
Tobias Brunner [Thu, 31 Oct 2019 08:51:42 +0000 (09:51 +0100)]
ike-cert-post: Encode intermediate CA certificates as hash-and-URL if possible

2 years agoike-cert-post: Generate URL for hash-and-URL here
Tobias Brunner [Thu, 31 Oct 2019 08:27:49 +0000 (09:27 +0100)]
ike-cert-post: Generate URL for hash-and-URL here

This avoids having to register certificates with authority/ca backends
beforehand, which is tricky for intermediate CA certificates loaded
themselves via authority/ca sections.  On the other hand, the form of
these URLs can't be determined by config backends anymore (not an issue
for the two current implementations, no idea if custom implementations
ever made use of that possibility).  If that became necessary, we could
perhaps pass the certificate to the CDP enumerator or add a new method
to the credential_set_t interface.

2 years agokernel-netlink: Check for offloading support in constructor
Thomas Egerer [Wed, 9 Oct 2019 15:16:29 +0000 (17:16 +0200)]
kernel-netlink: Check for offloading support in constructor

This avoids races that could potentially occur when doing the check during
SA installation.

Signed-off-by: Thomas Egerer <>
2 years agotesting: Import sys in Python updown script
Tobias Brunner [Thu, 21 Nov 2019 15:57:25 +0000 (16:57 +0100)]
testing: Import sys in Python updown script

2 years agoandroid: New version after fixing fetching via HTTP on Android 9
Tobias Brunner [Tue, 19 Nov 2019 13:43:39 +0000 (14:43 +0100)]
android: New version after fixing fetching via HTTP on Android 9

2 years agoandroid: Add networkSecurityConfig to fetch CLRs/OCSP via HTTP
Tobias Brunner [Tue, 19 Nov 2019 13:41:34 +0000 (14:41 +0100)]
android: Add networkSecurityConfig to fetch CLRs/OCSP via HTTP

Android 9 restricts this to only HTTPS by default.

Fixes #3273.

2 years agoandroid: Update Gradle plugin
Tobias Brunner [Tue, 19 Nov 2019 13:24:08 +0000 (14:24 +0100)]
android: Update Gradle plugin

2 years agoFix for libstrongswan after adding DRBGs
Tobias Brunner [Tue, 19 Nov 2019 13:24:17 +0000 (14:24 +0100)]
Fix for libstrongswan after adding DRBGs

2 years agotesting: Accept LANG and LC_* env variables via SSH on guests
Tobias Brunner [Thu, 14 Nov 2019 15:10:17 +0000 (16:10 +0100)]
testing: Accept LANG and LC_* env variables via SSH on guests

The client config already includes SendEnv for them.  Without that these
variables currently default to POSIX.

2 years agoswanctl: Document wildcard matching for remote identities
Tobias Brunner [Tue, 12 Nov 2019 09:59:38 +0000 (10:59 +0100)]
swanctl: Document wildcard matching for remote identities

2 years agoconf: Replace deprecated OptionParser with ArgumentParser
Tobias Brunner [Tue, 12 Nov 2019 09:57:45 +0000 (10:57 +0100)]
conf: Replace deprecated OptionParser with ArgumentParser

2 years agotesting: Remove unused connection definition in ikev2/force-udp-encaps [Wed, 6 Nov 2019 03:04:00 +0000 (03:04 +0000)]
testing: Remove unused connection definition in ikev2/force-udp-encaps

2 years agotesting: Fix SHA description in ikev*/esp-alg-null scenarios [Wed, 6 Nov 2019 01:45:09 +0000 (01:45 +0000)]
testing: Fix SHA description in ikev*/esp-alg-null scenarios

2 years agoproposal: Fix typos and clarify things in comments
Tobias Brunner [Mon, 4 Nov 2019 14:19:16 +0000 (15:19 +0100)]
proposal: Fix typos and clarify things in comments

2 years agoman: Correct typo in description of closeaction
Kenyon Ralph [Mon, 28 Oct 2019 18:48:36 +0000 (11:48 -0700)]
man: Correct typo in description of closeaction

Closes strongswan/strongswan#158.

2 years agoMerge branch 'enum-strings'
Tobias Brunner [Mon, 28 Oct 2019 17:46:11 +0000 (18:46 +0100)]
Merge branch 'enum-strings'

Adds a compile check the number of enum strings and updates several of
these lists, in particular, the one in the pfkey-kernel plugin, where
strings for several new extensions on FreeBSD were missing.

Fixes #3210.

2 years agokernel-pfkey: Add additional strings for extensions on different platforms
Tobias Brunner [Wed, 16 Oct 2019 17:46:09 +0000 (19:46 +0200)]
kernel-pfkey: Add additional strings for extensions on different platforms

Don't define structs for macOS as we don't need them (that's true for
most of the others too, though) and at least one is defined inside an extra

2 years agoAdd missing strings to several enum string definitions
Tobias Brunner [Tue, 22 Oct 2019 09:04:30 +0000 (11:04 +0200)]
Add missing strings to several enum string definitions

2 years agoenum: Add compile-time check for missing strings
Tobias Brunner [Wed, 16 Oct 2019 16:48:22 +0000 (18:48 +0200)]
enum: Add compile-time check for missing strings

If strings are missing (e.g. because the last value of a range changed
unknowingly or adding a string was simply forgotten) compilation will
now fail.

This could be problematic if the upper limit is out of our control (e.g.
from a system header like pfkeyv2.h), in which case patches might be
required on certain platforms (enforcing at least, and not exactly, the
required number of strings might also be an option to compile against
older versions of such a header - for internal enums it's obviously
better to enforce an exact match, though).

2 years agokernel-netlink: Support extended table IDs for custom routes
Tobias Brunner [Tue, 24 Sep 2019 10:59:00 +0000 (12:59 +0200)]
kernel-netlink: Support extended table IDs for custom routes

This adds support for installing routes in tables with IDs > 255.

2 years agovici: List additional information for deleted CHILD_SAs
Tobias Brunner [Thu, 10 Oct 2019 13:33:45 +0000 (15:33 +0200)]
vici: List additional information for deleted CHILD_SAs

If a CHILD_SA is terminated, the updown event is triggered after the
CHILD_SA is set to state CHILD_DELETED, so no usage stats or detail
information like SPIs were reported.  However, when an IKEv2 SA is
terminated, the updown event for its children is triggered without
changing the state first, that is, they usually remain in state
INSTALLED and detailed data was reported in the event.  IKEv1
CHILD_SAs are always terminated individually, i.e. with state
change and no extra data so far.

With this change usage stats are also returned for individually deleted
CHILD_SAs as long as the SA has not yet expired.

Fixes #3198.

2 years agokernel-pfkey: Clear receive buffer before sending request
Tobias Brunner [Fri, 25 Oct 2019 09:07:11 +0000 (11:07 +0200)]
kernel-pfkey: Clear receive buffer before sending request

Many of the messages sent by the kernel, including confirmations to our
requests, are sent as broadcasts to all PF_KEY sockets.  So if an
external tool is used to manage SAs/policies (e.g. unrelated to IPsec)
the receive buffer might be filled, resulting in errors like these:

  error sending to PF_KEY socket: No buffer space available

To avoid this, just clear the buffer before sending any message.

Fixes #3225.

2 years agoMerge branch 'proposal-flags'
Tobias Brunner [Thu, 24 Oct 2019 15:47:45 +0000 (17:47 +0200)]
Merge branch 'proposal-flags'

This uses flags for proposal selection and cloning that control
whether DH groups and algorithms from a private range are skipped, and
for selection whether configured or supplied proposals/algorithms are

2 years agoproposal: Remove unused strip_dh() method
Tobias Brunner [Thu, 5 Sep 2019 16:02:47 +0000 (18:02 +0200)]
proposal: Remove unused strip_dh() method

2 years agoproposal: Add selection flags to clone() method
Tobias Brunner [Thu, 5 Sep 2019 15:29:00 +0000 (17:29 +0200)]
proposal: Add selection flags to clone() method

This avoids having to call strip_dh() in child_cfg_t::get_proposals().
It also inverts the ALLOW_PRIVATE flag (i.e. makes it SKIP_PRIVATE) so
nothing has to be supplied to clone complete proposals.

2 years agoquick-mode: Promote selected DH group instead of stripping all others
Tobias Brunner [Thu, 5 Sep 2019 15:23:57 +0000 (17:23 +0200)]
quick-mode: Promote selected DH group instead of stripping all others

Since only the first DH group is encoded for IKEv1 this should have the
same effect as removing all other groups.

2 years agoproposal: Extract proposal selection code in ike/child_cfg_t
Tobias Brunner [Wed, 4 Sep 2019 14:25:18 +0000 (16:25 +0200)]
proposal: Extract proposal selection code in ike/child_cfg_t

Also invert the PREFER_CONFIGURED flag (i.e. make it PREFER_SUPPLIED)
so the default, without flags, is what we preferred so far.

2 years agoproposal: Handle skipping DH groups directly in select() and matches()
Tobias Brunner [Wed, 4 Sep 2019 09:25:12 +0000 (11:25 +0200)]
proposal: Handle skipping DH groups directly in select() and matches()

Also renames the flag.

2 years agoproposal: Use flags to select/match proposals
Thomas Egerer [Tue, 3 Sep 2019 11:24:08 +0000 (13:24 +0200)]
proposal: Use flags to select/match proposals

During proposal selection with ike/child_cfgs a couple of boolean
variables can be set (e.g. private, prefer_self, strip_dh). To simplify
the addition of new parameters, these functions now use a set of flags
instead of indiviual boolean values.

Signed-off-by: Thomas Egerer <>
2 years agotravis: Bump wolfSSL to 4.2.0
Tobias Brunner [Wed, 23 Oct 2019 15:50:20 +0000 (17:50 +0200)]
travis: Bump wolfSSL to 4.2.0

2 years agoMerge branch 'ipv6-addrs-mobike'
Tobias Brunner [Tue, 22 Oct 2019 12:15:27 +0000 (14:15 +0200)]
Merge branch 'ipv6-addrs-mobike'

Address enumeration on Linux now ignores deprecated addresses and
whether temporary or permanent IPv6 addresses are included now depends
on the charon.prefer_temporary_addrs setting.

Closes #3192.

2 years agokernel-netlink: Enumerate temporary IPv6 addresses according to config
Tobias Brunner [Fri, 4 Oct 2019 13:34:04 +0000 (15:34 +0200)]
kernel-netlink: Enumerate temporary IPv6 addresses according to config

This way we announce only permanent addresses via MOBIKE by default, and
temporary ones if the option is enabled.

2 years agokernel-netlink: Don't enumerate deprecated IPv6 addresses
Tobias Brunner [Fri, 4 Oct 2019 08:39:26 +0000 (10:39 +0200)]
kernel-netlink: Don't enumerate deprecated IPv6 addresses

2 years agoutils: Handle NULL consistently if memwipe() is implemented via explicit_bzero()
Tobias Brunner [Thu, 17 Oct 2019 11:09:54 +0000 (13:09 +0200)]
utils: Handle NULL consistently if memwipe() is implemented via explicit_bzero()

Our own implementation ignores NULL values, however, explicit_bzero()
can't handle that, as indicated by the `__nonnull ((1))` attribute in the
function's signature in string.h, and causes a segmentation fault.  This
was noticed in one of the unit tests for NewHope.  Since we usually use
memwipe() via chunk_clear(), which already ignores NULL pointers, this
is not that much of an issue in practice.

Fixes: 149d1bbb055a ("memory: Use explicit_bzero() as memwipe() if available")