updates.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 1 Dec 2001 21:44:32 +0000 (21:44 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 1 Dec 2001 21:44:32 +0000 (21:44 +0000)
CHANGES
TODO
apps/silcd/packet_receive.c
apps/silcd/server.c
lib/silcclient/silcapi.h
lib/silccrypt/silcdh.h
lib/silcmath/mp_gmp.c
lib/silcmath/mp_mpi.c
lib/silcske/payload.c
lib/silcske/silcske.c

diff --git a/CHANGES b/CHANGES
index 4cbc242e052e97ee31d2eb1dd6b178e8b1b40fe6..88a533cf149eb42d052030fba6d31f9de096ee3d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -33,7 +33,7 @@ Thu Nov 29 19:31:23 EET 2001  Pekka Riikonen <priikone@silcnet.org>'
          file configure.in.pre.
 
        * The silc_thread_create now calls the start function
-         directly if threads support is not compiled in.  Removes
+         directly if threads support is not compiled in.  Removes
          ugly #ifdef's from generic code.  Affected files are
          lib/silcutil/unix/silcunixthread, win32/silcwin32thread.c.
 
diff --git a/TODO b/TODO
index 9c8eb3f71ea1b808652bffd636028fe59a63da59..00e588d83f157dab93afd359fccdec21cfc4a7df 100644 (file)
--- a/TODO
+++ b/TODO
@@ -41,6 +41,8 @@ TODO/bugs In SILC Client Library
 TODO/bugs In SILC Server
 ========================
 
+ o XXXXXXXXX cannot join +a channel from other servers
+
  o Implement the <founder auth> and founder privileges gaining to
    the JOIN command.  This will bypass invite-only mode as well for
    the client who got the founder mode during JOIN.
@@ -126,6 +128,9 @@ TODO After 1.0
    not in distribution), but it is not used yet, and it requires some
    tweaking on the Makefiles (we want static lib not shared).
 
+ o Implement the defined SilcDH API.  The definition is in
+   lib/silccrypt/silcdh.h.
+
  o Add builtin SOCKS and HTTP Proxy support, well the SOCKS at least.
    SILC currently supports SOCKS4 and SOCKS5 but it needs to be compiled
    in separately.
@@ -145,11 +150,10 @@ TODO After 1.0
    to start writing one myself.  Anyhow, the OpenSSL X.509 lib should
    be checked.
 
-   Other package that should be checked is the NSS's X509 library.
+   Other package that should be checked is the NSS's X509 library,
+   which I like more over OpenSSL package.
 
- o SSH2 public keys support.  Maybe - not really needed but could be
-   nice as SSH is widely used all over the place.  SILC Protocol 
-   supports SSH2 public keys.
+ o SSH2 public keys support.
 
  o OpenPGP certificate support.
 
index f09bccb6dc4d7910c847e52d2d79001dc20ec545..f5cd5d20c3a3c8a13feed1878bce389c8acbbea2 100644 (file)
@@ -1444,7 +1444,6 @@ SilcClientEntry silc_server_new_client(SilcServer server,
   SilcClientID *client_id;
   SilcBuffer reply;
   SilcIDListData idata;
-  SilcIDCacheEntry id_cache = NULL;
   char *username = NULL, *realname = NULL, *id_string;
   uint32 id_len;
   int ret;
index 86b0a3dc048bb11b5ff537dd8cbbd69855c388d9..22af66f580e2b078d4e77b6723dfbb1293cceaa5 100644 (file)
@@ -602,6 +602,8 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_retry)
   if (sconn->retry_count > server->params->retry_count && 
       server->params->retry_keep_trying == FALSE) {
     SILC_LOG_ERROR(("Could not connect to router, giving up"));
+    silc_free(sconn->remote_host);
+    silc_free(sconn);
     return;
   }
 
@@ -993,6 +995,7 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_final)
     silc_packet_context_free(ctx->packet);
   if (ctx->ske)
     silc_ske_free(ctx->ske);
+  silc_free(ctx->auth_data);
   silc_free(ctx);
 }
 
index 03387ebfc8818f64a8489d6a05a1d6b92e03e544..cb48fd93d419037555bb0cbfc2c88aafa0299b4a 100644 (file)
@@ -1788,16 +1788,44 @@ silc_client_request_authentication_method(SilcClient client,
                                          SilcConnectionAuthRequest callback,
                                          void *context);
 
