Commit Graph

92 Commits

Author SHA1 Message Date
Tobias Brunner 121ac4b9e3 tls-crypto: Generate MSK for TLS 1.3
We generate material for both MSK and EMSK even though we only need the
former.  Because HKDF-Expand-Label(), on which the export functionality
is based, encodes the requested key length, we have to allocate the same
number of bytes as e.g. FreeRADIUS does (i.e. if we only request 64
bytes, those won't be the same as the first 64 bytes after requesting
128 bytes).

Unfortunately, key derivation for TLS-based methods is currently not
standardized for TLS 1.3.  There is a draft [1], which defines a scheme
that's different from previous versions (instead of individual label
strings it uses a single one and passes the EAP type/code as context
value to TLS-Export()).  The current code is compatible to FreeRADIUS
3.0.x, which doesn't implement it according to that draft yet (there are
unreleased changes for EAP-TLS, not for the other methods, but these only
switch the label, no context value is passed).  In a separate draft
for EAP-TLS [2] there is an altogether different scheme defined in the
latest version (label combined with EAP method, no context and separate
derivation for MSK and EMSK).

So this is a mess and we will have to change this later with the inevitable
compatibility issues (we should definitely disable TLS 1.3 by default).

[1] https://tools.ietf.org/html/draft-ietf-emu-tls-eap-types
[2] https://tools.ietf.org/html/draft-ietf-emu-eap-tls13
2021-02-12 14:35:23 +01:00
Tobias Brunner 1b593e1d48 tls-crypto: Add support for RSA-PSS signatures
PKCS#1 v1.5 signatures are not defined for use with TLS 1.3 (they can
only appear in certificates, we now send a signature_algorithms_cert
extension to indicate support for them).  So for RSA certificates, we
must support RSA-PSS signatures.

