fix: preserve authentication transcript order

Defer RSA, ECDH, and handshake completion until after each received packet
has been added to the authentication transcript, matching the upstream
workqueue ordering and preventing the controller from rejecting host secret.

Co-Authored-By: openai/gpt-5.6-luna: fixed GIP authentication ordering
This commit is contained in:
portersky
2026-08-29 13:54:23 +02:00
parent 0ed7a4bc3e
commit 1bcb038785
3 changed files with 34 additions and 4 deletions
+24 -3
View File
@@ -367,9 +367,30 @@ auto auth::handle_pkt_data(std::span<u8 const> data) -> int
return err;
transcript_.update(data.subspan(sizeof(hdr->handshake)));
run_deferred_action();
return 0;
}
auto auth::run_deferred_action() -> void
{
auto action = deferred_action_;
deferred_action_ = deferred_action::none;
switch (action) {
case deferred_action::exchange_rsa:
exchange_rsa();
break;
case deferred_action::exchange_ecdh:
exchange_ecdh();
break;
case deferred_action::complete:
complete_handshake();
break;
case deferred_action::none:
break;
}
}
auto auth::dispatch_pkt(u8 cmd, std::span<u8 const> data) -> int
{
switch (cmd) {
@@ -420,7 +441,7 @@ auto auth::handle_certificate(std::span<u8 const> data) -> int
return -EINVAL;
std::memcpy(pubkey_client_.data(), data.data() + i, k_pubkey_len);
exchange_rsa();
deferred_action_ = deferred_action::exchange_rsa;
return 0;
}
@@ -443,7 +464,7 @@ auto auth::handle_finish(std::span<u8 const> data) -> int
return -EPROTO;
}
complete_handshake();
deferred_action_ = deferred_action::complete;
return 0;
}
@@ -488,7 +509,7 @@ auto auth::handle_pubkey(std::span<u8 const> data) -> int
return -EINVAL;
std::memcpy(pubkey_client2_.data(), pkt->pubkey.data(), k_pubkey2_len);
exchange_ecdh();
deferred_action_ = deferred_action::exchange_ecdh;
return 0;
}