Commit Graph

75 Commits

Author SHA1 Message Date
Steffen Jaeckel
a251347c50 clean-up file headers & footers 2019-09-23 16:35:41 +02:00
Steffen Jaeckel
397d2ca9a3 fix fp_iseven() ... this time for real
as indicated once more by @muks in #21
2019-09-04 22:13:51 +02:00
Steffen Jaeckel
ae948ee4a9 fix fp_iseven()
as indicated by @muks in #21
2019-09-03 11:17:32 +02:00
Steffen Jaeckel
9752086431 fix warning when compiling tfm from pre_gen/mpi.c 2018-06-22 15:31:58 +02:00
Steffen Jaeckel
3bfaf74033 protect include of c-files
the way it was before, pre_gen/mpi.c couldn't be built
2018-02-01 01:53:00 +01:00
Steffen Jaeckel
e7fc79309e fix compiler warning 2017-09-13 17:28:15 +02:00
Steffen Jaeckel
0729166b25 also provide early-out optimization of comba32 for bigger multipliers 2017-09-13 16:11:43 +02:00
Steffen Jaeckel
5f0ffc0e26 properly re-generate fp_mul_comba32() 2017-09-13 16:07:59 +02:00
Steffen Jaeckel
8042e3ff5f also regen mont/fp_mont_small.i 2017-09-13 15:58:36 +02:00
Steffen Jaeckel
4eac223b54 display git version in ident string if available 2017-09-13 15:21:59 +02:00
Steffen Jaeckel
53baae2c99 don't include tfm.h from the system, but the local one 2017-06-14 13:18:12 +02:00
Steffen Jaeckel
fe56698355 also show in TFM_VERSION[_S] that we're in-development 2017-06-14 13:17:44 +02:00
bchauvaux
dfad7c7d17 Now truncating input array if ENDIANESS is unknown 2017-04-12 13:09:23 -07:00
Steffen Jaeckel
3a7273b2da Bump version & update tfm.pdf 2017-04-04 12:24:03 +02:00
Steffen Jaeckel
1404af6262 allow external define of FP_GEN_RANDOM 2017-04-04 00:45:06 +02:00
Steffen Jaeckel
8e034dcf6e add FP_GEN_RANDOM logic as in libtommath 2017-03-30 16:15:35 +02:00
Mathias Tausig
3eaee499a4 Add missing include (prevent compiler warning) 2016-10-25 11:13:07 +02:00
Sebastian Andrzej Siewior
dac0895159 tfm: make a few functions static
clamav expects them to be static and it does not seem bad to do so.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2016-04-24 14:00:15 +02:00
Sebastian Andrzej Siewior
f7e7f83718 provide tfm_private.h
tfm.h contains declarations for the public part of the library.
tfm_private.h contains the function which are private to tfm and should
not be exposed to the public.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-08-16 22:04:51 +02:00
Sebastian Andrzej Siewior
24d98570b0 define FP_64BIT on 64bit architectures
This should enable 64bit math on 64bit architecures besides amd64 (like
ppc64, sparc64 and so on)

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-08-16 15:27:31 +02:00
Steffen Jaeckel
1f1fafe7fb bump version 2015-08-07 01:03:23 +02:00
Steffen Jaeckel
846d7f36eb add version information 2015-04-25 15:25:42 +02:00
Steffen Jaeckel
6db706e857 bring back __DATE__ to fp_ident(), but it's disabled by default 2015-04-25 15:10:33 +02:00
Sebastian Andrzej Siewior
8ea169937d drop __DATE__ from fp_ident
To meet Debian's reproducible builds [0] goal I remove the __DATE__
macro.
In case this is not acceptable because the date of build is _really_
important / required I could come with a ifdef or something else.

[0] https://wiki.debian.org/ReproducibleBuilds

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-04-25 14:59:37 +02:00
Sebastian Andrzej Siewior
5d83c4e5ab tfm: use unsigned int for fp_digit on !FP_64BIT
There is a bugzilla entry at clamav [0] reports a problem on s390x
  "mul/fp_mul_comba_20.c:91: warning: right shift count >= width of type"
because fp_digit is 64bit and according to the comment it should be
smaller.
s390x is 64bit platform i.e. long and long long are both 64bit. The
same is true for ppc64, arm64 or sparc64 (RIP alpha).

