updates.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 27 May 2001 16:20:25 +0000 (16:20 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 27 May 2001 16:20:25 +0000 (16:20 +0000)
apps/irssi/src/silc/core/clientutil.c
apps/irssi/src/silc/core/clientutil.h
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-core.c
apps/irssi/src/silc/core/silc-nicklist.c

index cbd0c1846c8de564f7e6b25c7523ef0a61d82a51..fa7cf6255342f8076201db96fde9fd651dbc8941 100644 (file)
@@ -43,7 +43,7 @@
 #include "fe-common/core/printtext.h"
 #include "fe-common/core/keyboard.h"
 
-/* Lists supported (builtin) ciphers */
+/* Lists supported ciphers */
 
 void silc_client_list_ciphers()
 {
@@ -52,7 +52,7 @@ void silc_client_list_ciphers()
   silc_free(ciphers);
 }
 
-/* Lists supported (builtin) hash functions */
+/* Lists supported hash functions */
 
 void silc_client_list_hash_funcs()
 {
@@ -61,6 +61,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()
@@ -107,14 +116,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();
@@ -124,8 +135,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
index ab7c0208b75654d4c49e3939699e125986d7f055..efd69da009aeb114480966b3c8bb7450cb6cd2bd 100644 (file)
@@ -27,6 +27,7 @@
 char *silc_client_get_input(const char *prompt);
 void silc_client_list_ciphers();
 void silc_client_list_hash_funcs();
+void silc_client_list_hmacs();
 void silc_client_list_pkcs();
 char *silc_client_create_identifier();
 int silc_client_create_key_pair(char *pkcs_name, int bits,
index a19ca5accd3181b8c8eba513048de22ec03afeef..a522bc4b7dc144fee37de5db0e1ec019a448f7f7 100644 (file)
@@ -550,8 +550,6 @@ typedef struct {
   SILC_SERVER_REC *server;
 } *KeyInternal;
 
-static SilcSKEKeyMaterial *curr_key = NULL;
-
 /* Key agreement callback that is called after the key agreement protocol
    has been performed. This is called also if error occured during the
    key agreement protocol. The `key' is the allocated key material and
@@ -569,8 +567,6 @@ static void keyagr_completion(SilcClient client,
 {
   KeyInternal i = (KeyInternal)context;
 
-  curr_key = NULL;
-
   switch(status) {
   case SILC_KEY_AGREEMENT_OK:
     printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_NOTICES,
@@ -741,15 +737,6 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
   if (!strcasecmp(argv[3], "set")) {
     command = 1;
 
-    if (argc == 4) {
-      if (curr_key && type == 1 && client_entry) {
-       silc_client_del_private_message_key(silc_client, conn, client_entry);
-       silc_client_add_private_message_key_ske(silc_client, conn, 
-                                               client_entry, NULL, curr_key);
-       goto out;
-      }
-    }
-
     if (argc >= 5) {
       if (type == 1 && client_entry) {
        /* Set private message key */
index 4cfcd54dde5f3f1755130e273b096bf9e0928cf1..787290ccfa8556807779485a086b857ac37730b3 100644 (file)
 /* Command line option variables */
 static bool opt_create_keypair = FALSE;
 static bool opt_debug = FALSE;
+static bool opt_list_ciphers = FALSE;
+static bool opt_list_hash = FALSE;
+static bool opt_list_hmac = FALSE;
+static bool opt_list_pkcs = FALSE;
+static bool opt_version = FALSE;
 static char *opt_pkcs = NULL;
 static char *opt_keyfile = NULL;
 static int opt_bits = 0;
@@ -180,8 +185,18 @@ void silc_core_init(void)
       "Set the length of the public key pair", "VALUE" },
     { "show-key", 'S', POPT_ARG_STRING, &opt_keyfile, 0, 
       "Show the contents of the public key", "FILE" },
+    { "list-ciphers", 'C', POPT_ARG_NONE, &opt_list_ciphers, 0,
+      "List supported ciphers", NULL },
+    { "list-hash-funcs", 'H', POPT_ARG_NONE, &opt_list_hash, 0,
+      "List supported hash functions", NULL },
+    { "list-hmacs", 'H', POPT_ARG_NONE, &opt_list_hmac, 0,
+      "List supported HMACs", NULL },
+    { "list-pkcs", 'P', POPT_ARG_NONE, &opt_list_pkcs, 0,
+      "List supported PKCSs", NULL },
     { "debug", 'd', POPT_ARG_NONE, &opt_debug, 0,
       "Enable debugging", NULL },
+    { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
+      "Show version", NULL },
     { NULL, '\0', 0, NULL }
   };
 
@@ -215,6 +230,37 @@ void silc_core_init_finish(void)
     exit(0);
   }
 
