# HG changeset patch # User Matt Johnston # Date 1448460959 -28800 # Node ID 1b8afc698e39865d80938782e0945c2a7a2a34f9 # Parent 80cacacfec2383cce2f690e93fd97a7e69b9eaa3 check for zero K value from curve25519 diff -r 80cacacfec23 -r 1b8afc698e39 common-kex.c --- a/common-kex.c Wed Nov 25 20:46:06 2015 +0800 +++ b/common-kex.c Wed Nov 25 22:15:59 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));