From 6c30e71ed08cdb838b77b3fe52dea30774574230 Mon Sep 17 00:00:00 2001 From: Osmium Sorcerer Date: Sun, 22 Mar 2026 18:16:52 +0000 Subject: Add the extension packets Introduce the subprotocol ("Einsof"), its prototype serialization and parsing functions, and its first set of messages. These messages are carriers of public-key authentication mechanism which involves client request, server challenge, and client response. An "ident" message is used to tell a compatible server that you support a particular version of the subprotocol. Note: the functions that handle encoding are very specialized. They're not representative of how the wire format should be generally handled, and were written this way because the first set of messages is tiny and simple enough. --- src/ext_packet.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/ext_packet.h (limited to 'src/ext_packet.h') diff --git a/src/ext_packet.h b/src/ext_packet.h new file mode 100644 index 0000000..c6c77c4 --- /dev/null +++ b/src/ext_packet.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +enum class ExMsgType : quint8 +{ + ident = 1, + auth_request = 2, + auth_challenge = 3, + auth_response = 4 +}; + +struct ExMessage +{ + ExMsgType type; + QByteArray body; +}; + +enum class AuthMethod +{ + certificate = 1, + password = 2, +}; + +struct Ident +{ + quint8 version; +}; + +struct AuthRequest +{ + QString username; + AuthMethod method; + // Will be replaced if passwords are implemented. + QByteArray credentials; +}; + +struct AuthChallenge +{ + QByteArray challenge; +}; + +struct AuthResponse +{ + QByteArray response; +}; + +QByteArray serializeIdent(const Ident &m); +QByteArray serializeAuthRequest(const AuthRequest &m); +QByteArray serializeAuthResponse(const AuthResponse &m); + +bool parseAuthChallenge(QByteArrayView in, AuthChallenge &out); -- cgit