+  if (opt_list_ciphers) {
+    silc_cipher_register_default();
+    silc_client_list_ciphers();
+    exit(0);
+  }
+
+  if (opt_list_hash) {
+    silc_hash_register_default();
+    silc_client_list_hash_funcs();
+    exit(0);
+  }
+
+  if (opt_list_hmac) {
+    silc_hmac_register_default();
+    silc_client_list_hmacs();
+    exit(0);
+  }
+
+  if (opt_list_pkcs) {
+    silc_pkcs_register_default();
+    silc_client_list_pkcs();
+    exit(0);
+  }
+
+  if (opt_version) {
+    printf("SILC Secure Internet Live Conferencing, version %s\n", 
+          silc_version);
+    printf("(c) 1997 - 2001 Pekka Riikonen <priikone@poseidon.pspt.fi>\n");
+    exit(0); 
+  }
+
   silc_debug = opt_debug;
   silc_log_set_callbacks(silc_log_info, silc_log_warning,
                         silc_log_error, NULL);
index f84d1dd2e7746c6e358c5b3115bf56d35954d3d7..9ffa113822fcda07c193dc2b7a46ee90e30f98f9 100644 (file)
 SILC_NICK_REC *silc_nicklist_insert(SILC_CHANNEL_REC *channel,
                                    SilcChannelUser user, int send_massjoin)
 {
-       SILC_NICK_REC *rec;
+  SILC_NICK_REC *rec;
 
-       g_return_val_if_fail(IS_SILC_CHANNEL(channel), NULL);
-       g_return_val_if_fail(user != NULL, NULL);
+  g_return_val_if_fail(IS_SILC_CHANNEL(channel), NULL);
+  g_return_val_if_fail(user != NULL, NULL);
 
-       rec = g_new0(SILC_NICK_REC, 1);
-       rec->nick = g_strdup(user->client->nickname);
-        rec->host = g_strdup(user->client->username);
-       rec->silc_user = user;
-       rec->unique_id = user->client;
+  rec = g_new0(SILC_NICK_REC, 1);
+  rec->nick = g_strdup(user->client->nickname);
+  rec->host = g_strdup(user->client->username);
+  rec->silc_user = user;
+  rec->unique_id = user->client;
 
-       if (user->mode & SILC_CHANNEL_UMODE_CHANOP) 
-         rec->op = TRUE;
-       if (user->mode & SILC_CHANNEL_UMODE_CHANFO) 
-         rec->founder = TRUE;
-       rec->send_massjoin = send_massjoin;
+  if (user->mode & SILC_CHANNEL_UMODE_CHANOP) 
+    rec->op = TRUE;
+  if (user->mode & SILC_CHANNEL_UMODE_CHANFO) 
+    rec->founder = TRUE;
+  rec->send_massjoin = send_massjoin;
 
-       nicklist_insert(CHANNEL(channel), (NICK_REC *) rec);
-       return rec;
+  nicklist_insert(CHANNEL(channel), (NICK_REC *) rec);
+  return rec;
 }
 
 SILC_NICK_REC *silc_nicklist_find(SILC_CHANNEL_REC *channel,
                                  SilcClientEntry client)
 {
-       return (SILC_NICK_REC *)
-               nicklist_find_unique(CHANNEL(channel),
-                                    client->nickname, client);
+  return (SILC_NICK_REC *)nicklist_find_unique(CHANNEL(channel),
+                                              client->nickname, client);
 }
 
 #define isnickchar(a) \
