Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# #
#############################################################################

# Run the tests based on Ubuntu 16.04
dist: xenial

# Compilation failures are in gcc_errors_*.log
# Failed tests in test_*.log
# Files do not exist in case of success
Expand Down Expand Up @@ -57,6 +60,14 @@ matrix:
# We have only one program and the variable $BUILDOPTIONS
# has only the options to that program: testme.sh

# Check source code format
- env: BUILDOPTIONS='--format'
addons:
apt:
packages:
- astyle
sudo: required

# GCC for the 32-bit architecture (no valgrind yet)
- env: BUILDOPTIONS='--with-cc=gcc --with-m32'
addons:
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_clear.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void mp_clear(mp_int *a)
}

/* free ram */
XFREE(a->dp, sizeof (mp_digit) * (size_t)a->alloc);
XFREE(a->dp, sizeof(mp_digit) * (size_t)a->alloc);

/* reset members to make debugging easier */
a->dp = NULL;
Expand Down
9 changes: 4 additions & 5 deletions bn_mp_decr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ int mp_decr(mp_int *a)
}
return mp_sub_d(a, 1uL,a);
}


#endif
/* ref: \$Format:\%D$ */
/* git commit: \$Format:\%H$ */
/* commit time: \$Format:\%ai$ */

/* ref: $Format:%D$ */
/* git commit: $Format:%H$ */
/* commit time: $Format:%ai$ */
2 changes: 1 addition & 1 deletion bn_mp_grow.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int mp_grow(mp_int *a, int size)
* to overwrite the dp member of a.
*/
tmp = (mp_digit *) XREALLOC(a->dp,
(size_t)a->alloc * sizeof (mp_digit),
(size_t)a->alloc * sizeof(mp_digit),
(size_t)size * sizeof(mp_digit));
if (tmp == NULL) {
/* reallocation failed but "a" is still valid [can be freed] */
Expand Down
8 changes: 4 additions & 4 deletions bn_mp_incr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ int mp_incr(mp_int *a)
}
return mp_add_d(a, 1uL,a);
}

#endif
/* ref: \$Format:\%D$ */
/* git commit: \$Format:\%H$ */
/* commit time: \$Format:\%ai$ */

/* ref: $Format:%D$ */
/* git commit: $Format:%H$ */
/* commit time: $Format:%ai$ */
3 changes: 1 addition & 2 deletions bn_mp_iseven.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
* Michael Fromberger but has been written from scratch with
* additional optimizations in place.
*
* The library is free for all purposes without any express
* guarantee it works.
* SPDX-License-Identifier: Unlicense
*/

int mp_iseven(const mp_int *a)
Expand Down
3 changes: 1 addition & 2 deletions bn_mp_isodd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
* Michael Fromberger but has been written from scratch with
* additional optimizations in place.
*
* The library is free for all purposes without any express
* guarantee it works.
* SPDX-License-Identifier: Unlicense
*/

int mp_isodd(const mp_int *a)
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_shrink.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int mp_shrink(mp_int *a)

