Commit Graph

166 Commits

Author SHA1 Message Date
Steffen Jaeckel
f7b194f741 minor changes, trim trailing spaces 2014-10-13 13:39:30 +02:00
Steffen Jaeckel
3a80f80039 deterministic build of tfm.pdf 2014-10-13 12:32:25 +02:00
Steffen Jaeckel
4e0e2c0f90 update changes 2014-10-13 12:24:45 +02:00
Steffen Jaeckel
b0509acce9 Merge branch 'feature/rand' 2014-08-28 02:58:22 +02:00
Steffen Jaeckel
97248ae23e update makefiles 2014-08-14 21:19:14 +02:00
Steffen Jaeckel
ec7f25200f add fp_rand()
it's a port of the function in libtommath
2014-08-14 21:19:14 +02:00
Steffen Jaeckel
56438df4cf test/mtest/stest: improve a bit
fix compiler warnings
make internal buffer size dependant on its possible size
fix return values
2014-08-14 21:18:23 +02:00
Steffen Jaeckel
0b1ad14d7b makefile: rework a bit 2014-08-14 21:17:11 +02:00
Steffen Jaeckel
03334b30b4 mont: make INNERMUL register clobber list equal to the 64bit version 2014-08-14 21:17:11 +02:00
Steffen Jaeckel
14bb3e83ca gen.pl: update to current directory structure 2014-08-14 21:17:11 +02:00
Steffen Jaeckel
ec6c224b09 fix sqr_comba compiler warnings 2014-08-11 17:54:09 +02:00
Steffen Jaeckel
72fe8e48ba montgomery reduce: change #ifdef
as INNERMUL8 is only defined where it is available, simply check if it's
defined and don't check again for the arch
2014-07-20 16:08:35 +02:00
Steffen Jaeckel
06ef0be491 tfm.h: add missing prototype of fp_radix_size() 2014-06-21 13:24:22 +02:00
Steffen Jaeckel
7882b0370d ed1a1e90e9 was not only a x86-64 problem 2014-06-21 13:24:03 +02:00
Steffen Jaeckel
60cf64919f fp_read_radix: port modifications from libtommath 2014-06-15 18:35:31 +02:00
Steffen Jaeckel
74df3d9970 demo/stest: print ident string 2014-06-15 18:34:15 +02:00
Steffen Jaeckel
1e129bf61e demo/test: enable montogomery and prime tests per default 2014-06-14 18:17:47 +02:00
Steffen Jaeckel
06e1cd7216 fix compiler warning 2014-06-14 17:39:18 +02:00
Steffen Jaeckel
c6b1b8e2f1 fix ulong64 typedef that led to broken builds for several platforms
x86_64-w64-mingw32 and 32Bit mode on 64Bit system

x86_64-w64-mingw32-gcc
'gcc -m32'
'gcc -mx32'
2014-06-14 17:39:10 +02:00
Steffen Jaeckel
9671aa83e1 update makefile to be able to define a target platform prefix 2014-06-14 17:27:51 +02:00
Steffen Jaeckel
cbb1821bb9 don't require mtest when compiling test 2014-06-14 17:21:03 +02:00
Steffen Jaeckel
c81aac2674 demo/test: fix some compiler warnings 2014-06-12 19:38:15 +02:00
Steffen Jaeckel
019beee1c7 update makefiles 2014-06-12 18:20:38 +02:00
Steffen Jaeckel
ed1a1e90e9 fix clobber list for x86-64 assembler 2014-06-12 18:20:32 +02:00
Steffen Jaeckel
be2ca4880d Regenerate sqr comba files 2014-06-12 18:20:11 +02:00
Steffen Jaeckel
bdeafda752 Regenerate mul comba files 2014-06-12 18:19:53 +02:00
Steffen Jaeckel
3cabe12a21 mul generator: update preamble not to compile the code if it's not required 2014-06-12 18:08:34 +02:00
Steffen Jaeckel
8c8d763389 sqr generator: update preamble not to compile the code if it's not required 2014-06-12 18:08:10 +02:00
Steffen Jaeckel
2d5b8206fa also patch fp_mul() as proposed by tom on the ML [1]
[1] https://groups.google.com/forum/#!topic/libtom/MdbS1vcLhCU
2014-06-12 18:06:26 +02:00
Steffen Jaeckel
a7804acf42 implement 50f587c36f as proposed by tom 2014-06-12 18:04:03 +02:00
Steffen Jaeckel
e8163eb74a fixup 3f7a1dca3b 2014-06-12 18:01:58 +02:00
Steffen Jaeckel
82aeb1d824 change DIGIT_BIT define to be able to test e.g. FP_SIZE in a macro 2014-06-12 17:59:22 +02:00
Steffen Jaeckel
540e3ecbc1 Realign mult generators with existing files in repo.
NB: fp_mul_comba32() is hand-optimized and has to be hand-crafted after
re-generation
2014-06-12 17:40:58 +02:00
Steffen Jaeckel
39b18f774c fix compiler warnings 2014-06-12 17:36:49 +02:00
Steffen Jaeckel
86e7c59ff4 trim trailing spaces/clean-up 2014-06-12 17:35:54 +02:00
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