The headerfile seems only to define FP_64BIT on x86_64.
The current code seems to define SIZEOF_FP_DIGIT either to 8 (64bit) or
to 4 in the else case and 4 looks like int and not long. Therefore the
change here.

If this change makes no sense and you would prefer to use something like
    #if __SIZEOF_LONG__ == 8
       #define FP_64BIT
    #endif

to autodetect a 64bit platform then we could try do this instead. I
haven't tested this patch nor verified that the problem still occures.

If you have no obvious solution and would like to have a confirmation
that this patch solves a problem I could try to get my hands on
something not x86 with 64bit in order to verify.

[0] https://bugzilla.clamav.net/show_bug.cgi?id=9017

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-04-25 14:22:35 +02:00
Steven Morgan
522a092ffb fp_ident: fix incorrect length in strncat() call.
strncat' last argument is the remaining size of the buffer given in the
first argument, not the total buffer length.

Reported-by: contact@oppida.fr via clamav #11166
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-04-25 14:22:34 +02:00
David Raynor
060b2c5697 s_fp_add: completely init c after add
This was reported in clamav via a "coverity report" #11125/#11126. I can't
get the coverity report and I've been told that

|< linnatic> bigeasy: unfortunately, I can't get you the coverity report
|< linnatic> bigeasy: but it does seem that the patch is not
|required as the possible coverity issue is unlikely to occur

so if you thing that this patch is not required (which is what I assume) then
please drop that patch, I just added since it was in the clamav tree…

[sebastian@breakpoint: patch description]
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-04-25 14:22:34 +02:00
Sebastian Andrzej Siewior
6fbf2ba87d fp_toradix_n: make sure too small strings are recognized
If maxlen is too small then we get FP_OKAY as return value but not
everything is part of the string. This patch changes it so that the
caller learns about this short comming.

While at it, drop the doxygen style comment. It is the only of his kind
and does no longer match the code.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-04-25 14:22:34 +02:00
Patrick Oppenlander
c9ae4c70d4 ppc32: fix fp_montgomery_reduce assembly
Previous patch modified constraints from =m to =g. Turns out this also
allows registers which doesn't work with the inline assembly
instructions.

If we change back to =m GCC 5.0 warns that constraints do not allow a
register.

In order to work around these issues we now pass the arguments in
registers and let GCC handle the loading & storing.
2015-04-17 10:18:45 +10:00
Steffen Jaeckel
e4f8c04da6 fp_toradix[_n]: revise and split up 2015-02-15 23:33:11 +01:00
Sebastian Andrzej Siewior
f734a43b05 implement fp_toradix_n()
It is not implemened yet, just added to the headerfile. Therefore I don't
think it is a ABI breakage if I change maxlen from int to unsigned int.

The function releases fp_toradix() for the work which in turn now calls
fp_toradix_n() with a largest possible maxlen parameter.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2015-02-15 19:29:12 +01:00
Steffen Jaeckel
77be93c201 fix compile errors 2015-02-15 14:50:20 +01:00
Steffen Jaeckel
3142b0bdfc fp_prime_random_ex: make sure call-back function is not NULL 2014-10-13 16:51:13 +02:00
Steffen Jaeckel
fede300ee8 fp_prime_random_ex: use parameter 't' 2014-10-13 16:46:10 +02:00
Steffen Jaeckel
ce72d69438 add macro FP_PRIME_SIZE 2014-10-13 16:45:34 +02:00
Giovanni Bajo
08484a1020 Avoid always generating 0x80 as MSB in primes.
When we ask to generate a prime whose size is a multiple of 8,
the code wrongly computes the mask as 0x00 instead of 0xFF, so the
generated prime always has the MSB set to 0x80 (the highest bit is OR'ed
later in the code).
2014-10-13 13:40:57 +02:00
Steffen Jaeckel
7a38e49b8e add fp_isprime_ex()
fp_isprime() is now only a wrapper function to fp_isprime_ex()
2014-10-13 13:40:36 +02:00
Steffen Jaeckel
f7b194f741 minor changes, trim trailing spaces 2014-10-13 13:39:30 +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
03334b30b4 mont: make INNERMUL register clobber list equal to the 64bit version 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
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
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