tls-crypto: Add method to hash handshake data and use result as initial transcript
This is used for HelloRetryRequest.
This commit is contained in:
@@ -1579,6 +1579,30 @@ static bool hash_data(private_tls_crypto_t *this, chunk_t data, chunk_t *hash)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(tls_crypto_t, hash_handshake, bool,
|
||||||
|
private_tls_crypto_t *this, chunk_t *out)
|
||||||
|
{
|
||||||
|
chunk_t hash;
|
||||||
|
|
||||||
|
if (!hash_data(this, this->handshake, &hash))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk_free(&this->handshake);
|
||||||
|
append_handshake(this, TLS_MESSAGE_HASH, hash);
|
||||||
|
|
||||||
|
if (out)
|
||||||
|
{
|
||||||
|
*out = hash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(hash.ptr);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TLS 1.3 static part of the data the server signs (64 spaces followed by the
|
* TLS 1.3 static part of the data the server signs (64 spaces followed by the
|
||||||
* context string "TLS 1.3, server CertificateVerify" and a 0 byte).
|
* context string "TLS 1.3, server CertificateVerify" and a 0 byte).
|
||||||
@@ -2118,6 +2142,7 @@ tls_crypto_t *tls_crypto_create(tls_t *tls, tls_cache_t *cache)
|
|||||||
.create_ec_enumerator = _create_ec_enumerator,
|
.create_ec_enumerator = _create_ec_enumerator,
|
||||||
.set_protection = _set_protection,
|
.set_protection = _set_protection,
|
||||||
.append_handshake = _append_handshake,
|
.append_handshake = _append_handshake,
|
||||||
|
.hash_handshake = _hash_handshake,
|
||||||
.sign = _sign,
|
.sign = _sign,
|
||||||
.verify = _verify,
|
.verify = _verify,
|
||||||
.sign_handshake = _sign_handshake,
|
.sign_handshake = _sign_handshake,
|
||||||
|
|||||||
@@ -474,6 +474,14 @@ struct tls_crypto_t {
|
|||||||
void (*append_handshake)(tls_crypto_t *this,
|
void (*append_handshake)(tls_crypto_t *this,
|
||||||
tls_handshake_type_t type, chunk_t data);
|
tls_handshake_type_t type, chunk_t data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash the stored handshake data and store it. It is optionally returned
|
||||||
|
* so it could be sent in a cookie extension.
|
||||||
|
*
|
||||||
|
* @param hash optionally returned hash (allocated)
|
||||||
|
*/
|
||||||
|
bool (*hash_handshake)(tls_crypto_t *this, chunk_t *hash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a blob of data, append signature to writer.
|
* Sign a blob of data, append signature to writer.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user