There are two sets of schemes, that are differentiated by the type of
RSA key used for the signature, one is for classic RSA keys (rsaEncryption
OID), which can also be used with PKCS#1 when using TLS 1.2, the other
is for RSA-PSS keys (RSASSA-PSS OID), which are not yet commonly
used (and can't be generated by our pki tool).  According to the RFC,
PSS must also be supported for TLS 1.2 if the schemes are included in
the signature_algorithms extension (e.g. OpenSSL does not use PKCS#1 v1.5
anymore if PSS is proposed).

This changes how these schemes are stored and enumerated (they are not
treated as combination of hash algo and key type anymore).

Legacy schemes (MD5/SHA-1) are removed.
2021-02-12 11:45:47 +01:00
Tobias Brunner 1466d4da25 tls-crypto: Add method to update application traffic keys 2021-02-12 11:45:44 +01:00
Tobias Brunner 2271d67f07 tls-crypto: Add method to hash handshake data and use result as initial transcript
This is used for HelloRetryRequest.
2021-02-12 11:45:44 +01:00
Tobias Brunner 64e63c68c8 tls-crypto: Destroy HKDF instance if keys are derived multiple times
This will be the case during a retry.
2021-02-12 11:45:44 +01:00
Tobias Brunner 2e1c0a2776 tls-crypto: Rename methods to calculate finished message
Instead of the version number use "legacy" for the one for earlier TLS
versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner f116a4823f tls-crypto: Use internal PRF of tls-hkdf to generate finished message
Also adds additional checks.
2021-02-12 11:45:44 +01:00
Tobias Brunner de983a3cb9 tls-crypto: Simplify signature creation/verification 2021-02-12 11:45:44 +01:00
Tobias Brunner 2921f43705 tls-crypto: Simplify handshake/application key derivation and rename methods
Also consistently change the ciphers outside of tls_crypto_t and
simplify key derivation in tls_peer_t and fix a memory leak.
2021-02-12 11:45:44 +01:00
Tobias Brunner 3101120c75 tls-crypto: Enumerate x25519/448 and rename constant for consistency 2021-02-12 11:45:44 +01:00
Tobias Brunner 53ba0801ac tls-crypto: Simplify hash algorithm handling 2021-02-12 11:45:44 +01:00
Tobias Brunner 43c8f950a7 tls-crypto: Delay instantiation of cipher suites
This way we can take into account the version set via setter on tls_t.
2021-02-12 11:45:44 +01:00
Tobias Brunner 281766c5e6 tls-crypto: Filter TLS cipher suites by min/max version
There is no point proposing legacy (or future) cipher suites depending on
the proposed TLS versions. It was actually possible to negotiate and use
cipher suites only defined for TLS 1.2 with earlier TLS versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner 436571b2f0 tls-crypto: Correctly filter cipher suites based on PRF algorithms
The previous check operated on the first array element.
2021-02-12 11:45:44 +01:00
Tobias Brunner b7ea969b32 tls-crypto: Use correct key length for ChaCha20/Poly1305 2021-02-12 11:45:44 +01:00
bytinbit 7a2b02667c libtls: Implement TLS 1.3 handshake on client-side
The code is a minimal handshake with the HelloRetryRequest message
implementation missing.
Can be tested with an OpenSSL server running TLS 1.3. The server must
be at least version 1.1.1 (September 2018).

Co-authored-by: ryru <pascal.knecht@hsr.ch>
2021-02-12 11:45:44 +01:00
Tobias Brunner d5cf2d1f85 tls-crypto: Fix usage of chunk_from_chars()
See 8ea13bbc5c for details.

References #3249.
2020-01-30 18:18:06 +01:00
Tobias Brunner 2db6d5b8b3 Fixed some typos, courtesy of codespell 2018-02-13 12:19:54 +01:00
Tobias Brunner de280c2e03 private-key: Add optional parameters argument to sign() method 2017-11-08 16:48:10 +01:00
Tobias Brunner a413571f3b public-key: Add optional parameters argument to verify() method 2017-11-08 16:48:10 +01:00
Tobias Brunner 525cc46cab Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
2017-05-26 13:56:44 +02:00
Andreas Steffen 40f2589abf gmp: Support of SHA-3 RSA signatures 2016-09-22 17:34:31 +02:00
Andreas Steffen b12c53ce77 Use standard unsigned integer types 2016-03-24 18:52:48 +01:00
Martin Willi 064fe9c963 enum: Return boolean result for enum_from_name() lookup
Handling the result for enum_from_name() is difficult, as checking for
negative return values requires a cast if the enum type is unsigned. The new
signature clearly differentiates lookup result from lookup value.

Further, this actually allows to convert real -1 enum values, which could not
be distinguished from "not-found" and the -1 return value.

This also fixes several clang warnings where enums are unsigned.
2014-05-16 15:42:07 +02:00
Martin Willi ddf5222096 tls: Introduce a generic TLS purpose that accepts NULL encryption ciphers 2014-04-01 14:28:55 +02:00
Martin Willi ac5717c9e9 tls: Export a function to list supported TLS cipher suites 2014-04-01 14:28:55 +02:00
Martin Willi e67e8dd197 tls: Fix some TLS cipher suite enum names
It is important to have them mapped correctly, as we use these official TLS
identifiers to configure specific TLS suites.
2014-03-31 16:07:53 +02:00
Martin Willi b886dad498 tls: Fix AEAD algorithm filtering, avoid filtering all suites if no AEAD found 2014-03-31 15:56:12 +02:00
Martin Willi 48d6b57c30 tls: Offer TLS signature schemes in ClientHello in order of preference
Additionally, we now query plugin features to find out what schemes we exactly
support.
2014-03-31 15:56:12 +02:00
Martin Willi d06890d6e2 tls: Define AES-GCM cipher suites from RFC 5288/5289 2014-03-31 15:56:12 +02:00
Martin Willi f0f301170b tls: Implement the TLS AEAD abstraction for real AEAD modes 2014-03-31 15:56:12 +02:00
Martin Willi d3204677ba tls: Separate TLS protection to abstracted AEAD modes
To better separate the code path for different TLS versions and modes of
operation, we introduce a TLS AEAD abstraction. We provide three implementations
using traditional transforms, and get prepared for TLS AEAD modes.
2014-03-31 15:56:12 +02:00
Tobias Brunner 409adef43c libtls: Move settings to <ns>.tls with fallback to libtls 2014-02-12 14:34:32 +01:00
Tobias Brunner 07f826af67 Fixed encoding of TLS extensions (elliptic_curves and signature_algorithms) 2012-11-28 10:20:14 +01:00
Tobias Brunner f05b427265 Moved debug.[ch] to utils folder 2012-10-24 16:00:51 +02:00
Tobias Brunner 1407a0026f Added missing break when building TLS cipher suites 2012-09-28 18:55:40 +02:00
Martin Willi ab2c989c32 Don't allow NULL encryption with PEAP 2012-09-12 13:19:52 +02:00
Martin Willi 87dd205b61 Add a return value to hasher_t.allocate_hash() 2012-07-16 14:55:06 +02:00
Martin Willi 8bd6a30af1 Add a return value to hasher_t.get_hash() 2012-07-16 14:55:06 +02:00
Martin Willi ce73fc19db Add a return value to crypter_t.set_key() 2012-07-16 14:53:38 +02:00
Martin Willi e7d98b8c99 Add a return value to tls_prf_t.set_key() 2012-07-16 14:53:33 +02:00
Martin Willi 97b30b93b0 Add a return value to tls_prf_t.get_bytes() 2012-07-16 14:53:33 +02:00
Martin Willi 2d56575d52 Add a return value to signer_t.set_key() 2012-07-16 14:53:33 +02:00
Martin Willi 9020f7d0b9 Add a return value to tls_crypto_t.derive_secrets() 2012-07-16 14:53:33 +02:00
Martin Willi ae10ee6d0b Double check if a cached suite is available, overwrite any old suite state 2012-02-07 11:42:57 +01:00
Martin Willi 06c150365d Fix TLS EAP-MSK derivation, uses different order of randoms than key expansion 2012-02-07 10:54:53 +01:00
Martin Willi 1dabf5bfc7 Filter TLS suite MAC by HMAC algorithm, as the hash is not necessarily the same 2012-02-07 10:54:53 +01:00
Martin Willi 6a5c86b7ad Implemented TLS session resumption both as client and as server 2011-12-31 13:14:49 +01:00
Martin Willi ed57dfca3f In TLS 1.2, PRF and HASH function use at least SHA-256, not the MAC hash function 2011-12-24 12:42:28 +01:00
Tobias Brunner f3bb1bd039 Fixed common misspellings.
Mostly found by 'codespell'.
2011-07-20 16:14:10 +02:00