diff dropbearkey.c @ 299:740e782679be ucc-axis-hack

Various changes to compile+kind of run on UCC's axis board. Note that fprintf(stdin -> printf( accounts for many of the changes
author Matt Johnston <matt@ucc.asn.au>
date Sat, 25 Mar 2006 12:57:09 +0000
parents 0cfba3034be5
children
line wrap: on
line diff
--- a/dropbearkey.c	Fri Dec 09 06:10:27 2005 +0000
+++ b/dropbearkey.c	Sat Mar 25 12:57:09 2006 +0000
@@ -64,7 +64,7 @@
 /* Print a help message */
 static void printhelp(char * progname) {
 
-	fprintf(stderr, "Usage: %s -t <type> -f <filename> [-s bits]\n"
+	printf( "Usage: %s -t <type> -f <filename> [-s bits]\n"
 					"Options are:\n"
 					"-t type	Type of key to generate. One of:\n"
 #ifdef DROPBEAR_RSA
@@ -136,7 +136,7 @@
 					break;
 #endif
 				default:
-					fprintf(stderr, "Unknown argument %s\n", argv[i]);
+					printf( "Unknown argument %s\n", argv[i]);
 					printhelp(argv[0]);
 					exit(EXIT_FAILURE);
 					break;
@@ -145,7 +145,7 @@
 	}
 
 	if (!filename) {
-		fprintf(stderr, "Must specify a key filename\n");
+		printf( "Must specify a key filename\n");
 		printhelp(argv[0]);
 		exit(EXIT_FAILURE);
 	}
@@ -157,7 +157,7 @@
 
 	/* check/parse args */
 	if (!typetext) {
-		fprintf(stderr, "Must specify key type\n");
+		printf( "Must specify key type\n");
 		printhelp(argv[0]);
 		exit(EXIT_FAILURE);
 	}
@@ -177,19 +177,19 @@
 #endif
 	}
 	if (keytype == -1) {
-		fprintf(stderr, "Unknown key type '%s'\n", typetext);
+		printf( "Unknown key type '%s'\n", typetext);
 		printhelp(argv[0]);
 		exit(EXIT_FAILURE);
 	}
 
 	if (sizetext) {
 		if (sscanf(sizetext, "%u", &bits) != 1) {
-			fprintf(stderr, "Bits must be an integer\n");
+			printf( "Bits must be an integer\n");
 			exit(EXIT_FAILURE);
 		}
 	
 		if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
-			fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a"
+			printf( "Bits must satisfy 512 <= bits <= 4096, and be a"
 					" multiple of 8\n");
 			exit(EXIT_FAILURE);
 		}
@@ -206,7 +206,7 @@
 	}
 
 
-	fprintf(stderr, "Will output %d bit %s secret key to '%s'\n", keysize*8,
+	printf( "Will output %d bit %s secret key to '%s'\n", keysize*8,
 			typetext, filename);
 
 	/* don't want the file readable by others */
@@ -215,7 +215,7 @@
 	/* now we can generate the key */
 	key = new_sign_key();
 	
-	fprintf(stderr, "Generating key, this may take a while...\n");
+	printf( "Generating key, this may take a while...\n");
 	switch(keytype) {
 #ifdef DROPBEAR_RSA
 		case DROPBEAR_SIGNKEY_RSA:
@@ -228,7 +228,7 @@
 			break;
 #endif
 		default:
-			fprintf(stderr, "Internal error, bad key type\n");
+			printf( "Internal error, bad key type\n");
 			exit(EXIT_FAILURE);
 	}
 
@@ -261,7 +261,7 @@
 	ret = buf_readfile(buf, filename);
 
 	if (ret != DROPBEAR_SUCCESS) {
-		fprintf(stderr, "Failed reading '%s'\n", filename);
+		printf( "Failed reading '%s'\n", filename);
 		goto out;
 	}
 
@@ -271,7 +271,7 @@
 	buf_setpos(buf, 0);
 	ret = buf_get_priv_key(buf, key, &keytype);
 	if (ret == DROPBEAR_FAILURE) {
-		fprintf(stderr, "Bad key in '%s'\n", filename);
+		printf( "Bad key in '%s'\n", filename);
 		goto out;
 	}
 
@@ -308,7 +308,7 @@
 	err = base64_encode(buf_getptr(buf, len), len, base64key, &base64len);
 
 	if (err != CRYPT_OK) {
-		fprintf(stderr, "base64 failed");
+		printf( "base64 failed");
 	}
 
 	typestring = signkey_name_from_type(keytype, &err);
@@ -330,7 +330,7 @@
 
 	fd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 	if (fd < 0) {
-		fprintf(stderr, "Couldn't create new file %s\n", filename);
+		printf( "Couldn't create new file %s\n", filename);
 		perror("Reason");
 		buf_burn(buf);
 		exit(EXIT_FAILURE);
@@ -344,7 +344,7 @@
 			continue;
 		}
 		if (len <= 0) {
-			fprintf(stderr, "Failed writing file '%s'\n",filename);
+			printf( "Failed writing file '%s'\n",filename);
 			perror("Reason");
 			exit(EXIT_FAILURE);
 		}