Commit Graph

37 Commits

Author SHA1 Message Date
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04:00
Nicolas Williams
48382936e5 hcrypto: Fix performance regression 2023-01-27 11:00:23 -06:00
Nicolas Williams
1d06e8fcb9 hcrypto: Quell div-by-zero in mp_root_u32() 2023-01-04 02:02:44 -06:00
Nicolas Williams
274b683d76 hcrypto: Fix warning in HMAC_Init_ex() 2023-01-04 00:43:35 -06:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Luke Howard
4891d713fb bn_s_mp_rand_platform.c: s_read_urandom: correctly handle split read
s_read_urandom has a while loop to handle read() that returns less
than the full buffer (either due to EINTR or because more than the
atomic guarantee from urandom was requested). However, the target
of the read was always the base pointer p instead of the updated
pointer q, so in the end less than the requested randomness is returned.

Use q instead of p in the read() call.

Upstream pull request:
https://github.com/libtom/libtommath/pull/512

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2022-01-15 13:38:18 +11:00
Luke Howard
046675ce0e Revert "tommath: Fix warning in s_read_getrandom()"
This reverts commit 489da75e65.

Will be replaced with upstream commit.
2022-01-15 13:37:33 +11:00
Nicolas Williams
c607135a03 Use fallthrough statement attribute (moar) 2022-01-14 16:53:34 -06:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Nicolas Williams
489da75e65 tommath: Fix warning in s_read_getrandom()
See https://github.com/libtom/libtommath/pull/512

(Note: this has not shipped.  Only OS X would be affected, specifically
RSA key gen would be affected on OS X.)
2022-01-14 15:26:59 -06:00
Nicolas Williams
e56b558616 osx: Import fix for tommath #159 2022-01-13 19:56:12 -06:00
Luke Howard
7eb397834e hcrypto: make libtommath v1.2.0 work with Heimdal 2020-04-24 11:59:54 +10:00
Luke Howard
c403b66082 hcrypto: import libtommath v1.2.0 2020-04-24 11:59:54 +10:00
Nicolas Williams
352ff15477 Use labs(rand()) instead of abs(rand()) in tommath
Originally by Christos Zoulas.
2017-03-13 18:39:41 -04:00
Nicolas Williams
4c64231430 Misc last newline fixes
Originally by Christos Zoulas.
2017-03-13 18:39:41 -04:00
Thorsten Glaser
005c8886d7 Do not detect x32 as 64-bit platform.
Fixes test failures due to ISO C Undefined Behaviour in MP_MASK macro.
2017-01-09 19:57:40 +00:00
Nicolas Williams
b4cf4de807 Fix warnings (clang 3.6) 2016-02-26 01:04:31 -06:00
Jeffrey Altman
e8d2100880 libtommath: fix typo in bn_mp_mod.c
Change-Id: Ieec5c01d5bd59b9268f41933389b1b32a4c4d0c6
2013-10-08 21:32:39 -05:00
Jeffrey Altman
8dc29ae1a0 libtommath: remove bn_mp_isprime.c
Now that mp_prime() is no longer used, remove bn_mp_isprime.c from
the source tree.

Change-Id: Ie0f7ce3184c000f27ae5b9dbe07b323c02ce7199
2013-10-08 17:02:07 -05:00
Moritz Lenz
b709d39aa5 libtommath: Fix mp_mod(a, b, c) if b < 0 and a = n * b, n integer
it used to return b, now it return 0.

From https://github.com/libtom/libtommath

Change-Id: I99f5d42c09a6fbddfb32b7dd0ed10ef04f1c08a5
2013-10-08 16:17:14 -05:00
Steffen Jaeckel
7fe018e418 libtommath: mp_error_to_string: return const char* instead of char*
From https://github.com/libtom/libtommath

Change-Id: Idd5cbab380f5d504fece93afb3a5fcc026309482
2013-10-08 16:17:13 -05:00
Steffen Jaeckel
5bc653f0ef libtommath: allow mp_shrink to shrink initialized, but empty MPI's
from https://github.com/libtom/libtommath

Change-Id: I5814caeb44db710957152a7d47b03f9beb6e5147
2013-10-07 17:20:57 -05:00
Jeffrey Altman
28051fa99c Convert mp_find_prime to use mp_prime_is_prime
Modify the signature of mp_find_prime() to permit the number of
Miller-Rabin rounds to be specified.  In addition, valid responses
now include MP_NO, MP_YES, and MP_VAL which is returned when
mp_prime_is_prime() fails.

Change-Id: I0195129a4dd75875e6dddb6d49a5ceb30afb1a17
2013-10-07 15:18:42 -05:00
Jeffrey Altman
1859a85350 libtommath: protect functions by tommath_class macros
libtommath protects the inclusion of functions by wrapping their
declarations by CPP #ifdef tests and defining the matching macros
within libtommath_class.h.

Add missing macros:

  BN_MP_FIND_PRIME_C
  BN_MP_ISPRIME_C

Change-Id: Ic577300114f8e88d7a3af3d9f717a249d57f03b1
2013-10-07 14:00:21 -05:00
Jeffrey Altman
b90732860a libtommath: remove unnecessary comparison
As pointed out by Steffen Jaeckel [https://github.com/sjaeckel],
within bn_mp_prime_next_prime() t <= PRIME_SIZE as per the check
at the top of the function.  Remove the unnecessary comparison in
a for loop conditional.

Change-Id: I868bee1a7a019e0ab06bf2b81cc71cf66ca9acff
2013-10-07 13:57:03 -05:00
Love Hornquist Astrand
8a0e0f9472 do m-r on more then one prime 2011-11-21 20:33:53 -08:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Jeffrey Altman
6850d6a65f avoid uninit variable and unreachable code warnings
most of these warnings are not problems because of ample
use of abort() calls.  However, the large number of warnings
makes it difficult to identify real problems.  Initialize
the variables to shut up the compilers.

Change-Id: I8477c11b17c7b6a7d9074c721fdd2d7303b186a8
2011-05-17 12:02:16 -04:00
Asanka Herath
4b8c523d28 Fix line endings 2010-09-14 08:04:10 -04:00
Asanka Herath
4b1fbabe68 Windows: Fix build rules and includes for libtommath 2010-08-20 16:55:53 -04:00
Love Hornquist Astrand
c6ed8b9a66 indent 2010-08-20 00:07:03 -07:00
Love Hornquist Astrand
90a605432e .c -> .obj 2010-08-20 00:05:16 -07:00
Love Hornquist Astrand
27c94fadca bits 2010-08-20 00:03:16 -07:00
Love Hornquist Astrand
1f226a37b9 try glue in ltm in NTMakefile 2010-08-19 23:55:33 -07:00
Love Hornquist Astrand
aaf598c2fd drop pregen 2010-07-18 14:10:55 -07:00
Love Hornquist Astrand
6c0c936595 select add libtommath 2010-07-18 13:04:03 -07:00
Love Hornquist Astrand
1a625c0908 ltm-0.41 2010-07-01 10:51:29 -07:00