- OpenBSD CVS Updates:
   - markus@cvs.openbsd.org  2000/06/18 18:50:11
     [auth2.c compat.c compat.h sshconnect2.c]
     make userauth+pubkey interop with ssh.com-2.2.0
   - markus@cvs.openbsd.org  2000/06/18 20:56:17
     [dsa.c]
     mem leak + be more paranoid in dsa_verify.
   - markus@cvs.openbsd.org  2000/06/18 21:29:50
     [key.c]
     cleanup fingerprinting, less hardcoded sizes
   - markus@cvs.openbsd.org  2000/06/19 19:39:45
     [atomicio.c auth-options.c auth-passwd.c auth-rh-rsa.c auth-rhosts.c]
     [auth-rsa.c auth-skey.c authfd.c authfd.h authfile.c bufaux.c bufaux.h]
     [buffer.c buffer.h canohost.c channels.c channels.h cipher.c cipher.h]
     [clientloop.c compat.c compat.h compress.c compress.h crc32.c crc32.h]
     [deattack.c dispatch.c dsa.c fingerprint.c fingerprint.h getput.h hmac.c]
     [kex.c log-client.c log-server.c login.c match.c mpaux.c mpaux.h nchan.c]
     [nchan.h packet.c packet.h pty.c pty.h readconf.c readconf.h readpass.c]
     [rsa.c rsa.h scp.c servconf.c servconf.h ssh-add.c ssh-keygen.c ssh.c]
     [ssh.h tildexpand.c ttymodes.c ttymodes.h uidswap.c xmalloc.c xmalloc.h]
     OpenBSD tag
   - markus@cvs.openbsd.org  2000/06/21 10:46:10
     sshconnect2.c missing free; nuke old comment
diff --git a/key.c b/key.c
index d474f85..be38a88 100644
--- a/key.c
+++ b/key.c
@@ -121,8 +121,6 @@
 	return 0;
 }
 
-#define FPRINT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
-
 /*
  * Generate key fingerprint in ascii format.
  * Based on ideas and code from Bjoern Groenvall <bg@sics.se>
@@ -130,7 +128,7 @@
 char *
 key_fingerprint(Key *k)
 {
-	static char retval[80];
+	static char retval[(EVP_MAX_MD_SIZE+1)*3];
 	unsigned char *blob = NULL;
 	int len = 0;
 	int nlen, elen;
@@ -151,15 +149,22 @@
 		fatal("key_fingerprint: bad key type %d", k->type);
 		break;
 	}
+	retval[0] = '\0';
+
 	if (blob != NULL) {
-		unsigned char d[16];
-		EVP_MD_CTX md;
-		EVP_DigestInit(&md, EVP_md5());
-		EVP_DigestUpdate(&md, blob, len);
-		EVP_DigestFinal(&md, d, NULL);
-		snprintf(retval, sizeof(retval), FPRINT,
-		    d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
-		    d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+		int i;
+		unsigned char digest[EVP_MAX_MD_SIZE];
+		EVP_MD *md = EVP_md5();
+		EVP_MD_CTX ctx;
+		EVP_DigestInit(&ctx, md);
+		EVP_DigestUpdate(&ctx, blob, len);
+		EVP_DigestFinal(&ctx, digest, NULL);
+		for(i = 0; i < md->md_size; i++) {
+			char hex[4];
+			snprintf(hex, sizeof(hex), "%02x:", digest[i]);
+			strlcat(retval, hex, sizeof(retval));
+		}
+		retval[strlen(retval) - 1] = '\0';
 		memset(blob, 0, len);
 		xfree(blob);
 	}