Added support setting/using publi key files in CMODE and CUMODE
authorPekka Riikonen <priikone@silcnet.org>
Sun, 1 Dec 2002 20:21:52 +0000 (20:21 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 1 Dec 2002 20:21:52 +0000 (20:21 +0000)
commands.  Added support adding public key to invite/ban lists
in INVITE and BAN commands.

CHANGES
TODO
apps/irssi/docs/help/in/ban.in
apps/irssi/docs/help/in/cmode.in
apps/irssi/docs/help/in/cumode.in
apps/irssi/docs/help/in/invite.in
apps/irssi/src/silc/core/client_ops.c
lib/silcclient/command.c

diff --git a/CHANGES b/CHANGES
index e5d681150da7c2b894c4700cc6e82aabd4d17679..2efe070b104dc08d46b1a0795b480f79bdfaef8b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,19 @@ Sun Dec  1 20:48:17 EET 2002  Pekka Riikonen <priikone@silcnet.org>
        * Fixed CMODE setting in server when founder mode was set.
          Affected file silcd/command.c.  Bug #95.
 
+       * Added support to setting specific public key in CMODE in
+         Irssi SILC client.  Affected file lib/silcclient/command.c.
+
+       * Added support to use specific public key in CUMODE in
+         Irssi SILC Client.  Affected file lib/silcclient/command.c.
+
+       * Added support for inviting and banning by public key in
+         Irssi SILC client.  Affected file lib/silcclient/command.c.
+
+       * Fixed fingerprint/babbleprint showing in invite and ban
+         list command replys.  Affected file is
+         irssi/src/silc/core/client_ops.c.
+
 Sun Dec  1 16:32:03 CET 2002  Jochen Eisinger <c0ffee@penguin-breeder.org>
 
        * Format CMODE +c and +h to display both the mode and the argument
diff --git a/TODO b/TODO
index e6087a0b87ff7491840c5c0d5016c7dedf732cbb..009eebaec3f7175859266210cf2968190397d414 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,10 +1,6 @@
 TODO for Irssi SILC Client 1.0
 ==============================
 
- o Support to set arbitrary pulic key in CMODE.
-
- o INVITE/BAN by public key file.
-
  o Signed message payload handling on UI
 
  o bugs parsing nicknames with @ in NICK_CHANGE
index 2a22e26aad0da00392f9f5b7073ed8ac35ee9757..f6b7496aa9e3f36dbf889949ba5d382264f020d7 100644 (file)
@@ -5,6 +5,9 @@ This command is used to manage the ban list of the channel.
 You must be channel operator to be able to use this command.
 Wildcards may be used with this command.
 
+In ban list it is possible to add nicknames, server name, username,
+hostname or netmask (IP/MASK), and public keys.
+
 Examples:
     /BAN #mychannel +foobar!mr.bar@foo.bar.com
         Adds nickname `foobar' with username `mr.bar' from host
@@ -17,6 +20,10 @@ Examples:
         Adds foo* nicknames from any server with any username from
         *.foobar.com hosts to the ban list on current channel.
 
+    /BAN * +/path/to/public_key.pub
+        Adds the public key from file /path/to/public_key.pub to
+        ban list of the current channel.
+
     /BAN * -looser
         Removes the nickname `looser' from the ban list on current
         channel.
index 6f4f25db9920fb2d29c5d3fa88f55bfa7a383ff3..6806bea14b562dc4f760e9d2dc2b843fb9d0bdd5 100644 (file)
@@ -24,7 +24,8 @@ option(s).  The following modes are available:
                     be provided when joining to the channel.
     c <cipher>      Set/unset channel's cipher
     h <hmac>        Set/unset channel's hmac
-    f               Set/unset channel founder authentication.
+    f [<pubkeyfile> <privkeyfile> [<privkey passphrase>]]
+                    Set/unset channel founder authentication.
                     Channel founder may set this mode so that
                     if the client leaves the channel it can
                     claim the founder rights when it returns
@@ -32,6 +33,14 @@ option(s).  The following modes are available:
                     be permanent channel.  You can claim the
                     founder rights using CUMODE or JOIN commands.
 
+                    If the <pubkeyfile> and <privkeyfile> is
+                    provided then the <pubkeyfile> will the used
+                    as founder public key, and the private key
+                    is used to compute a signature for the SILC
+                    server.  If these are omitted then the default
+                    SILC keypair is used.  Normally you do not need
+                    to provide these arguments.
+
 Multiple modes can be set/unset at once if the modes does not
 require any arguments.  If mode requires an argument then only
 one mode can be set at once.
index 2bb44bcab4e1d5a28883e12b36c17a9a0915fb4d..623c7e548aeaa1409f42fe173c44b34c8f099b36 100644 (file)
@@ -15,11 +15,20 @@ are available:
         only to remove both modes at once).
 
     f <nickname>[@<server>]
+      [<pubkeyfile> <privkeyfile> [<privkey passphrase>]]
 
         Set/Unset channel founder.  If you are channel
         founder you can set the channel founder authentication
         using CMODEc command.
 
+        If the <pubkeyfile> and <privkeyfile> is
+        provided then the <pubkeyfile> will the used
+        as founder public key, and the private key
+        is used to compute a signature for the SILC
+        server.  If these are omitted then the default
+        SILC keypair is used.  Normally you do not need
+        to provide these arguments.
+
     o <nickname>[@<server>]
 
         Set/unset channel operator.  Requires that 
index 7d11e262b80efa6e466c39d1a7901f4b0b01e71e..21afbd1810ad53b59b39cea871f37aa417fd8a9a 100644 (file)
@@ -4,6 +4,9 @@
 This command is used to invite an client to a channel and to manage
 the channel's invite list.  Wildcards may be used with this command.
 
+In invite list it is possible to add nicknames, server name, username,
+hostname or netmask (IP/MASK), and public keys.
+
 Examples:
     /INVITE silc joe
         Invites nickname `joe' to channel 'silc', and adds the client
@@ -17,6 +20,10 @@ Examples:
         Adds nicknames foo* from silcnet.org server from *.foobar.com
         hosts to the invite list of the current channel.
 
+    /INVITE * +/path/to/public_key.pub
+        Adds the public key from file /path/to/public_key.pub to
+        invite list of the current channel.
+
     /INVITE * -joe
         Removes nickname `joe' from the invite list of the current
         channel.
index 78f0781a337cf1e0ca37c70ed957ff82f03d1d89..a21963ea17c5d43a9eaf2a244b98390b99bbcd0d 100644 (file)
@@ -1157,9 +1157,10 @@ void  silc_parse_inviteban_list(SilcClient client,
          /* a public key */
          char *fingerprint, *babbleprint;
 
-         fingerprint = silc_hash_fingerprint(NULL, tmp, len);
-         babbleprint = silc_hash_fingerprint(NULL, tmp, len);
-
+         /* tmp is Public Key Payload, take public key from it. */
+         fingerprint = silc_hash_fingerprint(NULL, tmp + 4, len - 4);
+         babbleprint = silc_hash_babbleprint(NULL, tmp + 4, len - 4);
+         
          printformat_module("fe-common/silc", server,
                             (chanrec ? chanrec->visible_name : NULL),
                             MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_PUBKEY,
index ed94414ddf2e3a23b273f6aab8ffae69e3c7ec41..346554fafd02aeb616f395d99e8716808cc4ae58 100644 (file)
@@ -625,6 +625,7 @@ SILC_CLIENT_CMD_FUNC(invite)
   SilcClientEntry client_entry = NULL;
   SilcChannelEntry channel;
   SilcBuffer buffer, clidp, chidp, args = NULL;
+  SilcPublicKey pubkey = NULL;
   char *nickname = NULL, *name;
   char *invite = NULL;
   unsigned char action[1];
@@ -687,12 +688,19 @@ SILC_CLIENT_CMD_FUNC(invite)
        goto out;
       }
     } else {
-      invite = cmd->argv[2];
-      invite++;
       if (cmd->argv[2][0] == '+')
        action[0] = 0x00;
       else
        action[0] = 0x01;
+
+      /* Check if it is public key file to be added to invite list */
+      if (!silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+                                    SILC_PKCS_FILE_PEM))
+       silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+                                 SILC_PKCS_FILE_BIN);
+      invite = cmd->argv[2];
+      if (!pubkey)
+       invite++;
     }
   }
 
@@ -701,7 +709,15 @@ SILC_CLIENT_CMD_FUNC(invite)
     silc_buffer_format(args,
                       SILC_STR_UI_SHORT(1),
                       SILC_STR_END);
-    args = silc_argument_payload_encode_one(args, invite, strlen(invite), 1);
+    if (pubkey) {
+      chidp = silc_pkcs_public_key_payload_encode(pubkey);
+      args = silc_argument_payload_encode_one(args, chidp->data,
+                                             chidp->len, 2);
+      silc_buffer_free(chidp);
+      silc_pkcs_public_key_free(pubkey);
+    } else {
+      args = silc_argument_payload_encode_one(args, invite, strlen(invite), 1);
+    }
   }
 
   /* Send the command */
@@ -1530,10 +1546,26 @@ SILC_CLIENT_CMD_FUNC(cmode)
       break;
     case 'f':
       if (add) {
+       SilcPublicKey pubkey = cmd->client->public_key;
+       SilcPrivateKey privkey = cmd->client->private_key;
+
        mode |= SILC_CHANNEL_MODE_FOUNDER_AUTH;
        type = 7;
-       auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
-                                                 cmd->client->private_key,
+
+       if (cmd->argc >= 5) {
+         char *pass = "";
+         if (cmd->argc >= 6)
+           pass = cmd->argv[5];
+         if (!silc_load_key_pair(cmd->argv[3], cmd->argv[4], pass,
+                                 NULL, &pubkey, &privkey)) {
+           SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+               "Could not load key pair, check your arguments");
+           COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+           goto out;
+         }
+       }
+
+       auth = silc_auth_public_key_auth_generate(pubkey, privkey,
                                                  cmd->client->rng, 
                                                  cmd->client->sha1hash,
                                                  conn->local_id,
@@ -1683,8 +1715,23 @@ SILC_CLIENT_CMD_FUNC(cumode)
       break;
     case 'f':
       if (add) {
-       auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
-                                                 cmd->client->private_key,
+       SilcPublicKey pubkey = cmd->client->public_key;
+       SilcPrivateKey privkey = cmd->client->private_key;
+
+       if (cmd->argc >= 6) {
+         char *pass = "";
+         if (cmd->argc >= 7)
+           pass = cmd->argv[6];
+         if (!silc_load_key_pair(cmd->argv[4], cmd->argv[5], pass,
+                                 NULL, &pubkey, &privkey)) {
+           SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+               "Could not load key pair, check your arguments");
+           COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+           goto out;
+         }
+       }
+
+       auth = silc_auth_public_key_auth_generate(pubkey, privkey,
                                                  cmd->client->rng,
                                                  cmd->client->sha1hash,
                                                  conn->local_id,
@@ -2006,7 +2053,8 @@ SILC_CLIENT_CMD_FUNC(ban)
   SilcBuffer buffer, chidp, args = NULL;
   char *name, *ban = NULL;
   unsigned char action[1];
-
+  SilcPublicKey pubkey = NULL;
+  
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
     COMMAND_ERROR(SILC_STATUS_ERR_NOT_REGISTERED);
@@ -2044,8 +2092,14 @@ SILC_CLIENT_CMD_FUNC(ban)
     else
       action[0] = 0x01;
 
+    /* Check if it is public key file to be added to invite list */
+    if (!silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+                                  SILC_PKCS_FILE_PEM))
+      silc_pkcs_load_public_key(cmd->argv[2] + 1, &pubkey,
+                               SILC_PKCS_FILE_BIN);
     ban = cmd->argv[2];
-    ban++;
+    if (!pubkey)
+      ban++;
   }
 
   if (ban) {
@@ -2053,7 +2107,15 @@ SILC_CLIENT_CMD_FUNC(ban)
     silc_buffer_format(args,
                       SILC_STR_UI_SHORT(1),
                       SILC_STR_END);
-    args = silc_argument_payload_encode_one(args, ban, strlen(ban), 1);
+    if (pubkey) {
+      chidp = silc_pkcs_public_key_payload_encode(pubkey);
+      args = silc_argument_payload_encode_one(args, chidp->data,
+                                             chidp->len, 2);
+      silc_buffer_free(chidp);
+      silc_pkcs_public_key_free(pubkey);
+    } else {
+      args = silc_argument_payload_encode_one(args, ban, strlen(ban), 1);
+    }
   }
 
   chidp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
@@ -2596,8 +2658,8 @@ void silc_client_commands_register(SilcClient client)
   SILC_CLIENT_CMD(join, JOIN, "JOIN", 9);
   SILC_CLIENT_CMD(motd, MOTD, "MOTD", 2);
   SILC_CLIENT_CMD(umode, UMODE, "UMODE", 2);
-  SILC_CLIENT_CMD(cmode, CMODE, "CMODE", 4);
-  SILC_CLIENT_CMD(cumode, CUMODE, "CUMODE", 5);
+  SILC_CLIENT_CMD(cmode, CMODE, "CMODE", 6);
+  SILC_CLIENT_CMD(cumode, CUMODE, "CUMODE", 9);
   SILC_CLIENT_CMD(kick, KICK, "KICK", 4);
   SILC_CLIENT_CMD(ban, BAN, "BAN", 3);
   SILC_CLIENT_CMD(detach, DETACH, "DETACH", 0);