mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-07 00:01:49 -04:00
tls-hkdf: Pass secret to derive_secret() explicitly
This commit is contained in:
parent
4e2b8f9c71
commit
3e89d26e1c
@ -169,8 +169,8 @@ static bool expand_label(private_tls_hkdf_t *this, chunk_t secret,
|
|||||||
* Derive-Secret as defined in RFC 8446, section 7.1:
|
* Derive-Secret as defined in RFC 8446, section 7.1:
|
||||||
* Derive-Secret(Secret, Label, Message) -> OKM
|
* Derive-Secret(Secret, Label, Message) -> OKM
|
||||||
*/
|
*/
|
||||||
static bool derive_secret(private_tls_hkdf_t *this, chunk_t label,
|
static bool derive_secret(private_tls_hkdf_t *this, chunk_t secret,
|
||||||
chunk_t messages, chunk_t *okm)
|
chunk_t label, chunk_t messages, chunk_t *okm)
|
||||||
{
|
{
|
||||||
chunk_t context;
|
chunk_t context;
|
||||||
bool success;
|
bool success;
|
||||||
@ -180,7 +180,7 @@ static bool derive_secret(private_tls_hkdf_t *this, chunk_t label,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = expand_label(this, this->prk, label, context,
|
success = expand_label(this, secret, label, context,
|
||||||
this->hasher->get_hash_size(this->hasher), okm);
|
this->hasher->get_hash_size(this->hasher), okm);
|
||||||
chunk_free(&context);
|
chunk_free(&context);
|
||||||
return success;
|
return success;
|
||||||
@ -264,7 +264,7 @@ static bool move_to_phase_2(private_tls_hkdf_t *this)
|
|||||||
/* fall-through */
|
/* fall-through */
|
||||||
case HKDF_PHASE_1:
|
case HKDF_PHASE_1:
|
||||||
derived = chunk_from_str("tls13 derived");
|
derived = chunk_from_str("tls13 derived");
|
||||||
if (!derive_secret(this, derived, chunk_empty, &okm))
|
if (!derive_secret(this, this->prk, derived, chunk_empty, &okm))
|
||||||
{
|
{
|
||||||
DBG1(DBG_TLS, "unable to derive secret");
|
DBG1(DBG_TLS, "unable to derive secret");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -335,7 +335,7 @@ static bool move_to_phase_3(private_tls_hkdf_t *this)
|
|||||||
case HKDF_PHASE_2:
|
case HKDF_PHASE_2:
|
||||||
/* prepare okm for next extract */
|
/* prepare okm for next extract */
|
||||||
derived = chunk_from_str("tls13 derived");
|
derived = chunk_from_str("tls13 derived");
|
||||||
if (!derive_secret(this, derived, chunk_empty, &okm))
|
if (!derive_secret(this, this->prk, derived, chunk_empty, &okm))
|
||||||
{
|
{
|
||||||
DBG1(DBG_TLS, "unable to derive secret");
|
DBG1(DBG_TLS, "unable to derive secret");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -434,8 +434,8 @@ METHOD(tls_hkdf_t, generate_secret, bool,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!derive_secret(this, chunk_from_str(hkdf_labels[label]), messages,
|
if (!derive_secret(this, this->prk, chunk_from_str(hkdf_labels[label]),
|
||||||
&okm))
|
messages, &okm))
|
||||||
{
|
{
|
||||||
DBG1(DBG_TLS, "unable to derive secret");
|
DBG1(DBG_TLS, "unable to derive secret");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user