changeset 1251:52a456a3add0

Merge branch '20151231_indent' of https://github.com/fperrad/dropbear into fperrad-20151231_indent
author Matt Johnston <matt@ucc.asn.au>
date Tue, 15 Mar 2016 21:41:06 +0800
parents 739b3909c499 (current diff) 2bb4c662d1c2 (diff)
children 3f4af834314d
files cli-tcpfwd.c common-kex.c scp.c svr-tcpfwd.c
diffstat 17 files changed, 142 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/bignum.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/bignum.c	Tue Mar 15 21:41:06 2016 +0800
@@ -39,33 +39,33 @@
  * on error */
 void m_mp_init_multi(mp_int *mp, ...) 
 {
-    mp_int* cur_arg = mp;
-    va_list args;
+	mp_int* cur_arg = mp;
+	va_list args;
 
-    va_start(args, mp);        /* init args to next argument from caller */
-    while (cur_arg != NULL) {
-        if (mp_init(cur_arg) != MP_OKAY) {
+	va_start(args, mp);        /* init args to next argument from caller */
+	while (cur_arg != NULL) {
+		if (mp_init(cur_arg) != MP_OKAY) {
 			dropbear_exit("Mem alloc error");
-        }
-        cur_arg = va_arg(args, mp_int*);
-    }
-    va_end(args);
+		}
+		cur_arg = va_arg(args, mp_int*);
+	}
+	va_end(args);
 }
 
 void m_mp_alloc_init_multi(mp_int **mp, ...) 
 {
-    mp_int** cur_arg = mp;
-    va_list args;
+	mp_int** cur_arg = mp;
+	va_list args;
 
-    va_start(args, mp);        /* init args to next argument from caller */
-    while (cur_arg != NULL) {
-    	*cur_arg = m_malloc(sizeof(mp_int));
-        if (mp_init(*cur_arg) != MP_OKAY) {
+	va_start(args, mp);        /* init args to next argument from caller */
+	while (cur_arg != NULL) {
+		*cur_arg = m_malloc(sizeof(mp_int));
+		if (mp_init(*cur_arg) != MP_OKAY) {
 			dropbear_exit("Mem alloc error");
-        }
-        cur_arg = va_arg(args, mp_int**);
-    }
-    va_end(args);
+		}
+		cur_arg = va_arg(args, mp_int**);
+	}
+	va_end(args);
 }
 
 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) {
--- a/buffer.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/buffer.c	Tue Mar 15 21:41:06 2016 +0800
@@ -98,7 +98,7 @@
 	ret = buf_new(buf->len);
 	ret->len = buf->len;
 	if (buf->len > 0) {
-	    memcpy(ret->data, buf->data, buf->len);
+		memcpy(ret->data, buf->data, buf->len);
 	}
 	return ret;
 }
--- a/cli-auth.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/cli-auth.c	Tue Mar 15 21:41:06 2016 +0800
@@ -332,12 +332,12 @@
 	char* password = NULL;
 	
 #ifdef DROPBEAR_PASSWORD_ENV
-    /* Password provided in an environment var */
-    password = getenv(DROPBEAR_PASSWORD_ENV);
-    if (password)
-    {
-        return password;
-    }
+	/* Password provided in an environment var */
+	password = getenv(DROPBEAR_PASSWORD_ENV);
+	if (password)
+	{
+		return password;
+	}
 #endif
 
 	password = getpass(prompt);
