Commit Graph
1675 Commits
Author SHA1 Message Date
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 Brunner 805cc3a69f curl: Add an option to select the SSL/TLS backend (if available)
If libcurl is built with MultiSSL support (not the case for e.g.
Debian/Ubuntu, which ship separate, conflicting libraries), this allows
selecting the SSL/TLS backend libcurl uses.
2023-01-23 11:17:33 +01:00
Tobias Brunner d11868fb38 curl: Don't ignore unknown SSL/TLS backends
Only older versions of OpenSSL and GnuTLS need special treatment, so we
now accept all other backends (e.g. "(SecureTransport) OpenSSL/1.1.1s"
on macOS).

Whenever we remove support for the affected versions of the mentioned
libraries, we can remove the corresponding *-threading plugin feature
and the code here.
2023-01-23 11:17:33 +01:00
Andreas Steffen 8effb06d6c pki: Use X.509v3 EKU extension in CSR 2023-01-11 19:19:09 +01:00
Tobias Brunner 98be74914d sha1: Clarify license of the implementation 2022-12-14 13:38:38 +01:00
Andreas Steffen 18082ce2b0 certificates: Retrieve serial numbers in canonical form
The x509 plugin retrieves serial numbers with two's complement
encoding whereas the openssl plugin partially returns them without
leading zeroes.

Serial numbers in X.509 certificates, X.509 CRL, X.509 attribute
certificates, OCSP Requests and OCSP responses are now returned in
canonical form without prepended zero octets.
2022-12-05 20:18:24 +01:00
Tobias Brunner 02519ad60e af-alg: Fix compiler warning 2022-12-02 14:56:38 +01:00
Tim Weller af71f14ba3 wolfssl: Updates to resolve build conflicts
The wolfSSL's OpenSSL compatibility layer is not used by the plugin at
all and preventing its inclusion avoids conflicts with ASN1_ constants.

The inclusion of wolfssl/ssl.h is moved to the only file that requires
it as older wolfSSL versions defined a conflicting ASN1_GENERALIZEDTIME.

Other changes address issues with the FIPS use case.

