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

This is a discussion on Proposed patch: ssh-keygen allows writing to stdout for moduli within the OpenSSH Development forums, part of the Networking and Network Related category; Hello all, I propose the following patch to ssh-keygen.c for openssh version 4.5. It allows to redirect ...


Go Back   Usenet Forums > Networking and Network Related > OpenSSH Development

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2007
Christian Pfaffel-Janser
 
Posts: n/a
Default Proposed patch: ssh-keygen allows writing to stdout for moduli

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/lis...enssh-unix-dev
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:52 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0