diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-03-22 18:16:52 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-03-29 22:22:25 +0000 |
| commit | 6c30e71ed08cdb838b77b3fe52dea30774574230 (patch) | |
| tree | 9620ee98a417f82f29c7ae101de0b021720c3612 /src/ext_packet.h | |
| parent | ade040cfa6c402bb336e7772de5e675549ded18e (diff) | |
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.
Diffstat (limited to 'src/ext_packet.h')
| -rw-r--r-- | src/ext_packet.h | 53 |
1 files changed, 53 insertions, 0 deletions
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 <QByteArray> +#include <QString> + +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); |
