aboutsummaryrefslogtreecommitdiff
path: root/src/ext_packet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext_packet.cpp')
-rw-r--r--src/ext_packet.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/ext_packet.cpp b/src/ext_packet.cpp
index 76ac492..06cce91 100644
--- a/src/ext_packet.cpp
+++ b/src/ext_packet.cpp
@@ -17,11 +17,16 @@ QByteArray serializeIdent(const Ident &m)
QByteArray serializeAuthRequest(const AuthRequest &m)
{
+ quint32 extended_method = (quint32)m.method;
+ if (m.variant == CertVariant::hardware)
+ {
+ extended_method = 4;
+ }
QByteArray msg;
const QByteArray username = m.username.toUtf8();
uint8_t method[sizeof(quint32) + 1];
uint8_t ulen[sizeof(quint32) + 1];
- size_t method_n = vli32_encode(method, (quint32)m.method);
+ size_t method_n = vli32_encode(method, extended_method);
size_t ulen_n = vli32_encode(ulen, username.size());
msg.reserve(2 + ulen_n + username.size() + method_n);
msg.append((char)ExMsgType::auth_request);
@@ -44,10 +49,26 @@ QByteArray serializeAuthResponse(const AuthResponse &m)
bool parseAuthChallenge(QByteArrayView in, AuthChallenge &out)
{
- if (in.size() < 1 + 32)
+ if (in.size() < 1)
{
return false;
}
- out.challenge = QByteArray(in.constData() + 1, 32);
- return true;
+ switch ((uchar)in.at(0)) {
+ case 0x00:
+ if (in.size() < 32 + 1)
+ {
+ return false;
+ }
+ out.challenge = QByteArray(in.constData() + 1, 32);
+ return true;
+ case 0x80:
+ if (in.size() < 64 + 1)
+ {
+ return false;
+ }
+ out.challenge = QByteArray(in.constData() + 1, 64);
+ return true;
+ default:
+ return false;
+ }
}