Commit 6d54b80456d71bd3f71264227cc0f2bcebb7e321

Steffen Jaeckel 2019-01-28T20:33:16

Merge tag 'v1.1.0' into develop v1.1.0

diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index 8d96e6a..15637c8 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -71,7 +71,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
    }
 #ifdef MP_8BIT
    /* The search in the loop above was exhaustive in this case */
-   if (a->used == 1 && PRIME_SIZE >= 31) {
+   if ((a->used == 1) && (PRIME_SIZE >= 31)) {
       return MP_OKAY;
    }
 #endif
@@ -126,7 +126,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
        */
 #if defined (MP_8BIT) || defined (LTM_USE_FROBENIUS_TEST)
       err = mp_prime_frobenius_underwood(a, &res);
-      if (err != MP_OKAY && err != MP_ITER) {
+      if ((err != MP_OKAY) && (err != MP_ITER)) {
          goto LBL_B;
       }
       if (res == MP_NO) {
@@ -296,7 +296,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
           * One 8-bit digit is too small, so concatenate two if the size of
           * unsigned int allows for it.
           */
-         if ((sizeof(unsigned int) * CHAR_BIT)/2 >= (sizeof(mp_digit) * CHAR_BIT)) {
+         if (((sizeof(unsigned int) * CHAR_BIT)/2) >= (sizeof(mp_digit) * CHAR_BIT)) {
             if ((err = mp_rand(&b, 1)) != MP_OKAY) {
                goto LBL_B;
             }
@@ -305,10 +305,9 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
             fips_rand &= mask;
          }
 #endif
-         if (fips_rand > ((unsigned int) INT_MAX - DIGIT_BIT)) {
+         if (fips_rand > (unsigned int)(INT_MAX - DIGIT_BIT)) {
             len = INT_MAX / DIGIT_BIT;
-         }
-         else {
+         } else {
             len = (((int)fips_rand + DIGIT_BIT) / DIGIT_BIT);
          }
          /*  Unlikely. */
diff --git a/changes.txt b/changes.txt
index 51da801..aa0c64c 100644
--- a/changes.txt
+++ b/changes.txt
@@ -1,3 +1,25 @@
+Jan 28th, 2019
+v1.1.0
+       -- Christoph Zurnieden contributed FIPS 186.4 compliant
+          prime-checking (PR #113), several other fixes and a load of documentation
+       -- Daniel Mendler provided two's-complement functions (PR #124)
+          and mp_{set,get}_double() (PR #123)
+       -- Francois Perrad took care of linting the sources, provided all fixes and
+          a astylerc to auto-format the sources.
+       -- A bunch of patches by Kevin B Kenny have been back-ported from TCL
+       -- Jan Nijtmans provided the patches to `const`ify all API
+          function arguments (also from TCL)
+       -- mp_rand() has now several native random provider implementations
+          and doesn't rely on `rand()` anymore
+       -- Karel Miko provided fixes when building for MS Windows
+          and re-worked the makefile generating process
+       -- The entire environment and build logic has been extended and improved
+          regarding auto-detection of platforms, libtool and a lot more
+       -- Prevent some potential BOF cases
+       -- Improved/fixed mp_lshd() and mp_invmod()
+       -- A load more bugs were fixed by various contributors
+
+
 Aug 29th, 2017
 v1.0.1
        -- Dmitry Kovalenko provided fixes to mp_add_d() and mp_init_copy()
diff --git a/demo/demo.c b/demo/demo.c
index 717b00d..642eab7 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -741,7 +741,8 @@ int main(void)
    }
    /* Check regarding problem #143 */
 #ifndef MP_8BIT
-   mp_read_radix(&a,    "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF",
+   mp_read_radix(&a,
+                 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF",
                  16);
    err = mp_prime_strong_lucas_selfridge(&a, &cnt);
    /* small problem */
diff --git a/dep.pl b/dep.pl
index e232e7e..f631100 100755
--- a/dep.pl
+++ b/dep.pl
@@ -21,6 +21,7 @@ print {$class} << 'EOS';
  *
  * SPDX-License-Identifier: Unlicense
  */
+
 #if !(defined(LTM1) && defined(LTM2) && defined(LTM3))
 #if defined(LTM2)
 #   define LTM3
diff --git a/doc/bn.tex b/doc/bn.tex
index 87f8aa2..ac84ed3 100644
--- a/doc/bn.tex
+++ b/doc/bn.tex
@@ -49,7 +49,7 @@
 \begin{document}
 \frontmatter
 \pagestyle{empty}
-\title{LibTomMath User Manual \\ v1.0.1}
+\title{LibTomMath User Manual \\ v1.1.0}
 \author{LibTom Projects \\ www.libtom.net}
 \maketitle
 This text, the library and the accompanying textbook are all hereby placed in the public domain.  This book has been
diff --git a/makefile b/makefile
index 4e5f0f1..a07c274 100644
--- a/makefile
+++ b/makefile
@@ -141,6 +141,8 @@ zipup: clean astyle new_file manual poster docs
 	$(MAKE) -C libtommath-$(VERSION)/ pre_gen
 	tar -c libtommath-$(VERSION)/ | xz -6e -c - > ltm-$(VERSION).tar.xz
 	zip -9rq ltm-$(VERSION).zip libtommath-$(VERSION)
+	cp doc/bn.pdf bn-$(VERSION).pdf
+	cp doc/tommath.pdf tommath-$(VERSION).pdf
 	rm -rf libtommath-$(VERSION)
 	gpg -b -a ltm-$(VERSION).tar.xz
 	gpg -b -a ltm-$(VERSION).zip
diff --git a/makefile.shared b/makefile.shared
index d5d1818..3955f83 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -83,6 +83,7 @@ test_standalone: $(LIBNAME) demo/demo.o
 	$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
 	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
 
+.PHONY: mtest
 mtest:
 	cd mtest ; $(CC) $(CFLAGS) $(LDFLAGS) mtest.c -o mtest
 
diff --git a/makefile.unix b/makefile.unix
index a51b973..b89cf47 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -21,7 +21,7 @@ RANLIB    = ranlib
 CFLAGS    = -O2
 LDFLAGS   =
 
-VERSION   = 1.0.1
+VERSION   = 1.1.0
 
 #Compilation flags
 LTM_CFLAGS  = -I. $(CFLAGS)
diff --git a/makefile_include.mk b/makefile_include.mk
index 4814593..ec2205b 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -3,9 +3,9 @@
 #
 
 #version of library
-VERSION=1.0.1
-VERSION_PC=1.0.1
-VERSION_SO=1:1
+VERSION=1.1.0
+VERSION_PC=1.1.0
+VERSION_SO=2:0:1
 
 PLATFORM := $(shell uname | sed -e 's/_.*//')
 
diff --git a/tommath.h b/tommath.h
index 6469edf..ee5da86 100644
--- a/tommath.h
+++ b/tommath.h
@@ -283,9 +283,10 @@ int mp_rand(mp_int *a, int digits);
 int mp_rand_digit(mp_digit *r);
 
 #ifdef MP_PRNG_ENABLE_LTM_RNG
-/* as last resort we will fall back to libtomcrypt's rng_get_bytes()
- * in case you don't use libtomcrypt or use it w/o rng_get_bytes()
- * you have to implement it somewhere else, as it's required */
+/* A last resort to provide random data on systems without any of the other
+ * implemented ways to gather entropy.
+ * It is compatible with `rng_get_bytes()` from libtomcrypt so you could
+ * provide that one and then set `ltm_rng = rng_get_bytes;` */
 extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
 extern void (*ltm_rng_callback)(void);
 #endif