aboutsummaryrefslogtreecommitdiff
path: root/src/ext_packet.h
blob: c6c77c41ccdbfccc14a584d21a02f3c85eca4294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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);