Add PSK to h as well.

This commit is contained in:
Adam Ierymenko 2023-03-08 16:00:23 -05:00
parent 5fbaf28c12
commit ccb5ff8e6d

View file

@ -948,7 +948,7 @@ impl<Application: ApplicationLayer> Context<Application> {
assert!(metadata.len() <= (u16::MAX as usize));
reply_len = append_to_slice(&mut reply_buffer, reply_len, &(metadata.len() as u16).to_le_bytes())?;
let noise_h_next = mix_hash(&noise_h_next, &reply_buffer[HEADER_SIZE..reply_len]);
let noise_h_next = mix_hash(&mix_hash(&noise_h_next, &reply_buffer[HEADER_SIZE..reply_len]), session.psk.as_bytes());
enc_start = reply_len;
reply_len = append_to_slice(&mut reply_buffer, reply_len, metadata)?;
@ -1047,6 +1047,8 @@ impl<Application: ApplicationLayer> Context<Application> {
}
let (alice_noise_s, psk, application_data) = check_result.unwrap();
let noise_h_next = mix_hash(&noise_h_next, psk.as_bytes());
// Complete Noise_XKpsk3 on Bob's side.
let noise_es_ee_se_hk_psk = Secret(hmac_sha512(
&hmac_sha512(