Commit Graph

131 Commits

Author SHA1 Message Date
Steffen Jaeckel
bea9b1cc22 Merge remote-tracking branch 'rasky/bugfix_sqr_bufferoverflow' 2014-06-12 11:31:39 +02:00
Steffen Jaeckel
7993b1b66c regenerate fp_sqr_comba_small_set.c 2014-06-12 11:00:30 +02:00
Steffen Jaeckel
6673bd99ce minor fixes to really reproduce original files 2014-06-12 10:58:54 +02:00
Steffen Jaeckel
f8227a0dd9 trim trailing spaces 2014-06-12 10:58:39 +02:00
Steffen Jaeckel
f5b5bc09fb Revert "Bugfix: clear the exceeding destination digits."
This reverts commit 50f587c36f.
2014-06-12 10:50:19 +02:00
Steffen Jaeckel
7d003805ad Revert "Regenerate sqr comba files with bugfix"
This reverts commit ab4374299c.
2014-06-12 10:50:03 +02:00
Steffen Jaeckel
bfa4582842 Merge pull request #2 from rasky/bugfix_sqr_destdigits
Bugfix sqr destdigits, c.f. 50f587c36f for further explanation
2011-09-21 03:31:20 -07:00
Giovanni Bajo
3f7a1dca3b Fix for buffer overflows in fp_mul. 2011-09-20 12:06:44 +02:00
Giovanni Bajo
c32affe350 Bugfix: fix buffer overflow with comba sqr
The comba sqr code does not check the maximum bounds of fp_int; eg:
if you invoke fp_sqr_comba_20, it will write 40 digits to the
destination even if FP_SIZE < 40. This is correct for achieving high
speeds, but it means that it is the caller's responsibility to check for
such overflows.

fp_sqr.c only checks for numeric overflows (a->used * 2 >= FP_SIZE)
though. This means that if you call fp_sqr() with a small number (say
1), and your FP_SIZE is 10, and you have enabled a fp_sqr_comba_8, it
will overflow your buffer by writing 16 digits.

Since the exact subset of active comba multipliers/sqrs are up to the user
(in tfm.h), we fix the code never to invoke them if they can cause
overflows.
2011-09-20 12:06:44 +02:00
Giovanni Bajo
ab4374299c Regenerate sqr comba files with bugfix 2011-09-20 11:37:23 +02:00
Giovanni Bajo
782c6e52de Realign generators with existing files in repo. 2011-09-20 11:36:41 +02:00
Giovanni Bajo
8f059cd52f Add makefile for sqr generators 2011-09-20 11:35:51 +02:00
Giovanni Bajo
50f587c36f Bugfix: clear the exceeding destination digits.
Currently, the fp_sqr_comba_* functions do not fully clear the destination
number, but only overwrites the digits they care about. Eg: if
you call a comba4, it will overwrite the first 8 digits and leave
the others unchanged.

On the other hand, fp_mul_comba_* functions do *not* check incoming
unused digits (relying on the guarantee that they must be zero),
so they will happily compute the wrong result if those digits
are not empty. Testcase for a 32-bit system:

   char buf[64];
   fp_int num, num2, d;

   memset(buf, 0xFF, sizeof(buf);
   fp_read_unsigned_bin(&num, buf);
   fp_set(&d, 1);

   fp_sqr_comba_3(&d, &num);
   // now num is { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
   //              0xFFFFFFFF, 0xFFFFFFFF ... }
   // only first 6 digits have been written, but even
   // if num.used is correctly set to 6, this can trigger
   // bugs.

   // Create a number larger than 6 digits
   fp_2expt(&num2, 8*32+4);

   fp_mul_comba_8(&num, &num2, &num2);
   // wrong result has been computed, because the first 8
   // digits of num have been read and multiplied
   // even if num->used == 6, relying on the fact that
   // they should be zero.
2011-09-20 11:02:53 +02:00
Steffen Jaeckel
da5fa59f2c fixed bug in testcase reported by martins.mozeiko@gmail.com 2011-03-27 19:57:48 +02:00
Steffen Jaeckel
1e90accef6 added testcase of problem reported by martins.mozeiko@gmail.com 2011-03-27 19:34:36 +02:00
Steffen Jaeckel
eb5075e7fc added typecast in fp_read_radix() to suppress compiler warning 2011-03-27 19:33:53 +02:00
Steffen Jaeckel
f340961df9 added gitignore 2011-03-27 19:33:13 +02:00
Steffen Jaeckel
a1ac91d15e after multiple objections of libtom users [1], we decided to change licensing
to a dual licensing model.

[1] https://groups.google.com/group/libtom/browse_thread/thread/d7b67bc6410250b3
2011-01-19 10:28:48 +01:00
Steffen Jaeckel
6efcb2e5e0 Re-licensed all code under WTFPL, c.f. http://sam.zoy.org/wtfpl/ 2010-10-26 16:02:37 +02:00
Patrick Oppenlander
cfb7c1e52e fix register constraints in fp_montgomery_reduce 2010-07-22 10:29:12 +02:00
Tom St Denis
da88c2d42f added tomsfastmath-0.12 2010-07-22 10:06:30 +02:00
Tom St Denis
ea10e969b2 added tomsfastmath-0.10 2010-07-22 10:06:29 +02:00
Tom St Denis
4b439169aa added tomsfastmath-0.09 2010-07-22 10:06:28 +02:00
Tom St Denis
f99cdec6b0 added tomsfastmath-0.08 2010-07-22 10:06:27 +02:00
Tom St Denis
9ce1fe4656 added tomsfastmath-0.07 2010-07-22 10:06:26 +02:00
Tom St Denis
091b337fe8 added tomsfastmath-0.06 2010-07-22 10:06:25 +02:00
Tom St Denis
a6c4c5a261 added tomsfastmath-0.05 2010-07-22 10:06:25 +02:00
Tom St Denis
f91cf2d1cf added tomsfastmath-0.04 2010-07-22 10:06:24 +02:00
Tom St Denis
ca551d4c5e added tomsfastmath-0.03 2010-07-22 10:06:23 +02:00
Tom St Denis
6bb413fd72 added tomsfastmath-0.02 2010-07-22 10:06:22 +02:00
Tom St Denis
5e92ed2a59 added tomsfastmath-0.01 2010-07-22 10:06:21 +02:00