Commit Graph
1740 Commits
Author SHA1 Message Date
Tobias Brunner 9ac6c469a5 bliss: Fix build with built-in printf-specifiers
This won't work for monolithic builds because the plugin and the
executable are built before libstrongswan.
2024-04-02 14:18:43 +02:00
Tobias Brunner b2f957f5f1 pkcs11: Fix cleanup when verifying signature fails because scheme isn't supported
Fixes: 49769fff53 ("pkcs11: Support RSA-PSS signatures")
2024-03-14 13:58:02 +01:00
Jean-François HrenandTobias Brunner 15612b3a42 Add support for IKEv2 OCSP extensions (RFC 4806)
Closes strongswan/strongswan#2016

Co-authored-by: Tobias Brunner <[email protected]>
2024-03-13 15:10:50 +01:00
Tobias Brunner b29be6029e constraints: Properly validate name constraints according to RFC 5280
The previous code was in a way too simple which resulted in it being too
strict.  For instance, it enforced that intermediate CA certificates
inherited the name constraints of their parents.  That's not required by
RFC 5280 and prevented e.g. adding constraints in an intermediate CA
certificate that's followed by another that doesn't contain any
name constraints.  That's perfectly fine as the set of constraints
specified by the parent continue to apply to that CA certificate and
the children it issues.

Name constraints were previously also applied to all identities of a
matching type, which is way too strict except for some very simple
cases.  It basically prevented multiple constraints of the same type
as e.g. an intermediate CA certificate that has permitted name constraints
for example.org and example.com couldn't issue acceptable certificates
because any SAN with one domain would get rejected by the other
constraint.  According to RFC 5280 matching one constraint is enough.

Also fixed is an issue with name constraints for IP addresses which were
previously only supported for a single level.
2024-03-12 09:14:44 +01:00
Gerardo Ravago 44e241fccc openssl: Handle BoringSSL-style ASN1_INTEGERs in cert serials
OpenSSL stores the serial number for an X509 certificate as an
`ASN1_INTEGER` type. Within BoringSSL (and AWS-LC), the library
represents the value of zero as an empty array [1] which is different
from OpenSSL which represents it as the 1-byte array [0x00]. Though the
value of zero for the certificate serial number is illegal under
X.509 [2], we need to handle/encode it consistently within strongSwan.
From 18082ce2b0 ("certificates: Retrieve serial numbers in canonical
form"), we infer that the canonical representation of the zero serial
is [0x00]. To do this, we introduce `openssl_asn1_int2chunk` to
complement the existing string version that allows us to handle the
special case for zero instead of always returning a reference to the
library-dependent encodings.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2138

[1] https://github.com/google/boringssl/commit/bdc35b63617f78037768f4897d8835696f02181a
[2] https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2
2024-03-05 08:51:16 +01:00
Tobias Brunner 6dee8587f0 Remove obvious empty statements (i.e. stray semicolons) 2024-02-29 15:30:40 +01:00
Andreas Steffen 49769fff53 pkcs11: Support RSA-PSS signatures 2024-02-21 11:22:33 +01:00
Andreas Steffen f739657aac pkcs11: Updated pkcs11.h header file based on OpenSC 2024-02-21 11:22:33 +01:00
Gerardo Ravago e56b597af1 openssl: Condition out unsupported curves for AWS-LC
AWS-LC lacks support for a number of elliptic curve algorithms so this
adds some conditional macros to avoid registering the related plugin
features. Support for curves ed448 and x448 is completely absent and are
not planned for implementation as they are no longer recommended for use.
While ed25519 is supported by the library, a single missing API for
ASN.1 DER encoding of its private keys is missing which prevents its
use in strongSwan. Future work may remove this limitation, but for now
we will disable the functionality.

Closes strongswan/strongswan#2109
2024-02-21 08:42:48 +01:00
Gerardo Ravago 7f1ba3cc68 openssl: Add conditional macros around SHA_CTX for AWS-LC
AWS-LC is a BoringSSL-based libcrypto implementation. SHA_CTX is declared with
the hash data specified as an array rather than as a field in upstream OpenSSL.
Since AWS-LC builds against C99, we are unable to handle this with anonymous
unions like BoringSSL. The workaround I propose is to add these conditional
macros around the accessors within openssl_sha1_prf. After this change,
everything builds successfully with AWS-LC headers.

Closes strongswan/strongswan#2103
2024-02-19 10:01:51 +01:00
Gerardo Ravago 31f55ba6e9 openssl: Add missing error checking when encoding ED private key
This applies the same logic found in other private key implementations
like that for ECDSA.

Closes strongswan/strongswan#2097
2024-02-14 17:57:41 +01:00
Tobias Brunner bf017a9d17 curl: Fix issue with printf checks in newer curl versions
Newer curl versions (as used on macOS via Homebrew) add attributes like

  __attribute__ ((format(printf, a, b)))

to their `curl_*printf*` functions, which fails if we redefine `printf`
as e.g. `builtin_printf` (pulled in via library.h).  We could disable
these checks via CURL_NO_FMT_CHECKS, but reordering the headers should
do the trick as well.
2024-01-16 11:00:29 +01:00
Tobias Brunner 9c4846cdbe x509: Make sure the status in OCSP responses has the correct length 2023-11-24 17:41:18 +01:00
Tobias Brunner f3af1704d9 x509: Make length of nonces in OCSP requests configurable
Some servers might not support a length of 32 and return a malformed
request error. Lowering the value to the previous default of 16 could
help in that case.
2023-11-24 17:41:18 +01:00
Tobias Brunner 6d345b3dde revocation: Reject OCSP error responses
Otherwise, there is lengthy code that tries to validate such responses,
even though they don't contain any signatures.
2023-11-24 17:41:18 +01:00
Tobias Brunner b3e66aca5c x509: Add getter for status of OCSP responses 2023-11-24 17:41:18 +01:00
Tobias Brunner e7a58f46f9 x509: Correctly parse responderId as ASN.1 CHOICE in OCSP response
The two OPTs that were used previously allowed to omit it completely (hence
the fallback to ID_ANY), but that's invalid, so it's better to fail
parsing.
2023-11-24 17:41:18 +01:00
Tobias Brunner 585c40095a x509: Correctly handle missing responder ID when parsing OCSP response errors
The has_issuer() and issued_by() methods relied on it to be defined, so
if the OCSP response wasn't successful (i.e. OCSP status indicates an
error and no OCSP response is parsed), a null-pointer dereference was
caused if the caller checked if the OCSP response was issued by a
specific certificate.

