From: Pekka Riikonen Date: Wed, 5 Mar 2008 18:46:42 +0000 (+0200) Subject: Added new math library based on TFM. X-Git-Tag: 1.2.beta1~6 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=abd261065eac46a2d2c970833f3fa701bc1516e3;hp=abd261065eac46a2d2c970833f3fa701bc1516e3;p=crypto.git Added new math library based on TFM. We've changed the TFM to support dynamically allocated integers. As good and fast as the TFM is its main flaw is that it uses pre-allocated integers. This doesn't work in real life, unless of course you know exactly how much memory you are going to use and need, or you don't care about how much your program consumes memory. On systems that need to work in environments from few integers to tens of thousands allocated at the same time, the dynamic allocation is the only right way to go to keep the memory consumption in line. It also has the added benefit that there is no artificial limit to integer size. The dynamically allocated integer can be initialized exactly the same way as the original TFM integer. It can be memset'ed to initialize, if needed, but tfm_fp_init should be used. However, tfm_fp_zero must always be called to avoid memory leaks. The integer thus is initialized to no memory at first and will grow automatically. It also supports SilcStack. With SilcStack integer reallocations are very fast and is ideal to use in temp integers that are used only for computations and not for storing integers for a long time. Integers can be copied with tfm_fp_copy and it will automatically allocate memory for the copied integer. The contents of the integer can be directly exchanged by exchanging the pointers with tfm_fp_exch, which is much faster that the copy that must be used in original TFM to do the same. We've also added missing routines like bitwise AND, OR and XOR, sqrt, expt_d and others. ---