#include "fe-common/core/printtext.h"
#include "fe-common/core/keyboard.h"
-/* Lists supported (builtin) ciphers */
+/* Lists supported ciphers */
void silc_client_list_ciphers()
{
silc_free(ciphers);
}
-/* Lists supported (builtin) hash functions */
+/* Lists supported hash functions */
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()
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();
/* 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
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,
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
{
KeyInternal i = (KeyInternal)context;
- curr_key = NULL;
-
switch(status) {
case SILC_KEY_AGREEMENT_OK:
printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_NOTICES,
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 */
/* 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;
"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 }
};
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);
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) \
/* 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);
}