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.
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")
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
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.
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.
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.
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
ifdef.
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).
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.
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.
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
preferred.
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.
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 <thomas.egerer@secunet.com>
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.
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")
Tobias Brunner [Thu, 17 Oct 2019 06:31:51 +0000 (08:31 +0200)]
travis: Switch to the Ubuntu 18.04 (bionic) image for tests
Do two full build tests on 16.04 (xenial) and the two for OpenSSL 1.0
also run there. Since 18.04 ships OpenSSL 1.1.1, which conflicts with
our custom built version, we skip that until OpenSSL 3.0 is released.
A workaround is required for an issue with sonarqube on bionic.
Tobias Brunner [Fri, 18 Oct 2019 14:53:35 +0000 (16:53 +0200)]
prf-plus: Fail after counter has wrapped around
The behavior is undefined if this happens (RFC 7296, section 2.13).
Instead of switching to the non-counter mode, or letting the counter
wrap, this makes it clear that the usage was not as intended.