From 6929c1364c39b41fba63e68260a40bbf48dec93e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 23 Mar 2022 17:50:22 +0100 Subject: [PATCH 1/6] add C89 support for CMake Signed-off-by: Steffen Jaeckel --- CMakeLists.txt | 8 +++++++- makefile | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63b62ac9..525ba1c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,11 +103,17 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE ${LTM_LD_FLAGS} ) +set(PUBLIC_HEADERS tommath.h) +set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install") +if(C89) + list(APPEND PUBLIC_HEADERS tommath_c89.h) +endif() + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME tommath VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} - PUBLIC_HEADER tommath.h + PUBLIC_HEADER "${PUBLIC_HEADERS}" ) option(COMPILE_LTO "Build with LTO enabled") diff --git a/makefile b/makefile index 7fa04d2c..7fe933fa 100644 --- a/makefile +++ b/makefile @@ -173,7 +173,8 @@ c89: -e 's/uint\([0-9][0-9]*\)_t/mp_u\1/g' \ -e 's/int\([0-9][0-9]*\)_t/mp_i\1/g' \ -e 's/__func__/MP_FUNCTION_NAME/g' \ - *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c + -e 's/set(C89 False/set(C89 True/g' \ + *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt c99: @echo "Applying substitutions for c99 compatibility..." @@ -196,7 +197,8 @@ c99: -e 's/mp_u\([0-9][0-9]*\)/uint\1_t/g' \ -e 's/mp_i\([0-9][0-9]*\)/int\1_t/g' \ -e 's/MP_FUNCTION_NAME/__func__/g' \ - *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c + -e 's/set(C89 True/set(C89 False/g' \ + *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt astyle: @echo " * run astyle on all sources" From 7c10db3d15e81049fc098271ba7cc46a6edfbe69 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 28 Apr 2022 11:41:40 +0200 Subject: [PATCH 2/6] support Valgrind for tests when using CMake Signed-off-by: Steffen Jaeckel --- demo/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 06ff898b..c44b7c23 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -61,3 +61,6 @@ target_link_options(${LTM_TEST} BEFORE PUBLIC # CTest #----------------------------------------------------------------------------- add_test(NAME ${LTM_TEST} COMMAND ${LTM_TEST}) + +find_program(MEMORYCHECK_COMMAND valgrind) +set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full") From e03e52d26e5d06435e8e033283317aa35b65ca35 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 28 Apr 2022 11:44:00 +0200 Subject: [PATCH 3/6] ensure compilation with Clang succeeds Signed-off-by: Steffen Jaeckel --- makefile_include.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makefile_include.mk b/makefile_include.mk index dca5c3bc..f88d18be 100644 --- a/makefile_include.mk +++ b/makefile_include.mk @@ -95,6 +95,10 @@ endif # COMPILE_SIZE ifneq ($(findstring clang,$(CC)),) LTM_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header +ifdef IGNORE_SPEED +#for dead code eliminiation +LTM_CFLAGS += -O1 +endif endif ifneq ($(findstring mingw,$(CC)),) LTM_CFLAGS += -Wno-shadow From ae0c9cb208e9ab576d7d0a6689ccf0cf39a06253 Mon Sep 17 00:00:00 2001 From: spaette Date: Sun, 2 Oct 2022 12:53:57 +0200 Subject: [PATCH 4/6] Add typos.sh script --- typos.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 typos.sh diff --git a/typos.sh b/typos.sh new file mode 100755 index 00000000..7ac60984 --- /dev/null +++ b/typos.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +sed -i "s/Dimminished/Diminished/g" libtommath/logs/before_after.dem +sed -i "s/Dimminished/Diminished/g" libtommath/logs/graphs.dem +sed -i "s/accomodate/accommodate/g" libtommath/mp_mul_2.c +sed -i "s/accomodate/accommodate/g" libtommath/mp_2expt.c +sed -i "s/addtional/additional/g" libtommath/mp_prime_is_prime.c +sed -i "s/alot/a lot/g" libtommath/changes.txt +sed -i "s/alot/a lot/g" libtommath/mp_exptmod.c +sed -i "s/alot/a lot/g" libtommath/mp_montgomery_calc_normalization.c +sed -i "s/annonying/annoying/g" libtommath/astylerc +sed -i "s/asymptopically/asymptotically/g" libtommath/s_mp_mul_karatsuba.c +sed -i "s/calulates/calculates/g" libtommath/mp_reduce_setup.c +sed -i "s/configuraion/configuration/g" libtommath/doc/makefile +sed -i "s/eliminiation/elimination/g" libtommath/CMakeLists.txt +sed -i "s/embeded/embedded/g" libtommath/mp_prime_is_prime.c +sed -i "s/endianess/endianness/g" libtommath/demo/test.c +sed -i "s/iterrate/iterate/g" libtommath/s_mp_sqr_comba.c +sed -i "s/iterrate/iterate/g" libtommath/s_mp_mul_high_comba.c +sed -i "s/iterrate/iterate/g" libtommath/s_mp_mul_comba.c +sed -i "s/maginitude/magnitude/g" libtommath/mp_cmp_mag.c +sed -i "s/offseting/offsetting/g" libtommath/s_mp_montgomery_reduce_comba.c +sed -i "s/ofthe/of the/g" libtommath/doc/bn.tex +sed -i "s/otherway/other way/g" libtommath/mp_lshd.c +sed -i "s/packagage/package/g" libtommath/changes.txt +sed -i "s/preemptivly/preemptively/g" libtommath/mp_prime_is_prime.c +sed -i "s/probabilty/probability/g" libtommath/doc/bn.tex +sed -i "s/programms/programs/g" libtommath/doc/bn.tex +sed -i "s/seperate/separate/g" libtommath/changes.txt +sed -i "s/simplifiy/simplify/g" libtommath/demo/test.c +sed -i "s/tollchocked/tolchocked/g" libtommath/mtest/mpi.c +sed -i "s/trimed/trimmed/g" libtommath/mp_clamp.c +sed -i "s/triming/trimming/g" libtommath/demo/mtest_opponent.c +sed -i "s/uncommited/uncommitted/g" libtommath/makefile +sed -i "s/unsused/unused/g" libtommath/changes.txt From c7686f2467a1926db13f9c6ce5480942c8ccd4a4 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 2 Oct 2022 12:58:53 +0200 Subject: [PATCH 5/6] slightly edit, update and run typos.sh Signed-off-by: Steffen Jaeckel --- CMakeLists.txt | 2 +- astylerc | 2 +- changes.txt | 8 ++-- demo/mtest_opponent.c | 2 +- demo/test.c | 8 ++-- doc/bn.tex | 6 +-- doc/makefile | 2 +- logs/before_after.dem | 4 +- logs/graphs.dem | 2 +- makefile | 2 +- mp_2expt.c | 2 +- mp_clamp.c | 2 +- mp_cmp_mag.c | 2 +- mp_exptmod.c | 2 +- mp_lshd.c | 2 +- mp_montgomery_calc_normalization.c | 2 +- mp_mul_2.c | 2 +- mp_prime_is_prime.c | 6 +-- mp_reduce_setup.c | 2 +- mtest/mpi.c | 2 +- s_mp_montgomery_reduce_comba.c | 2 +- s_mp_mul_comba.c | 2 +- s_mp_mul_high_comba.c | 2 +- s_mp_mul_karatsuba.c | 2 +- s_mp_sqr_comba.c | 2 +- typos.sh | 67 +++++++++++++++--------------- 26 files changed, 70 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 525ba1c9..8f852491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ endif() # What compiler do we have and what are their...uhm... peculiarities if(CMAKE_C_COMPILER_ID MATCHES "(C|c?)lang") list(APPEND LTM_C_FLAGS -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header) - # Clang requires at least '-O1' for dead code eliminiation + # Clang requires at least '-O1' for dead code elimination set(CMAKE_C_FLAGS_DEBUG "-O1 ${CMAKE_C_FLAGS_DEBUG}") endif() if(CMAKE_C_COMPILER MATCHES "mingw") diff --git a/astylerc b/astylerc index c5ff7794..029f3584 100644 --- a/astylerc +++ b/astylerc @@ -4,7 +4,7 @@ # usage: # astyle --options=astylerc *.[ch] -# Do not create backup, annonying in the times of git +# Do not create backup, annoying in the times of git suffix=none ## Bracket Style Options diff --git a/changes.txt b/changes.txt index 1b3a7a3a..565500b5 100644 --- a/changes.txt +++ b/changes.txt @@ -19,7 +19,7 @@ v1.2.0 -- Unified, safer and improved API's -- Less magic numbers - return values (where appropriate) and most flags are now enums, this was implemented in a backwards compatible way where return values were int. - -- API's with return values are now by default marked as "warn on unsused result", this + -- API's with return values are now by default marked as "warn on unused result", this can be disabled if required (which will most likely hide bugs), c.f. MP_WUR in tommath.h -- Provide a whole set of setters&getters for different primitive types (long, uint32_t, etc.) -- All those primitive setters are now optimized. @@ -412,8 +412,8 @@ v0.13 -- tons of minor speed-ups in low level add, sub, mul_2 and div_2 which p Jan 17th, 2003 v0.12 -- re-wrote the majority of the makefile so its more portable and will install via "make install" on most *nix platforms - -- Re-packaged all the source as seperate files. Means the library a single - file packagage any more. Instead of just adding "bn.c" you have to add + -- Re-packaged all the source as separate files. Means the library a single + file package any more. Instead of just adding "bn.c" you have to add libtommath.a -- Renamed "bn.h" to "tommath.h" -- Changes to the manual to reflect all of this @@ -444,7 +444,7 @@ v0.08 -- Sped up the multipliers by moving the inner loop variables into a smal -- add etc/pprime.c program which makes numbers which are provably prime. Jan 1st, 2003 -v0.07 -- Removed alot of heap operations from core functions to speed them up +v0.07 -- Removed a lot of heap operations from core functions to speed them up -- Added a root finding function [and mp_sqrt macro like from MPI] -- Added more to manual diff --git a/demo/mtest_opponent.c b/demo/mtest_opponent.c index 25d9b5b9..abd7c161 100644 --- a/demo/mtest_opponent.c +++ b/demo/mtest_opponent.c @@ -82,7 +82,7 @@ static int mtest_opponent(void) #endif for (;;) { - /* randomly clear and re-init one variable, this has the affect of triming the alloc space */ + /* randomly clear and re-init one variable, this has the effect of trimming the alloc space */ switch (abs(rand()) % 7) { case 0: mp_clear(&a); diff --git a/demo/test.c b/demo/test.c index c87f97c0..16fef557 100644 --- a/demo/test.c +++ b/demo/test.c @@ -1548,7 +1548,7 @@ static int test_mp_decr(void) default(realprecision,1000); for(n=3,100,r = floor(a^(1/n));printf("\"" r "\", ")) - All numbers as strings to simplifiy things, especially for the + All numbers as strings to simplify things, especially for the low-mp branch. */ @@ -2166,7 +2166,7 @@ static int test_mp_pack_unpack(void) uint8_t *buf = NULL; mp_order order = MP_LSB_FIRST; - mp_endian endianess = MP_NATIVE_ENDIAN; + mp_endian endianness = MP_NATIVE_ENDIAN; DOR(mp_init_multi(&a, &b, NULL)); DO(mp_rand(&a, 15)); @@ -2180,9 +2180,9 @@ static int test_mp_pack_unpack(void) } DO(mp_pack((void *)buf, count, &written, order, 1uL, - endianess, 0uL, &a)); + endianness, 0uL, &a)); DO(mp_unpack(&b, count, order, 1uL, - endianess, 0uL, (const void *)buf)); + endianness, 0uL, (const void *)buf)); if (mp_cmp(&a, &b) != MP_EQ) { fprintf(stderr, "pack/unpack cycle failed\n"); diff --git a/doc/bn.tex b/doc/bn.tex index 3e01e32d..566b3be3 100644 --- a/doc/bn.tex +++ b/doc/bn.tex @@ -210,7 +210,7 @@ \subsubsection{OpenBSD} At this time two versions of \texttt{libtool} are installed and both are named \texttt{libtool}, unfortunately but GNU \texttt{libtool} has been placed in \texttt{/usr/local/bin/} and the native version in \texttt{/usr/bin/}. The path might be different in other versions of OpenBSD but both -programms differ in the output of \texttt{libtool --version} +programs differ in the output of \texttt{libtool --version} \begin{alltt} $ /usr/local/bin/libtool --version libtool (GNU libtool) 2.4.2 @@ -519,7 +519,7 @@ \subsection{Single Initialization} \end{alltt} This function expects a pointer to an \texttt{mp\_int} structure and will initialize the members -ofthe structure so the \texttt{mp\_int} represents the default integer which is zero. If the +of the structure so the \texttt{mp\_int} represents the default integer which is zero. If the functions returns \texttt{MP\_OKAY} then the \texttt{mp\_int} is ready to be used by the other LibTomMath functions. @@ -2213,7 +2213,7 @@ \subsection{Required Number of Tests} Determining the probability needed to pick the right column is a bit harder. Fips 186.4, for example has $2^{-80}$ for $512$ bit large numbers, $2^{-112}$ for $1024$ bits, and $2^{128}$ for $1536$ bits. It can be seen in table \ref{table:millerrabinrunsp1} that those combinations follow -the diagonal from $(512,2^{-80})$ downwards and to the right to gain a lower probabilty of getting +the diagonal from $(512,2^{-80})$ downwards and to the right to gain a lower probability of getting a composite declared a pseudoprime for the same amount of work or less. If this version of the library has the strong Lucas--Selfridge and/or the Frobenius--Underwood test diff --git a/doc/makefile b/doc/makefile index 84c48e4b..a8c6a653 100644 --- a/doc/makefile +++ b/doc/makefile @@ -40,7 +40,7 @@ manual: mandvi # The file latexindent.pl is in several LaTeX distributions, if not: # https://ctan.org/pkg/latexindent -# Its configuraion is well documented +# Its configuration is well documented # http://mirrors.ctan.org/support/latexindent/documentation/latexindent.pdf pretty: latexindent -s -w -m -l=.latexindent.yaml bn.tex diff --git a/logs/before_after.dem b/logs/before_after.dem index edb59da4..33721ad2 100644 --- a/logs/before_after.dem +++ b/logs/before_after.dem @@ -23,8 +23,8 @@ plot 'sqr-before.log' smooth bezier title "Squaring (without Karatsuba) (before) set output "expt-ba.png" plot 'expt-before.log' smooth bezier title "Exptmod (Montgomery) (before)", \ 'expt-after.log' smooth bezier title "Exptmod (Montgomery) (after)", \ - 'expt_dr-before.log' smooth bezier title "Exptmod (Dimminished Radix) (before)", \ - 'expt_dr-after.log' smooth bezier title "Exptmod (Dimminished Radix) (after)", \ + 'expt_dr-before.log' smooth bezier title "Exptmod (Diminished Radix) (before)", \ + 'expt_dr-after.log' smooth bezier title "Exptmod (Diminished Radix) (after)", \ 'expt_2k-before.log' smooth bezier title "Exptmod (2k Reduction) (before)", \ 'expt_2k-after.log' smooth bezier title "Exptmod (2k Reduction) (after)", \ 'expt_2kl-before.log' smooth bezier title "Exptmod (2k-l Reduction) (before)", \ diff --git a/logs/graphs.dem b/logs/graphs.dem index 538e5c07..fc8ef1bc 100644 --- a/logs/graphs.dem +++ b/logs/graphs.dem @@ -9,7 +9,7 @@ set output "mult.png" plot 'sqr.log' smooth bezier title "Squaring (without Karatsuba)", 'sqr_kara.log' smooth bezier title "Squaring (Karatsuba)", 'mult.log' smooth bezier title "Multiplication (without Karatsuba)", 'mult_kara.log' smooth bezier title "Multiplication (Karatsuba)" set output "expt.png" -plot 'expt.log' smooth bezier title "Exptmod (Montgomery)", 'expt_dr.log' smooth bezier title "Exptmod (Dimminished Radix)", 'expt_2k.log' smooth bezier title "Exptmod (2k Reduction)" +plot 'expt.log' smooth bezier title "Exptmod (Montgomery)", 'expt_dr.log' smooth bezier title "Exptmod (Diminished Radix)", 'expt_2k.log' smooth bezier title "Exptmod (2k Reduction)" set output "invmod.png" plot 'invmod.log' smooth bezier title "Modular Inverse" diff --git a/makefile b/makefile index 7fe933fa..66627437 100644 --- a/makefile +++ b/makefile @@ -130,7 +130,7 @@ zipup: clean astyle new_file docs @# As the pdf creation modifies the tex files, git sometimes detects the @# modified files, but misses that it's put back to its original version. @git update-index --refresh - @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) + @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommitted changes or not a git" && exit 1 ) rm -rf libtommath-$(VERSION) ltm-$(VERSION).* @# files/dirs excluded from "git archive" are defined in .gitattributes git archive --format=tar --prefix=libtommath-$(VERSION)/ HEAD | tar x diff --git a/mp_2expt.c b/mp_2expt.c index 66e85747..4a5fc006 100644 --- a/mp_2expt.c +++ b/mp_2expt.c @@ -15,7 +15,7 @@ mp_err mp_2expt(mp_int *a, int b) /* zero a as per default */ mp_zero(a); - /* grow a to accomodate the single bit */ + /* grow a to accommodate the single bit */ if ((err = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) { return err; } diff --git a/mp_clamp.c b/mp_clamp.c index ae59c401..463f22dc 100644 --- a/mp_clamp.c +++ b/mp_clamp.c @@ -6,7 +6,7 @@ /* trim unused digits * * This is used to ensure that leading zero digits are - * trimed and the leading "used" digit will be non-zero + * trimmed and the leading "used" digit will be non-zero * Typically very fast. Also fixes the sign if there * are no more leading digits */ diff --git a/mp_cmp_mag.c b/mp_cmp_mag.c index e5e502b8..06f22e7c 100644 --- a/mp_cmp_mag.c +++ b/mp_cmp_mag.c @@ -3,7 +3,7 @@ /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ -/* compare maginitude of two ints (unsigned) */ +/* compare magnitude of two ints (unsigned) */ mp_ord mp_cmp_mag(const mp_int *a, const mp_int *b) { int n; diff --git a/mp_exptmod.c b/mp_exptmod.c index b8a5dccc..eaab861e 100644 --- a/mp_exptmod.c +++ b/mp_exptmod.c @@ -5,7 +5,7 @@ /* this is a shell function that calls either the normal or Montgomery * exptmod functions. Originally the call to the montgomery code was - * embedded in the normal function but that wasted alot of stack space + * embedded in the normal function but that wasted a lot of stack space * for nothing (since 99% of the time the Montgomery code would be called) */ mp_err mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y) diff --git a/mp_lshd.c b/mp_lshd.c index bfa8af88..90014e48 100644 --- a/mp_lshd.c +++ b/mp_lshd.c @@ -27,7 +27,7 @@ mp_err mp_lshd(mp_int *a, int b) a->used += b; /* much like mp_rshd this is implemented using a sliding window - * except the window goes the otherway around. Copying from + * except the window goes the other way around. Copying from * the bottom to the top. see mp_rshd.c for more info. */ for (x = a->used; x --> b;) { diff --git a/mp_montgomery_calc_normalization.c b/mp_montgomery_calc_normalization.c index cc07799d..bbb3adbc 100644 --- a/mp_montgomery_calc_normalization.c +++ b/mp_montgomery_calc_normalization.c @@ -7,7 +7,7 @@ * shifts with subtractions when the result is greater than b. * * The method is slightly modified to shift B unconditionally upto just under - * the leading bit of b. This saves alot of multiple precision shifting. + * the leading bit of b. This saves a lot of multiple precision shifting. */ mp_err mp_montgomery_calc_normalization(mp_int *a, const mp_int *b) { diff --git a/mp_mul_2.c b/mp_mul_2.c index 7d7084b3..459fbd29 100644 --- a/mp_mul_2.c +++ b/mp_mul_2.c @@ -10,7 +10,7 @@ mp_err mp_mul_2(const mp_int *a, mp_int *b) int x, oldused; mp_digit r; - /* grow to accomodate result */ + /* grow to accommodate result */ if ((err = mp_grow(b, a->used + 1)) != MP_OKAY) { return err; } diff --git a/mp_prime_is_prime.c b/mp_prime_is_prime.c index 7d73864c..bb24f594 100644 --- a/mp_prime_is_prime.c +++ b/mp_prime_is_prime.c @@ -181,7 +181,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result) * The mp_digit's have a defined bit-size but the size of the * array a.dp is a simple 'int' and this library can not assume full * compliance to the current C-standard (ISO/IEC 9899:2011) because - * it gets used for small embeded processors, too. Some of those MCUs + * it gets used for small embedded processors, too. Some of those MCUs * have compilers that one cannot call standard compliant by any means. * Hence the ugly type-fiddling in the following code. */ @@ -213,12 +213,12 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result) The function mp_rand() goes to some length to use a cryptographically good PRNG. That also means that the chance to always get the same base in the loop is non-zero, although very low. - If the BPSW test and/or the addtional Frobenious test have been + If the BPSW test and/or the additional Frobenious test have been performed instead of just the Miller-Rabin test with the bases 2 and 3, a single extra test should suffice, so such a very unlikely event will not do much harm. - To preemptivly answer the dangling question: no, a witness does not + To preemptively answer the dangling question: no, a witness does not need to be prime. */ for (ix = 0; ix < t; ix++) { diff --git a/mp_reduce_setup.c b/mp_reduce_setup.c index e12056e1..2ce5b96f 100644 --- a/mp_reduce_setup.c +++ b/mp_reduce_setup.c @@ -4,7 +4,7 @@ /* SPDX-License-Identifier: Unlicense */ /* pre-calculate the value required for Barrett reduction - * For a given modulus "b" it calulates the value required in "a" + * For a given modulus "b" it calculates the value required in "a" */ mp_err mp_reduce_setup(mp_int *a, const mp_int *b) { diff --git a/mtest/mpi.c b/mtest/mpi.c index faf09d8d..f9cc4290 100644 --- a/mtest/mpi.c +++ b/mtest/mpi.c @@ -418,7 +418,7 @@ void mp_exch(mp_int *mp1, mp_int *mp2) Release the storage used by an mp_int, and void its fields so that if someone calls mp_clear() again for the same int later, we won't - get tollchocked. + get tolchocked. */ void mp_clear(mp_int *mp) diff --git a/s_mp_montgomery_reduce_comba.c b/s_mp_montgomery_reduce_comba.c index 6f249c49..7472caf3 100644 --- a/s_mp_montgomery_reduce_comba.c +++ b/s_mp_montgomery_reduce_comba.c @@ -61,7 +61,7 @@ mp_err s_mp_montgomery_reduce_comba(mp_int *x, const mp_int *n, mp_digit rho) /* a = a + mu * m * b**i * * This is computed in place and on the fly. The multiplication - * by b**i is handled by offseting which columns the results + * by b**i is handled by offsetting which columns the results * are added to. * * Note the comba method normally doesn't handle carries in the diff --git a/s_mp_mul_comba.c b/s_mp_mul_comba.c index 07dd7913..1afa1fc6 100644 --- a/s_mp_mul_comba.c +++ b/s_mp_mul_comba.c @@ -43,7 +43,7 @@ mp_err s_mp_mul_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs) ty = MP_MIN(b->used-1, ix); tx = ix - ty; - /* this is the number of times the loop will iterrate, essentially + /* this is the number of times the loop will iterate, essentially while (tx++ < a->used && ty-- >= 0) { ... } */ iy = MP_MIN(a->used-tx, ty+1); diff --git a/s_mp_mul_high_comba.c b/s_mp_mul_high_comba.c index 317346df..74960aca 100644 --- a/s_mp_mul_high_comba.c +++ b/s_mp_mul_high_comba.c @@ -35,7 +35,7 @@ mp_err s_mp_mul_high_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs ty = MP_MIN(b->used-1, ix); tx = ix - ty; - /* this is the number of times the loop will iterrate, essentially its + /* this is the number of times the loop will iterate, essentially its while (tx++ < a->used && ty-- >= 0) { ... } */ iy = MP_MIN(a->used-tx, ty+1); diff --git a/s_mp_mul_karatsuba.c b/s_mp_mul_karatsuba.c index bf9271f3..b4652983 100644 --- a/s_mp_mul_karatsuba.c +++ b/s_mp_mul_karatsuba.c @@ -27,7 +27,7 @@ * are saved. Note also that the call to mp_mul can end up back * in this function if the a0, a1, b0, or b1 are above the threshold. * This is known as divide-and-conquer and leads to the famous - * O(N**lg(3)) or O(N**1.584) work which is asymptopically lower than + * O(N**lg(3)) or O(N**1.584) work which is asymptotically lower than * the standard O(N**2) that the baseline/comba methods use. * Generally though the overhead of this method doesn't pay off * until a certain size (N ~ 80) is reached. diff --git a/s_mp_sqr_comba.c b/s_mp_sqr_comba.c index cb88dcc9..1bcc1f93 100644 --- a/s_mp_sqr_comba.c +++ b/s_mp_sqr_comba.c @@ -39,7 +39,7 @@ mp_err s_mp_sqr_comba(const mp_int *a, mp_int *b) ty = MP_MIN(a->used-1, ix); tx = ix - ty; - /* this is the number of times the loop will iterrate, essentially + /* this is the number of times the loop will iterate, essentially while (tx++ < a->used && ty-- >= 0) { ... } */ iy = MP_MIN(a->used-tx, ty+1); diff --git a/typos.sh b/typos.sh index 7ac60984..cc2aa954 100755 --- a/typos.sh +++ b/typos.sh @@ -1,35 +1,36 @@ #!/bin/sh -sed -i "s/Dimminished/Diminished/g" libtommath/logs/before_after.dem -sed -i "s/Dimminished/Diminished/g" libtommath/logs/graphs.dem -sed -i "s/accomodate/accommodate/g" libtommath/mp_mul_2.c -sed -i "s/accomodate/accommodate/g" libtommath/mp_2expt.c -sed -i "s/addtional/additional/g" libtommath/mp_prime_is_prime.c -sed -i "s/alot/a lot/g" libtommath/changes.txt -sed -i "s/alot/a lot/g" libtommath/mp_exptmod.c -sed -i "s/alot/a lot/g" libtommath/mp_montgomery_calc_normalization.c -sed -i "s/annonying/annoying/g" libtommath/astylerc -sed -i "s/asymptopically/asymptotically/g" libtommath/s_mp_mul_karatsuba.c -sed -i "s/calulates/calculates/g" libtommath/mp_reduce_setup.c -sed -i "s/configuraion/configuration/g" libtommath/doc/makefile -sed -i "s/eliminiation/elimination/g" libtommath/CMakeLists.txt -sed -i "s/embeded/embedded/g" libtommath/mp_prime_is_prime.c -sed -i "s/endianess/endianness/g" libtommath/demo/test.c -sed -i "s/iterrate/iterate/g" libtommath/s_mp_sqr_comba.c -sed -i "s/iterrate/iterate/g" libtommath/s_mp_mul_high_comba.c -sed -i "s/iterrate/iterate/g" libtommath/s_mp_mul_comba.c -sed -i "s/maginitude/magnitude/g" libtommath/mp_cmp_mag.c -sed -i "s/offseting/offsetting/g" libtommath/s_mp_montgomery_reduce_comba.c -sed -i "s/ofthe/of the/g" libtommath/doc/bn.tex -sed -i "s/otherway/other way/g" libtommath/mp_lshd.c -sed -i "s/packagage/package/g" libtommath/changes.txt -sed -i "s/preemptivly/preemptively/g" libtommath/mp_prime_is_prime.c -sed -i "s/probabilty/probability/g" libtommath/doc/bn.tex -sed -i "s/programms/programs/g" libtommath/doc/bn.tex -sed -i "s/seperate/separate/g" libtommath/changes.txt -sed -i "s/simplifiy/simplify/g" libtommath/demo/test.c -sed -i "s/tollchocked/tolchocked/g" libtommath/mtest/mpi.c -sed -i "s/trimed/trimmed/g" libtommath/mp_clamp.c -sed -i "s/triming/trimming/g" libtommath/demo/mtest_opponent.c -sed -i "s/uncommited/uncommitted/g" libtommath/makefile -sed -i "s/unsused/unused/g" libtommath/changes.txt +sed -i "s/Dimminished/Diminished/g" logs/before_after.dem +sed -i "s/Dimminished/Diminished/g" logs/graphs.dem +sed -i "s/accomodate/accommodate/g" mp_mul_2.c +sed -i "s/accomodate/accommodate/g" mp_2expt.c +sed -i "s/addtional/additional/g" mp_prime_is_prime.c +sed -i "s/affect/effect/g" demo/mtest_opponent.c +sed -i "s/alot/a lot/g" changes.txt +sed -i "s/alot/a lot/g" mp_exptmod.c +sed -i "s/alot/a lot/g" mp_montgomery_calc_normalization.c +sed -i "s/annonying/annoying/g" astylerc +sed -i "s/asymptopically/asymptotically/g" s_mp_mul_karatsuba.c +sed -i "s/calulates/calculates/g" mp_reduce_setup.c +sed -i "s/configuraion/configuration/g" doc/makefile +sed -i "s/eliminiation/elimination/g" CMakeLists.txt +sed -i "s/embeded/embedded/g" mp_prime_is_prime.c +sed -i "s/endianess/endianness/g" demo/test.c +sed -i "s/iterrate/iterate/g" s_mp_sqr_comba.c +sed -i "s/iterrate/iterate/g" s_mp_mul_high_comba.c +sed -i "s/iterrate/iterate/g" s_mp_mul_comba.c +sed -i "s/maginitude/magnitude/g" mp_cmp_mag.c +sed -i "s/offseting/offsetting/g" s_mp_montgomery_reduce_comba.c +sed -i "s/ofthe/of the/g" doc/bn.tex +sed -i "s/otherway/other way/g" mp_lshd.c +sed -i "s/packagage/package/g" changes.txt +sed -i "s/preemptivly/preemptively/g" mp_prime_is_prime.c +sed -i "s/probabilty/probability/g" doc/bn.tex +sed -i "s/programms/programs/g" doc/bn.tex +sed -i "s/seperate/separate/g" changes.txt +sed -i "s/simplifiy/simplify/g" demo/test.c +sed -i "s/tollchocked/tolchocked/g" mtest/mpi.c +sed -i "s/trimed/trimmed/g" mp_clamp.c +sed -i "s/triming/trimming/g" demo/mtest_opponent.c +sed -i "s/uncommited/uncommitted/g" makefile +sed -i "s/unsused/unused/g" changes.txt From 4de4e4f1473df4bf30afd250ba1dbbaf1043ed54 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 2 Oct 2022 13:03:40 +0200 Subject: [PATCH 6/6] delete typos.sh again you did a good job :) This closes #533 Signed-off-by: Steffen Jaeckel --- typos.sh | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100755 typos.sh diff --git a/typos.sh b/typos.sh deleted file mode 100755 index cc2aa954..00000000 --- a/typos.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -sed -i "s/Dimminished/Diminished/g" logs/before_after.dem -sed -i "s/Dimminished/Diminished/g" logs/graphs.dem -sed -i "s/accomodate/accommodate/g" mp_mul_2.c -sed -i "s/accomodate/accommodate/g" mp_2expt.c -sed -i "s/addtional/additional/g" mp_prime_is_prime.c -sed -i "s/affect/effect/g" demo/mtest_opponent.c -sed -i "s/alot/a lot/g" changes.txt -sed -i "s/alot/a lot/g" mp_exptmod.c -sed -i "s/alot/a lot/g" mp_montgomery_calc_normalization.c -sed -i "s/annonying/annoying/g" astylerc -sed -i "s/asymptopically/asymptotically/g" s_mp_mul_karatsuba.c -sed -i "s/calulates/calculates/g" mp_reduce_setup.c -sed -i "s/configuraion/configuration/g" doc/makefile -sed -i "s/eliminiation/elimination/g" CMakeLists.txt -sed -i "s/embeded/embedded/g" mp_prime_is_prime.c -sed -i "s/endianess/endianness/g" demo/test.c -sed -i "s/iterrate/iterate/g" s_mp_sqr_comba.c -sed -i "s/iterrate/iterate/g" s_mp_mul_high_comba.c -sed -i "s/iterrate/iterate/g" s_mp_mul_comba.c -sed -i "s/maginitude/magnitude/g" mp_cmp_mag.c -sed -i "s/offseting/offsetting/g" s_mp_montgomery_reduce_comba.c -sed -i "s/ofthe/of the/g" doc/bn.tex -sed -i "s/otherway/other way/g" mp_lshd.c -sed -i "s/packagage/package/g" changes.txt -sed -i "s/preemptivly/preemptively/g" mp_prime_is_prime.c -sed -i "s/probabilty/probability/g" doc/bn.tex -sed -i "s/programms/programs/g" doc/bn.tex -sed -i "s/seperate/separate/g" changes.txt -sed -i "s/simplifiy/simplify/g" demo/test.c -sed -i "s/tollchocked/tolchocked/g" mtest/mpi.c -sed -i "s/trimed/trimmed/g" mp_clamp.c -sed -i "s/triming/trimming/g" demo/mtest_opponent.c -sed -i "s/uncommited/uncommitted/g" makefile -sed -i "s/unsused/unused/g" changes.txt