OpenSSH
[Top] [All Lists]

Proposed patch: ssh-keygen allows writing to stdout for moduli generatio

To: openssh-unix-dev <openssh-unix-dev@mindrot.org>
Subject: Proposed patch: ssh-keygen allows writing to stdout for moduli generation
From: Christian Pfaffel-Janser <christian.pfaffel-janser@SIEMENS.com>
Date: Thu, 01 Mar 2007 14:19:32 +0100
Delivered-to: sp-com-lists@consult.net
Delivered-to: openssh-unix-dev-list1@securepoint.com
Delivered-to: openssh-unix-dev-tmda@mindrot.org
Delivered-to: tmda@mindrot.org
List-archive: <http://lists.mindrot.org/pipermail/openssh-unix-dev>
List-help: <mailto:openssh-unix-dev-request@mindrot.org?subject=help>
List-id: Development of portable OpenSSH <openssh-unix-dev.mindrot.org>
List-post: <mailto:openssh-unix-dev@mindrot.org>
List-subscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=subscribe>
List-unsubscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=unsubscribe>
Old-delivered-to: openssh-unix-dev@mindrot.org
Organization: Siemens AG, PSE SMC BI3
Sender: openssh-unix-dev-bounces+openssh-unix-dev-list1=securepoint.com@mindrot.org
Hello all,

I propose the following patch to ssh-keygen.c for openssh version 4.5.
It allows to redirect output of the moduli operations to stdout, to do
something like e.g.:

$ ssh-keygen -G - -b 2048 | ssh-keygen -T - -f - >moduli

Best regards,

Christian

--- ssh/ssh-keygen.c.old        2007-03-01 12:43:06.000000000 +0100
+++ ssh/ssh-keygen.c    2007-03-01 12:47:32.000000000 +0100
@@ -1270,13 +1270,16 @@ 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));
-                       return (1);
-               }
+               FILE *out;
+               
+               if (strcmp(out_file, "-") != 0) {
+                       if ((out = fopen(out_file, "w")) == NULL) {
+                               fatal("Couldn't open modulus candidate file 
\"%s\": %s",
+                                     out_file, strerror(errno));
+                       }
+               } else 
+                       out = stdout;
+               
                if (bits == 0)
                        bits = DEFAULT_BITS;
                if (gen_candidates(out, memory, bits, start) != 0)
@@ -1287,8 +1290,16 @@ main(int ac, char **av)
 
        if (do_screen_candidates) {
                FILE *in;
-               FILE *out = fopen(out_file, "w");
+               FILE *out;
 
+               if (strcmp(out_file, "-") != 0) {
+                       if ((out = fopen(out_file, "w")) == NULL) {
+                               fatal("Couldn't open moduli file \"%s\": %s",
+                                     out_file, strerror(errno));
+                       }
+               } else 
+                       out = stdout;
+               
                if (have_identity && strcmp(identity_file, "-") != 0) {
                        if ((in = fopen(identity_file, "r")) == NULL) {
                                fatal("Couldn't open modulus candidate "
@@ -1298,10 +1309,6 @@ main(int ac, char **av)
                } else
                        in = stdin;
 
-               if (out == NULL) {
-                       fatal("Couldn't open moduli file \"%s\": %s",
-                           out_file, strerror(errno));
-               }
                if (prime_test(in, out, trials, generator_wanted) != 0)
                        fatal("modulus screening failed");
                return (0);


_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

<Prev in Thread] Current Thread [Next in Thread>