Commit Graph
1630 Commits
Author SHA1 Message Date
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
Tobias Brunner 1c1213f4b6 openssl: Move shared secret calculation to get_shared_secret()
This is a change from the multi-KE branch.
2022-04-14 19:05:44 +02:00
Tobias Brunner 56afc6e298 wolfssl: Implement HMAC-based IKEv2 PRFs via wolfSSL's HKDF implementation 2022-04-14 19:02:56 +02:00
Tobias Brunner 7498769aba botan: Implement HMAC-based IKEv2 PRFs via Botan's HKDF implementation 2022-04-14 19:02:56 +02:00
Tobias Brunner e0fc786ecd openssl: Implement HMAC-based IKEv2 PRFs via OpenSSL's HKDF implementation 2022-04-14 19:02:56 +02:00
Tobias Brunner 0339ce34f6 kdf: Implement wrapper for IKEv2 PRFs 2022-04-14 19:02:56 +02:00
Tobias Brunner ad0e94b6ed test-vectors: Add vectors for HMAC-based IKEv2 PRFs 2022-04-14 19:02:56 +02:00
Tobias Brunner 7bde56a9bc crypto: Adapt kdf_t interface to support KDFs with fixed output length 2022-04-14 19:02:56 +02:00
Tobias Brunner 96c7692661 wolfssl: Implement prf+ via wolfSSL's HKDF implementation 2022-04-14 19:02:56 +02:00
Tobias Brunner cb8f924051 botan: Implement prf+ via Botan's HKDF implementation 2022-04-14 19:02:56 +02:00
Tobias Brunner f0957d1250 kdf: Implement prf+ directly without relying on prf_plus_t 2022-04-14 19:02:56 +02:00
Tobias Brunner 2b9b579af9 openssl: Add a prf+ implementation based on OpenSSL's HKDF implementation
The HKDF-Expand() function defined in RFC 5869 is basically the same as
IKEv2's prf+(), so we can use the former to implement the latter.
However, we can only support HMAC-based PRFs this way, which should be
fine as others are rarely used.
2022-04-14 18:54:24 +02:00
Tobias Brunner 9e228de60a kdf: Add plugin that provides a default prf+ implementation 2022-04-14 18:54:24 +02:00
Tobias Brunner ce431366e6 test-vectors: Add test vectors for prf+ 2022-04-14 18:54:24 +02:00
Tobias Brunner 71ba969884 plugin-feature: Add plugin feature for KDFs 2022-04-14 18:54:24 +02:00
Tobias Brunner 961cb781b9 plugin-feature: Remove 'default' case in plugin_feature_un|load() 2022-04-14 18:54:24 +02:00
Tobias Brunner 86d526876d test-vectors: Add support for KDF test vectors 2022-04-14 18:54:24 +02:00
Tobias Brunner 3eecd40cec openssl: Don't unload providers
There is a conflict between atexit() handlers registered by OpenSSL and
some executables (e.g. swanctl or pki) to deinitialize libstrongswan.
Because plugins are usually loaded after atexit() has been called, the
handler registered by OpenSSL will run before our handler.  So when the
latter destroys the plugins it's a bad idea to try to access any OpenSSL
objects as they might already be invalid.

Fixes: f556fce16b ("openssl: Load "legacy" provider in OpenSSL 3 for algorithms like MD4, DES etc.")
Closes strongswan/strongswan#921
2022-02-24 15:03:09 +01:00
Tobias Brunner 9e3978259e mgf1: Fix Doxygen group for XOF implementation 2022-02-17 16:34:56 +01:00
Tobias Brunner 34a6cb858d openssl: Return correct number of plugin features if ECDH groups are omitted
Fixes: 46a6b06282 ("openssl: Only announce ECDH groups actually supported by OpenSSL")
2022-02-04 16:30:51 +01:00
Tobias Brunner 627eaa22ff Fixed some typos, courtesy of codespell 2022-01-20 10:44:42 +01:00
Tobias Brunner 21b2b124a1 agent: Log socket path if connecting to it failed 2022-01-20 10:02:54 +01:00
Tobias Brunner 910b7d1915 openssl: Log loaded providers 2021-12-08 11:34:22 +01:00
Tobias Brunner 3cd2e2ccc6 openssl: Make fips_mode option work with OpenSSL 3 2021-12-08 11:34:18 +01:00
Tobias Brunner f556fce16b openssl: Load "legacy" provider in OpenSSL 3 for algorithms like MD4, DES etc.
We still require these algorithms for e.g. EAP-MSCHAPv2, so the option is
enabled, by default.  To use other providers (e.g. fips or even custom
ones), the option can be disabled and the providers to load/activate can
be configured in openssl.cnf.  For instance, the following has the same
effect as enabling the option:

    openssl_conf = openssl_init

    [openssl_init]
    providers = providers

    [providers]
    default = activate
    legacy = activate

    [activate]
    activate = yes
