18937 Commits

Author SHA1 Message Date
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 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