From 26f52cd371f9211b6e80996f46bb9356f6b3300f Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 1 Dec 2002 20:21:52 +0000 Subject: [PATCH] Added support setting/using publi key files in CMODE and CUMODE commands. Added support adding public key to invite/ban lists in INVITE and BAN commands. --- CHANGES | 13 ++++ TODO | 4 -- apps/irssi/docs/help/in/ban.in | 7 +++ apps/irssi/docs/help/in/cmode.in | 11 +++- apps/irssi/docs/help/in/cumode.in | 9 +++ apps/irssi/docs/help/in/invite.in | 7 +++ apps/irssi/src/silc/core/client_ops.c | 7 ++- lib/silcclient/command.c | 86 +++++++++++++++++++++++---- 8 files changed, 124 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index e5d68115..2efe070b 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,19 @@ Sun Dec 1 20:48:17 EET 2002 Pekka Riikonen * 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 * Format CMODE +c and +h to display both the mode and the argument diff --git a/TODO b/TODO index e6087a0b..009eebae 100644 --- 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 diff --git a/apps/irssi/docs/help/in/ban.in b/apps/irssi/docs/help/in/ban.in index 2a22e26a..f6b7496a 100644 --- a/apps/irssi/docs/help/in/ban.in +++ b/apps/irssi/docs/help/in/ban.in @@ -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. diff --git a/apps/irssi/docs/help/in/cmode.in b/apps/irssi/docs/help/in/cmode.in index 6f4f25db..6806bea1 100644 --- a/apps/irssi/docs/help/in/cmode.in +++ b/apps/irssi/docs/help/in/cmode.in @@ -24,7 +24,8 @@ option(s). The following modes are available: be provided when joining to the channel. c Set/unset channel's cipher h Set/unset channel's hmac - f Set/unset channel founder authentication. + f [ []] + 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 and is + provided then the 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. diff --git a/apps/irssi/docs/help/in/cumode.in b/apps/irssi/docs/help/in/cumode.in index 2bb44bca..623c7e54 100644 --- a/apps/irssi/docs/help/in/cumode.in +++ b/apps/irssi/docs/help/in/cumode.in @@ -15,11 +15,20 @@ are available: only to remove both modes at once). f [@] + [ []] Set/Unset channel founder. If you are channel founder you can set the channel founder authentication using CMODEc command. + If the and is + provided then the 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 [@] Set/unset channel operator. Requires that diff --git a/apps/irssi/docs/help/in/invite.in b/apps/irssi/docs/help/in/invite.in index 7d11e262..21afbd18 100644 --- a/apps/irssi/docs/help/in/invite.in +++ b/apps/irssi/docs/help/in/invite.in @@ -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. diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 78f0781a..a21963ea 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -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, diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index ed94414d..346554fa 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -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); -- 2.24.0