Update of /cvsroot/gqclient/gq/src
In directory sc8-pr-cvs1:/tmp/cvs-serv32616
Modified Files:
formfill.h dt_password.c
Log Message:
* Added Lanman Hash to the list of hashing algorithms (Just for completeness)
* The combo box now can be focused
Index: formfill.h
===================================================================
RCS file: /cvsroot/gqclient/gq/src/formfill.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** formfill.h 21 Oct 2003 04:46:41 -0000 1.27
--- formfill.h 27 Oct 2003 22:08:03 -0000 1.28
***************
*** 78,81 ****
--- 78,82 ----
#define FLAG_ENCODE_SSHA 0x50
#define FLAG_ENCODE_NTHASH 0x60
+ #define FLAG_ENCODE_LMHASH 0x70
#define ENCODING_MASK ( FLAG_ENCODE_CRYPT | FLAG_ENCODE_MD5 | FLAG_ENCODE_SHA )
Index: dt_password.c
===================================================================
RCS file: /cvsroot/gqclient/gq/src/dt_password.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** dt_password.c 18 Oct 2003 08:26:59 -0000 1.19
--- dt_password.c 27 Oct 2003 22:08:03 -0000 1.20
***************
*** 34,37 ****
--- 34,38 ----
#include <fcntl.h>
#include <unistd.h>
+ #include <ctype.h>
#include <glib.h>
***************
*** 64,67 ****
--- 65,72 ----
#if defined(HAVE_LIBCRYPTO)
+
+
+ /* NOTE: The password-hash generating functions may change the data
+ in-place. They are explicitly permitted to do so. */
static GByteArray *dt_password_encode_password_crypt(char *data, int len);
static GByteArray *dt_password_encode_password_md5(char *data, int len);
***************
*** 70,73 ****
--- 75,79 ----
static GByteArray *dt_password_encode_password_smd5(char *data, int len);
static GByteArray *dt_password_encode_password_nthash(char *data, int len);
+ static GByteArray *dt_password_encode_password_lmhash(char *data, int len);
typedef GByteArray *(CryptFunc)(char *data, int len);
***************
*** 85,88 ****
--- 91,95 ----
{ FLAG_ENCODE_SHA, "SHA", dt_password_encode_password_sha1 },
{ FLAG_ENCODE_NTHASH, "NTHASH", dt_password_encode_password_nthash },
+ { FLAG_ENCODE_LMHASH, "LMHASH", dt_password_encode_password_lmhash },
#endif
{ 0, "", NULL },
***************
*** 305,308 ****
--- 312,372 ----
+ /* FIXME: silently assumes US-ASCII (or a single-byte encoding to be
+ handled by toupper) */
+
+ static des_cblock *lm_make_key(const char *pw, des_cblock *key)
+ {
+ int i;
+ char *k = (char *) key;
+
+ k[0] = 0;
+ for ( i = 0 ; i < 7 ; i++ ) {
+ k[i] |= (pw[i] >> i) & 0xff;
+ k[i+1] = (pw[i] << (7 - i)) & 0xff;
+ }
+
+ des_set_odd_parity(key);
+ }
+
+ static const char *lmhash_key = "KGS!@#$%";
+ static GByteArray *dt_password_encode_password_lmhash(char *data, int len)
+ {
+ int i;
+ char hex[2];
+ char plain[15];
+ des_key_schedule schedule;
+ GByteArray *gb = NULL;
+ des_cblock ckey1, ckey2;
+ des_cblock bin1, bin2;
+
+ memset(plain, 0, sizeof(plain));
+
+ for (i = 0 ; i < len && i < 14 ; i++) {
+ plain[i] = toupper(data[i]);
+ }
+
+ lm_make_key(plain, &ckey1);
+ des_set_key_unchecked(&ckey1, schedule);
+ des_ecb_encrypt((des_cblock*)lmhash_key, &bin1, schedule, DES_ENCRYPT);
+
+ lm_make_key(plain + 7, &ckey2);
+ des_set_key_unchecked(&ckey2, schedule);
+ des_ecb_encrypt((des_cblock*)lmhash_key, &bin2, schedule, DES_ENCRYPT);
+
+ gb = g_byte_array_new();
+
+ for(i = 0 ; i < sizeof(bin1) ; i++) {
+ hex[0] = hexdigit[bin1[i] / 16];
+ hex[1] = hexdigit[bin1[i] % 16];
+ g_byte_array_append(gb, hex, 2);
+ }
+ for(i = 0 ; i < sizeof(bin2) ; i++) {
+ hex[0] = hexdigit[bin2[i] / 16];
+ hex[1] = hexdigit[bin2[i] % 16];
+ g_byte_array_append(gb, hex, 2);
+ }
+ return gb;
+ }
+
#endif /* HAVE_LIBCRYPTO */
***************
*** 336,340 ****
--- 400,408 ----
combo = gtk_combo_new();
+ #ifdef OLD_FOCUS_HANDLING
GTK_WIDGET_UNSET_FLAGS(GTK_COMBO(combo)->entry, GTK_CAN_FOCUS);
+ #endif
+ gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), FALSE);
+
style = gtk_widget_get_style(GTK_COMBO(combo)->entry);
***************
*** 422,425 ****
--- 490,495 ----
if (cryptfunc != NULL) {
GByteArray *crypted = cryptfunc(data->data, data->len);
+ /* overwrite plain-text */
+ memset(data->data, 0, data->len);
g_byte_array_free(data, TRUE);
data = crypted;
|