updates.
[crypto.git] / TODO
diff --git a/TODO b/TODO
index 9a715bf0d8bd6f25fd75ce17d35527c147e5c1a9..734a026a4fbe97f7e834d2f8826edf4d5f441e46 100644 (file)
--- a/TODO
+++ b/TODO
@@ -80,7 +80,8 @@ Runtime library, lib/silcutil/
    SilcBool silc_clearenv(const char *variable);
 
  o Add functions to loading shared/dynamic object symbols (replaces the
-   SIM library (lib/silcsim) and introduces generic library).
+   SIM library (lib/silcsim) and introduces generic library).  Add this
+   to lib/silcutil/silcdll.[ch].
 
    SilcDll silc_dll_load(const char *object_path, SilcDllFlags flags);
    void silc_dll_close(SilcDll dll);
@@ -131,7 +132,34 @@ Runtime library, lib/silcutil/
 
    Problems: Events would be SilcSchedule specific, and would not work on 
    multi-thread/multi-scheduler system.  The events should be copyable 
-   between schedulers.
+   between schedulers.  Another problem is the signal delivery.  Do we
+   deliver them synchronously possibly from any thread to any other thread
+   or do we deliver them through the target schedulers.  If we use the
+   schedulers then signalling would be asynchronous (data must be 
+   duplicated and later freed) which is not very nice.
+
+ o If the event signals are added, the SILC_PARAM_* stuff needs to be
+   moved from silcbuffmt.h to silctypes.h or something similar.
+
+ o In case the SILC Events are done we shall create a new concept of
+   parent and child SilcSchedule's.  When new SilcSchedule is created a
+   parent can be associated to it.  This association could be done either
+   directly by the parent or by any other children.  This way the signals
+   would in effect be global and would reach all children schedulers.
+
+   This relationship would be associative only.  The schedulers are still
+   independent and run independently from each other.   All schedulers
+   would be linked and could be accessed from any of the schedulers.
+   It should be possible to retrieve the parent and enumate all children
+   from any of the schedulers.
+
+   SilcSchedule silc_schedule_init(int max_tasks, void *app_context,
+                                  SilcSchedule parent);
+   SilcSchedule silc_schedule_get_parent(SilcSchedule schedule);
+
+ o Additional scheduler changes: optimize silc_schedule_wakeup.  Wakeup 
+   only if the scheduler is actually waiting something.  If it is 
+   delivering tasks wakeup is not needed.
 
  o Structured log messages to Log API.  Allows machine readable log
    messages.  Would allow sending of any kind of data in a log message.
@@ -150,6 +178,59 @@ Runtime library, lib/silcutil/
 
  o SilcStack aware SilcDList.
 
