From: Pekka Riikonen Date: Fri, 14 Jul 2000 06:11:32 +0000 (+0000) Subject: Fixed key-pair generation. X-Git-Tag: SILC.0.1~453 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=75983944db40fd828fb048e7fb85e71f50b13ded;p=silc.git Fixed key-pair generation. --- 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; } diff --git a/apps/silc/silc.c b/apps/silc/silc.c index cdb21b53..68b4a90f 100644 --- a/apps/silc/silc.c +++ b/apps/silc/silc.c @@ -20,6 +20,9 @@ /* * $Id$ * $Log$ + * Revision 1.4 2000/07/14 06:11:32 priikone + * Fixed key-pair generation. + * * Revision 1.3 2000/07/05 06:11:00 priikone * Added ~./silc directory checking, autoloading of keys and * tweaked the key pair generation function. @@ -221,6 +224,13 @@ SILC Secure Internet Live Conferencing, version %s\n", signal(SIGFPE, SIG_DFL); // signal(SIGINT, SIG_IGN); + if (opt_create_keypair == TRUE) { + /* Create new key pair and exit */ + silc_client_create_key_pair(opt_pkcs, opt_bits, + NULL, NULL, NULL, NULL, NULL); + exit(0); + } + /* Default configuration file */ if (!opt_config_file) opt_config_file = strdup(SILC_CLIENT_CONFIG_FILE); @@ -230,13 +240,6 @@ SILC Secure Internet Live Conferencing, version %s\n", if (config == NULL) goto fail; - if (opt_create_keypair == TRUE) { - /* Create new key pair and exit */ - silc_client_create_key_pair(opt_pkcs, opt_bits, - NULL, NULL, NULL, NULL, NULL); - exit(0); - } - /* Read local configuration file */ /* Check ~/.silc directory and public and private keys */