diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-08-30 11:46:33 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-08-30 11:46:33 (GMT) |
commit | 1a00939829b0f8551c44af805ffd701f65c2a58b (patch) | |
tree | 381d6f47d6f24d896c7ab9c0a6e008d52ca207a3 | |
parent | 032ab0fd5ca666fb1e3cbbbb31e69cef956f9a9b (diff) | |
parent | d1a565fde90f8805d8e50073455049f92bef1d43 (diff) | |
download | tcl-1a00939829b0f8551c44af805ffd701f65c2a58b.zip tcl-1a00939829b0f8551c44af805ffd701f65c2a58b.tar.gz tcl-1a00939829b0f8551c44af805ffd701f65c2a58b.tar.bz2 |
Adapt libtommath's "changes.txt", and other text-files. Adapt bn_mp_read_radix.c to latest libtommaths 'tcl-fixes' commit (harmless for Tcl).
-rw-r--r-- | libtommath/LICENSE | 2 | ||||
-rw-r--r-- | libtommath/README.md | 13 | ||||
-rw-r--r-- | libtommath/TODO | 16 | ||||
-rw-r--r-- | libtommath/bn_mp_read_radix.c | 9 | ||||
-rw-r--r-- | libtommath/changes.txt | 2 | ||||
-rw-r--r-- | libtommath/makefile.cygwin_dll | 4 | ||||
-rw-r--r-- | libtommath/makefile_include.mk | 117 | ||||
-rw-r--r-- | libtommath/tommath_superclass.h | 4 |
8 files changed, 158 insertions, 9 deletions
diff --git a/libtommath/LICENSE b/libtommath/LICENSE index a75014d..04d6d1d 100644 --- a/libtommath/LICENSE +++ b/libtommath/LICENSE @@ -24,6 +24,6 @@ Tom St Denis DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. You just DO WHAT THE FUCK YOU WANT TO. + 0. You just DO WHAT THE FUCK YOU WANT TO. [/LICENSE #2] diff --git a/libtommath/README.md b/libtommath/README.md new file mode 100644 index 0000000..866f024 --- /dev/null +++ b/libtommath/README.md @@ -0,0 +1,13 @@ +[![Build Status](https://travis-ci.org/libtom/libtommath.png?branch=develop)](https://travis-ci.org/libtom/libtommath) + +This is the git repository for [LibTomMath](http://www.libtom.org/), a free open source portable number theoretic multiple-precision integer (MPI) library written entirely in C. + +The `develop` branch contains the in-development version. Stable releases are tagged. + +Documentation is built from the LaTeX file `bn.tex`. There is also limited documentation in `tommath.h`. There is also a document, `tommath.pdf`, which describes the goals of the project and many of the algorithms used. + +The project can be build by using `make`. Along with the usual `make`, `make clean` and `make install`, there are several other build targets, see the makefile for details. There are also makefiles for certain specific platforms. + +Tests are located in `demo/` and can be built in two flavors. +* `make test` creates a test binary that is intended to be run against `mtest`. `mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./test`. `mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm +* `make test_standalone` creates a stand-alone test binary that executes several test routines. diff --git a/libtommath/TODO b/libtommath/TODO new file mode 100644 index 0000000..deffba1 --- /dev/null +++ b/libtommath/TODO @@ -0,0 +1,16 @@ +things for book in order of importance... + +- Fix up pseudo-code [only] for combas that are not consistent with source +- Start in chapter 3 [basics] and work up... + - re-write to prose [less abrupt] + - clean up pseudo code [spacing] + - more examples where appropriate and figures + +Goal: + - Get sync done by mid January [roughly 8-12 hours work] + - Finish ch3-6 by end of January [roughly 12-16 hours of work] + - Finish ch7-end by mid Feb [roughly 20-24 hours of work]. + +Goal isn't "first edition" but merely cleaner to read. + + diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c index 11c845c..a4d1c8a 100644 --- a/libtommath/bn_mp_read_radix.c +++ b/libtommath/bn_mp_read_radix.c @@ -48,7 +48,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix) * this allows numbers like 1AB and 1ab to represent the same value * [e.g. in hex] */ - ch = (radix <= 36) ? (char)toupper((unsigned char)*str) : *str; + ch = (radix <= 36) ? (char)toupper((int)*str) : *str; for (y = 0; y < 64; y++) { if (ch == mp_s_rmap[y]) { break; @@ -71,11 +71,10 @@ int mp_read_radix (mp_int * a, const char *str, int radix) } ++str; } - - /* if an illegal character was found, fail. */ - if ( *str != '\0' ) { - mp_zero( a ); + /* if an illegal character was found, fail. */ + if (!(*str == '\0' || *str == '\r' || *str == '\n')) { + mp_zero(a); return MP_VAL; } diff --git a/libtommath/changes.txt b/libtommath/changes.txt index 3379f71..51da801 100644 --- a/libtommath/changes.txt +++ b/libtommath/changes.txt @@ -1,4 +1,4 @@ -XXX, 2017 +Aug 29th, 2017 v1.0.1 -- Dmitry Kovalenko provided fixes to mp_add_d() and mp_init_copy() -- Matt Johnston contributed some improvements to mp_div_2d(), diff --git a/libtommath/makefile.cygwin_dll b/libtommath/makefile.cygwin_dll index 59acad3..6feb5b4 100644 --- a/libtommath/makefile.cygwin_dll +++ b/libtommath/makefile.cygwin_dll @@ -51,3 +51,7 @@ windll: $(OBJECTS) test: $(OBJECTS) windll gcc $(CFLAGS) demo/demo.c libtommath.dll.a -Wl,--enable-auto-import -o test -s cd mtest ; $(CC) -O3 -fomit-frame-pointer -funroll-loops mtest.c -o mtest -s + +/* $Source: /cvs/libtom/libtommath/makefile.cygwin_dll,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:45 $ */ diff --git a/libtommath/makefile_include.mk b/libtommath/makefile_include.mk new file mode 100644 index 0000000..3a599e8 --- /dev/null +++ b/libtommath/makefile_include.mk @@ -0,0 +1,117 @@ +# +# Include makefile for libtommath +# + +#version of library +VERSION=1.0.1 +VERSION_PC=1.0.1 +VERSION_SO=1:1 + +PLATFORM := $(shell uname | sed -e 's/_.*//') + +# default make target +default: ${LIBNAME} + +# Compiler and Linker Names +ifndef CROSS_COMPILE + CROSS_COMPILE= +endif + +ifeq ($(CC),cc) + CC = $(CROSS_COMPILE)gcc +endif +LD=$(CROSS_COMPILE)ld +AR=$(CROSS_COMPILE)ar +RANLIB=$(CROSS_COMPILE)ranlib + +ifndef MAKE + MAKE=make +endif + +CFLAGS += -I./ -Wall -Wsign-compare -Wextra -Wshadow + +ifndef NO_ADDTL_WARNINGS +# additional warnings +CFLAGS += -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align +CFLAGS += -Wstrict-prototypes -Wpointer-arith +endif + +ifdef COMPILE_DEBUG +#debug +CFLAGS += -g3 +else + +ifdef COMPILE_SIZE +#for size +CFLAGS += -Os +else + +ifndef IGNORE_SPEED +#for speed +CFLAGS += -O3 -funroll-loops + +#x86 optimizations [should be valid for any GCC install though] +CFLAGS += -fomit-frame-pointer +endif + +endif # COMPILE_SIZE +endif # COMPILE_DEBUG + +ifneq ($(findstring clang,$(CC)),) +CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header +endif +ifeq ($(PLATFORM), Darwin) +CFLAGS += -Wno-nullability-completeness +endif + +# adjust coverage set +ifneq ($(filter $(shell arch), i386 i686 x86_64 amd64 ia64),) + COVERAGE = test_standalone timing + COVERAGE_APP = ./test && ./ltmtest +else + COVERAGE = test_standalone + COVERAGE_APP = ./test +endif + +HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h +HEADERS=tommath_private.h $(HEADERS_PUB) + +test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0 + +#LIBPATH The directory for libtommath to be installed to. +#INCPATH The directory to install the header files for libtommath. +#DATAPATH The directory to install the pdf docs. +DESTDIR ?= +PREFIX ?= /usr/local +LIBPATH ?= $(PREFIX)/lib +INCPATH ?= $(PREFIX)/include +DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf + +#make the code coverage of the library +# +coverage: CFLAGS += -fprofile-arcs -ftest-coverage -DTIMING_NO_LOGS +coverage: LFLAGS += -lgcov +coverage: LDFLAGS += -lgcov + +coverage: $(COVERAGE) + $(COVERAGE_APP) + +lcov: coverage + rm -f coverage.info + lcov --capture --no-external --no-recursion $(LCOV_ARGS) --output-file coverage.info -q + genhtml coverage.info --output-directory coverage -q + +# target that removes all coverage output +cleancov-clean: + rm -f `find . -type f -name "*.info" | xargs` + rm -rf coverage/ + +# cleans everything - coverage output and standard 'clean' +cleancov: cleancov-clean clean + +clean: + rm -f *.gcda *.gcno *.gcov *.bat *.o *.a *.obj *.lib *.exe *.dll etclib/*.o demo/demo.o test ltmtest mpitest mtest/mtest mtest/mtest.exe \ + *.idx *.toc *.log *.aux *.dvi *.lof *.ind *.ilg *.ps *.log *.s mpi.c *.da *.dyn *.dpi tommath.tex `find . -type f | grep [~] | xargs` *.lo *.la + rm -rf .libs/ + ${MAKE} -C etc/ clean MAKE=${MAKE} + ${MAKE} -C doc/ clean MAKE=${MAKE} diff --git a/libtommath/tommath_superclass.h b/libtommath/tommath_superclass.h index 3a7035e..2489a07 100644 --- a/libtommath/tommath_superclass.h +++ b/libtommath/tommath_superclass.h @@ -60,9 +60,9 @@ #undef BN_FAST_MP_INVMOD_C /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold - * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] + * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without - * trouble. + * trouble. */ #undef BN_S_MP_MUL_DIGS_C #undef BN_S_MP_SQR_C |