+ o Thread pool API.  Add this to lib/silcutil/silcthread.[ch].
+
+   typedef void (*SilcThreadPoolFunc)(SilcSchedule schedule,
+                                     void *context);
+
+   /* Allocate thread pool with at least `min_threads' and at most
+      `max_threads' many threads.  If `stack' is non-NULL all memory
+      is allocated from the `stack'.  If `start_min_threads' is TRUE
+      this will start `min_threads' many threads immediately. */
+   SilcThreadPool silc_thread_pool_alloc(SilcStack stack,
+                                        SilcUInt32 min_threads,
+                                        SilcUInt32 max_threads,
+                                        SilcBool start_min_threads);
+
+   /* Free thread pool.  If `wait_unfinished' is TRUE this will block
+      and waits that all remaining active threads finish before freeing
+      the pool. */
+   void silc_thread_pool_free(SilcThreadPool tp, SilcBool wait_unfinished);
+
+   /* Run `run' function with `run_context' in one of the threads in the
+      thread pool.  Returns FALSE if the thread pool is being freed.  If
+      there are no free threads left in the pool this will queue the
+      the `run' and will call it once a thread becomes free.
+
+      If `completion' is non-NULL it will be called to indicate completion
+      of the `run' function.  If `schedule' is non-NULL the `completion'
+      will be called through the scheduler in the main thread.  If it is
+      NULL the `completion' is called directly from the thread after the
+      `run' has returned. */
+   SilcBool silc_thread_pool_run(SilcThreadPool tp,
+                                SilcSchedule schedule,
+                                SilcThreadPoolFunc run,
+                                void *run_context,
+                                SilcThreadPoolFunc completion,
+                                void *completion_context);
+
+   /* Modify the amount of maximum threads of the pool. */
+   void silc_thread_pool_set_max_threads(SilcThreadPool tp,
+                                        SilcUInt32 max_threads);
+
+   /* Returns the amount of maximum size the pool can grow. */
+   SilcUInt32 silc_thread_pool_num_max_threads(SilcThreadPool tp);
+
+   /* Returns the amount of free threads in the pool currently. */
+   SilcUInt32 silc_thread_pool_num_free_threads(SilcThreadPool tp);
+
+   /* Stops all free and started threads.  The minumum amount of threads
+      specified to silc_thread_pool_alloc always remains. */
+   void silc_thread_pool_purge(SilcThreadPool tp);
+
+ o Fast mutex implementation.  Fast rwlock implementation.  Mutex and
+   rwlock implementation using atomic operations.
+
  o Compression routines are missing.  The protocol supports packet
    compression thus it must be implemented.  SILC Zip API must be
    defined.
@@ -159,8 +240,6 @@ Runtime library, lib/silcutil/
     protocol related status (currently in silcstatus.h) cannot be in 
     runtime library) maybe
 
- (o Thread pool) maybe
-
  (o SILC specific socket creation/closing routines to silcnet.h, wrappers
   to all send(), recv(), sendto() etc.  Bad thing is that we'd have to
   define all socket options, sockaddrs, etc.) maybe
@@ -299,13 +378,15 @@ Crypto Library, lib/silccrypt/
  o Add DSS support.  Take implementation from Tom or make it yourself.
 
  o Implement the defined SilcDH API.  The definition is in
-   lib/silccrypt/silcdh.h.
+   lib/silccrypt/silcdh.h.  Make sure it is asynchronous so that it can
+   be accelerated.  Also take into account that it could use elliptic
+   curves.
+
+ o ECDSA and ECDH
 
  o All cipher, hash, hmac etc. allocation routines should take their name
    in as const char * not const unsigned char *.
 
- o ECDSA and ECDH
-
 
 SILC Accelerator Library
 ========================
@@ -316,18 +397,23 @@ SILC Accelerator Library
 
    Something in the lines of (preliminary):
 
-   /* Register accelerator to system */
-   SilcBool silc_acc_register(const SilcAccelerator acc);
+   /* Register accelerator to system.  Initializes the accelerator. */
+      Varargs are optional accelerator specific init parameteres. */
+   SilcBool silc_acc_register(SilcAccelerator acc, ...);
+
+     silc_acc_register(softacc, "min_threads", 2, "max_threads", 16, NULL);
 
-   /* Unregister accelerator */
+   /* Unregister accelerator.  Uninitializes the accelerator. */
    SilcBool silc_acc_unregister(const SilcAccelerator acc);
 
-   /* Find existing accelerator.  `name' is accelerators name and
-      `params' is optional accelerator specific parameters. */
-   SilcAccelerator silc_acc_find(const char *name, const char *params);
+   /* Return list of the registered accelerators */
+   SilcDList silc_acc_get_supported(void);
 
