summaryrefslogtreecommitdiffstats
path: root/libvncclient/rfbproto.c
diff options
context:
space:
mode:
authorVic Lee <llyzs@163.com>2009-10-02 20:42:05 +0800
committerJohannes Schindelin <johannes.schindelin@gmx.de>2009-10-02 16:55:58 +0200
commit95ae56c83110c35bce9752d18975b6edcd8088b9 (patch)
tree89f2f133c19e54d3eeae36a4ef404176286576d8 /libvncclient/rfbproto.c
parent68964c29d97b9b9d9d5bfbe685eb05c3c17c5fd1 (diff)
downloadlibtdevnc-95ae56c83110c35bce9752d18975b6edcd8088b9.tar.gz
libtdevnc-95ae56c83110c35bce9752d18975b6edcd8088b9.zip
Add VeNCrypt support in libvncclient
Signed-off-by: Vic Lee <llyzs@163.com>
Diffstat (limited to 'libvncclient/rfbproto.c')
-rw-r--r--libvncclient/rfbproto.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
index 1a71f4f..497facb 100644
--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -504,7 +504,7 @@ ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
rfbClientLog("%d) Received security type %d\n", loop, tAuth[loop]);
if (flag) continue;
if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth ||
- (!subAuth && tAuth[loop]==rfbTLS))
+ (!subAuth && (tAuth[loop]==rfbTLS || tAuth[loop]==rfbVeNCrypt)))
{
flag++;
authScheme=tAuth[loop];
@@ -569,6 +569,50 @@ HandleVncAuth(rfbClient *client)
return TRUE;
}
+static rfbBool
+HandlePlainAuth(rfbClient *client)
+{
+ uint32_t ulen, ulensw;
+ uint32_t plen, plensw;
+ rfbCredential *cred;
+
+ if (!client->GetCredential)
+ {
+ rfbClientLog("GetCredential callback is not set.\n");
+ return FALSE;
+ }
+ cred = client->GetCredential(client, rfbCredentialTypeUser);
+ if (!cred)
+ {
+ rfbClientLog("Reading credential failed\n");
+ return FALSE;
+ }
+
+ ulen = (cred->userCredential.username ? strlen(cred->userCredential.username) : 0);
+ ulensw = rfbClientSwap32IfLE(ulen);
+ plen = (cred->userCredential.password ? strlen(cred->userCredential.password) : 0);
+ plensw = rfbClientSwap32IfLE(plen);
+ if (!WriteToRFBServer(client, (char *)&ulensw, 4)) return FALSE;
+ if (!WriteToRFBServer(client, (char *)&plensw, 4)) return FALSE;
+ if (ulen > 0)
+ {
+ if (!WriteToRFBServer(client, cred->userCredential.username, ulen)) return FALSE;
+ }
+ if (plen > 0)
+ {
+ if (!WriteToRFBServer(client, cred->userCredential.password, plen)) return FALSE;
+ }
+
+ if (cred->userCredential.username) free(cred->userCredential.username);
+ if (cred->userCredential.password) free(cred->userCredential.password);
+ free(cred);
+
+ /* Handle the SecurityResult message */
+ if (!rfbHandleAuthResult(client)) return FALSE;
+
+ return TRUE;
+}
+
/*
* InitialiseRFBConnection.
*/
@@ -700,6 +744,35 @@ InitialiseRFBConnection(rfbClient* client)
break;
+ case rfbVeNCrypt:
+ if (!HandleVeNCryptAuth(client)) return FALSE;
+
+ switch (client->subAuthScheme) {
+
+ case rfbVeNCryptTLSNone:
+ case rfbVeNCryptX509None:
+ rfbClientLog("No sub authentication needed\n");
+ if (!rfbHandleAuthResult(client)) return FALSE;
+ break;
+
+ case rfbVeNCryptTLSVNC:
+ case rfbVeNCryptX509VNC:
+ if (!HandleVncAuth(client)) return FALSE;
+ break;
+
+ case rfbVeNCryptTLSPlain:
+ case rfbVeNCryptX509Plain:
+ if (!HandlePlainAuth(client)) return FALSE;
+ break;
+
+ default:
+ rfbClientLog("Unknown sub authentication scheme from VNC server: %d\n",
+ client->subAuthScheme);
+ return FALSE;
+ }
+
+ break;
+
default:
rfbClientLog("Unknown authentication scheme from VNC server: %d\n",
(int)authScheme);