From b3cab3ce3163083bbff9561a54369056793ab73d Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Tue, 3 Dec 2013 21:13:58 +0800
Subject: [PATCH] Log when generating a hostkey

---
 dropbear.8 |  2 +-
 svr-kex.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/dropbear.8 b/dropbear.8
index 40e1772b..032e4ce0 100644
--- a/dropbear.8
+++ b/dropbear.8
@@ -29,7 +29,7 @@ This file is generated with
 or automatically with the '-R' option. See "Host Key Files" below.
 .TP
 .B \-R
-Generate hostkeys automatically
+Generate hostkeys automatically. See "Host Key Files" below.
 .TP
 .B \-F
 Don't fork into background.
diff --git a/svr-kex.c b/svr-kex.c
index 24f1d737..e42a67cd 100644
--- a/svr-kex.c
+++ b/svr-kex.c
@@ -145,6 +145,20 @@ static void svr_ensure_hostkey() {
 
 	ret = readhostkey(fn, svr_opts.hostkey, &type);
 
+	if (ret == DROPBEAR_SUCCESS) {
+		char *fp = NULL;
+		unsigned int len;
+		buffer *key_buf = buf_new(MAX_PUBKEY_SIZE);
+		buf_put_pub_key(key_buf, svr_opts.hostkey, type);
+		buf_setpos(key_buf, 4);
+		len = key_buf->len - key_buf->pos;
+		fp = sign_key_fingerprint(buf_getptr(key_buf, len), len);
+		dropbear_log(LOG_INFO, "Generated hostkey %s, fingerprint is %s",
+			fn, fp);
+		m_free(fp);
+		buf_free(key_buf);
+	}
+
 out:
 	if (fn_temp) {
 		unlink(fn_temp);
-- 
GitLab