-   /* Return accelerator's displayable name */
-   const char *silc_ac_get_display_name(SilcAccelerator acc);
+   /* Find existing accelerator.  `name' is accelerator's name. */
+   SilcAccelerator silc_acc_find(const char *name);
+
+   /* Return accelerator's name */
+   const char *silc_acc_get_name(SilcAccelerator acc);
 
    /* Accelerate `public_key'.  Return accelerated public key. */
    SilcPublicKey silc_acc_public_key(SilcAccelerator acc,
@@ -346,33 +432,45 @@ SILC Accelerator Library
                                           SilcPrivateKey private_key);
 
    typedef struct SilcAcceleratorObject {
-     const char *name;                         /* Accelerator's name */
-     const char *display_name;                 /* Displayable name */
-     SilcAcceleratorType type;                 /* Accelerator type */
-     union {
-       struct {
-        SilcPKCSObject *pkcs;                  /* PKCS, may be NULL */
-        SilcPKCSAlgorithm *algorithm;          /* Accelerator */
-       } pkcs;
-
-       struct {
-
-       } cipher;
-     } u;
+     const char *name;                 /* Accelerator's name */
+     SilcBool (*init)(va_list va);     /* Initialize accelerator */
+     SilcBool (*uninit)(void);         /* Uninitialize accelerator */
+     const SilcPKCSAlgorithm *pkcs;    /* Accelerated PKCS algorithms */
+     const SilcDHObject *dh;           /* Accelerated Diffie-Hellmans */
+     const SilcCipherObject *cipher;   /* Accelerated ciphers */
+     const SilcHashObject *hash;       /* Accelerated hashes */
+     const SilcHmacObject *hmac;       /* Accelerated HMACs */
+     const SilcRngObject *rng;         /* Accelerated RNG's */
    } *SilcAccelerator, SilcAcceleratorStruct;
 
+   Allows accelerator to have multiple accelerators (cipher, hash etc)
+   and multiple different algorithms and implementations (SHA-1, SHA-256 etc).
+
    SilcPublicKey->SilcSILCPublicKey->RsaPublicKey accelerated as:
-   SilcPublicKey->SilcSILCPublicKey->SilcAcceleratorSoftware->RsaPublicKey or
-   SilcPublicKey->SilcSILCPublicKey->SilcAcceleratorPublicKey->
-     SilcAcceleratorSoftware->RsaPublicKey 
+   SilcPublicKey->SilcAcceleratorPublicKey->SilcSoftAccPublicKey->
+     SilcPublicKey->SilcSILCPublicKey->RsaPublicKey
 
-   The former one if u.pkcs.pkcs == NULL.
+   silc_acc_public_key creates SilcPublicKey and SilcAcceleratorPublicKey
+   and acc->pkcs->import_public_key creates SilcSoftAccPublicKey.
 
  o Implement software accelerator.  It is a thread pool system where the
    public key and private key operations are executed in threads.
 
-   This implements SilcPKCSAlgorithm (and SilcPKCSObject if needed) that 
-   implements the thread acclerated system.
+   const struct SilcAcceleratorObject softacc =
+   {
+     "softacc", softacc_init, softacc_uninit,
+     softacc_pkcs, NULL, NULL, NULL, NULL
+   }
+
+   /* Called from silc_acc_private_key */
+   int silc_softacc_import_private_key(void *key, SilcUInt32 key_len,
+                                      void **ret_private_key)
+   {
+     SilcSoftAccPrivateKey prv = silc_calloc(1, sizeof(*prv));
+     prv->pkcs = acc->pkcs;
+     prv->private_key = key;
+     *ret_private_key = prv;
+   }
 
  (o Symmetric key cryptosystem acceleration?  They are always sycnhronouos
    even with hardware acceleration so the crypto API shouldn't require
@@ -403,8 +501,14 @@ lib/silcmath
 SILC XML Library, lib/silcxml/
 ==============================
 
- o SILC XML API (wrapper to expat).  The SILC XML API should follow and 
-   resemble Simple API for XML (SAX).
+ o SILC XML API (wrapper to expat).  Look at the expat API and simplify
+   it.  The SILC XML API should have at most 8-10 API functions.  It should 
+   be possible to create full XML parser with only one function.  And, it 
+   should be possible to have a function that is able to parse an entire
+   XML document.  It should also have a parser function to be able to
+   parse a stream of XML data (SilcStream).  It MUST NOT have operations
+   that require multiple function calls to be able to execute that one
+   operation (like creating parser).
 
 
 lib/silcske/silcske.[ch]