--- a/cli-tcpfwd.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/cli-tcpfwd.c	Tue Mar 15 21:41:06 2016 +0800
@@ -231,7 +231,7 @@
 
 static int newtcpforwarded(struct Channel * channel) {
 
-    char *origaddr = NULL;
+	char *origaddr = NULL;
 	unsigned int origport;
 	m_list_elem * iter = NULL;
 	struct TCPFwdEntry *fwd;
@@ -267,7 +267,7 @@
 
 	if (iter == NULL) {
 		/* We didn't request forwarding on that port */
-        	cleantext(origaddr);
+		cleantext(origaddr);
 		dropbear_log(LOG_INFO, "Server sent unrequested forward from \"%s:%d\"", 
                 origaddr, origport);
 		goto out;
--- a/common-kex.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/common-kex.c	Tue Mar 15 21:41:06 2016 +0800
@@ -308,17 +308,17 @@
 	ses.hash = NULL;
 
 	if (IS_DROPBEAR_CLIENT) {
-	    trans_IV	= C2S_IV;
-	    recv_IV		= S2C_IV;
-	    trans_key	= C2S_key;
-	    recv_key	= S2C_key;
+		trans_IV	= C2S_IV;
+		recv_IV		= S2C_IV;
+		trans_key	= C2S_key;
+		recv_key	= S2C_key;
 		mactransletter = 'E';
 		macrecvletter = 'F';
 	} else {
-	    trans_IV	= S2C_IV;
-	    recv_IV		= C2S_IV;
-	    trans_key	= S2C_key;
-	    recv_key	= C2S_key;
+		trans_IV	= S2C_IV;
+		recv_IV		= C2S_IV;
+		trans_key	= S2C_key;
+		recv_key	= C2S_key;
 		mactransletter = 'F';
 		macrecvletter = 'E';
 	}
@@ -484,18 +484,18 @@
 		read_kex_algos();
 
 		/* V_C, the client's version string (CR and NL excluded) */
-	    buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
+		buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
 		/* V_S, the server's version string (CR and NL excluded) */
-	    buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
+		buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
 
 		/* I_C, the payload of the client's SSH_MSG_KEXINIT */
-	    buf_putstring(ses.kexhashbuf,
+		buf_putstring(ses.kexhashbuf,
 			(const char*)ses.transkexinit->data, ses.transkexinit->len);
 		/* I_S, the payload of the server's SSH_MSG_KEXINIT */
-	    buf_setpos(ses.payload, ses.payload_beginning);
-	    buf_putstring(ses.kexhashbuf, 
-	    	(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
-	    	ses.payload->len-ses.payload->pos);
+		buf_setpos(ses.payload, ses.payload_beginning);
+		buf_putstring(ses.kexhashbuf,
+			(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
+			ses.payload->len-ses.payload->pos);
 		ses.requirenext = SSH_MSG_KEXDH_REPLY;
 	} else {
 		/* SERVER */
@@ -503,18 +503,18 @@
 		/* read the peer's choice of algos */
 		read_kex_algos();
 		/* V_C, the client's version string (CR and NL excluded) */
-	    buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
+		buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
 		/* V_S, the server's version string (CR and NL excluded) */
-	    buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
+		buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
 
 		/* I_C, the payload of the client's SSH_MSG_KEXINIT */
-	    buf_setpos(ses.payload, ses.payload_beginning);
-	    buf_putstring(ses.kexhashbuf, 
-	    	(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
-	    	ses.payload->len-ses.payload->pos);
+		buf_setpos(ses.payload, ses.payload_beginning);
+		buf_putstring(ses.kexhashbuf, 
+			(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
+			ses.payload->len-ses.payload->pos);
 
 		/* I_S, the payload of the server's SSH_MSG_KEXINIT */
-	    buf_putstring(ses.kexhashbuf,
+		buf_putstring(ses.kexhashbuf,
 			(const char*)ses.transkexinit->data, ses.transkexinit->len);
 
 		ses.requirenext = SSH_MSG_KEXDH_INIT;
--- a/dbutil.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/dbutil.c	Tue Mar 15 21:41:06 2016 +0800
@@ -157,26 +157,26 @@
 {
 	if (getenv("DROPBEAR_DEBUG_NET_TIMESTAMP"))
 	{
-    	/* Timestamps start from first network activity */
-	    struct timeval tv;
-	    gettimeofday(&tv, NULL);
-	    debug_start_time = tv.tv_sec + (tv.tv_usec / 1000000.0);
-	    TRACE(("Resetting Dropbear TRACE timestamps"))
+		/* Timestamps start from first network activity */
+		struct timeval tv;
+		gettimeofday(&tv, NULL);
+		debug_start_time = tv.tv_sec + (tv.tv_usec / 1000000.0);
+		TRACE(("Resetting Dropbear TRACE timestamps"))
 	}
 }
 
 static double time_since_start()
 {
-    double nowf;
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    nowf = tv.tv_sec + (tv.tv_usec / 1000000.0);
-    if (debug_start_time < 0)
-    {
-        debug_start_time = nowf;
-        return 0;
-    }
-    return nowf - debug_start_time;
+	double nowf;
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	nowf = tv.tv_sec + (tv.tv_usec / 1000000.0);
+	if (debug_start_time < 0)
+	{
+		debug_start_time = nowf;
+		return 0;
+	}
+	return nowf - debug_start_time;
 }
 
 void dropbear_trace(const char* format, ...) {
--- a/dropbearkey.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/dropbearkey.c	Tue Mar 15 21:41:06 2016 +0800
@@ -105,25 +105,25 @@
 /* fails fatally */
 static void check_signkey_bits(enum signkey_type type, int bits)
 {
-        switch (type) {
+	switch (type) {
 #ifdef DROPBEAR_RSA
-            case DROPBEAR_SIGNKEY_RSA:
-                if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
-                	dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a"
-                            " multiple of 8\n");
-                }
-                break;
+		case DROPBEAR_SIGNKEY_RSA:
+			if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
+				dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a"
+				              " multiple of 8\n");
+			}
+			break;
 #endif
 #ifdef DROPEAR_DSS
-            case DROPBEAR_SIGNKEY_DSS:
-                if (bits != 1024) {
-                    dropbear_exit("DSS keys have a fixed size of 1024 bits\n");
-                    exit(EXIT_FAILURE);
-                }
+		case DROPBEAR_SIGNKEY_DSS:
+			if (bits != 1024) {
+				dropbear_exit("DSS keys have a fixed size of 1024 bits\n");
+				exit(EXIT_FAILURE);
+			}
 #endif
-			default:
-				(void)0; /* quiet, compiler. ecdsa handles checks itself */
-        }
+		default:
+			(void)0; /* quiet, compiler. ecdsa handles checks itself */
+	}
 }
 
 #if defined(DBMULTI_dropbearkey) || !defined(DROPBEAR_MULTI)
@@ -238,13 +238,13 @@
 		}
 		
 		check_signkey_bits(keytype, bits);;
-    }
+	}
 
 	fprintf(stderr, "Generating key, this may take a while...\n");
-    if (signkey_generate(keytype, bits, filename) == DROPBEAR_FAILURE)
-    {
-    	dropbear_exit("Failed to generate key.\n");
-    }
+	if (signkey_generate(keytype, bits, filename) == DROPBEAR_FAILURE)
+	{
+		dropbear_exit("Failed to generate key.\n");
+	}
 
 	printpubfile(filename);
 
--- a/ecdsa.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/ecdsa.c	Tue Mar 15 21:41:06 2016 +0800
@@ -385,12 +385,12 @@
 			goto out; 
 		}
 
-    	/* reduce */
+		/* reduce */
 		if (ltc_mp.ecc_map(mG, m, mp) != CRYPT_OK) { 
 			goto out; 
 		}
 	} else {
-      /* use Shamir's trick to compute u1*mG + u2*mQ using half of the doubles */
+		/* use Shamir's trick to compute u1*mG + u2*mQ using half of the doubles */
 		if (ltc_mp.ecc_mul2add(mG, u1, mQ, u2, mG, m) != CRYPT_OK) { 
 			goto out; 
 		}
--- a/gensignkey.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/gensignkey.c	Tue Mar 15 21:41:06 2016 +0800
@@ -52,28 +52,28 @@
 /* returns 0 on failure */
 static int get_default_bits(enum signkey_type keytype)
 {
-        switch (keytype) {
+	switch (keytype) {
 #ifdef DROPBEAR_RSA
-            case DROPBEAR_SIGNKEY_RSA:
-				return RSA_DEFAULT_SIZE;
+		case DROPBEAR_SIGNKEY_RSA:
+			return RSA_DEFAULT_SIZE;
 #endif
 #ifdef DROPBEAR_DSS
-            case DROPBEAR_SIGNKEY_DSS:
-                return DSS_DEFAULT_SIZE;
+		case DROPBEAR_SIGNKEY_DSS:
+			return DSS_DEFAULT_SIZE;
 #endif
 #ifdef DROPBEAR_ECDSA
-            case DROPBEAR_SIGNKEY_ECDSA_KEYGEN:
-                return ECDSA_DEFAULT_SIZE;
-            case DROPBEAR_SIGNKEY_ECDSA_NISTP521:
-            	return 521;
-            case DROPBEAR_SIGNKEY_ECDSA_NISTP384:
-            	return 384;
-            case DROPBEAR_SIGNKEY_ECDSA_NISTP256:
-            	return 256;
+		case DROPBEAR_SIGNKEY_ECDSA_KEYGEN:
+			return ECDSA_DEFAULT_SIZE;
+		case DROPBEAR_SIGNKEY_ECDSA_NISTP521:
+			return 521;
+		case DROPBEAR_SIGNKEY_ECDSA_NISTP384:
+			return 384;
+		case DROPBEAR_SIGNKEY_ECDSA_NISTP256:
+			return 256;
 #endif
-            default:
-                return 0;
-		}
+		default:
+			return 0;
+	}
 }
 
 int signkey_generate(enum signkey_type keytype, int bits, const char* filename)
--- a/keyimport.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/keyimport.c	Tue Mar 15 21:41:06 2016 +0800
@@ -194,13 +194,13 @@
 		int datalen, int cpl)
 {
 	unsigned char out[100];
-    int n;
+	int n;
 	unsigned long outlen;
 	int rawcpl;
 	rawcpl = cpl * 3 / 4;
 	dropbear_assert((unsigned int)cpl < sizeof(out));
 
-    while (datalen > 0) {
+	while (datalen > 0) {
 		n = (datalen < rawcpl ? datalen : rawcpl);
 		outlen = sizeof(out);
 		base64_encode(data, n, out, &outlen);
@@ -208,7 +208,7 @@
 		datalen -= n;
 		fwrite(out, 1, outlen, fp);
 		fputc('\n', fp);
-    }
+	}
 }
 /*
  * Read an ASN.1/BER identifier and length pair.
@@ -1056,7 +1056,7 @@
 		dropbear_assert(k_size <= curve_size);
 		buf_incrwritepos(seq_buf,
 			ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0));
-	    mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size));
+		mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size));
 		buf_incrwritepos(seq_buf, k_size);
 
 		/* SECGCurveNames */
