aboutsummaryrefslogtreecommitdiff
path: root/src/ext_packet.h
blob: 2697217be62a346e53db60c7c25b84cecddad8d4 (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
54
55
56
57
58
59
#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;
};

enum class CertVariant
{
  software,
  hardware,
};

struct AuthRequest
{
  QString username;
  AuthMethod method;
  // Added as an extension. To be reimplemented in version 3.
  CertVariant variant;
};

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);