tls-server: Mutual authentication support for TLS 1.3
This commit also addresses the side effect that additional messages have an influence on the derivation of the application traffic secrets. Therefore, key derivation is relocated after the server finished message has been sent, so the additional messages from the client (Certificate, CertificateVerify) don't affect the key derivation. Only the outbound key is switched there, the inbound key remains in use until the client's finished message has been processed.
This commit is contained in:
committed by
Tobias Brunner
parent
dc49d457a2
commit
d2fc9b0961
+28
-1
@@ -1730,6 +1730,26 @@ static chunk_t tls13_sig_data_server = chunk_from_chars(
|
||||
0x79, 0x00,
|
||||
);
|
||||
|
||||
/**
|
||||
* TLS 1.3 static part of the data the peer signs (64 spaces followed by the
|
||||
* context string "TLS 1.3, client CertificateVerify" and a 0 byte).
|
||||
*/
|
||||
static chunk_t tls13_sig_data_client = chunk_from_chars(
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x2c,
|
||||
0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20,
|
||||
0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63,
|
||||
0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66,
|
||||
0x79, 0x00,
|
||||
);
|
||||
|
||||
METHOD(tls_crypto_t, sign, bool,
|
||||
private_tls_crypto_t *this, private_key_t *key, bio_writer_t *writer,
|
||||
chunk_t data, chunk_t hashsig)
|
||||
@@ -1873,7 +1893,14 @@ METHOD(tls_crypto_t, verify, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
data = chunk_cata("cm", tls13_sig_data_server, transcript_hash);
|
||||
if (this->tls->is_server(this->tls))
|
||||
{
|
||||
data = chunk_cata("cm", tls13_sig_data_client, transcript_hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = chunk_cata("cm", tls13_sig_data_server, transcript_hash);
|
||||
}
|
||||
}
|
||||
if (!key->verify(key, params->scheme, params->params, data, sig))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user