X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=apps%2Fsilc%2Fclientutil.c;fp=apps%2Fsilc%2Fclientutil.c;h=80fafa553fb9cb0a9a3e242ca2890c866022ea1d;hp=6ef0c699f5755a7f713666f439ffe3e02d2bee10;hb=75983944db40fd828fb048e7fb85e71f50b13ded;hpb=f665e89600524575b7dd32936f13b96f3fa550e4 diff --git a/apps/silc/clientutil.c b/apps/silc/clientutil.c index 6ef0c699..80fafa55 100644 --- a/apps/silc/clientutil.c +++ b/apps/silc/clientutil.c @@ -20,6 +20,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2000/07/14 06:11:32 priikone + * Fixed key-pair generation. + * * Revision 1.5 2000/07/12 05:55:50 priikone * Added client_parse_nickname. * @@ -86,7 +89,7 @@ static void silc_print_to_window(WINDOW *win, char *message) void silc_say(SilcClient client, char *msg, ...) { va_list vp; - char message[1024]; + char message[2048]; memset(message, 0, sizeof(message)); strncat(message, "\n*** ", 5); @@ -105,7 +108,7 @@ void silc_say(SilcClient client, char *msg, ...) void silc_print(SilcClient client, char *msg, ...) { va_list vp; - char message[1024]; + char message[2048]; memset(message, 0, sizeof(message)); strncat(message, "\n ", 2); @@ -458,6 +461,7 @@ int silc_client_create_key_pair(char *pkcs_name, int bits, SilcRng rng; unsigned char *key; unsigned int key_len; + char line[256]; char *pkfile = NULL, *prvfile = NULL; if (!pkcs_name || !public_key || !private_key) @@ -497,17 +501,19 @@ New pair of keys will be created. Please, answer to following questions.\n\ if (!identifier) { char *def = silc_client_create_identifier(); - if (identifier) - snprintf(def, sizeof(def), "Public key identifier [%s]: ", def); + memset(line, 0, sizeof(line)); + if (def) + snprintf(line, sizeof(line), "Identifier [%s]: ", def); else - snprintf(def, sizeof(def), - "Public key identifier (eg. UN=priikone, HN=poseidon.pspt.fi, " - "RN=Pekka Riikonen, E=priikone@poseidon.pspt.fi): "); - - again_ident: - identifier = silc_client_get_input(def); - if (!identifier) - goto again_ident; + snprintf(line, sizeof(line), + "Identifier (eg. UN=jon, HN=jon.dummy.com, " + "RN=Jon Johnson, E=jon@dummy.com): "); + + while (!identifier) { + identifier = silc_client_get_input(line); + if (!identifier && def) + identifier = strdup(def); + } if (def) silc_free(def); @@ -518,23 +524,23 @@ New pair of keys will be created. Please, answer to following questions.\n\ silc_math_primegen_init(); if (!public_key) { - again_pk: - pkfile = silc_client_get_input("Public key filename: "); - if (!pkfile) { - printf("Public key filename must be defined\n"); - goto again_pk; - } + memset(line, 0, sizeof(line)); + snprintf(line, sizeof(line), "Public key filename [%s] ", + SILC_CLIENT_PUBLIC_KEY_NAME); + pkfile = silc_client_get_input(line); + if (!pkfile) + pkfile = SILC_CLIENT_PUBLIC_KEY_NAME; } else { pkfile = public_key; } if (!private_key) { - again_prv: - prvfile = silc_client_get_input("Private key filename: "); - if (!prvfile) { - printf("Private key filename must be defined\n"); - goto again_prv; - } + memset(line, 0, sizeof(line)); + snprintf(line, sizeof(line), "Public key filename [%s] ", + SILC_CLIENT_PRIVATE_KEY_NAME); + prvfile = silc_client_get_input(line); + if (!prvfile) + prvfile = SILC_CLIENT_PRIVATE_KEY_NAME; } else { prvfile = private_key; }