--- a/list.h	Sat Mar 12 16:21:13 2016 +0800
+++ b/list.h	Tue Mar 15 21:41:06 2016 +0800
@@ -4,17 +4,17 @@
 struct _m_list;
 
 struct _m_list_elem {
-    void *item;
+	void *item;
 	struct _m_list_elem *next;
 	struct _m_list_elem *prev;
-    struct _m_list *list;
+	struct _m_list *list;
 };
 	
 typedef struct _m_list_elem m_list_elem;
 
 struct _m_list {
-    m_list_elem *first;
-    m_list_elem *last;
+	m_list_elem *first;
+	m_list_elem *last;
 };
 
 typedef struct _m_list m_list;
--- a/packet.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/packet.c	Tue Mar 15 21:41:06 2016 +0800
@@ -576,8 +576,8 @@
 	}
 	buf_incrpos(writebuf, len);
 
-    /* stick the MAC on it */
-    buf_putbytes(writebuf, mac_bytes, mac_size);
+	/* stick the MAC on it */
+	buf_putbytes(writebuf, mac_bytes, mac_size);
 
 	/* Update counts */
 	ses.kexstate.datatrans += writebuf->len;
@@ -645,7 +645,7 @@
 			dropbear_exit("HMAC error");
 		}
 	
-        bufsize = MAX_MAC_LEN;
+		bufsize = MAX_MAC_LEN;
 		if (hmac_done(&hmac, output_mac, &bufsize) != CRYPT_OK) {
 			dropbear_exit("HMAC error");
 		}
