]> andersk Git - openssh.git/blobdiff - ssh-keygen.c
- deraadt@cvs.openbsd.org 2004/09/15 00:46:01
[openssh.git] / ssh-keygen.c
index 4a3cf241a5366677d5f24f766f067165bfd29999..d39e7d8811e9ccc393269eb229d6fcd773b08cc8 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keygen.c,v 1.110 2003/10/14 19:42:10 jakob Exp $");
+RCSID("$OpenBSD: ssh-keygen.c,v 1.117 2004/07/11 17:48:47 deraadt Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/pem.h>
@@ -26,8 +26,7 @@ RCSID("$OpenBSD: ssh-keygen.c,v 1.110 2003/10/14 19:42:10 jakob Exp $");
 #include "bufaux.h"
 #include "pathnames.h"
 #include "log.h"
-#include "readpass.h"
-#include "moduli.h"
+#include "misc.h"
 
 #ifdef SMARTCARD
 #include "scard.h"
@@ -77,14 +76,14 @@ int print_generic = 0;
 char *key_type_name = NULL;
 
 /* argv0 */
-#ifdef HAVE___PROGNAME
 extern char *__progname;
-#else
-char *__progname;
-#endif
 
 char hostname[MAXHOSTNAMELEN];
 
+/* moduli.c */
+int gen_candidates(FILE *, int, int, BIGNUM *);
+int prime_test(FILE *, FILE *, u_int32_t, u_int32_t);
+
 static void
 ask_filename(struct passwd *pw, const char *prompt)
 {
@@ -189,8 +188,8 @@ do_convert_to_ssh2(struct passwd *pw)
 static void
 buffer_get_bignum_bits(Buffer *b, BIGNUM *value)
 {
-       u_int bits = buffer_get_int(b);
-       u_int bytes = (bits + 7) / 8;
+       u_int bignum_bits = buffer_get_int(b);
+       u_int bytes = (bignum_bits + 7) / 8;
 
        if (buffer_len(b) < bytes)
                fatal("buffer_get_bignum_bits: input buffer too small: "
@@ -627,7 +626,7 @@ do_change_passphrase(struct passwd *pw)
  * Print the SSHFP RR.
  */
 static void
-do_print_resource_record(struct passwd *pw, char *hostname)
+do_print_resource_record(struct passwd *pw, char *hname)
 {
        Key *public;
        char *comment = NULL;
@@ -641,7 +640,7 @@ do_print_resource_record(struct passwd *pw, char *hostname)
        }
        public = key_load_public(identity_file, &comment);
        if (public != NULL) {
-               export_dns_rr(hostname, public, stdout, print_generic);
+               export_dns_rr(hname, public, stdout, print_generic);
                key_free(public);
                xfree(comment);
                exit(0);
@@ -797,6 +796,7 @@ main(int ac, char **av)
        int opt, type, fd, download = 0, memory = 0;
        int generator_wanted = 0, trials = 100;
        int do_gen_candidates = 0, do_screen_candidates = 0;
+       int log_level = SYSLOG_LEVEL_INFO;
        BIGNUM *start = NULL;
        FILE *f;
 
@@ -823,7 +823,7 @@ main(int ac, char **av)
        }
 
        while ((opt = getopt(ac, av,
-           "degiqpclBRxXyb:f:t:U:D:P:N:C:r:g:T:G:M:S:a:W:")) != -1) {
+           "degiqpclBRvxXyb:f:t:U:D:P:N:C:r:g:T:G:M:S:a:W:")) != -1) {
                switch (opt) {
                case 'b':
                        bits = atoi(optarg);
@@ -891,6 +891,15 @@ main(int ac, char **av)
                case 'U':
                        reader_id = optarg;
                        break;
+               case 'v':
+                       if (log_level == SYSLOG_LEVEL_INFO)
+                               log_level = SYSLOG_LEVEL_DEBUG1;
+                       else {
+                               if (log_level >= SYSLOG_LEVEL_DEBUG1 &&
+                                   log_level < SYSLOG_LEVEL_DEBUG3)
+                                       log_level++;
+                       }
+                       break;
                case 'r':
                        resource_record_hostname = optarg;
                        break;
@@ -901,18 +910,9 @@ main(int ac, char **av)
                        break;
                case 'a':
                        trials = atoi(optarg);
-                       if (trials < TRIAL_MINIMUM) {
-                               fatal("Minimum primality trials is %d", 
-                                   TRIAL_MINIMUM);
-                       }
                        break;
                case 'M':
                        memory = atoi(optarg);
-                       if (memory != 0 && 
-                          (memory < LARGE_MINIMUM || memory > LARGE_MAXIMUM)) {
-                               fatal("Invalid memory amount (min %ld, max %ld)",
-                                   LARGE_MINIMUM, LARGE_MAXIMUM);
-                       }
                        break;
                case 'G':
                        do_gen_candidates = 1;
@@ -932,6 +932,10 @@ main(int ac, char **av)
                        usage();
                }
        }
+
+       /* reinit */
+       log_init(av[0], log_level, SYSLOG_FACILITY_USER, 1);
+
        if (optind < ac) {
                printf("Too many arguments.\n");
                usage();
@@ -968,7 +972,7 @@ main(int ac, char **av)
 
        if (do_gen_candidates) {
                FILE *out = fopen(out_file, "w");
-               
+
                if (out == NULL) {
                        error("Couldn't open modulus candidate file \"%s\": %s",
                            out_file, strerror(errno));
@@ -987,7 +991,7 @@ main(int ac, char **av)
                if (have_identity && strcmp(identity_file, "-") != 0) {
                        if ((in = fopen(identity_file, "r")) == NULL) {
                                fatal("Couldn't open modulus candidate "
-                                   "file \"%s\": %s", identity_file, 
+                                   "file \"%s\": %s", identity_file,
                                    strerror(errno));
                        }
                } else
This page took 0.064839 seconds and 4 git commands to generate.