if (a->alloc != used) {
if ((tmp = (mp_digit *) XREALLOC(a->dp,
(size_t)a->alloc * sizeof (mp_digit),
(size_t)a->alloc * sizeof(mp_digit),
(size_t)used * sizeof(mp_digit))) == NULL) {
return MP_MEM;
}
Expand Down
45 changes: 0 additions & 45 deletions callgraph.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,6 @@ BN_MP_INIT_SET_INT_C
+--->BN_MP_INIT_C
+--->BN_MP_SET_INT_C
| +--->BN_MP_SET_LONG_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C


BN_MP_INIT_SIZE_C
Expand Down Expand Up @@ -2743,8 +2741,6 @@ BN_MP_IS_SQUARE_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SET_INT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
+--->BN_MP_MOD_C
| +--->BN_MP_INIT_SIZE_C
| | +--->BN_MP_INIT_C
Expand Down Expand Up @@ -5659,8 +5655,6 @@ BN_MP_PRIME_FROBENIUS_UNDERWOOD_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_SET_INT_C
| | | | +--->BN_MP_SET_LONG_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_INIT_C
Expand Down Expand Up @@ -7264,8 +7258,6 @@ BN_MP_PRIME_FROBENIUS_UNDERWOOD_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_INIT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MUL_C
| | | +--->BN_MP_TOOM_MUL_C
| | | | +--->BN_MP_INIT_MULTI_C
Expand Down Expand Up @@ -7616,8 +7608,6 @@ BN_MP_PRIME_FROBENIUS_UNDERWOOD_C
| +--->BN_MP_INIT_C
| +--->BN_MP_CLEAR_C
+--->BN_MP_SET_LONG_C
| +--->BN_MP_GROW_C
| +--->BN_MP_ZERO_C
+--->BN_MP_SQR_C
| +--->BN_MP_TOOM_SQR_C
| | +--->BN_MP_MOD_2D_C
Expand Down Expand Up @@ -7975,8 +7965,6 @@ BN_MP_PRIME_IS_PRIME_C
| | +--->BN_MP_INIT_C
| | +--->BN_MP_SET_INT_C
| | | +--->BN_MP_SET_LONG_C
| | | | +--->BN_MP_GROW_C
| | | | +--->BN_MP_ZERO_C
| +--->BN_MP_MOD_C
| | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_INIT_C
Expand Down Expand Up @@ -9579,8 +9567,6 @@ BN_MP_PRIME_IS_PRIME_C
| | +--->BN_MP_INIT_C
| | +--->BN_MP_CLEAR_C
| +--->BN_MP_SET_LONG_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| +--->BN_MP_SQR_C
| | +--->BN_MP_TOOM_SQR_C
| | | +--->BN_MP_MOD_2D_C
Expand Down Expand Up @@ -9890,8 +9876,6 @@ BN_MP_PRIME_IS_PRIME_C
| | +--->BN_MP_CLAMP_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SET_LONG_C
| | +--->BN_MP_GROW_C
| | +--->BN_MP_ZERO_C
| +--->BN_MP_MUL_C
| | +--->BN_MP_TOOM_MUL_C
| | | +--->BN_MP_INIT_MULTI_C
Expand Down Expand Up @@ -11371,8 +11355,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | +--->BN_MP_INIT_SET_INT_C
| | | +--->BN_MP_SET_INT_C
| | | | +--->BN_MP_SET_LONG_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | +--->BN_MP_DIV_C
Expand Down Expand Up @@ -12909,8 +12891,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | +--->BN_MP_INIT_MULTI_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_SQR_C
| | | +--->BN_MP_TOOM_SQR_C
| | | | +--->BN_MP_MOD_2D_C
Expand Down Expand Up @@ -13200,8 +13180,6 @@ BN_MP_PRIME_NEXT_PRIME_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MUL_C
| | | +--->BN_MP_TOOM_MUL_C
| | | | +--->BN_MP_INIT_MULTI_C
Expand Down Expand Up @@ -13568,8 +13546,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_SET_INT_C
| | | | +--->BN_MP_SET_LONG_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_INIT_C
Expand Down Expand Up @@ -15172,8 +15148,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_SQR_C
| | | +--->BN_MP_TOOM_SQR_C
| | | | +--->BN_MP_MOD_2D_C
Expand Down Expand Up @@ -15483,8 +15457,6 @@ BN_MP_PRIME_RANDOM_EX_C
| | | +--->BN_MP_CLAMP_C
| | +--->BN_MP_INIT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MUL_C
| | | +--->BN_MP_TOOM_MUL_C
| | | | +--->BN_MP_INIT_MULTI_C
Expand Down Expand Up @@ -15874,8 +15846,6 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_SET_INT_C
| | | | +--->BN_MP_SET_LONG_C
| | | | | +--->BN_MP_GROW_C
| | | | | +--->BN_MP_ZERO_C
| | +--->BN_MP_MOD_C
| | | +--->BN_MP_INIT_SIZE_C
| | | | +--->BN_MP_INIT_C
Expand Down Expand Up @@ -17478,8 +17448,6 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
| | | +--->BN_MP_INIT_C
| | | +--->BN_MP_CLEAR_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
| | +--->BN_MP_SQR_C
| | | +--->BN_MP_TOOM_SQR_C
| | | | +--->BN_MP_MOD_2D_C
Expand Down Expand Up @@ -17822,8 +17790,6 @@ BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C
| +--->BN_MP_CLAMP_C
+--->BN_MP_INIT_C
+--->BN_MP_SET_LONG_C
| +--->BN_MP_GROW_C
| +--->BN_MP_ZERO_C
+--->BN_MP_MUL_C
| +--->BN_MP_TOOM_MUL_C
| | +--->BN_MP_INIT_MULTI_C
Expand Down Expand Up @@ -18666,13 +18632,9 @@ BN_MP_SET_DOUBLE_C

BN_MP_SET_INT_C
+--->BN_MP_SET_LONG_C
| +--->BN_MP_GROW_C
| +--->BN_MP_ZERO_C


BN_MP_SET_LONG_C
+--->BN_MP_GROW_C
+--->BN_MP_ZERO_C


BN_MP_SET_LONG_LONG_C
Expand Down Expand Up @@ -19855,7 +19817,6 @@ BN_MP_SQRTMOD_PRIME_C
| +--->BN_MP_CLAMP_C
+--->BN_MP_SET_INT_C
| +--->BN_MP_SET_LONG_C
| | +--->BN_MP_GROW_C
+--->BN_MP_SQRMOD_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SQR_C
Expand Down Expand Up @@ -20593,8 +20554,6 @@ BN_MP_TC_AND_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SET_INT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
+--->BN_MP_MUL_2D_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
Expand Down Expand Up @@ -20655,8 +20614,6 @@ BN_MP_TC_OR_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SET_INT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
+--->BN_MP_MUL_2D_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
Expand Down Expand Up @@ -20698,8 +20655,6 @@ BN_MP_TC_XOR_C
| +--->BN_MP_INIT_C
| +--->BN_MP_SET_INT_C
| | +--->BN_MP_SET_LONG_C
| | | +--->BN_MP_GROW_C
| | | +--->BN_MP_ZERO_C
+--->BN_MP_MUL_2D_C
| +--->BN_MP_COPY_C
| | +--->BN_MP_GROW_C
Expand Down
3 changes: 2 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ perlcritic:
perlcritic *.pl doc/*.pl

astyle:
astyle --options=astylerc $(OBJECTS:.o=.c) tommath*.h demo/*.c etc/*.c mtest/mtest.c
@echo " * run astyle on all sources"
@astyle --options=astylerc --formatted $(OBJECTS:.o=.c) tommath*.h demo/*.c etc/*.c mtest/mtest.c
23 changes: 23 additions & 0 deletions testme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ _help()
echo " --all Choose all architectures and gcc and clang"
echo " as compilers but does not run valgrind."
echo
echo " --format Runs the various source-code formatters"
echo " and generators and checks if the sources"
echo " are clean."
echo
echo " -h"
echo " --help This message"
echo
Expand Down Expand Up @@ -168,6 +172,7 @@ MTEST_RAND=""
VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
#VALGRIND_OPTS=""
VALGRIND_BIN=""
CHECK_FORMAT=""

alive_pid=0

Expand Down Expand Up @@ -225,6 +230,9 @@ do
--mtest-real-rand)
MTEST_RAND="-DLTM_MTEST_REAL_RAND"
;;
--format)
CHECK_FORMAT="1"
;;
--all)
COMPILERS="gcc clang"
ARCHFLAGS="-m64 -m32 -mx32"
Expand All @@ -243,6 +251,21 @@ do
shift
done

function _check_git() {
git update-index --refresh >/dev/null || true
git diff-index --quiet HEAD -- . || ( echo "FAILURE: $*" && exit 1 )
}

if [[ "$CHECK_FORMAT" == "1" ]]
then
make astyle
_check_git "make astyle"
make new_file
_check_git "make format"
perl helper.pl -a
exit $?
fi

[[ "$VALGRIND_BIN" == "" ]] && VALGRIND_OPTS=""

# default to CC environment variable if no compiler is defined but some other options
Expand Down
2 changes: 0 additions & 2 deletions tommath_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,6 @@
#endif

#if defined(BN_MP_SET_LONG_C)
# define BN_MP_GROW_C
# define BN_MP_ZERO_C
#endif

#if defined(BN_MP_SET_LONG_LONG_C)
Expand Down