--- a/rsa.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/rsa.c	Tue Mar 15 21:41:06 2016 +0800
@@ -47,7 +47,7 @@
  * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
 int buf_get_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) {
 
-    int ret = DROPBEAR_FAILURE;
+	int ret = DROPBEAR_FAILURE;
 	TRACE(("enter buf_get_rsa_pub_key"))
 	dropbear_assert(key != NULL);
 	m_mp_alloc_init_multi(&key->e, &key->n, NULL);
@@ -60,21 +60,21 @@
 	if (buf_getmpint(buf, key->e) == DROPBEAR_FAILURE
 	 || buf_getmpint(buf, key->n) == DROPBEAR_FAILURE) {
 		TRACE(("leave buf_get_rsa_pub_key: failure"))
-	    goto out;
+		goto out;
 	}
 
 	if (mp_count_bits(key->n) < MIN_RSA_KEYLEN) {
 		dropbear_log(LOG_WARNING, "RSA key too short");
-	    goto out;
+		goto out;
 	}
 
 	TRACE(("leave buf_get_rsa_pub_key: success"))
-    ret = DROPBEAR_SUCCESS;
+	ret = DROPBEAR_SUCCESS;
 out:
-    if (ret == DROPBEAR_FAILURE) {
-        m_free(key->e);
-        m_free(key->n);
-    }
+	if (ret == DROPBEAR_FAILURE) {
+		m_free(key->e);
+		m_free(key->n);
+	}
 	return ret;
 }
 
