Commit Graph
4077 Commits
Author SHA1 Message Date
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 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 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 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
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 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
Tobias Brunner ba9228ab00 watcher: Change handling of POLLERR and remove WATCHER_EXCEPT
We can't actually explicitly listen for errors by passing POLLERR in
`events` (the man page for poll() clearly states it's ignored).  On the
other hand, POLLERR can be returned for any FD and, even worse, it might
be the only event indicated.

The latter caused an infinite loop as we didn't notify the callback nor
clear the error by calling `getsockopt(..., SOL_SOCKET, SO_ERROR, ...)`.
And while the latter would be able to reset the state to break the loop,
it seems to leave the FD in a defunct state where no further events will
be returned by poll().  Notifying the callback works better (the error
is then reported by e.g. recvfrom()) and automatically happened already
if POLLERR was returned together with e.g. POLLIN.

So we now treat POLLERR like the other error indicators we handle (POLLHUP
and POLLINVAL) and just notify the callbacks.
2023-07-26 15:14:50 +02:00
Tobias Brunner e0e99c1dd3 sha3: Make sure to wipe the internal Keccak state 2023-07-26 15:08:33 +02:00
Tobias Brunner bbbd15dd5c pkcs12: Make sure to wipe potentially decrypted PKCS#7 data 2023-07-26 15:08:33 +02:00
Tobias Brunner b4694aef49 pkcs7: Make sure to wipe decrypted content 2023-07-26 15:08:33 +02:00
Tobias Brunner ad8484a6cc aesni: Make sure to wipe salt 2023-07-26 15:08:33 +02:00
Tobias Brunner 9bda4a4415 ccm: Make sure to wipe salt 2023-07-26 15:08:33 +02:00
Tobias Brunner 0abb37b830 gcm: Make sure to wipe salt and H 2023-07-26 15:08:33 +02:00
Tobias Brunner 36b1a6d76c Use Botan 3.1.1 for tests
The all-zero Ed25519 public key is rejected by botan_pubkey_check_key()
when the key is loaded.

Note that Botan 3 requires GCC 11 or CLANG 14, i.e. can't easily be built
on Debian bullseye or Ubuntu 20.04.

The thread-local storage function gets flagged via various botan FFI
functions when using Botan 3, whitelist that instead of all of them.
2023-07-26 13:09:22 +02:00
Tobias Brunner fbc25f1c25 leak-detective: Whitelist C++'s __cxa_get_globals() 2023-07-13 10:48:53 +02:00
Tobias Brunner 43975f33ef Use wolfSSL 5.6.2 for tests
ECC keys can now be smaller so we can't access the private key directly
anymore.
2023-06-13 10:13:29 +02:00
Tobias Brunner 89ce398c3d openssl: Fix memory leak if FIPS provider isn't available 2023-06-02 11:27:39 +02:00
Tobias Brunner ee9a663b01 Fixed some typos, courtesy of codespell 2023-06-02 10:36:47 +02:00
Tobias Brunner efdcbd13cb credential-manager: Improve selection of local certificate and trust chain
The previous code was problematic if a certificate request for a known
but unrelated CA was received and the local trust chain was incomplete.
Due to the received anchor, the incomplete trust chain was dismissed and
any intermediate CA certificates were, therefore, not sent to the peer.

This new approach doesn't dismiss an incomplete trust chain, but prefers
one that can be resolved to a received anchor.  If no such chain is found,
the first one is used.
2023-06-02 10:04:39 +02:00
Tobias Brunner 1b58e8c386 drbg: Fix build with DEBUG_LEVEL < 4 2023-05-08 17:32:17 +02:00
Tobias Brunner 94cbd6469a bliss: Fix build with DEBUG_LEVEL < 2 2023-05-08 17:32:17 +02:00
Tobias Brunner b158c210cd sqlite: Fix build with DEBUG_LEVEL < 2 2023-05-08 14:07:18 +02:00
Tobias Brunner a9a2c040ba pkcs7: Fix build with DEBUG_LEVEL < 2 2023-05-08 14:07:18 +02:00
Tobias Brunner 7ea431cf70 constraints: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:07:18 +02:00
Tobias Brunner 984f8cbcde revocation: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:07:18 +02:00
Tobias Brunner c0a281472f x509: Fix build with DEBUG_LEVEL < 2 for structures that ignore unknown critical extensions 2023-05-08 14:07:18 +02:00
Tobias Brunner a551f80e4f plugin-loader: Fix build with DEBUG_LEVEL < 3 2023-05-08 14:06:43 +02:00
Tobias Brunner 1b59031cc3 auth-cfg: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:06:43 +02:00
Tobias Brunner 5a98f8f4ab certificate: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:06:43 +02:00
Tobias Brunner b39105b5b4 credential-factory: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:06:43 +02:00
Tobias Brunner f73d8699b3 crypto-tester: Fix build with DEBUG_LEVEL < 1 2023-05-08 14:06:43 +02:00
Tobias Brunner d7750dff9b asn1: Fix build with DEBUG_LEVEL < 2 2023-05-08 14:06:43 +02:00
Tobias Brunner 2d4a98d0d3 debug: Add macro to mark variables that are only used in DBG statements
Some variables that are only assigned to be used in DBG statements
will otherwise trigger a "set but not used" warning/error if DEBUG_LEVEL
is too low.
2023-05-08 11:51:10 +02:00
Tobias Brunner 0bf061d737 leak-detective: Add on_exit(3) to whitelist
Seems to allocate some TLS value in newer glibc versions.
2023-04-27 13:52:34 +02:00
Tobias Brunner 30803f90eb watcher: Prevent busy wait if callback is active and other FDs have events
Exiting the loop previously could cause watcher to busy wait (i.e.
rebuild the array and call poll() repeatedly) until the active callback
was done.

Assume watcher observes two FDs 15 and 22, which are in the list in that
order.  FD 15 is signaled and its callback gets triggered.  The array of
FDs is rebuilt and does not include 15 anymore.  Now FD 22 is ready for
reading.  However, when enumerating all registered FDs, the loop previously
was exited when reaching FD 15 and seeing that it's active.  FD 22 was
never checked and the array was immediately rebuilt and poll() called.
If the callback for 15 took longer, this was repeated over and over.

This basically reverts d16d5a245f ("watcher: Avoid queueing multiple
watcher callbacks at the same time"), whose goal is quite unclear to me.
If it really wanted to allow only a single callback for all FDs, it didn't
achieve that as any FD before an active one would get notified and if
multiple FDs are ready concurrently, they'd all get triggered too.
Skipping entries with active callback makes sense as it avoids a lookup
in the FD array and subsequent revents checks.  But why would we need to
rebuild the array if we see such an entry?  Once the callback is done,
the watcher is notified and the array rebuilt anyway (also if any other
FD was ready and jobs get queued).
2023-04-27 13:52:34 +02:00
Tobias Brunner 53208b0ba4 watcher: Move debug log messages out of mutex
The list of FDs is recreated quite often (e.g. due to the kernel-netlink
event sockets) and if a logger depends on watcher_t in some way this
might cause conflicts if the mutex is held.
2023-04-27 13:52:34 +02:00
Tobias Brunner 705a20619f watcher: Make sure to re-activate the correct entry after a callback
Since the same FD may be added multiple times (e.g. with separate
callbacks for WATCHER_READ and WATCHER_WRITE), the previous check
might not have found the correct entry.  As the entry can't be removed
while in a callback, the pointer comparison is fine.
2023-04-27 13:52:34 +02:00
Tobias Brunner 34e9cdbcac watcher: Log when watched FDs are added, removed or updated 2023-04-27 13:52:27 +02:00
Tobias Brunner 0a806d9717 watcher: Only log number of managed FDs
Adding the internal notify FD might be confusing.
2023-04-27 13:45:32 +02:00
Tobias Brunner 7c657e78ff watcher: Avoid logging on level 1 while holding the mutex
This could be problematic in case loggers in some way rely on watcher_t
themselves.  This particular log message should rarely occur if at all,
but still avoid holding the mutex.
2023-04-27 13:45:32 +02:00
Andreas Steffen 47e8b21c76 cert_cache: Replace cached stale OCSP responses in-place 2023-04-21 16:04:26 +02:00