diff keyimport.c @ 73:0bf5cebe622c

Dropbearkey can now print out pubkey portions
author Matt Johnston <matt@ucc.asn.au>
date Sat, 14 Aug 2004 17:35:28 +0000
parents fe6bca95afa7
children 680a0bc9df0a
line wrap: on
line diff
--- a/keyimport.c	Fri Aug 13 10:58:51 2004 +0000
+++ b/keyimport.c	Sat Aug 14 17:35:28 2004 +0000
@@ -109,29 +109,16 @@
 
 	buffer * buf = NULL;
 	int len, maxlen;
-	FILE *fp;
+	FILE *fp = NULL;
 	sign_key *ret = NULL;
 	int type;
 
-	buf = buf_new(2000);
-	/* can't use buf_readfile since we might have "-" as filename */
-	if (strlen(filename) == 1 && filename[0] == '-') {
-		fp = stdin;
-	} else {
-		fp = fopen(filename, "r");
-	}
-	if (!fp) {
+	buf = buf_new(MAX_PRIVKEY_SIZE);
+	/* buf_readfile knows about "-" */
+	if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) {
 		goto error;
 	}
 
-	do {
-		maxlen = buf->size - buf->pos;
-		len = fread(buf_getwriteptr(buf, maxlen), 1, maxlen, fp);
-		buf_incrwritepos(buf, len);
-	} while (len != maxlen && len > 0);
-
-	fclose(fp);
-
 	buf_setpos(buf, 0);
 	ret = new_sign_key();
 
@@ -173,7 +160,7 @@
 	}
 #endif
 
-	buf = buf_new(2000);
+	buf = buf_new(MAX_PRIVKEY_SIZE);
 	buf_put_priv_key(buf, key, keytype);
 
 	if (strlen(filename) == 1 && filename[0] == '-') {