diff options
Diffstat (limited to 'vnc')
-rw-r--r-- | vnc/vnc.c | 67 | ||||
-rw-r--r-- | vnc/vnc.h | 2 |
2 files changed, 52 insertions, 17 deletions
@@ -49,15 +49,37 @@ lib_send_copy(struct vnc *v, struct stream *s) /******************************************************************************/ /* taken from vncauth.c */ -void DEFAULT_CC -rfbEncryptBytes(char *bytes, char *passwd) +/* performing the des3 crypt on the password so it can not be seen + on the wire + 'bytes' in, contains 16 bytes server random + out, random and 'passwd' conbined */ +static void APP_CC +rfbEncryptBytes(char *bytes, const char *passwd) { char key[24]; + void *des; + int len; + + /* key is simply password padded with nulls */ + g_memset(key, 0, sizeof(key)); + len = MIN(g_strlen(passwd), 8); + g_mirror_memcpy(key, passwd, len); + des = ssl_des3_encrypt_info_create(key, 0); + ssl_des3_encrypt(des, 8, bytes, bytes); + ssl_des3_info_delete(des); + des = ssl_des3_encrypt_info_create(key, 0); + ssl_des3_encrypt(des, 8, bytes + 8, bytes + 8); + ssl_des3_info_delete(des); +} + +/******************************************************************************/ +/* sha1 hash 'passwd', create a string from the hash and call rfbEncryptBytes */ +static void APP_CC +rfbHashEncryptBytes(char *bytes, const char *passwd) +{ char passwd_hash[20]; char passwd_hash_text[40]; - void *des; void *sha1; - int len; int passwd_bytes; /* create password hash from password */ @@ -72,18 +94,7 @@ rfbEncryptBytes(char *bytes, char *passwd) (tui8)passwd_hash[0], (tui8)passwd_hash[1], (tui8)passwd_hash[2], (tui8)passwd_hash[3]); passwd_hash_text[39] = 0; - passwd = passwd_hash_text; - - /* key is simply password padded with nulls */ - g_memset(key, 0, sizeof(key)); - len = MIN(g_strlen(passwd), 8); - g_mirror_memcpy(key, passwd, len); - des = ssl_des3_encrypt_info_create(key, 0); - ssl_des3_encrypt(des, 8, bytes, bytes); - ssl_des3_info_delete(des); - des = ssl_des3_encrypt_info_create(key, 0); - ssl_des3_encrypt(des, 8, bytes + 8, bytes + 8); - ssl_des3_info_delete(des); + rfbEncryptBytes(bytes, passwd_hash_text); } /******************************************************************************/ @@ -1083,7 +1094,24 @@ lib_mod_connect(struct vnc *v) if (error == 0) { init_stream(s, 8192); - rfbEncryptBytes(s->data, v->password); + if (v->got_guid) + { + char guid_str[64]; + char *pguid_str; + int index; + pguid_str = guid_str; + for (index = 0; index < 16; index++) + { + g_snprintf(pguid_str, 4, "%2.2x", v->guid[index]); + pguid_str += 2; + } + guid_str[32] = 0; + rfbHashEncryptBytes(s->data, guid_str); + } + else + { + rfbEncryptBytes(s->data, v->password); + } s->p += 16; s_mark_end(s); error = trans_force_write_s(v->trans, s); @@ -1422,6 +1450,11 @@ lib_mod_set_param(struct vnc *v, const char *name, char *value) { v->delay_ms = g_atoi(value); } + else if (g_strcasecmp(name, "guid") == 0) + { + v->got_guid = 1; + g_memcpy(v->guid, value, 16); + } return 0; } @@ -114,4 +114,6 @@ struct vnc struct stream *clip_data_s; int delay_ms; struct trans *trans; + int got_guid; + tui8 guid[16]; }; |