summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/key.c
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-09-10 09:35:38 +0000
committerkris <kris@FreeBSD.org>2000-09-10 09:35:38 +0000
commit24372e6c107e496b6909e6a488fe2303cef77299 (patch)
tree3c5f04df23b54861f107ea20953c1aa478ade5f7 /crypto/openssh/key.c
parent06ca4c9ec0ae64896cd4d42f586cdf3fa0c033ef (diff)
downloadFreeBSD-src-24372e6c107e496b6909e6a488fe2303cef77299.zip
FreeBSD-src-24372e6c107e496b6909e6a488fe2303cef77299.tar.gz
Resolve conflicts and update for OpenSSH 2.2.0
Reviewed by: gshapiro, peter, green
Diffstat (limited to 'crypto/openssh/key.c')
-rw-r--r--crypto/openssh/key.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/crypto/openssh/key.c b/crypto/openssh/key.c
index b91bd21..f83724a 100644
--- a/crypto/openssh/key.c
+++ b/crypto/openssh/key.c
@@ -1,4 +1,14 @@
/*
+ * read_bignum():
+ * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+ *
+ * As far as I am concerned, the code I have written for this software
+ * can be used freely for any purpose. Any derived versions of this
+ * software must be clearly marked as such, and if the derived work is
+ * incompatible with the protocol description in the RFC file, it must be
+ * called by a name other than "ssh" or "Secure Shell".
+ *
+ *
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,11 +19,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Markus Friedl.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -25,12 +30,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-/*
- * read_bignum():
- * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
*/
#include "includes.h"
@@ -43,6 +42,9 @@
#include "dsa.h"
#include "uuencode.h"
+RCSID("$OpenBSD: key.c,v 1.11 2000/09/07 20:27:51 deraadt Exp $");
+RCSID("$FreeBSD$");
+
#define SSH_DSS "ssh-dss"
Key *
@@ -123,8 +125,6 @@ key_equal(Key *a, Key *b)
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>
@@ -132,7 +132,7 @@ key_equal(Key *a, Key *b)
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;
@@ -153,15 +153,22 @@ key_fingerprint(Key *k)
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);
}
@@ -330,3 +337,15 @@ key_type(Key *k)
}
return "unknown";
}
+unsigned int
+key_size(Key *k){
+ switch (k->type) {
+ case KEY_RSA:
+ return BN_num_bits(k->rsa->n);
+ break;
+ case KEY_DSA:
+ return BN_num_bits(k->dsa->p);
+ break;
+ }
+ return 0;
+}
OpenPOWER on IntegriCloud