+/****d* silcclient/SilcClientAPI/SilcClientMonitorStatus
+ *
+ * NAME
+ *
+ *    typedef enum { ... } SilcClientMonitorStatus;
+ *
+ * DESCRIPTION
+ *
+ *    File transmission session status types.  These will indicate
+ *    the status of the file transmission session.
+ *
+ * SOURCE
+ */
 typedef enum {
-  SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT,
-  SILC_CLIENT_FILE_MONITOR_SEND,
-  SILC_CLIENT_FILE_MONITOR_RECEIVE,
+  SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT,    /* In key agreemenet phase */
+  SILC_CLIENT_FILE_MONITOR_SEND,            /* Sending file */
+  SILC_CLIENT_FILE_MONITOR_RECEIVE,         /* Receiving file */
   SILC_CLIENT_FILE_MONITOR_GET,
   SILC_CLIENT_FILE_MONITOR_PUT,
-  SILC_CLIENT_FILE_MONITOR_CLOSED,
-  SILC_CLIENT_FILE_MONITOR_ERROR,
+  SILC_CLIENT_FILE_MONITOR_CLOSED,          /* Session closed */
+  SILC_CLIENT_FILE_MONITOR_ERROR,           /* Error during session */
 } SilcClientMonitorStatus;
+/***/
 
