720cf82
diff --git a/audit-bsm.c b/audit-bsm.c
720cf82
index 5160869..c7a1b47 100644
720cf82
--- a/audit-bsm.c
720cf82
+++ b/audit-bsm.c
720cf82
@@ -481,7 +481,7 @@ audit_unsupported_body(int what)
720cf82
 }
720cf82
 
720cf82
 void
720cf82
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid, uid_t uid)
720cf82
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid, uid_t uid)
720cf82
 {
720cf82
 	/* not implemented */
720cf82
 }
720cf82
diff --git a/audit-linux.c b/audit-linux.c
720cf82
index 6954fc1..6686f6a 100644
720cf82
--- a/audit-linux.c
720cf82
+++ b/audit-linux.c
720cf82
@@ -297,7 +297,7 @@ audit_unsupported_body(int what)
720cf82
 const static char *direction[] = { "from-server", "from-client", "both" };
720cf82
 
720cf82
 void
720cf82
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
720cf82
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
720cf82
 	       uid_t uid)
720cf82
 {
720cf82
 #ifdef AUDIT_CRYPTO_SESSION
720cf82
@@ -306,8 +306,8 @@ audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
720cf82
 	Cipher *cipher = cipher_by_name(enc);
720cf82
 	char *s;
720cf82
 
720cf82
-	snprintf(buf, sizeof(buf), "op=start direction=%s cipher=%s ksize=%d mac=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
720cf82
-		direction[ctos], enc, cipher ? 8 * cipher->key_len : 0, mac,
720cf82
+	snprintf(buf, sizeof(buf), "op=start direction=%s cipher=%s ksize=%d mac=%s pfs=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
720cf82
+		direction[ctos], enc, cipher ? 8 * cipher->key_len : 0, mac, pfs,
720cf82
 		(intmax_t)pid, (intmax_t)uid,
720cf82
 		get_remote_port(), (s = get_local_ipaddr(packet_get_connection_in())), get_local_port());
720cf82
 	free(s);
720cf82
diff --git a/audit.c b/audit.c
720cf82
index 13c6849..5b49434 100644
720cf82
--- a/audit.c
720cf82
+++ b/audit.c
720cf82
@@ -135,9 +135,9 @@ audit_unsupported(int what)
720cf82
 }
720cf82
 
720cf82
 void
720cf82
-audit_kex(int ctos, char *enc, char *mac, char *comp)
720cf82
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
720cf82
 {
720cf82
-	PRIVSEP(audit_kex_body(ctos, enc, mac, comp, getpid(), getuid()));
720cf82
+	PRIVSEP(audit_kex_body(ctos, enc, mac, comp, pfs, getpid(), getuid()));
720cf82
 }
720cf82
 
720cf82
 void
720cf82
@@ -270,11 +270,11 @@ audit_unsupported_body(int what)
720cf82
  * This will be called on succesfull protocol negotiation.
720cf82
  */
720cf82
 void
720cf82
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
720cf82
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
720cf82
 	       uid_t uid)
720cf82
 {
720cf82
-	debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s from pid %ld uid %u",
720cf82
-		(unsigned)geteuid(), ctos, enc, mac, compress, (long)pid,
720cf82
+	debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s pfs %s from pid %ld uid %u",
720cf82
+		(unsigned)geteuid(), ctos, enc, mac, compress, pfs, (long)pid,
720cf82
 	        (unsigned)uid);
720cf82
 }
720cf82
 
720cf82
diff --git a/audit.h b/audit.h
720cf82
index a2dc3ff..903df66 100644
720cf82
--- a/audit.h
720cf82
+++ b/audit.h
720cf82
@@ -61,9 +61,9 @@ ssh_audit_event_t audit_classify_auth(const char *);
720cf82
 int	audit_keyusage(int, const char *, unsigned, char *, int);
720cf82
 void	audit_key(int, int *, const Key *);
720cf82
 void	audit_unsupported(int);
720cf82
-void	audit_kex(int, char *, char *, char *);
720cf82
+void	audit_kex(int, char *, char *, char *, char *);
720cf82
 void	audit_unsupported_body(int);
720cf82
-void	audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
720cf82
+void	audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
720cf82
 void	audit_session_key_free(int ctos);
720cf82
 void	audit_session_key_free_body(int ctos, pid_t, uid_t);
720cf82
 void	audit_destroy_sensitive_data(const char *, pid_t, uid_t);
720cf82
diff --git a/auditstub.c b/auditstub.c
720cf82
index 45817e0..116f460 100644
720cf82
--- a/auditstub.c
720cf82
+++ b/auditstub.c
720cf82
@@ -35,7 +35,7 @@ audit_unsupported(int n)
720cf82
 }
720cf82
 
720cf82
 void
720cf82
-audit_kex(int ctos, char *enc, char *mac, char *comp)
720cf82
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
720cf82
 {
720cf82
 }
720cf82
 
720cf82
diff --git a/kex.c b/kex.c
720cf82
index ede7b67..eb5f333 100644
720cf82
--- a/kex.c
720cf82
+++ b/kex.c
720cf82
@@ -553,13 +553,12 @@ kex_choose_conf(Kex *kex)
720cf82
 		    newkeys->enc.name,
720cf82
 		    authlen == 0 ? newkeys->mac.name : "<implicit>",
720cf82
 		    newkeys->comp.name);
720cf82
-#ifdef SSH_AUDIT_EVENTS
720cf82
-		audit_kex(ctos, newkeys->enc.name, newkeys->mac.name, newkeys->comp.name);
720cf82
-#endif
720cf82
 	}
720cf82
+
720cf82
 	choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]);
720cf82
 	choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
