www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git] / userapps / opensource / sshd / dropbearconvert.c
index bba709e..9e16fe7 100755 (executable)
 
 /* This program converts to/from Dropbear and OpenSSH private-key formats */
 #include "includes.h"
-#include "runopts.h"
 #include "signkey.h"
 #include "buffer.h"
-#include "util.h"
+#include "dbutil.h"
 #include "keyimport.h"
 
 
@@ -39,8 +38,8 @@ static void printhelp(char * progname);
 static void printhelp(char * progname) {
 
        fprintf(stderr, "Usage: %s <inputtype> <outputtype> <inputfile> <outputfile>\n\n"
-                                       "Caution: This program is for convenience only, and is not secure if used on\n"
-                                       "untrusted input files -- don't run this as root on random luser's files :)\n"
+                                       "CAUTION: This program is for convenience only, and is not secure if used on\n"
+                                       "untrusted input files, ie it could allow arbitrary code execution.\n"
                                        "All parameters must be specified in order.\n"
                                        "\n"
                                        "The input and output types are one of:\n"
@@ -48,18 +47,26 @@ static void printhelp(char * progname) {
                                        "dropbear\n"
                                        "\n"
                                        "Example:\n"
-                                       "dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key /etc/dropbear_rsa_host_key\n"
-                                       "\n"
-                                       "The inputfile and output file can be '-' to specify"
-                                       "standard input or standard output.", progname);
+                                       "dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key /etc/dropbear_rsa_host_key\n",
+                                       progname);
 }
 
+#if defined(DBMULTI_dropbearconvert) || !defined(DROPBEAR_MULTI)
+#if defined(DBMULTI_dropbearconvert) && defined(DROPBEAR_MULTI)
+int dropbearconvert_main(int argc, char ** argv) {
+#else 
 int main(int argc, char ** argv) {
+#endif
 
        int intype, outtype;
        const char* infile;
        const char* outfile;
 
+#ifdef DEBUG_TRACE
+       /* It's hard for it to get in the way _too_ much */
+       debug_trace = 1;
+#endif
+
        /* get the commandline options */
        if (argc != 5) {
                fprintf(stderr, "All arguments must be specified\n");
@@ -98,12 +105,13 @@ usage:
        printhelp(argv[0]);
        return 1;
 }
+#endif
 
 static int do_convert(int intype, const char* infile, int outtype,
                const char* outfile) {
 
        sign_key * key = NULL;
-       char * keytype;
+       char * keytype = NULL;
        int ret = 1;
 
        key = import_read(infile, NULL, intype);
@@ -113,7 +121,16 @@ static int do_convert(int intype, const char* infile, int outtype,
                goto out;
        }
 
-       keytype = key->rsakey != NULL ? "RSA" : "DSS";
+#ifdef DROPBEAR_RSA
+       if (key->rsakey != NULL) {
+               keytype = "RSA";
+       }
+#endif
+#ifdef DROPBEAR_DSS
+       if (key->dsskey != NULL) {
+               keytype = "DSS";
+       }
+#endif
 
        fprintf(stderr, "Key is a %s key\n", keytype);