X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/996c8c3b71ae7d62c5da27e40d6771f1d17c584b..48672163702ae1382acf8cdfae208031b533a05c:/scpssh.c?ds=sidebyside diff --git a/scpssh.c b/scpssh.c index 5db056a4..3d2c8240 100644 --- a/scpssh.c +++ b/scpssh.c @@ -121,8 +121,15 @@ next_packet: pktin.length = len; if (pktin.maxlen < biglen) { pktin.maxlen = biglen; +#ifdef MSCRYPTOAPI + /* allocate enough buffer space for extra block + * for MS CryptEncrypt() */ + pktin.data = (pktin.data == NULL) ? + smalloc(biglen+8) : srealloc(pktin.data, biglen+8); +#else pktin.data = (pktin.data == NULL) ? - smalloc(biglen) : srealloc(pktin.data, biglen); + smalloc(biglen) : srealloc(pktin.data, biglen); +#endif } ret = s_read(pktin.data, biglen); @@ -162,8 +169,15 @@ static void s_wrpkt_start(int type, int len) { pktout.length = len-5; if (pktout.maxlen < biglen) { pktout.maxlen = biglen; +#ifdef MSCRYPTOAPI + /* Allocate enough buffer space for extra block + * for MS CryptEncrypt() */ + pktout.data = (pktout.data == NULL ? malloc(biglen+8) : + realloc(pktout.data, biglen+8)); +#else pktout.data = (pktout.data == NULL ? malloc(biglen+4) : realloc(pktout.data, biglen+4)); +#endif if (!pktout.data) fatalbox("Out of memory"); } @@ -281,7 +295,21 @@ static void ssh_login(char *username, char *cmd) if (!rsabuf) fatalbox("Out of memory"); - verify_ssh_host_key(savedhost, &hostkey); + /* + * Verify the host key. + */ + { + /* + * First format the key into a string. + */ + int len = rsastr_len(&hostkey); + char *keystr = malloc(len); + if (!keystr) + fatalbox("Out of memory"); + rsastr_fmt(keystr, &hostkey); + verify_ssh_host_key(savedhost, keystr); + free(keystr); + } for (i=0; i<32; i++) { rsabuf[i] = session_key[i]; @@ -474,6 +502,11 @@ char *ssh_init(char *host, int port, char *cmd, char **realhost) { int FWport; #endif +#ifdef MSCRYPTOAPI + if(crypto_startup() == 0) + return "Microsoft high encryption pack not installed!"; +#endif + savedhost = malloc(1+strlen(host)); if (!savedhost) fatalbox("Out of memory");