+/****d* silcclient/SilcClientAPI/SilcClientFileError
+ *
+ * NAME
+ *
+ *    typedef enum { ... } SilcClientFileError;
+ *
+ * DESCRIPTION
+ *
+ *    File transmission error types.  These types are returned by
+ *    some of the file transmission functions, and by the monitor
+ *    callback to indicate error.
+ *
+ * SOURCE
+ */
 typedef enum {
   SILC_CLIENT_FILE_OK,
   SILC_CLIENT_FILE_ERROR,
@@ -1806,8 +1834,9 @@ typedef enum {
   SILC_CLIENT_FILE_NO_SUCH_FILE,
   SILC_CLIENT_FILE_PERMISSION_DENIED,
 } SilcClientFileError;
+/***/
 
-/****f* silcclient/SilcClientAPI/silc_client_file_receive
+/****f* silcclient/SilcClientAPI/SilcClientFileMonitor
  *
  * SYNOPSIS
  *
@@ -1826,10 +1855,12 @@ typedef enum {
  *
  *    Monitor callback that is called during the file transmission to
  *    monitor the transmission process.  The `status' indicates the current
- *    monitoring process.  The `offset' is the currently transmitted amount
- *    of total `filesize'.  The `client_entry' indicates the remote client,
- *    and the transmission session ID is the `session_id'.  The filename
- *    being transmitted is indicated by the `filepath'.
+ *    monitoring process.  The `error' will indicate the error type
+ *    if `status' is SILC_CLIENT_FILE_MONITOR_ERROR.  The `offset' is the
+ *    currently transmitted amount of total `filesize'.  The `client_entry'
+ *    indicates the remote client, and the transmission session ID is the 
+ *    `session_id'.  The filename being transmitted is indicated by the 
+ *    `filepath'.
  *
  ***/
 typedef void (*SilcClientFileMonitor)(SilcClient client,
index 68d36764c48c7d332f11efbb82d062a774738dd3..1f90ba3d51855f93ebf417ee2bfbd2bee4bc5d65 100644 (file)
@@ -1,36 +1,35 @@
+/*
+
+  silcdh.h 
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2001 Pekka Riikonen
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
 /****h* silccrypt/SilcDH/silcdh.h
- *
- * NAME
- *
- * silcdh.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
- *
- * Copyright (C) 2001 Pekka Riikonen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  *
  * DESCRIPTION
  *
  * PKCS #3 compliant Diffie Hellman key agreement protocol implementation.
  * This is used as part of SKE (SILC Key Exchange) protocol.
+ *
  ***/
 
 #ifndef SILCDH_H
 #define SILCDH_H
 
 #include "silcmp.h"
-#include "silcrng.h"
 
 /****s* silccrypt/SilcDH/SilcDH
  *
@@ -50,35 +49,33 @@ typedef struct SilcDHStruct *SilcDH;
 /* Diffie Hellman context. This includes the DH parameters including the
    negotiated key material. */
 struct SilcDHStruct {
-  SilcMPInt *g;             /* Global base (generator) */
-  SilcMPInt *p;                  /* Global prime (modulus, prime) */
-  SilcMPInt *lpf;                /* Largest prime factor (prime) */
-  SilcMPInt *my_x;               /* x, My private value (random) */
-  SilcMPInt *my_y;               /* y, My public value (y = g ^ x mod p) */
-  SilcMPInt *your_y;     /* y', Your public value (y' = g ^ x' mod p) */
-  SilcMPInt *z;                  /* The computed secret key (z = y' ^ x mod p) */
-
-  SilcRng rng;           /* RNG */
+  SilcMPInt *g;                     /* Global base (generator) */
+  SilcMPInt *p;                     /* Global prime (modulus, prime) */
+  SilcMPInt *lpf;           /* Largest prime factor (prime) */
+  SilcMPInt *my_x;          /* x, My private value (random) */
+  SilcMPInt *my_y;          /* y, My public value (y = g ^ x mod p) */
+  SilcMPInt *your_y;        /* y', Your public value (y' = g ^ x' mod p) */
+  SilcMPInt *z;                     /* The computed secret key (z = y' ^ x mod p) */
 };
 
 /****f* silccrypt/SilcDH/silc_dh_alloc
  *
  * SYNOPSIS
  *    
- *    SilcDH silc_dh_alloc(SilcRng rng, SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf);
+ *    SilcDH silc_dh_alloc(SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf);
  * 
  * DESCRIPTION
  *
- *    Allocate SilcDH context. The `rng' must be initialized random number 
- *    generator context, the `g' is the public base generator used in the 
- *    negotiation, the `p' is the public prime used in the negotiation and
- *    the `lpf' is largest prime factor of p defined publicly as well. The
- *    `lpf' is optional and if it is not supplied then the private values
- *    generated satifies 0 < x < p - 1 instead of 0 < x < lpf. Returns NULL
- *    on error or allocated SilcDH context on success. 
+ *    Allocate SilcDH context. The `g' is the public base generator used
+ *    in the negotiation, the `p' is the public prime used in the
+ *    negotiation and the `lpf' is largest prime factor of p defined
+ *    publicly as well. The `lpf' is optional and if it is not supplied
+ *    then the private values generated satifies 0 < x < p - 1 instead
+ *    of 0 < x < lpf. Returns NULL on error or allocated SilcDH context
+ *    on success. 
  *
  ***/
-SilcDH silc_dh_alloc(SilcRng rng, SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf);
+SilcDH silc_dh_alloc(SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf);
 
 /****f* silccrypt/SilcDH/silc_dh_free
  *
@@ -88,8 +85,8 @@ SilcDH silc_dh_alloc(SilcRng rng, SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf);
  *
  * DESCRIPTION
  *
- *    Frees the SilcDH context. Does not free the RNG context given in the 
- *    allocation. Frees all the allocated data inside the SilcDH context. 
+ *    Free the SilcDH context. Frees all the allocated data inside the 
+ *    SilcDH context. 
  *
  ***/
 void silc_dh_free(SilcDH dh);
@@ -98,23 +95,23 @@ void silc_dh_free(SilcDH dh);
  *
  * SYNOPSIS
  *
- *    int silc_dh_generate_private(SilcDH dh, SilcMPInt **x);
+ *    bool silc_dh_generate_private(SilcDH dh, const SilcMPInt **x);
  *
  * DESCRIPTION
  *
  *    Generates random private value `x' such that 0 < x < lpf at most of
  *    length of lpf. Returns FALSE if the random number could not be generated.
  *    Returns the generated value into `x' pointer sent as argument, unless
- *    the `x' is NULL. The returned `x' must no be freed by the caller. 
+ *    the `x' is NULL. The returned `x' must not be freed by the caller. 
  *
  ***/
-int silc_dh_generate_private(SilcDH dh, SilcMPInt **x);
+bool silc_dh_generate_private(SilcDH dh, const SilcMPInt **x);
 
 /****f* silccrypt/SilcDH/silc_dh_compute_public
  *
  * SYNOPSIS
  *
- *    int silc_dh_compute_public(SilcDH dh, SilcMPInt **y);
+ *    bool silc_dh_compute_public(SilcDH dh, const SilcMPInt **y);
  *
  * DESCRIPTION
  *
@@ -124,13 +121,13 @@ int silc_dh_generate_private(SilcDH dh, SilcMPInt **x);
  *    freed by the caller. 
  *
  ***/
-int silc_dh_compute_public(SilcDH dh, SilcMPInt **y);
+bool silc_dh_compute_public(SilcDH dh, const SilcMPInt **y);
 
 /****f* silccrypt/SilcDH/silc_dh_remote_public
  *
  * SYNOPSIS
  *
- *    int silc_dh_compute_public(SilcDH dh, SilcMPInt **y);
+ *    bool silc_dh_compute_public(SilcDH dh, SilcMPInt *y);
  *
  * DESCRIPTION
  *
@@ -139,13 +136,13 @@ int silc_dh_compute_public(SilcDH dh, SilcMPInt **y);
  *    on error. 
  *
  ***/
-int silc_dh_set_remote_public(SilcDH dh, SilcMPInt *y);
+bool silc_dh_set_remote_public(SilcDH dh, SilcMPInt *y);
 
 /****f* silccrypt/SilcDH/silc_dh_compute_key
  *
  * SYNOPSIS
  *
- *    int silc_dh_compute_key(SilcDH dh, SilcMPInt **z);
+ *    bool silc_dh_compute_key(SilcDH dh, const SilcMPInt **z);
  *
  * DESCRIPTION
  *
@@ -155,22 +152,22 @@ int silc_dh_set_remote_public(SilcDH dh, SilcMPInt *y);
  *    freed by the caller. 
  *
  ***/
-int silc_dh_compute_key(SilcDH dh, SilcMPInt **z);
+bool silc_dh_compute_key(SilcDH dh, const SilcMPInt **z);
 
 /****f* silccrypt/SilcDH/silc_dh_remote_public
  *
  * SYNOPSIS
  *
- *    int silc_dh_compute_key_data(SilcDH dh, unsigned char **z, 
- *                                 uint32 *z_len);
+ *    bool silc_dh_compute_key_data(SilcDH dh, unsigned char **z, 
+ *                                  uint32 *z_len);
  *
  * DESCRIPTION
  *
  *    Same as above but returns the computed secret key as octet binary
- *    string. 
+ *    string.  The caller must free the returned binary string.
  *
  ***/
-int silc_dh_compute_key_data(SilcDH dh, unsigned char **z, 
-                            uint32 *z_len);
+bool silc_dh_compute_key_data(SilcDH dh, unsigned char **z, 
+                             uint32 *z_len);
 
 #endif
index b8f1cda6ad9ff63f15101cd51dc4bb84ade5d5ba..d4f62c3e023763e72a72191aca33cfcee1d11157 100644 (file)
@@ -1,16 +1,15 @@
 /*
 
-  mp_gmp.c
+  mp_gmp.c 
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
   Copyright (C) 2001 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-  
+  the Free Software Foundation; version 2 of the License.
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
index f3ae30e91410bbf888713a36405ca3044f370030..56d2730aa8d9b2466fc11f7291ea923d3b2c8452 100644 (file)
@@ -1,16 +1,15 @@
 /*
 
-  mp_mpi.c
+  mp_mpi.c 
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
   Copyright (C) 2001 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-  
+  the Free Software Foundation; version 2 of the License.
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -43,7 +42,7 @@ size_t silc_mp_sizeinbase(SilcMPInt *mp, int base)
   return mp_radix_size(mp, base) - 2; /* XXX This is actually wrong since
                                         this might produce wrong balue.
                                         But, it looks like MPI always returns
-                                        correct value + plus, whereas
+                                        correct value plus one, whereas
                                         GMP returns always the right value. */
 }
 
index 6472e1e82ffd2c2beb2de81fa35dd6577e4cf08d..c2b64be0536a87a3c3f5b1641b8a18290976748d 100644 (file)
@@ -320,12 +320,9 @@ SilcSKEStatus silc_ske_payload_ke_decode(SilcSKE ske,
   return SILC_SKE_STATUS_OK;
 
  err:
-  if (payload->pk_data)
-    silc_free(payload->pk_data);
-  if (payload->sign_data)
-    silc_free(payload->sign_data);
-  if (x)
-    silc_free(x);
+  silc_free(payload->pk_data);
+  silc_free(payload->sign_data);
+  silc_free(x);
   silc_free(payload);
   ske->status = status;
   return status;
@@ -336,11 +333,9 @@ SilcSKEStatus silc_ske_payload_ke_decode(SilcSKE ske,
 void silc_ske_payload_ke_free(SilcSKEKEPayload *payload)
 {
   if (payload) {
-    if (payload->pk_data)
-      silc_free(payload->pk_data);
+    silc_free(payload->pk_data);
     silc_mp_uninit(&payload->x);
-    if (payload->sign_data)
-      silc_free(payload->sign_data);
+    silc_free(payload->sign_data);
     silc_free(payload);
   }
 }
index c3c14297046ff717531664f662183b5f33de0fac..a6b23c857918cbf090182b3cfc8f86644c266f7d 100644 (file)
@@ -69,6 +69,8 @@ void silc_ske_free(SilcSKE ske)
     /* Free KE payload */
     if (ske->ke1_payload)
       silc_ske_payload_ke_free(ske->ke1_payload);
+    if (ske->ke2_payload)
+      silc_ske_payload_ke_free(ske->ke2_payload);
 
     /* Free rest */
     if (ske->prop) {