mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Single-DES encryption, patch courtesy of Murphy Lam
[originally from svn r253]
This commit is contained in:
parent
2da19fc59d
commit
2d6fcb0a7a
2
putty.h
2
putty.h
@ -97,7 +97,7 @@ typedef struct {
|
|||||||
int close_on_exit;
|
int close_on_exit;
|
||||||
/* SSH options */
|
/* SSH options */
|
||||||
int nopty;
|
int nopty;
|
||||||
enum { CIPHER_3DES, CIPHER_BLOWFISH } cipher;
|
enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
|
||||||
/* Telnet options */
|
/* Telnet options */
|
||||||
char termtype[32];
|
char termtype[32];
|
||||||
char termspeed[32];
|
char termspeed[32];
|
||||||
|
22
ssh.c
22
ssh.c
@ -213,6 +213,21 @@ static void s_wrpkt(void) {
|
|||||||
s_write(pktout.data, biglen+4);
|
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) {
|
static int do_ssh_init(void) {
|
||||||
char c;
|
char c;
|
||||||
char version[10];
|
char version[10];
|
||||||
@ -248,8 +263,8 @@ static int do_ssh_init(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(vstring, "SSH-%s-7.7.7\n",
|
sprintf(vstring, "SSH-%s-PuTTY\n",
|
||||||
(strcmp(version, "1.5") <= 0 ? version : "1.5"));
|
(ssh_versioncmp(version, "1.5") <= 0 ? version : "1.5"));
|
||||||
s_write(vstring, strlen(vstring));
|
s_write(vstring, strlen(vstring));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -265,6 +280,7 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
|
|||||||
int cipher_type;
|
int cipher_type;
|
||||||
|
|
||||||
extern struct ssh_cipher ssh_3des;
|
extern struct ssh_cipher ssh_3des;
|
||||||
|
extern struct ssh_cipher ssh_des;
|
||||||
extern struct ssh_cipher ssh_blowfish;
|
extern struct ssh_cipher ssh_blowfish;
|
||||||
|
|
||||||
crBegin;
|
crBegin;
|
||||||
@ -322,6 +338,7 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cipher_type = cfg.cipher == CIPHER_BLOWFISH ? SSH_CIPHER_BLOWFISH :
|
cipher_type = cfg.cipher == CIPHER_BLOWFISH ? SSH_CIPHER_BLOWFISH :
|
||||||
|
cfg.cipher == CIPHER_DES ? SSH_CIPHER_DES :
|
||||||
SSH_CIPHER_3DES;
|
SSH_CIPHER_3DES;
|
||||||
if ((supported_ciphers_mask & (1 << cipher_type)) == 0) {
|
if ((supported_ciphers_mask & (1 << cipher_type)) == 0) {
|
||||||
c_write("Selected cipher not supported, falling back to 3DES\r\n", 53);
|
c_write("Selected cipher not supported, falling back to 3DES\r\n", 53);
|
||||||
@ -341,6 +358,7 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
|
|||||||
free(rsabuf);
|
free(rsabuf);
|
||||||
|
|
||||||
cipher = cipher_type == SSH_CIPHER_BLOWFISH ? &ssh_blowfish :
|
cipher = cipher_type == SSH_CIPHER_BLOWFISH ? &ssh_blowfish :
|
||||||
|
cipher_type == SSH_CIPHER_DES ? &ssh_des :
|
||||||
&ssh_3des;
|
&ssh_3des;
|
||||||
cipher->sesskey(session_key);
|
cipher->sesskey(session_key);
|
||||||
|
|
||||||
|
1
ssh.h
1
ssh.h
@ -1,6 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define SSH_CIPHER_IDEA 1
|
#define SSH_CIPHER_IDEA 1
|
||||||
|
#define SSH_CIPHER_DES 2
|
||||||
#define SSH_CIPHER_3DES 3
|
#define SSH_CIPHER_3DES 3
|
||||||
#define SSH_CIPHER_BLOWFISH 6
|
#define SSH_CIPHER_BLOWFISH 6
|
||||||
|
|
||||||
|
21
sshdes.c
21
sshdes.c
@ -673,6 +673,27 @@ struct ssh_cipher ssh_3des = {
|
|||||||
des3_decrypt_blk
|
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
|
#ifdef DES_TEST
|
||||||
|
|
||||||
void des_encrypt_buf(DESContext *ks, unsigned char *out,
|
void des_encrypt_buf(DESContext *ks, unsigned char *out,
|
||||||
|
@ -99,6 +99,7 @@
|
|||||||
#define IDC3_CIPHERSTATIC 1019
|
#define IDC3_CIPHERSTATIC 1019
|
||||||
#define IDC3_CIPHER3DES 1020
|
#define IDC3_CIPHER3DES 1020
|
||||||
#define IDC3_CIPHERBLOWF 1021
|
#define IDC3_CIPHERBLOWF 1021
|
||||||
|
#define IDC3_CIPHERDES 1022
|
||||||
|
|
||||||
#define IDC4_MBSTATIC 1001
|
#define IDC4_MBSTATIC 1001
|
||||||
#define IDC4_MBWINDOWS 1002
|
#define IDC4_MBWINDOWS 1002
|
||||||
|
@ -163,6 +163,7 @@ BEGIN
|
|||||||
LTEXT "Cipher:", IDC3_CIPHERSTATIC, 3, 50, 40, 8
|
LTEXT "Cipher:", IDC3_CIPHERSTATIC, 3, 50, 40, 8
|
||||||
AUTORADIOBUTTON "&3DES", IDC3_CIPHER3DES, 46, 50, 35, 10, WS_GROUP
|
AUTORADIOBUTTON "&3DES", IDC3_CIPHER3DES, 46, 50, 35, 10, WS_GROUP
|
||||||
AUTORADIOBUTTON "&Blowfish", IDC3_CIPHERBLOWF, 84, 50, 40, 10
|
AUTORADIOBUTTON "&Blowfish", IDC3_CIPHERBLOWF, 84, 50, 40, 10
|
||||||
|
AUTORADIOBUTTON "&DES", IDC3_CIPHERDES, 127, 50, 30, 10
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_PANEL4 DIALOG DISCARDABLE 6, 30, 168, 163
|
IDD_PANEL4 DIALOG DISCARDABLE 6, 30, 168, 163
|
||||||
|
11
windlg.c
11
windlg.c
@ -148,7 +148,7 @@ static void save_settings (char *section, int do_host) {
|
|||||||
wpps (sesskey, "UserName", cfg.username);
|
wpps (sesskey, "UserName", cfg.username);
|
||||||
wppi (sesskey, "NoPTY", cfg.nopty);
|
wppi (sesskey, "NoPTY", cfg.nopty);
|
||||||
wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
|
wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
|
||||||
"3des");
|
cfg.cipher == CIPHER_DES ? "des" : "3des");
|
||||||
wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
|
wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
|
||||||
wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
|
wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
|
||||||
wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
|
wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
|
||||||
@ -270,6 +270,8 @@ static void load_settings (char *section, int do_host) {
|
|||||||
gpps (sesskey, "Cipher", "3des", cipher, 10);
|
gpps (sesskey, "Cipher", "3des", cipher, 10);
|
||||||
if (!strcmp(cipher, "blowfish"))
|
if (!strcmp(cipher, "blowfish"))
|
||||||
cfg.cipher = CIPHER_BLOWFISH;
|
cfg.cipher = CIPHER_BLOWFISH;
|
||||||
|
else if (!strcmp(cipher, "des"))
|
||||||
|
cfg.cipher = CIPHER_DES;
|
||||||
else
|
else
|
||||||
cfg.cipher = CIPHER_3DES;
|
cfg.cipher = CIPHER_3DES;
|
||||||
}
|
}
|
||||||
@ -874,8 +876,10 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
|
|||||||
SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
|
SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
|
||||||
SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
|
SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
|
||||||
CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
|
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_BLOWFISH ? IDC3_CIPHERBLOWF :
|
||||||
|
cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES :
|
||||||
|
|
||||||
IDC3_CIPHER3DES);
|
IDC3_CIPHER3DES);
|
||||||
break;
|
break;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
@ -897,12 +901,15 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
|
|||||||
break;
|
break;
|
||||||
case IDC3_CIPHER3DES:
|
case IDC3_CIPHER3DES:
|
||||||
case IDC3_CIPHERBLOWF:
|
case IDC3_CIPHERBLOWF:
|
||||||
|
case IDC3_CIPHERDES:
|
||||||
if (HIWORD(wParam) == BN_CLICKED ||
|
if (HIWORD(wParam) == BN_CLICKED ||
|
||||||
HIWORD(wParam) == BN_DOUBLECLICKED) {
|
HIWORD(wParam) == BN_DOUBLECLICKED) {
|
||||||
if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES))
|
if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES))
|
||||||
cfg.cipher = CIPHER_3DES;
|
cfg.cipher = CIPHER_3DES;
|
||||||
else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF))
|
else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF))
|
||||||
cfg.cipher = CIPHER_BLOWFISH;
|
cfg.cipher = CIPHER_BLOWFISH;
|
||||||
|
else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERDES))
|
||||||
|
cfg.cipher = CIPHER_DES;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user