int close_on_exit;
/* SSH options */
int nopty;
- enum { CIPHER_3DES, CIPHER_BLOWFISH } cipher;
+ enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
/* Telnet options */
char termtype[32];
char termspeed[32];
s_write(pktout.data, biglen+4);
}
+static int ssh_versioncmp(char *a, char *b) {
+ char *ae, *be;
+ unsigned long av, bv;
+
+ av = strtoul(a, &ae);
+ bv = strtoul(b, &be);
+ if (av != bv) return (av < bv ? -1 : +1);
+ if (*ae == '.') ae++;
+ if (*be == '.') be++;
+ av = strtoul(ae, &ae);
+ bv = strtoul(be, &be);
+ if (av != bv) return (av < bv ? -1 : +1);
+ return 0;
+}
+
static int do_ssh_init(void) {
char c;
char version[10];
break;
}
- sprintf(vstring, "SSH-%s-7.7.7\n",
- (strcmp(version, "1.5") <= 0 ? version : "1.5"));
+ sprintf(vstring, "SSH-%s-PuTTY\n",
+ (ssh_versioncmp(version, "1.5") <= 0 ? version : "1.5"));
s_write(vstring, strlen(vstring));
return 1;
}
int cipher_type;
extern struct ssh_cipher ssh_3des;
+ extern struct ssh_cipher ssh_des;
extern struct ssh_cipher ssh_blowfish;
crBegin;
}
cipher_type = cfg.cipher == CIPHER_BLOWFISH ? SSH_CIPHER_BLOWFISH :
+ cfg.cipher == CIPHER_DES ? SSH_CIPHER_DES :
SSH_CIPHER_3DES;
if ((supported_ciphers_mask & (1 << cipher_type)) == 0) {
c_write("Selected cipher not supported, falling back to 3DES\r\n", 53);
free(rsabuf);
cipher = cipher_type == SSH_CIPHER_BLOWFISH ? &ssh_blowfish :
+ cipher_type == SSH_CIPHER_DES ? &ssh_des :
&ssh_3des;
cipher->sesskey(session_key);
#include <string.h>
#define SSH_CIPHER_IDEA 1
+#define SSH_CIPHER_DES 2
#define SSH_CIPHER_3DES 3
#define SSH_CIPHER_BLOWFISH 6
des3_decrypt_blk
};
+static void des_sesskey(unsigned char *key) {
+ des_set_key(key, &ekey1);
+ memset(eiv1, 0, sizeof(eiv1));
+ des_set_key(key, &dkey1);
+ memset(div1, 0, sizeof(div1));
+}
+
+static void des_encrypt_blk(unsigned char *blk, int len) {
+ des_cbc_encrypt(&ekey1, eiv1, blk, blk, len);
+}
+
+static void des_decrypt_blk(unsigned char *blk, int len) {
+ des_cbc_decrypt(&dkey1, div1, blk, blk, len);
+}
+
+struct ssh_cipher ssh_des = {
+ des_sesskey,
+ des_encrypt_blk,
+ des_decrypt_blk
+};
+
#ifdef DES_TEST
void des_encrypt_buf(DESContext *ks, unsigned char *out,
#define IDC3_CIPHERSTATIC 1019
#define IDC3_CIPHER3DES 1020
#define IDC3_CIPHERBLOWF 1021
+#define IDC3_CIPHERDES 1022
#define IDC4_MBSTATIC 1001
#define IDC4_MBWINDOWS 1002
LTEXT "Cipher:", IDC3_CIPHERSTATIC, 3, 50, 40, 8
AUTORADIOBUTTON "&3DES", IDC3_CIPHER3DES, 46, 50, 35, 10, WS_GROUP
AUTORADIOBUTTON "&Blowfish", IDC3_CIPHERBLOWF, 84, 50, 40, 10
+ AUTORADIOBUTTON "&DES", IDC3_CIPHERDES, 127, 50, 30, 10
END
IDD_PANEL4 DIALOG DISCARDABLE 6, 30, 168, 163
wpps (sesskey, "UserName", cfg.username);
wppi (sesskey, "NoPTY", cfg.nopty);
wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
- "3des");
+ cfg.cipher == CIPHER_DES ? "des" : "3des");
wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
gpps (sesskey, "Cipher", "3des", cipher, 10);
if (!strcmp(cipher, "blowfish"))
cfg.cipher = CIPHER_BLOWFISH;
+ else if (!strcmp(cipher, "des"))
+ cfg.cipher = CIPHER_DES;
else
cfg.cipher = CIPHER_3DES;
}
SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
- CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERBLOWF,
+ CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERDES,
cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF :
+ cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES :
+
IDC3_CIPHER3DES);
break;
case WM_COMMAND:
break;
case IDC3_CIPHER3DES:
case IDC3_CIPHERBLOWF:
+ case IDC3_CIPHERDES:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES))
cfg.cipher = CIPHER_3DES;
else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF))
cfg.cipher = CIPHER_BLOWFISH;
+ else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERDES))
+ cfg.cipher = CIPHER_DES;
}
break;
}