@@ -66,66 +65,68 @@ SILC_NICK_REC *silc_nicklist_find(SILC_CHANNEL_REC *channel,
 /* Remove all "extra" characters from `nick'. Like _nick_ -> nick */
 char *silc_nick_strip(const char *nick)
 {
-       char *stripped, *spos;
-
-       g_return_val_if_fail(nick != NULL, NULL);
-
-       spos = stripped = g_strdup(nick);
-       while (isnickchar(*nick)) {
-               if (isalnum((int) *nick))
-                       *spos++ = *nick;
-               nick++;
-       }
-       if ((unsigned char) *nick >= 128)
-               *spos++ = *nick; /* just add it so that nicks won't match.. */
-       *spos = '\0';
-       return stripped;
+  char *stripped, *spos;
+
+  g_return_val_if_fail(nick != NULL, NULL);
+  
+  spos = stripped = g_strdup(nick);
+  while (isnickchar(*nick)) {
+    if (isalnum((int) *nick))
+      *spos++ = *nick;
+    nick++;
+  }
+  if ((unsigned char) *nick >= 128)
+    *spos++ = *nick; /* just add it so that nicks won't match.. */
+  *spos = '\0';
+
+  return stripped;
 }
 
 /* Check is `msg' is meant for `nick'. */
 int silc_nick_match(const char *nick, const char *msg)
 {
-       char *stripnick, *stripmsg;
-       int ret, len;
-
-       g_return_val_if_fail(nick != NULL, FALSE);
-       g_return_val_if_fail(msg != NULL, FALSE);
-
-       len = strlen(nick);
-       if (g_strncasecmp(msg, nick, len) == 0 && !isalnum((int) msg[len]))
-               return TRUE;
-
-       stripnick = silc_nick_strip(nick);
-       stripmsg = silc_nick_strip(msg);
-
-       len = strlen(stripnick);
-       ret = len > 0 && g_strncasecmp(stripmsg, stripnick, len) == 0 &&
-               !isalnum((int) stripmsg[len]) &&
-               (unsigned char) stripmsg[len] < 128;
-
-       g_free(stripnick);
-       g_free(stripmsg);
-       return ret;
+  char *stripnick, *stripmsg;
+  int ret, len;
+
+  g_return_val_if_fail(nick != NULL, FALSE);
+  g_return_val_if_fail(msg != NULL, FALSE);
+
+  len = strlen(nick);
+  if (g_strncasecmp(msg, nick, len) == 0 && !isalnum((int) msg[len]))
+    return TRUE;
+  
+  stripnick = silc_nick_strip(nick);
+  stripmsg = silc_nick_strip(msg);
+  
+  len = strlen(stripnick);
+  ret = len > 0 && g_strncasecmp(stripmsg, stripnick, len) == 0 &&
+    !isalnum((int) stripmsg[len]) &&
+    (unsigned char) stripmsg[len] < 128;
+  
+  g_free(stripnick);
+  g_free(stripmsg);
+
+  return ret;
 }
 
 static const char *get_nick_flags(void)
 {
-       static char flags[3] = { '@', '+', '\0' };
-       return flags;
+  static char flags[3] = { '@', '+', '\0' };
+  return flags;
 }
 
 static void sig_connected(SILC_SERVER_REC *server)
 {
-       if (IS_SILC_SERVER(server))
-               server->get_nick_flags = (void *) get_nick_flags;
+  if (IS_SILC_SERVER(server))
+    server->get_nick_flags = (void *) get_nick_flags;
 }
 
 void silc_nicklist_init(void)
 {
-       signal_add("server connected", (SIGNAL_FUNC) sig_connected);
+  signal_add("server connected", (SIGNAL_FUNC) sig_connected);
 }
 
 void silc_nicklist_deinit(void)
 {
-       signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
+  signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
 }