From: Pekka Riikonen Date: Sat, 1 Dec 2001 21:44:32 +0000 (+0000) Subject: updates. X-Git-Tag: silc.toolkit.0.7~6 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=cfe162b20857876582cdbc541f628bc8048cac82 updates. --- diff --git a/CHANGES b/CHANGES index 4cbc242e..88a533cf 100644 --- a/CHANGES +++ b/CHANGES @@ -33,7 +33,7 @@ Thu Nov 29 19:31:23 EET 2001 Pekka Riikonen ' 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 9c8eb3f7..00e588d8 100644 --- 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 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. diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index f09bccb6..f5cd5d20 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 86b0a3dc..22af66f5 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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); } diff --git a/lib/silcclient/silcapi.h b/lib/silcclient/silcapi.h index 03387ebf..cb48fd93 100644 --- a/lib/silcclient/silcapi.h +++ b/lib/silcclient/silcapi.h @@ -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, diff --git a/lib/silccrypt/silcdh.h b/lib/silccrypt/silcdh.h index 68d36764..1f90ba3d 100644 --- a/lib/silccrypt/silcdh.h +++ b/lib/silccrypt/silcdh.h @@ -1,36 +1,35 @@ +/* + + silcdh.h + + Author: Pekka Riikonen + + 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 - * - * 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 diff --git a/lib/silcmath/mp_gmp.c b/lib/silcmath/mp_gmp.c index b8f1cda6..d4f62c3e 100644 --- a/lib/silcmath/mp_gmp.c +++ b/lib/silcmath/mp_gmp.c @@ -1,16 +1,15 @@ /* - mp_gmp.c + mp_gmp.c - Author: Pekka Riikonen + Author: Pekka Riikonen 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 diff --git a/lib/silcmath/mp_mpi.c b/lib/silcmath/mp_mpi.c index f3ae30e9..56d2730a 100644 --- a/lib/silcmath/mp_mpi.c +++ b/lib/silcmath/mp_mpi.c @@ -1,16 +1,15 @@ /* - mp_mpi.c + mp_mpi.c - Author: Pekka Riikonen + Author: Pekka Riikonen 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. */ } diff --git a/lib/silcske/payload.c b/lib/silcske/payload.c index 6472e1e8..c2b64be0 100644 --- a/lib/silcske/payload.c +++ b/lib/silcske/payload.c @@ -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); } } diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index c3c14297..a6b23c85 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -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) {