Francois Perrad
25ff85d2bf
move cast inside macro
2019-05-29 08:16:46 +02:00
Daniel Mendler
c7314fa400
deprecate mp_n_root_ex and mp_expt_d_ex
...
These functions were introduced to give some timing guarantees.
However the guarantees are too weak to be useful.
The functions seem to be unused essentially by downstream users.
2019-05-27 15:59:40 +02:00
Daniel Mendler
4b475aca03
fixes for msvc
2019-05-26 11:47:26 +02:00
Daniel Mendler
bcec605af5
deprecate mp_prime_is_divisible and ltm_prime_tab
...
* it is an implementation detail used for prime testing
* there is upcoming work by @czurnieden regarding a generalised prime sieve
* furthermore remove jacobi test (replaced by kronecker)
2019-05-24 12:30:55 +02:00
Daniel Mendler
c7a7bd47af
MP_PREC is an internal macro, it should be defined in tommath_private.h
2019-05-24 12:26:50 +02:00
Daniel Mendler
b0938d70f3
remove obsolete comment
2019-05-24 11:57:47 +02:00
Daniel Mendler
9f607dd5eb
disallow defining MP_DIGIT_BIT, only allow MP_8/16/31/32/64BIT
2019-05-24 11:57:47 +02:00
Daniel Mendler
0a9f5e9bc1
use u32 i64 suffix
2019-05-24 10:21:54 +02:00
Daniel Mendler
d7e1cb4a09
another proposal: use _ul and _l for the long macros
2019-05-24 00:15:57 +02:00
Daniel Mendler
b58c996686
use int32 and uint32 instead of sint and uint
2019-05-24 00:15:57 +02:00
Daniel Mendler
d795985497
improve comment in tommath.h, extend .gitignore
2019-05-24 00:15:57 +02:00
Daniel Mendler
3289c9590b
introduce various mp_set_sint/mp_set_uint functions with precise types
2019-05-24 00:15:57 +02:00
Daniel Mendler
1af0de1f91
deprecate mp_tc_(and|or|xor) in favor of mp_(and|or|xor)
...
* same behavior for positive numbers
* generalisation for negative numbers, treating them as two complement
* improve algorithm, iterate once over the digits, manually perform two complement
* simplify mp_add_d, mp_sub_d
* functions are safe in case of a==c or b==c
* renamed mp_tc_div_2d to mp_signed_rsh (signed right shift)
2019-05-21 18:28:11 +02:00
Daniel Mendler
0dfa9da5a6
make tommath_class.h and tommath_superclass.h private
...
These headers are used for configuration during build time.
Therefore they shouldn't be exposed as part of the public API.
2019-05-21 18:01:17 +02:00
Daniel Mendler
0b840b78a3
make mp_word private
...
mp_word is an internal type and it is problematic if it is exposed
in the public api. See for example #216 - MSVC does not support 128 bit
mp_words. But it is perfectly ok to use those internally in the library,
as long as the library is compiled with GCC.
2019-05-21 15:34:04 +02:00
Daniel Mendler
a8239c2465
deprecate mp_get_bit
...
The return type of mp_get_bit was imprecise (either mp_err or mp_bool),
therefore this function is deprecated in favor of s_mp_get_bit for now.
If we need s_mp_get_bit to be public, we should add it under a different
name. However since mp_set_bit is not available, I don't think there any
downstream users (ab)using mp_int as bitsets.
2019-05-18 10:03:47 +02:00
Daniel Mendler
56e7a40123
deprecate mp_jacobi
2019-05-18 10:03:46 +02:00
Daniel Mendler
89bac3a7a0
deprecate MP_RANGE
2019-05-13 19:15:14 +02:00
Daniel Mendler
4534056c28
use enums mp_err, mp_ord, mp_bool, mp_sign
...
* MP_USE_ENUMS enables enums
* Wc++-compat catches some implicit conversions if MP_USE_ENUMS is defined
* 100% backwards compatible API/ABI if MP_USE_ENUMS is not defined
2019-05-13 19:15:14 +02:00
Francois Perrad
38116079e4
literal suffix
2019-05-13 17:53:10 +02:00
Francois Perrad
2d508723aa
const parameter
2019-05-13 17:53:00 +02:00
Daniel Mendler
7365442ace
No grow necessary in mp_set_int* functions
...
* mp_set_int* always return MP_OKAY
* remove return checks for mp_set_int*
* introduce MP_MIN_PREC
2019-05-12 13:04:45 +02:00
Daniel Mendler
adf9605d6c
add warn_unused_result, found one missing check!
2019-05-11 19:26:58 +02:00
Francois Perrad
cc703a849b
add missing parameter name in prototype
2019-05-11 16:57:04 +02:00
Daniel Mendler
0669e92e78
deprecate mp_prime_random_ex in favor of mp_prime_rand
...
We can use the internal mp_rand generator now, since it generates
numbers which are safe for crypto purposes.
2019-05-11 00:48:48 +02:00
Daniel Mendler
e05215a894
deprecate old macros, deprecate mp_rand_digit
2019-05-09 15:05:47 +02:00
Daniel Mendler
9ddf1e5838
support custom random data source via mp_rand_source
...
* deprecate MP_PRNG_ENABLE_LTM_RNG
* custom mp_rand_source is used always if set, which should be more aligned with user expectations
* use custom source in tune.c
* don't call random number generator once per digit, which is slow
2019-05-08 11:21:10 +02:00
Daniel Mendler
290c28c10e
deprecate PRIME_SIZE in favor of MP_PRIME_SIZE
2019-05-07 09:49:26 +02:00
Daniel Mendler
44d03a6f8b
deprecate LTM_PRIME_* macros in favor of MP_PRIME_*
2019-05-07 09:45:38 +02:00
Daniel Mendler
e2ee39b536
deprecate ltm_prime_callback
2019-05-07 09:36:24 +02:00
Daniel Mendler
80f5fac53b
rename LTM_NO_FILE to MP_NO_FILE
2019-05-07 09:33:56 +02:00
Daniel Mendler
0337d48b67
add MP_NULL_TERMINATED
2019-05-07 09:33:46 +02:00
Daniel Mendler
250751be46
tommath.h: do not expose stdlib.h
2019-05-07 09:32:59 +02:00
Daniel Mendler
818d8fb7f5
Rework handling of tunable cutoffs
...
* In the default settings, a cutoff X can be modified at runtime
by adjusting the corresponding X_CUTOFF variable.
* Tunability of the library can be disabled at compile time
by defining the MP_FIXED_CUTOFFS macro.
* There is an additional file tommath_cutoffs.h, which defines
the default cutoffs. These can be adjusted manually or by the
autotuner.
2019-05-04 13:08:37 +02:00
Daniel Mendler
90eccd5768
prefix private macros by PRIVATE_
2019-04-25 15:36:35 +02:00
Daniel Mendler
632601f405
MP_WARRAY is an internal macro
2019-04-25 13:39:50 +02:00
Daniel Mendler
e45f75fddb
deprecate DIGIT_BIT, use MP_DIGIT_BIT
2019-04-25 13:39:50 +02:00
Daniel Mendler
a8c76138f9
deprecate macros in tommath.h
...
* move MP_DEPRECATED to tommath.h since we need it later
* add MP_DEPRECATED_PRAGMA
2019-04-25 13:39:50 +02:00
Daniel Mendler
87292ed10a
move mp_balance_mul to tommath_private.h
2019-04-12 14:55:09 +02:00
czurnieden
35311aea49
added function mp_ilogb
2019-04-09 21:59:59 +02:00
czurnieden
27ca25cb82
added multiplcation balancing for the Toom-Cook algorithms
2019-04-07 22:15:09 +02:00
Daniel Mendler
ff56140462
shorter headers
2019-04-07 17:26:31 +02:00
Daniel Mendler
70a30ae7a7
remove footers
2019-04-07 17:26:31 +02:00
Daniel Mendler
5da4e0ac01
remove unnecessary size_t casts, fix Wconversion/Wsign-conversion issues
...
Wconversion and Wsign-conversion is still not activated by default,
since there are many issues in demo.c.
2019-04-05 10:52:39 +02:00
czurnieden
769218ccc7
additional functions mp_incr and mp_decr
2019-04-04 07:58:19 +02:00
nijtmans
a3076677be
previous commit removed a little bit too much
2019-03-28 16:18:41 +01:00
nijtmans
ef07da5b8c
mp_min_u32 is not used anywhere anymore, so it can be removed
2019-03-28 16:13:37 +01:00
Daniel Mendler
8eb3bb282e
do not include stdio.h if LTM_NO_FILE is defined
...
stdio.h might not be available on constraint environments
2019-03-26 17:47:16 +01:00
Francois Perrad
6ce271c4db
mp_iseven & mp_isodd becomes C functions
2019-02-02 07:39:23 +01:00
Steffen Jaeckel
1c8c534885
Merge pull request #147 from czurnieden/moarvm_workarounds
...
workaround for the MoarVM problem with MP_GEN_RAND et al.
(cherry picked from commit 11d6e03914
)
2019-01-15 18:22:23 +01:00
Steffen Jaeckel
7ac11218ca
clarify comment of ltm_rng()
2018-12-31 11:54:02 +01:00
Steffen Jaeckel
18355de625
Update file headers
...
[skip ci]
2018-12-29 17:56:20 +01:00
czurnieden
f4449362c0
fixes for MP_8BIT and mx32, prefinal design
2018-12-25 15:17:12 +01:00
czurnieden
08cee4325d
Moved mp_mul_si() into bn_mp_prime_strong_lucas_selfridge.c as a local function
2018-12-25 15:17:03 +01:00
czurnieden
a218ddce9b
Added Fips 186.4 compliance, an additional strong Lucas-Selfridge (for BPSW) and a Frobenius (Paul UNderwood) test, both optional. With documentation.
2018-12-25 15:17:03 +01:00
Mikhail Novosyolov
adbadc70f4
Fix includes
...
Header files which are located in the same directory that the file from where it is included must be included using `" "`, not `< >`.
Otherwise the compiler (gcc 5) cannot understand `#include <tommath_class.h>` in `/usr/include/tommath/tommath.h`.
2018-12-01 15:27:40 +01:00
Daniel Mendler
2ab527b7e0
add mp_get_double, mp_set_double
2018-11-22 12:05:16 +01:00
Steffen Jaeckel
8b9f98baa1
auto-format
...
by executing `make astyle`
2018-09-23 21:37:58 +02:00
Daniel Mendler
eebbcf0644
add mp_complement, mp_tc_div_2d, mp_tc_and, mp_tc_or, mp_tc_xor
2018-09-10 18:48:58 +02:00
Karel Miko
92e8719b80
improved detection of MP_64BIT
2018-05-28 22:02:13 +02:00
Steffen Jaeckel
ef6d85a1a6
don't use rand() in mp_rand()
...
This fixes #103
2018-04-23 22:31:59 +02:00
Michael Shigorin
0bc755139c
add e2k/lcc support
2018-02-27 23:30:43 +01:00
Steffen Jaeckel
f51249b6aa
clean-up file headers
2018-02-27 23:30:43 +01:00
Francois Perrad
43c26b3a3d
use same parameter name between prototype declaration and definition
2017-10-15 19:58:50 +02:00
Francois Perrad
bdbed00079
literal suffix
2017-10-15 19:57:12 +02:00
Steffen Jaeckel
d1fc4a71d3
LLP64 indicates a windows environment
...
as of [1] the only architecture using a LLP64 data model is windows
[1]: https://en.wikipedia.org/wiki/64-bit_computing
2017-10-03 15:18:33 +02:00
Steffen Jaeckel
1346d9830a
there's no __int128 on MSVC, fall back to 32bit MPI's
2017-10-03 09:19:50 +02:00
Francois Perrad
d293ab6604
more constify
2017-09-30 22:57:00 +02:00
nijtmans
f674018a41
constify remaining functions
2017-09-20 16:59:43 +02:00
nijtmans
41de585524
Add 'const' keyword in various places. Adopted from Tcl
2017-09-19 13:35:15 +02:00
Francois Perrad
f89cda034b
format with astyle (step 5)
2017-08-30 20:23:26 +02:00
Francois Perrad
82a2d385db
refactor indentation of preprocessor directives
2017-08-30 20:09:16 +02:00
Francois Perrad
378be117a3
add missing space after comma
2017-08-30 05:52:31 +02:00
Kevin B Kenny
71e3024f30
fix mp_iseven
2017-08-29 23:48:32 +02:00
Steffen Jaeckel
6f21294212
replace SVN tags
2017-08-28 17:00:58 +02:00
Steffen Jaeckel
27115d4b4c
use 64-bit detection code from libtomcrypt
2017-05-09 14:00:26 +02:00
Steffen Jaeckel
c17c47715a
allow external define of MP_GEN_RANDOM
2017-04-09 01:04:07 +02:00
Steffen Jaeckel
d5b0f1e993
loop&shift until enough random data has been read
2016-10-10 00:48:01 +02:00
Tom St Denis
f551dbc8ac
Remove all traces of ulong64 as per comment by Karel M
2016-02-03 13:07:27 -05:00
Francois Perrad
a0b8ce68f7
use unsigned literal
2015-12-02 22:47:51 +01:00
Francois Perrad
e6cfefc1ac
more private stuff
2015-11-19 21:53:32 +01:00
Francois Perrad
f771e317ff
move standard includes
2015-11-19 21:34:58 +01:00
Steffen Jaeckel
4e3f1344a5
provide tommath_private.h
...
tommath.h contains declarations for the public part of the library.
tommath_private.h contains the functions which are private to ltm and
should not be exposed to the public.
2015-11-12 01:49:07 +01:00
Steffen Jaeckel
bd39da2397
use correct value to compare to in mp_isneg() macro
2015-11-12 01:33:25 +01:00
Francois Perrad
e25f1701e4
explicit condition (part H)
2015-11-12 01:20:40 +01:00
Francois Perrad
9f7811624a
add parentheses for explicit operator association
2015-11-12 01:20:40 +01:00
Francois Perrad
84db6f9dbc
add parentheses for explicit operator precedence
2015-11-12 01:20:40 +01:00
Francois Perrad
4430c6bc5f
array declaration with its size
2015-11-12 01:20:40 +01:00
Steffen Jaeckel
7ab90a48ee
use stdint.h for mp_digit and mp_word typedefs
2015-11-01 12:40:31 +01:00
Steffen Jaeckel
8432c4eda5
clarify documentation of mp_div_2d() and mp_mul_2d()
2015-10-30 18:11:32 -04:00
Karel Miko
1c85a28372
adding bn_mp_sqrtmod_prime.c
2015-10-30 18:04:33 -04:00
Tom St Denis
079b0f65a9
Getting ready for v0.43.0 release
...
Also updated my email address...
Signed-off-by: Tom St Denis <tstdenis82@gmail.com>
2015-10-30 17:55:29 -04:00
Donald Chan
676e7ea488
Adding LTM_NO_FILE flag
...
Certain embedded implementatino does not have FILE defined, adding
LTM_NO_FILE flag to avoid compiler errors
Signed-off-by: Donald Chan <hoiho.chan@gmail.com>
Reviewed-by: Tom St Denis <tstdenis82@gmail.com>
2015-10-30 17:41:22 -04:00
Carlin
5d1096b0bd
use arc4random() instead of rand() on *BSD
2014-12-12 01:42:30 +13:00
Steffen Jaeckel
9d697d4686
fix compilation with MP_8BIT or MP_16BIT
2014-12-10 19:01:12 +01:00
Steffen Jaeckel
0e3d3ad29d
add mp_get_long_long() and mp_set_long_long()
2014-12-10 18:59:31 +01:00
Steffen Jaeckel
f88e6a042a
replace mp_set_long() implementation by macro
2014-12-10 18:32:44 +01:00
Moritz Lenz
6df187aea4
Add set_long and get_long functions
...
They work on platform-dependent long ints
2014-12-10 16:53:06 +01:00
Steffen Jaeckel
b425b0ea1f
Revert "balancing multiplication like that in Ruby 1.9"
...
This reverts commit e68439aae1
.
Conflicts:
bn_mp_balance_mul.c
makefile
2014-10-18 18:54:06 +02:00
Steffen Jaeckel
52cfd5ff0a
mp_n_root: add mp_n_root_ex() with parameter 'fast' for mp_expt_d_ex()
...
This change is introduced to be able to choose the underlying
implementation of mp_expt_d_ex()
The implementation of the root_n functionality is now implemented in the
mp_n_root_ex() function.
The parameter 'fast' is just passed over to mp_expt_d_ex().
mp_n_root() defaults to the pre 921be35779
implementation
2014-09-28 13:33:59 +02:00