Fixed public key saving in WHOIS -details. Get user public key
authorPekka Riikonen <priikone@silcnet.org>
Thu, 25 Jan 2007 17:40:34 +0000 (17:40 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 25 Jan 2007 17:40:34 +0000 (17:40 +0000)
if it is available.

apps/irssi/src/fe-common/silc/fe-silc-messages.c
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-queries.c
apps/irssi/src/silc/core/silc-servers.c

index 475c9e9ef717e6c76d22897a73f1ed20afe65508..acded96f8f617c30e1ed19342f40b73b48bb064f 100644 (file)
@@ -10,7 +10,7 @@
   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.
-  
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -52,7 +52,7 @@ static void sig_signed_message_public(SERVER_REC * server, const char *msg,
                                      int verified)
 {
   CHANNEL_REC *chanrec;
-  NICK_REC *nickrec = NULL; /* we cheat here a little to keep the limit of 
+  NICK_REC *nickrec = NULL; /* we cheat here a little to keep the limit of
                               6 parameters to a signal handler ... */
   const char *nickmode, *printnick;
   int for_me, print_channel, level;
@@ -67,8 +67,8 @@ static void sig_signed_message_public(SERVER_REC * server, const char *msg,
   for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
       nick_match_msg(chanrec, msg, server->nick);
   color = for_me ? NULL :
-      hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC,
-                        msg);
+    (char *)hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC,
+                              msg);
 
   print_channel = chanrec == NULL ||
       !window_item_is_active((WI_ITEM_REC *) chanrec);
@@ -225,7 +225,7 @@ static void sig_signed_message_own_private(SERVER_REC * server,
   g_free_not_null(freemsg);
 }
 
-static void sig_message_own_action_all(SERVER_REC *server, 
+static void sig_message_own_action_all(SERVER_REC *server,
                                        const char *msg, const char *target,
                                        bool is_channel, bool is_signed)
 {
@@ -243,7 +243,7 @@ static void sig_message_own_action_all(SERVER_REC *server,
   printformat(server, target,
              MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
              (is_channel ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
-             item != NULL ? 
+             item != NULL ?
              (is_signed ? SILCTXT_OWN_ACTION_SIGNED : SILCTXT_OWN_ACTION) :
              (is_signed ? SILCTXT_OWN_ACTION_TARGET_SIGNED :
                           SILCTXT_OWN_ACTION_TARGET),
@@ -300,11 +300,11 @@ static void sig_message_action_all(SERVER_REC *server, const char *msg,
     msg = freemsg = expand_emphasis(item, msg);
 
   if (is_channel) {
-    /* channel action */ 
+    /* channel action */
     if (window_item_is_active(item)) {
       /* message to active channel in window */
       printformat(server, target, level,
-                 VERIFIED_MSG2(verified, SILCTXT_ACTION_PUBLIC), 
+                 VERIFIED_MSG2(verified, SILCTXT_ACTION_PUBLIC),
                  nick, target, msg);
     } else {
       /* message to not existing/active channel */
@@ -352,7 +352,7 @@ static void sig_message_private_action_signed(SERVER_REC *server,
   sig_message_action_all(server, msg, nick, address, target, FALSE, verified);
 }
 
-static void sig_message_own_notice_all(SERVER_REC *server, 
+static void sig_message_own_notice_all(SERVER_REC *server,
                                        const char *msg, const char *target,
                                        bool is_signed)
 {
@@ -383,9 +383,9 @@ static void sig_message_notice_all(SERVER_REC *server, const char *msg,
     return;
 
   if (is_channel) {
-    /* channel notice */ 
+    /* channel notice */
       printformat(server, target, MSGLEVEL_NOTICES,
-                 VERIFIED_MSG2(verified, SILCTXT_NOTICE_PUBLIC), 
+                 VERIFIED_MSG2(verified, SILCTXT_NOTICE_PUBLIC),
                  nick, target, msg);
   } else {
     /* private notice */
index bcf4099d1da38a6d9050ef82fa17928cbb258c8b..5cc7807c42696df88002e5ba76a75af8ba47e9f0 100644 (file)
@@ -830,7 +830,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
       silc_client_free_private_message_keys(keys, keys_count);
 
     } else if (type == 2) {
-      int k, len;
+      int len;
       char buf[1024];
 
       ckeys = silc_client_list_channel_private_keys(silc_client, conn,
index 8ef5517250a8041fa8131a555dbea79e2c220ac9..c81ae8626cbac5a25c4144e1835da23f3b37f5ec 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2002 - 2006 Pekka Riikonen
+  Copyright (C) 2002 - 2007 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
@@ -821,12 +821,8 @@ void silc_query_attributes_print(SILC_SERVER_REC *server,
 
   /* Handle the signature verifications and public key verifying here */
 
-  if (usersign.data) {
-    /* Verify the signature now */
-    SilcPublicKey public_key;
+  if (verify->userpk.data) {
     SilcPKCSType type = 0;
-    unsigned char *verifyd;
-    SilcUInt32 verify_len;
 
     if (!strcmp(verify->userpk.type, "silc-rsa"))
       type = SILC_PKCS_SILC;
@@ -837,9 +833,17 @@ void silc_query_attributes_print(SILC_SERVER_REC *server,
     else if (!strcmp(verify->userpk.type, "pgp-sign-rsa"))
       type = SILC_PKCS_OPENPGP;
 
-    if (silc_pkcs_public_key_alloc(type, verify->userpk.data,
-                                  verify->userpk.data_len,
-                                  &verify->public_key)) {
+    silc_pkcs_public_key_alloc(type, verify->userpk.data,
+                              verify->userpk.data_len,
+                              &verify->public_key);
+  }
+
+  if (usersign.data) {
+    /* Verify the signature now */
+    unsigned char *verifyd;
+    SilcUInt32 verify_len;
+
+    if (verify->public_key) {
       verifyd = silc_attribute_get_verify_data(attrs, FALSE, &verify_len);
       if (verifyd && silc_pkcs_verify(verify->public_key,
                                      usersign.data,
@@ -916,7 +920,6 @@ void silc_query_attributes_print(SILC_SERVER_REC *server,
 static void silc_query_attributes_print_final(bool success, void *context)
 {
   AttrVerify verify = context;
-  SilcClient client = verify->client;
   SILC_SERVER_REC *server = verify->server;
   char *format = NULL;
   unsigned char filename[256], *fingerprint = NULL, *tmp;
@@ -969,7 +972,6 @@ static void silc_query_attributes_print_final(bool success, void *context)
 static void silc_query_attributes_accept(const char *line, void *context)
 {
   AttrVerify verify = context;
-  SilcClient client = verify->client;
   SILC_SERVER_REC *server = verify->server;
   struct stat st;
   struct passwd *pw;
@@ -1031,11 +1033,13 @@ static void silc_query_attributes_accept(const char *line, void *context)
     }
 
     /* Save public key */
-    memset(filename2, 0, sizeof(filename2));
-    snprintf(filename2, sizeof(filename2) - 1, "%s/clientkey_%s.pub",
-            filename, fingerprint);
-    silc_pkcs_save_public_key(filename2, verify->public_key,
-                             SILC_PKCS_FILE_BASE64);
+    if (verify->public_key) {
+      memset(filename2, 0, sizeof(filename2));
+      snprintf(filename2, sizeof(filename2) - 1, "%s/clientkey_%s.pub",
+              filename, fingerprint);
+      silc_pkcs_save_public_key(filename2, verify->public_key,
+                               SILC_PKCS_FILE_BASE64);
+    }
 
     /* Save extension data */
     if (verify->extension) {
index d661187088046b4efe3566e2d0695dec40d69bb5..11f1032e06fee5a891aa0dbf5ce04dda627fbf7c 100644 (file)
@@ -223,7 +223,7 @@ void silc_send_mime(SILC_SERVER_REC *server, int channel, const char *to,
   silc_free(unescaped_data);
 }
 
-static int isnickflag_func(char flag)
+static int isnickflag_func(SERVER_REC *server, char flag)
 {
   return flag == '@' || flag == '+';
 }
@@ -233,7 +233,7 @@ static int ischannel_func(SERVER_REC *server, const char *data)
   return FALSE;
 }
 
-const char *get_nick_flags(void)
+const char *get_nick_flags(SERVER_REC *server)
 {
   return "@\0\0";
 }
@@ -292,6 +292,9 @@ static void silc_connect_cb(SilcClient client,
   SILC_SERVER_REC *server = context;
   char *file;
 
+  SILC_LOG_DEBUG(("Connection callback %p, status %d, error %d, message %s",
+                 conn, status, error, message ? message : "N/A"));
+
   server->op = NULL;
 
   switch (status) {