Skip to content

Commit

Permalink
Workaround extraction issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Feb 11, 2025
1 parent e20cc16 commit 9a3b214
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
46 changes: 28 additions & 18 deletions src/tls13handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,19 @@ fn put_server_hello(
};
set_by_handle(ks, &shared_secret_handle, shared_secret);

let psk_handle = psk.map(|x| {
let handle = Handle {
alg: ciphersuite.hash,
name: PSK,
level: 0,
};
set_by_handle(ks, &handle, x);
handle
});
// hax-issue: can't use mutating map here
let psk_handle = match psk {
Some(bytes) => {
let handle = Handle {
alg: ciphersuite.hash,
name: PSK,
level: 0,
};
set_by_handle(ks, &handle, bytes);
Some(handle)
}
None => None,
};

let (ch_handle, sh_handle, ms_handle) = derive_hk_handles(
&ciphersuite.hash,
Expand Down Expand Up @@ -560,16 +564,22 @@ fn get_server_hello(
let transcript = state.transcript.add(&sh);
let transcript_hash = transcript.transcript_hash()?;

let psk_handle = state.server.psk_opt.clone().map(|x| {
let handle = Handle {
alg: state.ciphersuite.hash,
name: PSK,
level: 0,
};
set_by_handle(ks, &handle, x);
handle
});

// hax-issue: can't use mutating map here
let psk_handle = state.server.psk_opt.clone();
let psk_handle = match psk_handle {
Some(bytes) => {
let handle = Handle {
alg: state.ciphersuite.hash,
name: PSK,
level: 0,
};
set_by_handle(ks, &handle, bytes);
Some(handle)
}
None => None,
};

let (ch_handle, sh_handle, ms_handle) = derive_hk_handles(
&state.ciphersuite.hash,
&shared_secret_handle,
Expand Down
12 changes: 6 additions & 6 deletions src/tls13keyscheduler/key_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,30 +367,30 @@ pub fn XPD<KS: KeySchedule<TLSnames>>(
.get(n1.unwrap(), l, (h1.name, h1.alg, h1.level))
.ok_or(INCORRECT_STATE)?;

let k: TagKey;
let k: TagKey =
if n == PSK {
l = l + 1;
k = xpd(
xpd(
&TagKey {
alg: h1.alg,
tag: h1.name,
val: k1,
},
label,
args,
)?;
)?
} else {
let d = KS::hash(args);
k = xpd(
xpd(
&TagKey {
alg: h1.alg,
tag: h1.name,
val: k1,
},
label,
&d,
)?;
}
)?
};
// let h =
let _ = ks.set(n, l, (h.name, h.alg, h.level), k.val);
// set(&mut self, name: N, level: u8, h: (N, HashAlgorithm, u8), hon: bool, k: (N, Key));
Expand Down

0 comments on commit 9a3b214

Please sign in to comment.