That's a side-effect of the referenced commit.  Previously, error codes
caused the OCSP response to not get parsed successfully, which technically
wasn't correct as it's well formed and successfully parsed, it's just
indicating an error state.

Fixes: 00ab8d62c0 ("x509: Support generation of OCSP responses")
2023-11-24 17:41:18 +01:00
Tobias Brunner 74ae71d2b8 x509: Ensure extensions are encoded even if others are missing
As with the previous commit, this is probably never an issue in practice
as most certificates contain at least one SAN.
2023-11-15 17:08:46 +01:00
Tobias Brunner ba08e01b86 x509: Also encode extendedKeyUsage in cert requests if there are no SANs or certificate type
Probably never was an issue in practice as most certificates contain at
least one SAN.
2023-11-15 17:01:02 +01:00
Tobias Brunner 724e64cac4 Move ocsp_responder_t interface as it's not a certificate 2023-11-14 10:35:47 +01:00
Tobias Brunner 14bd0bc743 Fixed some typos, courtesy of codespell 2023-11-14 10:11:16 +01:00
Andreas Steffen 6941dcb17a x509: Fix regression introduced by commit a22147a
Instead of the CA certificate's subjectKeyIdentifier erroneously
the CA's authorityKeyIdentifier was used as the authorityKeyIdentfier
of the certificate to be issued. This might work with a root CA
where the authorityKeyIdentifier equals its subjectKeyIdentfier
but introduces a severe regression when an intermediate CA is used.
2023-11-14 08:00:27 +01:00
Tobias Brunner efac611566 openxpki: Register as OCSP responder 2023-11-13 12:50:24 +01:00
Andreas Steffen 00ab8d62c0 x509: Support generation of OCSP responses 2023-11-13 12:40:55 +01:00
Andreas Steffen 199c7083e1 openxpki: OCSP responder plugin accessing OpenXPKI
The openxpki plugin directly access the certificates table in
the OpenXPKI's MariaDB in order to retrieve the status of an
issued X.509 certificate based on its serial number.
2023-11-13 12:40:55 +01:00
Andreas Steffen 9381559754 x509: Support parsing of OCSP requests 2023-11-13 12:39:10 +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 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 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 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 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 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 1b58e8c386 drbg: Fix build with DEBUG_LEVEL < 4 2023-05-08 17:32:17 +02:00