X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Firssi%2Fsrc%2Fsilc%2Fcore%2Fclientutil.c;h=93b575fe9a5fdc14a38da05166f101a169c7ce1d;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=77607adc6f644c5964424c06b357fb61ec852713;hpb=c3605468d73126ecad0de98e994a68ad6d17adca;p=silc.git diff --git a/apps/irssi/src/silc/core/clientutil.c b/apps/irssi/src/silc/core/clientutil.c index 77607adc..93b575fe 100644 --- a/apps/irssi/src/silc/core/clientutil.c +++ b/apps/irssi/src/silc/core/clientutil.c @@ -2,14 +2,13 @@ client.c - Author: Pekka Riikonen + Author: Pekka Riikonen - Copyright (C) 1997 - 2000 Pekka Riikonen + Copyright (C) 1997 - 2002 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -43,15 +42,7 @@ #include "fe-common/core/printtext.h" #include "fe-common/core/keyboard.h" -/* Asks yes/no from user on the input line. Returns TRUE on "yes" and - FALSE on "no". */ - -void silc_client_ask_yes_no(char *prompt, SIGNAL_FUNC func) -{ - keyboard_entry_redirect(func, prompt, 0, NULL); -} - -/* Lists supported (builtin) ciphers */ +/* Lists supported ciphers */ void silc_client_list_ciphers() { @@ -60,7 +51,7 @@ void silc_client_list_ciphers() silc_free(ciphers); } -/* Lists supported (builtin) hash functions */ +/* Lists supported hash functions */ void silc_client_list_hash_funcs() { @@ -69,6 +60,15 @@ void silc_client_list_hash_funcs() silc_free(hash); } +/* Lists supported hash functions */ + +void silc_client_list_hmacs() +{ + char *hash = silc_hmac_get_supported(); + fprintf(stdout, "%s\n", hash); + silc_free(hash); +} + /* Lists supported PKCS algorithms */ void silc_client_list_pkcs() @@ -115,14 +115,16 @@ char *silc_client_get_input(const char *prompt) char *silc_client_create_identifier() { char *username = NULL, *realname = NULL; - char hostname[256], email[256]; + char *hostname, email[256]; + char *ident; /* Get realname */ realname = silc_get_real_name(); /* Get hostname */ - memset(hostname, 0, sizeof(hostname)); - gethostname(hostname, sizeof(hostname)); + hostname = silc_net_localhost(); + if (!hostname) + return NULL; /* Get username (mandatory) */ username = silc_get_username(); @@ -132,8 +134,14 @@ char *silc_client_create_identifier() /* Create default email address, whether it is right or not */ snprintf(email, sizeof(email), "%s@%s", username, hostname); - return silc_pkcs_encode_identifier(username, hostname, realname, email, - NULL, NULL); + ident = silc_pkcs_encode_identifier(username, hostname, realname, email, + NULL, NULL); + if (realname) + silc_free(realname); + silc_free(hostname); + silc_free(username); + + return ident; } /* Creates new public key and private key pair. This is used only @@ -150,7 +158,7 @@ int silc_client_create_key_pair(char *pkcs_name, int bits, SilcPrivateKey prv_key; SilcRng rng; unsigned char *key; - uint32 key_len; + SilcUInt32 key_len; char line[256]; char *pkfile = NULL, *prvfile = NULL; @@ -295,14 +303,16 @@ int silc_client_check_silc_dir() memset(file_public_key, 0, sizeof(file_public_key)); memset(file_private_key, 0, sizeof(file_private_key)); + identifier = silc_client_create_identifier(); + pw = getpwuid(getuid()); if (!pw) { fprintf(stderr, "silc: %s\n", strerror(errno)); + if (identifier) + silc_free(identifier); return FALSE; } - identifier = silc_client_create_identifier(); - /* We'll take home path from /etc/passwd file to be sure. */ snprintf(filename, sizeof(filename) - 1, "%s/.silc/", pw->pw_dir); snprintf(servfilename, sizeof(servfilename) - 1, "%s/.silc/serverkeys", @@ -342,6 +352,7 @@ int silc_client_check_silc_dir() return FALSE; } +#if 0 /* Check the permissions of the dir */ if ((st.st_mode & 0777) != 0755) { if ((chmod(filename, 0755)) == -1) { @@ -350,6 +361,7 @@ int silc_client_check_silc_dir() return FALSE; } } +#endif } /* @@ -526,6 +538,10 @@ int silc_client_load_keys(SilcClient client) SILC_PKCS_FILE_BIN) == FALSE) return FALSE; + silc_pkcs_alloc(client->public_key->name, &client->pkcs); + silc_pkcs_public_key_set(client->pkcs, client->public_key); + silc_pkcs_private_key_set(client->pkcs, client->private_key); + return TRUE; } @@ -535,9 +551,9 @@ int silc_client_show_key(char *keyfile) { SilcPublicKey public_key; SilcPublicKeyIdentifier ident; - char *fingerprint; + char *fingerprint, *babbleprint; unsigned char *pk; - uint32 pk_len; + SilcUInt32 pk_len; SilcPKCS pkcs; int key_len = 0; @@ -553,6 +569,7 @@ int silc_client_show_key(char *keyfile) pk = silc_pkcs_public_key_encode(public_key, &pk_len); fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); + babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); if (silc_pkcs_alloc(public_key->name, &pkcs)) { key_len = silc_pkcs_public_key_set(pkcs, public_key); @@ -576,10 +593,12 @@ int silc_client_show_key(char *keyfile) if (ident->country) printf("Country : %s\n", ident->country); printf("Fingerprint (SHA1) : %s\n", fingerprint); + printf("Babbleprint (SHA1) : %s\n", babbleprint); fflush(stdout); silc_free(fingerprint); + silc_free(babbleprint); silc_free(pk); silc_pkcs_public_key_free(public_key); silc_pkcs_free_identifier(ident);