The unified diff between revisions [2dd1bf91..] and [8a7db1e2..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'dropbearkey.c'

#
#
# patch "dropbearkey.c"
#  from [8fd3c812b69ecacaeac14b897f9649a9b33c0628]
#    to [85b53ed835885a034bc2d898253a14c051031603]
#
============================================================
--- dropbearkey.c	8fd3c812b69ecacaeac14b897f9649a9b33c0628
+++ dropbearkey.c	85b53ed835885a034bc2d898253a14c051031603
@@ -75,6 +75,7 @@ static void printhelp(char * progname) {
 #endif
 					"-f filename	Use filename for the secret key\n"
 					"-s bits	Key size in bits, should be a multiple of 8 (optional)\n"
+					"           (DSS has a fixed size of 1024 bits)\n"
 					"-y		Just print the publickey and fingerprint for the\n		private key in <filename>.\n"
 #ifdef DEBUG_TRACE
 					"-v		verbose\n"
@@ -187,8 +188,11 @@ int main(int argc, char ** argv) {
 			fprintf(stderr, "Bits must be an integer\n");
 			exit(EXIT_FAILURE);
 		}
-
-		if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
+
+		if (keytype == DROPBEAR_SIGNKEY_DSS && bits != 1024) {
+			fprintf(stderr, "DSS keys have a fixed size of 1024 bits\n");
+			exit(EXIT_FAILURE);
+		} else if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
 			fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a"
 					" multiple of 8\n");
 			exit(EXIT_FAILURE);
@@ -283,8 +287,10 @@ out:
 	buf_burn(buf);
 	buf_free(buf);
 	buf = NULL;
-	sign_key_free(key);
-	key = NULL;
+	if (key) {
+		sign_key_free(key);
+		key = NULL;
+	}
 	exit(err);
 }

@@ -297,6 +303,9 @@ static void printpubkey(sign_key * key,
 	const char * typestring = NULL;
 	char *fp = NULL;
 	int len;
+	struct passwd * pw = NULL;
+	char * username = NULL;
+	char hostname[100];

 	buf = buf_new(MAX_PUBKEY_SIZE);
 	buf_put_pub_key(buf, key, keytype);
@@ -315,9 +324,19 @@ static void printpubkey(sign_key * key,

 	fp = sign_key_fingerprint(buf_getptr(buf, len), len);

-	printf("Public key portion is:\n%s %s\nFingerprint: %s\n",
-			typestring, base64key, fp);
+	/* a user@host comment is informative */
+	username = "";
+	pw = getpwuid(getuid());
+	if (pw) {
+		username = pw->pw_name;
+	}

+	gethostname(hostname, sizeof(hostname));
+	hostname[sizeof(hostname)-1] = '\0';
+
+	printf("Public key portion is:\n%s %s %s@%s\nFingerprint: %s\n",
+			typestring, base64key, username, hostname, fp);
+
 	m_free(fp);
 	buf_free(buf);
 }