Check protocol compatibility on handshake

This commit is contained in:
Patrick Nicolas
2025-06-17 09:31:30 +02:00
parent 7e3b6d001e
commit 169e8bf206
3 changed files with 18 additions and 2 deletions
+9
View File
@@ -19,6 +19,7 @@
#include "wivrn_connection.h"
#include "configuration.h"
#include "protocol_version.h"
#include "secrets.h"
#include "smp.h"
#include "wivrn_ipc.h"
@@ -169,6 +170,14 @@ void wivrn::wivrn_connection::init(std::stop_token stop_token, std::function<voi
// Wait for client to send handshake packet
auto crypto_handshake = std::get<from_headset::crypto_handshake>(receive(10s).first);
if (crypto_handshake.protocol_version != wivrn::protocol_version)
{
control.send(to_headset::crypto_handshake{
.state = to_headset::crypto_handshake::crypto_state::incompatible_version,
});
throw std::runtime_error("Incompatible protocol version");
}
crypto::key headset_key = crypto::key::from_public_key(crypto_handshake.public_key);
bool is_public_key_known = std::ranges::any_of(
wivrn::known_keys(),