summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-06-22 21:32:31 +1000
committerDamien Miller <djm@mindrot.org>2000-06-22 21:32:31 +1000
commit6536c7d3c9d0e794c5c85d4f1746b958d7e04343 (patch)
tree9551d0d84924d6a206130fb575df5d90f1cc7a28 /key.c
parent099f505f9526311e48f828e95d90d488fe237219 (diff)
- 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
Diffstat (limited to 'key.c')
-rw-r--r--key.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/key.c b/key.c
index d474f85c6..be38a88f5 100644
--- a/key.c
+++ b/key.c
@@ -121,8 +121,6 @@ key_equal(Key *a, Key *b)
121 return 0; 121 return 0;
122} 122}
123 123
124#define FPRINT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
125
126/* 124/*
127 * Generate key fingerprint in ascii format. 125 * Generate key fingerprint in ascii format.
128 * Based on ideas and code from Bjoern Groenvall <bg@sics.se> 126 * Based on ideas and code from Bjoern Groenvall <bg@sics.se>
@@ -130,7 +128,7 @@ key_equal(Key *a, Key *b)
130char * 128char *
131key_fingerprint(Key *k) 129key_fingerprint(Key *k)
132{ 130{
133 static char retval[80]; 131 static char retval[(EVP_MAX_MD_SIZE+1)*3];
134 unsigned char *blob = NULL; 132 unsigned char *blob = NULL;
135 int len = 0; 133 int len = 0;
136 int nlen, elen; 134 int nlen, elen;
@@ -151,15 +149,22 @@ key_fingerprint(Key *k)
151 fatal("key_fingerprint: bad key type %d", k->type); 149 fatal("key_fingerprint: bad key type %d", k->type);
152 break; 150 break;
153 } 151 }
152 retval[0] = '\0';
153
154 if (blob != NULL) { 154 if (blob != NULL) {
155 unsigned char d[16]; 155 int i;
156 EVP_MD_CTX md; 156 unsigned char digest[EVP_MAX_MD_SIZE];
157 EVP_DigestInit(&md, EVP_md5()); 157 EVP_MD *md = EVP_md5();
158 EVP_DigestUpdate(&md, blob, len); 158 EVP_MD_CTX ctx;
159 EVP_DigestFinal(&md, d, NULL); 159 EVP_DigestInit(&ctx, md);
160 snprintf(retval, sizeof(retval), FPRINT, 160 EVP_DigestUpdate(&ctx, blob, len);
161 d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], 161 EVP_DigestFinal(&ctx, digest, NULL);
162 d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 162 for(i = 0; i < md->md_size; i++) {
163 char hex[4];
164 snprintf(hex, sizeof(hex), "%02x:", digest[i]);
165 strlcat(retval, hex, sizeof(retval));
166 }
167 retval[strlen(retval) - 1] = '\0';
163 memset(blob, 0, len); 168 memset(blob, 0, len);
164 xfree(blob); 169 xfree(blob);
165 } 170 }