summaryrefslogtreecommitdiffstats
path: root/fingerprint.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-11-17 17:29:08 +1100
committerDamien Miller <djm@mindrot.org>1999-11-17 17:29:08 +1100
commit10f6f6ba9ee14d306f8780edee8a10640c1643e0 (patch)
tree859600c705d582b147162d73746cb2f39b59ed58 /fingerprint.c
parentd743bba481056ba3d1c229c18fd42c6bdc3f8d74 (diff)
- Merged OpenBSD CVS changes
- [ChangeLog.Ylonen] noone needs this anymore - [authfd.c] close-on-exec for auth-socket, ok deraadt - [hostfile.c] in known_hosts key lookup the entry for the bits does not need to match, all the information is contained in n and e. This solves the problem with buggy servers announcing the wrong modulus length. markus and me. - [serverloop.c] bugfix: check for space if child has terminated, from: iedowse@maths.tcd.ie - [ssh-add.1 ssh-add.c ssh-keygen.1 ssh-keygen.c sshconnect.c] [fingerprint.c fingerprint.h] rsa key fingerprints, idea from Bjoern Groenvall <bg@sics.se> - [ssh-agent.1] typo - [ssh.1] add OpenSSH information to AUTHOR section. okay markus@ - [sshd.c] force logging to stderr while loading private key file (lost while converting to new log-levels)
Diffstat (limited to 'fingerprint.c')
-rw-r--r--fingerprint.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/fingerprint.c b/fingerprint.c
new file mode 100644
index 00000000..c319fa23
--- /dev/null
+++ b/fingerprint.c
@@ -0,0 +1,39 @@
+#include "includes.h"
+RCSID("$Id: fingerprint.c,v 1.1 1999/11/16 22:49:28 markus Exp $");
+
+#include "ssh.h"
+#include "xmalloc.h"
+#include <ssl/md5.h>
+
+#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> */
+
+char *
+fingerprint(BIGNUM *e, BIGNUM *n)
+{
+ static char retval[80];
+ MD5_CTX md;
+ unsigned char d[16];
+ char *buf;
+ int nlen, elen;
+
+ nlen = BN_num_bytes(n);
+ elen = BN_num_bytes(e);
+
+ buf = xmalloc(nlen + elen);
+
+ BN_bn2bin(n, buf);
+ BN_bn2bin(e, buf + nlen);
+
+ MD5_Init(&md);
+ MD5_Update(&md, buf, nlen + elen);
+ MD5_Final(d, &md);
+ 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]);
+ memset(buf, 0, nlen + elen);
+ xfree(buf);
+ return retval;
+}