updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 13 Apr 2001 15:10:20 +0000 (15:10 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 13 Apr 2001 15:10:20 +0000 (15:10 +0000)
CHANGES
apps/silc/client_ops.c
lib/silcclient/client.c
lib/silcclient/client_internal.h
lib/silcclient/client_keyagr.c
lib/silcske/silcske.c

diff --git a/CHANGES b/CHANGES
index 4f4c38f5616ef7000f15a3dd9563bdb57dfb2790..2186b85a0b88e21ef1297205338c1a855c5bba94 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,15 @@
+Fri Apr 13 17:12:46 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added printing of error messages during SKE protocol from the
+         failure packet sent by server during SKE.  Affected file
+         silc/client_ops.c.
+
+       * Removed the client's failure_callback handling with timeout
+         and handle it immediately when received.
+
+       * The SKE library returned wrong type in SUCCESS and FAILURE 
+         packets.  They must be 32 bit MSB not 16 bit MSB.
+
 Fri Apr 13 00:09:08 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Ok, rewrote the logic of the re-key and now it seems to work.
index 985be666d654b7a2dd5b90225b7f254cb4d00aa8..bfd3a2057e3e7c5e0b8c297c83d98d1852fa1a69 100644 (file)
@@ -1195,7 +1195,40 @@ int silc_get_auth_method(SilcClient client, SilcClientConnection conn,
 void silc_failure(SilcClient client, SilcClientConnection conn, 
                  SilcProtocol protocol, void *failure)
 {
+  if (protocol->protocol->type == SILC_PROTOCOL_CLIENT_KEY_EXCHANGE) {
+    SilcSKEStatus status = (SilcSKEStatus)failure;
+    
+    if (status == SILC_SKE_STATUS_BAD_VERSION)
+      silc_say(client, conn, 
+              "You are running incompatible client version (it may be "
+              "too old or too new)");
+    if (status == SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY)
+      silc_say(client, conn, "Server does not support your public key type");
+    if (status == SILC_SKE_STATUS_UNKNOWN_GROUP)
+      silc_say(client, conn, 
+              "Server does not support one of your proposed KE group");
+    if (status == SILC_SKE_STATUS_UNKNOWN_CIPHER)
+      silc_say(client, conn, 
+              "Server does not support one of your proposed cipher");
+    if (status == SILC_SKE_STATUS_UNKNOWN_PKCS)
+      silc_say(client, conn, 
+              "Server does not support one of your proposed PKCS");
+    if (status == SILC_SKE_STATUS_UNKNOWN_HASH_FUNCTION)
+      silc_say(client, conn, 
+              "Server does not support one of your proposed hash function");
+    if (status == SILC_SKE_STATUS_UNKNOWN_HMAC)
+      silc_say(client, conn, 
+              "Server does not support one of your proposed HMAC");
+    if (status == SILC_SKE_STATUS_INCORRECT_SIGNATURE)
+      silc_say(client, conn, "Incorrect signature");
+  }
 
+  if (protocol->protocol->type == SILC_PROTOCOL_CLIENT_CONNECTION_AUTH) {
+    uint32 err = (uint32)failure;
+
+    if (err == SILC_AUTH_FAILED)
+      silc_say(client, conn, "Authentication failed");
+  }
 }
 
 /* Asks whether the user would like to perform the key agreement protocol.
index 50445d004a888aa7a3b1a638089abd2ebea723c3..52cda1dd3c24d96649a4da8cd8f1ae8ca8203892 100644 (file)
@@ -434,8 +434,6 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_second)
     if (ctx->dest_id)
       silc_free(ctx->dest_id);
     ctx->sock->protocol = NULL;
-    silc_task_unregister_by_callback(client->timeout_queue,
-                                    silc_client_failure_callback);
 
     /* Notify application of failure */
     client->ops->connect(client, ctx->sock->user_data, FALSE);
@@ -521,8 +519,6 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
     if (ctx->dest_id)
       silc_free(ctx->dest_id);
     conn->sock->protocol = NULL;
-    silc_task_unregister_by_callback(client->timeout_queue,
-                                    silc_client_failure_callback);
 
     /* Notify application of failure */
     client->ops->connect(client, ctx->sock->user_data, FALSE);
@@ -564,8 +560,6 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
                     (void *)conn->sock, conn->rekey->timeout, 0,
                     SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
 
-  silc_task_unregister_by_callback(client->timeout_queue,
-                                  silc_client_failure_callback);
   silc_protocol_free(protocol);
   if (ctx->auth_data)
     silc_free(ctx->auth_data);
@@ -1626,30 +1620,6 @@ char *silc_client_chumode_char(uint32 mode)
   return strdup(string);
 }
 
-/* Failure timeout callback. If this is called then we will immediately
-   process the received failure. We always process the failure with timeout
-   since we do not want to blindly trust to received failure packets. 
-   This won't be called (the timeout is cancelled) if the failure was
-   bogus (it is bogus if remote does not close the connection after sending
-   the failure). */
-
-SILC_TASK_CALLBACK_GLOBAL(silc_client_failure_callback)
-{
-  SilcClientFailureContext *f = (SilcClientFailureContext *)context;
-
-  if (f->sock->protocol) {
-    f->sock->protocol->state = SILC_PROTOCOL_STATE_FAILURE;
-    f->sock->protocol->execute(f->client->timeout_queue, 0,
-                              f->sock->protocol, f->sock->sock, 0, 0);
-    
-    /* Notify application */
-    f->client->ops->failure(f->client, f->sock->user_data, f->sock->protocol,
-                           (void *)f->failure);
-  }
-
-  silc_free(f);
-}
-
 /* Registers failure timeout to process the received failure packet
    with timeout. */
 
@@ -1657,22 +1627,15 @@ void silc_client_process_failure(SilcClient client,
                                 SilcSocketConnection sock,
                                 SilcPacketContext *packet)
 {
-  SilcClientFailureContext *f;
   uint32 failure = 0;
 
   if (sock->protocol) {
     if (packet->buffer->len >= 4)
       SILC_GET32_MSB(failure, packet->buffer->data);
 
-    f = silc_calloc(1, sizeof(*f));
-    f->client = client;
-    f->sock = sock;
-    f->failure = failure;
-
-    /* We will wait 5 seconds to process this failure packet */
-    silc_task_register(client->timeout_queue, sock->sock,
-                      silc_client_failure_callback, (void *)f, 5, 0,
-                      SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+    /* Notify application */
+    client->ops->failure(client, sock->user_data, sock->protocol,
+                        (void *)failure);
   }
 }
 
index dadf8f728b28f49560bf00954d25a42bae5a184f..53b03ab2f475cfe39cae74a76c4404b8bdea6c90 100644 (file)
@@ -52,19 +52,9 @@ struct SilcClientAwayStruct {
   struct SilcClientAwayStruct *next;
 };
 
-/* Failure context. This is allocated when failure packet is received.
-   Failure packets are processed with timeout and data is saved in this
-   structure. */
-typedef struct {
-  SilcClient client;
-  SilcSocketConnection sock;
-  uint32 failure;
-} SilcClientFailureContext;
-
 /* Protypes */
 
 SILC_TASK_CALLBACK_GLOBAL(silc_client_packet_process);
-SILC_TASK_CALLBACK_GLOBAL(silc_client_failure_callback);
 int silc_client_packet_send_real(SilcClient client,
                                 SilcSocketConnection sock,
                                 bool force_send,
index 9191edd623036e2ff302be70dbc485f786f33386..e05db76c043fbfa45c04351d709fb3b80d4794e8 100644 (file)
@@ -119,8 +119,6 @@ SILC_TASK_CALLBACK(silc_client_key_agreement_final)
     silc_ske_free(ctx->ske);
   if (ctx->dest_id)
     silc_free(ctx->dest_id);
-  silc_task_unregister_by_callback(client->timeout_queue,
-                                  silc_client_failure_callback);
   silc_task_unregister_by_fd(client->io_queue, ke->fd);
   silc_schedule_unset_listen_fd(ke->fd);
   silc_net_close_connection(ke->fd);
@@ -245,8 +243,6 @@ SILC_TASK_CALLBACK(silc_client_key_agreement_timeout)
     silc_socket_free(ke->sock);
   }
   ke->client_entry->ke = NULL;
-  silc_task_unregister_by_callback(ke->client->timeout_queue,
-                                  silc_client_failure_callback);
   if (ke->fd)
     silc_task_unregister_by_fd(ke->client->io_queue, ke->fd);
   silc_schedule_unset_listen_fd(ke->fd);
index 852ad4fd2cd5e9dfbbb19f123f784c409afebe00..3fef422210bcd3fba9afb023b94889c95c721b85 100644 (file)
@@ -810,7 +810,7 @@ SilcSKEStatus silc_ske_end(SilcSKE ske,
   packet = silc_buffer_alloc(4);
   silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
   silc_buffer_format(packet,
-                    SILC_STR_UI_SHORT(SILC_SKE_STATUS_OK),
+                    SILC_STR_UI_INT((uint32)SILC_SKE_STATUS_OK),
                     SILC_STR_END);
 
   if (send_packet)
@@ -836,7 +836,7 @@ SilcSKEStatus silc_ske_abort(SilcSKE ske, SilcSKEStatus status,
   packet = silc_buffer_alloc(4);
   silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
   silc_buffer_format(packet,
-                    SILC_STR_UI_SHORT(status),
+                    SILC_STR_UI_INT((uint32)status),
                     SILC_STR_END);
 
   if (send_packet)