diff -Nrup filezilla-3.31.0/src/putty/import.c filezilla-3.41.2/src/putty/import.c --- filezilla-3.31.0/src/putty/import.c 2017-07-16 12:29:48.000000000 +0200 +++ filezilla-3.41.2/src/putty/import.c 2018-04-25 05:30:06.000000000 +0200 @@ -1270,7 +1270,7 @@ int openssh_pem_write(const Filename *fi */ typedef enum { - ON_E_NONE, ON_E_AES256CBC + ON_E_NONE, ON_E_AES256CBC, ON_E_AES256CTR } openssh_new_cipher; typedef enum { ON_K_NONE, ON_K_BCRYPT @@ -1409,6 +1409,8 @@ static struct openssh_new_key *load_open ret->cipher = ON_E_NONE; } else if (match_ssh_id(stringlen, string, "aes256-cbc")) { ret->cipher = ON_E_AES256CBC; + } else if (match_ssh_id(stringlen, string, "aes256-ctr")) { + ret->cipher = ON_E_AES256CTR; } else { errmsg = "unrecognised cipher name\n"; goto error; @@ -1568,6 +1570,7 @@ struct ssh2_userkey *openssh_new_read(co keysize = 0; break; case ON_E_AES256CBC: + case ON_E_AES256CTR: keysize = 48; /* 32 byte key + 16 byte IV */ break; default: @@ -1592,6 +1595,7 @@ struct ssh2_userkey *openssh_new_read(co case ON_E_NONE: break; case ON_E_AES256CBC: + case ON_E_AES256CTR: if (key->privatelen % 16 != 0) { errmsg = "private key container length is not a" " multiple of AES block size\n"; @@ -1601,8 +1605,14 @@ struct ssh2_userkey *openssh_new_read(co void *ctx = aes_make_context(); aes256_key(ctx, keybuf); aes_iv(ctx, keybuf + 32); - aes_ssh2_decrypt_blk(ctx, key->privatestr, - key->privatelen); + if (key->cipher == ON_E_AES256CBC) { + aes_ssh2_decrypt_blk(ctx, key->privatestr, + key->privatelen); + } + else { + aes_ssh2_sdctr(ctx, key->privatestr, + key->privatelen); + } aes_free_context(ctx); } break; diff -Nrup filezilla-3.31.0/src/putty/Makefile.in filezilla-3.41.2/src/putty/Makefile.in --- filezilla-3.31.0/src/putty/Makefile.in 2018-02-23 10:35:55.000000000 +0100 +++ filezilla-3.41.2/src/putty/Makefile.in 2019-03-18 15:08:43.000000000 +0100 @@ -112,7 +112,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a $(top_srcdir)/m4/check_thread_local.m4 \ $(top_srcdir)/m4/check_time.m4 \ $(top_srcdir)/m4/cxx_compile_stdcxx_14.m4 \ - $(top_srcdir)/m4/d-type.m4 \ $(top_srcdir)/m4/fz_check_pugixml.m4 \ $(top_srcdir)/m4/fz_checkversion.m4 \ $(top_srcdir)/m4/icopyhookw.m4 $(top_srcdir)/m4/libtool.m4 \ diff -Nrup filezilla-3.31.0/src/putty/psftp.c filezilla-3.41.2/src/putty/psftp.c --- filezilla-3.31.0/src/putty/psftp.c 2017-09-19 23:36:39.000000000 +0200 +++ filezilla-3.41.2/src/putty/psftp.c 2019-03-18 14:29:34.000000000 +0100 @@ -1133,12 +1133,11 @@ int sftp_cmd_ls(struct sftp_command *cmd { struct fxp_handle *dirh; struct fxp_names *names; - struct fxp_name **ournames; - int nnames, namesize; const char *dir; char *cdir, *unwcdir, *wildcard; struct sftp_packet *pktin; struct sftp_request *req; + struct sftp_request *reqs[4]; int i; int ret; @@ -1195,14 +1194,16 @@ int sftp_cmd_ls(struct sftp_command *cmd fzprintf(sftpError, "Unable to open %s: %s", dir, fxp_error()); ret = 1; } else { - nnames = namesize = 0; - ournames = NULL; - + reqs[0] = fxp_readdir_send(dirh); + reqs[1] = fxp_readdir_send(dirh); + reqs[2] = fxp_readdir_send(dirh); + reqs[3] = fxp_readdir_send(dirh); + int ri = 0; while (1) { - req = fxp_readdir_send(dirh); - pktin = sftp_wait_for_reply(req); - names = fxp_readdir_recv(pktin, req); + pktin = sftp_wait_for_reply(reqs[ri]); + names = fxp_readdir_recv(pktin, reqs[ri]); + reqs[ri] = NULL; if (names == NULL) { if (fxp_error_type() == SSH_FX_EOF) @@ -1215,42 +1216,35 @@ int sftp_cmd_ls(struct sftp_command *cmd break; } - if (nnames + names->nnames >= namesize) { - namesize += names->nnames + 128; - ournames = sresize(ournames, namesize, struct fxp_name *); + for (i = 0; i < names->nnames; i++) { + if (!wildcard || wc_match(wildcard, names->names[i].filename)) { + unsigned long mtime = 0; + if (names->names[i].attrs.flags & SSH_FILEXFER_ATTR_ACMODTIME) { + mtime = names->names[i].attrs.mtime; + } + fzprintf_raw_untrusted(sftpListentry, "%s", names->names[i].longname); + fzprintf_raw_untrusted(sftpUnknown, "%lu", mtime); + fzprintf_raw_untrusted(sftpUnknown, "%s", names->names[i].filename); + } } - for (i = 0; i < names->nnames; i++) - if (!wildcard || wc_match(wildcard, names->names[i].filename)) - ournames[nnames++] = fxp_dup_name(&names->names[i]); - fxp_free_names(names); + reqs[ri++] = fxp_readdir_send(dirh); + ri %= 4; + } + for (i = 0; i < 4; ++i) { + if (reqs[ri]) { + pktin = sftp_wait_for_reply(reqs[ri]); + sfree(reqs[ri]); + sfree(pktin); + } + ++ri; + ri %= 4; } req = fxp_close_send(dirh); pktin = sftp_wait_for_reply(req); fxp_close_recv(pktin, req); - /* - * Now we have our filenames. Sort them by actual file - * name, and then output the longname parts. - */ - /*if (nnames > 0) - qsort(ournames, nnames, sizeof(*ournames), sftp_name_compare);*/ - - /* - * And print them. - */ - for (i = 0; i < nnames; ++i) { - unsigned long mtime = 0; - if (ournames[i]->attrs.flags & SSH_FILEXFER_ATTR_ACMODTIME) { - mtime = ournames[i]->attrs.mtime; - } - fzprintf_raw_untrusted(sftpListentry, "%s", ournames[i]->longname); - fzprintf_raw_untrusted(sftpUnknown, "%lu", mtime); - fzprintf_raw_untrusted(sftpUnknown, "%s", ournames[i]->filename); - fxp_free_name(ournames[i]); - } - sfree(ournames); ret = 0; } diff -Nrup filezilla-3.31.0/src/putty/ssh.c filezilla-3.41.2/src/putty/ssh.c --- filezilla-3.31.0/src/putty/ssh.c 2017-09-19 23:36:39.000000000 +0200 +++ filezilla-3.41.2/src/putty/ssh.c 2019-03-18 14:32:00.000000000 +0100 @@ -7442,6 +7442,18 @@ static void do_ssh2_transport(Ssh ssh, c */ { int klen = ssh_rsakex_klen(s->rsakey); + + int minlen = (strcmp(ssh->kex->name, "rsa1024-sha1") != 0) ? 2048 : 1024; + + if (klen < minlen) { + sfree(s->rsakeydata); + bombout(("Server sent %d-bit RSA key, " + "less than the minimum size %d for %s " + "key exchange", klen, minlen, + ssh->kex->name)); + crStopV; + } + int nbits = klen - (2*ssh->kex->hash->hlen*8 + 49); int i, byte = 0; unsigned char *kstr1, *kstr2, *outstr; diff -Nrup filezilla-3.31.0/src/putty/ssh.h filezilla-3.41.2/src/putty/ssh.h --- filezilla-3.31.0/src/putty/ssh.h 2017-09-19 23:36:39.000000000 +0200 +++ filezilla-3.41.2/src/putty/ssh.h 2019-03-18 14:29:34.000000000 +0100 @@ -473,6 +473,7 @@ void aes256_key(void *handle, unsigned c void aes_iv(void *handle, unsigned char *iv); void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len); void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len); +void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len); /* * PuTTY version number formatted as an SSH version string. diff -Nrup filezilla-3.31.0/src/putty/unix/Makefile.in filezilla-3.41.2/src/putty/unix/Makefile.in --- filezilla-3.31.0/src/putty/unix/Makefile.in 2018-02-23 10:35:55.000000000 +0100 +++ filezilla-3.41.2/src/putty/unix/Makefile.in 2019-03-18 15:08:43.000000000 +0100 @@ -102,7 +102,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a $(top_srcdir)/m4/check_thread_local.m4 \ $(top_srcdir)/m4/check_time.m4 \ $(top_srcdir)/m4/cxx_compile_stdcxx_14.m4 \ - $(top_srcdir)/m4/d-type.m4 \ $(top_srcdir)/m4/fz_check_pugixml.m4 \ $(top_srcdir)/m4/fz_checkversion.m4 \ $(top_srcdir)/m4/icopyhookw.m4 $(top_srcdir)/m4/libtool.m4 \ diff -Nrup filezilla-3.31.0/src/putty/windows/Makefile.am filezilla-3.41.2/src/putty/windows/Makefile.am --- filezilla-3.31.0/src/putty/windows/Makefile.am 2018-01-03 05:30:05.000000000 +0100 +++ filezilla-3.41.2/src/putty/windows/Makefile.am 2019-03-18 14:29:34.000000000 +0100 @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I$(srcdir)/.. COMMON_CFLAGS = $(AM_CFLAGS) -D_WINDOWS -DSECURITY_WIN32 \ -D_WIN32_IE=0x0900 \ - -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 $(NETTLE_CFLAGS) + -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 $(NETTLE_CFLAGS) libfzputtycommon_win_a_CFLAGS = $(COMMON_CFLAGS) diff -Nrup filezilla-3.31.0/src/putty/windows/Makefile.in filezilla-3.41.2/src/putty/windows/Makefile.in --- filezilla-3.31.0/src/putty/windows/Makefile.in 2018-02-23 10:35:55.000000000 +0100 +++ filezilla-3.41.2/src/putty/windows/Makefile.in 2019-03-18 15:08:43.000000000 +0100 @@ -103,7 +103,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a $(top_srcdir)/m4/check_thread_local.m4 \ $(top_srcdir)/m4/check_time.m4 \ $(top_srcdir)/m4/cxx_compile_stdcxx_14.m4 \ - $(top_srcdir)/m4/d-type.m4 \ $(top_srcdir)/m4/fz_check_pugixml.m4 \ $(top_srcdir)/m4/fz_checkversion.m4 \ $(top_srcdir)/m4/icopyhookw.m4 $(top_srcdir)/m4/libtool.m4 \ @@ -402,7 +401,7 @@ noinst_LIBRARIES = libfzsftp_win.a libfz AM_CPPFLAGS = -I$(srcdir)/.. COMMON_CFLAGS = $(AM_CFLAGS) -D_WINDOWS -DSECURITY_WIN32 \ -D_WIN32_IE=0x0900 \ - -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 $(NETTLE_CFLAGS) + -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 $(NETTLE_CFLAGS) libfzputtycommon_win_a_CFLAGS = $(COMMON_CFLAGS) libfzputtycommon_win_a_SOURCES = wincons.c \