2021-12-08 11:34:13 +01:00
Tobias Brunner 46a6b06282 openssl: Only announce ECDH groups actually supported by OpenSSL
Determined by whether the library provides curves for it or not.
For instance, in the OpenSSL 3 FIPS provider the Brainpool curves are
not included.  And in the Fedora package several weak curves are
explicitly patched out and the Brainpool curves are omitted even in
non-FIPS mode.
2021-12-08 11:33:04 +01:00
Tobias Brunner 03520a0d54 openssl: Add helper to map ECDH groups to curve NIDs 2021-12-08 11:32:59 +01:00
Andreas Steffen 01485770fd gcrypt: Support of AES-CFB encryption 2021-12-06 13:43:45 +01:00
Andreas Steffen 2d1a1cc907 botan: Support of AES-CFB encryption 2021-12-06 13:28:31 +01:00
Andreas Steffen 54d7e39d40 wolfssl: Support of AES-CFB encryption 2021-12-06 12:53:11 +01:00
Andreas Steffen 695a04d146 openssl: Support of AES-CFB encryption 2021-12-06 12:52:37 +01:00
Andreas Steffen 93bf894cd2 gcrypt: Support RSA OAEP SHA1 encryption/decryption 2021-11-10 21:06:10 +01:00
Andreas Steffen b50e8a88ff gcrypt: Enable RSA PKCS1 encryption/decryption 2021-11-10 20:17:49 +01:00
Andreas Steffen be52ad7c6d botan: RSA OAEP labels are not supported 2021-11-10 20:03:22 +01:00
Andreas Steffen 9cfdc32597 wolfssl: Support OAEP labels 2021-11-10 20:03:22 +01:00
Andreas Steffen 6adb543341 openssl: Implemented RSA OAEP encryption/decryption with optional labels 2021-11-10 20:03:22 +01:00
Andreas Steffen 4abb29f639 credentials: Added void *params to public_key encrypt() and private_key decrypt() methods 2021-11-09 17:58:28 +01:00
Andreas Steffen c8341fca61 botan: Fully enable RSA OAEP decryption 2021-11-09 17:58:28 +01:00
Tobias Brunner d6d31fce23 pkcs8: Don't forward NULL parameters when parsing keys
Other plugins don't expect this build part for RSA keys and will fail
parsing the keys further.
2021-10-18 11:24:11 +02:00
Tobias Brunner 234302a108 gmp: Reject RSASSA-PSS signatures with negative salt length
The `salt_len` field is signed because negative values are used to indicate
automatic salt lengths when generating signatures.  This must never be the
case when validating them.

Not checking this could lead to an integer overflow below.  The value is
assigned to the `len` field of a chunk (`size_t`), which is further used
in calculations to check the padding structure and (if that is passed by
a matching crafted signature value) eventually a memcpy() that will result
in a segmentation fault.

Fixes: 7d6b81648b ("gmp: Add support for RSASSA-PSS signature verification")
Fixes: CVE-2021-41990
2021-10-14 18:59:07 +02:00
Tobias Brunner 3a739424e1 pem: Clear possibly unencrypted key file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner 66e80f3d1b pem: Clear chunks after decrypting files 2021-10-04 11:30:03 +02:00
Tobias Brunner f92ad8454b openssl: Use correct key types when adopting Ed25519/448 keys
Fixes: cbf07ab5b0 ("openssl: Add support for Ed25519/Ed448")
2021-10-01 15:04:13 +02:00
Tobias Brunner c463a14483 openssl: Remove workaround for Brainpool ECDH curves for older OpenSSL versions
Using the workaround with the EVP interface, which we use to derive shared
keys since 74e02ff5e6 ("openssl: Mainly use EVP interface for ECDH"),
would actually require us to register the OIDs of these curves as NID.
Otherwise, the two EC_GROUPs used by private and public key objects
are not considered the same and the key derivation fails.

Since the curves are supported by OpenSSL since 1.0.2 it's probably rare to
find a version without them nowadays.  One exception is the old BoringSSL
version we still use on Android, which defines the NIDs but not the curve
data.  However, that version also lacks support to register OIDs as NIDs,
so the only option to support these groups there would be to got back to not
using the EVP interface, which isn't in anyone's interest.  If there really
is a need for them there, we could probably patch BoringSSL or use OpenSSL.
2021-10-01 15:04:13 +02:00
Tobias Brunner e166e6913c Change shebang for Python scripts to use python3 2021-09-21 12:51:47 +02:00
Tobias Brunner 57e68ab9c5 openssl: Improve compatibility to newer BoringSSL releases
Closes strongswan/strongswan#352
2021-08-24 14:20:37 +02:00