From: Pekka Riikonen Date: Mon, 26 Feb 2001 17:32:08 +0000 (+0000) Subject: updates. X-Git-Tag: 1.2.beta1~2494 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=8fb7b5c889c5ec7f284f74dc68ce62553ed8f600;p=crypto.git updates. --- diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 418b5b12..2361f87f 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -2988,7 +2988,7 @@ SILC_SERVER_CMD_FUNC(connect) unsigned int tmp_len; unsigned int port = SILC_PORT; - SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_CONNECT, cmd, 1, 2); + SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_CONNECT, cmd, 0, 0); if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT) goto out; @@ -3048,7 +3048,7 @@ SILC_SERVER_CMD_FUNC(close) unsigned char *name; unsigned int port = SILC_PORT; - SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_CLOSE, cmd, 1, 2); + SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_CLOSE, cmd, 0, 0); if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT) goto out; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 89043217..5db18ef6 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -2334,8 +2334,7 @@ void silc_server_create_channel_key(SilcServer server, unsigned int len; if (!channel->channel_key) - if (!silc_cipher_alloc("aes-256-cbc", &channel->channel_key)) - return; + silc_cipher_alloc("aes-256-cbc", &channel->channel_key); if (key_len) len = key_len; diff --git a/apps/silcd/testi2.conf b/apps/silcd/testi2.conf index 50064d06..674f0cfa 100644 --- a/apps/silcd/testi2.conf +++ b/apps/silcd/testi2.conf @@ -3,7 +3,7 @@ aes-256-cbc:../lib/silcsim/modules/aes.sim.so:32:16 aes-192-cbc:../lib/silcsim/modules/aes.sim.so:24:16 aes-128-cbc:../lib/silcsim/modules/aes.sim.so:16:16 twofish-256-cbc:../lib/silcsim/modules/twofish.sim.so:32:16 -twofish-192-cbc:../lib/silcsim/modules/twofish.sim.so:24:16 +twofish-192-cbc:../lib/silcsim/modules/twofish.sim.so:24:16 twofish-128-cbc:../lib/silcsim/modules/twofish.sim.so:16:16 mars-256-cbc:../lib/silcsim/modules/mars.sim.so:32:16 mars-192-cbc:../lib/silcsim/modules/mars.sim.so:24:16 @@ -25,10 +25,10 @@ nobody:nobody Mun huone:Mun servo:Pekka Riikonen:priikone@poseidon.pspt.fi [ServerInfo] -lassi.kuo.fi.ssh.com:212.146.42.253:Kuopio, Finland:1334 +lassi.kuo.fi.ssh.com:10.2.1.7:Kuopio, Finland:1334 [ListenPort] -212.146.42.253:212.146.42.253:1334 +10.2.1.7:10.2.1.7:1334 [Logging] infologfile:silcd2.log:10000 @@ -49,10 +49,10 @@ errorlogfile:silcd2.log:10000 [AdminConnection] [ServerConnection] -212.146.42.253:passwd:priikone:1333:1:1 +10.2.1.7:passwd:priikone:1333:1:1 [RouterConnection] -212.146.42.253:passwd:priikone:1335:1:1:0 +10.2.1.7:passwd:priikone:1335:1:1:0 [DenyConnection] [RedirectClient] diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index b4f46104..08b643ea 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -970,7 +970,6 @@ void silc_client_packet_send_to_channel(SilcClient client, SilcCipher cipher; SilcHmac hmac; unsigned char *id_string; - unsigned int block_len; SILC_LOG_DEBUG(("Sending packet to channel")); @@ -981,15 +980,14 @@ void silc_client_packet_send_to_channel(SilcClient client, } /* Generate IV */ - block_len = silc_cipher_get_block_len(channel->channel_key); if (channel->iv[0] == '\0') - for (i = 0; i < block_len; i++) channel->iv[i] = silc_rng_get_byte(client->rng); + for (i = 0; i < 16; i++) channel->iv[i] = silc_rng_get_byte(client->rng); else - silc_hash_make(client->md5hash, channel->iv, block_len, channel->iv); + silc_hash_make(client->md5hash, channel->iv, 16, channel->iv); /* Encode the channel payload */ - payload = silc_channel_payload_encode(data_len, data, block_len, - channel->iv, client->rng); + payload = silc_channel_payload_encode(data_len, data, 16, channel->iv, + client->rng); if (!payload) { client->ops->say(client, conn, "Error: Could not create packet to be sent to channel"); @@ -1030,10 +1028,13 @@ void silc_client_packet_send_to_channel(SilcClient client, packetdata.buffer = sock->outbuf; + SILC_LOG_HEXDUMP(("IV"), channel->iv, 16); + SILC_LOG_HEXDUMP(("channel key"), channel->key, channel->key_len/8); + /* Encrypt payload of the packet. This is encrypted with the channel key. */ channel->channel_key->cipher->encrypt(channel->channel_key->context, payload->data, payload->data, - payload->len - block_len, /* -IV_LEN */ + payload->len - 16, /* -IV_LEN */ channel->iv); /* Put the actual encrypted payload data into the buffer. */ @@ -2068,7 +2069,6 @@ void silc_client_channel_message(SilcClient client, SilcIDCacheEntry id_cache = NULL; SilcClientID *client_id = NULL; int found = FALSE; - unsigned int block_len; /* Sanity checks */ if (packet->dst_id_type != SILC_ID_CHANNEL) @@ -2089,14 +2089,20 @@ void silc_client_channel_message(SilcClient client, channel = (SilcChannelEntry)id_cache->context; + SILC_LOG_HEXDUMP(("channel key"), channel->key, channel->key_len); + /* Decrypt the channel message payload. Push the IV out of the way, since it is not encrypted (after pushing buffer->tail has the IV). */ - block_len = silc_cipher_get_block_len(channel->channel_key); - silc_buffer_push_tail(buffer, block_len); + SILC_LOG_HEXDUMP(("Packet"), buffer->data, buffer->len); + silc_buffer_push_tail(buffer, channel->channel_key->cipher->block_len); + SILC_LOG_HEXDUMP(("Packet"), buffer->data, buffer->len); + SILC_LOG_HEXDUMP(("IV"), buffer->tail, 16); channel->channel_key->cipher->decrypt(channel->channel_key->context, buffer->data, buffer->data, buffer->len, buffer->tail); - silc_buffer_pull_tail(buffer, block_len); + SILC_LOG_HEXDUMP(("Packet"), buffer->data, buffer->len); + silc_buffer_pull_tail(buffer, channel->channel_key->cipher->block_len); + SILC_LOG_HEXDUMP(("Packet"), buffer->data, buffer->len); /* Parse the channel message payload */ payload = silc_channel_payload_parse(buffer); diff --git a/lib/silccrypt/silccipher.c b/lib/silccrypt/silccipher.c index 0c8b6c77..8162abd9 100644 --- a/lib/silccrypt/silccipher.c +++ b/lib/silccrypt/silccipher.c @@ -200,7 +200,7 @@ int silc_cipher_alloc(const unsigned char *name, SilcCipher *new_cipher) c = c->next; } - if (!c || !c->cipher->context_len) + if (!c) goto check_builtin; /* Set the pointers */ @@ -222,7 +222,6 @@ int silc_cipher_alloc(const unsigned char *name, SilcCipher *new_cipher) if (silc_cipher_builtin_list[i].name == NULL) { silc_free(*new_cipher); - *new_cipher = NULL; return FALSE; }