@@ -82,7 +82,7 @@
  * Loads a private rsa key from a buffer
  * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
 int buf_get_rsa_priv_key(buffer* buf, dropbear_rsa_key *key) {
-    int ret = DROPBEAR_FAILURE;
+	int ret = DROPBEAR_FAILURE;
 
 	TRACE(("enter buf_get_rsa_priv_key"))
 	dropbear_assert(key != NULL);
@@ -99,34 +99,34 @@
 	m_mp_alloc_init_multi(&key->d, NULL);
 	if (buf_getmpint(buf, key->d) == DROPBEAR_FAILURE) {
 		TRACE(("leave buf_get_rsa_priv_key: d: ret == DROPBEAR_FAILURE"))
-	    goto out;
+		goto out;
 	}
 
 	if (buf->pos == buf->len) {
-    	/* old Dropbear private keys didn't keep p and q, so we will ignore them*/
+		/* old Dropbear private keys didn't keep p and q, so we will ignore them*/
 	} else {
 		m_mp_alloc_init_multi(&key->p, &key->q, NULL);
 
 		if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE) {
 			TRACE(("leave buf_get_rsa_priv_key: p: ret == DROPBEAR_FAILURE"))
-		    goto out;
+			goto out;
 		}
 
 		if (buf_getmpint(buf, key->q) == DROPBEAR_FAILURE) {
 			TRACE(("leave buf_get_rsa_priv_key: q: ret == DROPBEAR_FAILURE"))
-		    goto out;
+			goto out;
 		}
 	}
 
-    ret = DROPBEAR_SUCCESS;
+	ret = DROPBEAR_SUCCESS;
 out:
-    if (ret == DROPBEAR_FAILURE) {
-        m_free(key->d);
-        m_free(key->p);
-        m_free(key->q);
-    }
+	if (ret == DROPBEAR_FAILURE) {
+		m_free(key->d);
+		m_free(key->p);
+		m_free(key->q);
+	}
 	TRACE(("leave buf_get_rsa_priv_key"))
-    return ret;
+	return ret;
 }
 	
 
--- a/scp.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/scp.c	Tue Mar 15 21:41:06 2016 +0800
@@ -440,9 +440,9 @@
 	 */
 	if (do_cmd_pid != -1 && errs == 0) {
 		if (remin != -1)
-		    (void) close(remin);
+			(void) close(remin);
 		if (remout != -1)
-		    (void) close(remout);
+			(void) close(remout);
 		if (waitpid(do_cmd_pid, &status, 0) == -1)
 			errs = 1;
 		else {
--- a/signkey.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/signkey.c	Tue Mar 15 21:41:06 2016 +0800
@@ -317,15 +317,15 @@
 #ifdef DROPBEAR_DSS
 	if (type == DROPBEAR_SIGNKEY_DSS) {
 		buf_put_dss_priv_key(buf, key->dsskey);
-	TRACE(("leave buf_put_priv_key: dss done"))
-	return;
+		TRACE(("leave buf_put_priv_key: dss done"))
+		return;
 	}
 #endif
 #ifdef DROPBEAR_RSA
 	if (type == DROPBEAR_SIGNKEY_RSA) {
 		buf_put_rsa_priv_key(buf, key->rsakey);
-	TRACE(("leave buf_put_priv_key: rsa done"))
-	return;
+		TRACE(("leave buf_put_priv_key: rsa done"))
+		return;
 	}
 #endif
 #ifdef DROPBEAR_ECDSA
--- a/svr-main.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/svr-main.c	Tue Mar 15 21:41:06 2016 +0800
@@ -398,7 +398,7 @@
 	 * otherwise we might end up blatting error messages to the socket */
 	load_all_hostkeys();
 
-    seedrandom();
+	seedrandom();
 }
 
 /* Set up listening sockets for all the requested ports */
--- a/svr-tcpfwd.c	Sat Mar 12 16:21:13 2016 +0800
+++ b/svr-tcpfwd.c	Tue Mar 15 21:41:06 2016 +0800
@@ -194,7 +194,7 @@
 
 	tcpinfo->request_listenaddr = request_addr;
 	if (!opts.listen_fwd_all || (strcmp(request_addr, "localhost") == 0) ) {
-        /* NULL means "localhost only" */
+		/* NULL means "localhost only" */
 		tcpinfo->listenaddr = NULL;
 	}
 	else