Closes strongswan/strongswan#1332
2022-11-10 16:23:44 +01:00
Tobias Brunner 7f46c76125 Make functions static that are only accessed from the same compilation unit
Also removed some declarations for undefined functions.
2022-10-05 19:00:46 +02:00
Tobias Brunner c58ba0cb9f openssl: Remove unused openssl_hash_chunk() helper
Was used by the ECDSA implementation before 293a912c7d ("openssl: Fixes
for ECDSA with OpenSSL 3.0").
2022-10-05 18:15:26 +02:00
Tobias Brunner 1f870ae189 cert-validator: Use a separate method for online revocation checking
This avoids having to repeat offline checks after basic trust chain
validation.
2022-10-03 10:48:46 +02:00
Tobias Brunner 1968615590 revocation: Enforce a (configurable) timeout when fetching OCSP/CRL
Malicious servers could otherwise block the fetching thread indefinitely
after the initial TCP handshake (which has a default timeout of 10s
in the curl and winhttp plugins, the soup plugin actually has a default
overall timeout of 10s).
2022-10-03 10:48:46 +02:00
Andreas Steffen 6bf60221f5 pkcs7: Support rsa-pss signatures 2022-10-03 09:52:07 +02:00
Tobias Brunner 9efd7d7e90 eap: Print vendor (PEN) names for vendor-specific EAP methods 2022-09-21 13:53:44 +02:00
Tobias Brunner 48e9267d7a cred-encoding: Avoid potential use after free when caching encodings
The pattern currently is to call get_cache(), generate the encoding
if that failed and then store it with cache().  The latter adopts the
passed encoding and frees any stored encoding.  However, the latter means
that if two threads concurrently fail to get a cached encoding and then
both generate and store one, one of the threads might use an encoding
that was freed by the other thread.

Since encodings are not expected to change, we can avoid this issue by
not replacing an existing cache entry and instead return that (while
freeing the passed value instead of the cached one).

Closes strongswan/strongswan#1231
2022-09-20 09:53:13 +02:00
Tobias Brunner 80b2c6cdc5 gcrypt: Return correct IV length (0) for ECB mode 2022-09-15 12:16:12 +02:00
Tobias Brunner 7217ff5fc5 aesni: Fix out-of-bound read when loading 192-bit AES keys 2022-09-15 12:16:12 +02:00
Andreas Steffen 3fa3d2666a pki: pki --req can use old certreq as template
When an X.509 certificate has to be renewed it is helpful to use
the old PKCS#10 certificate request as a template, so that the
distinguishedName (DN), the subjectAlternativeName (SAN) and
a certificate profile name don't have to be typed-in again.

The old public key in the existing certreq is replaced with the
new key and the signature is re-generated using the new private key.
2022-08-31 15:10:34 +02:00
Andreas Steffen 1ef8b92211 pkcs10: Support of Microsoft CertTypeExtension
The msCertificateTypeExtension OID (1.3.6.1.4.1.311.20.2) can
be used in a PKCS#10 certificate request to define a certificate
profile. It consists of an UTF8 string.

pki: profile option
2022-08-24 20:46:44 +02:00
Fabrice Fontaine 5900426a71 wolfssl: Rename encrypt methods to avoid conflicts with system headers
Rename `encrypt` methods to avoid the following build failure when wolfSSL
is built with --enable-opensslextra:

In file included from ../../../../src/libstrongswan/utils/utils.h:59,
                 from ../../../../src/libstrongswan/library.h:101,
                 from wolfssl_common.h:29,
                 from wolfssl_aead.c:23:
wolfssl_aead.c:90:16: error: conflicting types for 'encrypt'; have '_Bool(union <anonymous>,  chunk_t,  chunk_t,  chunk_t,  chunk_t *)'
   90 | METHOD(aead_t, encrypt, bool,
      |                ^~~~~~~
../../../../src/libstrongswan/utils/utils/object.h:99:20: note: in definition of macro 'METHOD'
   99 |         static ret name(union {iface *_public; this;} \
      |                    ^~~~
In file included from /home/autobuild/autobuild/instance-5/output-1/host/powerpc64le-buildroot-linux-musl/sysroot/usr/include/wolfssl/wolfcrypt/wc_port.h:573,
                 from /home/autobuild/autobuild/instance-5/output-1/host/powerpc64le-buildroot-linux-musl/sysroot/usr/include/wolfssl/wolfcrypt/types.h:35,
                 from /home/autobuild/autobuild/instance-5/output-1/host/powerpc64le-buildroot-linux-musl/sysroot/usr/include/wolfssl/wolfcrypt/logging.h:33,
                 from /home/autobuild/autobuild/instance-5/output-1/host/powerpc64le-buildroot-linux-musl/sysroot/usr/include/wolfssl/ssl.h:35,
                 from wolfssl_common.h:64,
                 from wolfssl_aead.c:23:
/home/autobuild/autobuild/instance-5/output-1/host/powerpc64le-buildroot-linux-musl/sysroot/usr/include/unistd.h:149:6: note: previous declaration of 'encrypt' with type 'void(char *, int)'
  149 | void encrypt(char *, int);
      |      ^~~~~~~

Closes strongswan/strongswan#1201
2022-08-18 10:41:15 +02:00
Andreas Steffen bcedd65a31 pkcs7: Allow for missing optional content field
The content field of type OCTET STRING of a ContentInfo object
with ContentType Data

  ContentInfo ::= SEQUENCE {
     contentType ContentType,
     content
        [0] EXPLICIT OCTET STRING OPTIONAL

is optional and can be missing if no data is available
2022-07-29 07:59:00 +02:00
Tobias Brunner 42ed6b44b2 af-alg: Fix "'strncpy' specified bound equals destination size" warnings 2022-07-18 14:49:12 +02:00
Tobias Brunner 112bb465fb openssl: Add support for AES and Camellia in CTR mode 2022-07-18 13:01:22 +02:00
Tobias Brunner eae30af029 Use wolfSSL 5.4.0 for tests
The 5.4.0 update changed the default bignum implementation to what
could explicitly be enabled via `--enable-sp-math-all`.  Since this uses
fixed-sized buffers sufficient for key sizes of SP_INT_BITS, with a default
of 4096, modp6144 and modp8192 didn't work anymore (wc_DhGenerateKeyPair()
returned MP_EXPTMOD_E).  So we have to adapt the feature checks for this.

To support the larger DH groups we can either increase the buffer size
via `--with-max-rsa-bits` or add `--enable-heapmath` so buffers get
(re-)allocated as needed.  We go with the latter for now.
2022-07-18 12:42:24 +02:00
Andreas Steffen 2b474073d9 pem: Support PEM-encoded PKCS#7 container 2022-07-06 20:38:00 +02:00
Tobias Brunner 4e5a2037e7 wolfssl: Move shared secret calculation to get_shared_secret()
The ECDH implementation gets a bit simpler since we removed the
ecp_x_coordinate_only option a while ago.

Also added calls to verify public keys.
2022-06-29 10:28:50 +02:00
Tobias Brunner 26ca0c9f70 pkcs11: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner d95082ce0d gcrypt: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner ed3494ef7b curve25519: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner 31f467d70b botan: Move shared secret calculation to get_shared_secret() 2022-06-29 10:28:50 +02:00
Tobias Brunner 0e82d5cc2c gmp: Move shared secret calculation to get_shared_secret()
This avoids doing costly operations when just setting the public key.
For the same reason the optional extended public key check is moved.
2022-06-29 10:28:50 +02:00
Tobias Brunner 3af7c6db87 Rename diffie_hellman_t to key_exchange_t and change the interface etc.
This makes it more generic so we can use it for QSKE methods.
2022-06-29 10:28:50 +02:00
Tobias Brunner ec95fd9b93 bliss: Remove stray URLs from headers 2022-06-29 10:28:17 +02:00
Tobias Brunner 19ef2aec15 Update copyright headers after acquisition by secunet 2022-06-28 10:22:56 +02:00
Tobias Brunner 8dbcff1e8b openssl: Use dynamically allocated array to determine EC curves
This avoids the use of a variable length array, which should probably
be avoided in general due to potential performance, portability and
security issues (not in this particular case, though).

Closes strongswan/strongswan#1095
2022-06-27 15:54:23 +02:00
Tobias Brunner 1c198bf22b fips-prf: Add explicit bound check to avoid GCC 12 compile warning
GCC assumes this->b is zero (or may be zero) and spits out the following
warning (or error with -Werror):

src/libstrongswan/plugins/fips_prf/fips_prf.c:124:12: error: array subscript 18446744073709551615 is above array bounds of ‘uint8_t[<U8090>]’ {aka ‘unsigned char[<U8090>]’} [-Werror=array-bounds]
  124 |         one[this->b - 1] = 0x01;
      |         ~~~^~~~~~~~~~~~~
2022-06-27 14:09:11 +02:00
Tobias Brunner af9c78d393 plugin-loader: Print an error message if plugin constructor is not found 2022-05-06 12:02:45 +02:00
Tobias Brunner 352fa96dfc gcrypt: Initialize variables when en-/decrypting with RSA to avoid warnings 2022-04-22 09:49:37 +02:00
Tobias Brunner 2283a19b80 kdf: Fix Doxygen comments 2022-04-22 09:49:37 +02:00
Tobias Brunner c508b904b8 openssl: Fix typo in comment 2022-04-21 11:06:30 +02:00
Tobias Brunner a8bab0ee15 openssl: Move ENGINE-specific code into a separate file
This way we can compile it with OPENSSL_SUPPRESS_DEPRECATED for
OpenSSL 3.0, which deprecated the ENGINE API.
2022-04-14 19:05:44 +02:00
Tobias Brunner f26639de2c openssl: Remove checks and legacy compatibility code for OpenSSL < 1.0.2
More of this code was already removed with previous commits.

While versions < 1.1.1 are not officially supported anymore, 1.0.2 might
still be in use because before 3.x that was the latest version with
official FIPS support (OpenSSL apparently also provides extended commercial
support for it).
2022-04-14 19:05:44 +02:00
Tobias Brunner db0c53c207 openssl: Fixes for HMAC with OpenSSL 3.0 2022-04-14 19:05:44 +02:00
Tobias Brunner 293a912c7d openssl: Fixes for ECDSA with OpenSSL 3.0 2022-04-14 19:05:44 +02:00
Tobias Brunner 544fb1cf92 pkcs8: Parse the decrypted PKCS#8 structure via regular builders
This allows other plugins to parse such structures directly.  The pkcs8
plugin is called recursively again if necessary.
2022-04-14 19:05:44 +02:00
Tobias Brunner 21b586c61c openssl: Fixes for RSA with OpenSSL 3.0 2022-04-14 19:05:44 +02:00
Tobias Brunner 36cf74f5d9 openssl: Fixes for DH with OpenSSL 3.0
While we could assign the DH object to a EVP_PKEY object, this won't work
with BoringSSL as it doesn't seem to support EVP_PKEY_derive() for DH.
2022-04-14 19:05:44 +02:00
Tobias Brunner f5710c9ccb openssl: Fixes for ECDH with OpenSSL 3.0
Uses new and non-deprecated APIs to create/generate key pairs.
2022-04-14 19:05:44 +02:00
Tobias Brunner 13efce489e openssl: PRF_KEYED_SHA1 might not be supported
The old API has been deprecated with OpenSSL 3 and direct access to the
state isn't possible via EVP API.  In the future we might just remove this
implementation but we'd probably have to implement EAP-AKA' first, which
uses HMAC-SHA-256 with IKEv2's prf+ construct to derive keys instead
of this weird construct (plus what fips-prf builds around it) that's used
by EAP-AKA.
2022-04-14 19:05:44 +02:00