Commit 241eb055 authored by Paul Tvete's avatar Paul Tvete
Browse files

Refactored VeNCrypt (still not finished)

parent 1b0e201c
......@@ -647,7 +647,100 @@ public:
private:
QByteArray m_randomChallenge;
};
#endif
#endif // QT_VNC_AUTH
class QVeNCryptSecurity : public QVncSecurity
{
public:
QVeNCryptSecurity(QVncClient *client)
: QVncSecurity(client)
{
char version[] = {0, 2};
m_client->clientSocket()->write(version, sizeof(version));
m_state = State::Pending;
m_bytesToRead = 2; // Waiting for client's supported version
subState = Version;
}
void process(QTcpSocket *socket) override {
Q_ASSERT(socket->bytesAvailable() >= m_bytesToRead);
m_bytesToRead = 0;
switch (subState) {
case Start:
qWarning("This should not happen");
m_state = State::AuthFailure;
break;
case Version:
{
char version[2];
socket->read(version, 2);
qDebug() << "VeNCrypt version" << uint(version[0]) << uint(version[1]);
bool versionSupported = version[0] == 0 && version[1] >= 2;
char response = versionSupported ? 0 : 1; // 0 success, 1 failure
socket->write(&response, 1);
qDebug() << "Supported?" << uint(response);
if (!versionSupported) {
m_state = State::AuthFailure;
return;
}
const quint32 subtypes[] = {
//VenCryptPlain,
htonl(QVncClient::VenCryptTLSPlain),
htonl(QVncClient::VenCryptTLSVnc),
htonl(QVncClient::VenCryptTLSNone),
htonl(QVncClient::SecurityVncAuthentication) // #### TESTING
// VenCryptX509None,
// VenCryptX509Vnc,
// VenCryptX509Plain,
// VenCryptTLSSASL,
// VenCryptX509SASL
};
const char size = sizeof(subtypes) / sizeof(quint32);
socket->write(&size, 1);
socket->write(reinterpret_cast<const char*>(subtypes), sizeof(subtypes));
qDebug() << "Wrote size:" << uint(size) << "bytes:" << sizeof(subtypes);
qDebug() << "bytes available" << socket->bytesAvailable();
m_state = State::Pending;
m_bytesToRead = 4;
subState = SubType;
break;
}
case SubType:
{
quint32 subtype;
socket->read(reinterpret_cast<char *>(&subtype), sizeof(subtype));
qDebug() << "Got VenCrypt subtype" << ntohl(subtype);
// just give up now, since we don't actually support anything yet
const char response = 0; //1 success, because why be consistent? Everything else failure
socket->write(&response, 1);
m_state = State::AuthFailure;
break;
}
}
}
private:
enum SubState {
Start,
Version,
SubType
};
SubState subState = Start;
};
void QVncClient::readClient()
{
......@@ -727,7 +820,10 @@ void QVncClient::readClient()
#ifdef QT_VNC_AUTH
case SecurityVncAuthentication:
m_security = new QVncAutenticationSecurity(this);
break;
#endif
case SecurityVeNCrypt:
m_security = new QVeNCryptSecurity(this);
default:
break;
}
......
......@@ -94,6 +94,35 @@ public:
V3_8
};
enum VeNCryptSecurityType : quint32 {
VenCryptPlain = 256, // Do not use
VenCryptTLSNone = 257,
VenCryptTLSVnc = 258,
VenCryptTLSPlain = 259,
VenCryptX509None = 260,
VenCryptX509Vnc = 261,
VenCryptX509Plain = 262,
VenCryptTLSSASL = 263,
VenCryptX509SASL = 264
};
enum SecurityType : uchar {
SecurityInvalid = 0,
SecurityNone = 1,
SecurityVncAuthentication = 2,
SecurityRsaAes = 5,
SecurityRsaAesUnencrypted = 6,
SecurityRsaAesTwoStep = 13,
SecurityTight = 16,
SecurityVeNCrypt = 19,
SecurityXvp = 22,
SecurityDiffieHellman = 30,
SecurityRsaAes256 = 129,
SecurityRsaAes256Unencrypted = 130,
SecurityRsaAes256TwoStep = 133
};
class DirtyMap;
explicit QVncClient(QVncServer *server);
......@@ -178,34 +207,6 @@ private:
Connected
};
enum VeNCryptSecurity : quint32 {
VenCryptPlain = 256,
VenCryptTLSNone = 257,
VenCryptTLSVnc = 258,
VenCryptTLSPlain = 259,
VenCryptX509None = 260,
VenCryptX509Vnc = 261,
VenCryptX509Plain = 262,
VenCryptTLSSASL = 263,
VenCryptX509SASL = 264
};
enum SecurityType : uchar {
SecurityInvalid = 0,
SecurityNone = 1,
SecurityVncAuthentication = 2,
SecurityRsaAes = 5,
SecurityRsaAesUnencrypted = 6,
SecurityRsaAesTwoStep = 13,
SecurityTight = 16,
SecurityVeNCrypt = 19,
SecurityXvp = 22,
SecurityDiffieHellman = 30,
SecurityRsaAes256 = 129,
SecurityRsaAes256Unencrypted = 130,
SecurityRsaAes256TwoStep = 133
};
void setPixelFormat();
void setEncodings();
void frameBufferUpdateRequest();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment