Commit Graph
4061 Commits
Author SHA1 Message Date
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
Tobias Brunner 47d9590556 openssl: Add support for CMS-style signatures in PKCS#7 (RSA-PSS, ECDSA) 2023-03-30 10:46:46 +02:00
Tobias Brunner 5e76bc1634 pkcs7: Add support for CMS-style signatures (RSA-PSS, ECDSA)
For the legacy schemes with rsaEncryption nothing changes, but if an
actual signature scheme is encoded we use that to find the key and
verify the signature.

The descriptions for the PKCS#7 structure are adapted for CMS.
2023-03-30 10:46:46 +02:00
Tobias Brunner 1326f805a8 asn1: Allow suppressing log messages when parsing algorithm identifiers 2023-03-30 10:46:46 +02:00
Tobias Brunner 4e73e9d3e9 botan: Pass n and e separately for RSA public keys
Some encoders, like those provided by the dnskey and sshkey plugins,
require these separately when encoding keys.

Also fixes the type for the ASN.1 encoding (which is a subjectPublicKeyInfo
structure) depending on the key type.  This worked fine for PEM encoding
as the pem plugin doesn't care what the actual type of the key is (which
is encoded in the SPKI structure), but other plugins do (e.g. the sshkey
plugin).
2023-03-30 10:45:04 +02:00
Tobias Brunner 9e17a0ed88 revocation: Suppress some log messages for cached OCSP responses
We don't have any information on the issuer of cached OCSP responses, in
particular if the OCSP response is issued by a dedicated OCSP signer,
whose certificate might not be contained in the response or even signed
by the same CA but could just be locally installed.  So the only way to
determine if a response applies to the current certificate and its CA
is searching for the response's issuer certificate and verifying that.

However, when using multiple CAs that provide revocation checking via
OCSP, in particular with multi-level CAs (e.g. like the
ikev2-multi-ca/ocsp-signers test scenario), we might have unrelated OCSP
responses in the cache when verifying a particular certificate.  In this
case we don't need any confusing

  ocsp response verification failed, no signer certificate '...' found

error messages because the response was for a different CA.

Similarly, if lots of clients of the same CA connect there could be lots
of OCSP responses in the cache that, while being applicable to the current
CA, don't have any information on the certificate we are currently
checking.  In this case all the

  ocsp response correctly signed by "..."
  ocsp response contains no status on our certificate

messages don't provide any value.

In the mentioned test scenario, we suppress the

  ocsp response verification failed, no signer certificate 'C=CH, O=strongSwan Project, OU=Research OCSP Signing Authority, CN=ocsp.research.strongswan.org' found

message from the cached OCSP response for carol's end-entity certificate
when verifying the "Research" intermediate CA certificate that issued
carol's certificate.

Then the

  ocsp response verification failed, no signer certificate 'C=CH, O=strongSwan Project, OU=Research OCSP Signing Authority, CN=ocsp.research.strongswan.org' found
  ocsp response verification failed, no signer certificate 'C=CH, O=strongSwan Project, OU=OCSP Signing Authority, CN=ocsp.strongswan.org' found

messages from the cached OCSP responses for carol's end-entity and
intermediate CA certificates when verifying dave's end-entity certificate.

And finally the

  ocsp response verification failed, no signer certificate 'C=CH, O=strongSwan Project, OU=Research OCSP Signing Authority, CN=ocsp.research.strongswan.org' found
    ocsp response correctly signed by "C=CH, O=strongSwan Project, OU=OCSP Signing Authority, CN=ocsp.strongswan.org"
    ocsp response contains no status on our certificate
  ocsp response verification failed, no signer certificate 'C=CH, O=strongSwan Project, OU=Sales OCSP Signing Authority, CN=ocsp.sales.strongswan.org' found

messages from the cached OCSP responses for carol's end-entity
certificate, the applicable but unrelated response for carol's "Research"
intermediate CA certificate and the response for dave's end-entity
certificate when verifying dave's "Sales" intermediate CA.
2023-03-28 16:26:01 +02:00
Tobias Brunner 01ec54afc9 openssl: Only allow certificates with cRLSign keyUsage to sign CRLs 2023-03-21 16:34:14 +01:00
Tobias Brunner 7d1f221211 x509: Only allow certificates with cRLSign keyUsage to sign CRLs 2023-03-21 16:34:14 +01:00
Tobias Brunner d12a4f5d23 openssl: Set X509_CRL_SIGN for CA certificates without keyUsage extension 2023-03-21 16:34:14 +01:00
Tobias Brunner 7414c06669 x509: Set X509_CRL_SIGN for CA certificates without keyUsage extension 2023-03-21 16:34:14 +01:00
Tobias Brunner 993dd54c8d windows: Fix compat define for sendto(2) 2023-03-21 16:33:03 +01:00
Tobias Brunner 8f5c0c9ca9 windows: Fix invalid pointer dereference when terminating service thread
When running as a service, the libraries are initialized/deinitialized
not by the main thread but by a separate thread that runs the registered
main service procedure.  When the service is stopped, the libraries are
deinitialized by that thread and the thread lock and hashtable are
destroyed.  But afterwards the DllMain callback is also triggered for
that thread so we have to prevent it from accessing these objects again.

References strongswan/strongswan#1567
2023-03-21 16:27:10 +01:00
Tobias Brunner 18d73a9a5c utils: Add counterpart to wait_sigint() to explicitly stop waiting 2023-02-22 14:33:34 +01:00
Tobias Brunner 48ef9bfbb6 openssl: Fix size of plugin feature array
Fixes: 312847e1a3 ("openssl: Add curve25519 and curve448 after ECDH groups")
2023-02-17 16:58:19 +01:00
Tobias Brunner 312847e1a3 openssl: Add curve25519 and curve448 after ECDH groups
This was the order before 46a6b06282 ("openssl: Only announce ECDH
groups actually supported by OpenSSL") but that's not really the reason
for this change.  It's related to the Android app, where we previously
didn't support these DH groups in BoringSSL and added the curve25519
plugin after the openssl plugin instead.  This resulted in the same
order, i.e. ECDH groups before curve25519.  With the switch to OpenSSL
and the mentioned commit, this changed and curve25519 was now the first
group that was proposed and used for the KE payload.  Not really an
issue you'd think, however, there are apparently Zyxel Firewalls with
older firmware versions (some forum posts mentioned a fix in V5.31) that
can't handle KE payloads with DH groups > 21 (ecp521). So with
curve25519 (31) proposed in the KE payload, they silently dropped the
IKE_SA_INIT request and no connection could be established.
2023-02-17 16:40:59 +01:00
Tobias BrunnerandThomas Egerer 0de42047a9 enum: Add functions to add and remove mappings from enum names
Co-authored-by: Thomas Egerer <[email protected]>
2023-02-17 13:37:38 +01:00
Tobias Brunner 55719d7de5 kernel-netlink: Add support for full packet and policy HW offloading 2023-02-16 13:25:34 +01:00