diff common-kex.c @ 682:4edea9f363d0

Add rough support for choosing ciphers/hashes with "-c" or "-m"
author Matt Johnston <matt@ucc.asn.au>
date Thu, 17 May 2012 00:12:42 +0800
parents 4222a1039b06
children 63f8d6c469cf
line wrap: on
line diff
--- a/common-kex.c	Wed May 09 22:52:58 2012 +0800
+++ b/common-kex.c	Thu May 17 00:12:42 2012 +0800
@@ -106,17 +106,40 @@
 	/* server_host_key_algorithms */
 	buf_put_algolist(ses.writepayload, sshhostkey);
 
-	/* encryption_algorithms_client_to_server */
-	buf_put_algolist(ses.writepayload, sshciphers);
-
-	/* encryption_algorithms_server_to_client */
-	buf_put_algolist(ses.writepayload, sshciphers);
+#ifdef ENABLE_USER_ALGO_LIST
+	if (opts.cipher_list)
+	{
+		/* encryption_algorithms_client_to_server */
+		buf_putbytes(ses.writepayload, opts.cipher_list, strlen(opts.cipher_list));
+		/* encryption_algorithms_server_to_client */
+		buf_putbytes(ses.writepayload, opts.cipher_list, strlen(opts.cipher_list));
+	}
+	else
+#endif
+	{
+		/* encryption_algorithms_client_to_server */
+		buf_put_algolist(ses.writepayload, sshciphers);
+		/* encryption_algorithms_server_to_client */
+		buf_put_algolist(ses.writepayload, sshciphers);
+	}
 
-	/* mac_algorithms_client_to_server */
-	buf_put_algolist(ses.writepayload, sshhashes);
+#ifdef ENABLE_USER_ALGO_LIST
+	if (opts.mac_list)
+	{
+		/* mac_algorithms_client_to_server */
+		buf_putbytes(ses.writepayload, opts.mac_list, strlen(opts.mac_list));
+		/* mac_algorithms_server_to_client */
+		buf_putbytes(ses.writepayload, opts.mac_list, strlen(opts.mac_list));
+	}
+	else
+#endif
+	{
+		/* mac_algorithms_client_to_server */
+		buf_put_algolist(ses.writepayload, sshhashes);
+		/* mac_algorithms_server_to_client */
+		buf_put_algolist(ses.writepayload, sshhashes);
+	}
 
-	/* mac_algorithms_server_to_client */
-	buf_put_algolist(ses.writepayload, sshhashes);
 
 	/* compression_algorithms_client_to_server */
 	buf_put_algolist(ses.writepayload, ses.compress_algos);