18830 Commits

Author SHA1 Message Date
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 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 5.9.12dr1 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
Tobias Brunner
e2bba1e2cf android: New release after updating target SDK to 33 android-2.4.2 2023-08-29 18:35:57 +02:00
Tobias Brunner
dfbafffc45 android: Increase compile-/targetSdkVersion to 33 (Android 13) 2023-08-29 18:03:30 +02:00