720cf82
 	    sprop[PROPOSAL_SERVER_HOST_KEY_ALGS]);
720cf82
+
720cf82
 	need = dh_need = 0;
720cf82
 	for (mode = 0; mode < MODE_MAX; mode++) {
720cf82
 		newkeys = kex->newkeys[mode];
720cf82
@@ -571,11 +570,16 @@ kex_choose_conf(Kex *kex)
720cf82
 		dh_need = MAX(dh_need, newkeys->enc.block_size);
720cf82
 		dh_need = MAX(dh_need, newkeys->enc.iv_len);
720cf82
 		dh_need = MAX(dh_need, newkeys->mac.key_len);
720cf82
+		debug("kex: %s need=%d dh_need=%d", kex->name, need, dh_need);
720cf82
+#ifdef SSH_AUDIT_EVENTS
720cf82
+		audit_kex(ctos, newkeys->enc.name, newkeys->mac.name, newkeys->comp.name, kex->name);
720cf82
+#endif
720cf82
 	}
720cf82
 	/* XXX need runden? */
720cf82
 	kex->we_need = need;
720cf82
 	kex->dh_need = dh_need;
720cf82
 
720cf82
+
720cf82
 	/* ignore the next message if the proposals do not match */
720cf82
 	if (first_kex_follows && !proposals_match(my, peer) &&
720cf82
 	    !(datafellows & SSH_BUG_FIRSTKEX)) {
720cf82
diff --git a/monitor.c b/monitor.c
720cf82
index 70b9b4c..81bc9c1 100644
720cf82
--- a/monitor.c
720cf82
+++ b/monitor.c
720cf82
@@ -2396,7 +2396,7 @@ int
720cf82
 mm_answer_audit_kex_body(int sock, Buffer *m)
720cf82
 {
720cf82
 	int ctos, len;
720cf82
-	char *cipher, *mac, *compress;
720cf82
+	char *cipher, *mac, *compress, *pfs;
720cf82
 	pid_t pid;
720cf82
 	uid_t uid;
720cf82
 
720cf82
@@ -2404,14 +2404,16 @@ mm_answer_audit_kex_body(int sock, Buffer *m)
720cf82
 	cipher = buffer_get_string(m, &len;;
720cf82
 	mac = buffer_get_string(m, &len;;
720cf82
 	compress = buffer_get_string(m, &len;;
720cf82
+	pfs = buffer_get_string(m, &len;;
720cf82
 	pid = buffer_get_int64(m);
720cf82
 	uid = buffer_get_int64(m);
720cf82
 
720cf82
-	audit_kex_body(ctos, cipher, mac, compress, pid, uid);
720cf82
+	audit_kex_body(ctos, cipher, mac, compress, pfs, pid, uid);
720cf82
 
720cf82
 	free(cipher);
720cf82
 	free(mac);
720cf82
 	free(compress);
720cf82
+	free(pfs);
720cf82
 	buffer_clear(m);
720cf82
 
720cf82
 	mm_request_send(sock, MONITOR_ANS_AUDIT_KEX, m);
720cf82
diff --git a/monitor_wrap.c b/monitor_wrap.c
720cf82
index 93f6535..69b29d8 100644
720cf82
--- a/monitor_wrap.c
720cf82
+++ b/monitor_wrap.c
720cf82
@@ -1408,7 +1408,7 @@ mm_audit_unsupported_body(int what)
720cf82
 }
720cf82
 
720cf82
 void
720cf82
-mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, pid_t pid,
720cf82
+mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, char *fps, pid_t pid,
720cf82
 		  uid_t uid)
720cf82
 {
720cf82
 	Buffer m;
720cf82
@@ -1418,6 +1418,7 @@ mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, pid_t pid,
720cf82
 	buffer_put_cstring(&m, cipher);
720cf82
 	buffer_put_cstring(&m, (mac ? mac : ""));
720cf82
 	buffer_put_cstring(&m, compress);
720cf82
+	buffer_put_cstring(&m, fps);
720cf82
 	buffer_put_int64(&m, pid);
720cf82
 	buffer_put_int64(&m, uid);
720cf82
 
720cf82
diff --git a/monitor_wrap.h b/monitor_wrap.h
720cf82
index 4cf0c78..e43109f 100644
720cf82
--- a/monitor_wrap.h
720cf82
+++ b/monitor_wrap.h
720cf82
@@ -83,7 +83,7 @@ void mm_audit_event(ssh_audit_event_t);
720cf82
 int mm_audit_run_command(const char *);
720cf82
 void mm_audit_end_command(int, const char *);
720cf82
 void mm_audit_unsupported_body(int);
720cf82
-void mm_audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
720cf82
+void mm_audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
720cf82
 void mm_audit_session_key_free_body(int, pid_t, uid_t);
720cf82
 void mm_audit_destroy_sensitive_data(const char *, pid_t, uid_t);
720cf82
 #endif
720cf82
diff --git a/sshd.c b/sshd.c
720cf82
index ee94825..41a94a7 100644
720cf82
--- a/sshd.c
720cf82
+++ b/sshd.c
720cf82
@@ -2430,7 +2430,7 @@ do_ssh1_kex(void)
720cf82
 			packet_disconnect("IP Spoofing check bytes do not match.");
720cf82
 
720cf82
 #ifdef SSH_AUDIT_EVENTS
720cf82
-	audit_kex(2, cipher_name(cipher_type), "crc", "none");
720cf82
+	audit_kex(2, cipher_name(cipher_type), "crc", "none", "none");
720cf82
 #endif
720cf82
 
720cf82
 	debug("Encryption type: %.200s", cipher_name(cipher_type));