diff common-kex.c @ 1196:a29559086628 coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Wed, 02 Dec 2015 22:37:51 +0800
parents 1b8afc698e39
children 82e2037d34ea 2bb4c662d1c2
line wrap: on
line diff
--- a/common-kex.c	Mon Nov 23 23:04:48 2015 +0800
+++ b/common-kex.c	Wed Dec 02 22:37:51 2015 +0800
@@ -760,6 +760,7 @@
 	unsigned char out[CURVE25519_LEN];
 	const unsigned char* Q_C = NULL;
 	const unsigned char* Q_S = NULL;
+	char zeroes[CURVE25519_LEN] = {0};
 
 	if (buf_pub_them->len != CURVE25519_LEN)
 	{
@@ -767,6 +768,11 @@
 	}
 
 	curve25519_donna(out, param->priv, buf_pub_them->data);
+
+	if (constant_time_memcmp(zeroes, out, CURVE25519_LEN) == 0) {
+		dropbear_exit("Bad curve25519");
+	}
+
 	m_mp_alloc_init_multi(&ses.dh_K, NULL);
 	bytes_to_mp(ses.dh_K, out, CURVE25519_LEN);
 	m_burn(out, sizeof(out));