# HG changeset patch # User Matt Johnston # Date 1168485295 0 # Node ID 5ff8218bcee9aa28d6508a5a8a70ab04c62fb03e # Parent fb54020f78e1c5fb909a732ae57974e63dd9fe80# Parent a05fb340a95d7da3d0d3191fd7e5fb440cd29523 propagate from branch 'au.asn.ucc.matt.ltm.dropbear' (head 2af95f00ebd5bb7a28b3817db1218442c935388e) to branch 'au.asn.ucc.matt.dropbear' (head ecd779509ef23a8cdf64888904fc9b31d78aa933) diff -r a05fb340a95d -r 5ff8218bcee9 Makefile.in diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/Makefile.in --- a/libtommath/Makefile.in Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/Makefile.in Thu Jan 11 03:14:55 2007 +0000 @@ -3,7 +3,7 @@ #Tom St Denis #version of library -VERSION=0.35 +VERSION=0.40 VPATH=@srcdir@ srcdir=@srcdir@ @@ -13,6 +13,8 @@ #CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare +ifndef IGNORE_SPEED + #for speed #CFLAGS += -O3 -funroll-all-loops @@ -26,13 +28,25 @@ #CFLAGS += -g3 #install as this user -USER=root -GROUP=root +ifndef INSTALL_GROUP + GROUP=wheel +else + GROUP=$(INSTALL_GROUP) +endif -default: libtommath.a +ifndef INSTALL_USER + USER=root +else + USER=$(INSTALL_USER) +endif #default files to install -LIBNAME=libtommath.a +ifndef LIBNAME + LIBNAME=libtommath.a +endif + +default: ${LIBNAME} + HEADERS=tommath.h tommath_class.h tommath_superclass.h #LIBPATH-The directory for libtommath to be installed to. @@ -71,9 +85,9 @@ bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \ bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o -libtommath.a: $(OBJECTS) - $(AR) $(ARFLAGS) libtommath.a $(OBJECTS) - $(RANLIB) libtommath.a +$(LIBNAME): $(OBJECTS) + $(AR) $(ARFLAGS) $@ $(OBJECTS) + $(RANLIB) $@ #make a profiled library (takes a while!!!) # @@ -95,27 +109,27 @@ ./ltmtest rm -f *.o ltmtest $(CC) $(CFLAGS) -fbranch-probabilities -DTESTING -c mpi.c -o mpi.o - $(AR) $(ARFLAGS) libtommath.a mpi.o - ranlib libtommath.a + $(AR) $(ARFLAGS) $(LIBNAME) mpi.o + $(RANLIB) $(LIBNAME) -install: libtommath.a +install: $(LIBNAME) install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH) install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) -test: libtommath.a demo/demo.o - $(CC) $(CFLAGS) demo/demo.o libtommath.a -o test +test: $(LIBNAME) demo/demo.o + $(CC) $(CFLAGS) demo/demo.o $(LIBNAME) -o test mtest: test cd mtest ; $(CC) $(CFLAGS) mtest.c -o mtest -timing: libtommath.a - $(CC) $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o ltmtest +timing: $(LIBNAME) + $(CC) $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o ltmtest # makes the LTM book DVI file, requires tetex, perl and makeindex [part of tetex I think] docdvi: tommath.src - cd pics ; make + cd pics ; MAKE=${MAKE} ${MAKE} echo "hello" > tommath.ind perl booker.pl latex tommath > /dev/null @@ -132,7 +146,7 @@ docs: docdvi dvipdf tommath rm -f tommath.log tommath.aux tommath.dvi tommath.idx tommath.toc tommath.lof tommath.ind tommath.ilg - cd pics ; make clean + cd pics ; MAKE=${MAKE} ${MAKE} clean #LTM user manual mandvi: bn.tex @@ -152,14 +166,21 @@ clean: rm -f *.bat *.pdf *.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 *.lo *.la + *.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 - cd etc && make clean - cd pics && make clean + cd etc ; MAKE=${MAKE} ${MAKE} clean + cd pics ; MAKE=${MAKE} ${MAKE} clean + +#zipup the project (take that!) +no_oops: clean + cd .. ; cvs commit + echo Scanning for scratch/dirty files + find . -type f | grep -v CVS | xargs -n 1 bash mess.sh zipup: clean manual poster docs perl gen.pl ; mv mpi.c pre_gen/ ; \ cd .. ; rm -rf ltm* libtommath-$(VERSION) ; mkdir libtommath-$(VERSION) ; \ cp -R ./libtommath/* ./libtommath-$(VERSION)/ ; \ tar -c libtommath-$(VERSION)/* | bzip2 -9vvc > ltm-$(VERSION).tar.bz2 ; \ - zip -9 -r ltm-$(VERSION).zip libtommath-$(VERSION)/* + zip -9 -r ltm-$(VERSION).zip libtommath-$(VERSION)/* ; \ + mv -f ltm* ~ ; rm -rf libtommath-$(VERSION) diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/TODO --- a/libtommath/TODO Thu Jan 11 03:05:30 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -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 -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn.tex --- a/libtommath/bn.tex Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn.tex Thu Jan 11 03:14:55 2007 +0000 @@ -1,4 +1,4 @@ -\documentclass[b5paper]{book} +\documentclass[synpaper]{book} \usepackage{hyperref} \usepackage{makeidx} \usepackage{amssymb} @@ -49,8 +49,8 @@ \begin{document} \frontmatter \pagestyle{empty} -\title{LibTomMath User Manual \\ v0.35} -\author{Tom St Denis \\ tomstdenis@iahu.ca} +\title{LibTomMath User Manual \\ v0.40} +\author{Tom St Denis \\ tomstdenis@gmail.com} \maketitle This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been formatted for B5 [176x250] paper using the \LaTeX{} {\em book} macro package. diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_error.c --- a/libtommath/bn_error.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_error.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static const struct { @@ -41,3 +41,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_error.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_fast_mp_invmod.c --- a/libtommath/bn_fast_mp_invmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_fast_mp_invmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes the modular inverse via binary extended euclidean algorithm, @@ -142,3 +142,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_fast_mp_montgomery_reduce.c --- a/libtommath/bn_fast_mp_montgomery_reduce.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_fast_mp_montgomery_reduce.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes xR**-1 == x (mod N) via Montgomery Reduction @@ -166,3 +166,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_fast_s_mp_mul_digs.c --- a/libtommath/bn_fast_s_mp_mul_digs.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_fast_s_mp_mul_digs.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Fast (comba) multiplier @@ -70,6 +70,7 @@ /* execute loop */ for (iz = 0; iz < iy; ++iz) { _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); + } /* store term */ @@ -77,10 +78,7 @@ /* make next carry */ _W = _W >> ((mp_word)DIGIT_BIT); - } - - /* store final carry */ - W[ix] = (mp_digit)(_W & MP_MASK); + } /* setup dest */ olduse = c->used; @@ -103,3 +101,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_fast_s_mp_mul_high_digs.c --- a/libtommath/bn_fast_s_mp_mul_high_digs.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_fast_s_mp_mul_high_digs.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* this is a modified version of fast_s_mul_digs that only produces @@ -70,9 +70,6 @@ _W = _W >> ((mp_word)DIGIT_BIT); } - /* store final carry */ - W[ix] = (mp_digit)(_W & MP_MASK); - /* setup dest */ olduse = c->used; c->used = pa; @@ -81,7 +78,7 @@ register mp_digit *tmpc; tmpc = c->dp + digs; - for (ix = digs; ix <= pa; ix++) { + for (ix = digs; ix < pa; ix++) { /* now extract the previous digit [below the carry] */ *tmpc++ = W[ix]; } @@ -95,3 +92,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/11/14 03:46:25 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_fast_s_mp_sqr.c --- a/libtommath/bn_fast_s_mp_sqr.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_fast_s_mp_sqr.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* the jist of squaring... @@ -108,3 +108,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_2expt.c --- a/libtommath/bn_mp_2expt.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_2expt.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes a = 2**b @@ -42,3 +42,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_abs.c --- a/libtommath/bn_mp_abs.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_abs.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = |a| @@ -37,3 +37,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_add.c --- a/libtommath/bn_mp_add.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_add.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level addition (handles signs) */ @@ -47,3 +47,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_add_d.c --- a/libtommath/bn_mp_add_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_add_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* single digit addition */ @@ -40,6 +40,9 @@ /* fix sign */ a->sign = c->sign = MP_NEG; + /* clamp */ + mp_clamp(c); + return res; } @@ -103,3 +106,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_addmod.c --- a/libtommath/bn_mp_addmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_addmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a + b (mod c) */ @@ -35,3 +35,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_and.c --- a/libtommath/bn_mp_and.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_and.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* AND two ints together */ @@ -51,3 +51,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_clamp.c --- a/libtommath/bn_mp_clamp.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_clamp.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* trim unused digits @@ -38,3 +38,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_clear.c --- a/libtommath/bn_mp_clear.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_clear.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* clear one (frees) */ @@ -41,3 +41,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_clear_multi.c --- a/libtommath/bn_mp_clear_multi.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_clear_multi.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #include @@ -28,3 +28,7 @@ va_end(args); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_cmp.c --- a/libtommath/bn_mp_cmp.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_cmp.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare two ints (signed)*/ @@ -37,3 +37,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_cmp_d.c --- a/libtommath/bn_mp_cmp_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_cmp_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare a digit */ @@ -38,3 +38,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_cmp_mag.c --- a/libtommath/bn_mp_cmp_mag.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_cmp_mag.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare maginitude of two ints (unsigned) */ @@ -49,3 +49,7 @@ return MP_EQ; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_cnt_lsb.c --- a/libtommath/bn_mp_cnt_lsb.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_cnt_lsb.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static const int lnz[16] = { @@ -47,3 +47,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_copy.c --- a/libtommath/bn_mp_copy.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_copy.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* copy, b = a */ @@ -62,3 +62,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_count_bits.c --- a/libtommath/bn_mp_count_bits.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_count_bits.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* returns the number of bits in an int */ @@ -39,3 +39,7 @@ return r; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_div.c --- a/libtommath/bn_mp_div.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_div.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #ifdef BN_MP_DIV_SMALL @@ -288,3 +288,7 @@ #endif #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_div_2.c --- a/libtommath/bn_mp_div_2.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_div_2.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = a/2 */ @@ -62,3 +62,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_div_2d.c --- a/libtommath/bn_mp_div_2d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_div_2d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ @@ -91,3 +91,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_div_3.c --- a/libtommath/bn_mp_div_3.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_div_3.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* divide by three (based on routine from MPI and the GMP manual) */ @@ -73,3 +73,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_div_d.c --- a/libtommath/bn_mp_div_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_div_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static int s_is_power_of_two(mp_digit b, int *p) @@ -104,3 +104,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_dr_is_modulus.c --- a/libtommath/bn_mp_dr_is_modulus.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_dr_is_modulus.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if a number is a valid DR modulus */ @@ -37,3 +37,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_dr_reduce.c --- a/libtommath/bn_mp_dr_reduce.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_dr_reduce.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduce "x" in place modulo "n" using the Diminished Radix algorithm. @@ -88,3 +88,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_dr_setup.c --- a/libtommath/bn_mp_dr_setup.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_dr_setup.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -26,3 +26,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_exch.c --- a/libtommath/bn_mp_exch.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_exch.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* swap the elements of two integers, for cases where you can't simply swap the @@ -28,3 +28,7 @@ *b = t; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_expt_d.c --- a/libtommath/bn_mp_expt_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_expt_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* calculate c = a**b using a square-multiply algorithm */ @@ -51,3 +51,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_exptmod.c --- a/libtommath/bn_mp_exptmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_exptmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ @@ -66,7 +66,7 @@ } /* modified diminished radix reduction */ -#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) +#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C) if (mp_reduce_is_2k_l(P) == MP_YES) { return s_mp_exptmod(G, X, P, Y, 1); } @@ -106,3 +106,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_exptmod_fast.c --- a/libtommath/bn_mp_exptmod_fast.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_exptmod_fast.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85 @@ -315,3 +315,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_exteuclid.c --- a/libtommath/bn_mp_exteuclid.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_exteuclid.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Extended euclidean algorithm of (a, b) produces @@ -76,3 +76,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_fread.c --- a/libtommath/bn_mp_fread.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_fread.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read a bigint from a file stream in ASCII */ @@ -61,3 +61,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_fwrite.c --- a/libtommath/bn_mp_fwrite.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_fwrite.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ int mp_fwrite(mp_int *a, int radix, FILE *stream) @@ -46,3 +46,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_gcd.c --- a/libtommath/bn_mp_gcd.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_gcd.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Greatest Common Divisor using the binary method */ @@ -22,21 +22,13 @@ int k, u_lsb, v_lsb, res; /* either zero than gcd is the largest */ - if (mp_iszero (a) == 1 && mp_iszero (b) == 0) { + if (mp_iszero (a) == MP_YES) { return mp_abs (b, c); } - if (mp_iszero (a) == 0 && mp_iszero (b) == 1) { + if (mp_iszero (b) == MP_YES) { return mp_abs (a, c); } - /* optimized. At this point if a == 0 then - * b must equal zero too - */ - if (mp_iszero (a) == 1) { - mp_zero(c); - return MP_OKAY; - } - /* get copies of a and b we can modify */ if ((res = mp_init_copy (&u, a)) != MP_OKAY) { return res; @@ -107,3 +99,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_get_int.c --- a/libtommath/bn_mp_get_int.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_get_int.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the lower 32-bits of an mp_int */ @@ -39,3 +39,7 @@ return res & 0xFFFFFFFFUL; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_grow.c --- a/libtommath/bn_mp_grow.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_grow.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* grow as required */ @@ -51,3 +51,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init.c --- a/libtommath/bn_mp_init.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* init a new mp_int */ @@ -40,3 +40,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init_copy.c --- a/libtommath/bn_mp_init_copy.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init_copy.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* creates "a" then copies b into it */ @@ -26,3 +26,7 @@ return mp_copy (b, a); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init_multi.c --- a/libtommath/bn_mp_init_multi.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init_multi.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #include @@ -53,3 +53,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init_set.c --- a/libtommath/bn_mp_init_set.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init_set.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* initialize and set a digit */ @@ -26,3 +26,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init_set_int.c --- a/libtommath/bn_mp_init_set_int.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init_set_int.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* initialize and set a digit */ @@ -25,3 +25,7 @@ return mp_set_int(a, b); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_init_size.c --- a/libtommath/bn_mp_init_size.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_init_size.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* init an mp_init for a given size */ @@ -42,3 +42,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_invmod.c --- a/libtommath/bn_mp_invmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_invmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* hac 14.61, pp608 */ @@ -37,3 +37,7 @@ return MP_VAL; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_invmod_slow.c --- a/libtommath/bn_mp_invmod_slow.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_invmod_slow.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* hac 14.61, pp608 */ @@ -169,3 +169,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_is_square.c --- a/libtommath/bn_mp_is_square.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_is_square.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Check if remainders are possible squares - fast exclude non-squares */ @@ -103,3 +103,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_jacobi.c --- a/libtommath/bn_mp_jacobi.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_jacobi.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes the jacobi c = (a | n) (or Legendre if n is prime) @@ -99,3 +99,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_karatsuba_mul.c --- a/libtommath/bn_mp_karatsuba_mul.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_karatsuba_mul.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = |a| * |b| using Karatsuba Multiplication using @@ -26,12 +26,12 @@ * b = b1 * B**n + b0 * * Then, a * b => - a1b1 * B**2n + ((a1 - a0)(b1 - b0) + a0b0 + a1b1) * B + a0b0 + a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0 * * Note that a1b1 and a0b0 are used twice and only need to be * computed once. So in total three half size (half # of * digit) multiplications are performed, a0b0, a1b1 and - * (a1-b1)(a0-b0) + * (a1+b1)(a0+b0) * * Note that a multiplication of half the digits requires * 1/4th the number of single precision multiplications so in @@ -122,19 +122,19 @@ if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY) goto X1Y1; /* x1y1 = x1*y1 */ - /* now calc x1-x0 and y1-y0 */ - if (mp_sub (&x1, &x0, &t1) != MP_OKAY) + /* now calc x1+x0 and y1+y0 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) goto X1Y1; /* t1 = x1 - x0 */ - if (mp_sub (&y1, &y0, &x0) != MP_OKAY) + if (s_mp_add (&y1, &y0, &x0) != MP_OKAY) goto X1Y1; /* t2 = y1 - y0 */ if (mp_mul (&t1, &x0, &t1) != MP_OKAY) - goto X1Y1; /* t1 = (x1 - x0) * (y1 - y0) */ + goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */ /* add x0y0 */ if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY) goto X1Y1; /* t2 = x0y0 + x1y1 */ - if (mp_sub (&x0, &t1, &t1) != MP_OKAY) - goto X1Y1; /* t1 = x0y0 + x1y1 - (x1-x0)*(y1-y0) */ + if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY) + goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */ /* shift by B */ if (mp_lshd (&t1, B) != MP_OKAY) @@ -161,3 +161,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_mul.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_karatsuba_sqr.c --- a/libtommath/bn_mp_karatsuba_sqr.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_karatsuba_sqr.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Karatsuba squaring, computes b = a*a using three @@ -80,8 +80,8 @@ if (mp_sqr (&x1, &x1x1) != MP_OKAY) goto X1X1; /* x1x1 = x1*x1 */ - /* now calc (x1-x0)**2 */ - if (mp_sub (&x1, &x0, &t1) != MP_OKAY) + /* now calc (x1+x0)**2 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) goto X1X1; /* t1 = x1 - x0 */ if (mp_sqr (&t1, &t1) != MP_OKAY) goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */ @@ -89,8 +89,8 @@ /* add x0y0 */ if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY) goto X1X1; /* t2 = x0x0 + x1x1 */ - if (mp_sub (&t2, &t1, &t1) != MP_OKAY) - goto X1X1; /* t1 = x0x0 + x1x1 - (x1-x0)*(x1-x0) */ + if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY) + goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */ /* shift by B */ if (mp_lshd (&t1, B) != MP_OKAY) @@ -115,3 +115,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_sqr.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_lcm.c --- a/libtommath/bn_mp_lcm.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_lcm.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes least common multiple as |a*b|/(a, b) */ @@ -54,3 +54,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_lshd.c --- a/libtommath/bn_mp_lshd.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_lshd.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift left a certain amount of digits */ @@ -61,3 +61,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mod.c --- a/libtommath/bn_mp_mod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = a mod b, 0 <= c < b */ @@ -42,3 +42,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mod_2d.c --- a/libtommath/bn_mp_mod_2d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mod_2d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* calc a value mod 2**b */ @@ -49,3 +49,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mod_d.c --- a/libtommath/bn_mp_mod_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mod_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ int @@ -21,3 +21,7 @@ return mp_div_d(a, b, NULL, c); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_montgomery_calc_normalization.c --- a/libtommath/bn_mp_montgomery_calc_normalization.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_montgomery_calc_normalization.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* @@ -53,3 +53,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_montgomery_reduce.c --- a/libtommath/bn_mp_montgomery_reduce.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_montgomery_reduce.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes xR**-1 == x (mod N) via Montgomery Reduction */ @@ -112,3 +112,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_montgomery_setup.c --- a/libtommath/bn_mp_montgomery_setup.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_montgomery_setup.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* setups the montgomery reduction stuff */ @@ -48,8 +48,12 @@ #endif /* rho = -1/m mod b */ - *rho = (((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; + *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/04 21:34:03 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mul.c --- a/libtommath/bn_mp_mul.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mul.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level multiplication (handles sign) */ @@ -60,3 +60,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mul_2.c --- a/libtommath/bn_mp_mul_2.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mul_2.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = a*2 */ @@ -76,3 +76,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mul_2d.c --- a/libtommath/bn_mp_mul_2d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mul_2d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift left by a certain bit count */ @@ -79,3 +79,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mul_d.c --- a/libtommath/bn_mp_mul_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mul_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiply by a digit */ @@ -73,3 +73,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_mulmod.c --- a/libtommath/bn_mp_mulmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_mulmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,12 +12,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a * b (mod c) */ -int -mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) { int res; mp_int t; @@ -35,3 +34,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_n_root.c --- a/libtommath/bn_mp_n_root.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_n_root.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* find the n'th root of an integer @@ -126,3 +126,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_neg.c --- a/libtommath/bn_mp_neg.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_neg.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = -a */ @@ -34,3 +34,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_or.c --- a/libtommath/bn_mp_or.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_or.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* OR two ints together */ @@ -44,3 +44,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_fermat.c --- a/libtommath/bn_mp_prime_fermat.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_fermat.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* performs one Fermat test. @@ -56,3 +56,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_is_divisible.c --- a/libtommath/bn_mp_prime_is_divisible.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_is_divisible.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if an integers is divisible by one @@ -44,3 +44,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_is_prime.c --- a/libtommath/bn_mp_prime_is_prime.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_is_prime.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* performs a variable number of rounds of Miller-Rabin @@ -77,3 +77,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_miller_rabin.c --- a/libtommath/bn_mp_prime_miller_rabin.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_miller_rabin.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Miller-Rabin test of "a" to the base of "b" as described in @@ -97,3 +97,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_next_prime.c --- a/libtommath/bn_mp_prime_next_prime.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_next_prime.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* finds the next prime after the number "a" using "t" trials @@ -164,3 +164,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_next_prime.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_rabin_miller_trials.c --- a/libtommath/bn_mp_prime_rabin_miller_trials.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_rabin_miller_trials.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ @@ -46,3 +46,7 @@ #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_prime_random_ex.c --- a/libtommath/bn_mp_prime_random_ex.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_prime_random_ex.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* makes a truly random prime of a given size (bits), @@ -62,10 +62,8 @@ maskOR_msb = 0; maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0; if (flags & LTM_PRIME_2MSB_ON) { - maskOR_msb |= 1 << ((size - 2) & 7); - } else if (flags & LTM_PRIME_2MSB_OFF) { - maskAND &= ~(1 << ((size - 2) & 7)); - } + maskOR_msb |= 0x80 >> ((9 - size) & 7); + } /* get the maskOR_lsb */ maskOR_lsb = 1; @@ -121,3 +119,7 @@ #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_radix_size.c --- a/libtommath/bn_mp_radix_size.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_radix_size.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* returns size of ASCII reprensentation */ @@ -36,7 +36,7 @@ } if (mp_iszero(a) == MP_YES) { - *size = 2; + *size = 2; return MP_OKAY; } @@ -72,3 +72,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_radix_smap.c --- a/libtommath/bn_mp_radix_smap.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_radix_smap.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,9 +12,13 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* chars used in radix conversions */ const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_rand.c --- a/libtommath/bn_mp_rand.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_rand.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* makes a pseudo-random int of a given size */ @@ -49,3 +49,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_read_radix.c --- a/libtommath/bn_mp_read_radix.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_read_radix.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read a string [ASCII] in a given radix */ @@ -21,6 +21,9 @@ int y, res, neg; char ch; + /* zero the digit bignum */ + mp_zero(a); + /* make sure the radix is ok */ if (radix < 2 || radix > 64) { return MP_VAL; @@ -76,3 +79,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_read_signed_bin.c --- a/libtommath/bn_mp_read_signed_bin.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_read_signed_bin.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,12 +12,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read signed bin, big endian, first byte is 0==positive or 1==negative */ -int -mp_read_signed_bin (mp_int * a, unsigned char *b, int c) +int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c) { int res; @@ -36,3 +35,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_read_unsigned_bin.c --- a/libtommath/bn_mp_read_unsigned_bin.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_read_unsigned_bin.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,12 +12,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reads a unsigned char array, assumes the msb is stored first [big endian] */ -int -mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c) +int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c) { int res; @@ -50,3 +49,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce.c --- a/libtommath/bn_mp_reduce.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces x mod m, assumes 0 < x < m**2, mu is @@ -94,3 +94,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_2k.c --- a/libtommath/bn_mp_reduce_2k.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_2k.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces a modulo n where n is of the form 2**p - d */ @@ -55,3 +55,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_2k_l.c --- a/libtommath/bn_mp_reduce_2k_l.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_2k_l.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces a modulo n where n is of the form 2**p - d @@ -56,3 +56,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_2k_setup.c --- a/libtommath/bn_mp_reduce_2k_setup.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_2k_setup.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -41,3 +41,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_2k_setup_l.c --- a/libtommath/bn_mp_reduce_2k_setup_l.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_2k_setup_l.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -38,3 +38,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_is_2k.c --- a/libtommath/bn_mp_reduce_is_2k.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_is_2k.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if mp_reduce_2k can be used */ @@ -46,3 +46,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_is_2k_l.c --- a/libtommath/bn_mp_reduce_is_2k_l.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_is_2k_l.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if reduce_2k_l can be used */ @@ -38,3 +38,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_reduce_setup.c --- a/libtommath/bn_mp_reduce_setup.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_reduce_setup.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* pre-calculate the value required for Barrett reduction @@ -28,3 +28,7 @@ return mp_div (a, b, a, NULL); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_rshd.c --- a/libtommath/bn_mp_rshd.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_rshd.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift right a certain amount of digits */ @@ -66,3 +66,7 @@ a->used -= b; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_set.c --- a/libtommath/bn_mp_set.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_set.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set to a digit */ @@ -23,3 +23,7 @@ a->used = (a->dp[0] != 0) ? 1 : 0; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_set.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_set_int.c --- a/libtommath/bn_mp_set_int.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_set_int.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set a 32-bit const */ @@ -42,3 +42,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_set_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_shrink.c --- a/libtommath/bn_mp_shrink.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_shrink.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shrink a bignum */ @@ -29,3 +29,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_shrink.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_signed_bin_size.c --- a/libtommath/bn_mp_signed_bin_size.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_signed_bin_size.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the size for an signed equivalent */ @@ -21,3 +21,7 @@ return 1 + mp_unsigned_bin_size (a); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_signed_bin_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_sqr.c --- a/libtommath/bn_mp_sqr.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_sqr.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes b = a*a */ @@ -52,3 +52,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_sqrmod.c --- a/libtommath/bn_mp_sqrmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_sqrmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = a * a (mod b) */ @@ -35,3 +35,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_sqrt.c --- a/libtommath/bn_mp_sqrt.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_sqrt.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* this function is less generic than mp_n_root, simpler and faster */ @@ -75,3 +75,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrt.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_sub.c --- a/libtommath/bn_mp_sub.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_sub.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level subtraction (handles signs) */ @@ -53,3 +53,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sub.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_sub_d.c --- a/libtommath/bn_mp_sub_d.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_sub_d.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* single digit subtraction */ @@ -36,6 +36,10 @@ a->sign = MP_ZPOS; res = mp_add_d(a, b, c); a->sign = c->sign = MP_NEG; + + /* clamp */ + mp_clamp(c); + return res; } @@ -83,3 +87,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_sub_d.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_submod.c --- a/libtommath/bn_mp_submod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_submod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a - b (mod c) */ @@ -36,3 +36,7 @@ return res; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_submod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_to_signed_bin.c --- a/libtommath/bn_mp_to_signed_bin.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_to_signed_bin.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in signed [big endian] format */ @@ -27,3 +27,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_to_signed_bin_n.c --- a/libtommath/bn_mp_to_signed_bin_n.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_to_signed_bin_n.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in signed [big endian] format */ @@ -25,3 +25,7 @@ return mp_to_signed_bin(a, b); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin_n.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_to_unsigned_bin.c --- a/libtommath/bn_mp_to_unsigned_bin.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_to_unsigned_bin.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in unsigned [big endian] format */ @@ -42,3 +42,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_to_unsigned_bin_n.c --- a/libtommath/bn_mp_to_unsigned_bin_n.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_to_unsigned_bin_n.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in unsigned [big endian] format */ @@ -25,3 +25,7 @@ return mp_to_unsigned_bin(a, b); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin_n.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_toom_mul.c --- a/libtommath/bn_mp_toom_mul.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_toom_mul.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplication using the Toom-Cook 3-way algorithm @@ -278,3 +278,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_mul.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_toom_sqr.c --- a/libtommath/bn_mp_toom_sqr.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_toom_sqr.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* squaring using Toom-Cook 3-way algorithm */ @@ -220,3 +220,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_toradix.c --- a/libtommath/bn_mp_toradix.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_toradix.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* stores a bignum as a ASCII string in a given radix (2..64) */ @@ -69,3 +69,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_toradix_n.c --- a/libtommath/bn_mp_toradix_n.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_toradix_n.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* stores a bignum as a ASCII string in a given radix (2..64) @@ -27,12 +27,12 @@ char *_s = str; /* check range of the maxlen, radix */ - if (maxlen < 3 || radix < 2 || radix > 64) { + if (maxlen < 2 || radix < 2 || radix > 64) { return MP_VAL; } /* quick out if its zero */ - if (mp_iszero(a) == 1) { + if (mp_iszero(a) == MP_YES) { *str++ = '0'; *str = '\0'; return MP_OKAY; @@ -57,21 +57,20 @@ digs = 0; while (mp_iszero (&t) == 0) { + if (--maxlen < 1) { + /* no more room */ + break; + } if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { mp_clear (&t); return res; } *str++ = mp_s_rmap[d]; ++digs; - - if (--maxlen == 1) { - /* no more room */ - break; - } } /* reverse the digits of the string. In this case _s points - * to the first digit [exluding the sign] of the number] + * to the first digit [exluding the sign] of the number */ bn_reverse ((unsigned char *)_s, digs); @@ -83,3 +82,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix_n.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_unsigned_bin_size.c --- a/libtommath/bn_mp_unsigned_bin_size.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_unsigned_bin_size.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the size for an unsigned equivalent */ @@ -22,3 +22,7 @@ return (size / 8 + ((size & 7) != 0 ? 1 : 0)); } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_unsigned_bin_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_xor.c --- a/libtommath/bn_mp_xor.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_xor.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* XOR two ints together */ @@ -45,3 +45,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_xor.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_mp_zero.c --- a/libtommath/bn_mp_zero.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_mp_zero.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set to zero */ @@ -30,3 +30,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_mp_zero.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_prime_tab.c --- a/libtommath/bn_prime_tab.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_prime_tab.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ const mp_digit ltm_prime_tab[] = { 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, @@ -55,3 +55,7 @@ #endif }; #endif + +/* $Source: /cvs/libtom/libtommath/bn_prime_tab.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_reverse.c --- a/libtommath/bn_reverse.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_reverse.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reverse an array, used for radix code */ @@ -33,3 +33,7 @@ } } #endif + +/* $Source: /cvs/libtom/libtommath/bn_reverse.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_add.c --- a/libtommath/bn_s_mp_add.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_add.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level addition, based on HAC pp.594, Algorithm 14.7 */ @@ -103,3 +103,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_add.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_exptmod.c --- a/libtommath/bn_s_mp_exptmod.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_exptmod.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,9 +12,8 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ - #ifdef MP_LOW_MEM #define TAB_SIZE 32 #else @@ -247,3 +246,7 @@ return err; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_exptmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_mul_digs.c --- a/libtommath/bn_s_mp_mul_digs.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_mul_digs.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplies |a| * |b| and only computes upto digs digits of result @@ -84,3 +84,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_mul_high_digs.c --- a/libtommath/bn_s_mp_mul_high_digs.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_mul_high_digs.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplies |a| * |b| and does not compute the lower digs digits @@ -75,3 +75,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_sqr.c --- a/libtommath/bn_s_mp_sqr.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_sqr.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ @@ -78,3 +78,7 @@ return MP_OKAY; } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bn_s_mp_sub.c --- a/libtommath/bn_s_mp_sub.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bn_s_mp_sub.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ @@ -83,3 +83,7 @@ } #endif + +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sub.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/bncore.c --- a/libtommath/bncore.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/bncore.c Thu Jan 11 03:14:55 2007 +0000 @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Known optimal configurations @@ -20,13 +20,17 @@ CPU /Compiler /MUL CUTOFF/SQR CUTOFF ------------------------------------------------------------- Intel P4 Northwood /GCC v3.4.1 / 88/ 128/LTM 0.32 ;-) - AMD Athlon64 /GCC v3.4.4 / 74/ 124/LTM 0.34 + AMD Athlon64 /GCC v3.4.4 / 80/ 120/LTM 0.35 */ -int KARATSUBA_MUL_CUTOFF = 74, /* Min. number of digits before Karatsuba multiplication is used. */ - KARATSUBA_SQR_CUTOFF = 124, /* Min. number of digits before Karatsuba squaring is used. */ +int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsuba multiplication is used. */ + KARATSUBA_SQR_CUTOFF = 120, /* Min. number of digits before Karatsuba squaring is used. */ TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */ TOOM_SQR_CUTOFF = 400; #endif + +/* $Source: /cvs/libtom/libtommath/bncore.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/booker.pl --- a/libtommath/booker.pl Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/booker.pl Thu Jan 11 03:14:55 2007 +0000 @@ -82,13 +82,16 @@ # scan till next end of comment, e.g. skip license while () { $text[$line++] = $_; - last if ($_ =~ /math\.libtomcrypt\.org/); + last if ($_ =~ /math\.libtomcrypt\.com/); } ; } $inline = 0; while () { + next if ($_ =~ /\$Source/); + next if ($_ =~ /\$Revision/); + next if ($_ =~ /\$Date/); $text[$line++] = $_; ++$inline; chomp($_); @@ -218,7 +221,7 @@ $str = "chapter eight"; } elsif ($a == 9) { $str = "chapter nine"; - } elsif ($a == 2) { + } elsif ($a == 10) { $str = "chapter ten"; } } else { diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/changes.txt --- a/libtommath/changes.txt Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/changes.txt Thu Jan 11 03:14:55 2007 +0000 @@ -1,3 +1,36 @@ +December 24th, 2006 +v0.40 -- Updated makefile to properly support LIBNAME + -- Fixed bug in fast_s_mp_mul_high_digs() which overflowed (line 83), thanks Valgrind! + +April 4th, 2006 +v0.39 -- Jim Wigginton pointed out my Montgomery examples in figures 6.4 and 6.6 were off by one, k should be 9 not 8 + -- Bruce Guenter suggested I use --tag=CC for libtool builds where the compiler may think it's C++. + -- "mm" from sci.crypt pointed out that my mp_gcd was sub-optimal (I also updated and corrected the book) + -- updated some of the @@ tags in tommath.src to reflect source changes. + -- updated email and url info in all source files + +Jan 26th, 2006 +v0.38 -- broken makefile.shared fixed + -- removed some carry stores that were not required [updated text] + +November 18th, 2005 +v0.37 -- [Don Porter] reported on a TCL list [HEY SEND ME BUGREPORTS ALREADY!!!] that mp_add_d() would compute -0 with some inputs. Fixed. + -- [rinick@gmail.com] reported the makefile.bcc was messed up. Fixed. + -- [Kevin Kenny] reported some issues with mp_toradix_n(). Now it doesn't require a min of 3 chars of output. + -- Made the make command renamable. Wee + +August 1st, 2005 +v0.36 -- LTM_PRIME_2MSB_ON was fixed and the "OFF" flag was removed. + -- [Peter LaDow] found a typo in the XREALLOC macro + -- [Peter LaDow] pointed out that mp_read_(un)signed_bin should have "const" on the input + -- Ported LTC patch to fix the prime_random_ex() function to get the bitsize correct [and the maskOR flags] + -- Kevin Kenny pointed out a stray // + -- David Hulton pointed out a typo in the textbook [mp_montgomery_setup() pseudo-code] + -- Neal Hamilton (Elliptic Semiconductor) pointed out that my Karatsuba notation was backwards and that I could use + unsigned operations in the routine. + -- Paul Schmidt pointed out a linking error in mp_exptmod() when BN_S_MP_EXPTMOD_C is undefined (and another for read_radix) + -- Updated makefiles to be way more flexible + March 12th, 2005 v0.35 -- Stupid XOR function missing line again... oops. -- Fixed bug in invmod not handling negative inputs correctly [Wolfgang Ehrhardt] diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/demo/demo.c --- a/libtommath/demo/demo.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/demo/demo.c Thu Jan 11 03:14:55 2007 +0000 @@ -389,8 +389,8 @@ sub_d_n = 0; /* force KARA and TOOM to enable despite cutoffs */ - KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 110; - TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 150; + KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 8; + TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 16; for (;;) { /* randomly clear and re-init one variable, this has the affect of triming the alloc space */ @@ -734,3 +734,7 @@ } return 0; } + +/* $Source: /cvs/libtom/libtommath/demo/demo.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2005/06/24 11:32:07 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/demo/timing.c --- a/libtommath/demo/timing.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/demo/timing.c Thu Jan 11 03:14:55 2007 +0000 @@ -313,3 +313,7 @@ return 0; } + +/* $Source: /cvs/libtom/libtommath/demo/timing.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/2kprime.c --- a/libtommath/etc/2kprime.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/2kprime.c Thu Jan 11 03:14:55 2007 +0000 @@ -78,3 +78,7 @@ + +/* $Source: /cvs/libtom/libtommath/etc/2kprime.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/drprime.c --- a/libtommath/etc/drprime.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/drprime.c Thu Jan 11 03:14:55 2007 +0000 @@ -58,3 +58,7 @@ return 0; } + +/* $Source: /cvs/libtom/libtommath/etc/drprime.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/drprimes.txt --- a/libtommath/etc/drprimes.txt Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/drprimes.txt Thu Jan 11 03:14:55 2007 +0000 @@ -1,6 +1,9 @@ -280-bit prime: -p == 1942668892225729070919461906823518906642406839052139521251812409738904285204940164839 +300-bit prime: +p == 2037035976334486086268445688409378161051468393665936250636140449354381298610415201576637819 -532-bit prime: -p == 14059105607947488696282932836518693308967803494693489478439861164411992439598399594747002144074658928593502845729752797260025831423419686528151609940203368691747 +540-bit prime: +p == 3599131035634557106248430806148785487095757694641533306480604458089470064537190296255232548883112685719936728506816716098566612844395439751206810991770626477344739 +780-bit prime: +p == 6359114106063703798370219984742410466332205126109989319225557147754704702203399726411277962562135973685197744935448875852478791860694279747355800678568677946181447581781401213133886609947027230004277244697462656003655947791725966271167 + diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/makefile.icc --- a/libtommath/etc/makefile.icc Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/makefile.icc Thu Jan 11 03:14:55 2007 +0000 @@ -16,7 +16,7 @@ # B - Blend of P4 and PM [mobile] # # Default to just generic max opts -CFLAGS += -O3 -xN -ip +CFLAGS += -O3 -xP -ip # default lib name (requires install with root) # LIBNAME=-ltommath diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/mersenne.c --- a/libtommath/etc/mersenne.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/mersenne.c Thu Jan 11 03:14:55 2007 +0000 @@ -1,6 +1,6 @@ /* Finds Mersenne primes using the Lucas-Lehmer test * - * Tom St Denis, tomstdenis@iahu.ca + * Tom St Denis, tomstdenis@gmail.com */ #include #include @@ -138,3 +138,7 @@ } return 0; } + +/* $Source: /cvs/libtom/libtommath/etc/mersenne.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/mont.c --- a/libtommath/etc/mont.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/mont.c Thu Jan 11 03:14:55 2007 +0000 @@ -44,3 +44,7 @@ + +/* $Source: /cvs/libtom/libtommath/etc/mont.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/pprime.c --- a/libtommath/etc/pprime.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/pprime.c Thu Jan 11 03:14:55 2007 +0000 @@ -1,8 +1,8 @@ /* Generates provable primes * - * See http://iahu.ca:8080/papers/pp.pdf for more info. + * See http://gmail.com:8080/papers/pp.pdf for more info. * - * Tom St Denis, tomstdenis@iahu.ca, http://tom.iahu.ca + * Tom St Denis, tomstdenis@gmail.com, http://tom.gmail.com */ #include #include "tommath.h" @@ -394,3 +394,7 @@ return 0; } + +/* $Source: /cvs/libtom/libtommath/etc/pprime.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/etc/tune.c --- a/libtommath/etc/tune.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/etc/tune.c Thu Jan 11 03:14:55 2007 +0000 @@ -1,6 +1,6 @@ /* Tune the Karatsuba parameters * - * Tom St Denis, tomstdenis@iahu.ca + * Tom St Denis, tomstdenis@gmail.com */ #include #include @@ -136,3 +136,7 @@ return 0; } + +/* $Source: /cvs/libtom/libtommath/etc/tune.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/expt.log --- a/libtommath/logs/expt.log Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/logs/expt.log Thu Jan 11 03:14:55 2007 +0000 @@ -1,7 +1,7 @@ -513 1489160 -769 3688476 -1025 8162061 -2049 49260015 -2561 89579052 -3073 148797060 -4097 324449263 +513 1435869 +769 3544970 +1025 7791638 +2049 46902238 +2561 85334899 +3073 141451412 +4097 308770310 diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/expt_2k.log --- a/libtommath/logs/expt_2k.log Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/logs/expt_2k.log Thu Jan 11 03:14:55 2007 +0000 @@ -1,5 +1,5 @@ -607 2272809 -1279 9557382 -2203 36250309 -3217 87666486 -4253 174168369 +607 2109225 +1279 10148314 +2203 34126877 +3217 82716424 +4253 161569606 diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/expt_2kl.log --- a/libtommath/logs/expt_2kl.log Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/logs/expt_2kl.log Thu Jan 11 03:14:55 2007 +0000 @@ -1,4 +1,4 @@ -1024 6954080 -2048 35993987 -4096 176068521 -521 1683720 +1024 7705271 +2048 34286851 +4096 165207491 +521 1618631 diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/expt_dr.log --- a/libtommath/logs/expt_dr.log Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/logs/expt_dr.log Thu Jan 11 03:14:55 2007 +0000 @@ -1,7 +1,7 @@ -532 1989592 -784 3898697 -1036 6519700 -1540 15676650 -2072 33128187 -3080 82963362 -4116 168358337 +532 1928550 +784 3763908 +1036 7564221 +1540 16566059 +2072 32283784 +3080 79851565 +4116 157843530 diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/index.html --- a/libtommath/logs/index.html Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/logs/index.html Thu Jan 11 03:14:55 2007 +0000 @@ -21,4 +21,7 @@
- \ No newline at end of file + +/* $Source: /cvs/libtom/libtommath/logs/index.html,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/logs/sqr.old --- a/libtommath/logs/sqr.old Thu Jan 11 03:05:30 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -896 382617 -1344 207161 -1792 131522 -2240 90775 -2688 66652 -3136 50955 -3584 11678 -4032 9342 -4480 7684 -4928 6382 -5376 5399 -5824 4545 -6272 3994 -6720 3490 -7168 3075 -7616 2733 -8064 2428 diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/makefile.bcc --- a/libtommath/makefile.bcc Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/makefile.bcc Thu Jan 11 03:14:55 2007 +0000 @@ -39,6 +39,6 @@ $(TARGET): $(OBJECTS) -.c.objbjbjbj: +.c.obj: $(CC) $(CFLAGS) $< $(LIB) $(TARGET) -+$@ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/makefile.cygwin_dll --- a/libtommath/makefile.cygwin_dll Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/makefile.cygwin_dll Thu Jan 11 03:14:55 2007 +0000 @@ -49,3 +49,7 @@ 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 -r a05fb340a95d -r 5ff8218bcee9 libtommath/makefile.icc --- a/libtommath/makefile.icc Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/makefile.icc Thu Jan 11 03:14:55 2007 +0000 @@ -19,7 +19,7 @@ # B - Blend of P4 and PM [mobile] # # Default to just generic max opts -CFLAGS += -O3 -xN +CFLAGS += -O3 -xP -ip #install as this user USER=root diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/makefile.msvc --- a/libtommath/makefile.msvc Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/makefile.msvc Thu Jan 11 03:14:55 2007 +0000 @@ -2,7 +2,7 @@ # #Tom St Denis -CFLAGS = /I. /Ox /DWIN32 /W4 +CFLAGS = /I. /Ox /DWIN32 /W3 /Fo$@ default: library @@ -34,5 +34,7 @@ bn_mp_init_set.obj bn_mp_init_set_int.obj bn_mp_invmod_slow.obj bn_mp_prime_rabin_miller_trials.obj \ bn_mp_to_signed_bin_n.obj bn_mp_to_unsigned_bin_n.obj +HEADERS=tommath.h tommath_class.h tommath_superclass.h + library: $(OBJECTS) lib /out:tommath.lib $(OBJECTS) diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/makefile.shared --- a/libtommath/makefile.shared Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/makefile.shared Thu Jan 11 03:14:55 2007 +0000 @@ -1,11 +1,14 @@ #Makefile for GCC # #Tom St Denis -VERSION=0:35 +VERSION=0:40 + +CC = libtool --mode=compile --tag=CC gcc -CC = libtool --mode=compile gcc CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare +ifndef IGNORE_SPEED + #for speed CFLAGS += -O3 -funroll-loops @@ -15,14 +18,30 @@ #x86 optimizations [should be valid for any GCC install though] CFLAGS += -fomit-frame-pointer +endif + #install as this user -USER=root -GROUP=root +ifndef INSTALL_GROUP + GROUP=wheel +else + GROUP=$(INSTALL_GROUP) +endif + +ifndef INSTALL_USER + USER=root +else + USER=$(INSTALL_USER) +endif default: libtommath.la #default files to install -LIBNAME=libtommath.la +ifndef LIBNAME + LIBNAME=libtommath.la +endif +ifndef LIBNAME_S + LIBNAME_S=libtommath.a +endif HEADERS=tommath.h tommath_class.h tommath_superclass.h #LIBPATH-The directory for libtommath to be installed to. @@ -61,20 +80,23 @@ bn_mp_init_set_int.o bn_mp_invmod_slow.o bn_mp_prime_rabin_miller_trials.o \ bn_mp_to_signed_bin_n.o bn_mp_to_unsigned_bin_n.o +objs: $(OBJECTS) -libtommath.la: $(OBJECTS) - libtool --mode=link gcc *.lo -o libtommath.la -rpath $(LIBPATH) -version-info $(VERSION) - libtool --mode=link gcc *.o -o libtommath.a - libtool --mode=install install -c libtommath.la $(LIBPATH)/libtommath.la +$(LIBNAME): $(OBJECTS) + libtool --mode=link gcc *.lo -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) + +install: $(LIBNAME) + install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) + libtool --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME) install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) -test: libtommath.a demo/demo.o +test: $(LIBNAME) demo/demo.o gcc $(CFLAGS) -c demo/demo.c -o demo/demo.o - libtool --mode=link gcc -o test demo/demo.o libtommath.la + libtool --mode=link gcc -o test demo/demo.o $(LIBNAME_S) mtest: test - cd mtest ; gcc $(CFLAGS) mtest.c -o mtest -s + cd mtest ; gcc $(CFLAGS) mtest.c -o mtest -timing: libtommath.la - gcc $(CFLAGS) -DTIMER demo/timing.c libtommath.a -o ltmtest -s +timing: $(LIBNAME) + gcc $(CFLAGS) -DTIMER demo/timing.c $(LIBNAME_S) -o ltmtest diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mess.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtommath/mess.sh Thu Jan 11 03:14:55 2007 +0000 @@ -0,0 +1,4 @@ +#!/bin/bash +if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here" ; exit 1; fi + + diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/logtab.h --- a/libtommath/mtest/logtab.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/logtab.h Thu Jan 11 03:14:55 2007 +0000 @@ -18,3 +18,7 @@ 0.166666667 }; + +/* $Source: /cvs/libtom/libtommath/mtest/logtab.h,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/mpi-config.h --- a/libtommath/mtest/mpi-config.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/mpi-config.h Thu Jan 11 03:14:55 2007 +0000 @@ -1,5 +1,5 @@ /* Default configuration for MPI library */ -/* $Id: mpi-config.h,v 1.8 2000/07/11 04:28:14 sting Exp sting $ */ +/* $Id: mpi-config.h,v 1.2 2005/05/05 14:38:47 tom Exp $ */ #ifndef MPI_CONFIG_H_ #define MPI_CONFIG_H_ @@ -84,3 +84,7 @@ /* crc==3287762869, version==2, Sat Feb 02 06:43:53 2002 */ + +/* $Source: /cvs/libtom/libtommath/mtest/mpi-config.h,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/mpi-types.h --- a/libtommath/mtest/mpi-types.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/mpi-types.h Thu Jan 11 03:14:55 2007 +0000 @@ -14,3 +14,7 @@ #define DIGIT_FMT "%04X" #define RADIX (MP_DIGIT_MAX+1) + +/* $Source: /cvs/libtom/libtommath/mtest/mpi-types.h,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/mpi.c --- a/libtommath/mtest/mpi.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/mpi.c Thu Jan 11 03:14:55 2007 +0000 @@ -6,7 +6,7 @@ Arbitrary precision integer arithmetic library - $Id: mpi.c,v 1.22 2001/09/14 15:11:20 sting Exp sting $ + $Id: mpi.c,v 1.2 2005/05/05 14:38:47 tom Exp $ */ #include "mpi.h" @@ -3979,3 +3979,7 @@ /*------------------------------------------------------------------------*/ /* HERE THERE BE DRAGONS */ /* crc==4242132123, version==2, Sat Feb 02 06:43:52 2002 */ + +/* $Source: /cvs/libtom/libtommath/mtest/mpi.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/mpi.h --- a/libtommath/mtest/mpi.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/mpi.h Thu Jan 11 03:14:55 2007 +0000 @@ -6,7 +6,7 @@ Arbitrary precision integer arithmetic library - $Id: mpi.h,v 1.15 2001/09/17 14:16:22 sting Exp $ + $Id: mpi.h,v 1.2 2005/05/05 14:38:47 tom Exp $ */ #ifndef _H_MPI_ @@ -225,3 +225,7 @@ const char *mp_strerror(mp_err ec); #endif /* end _H_MPI_ */ + +/* $Source: /cvs/libtom/libtommath/mtest/mpi.h,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/mtest/mtest.c --- a/libtommath/mtest/mtest.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/mtest/mtest.c Thu Jan 11 03:14:55 2007 +0000 @@ -302,3 +302,7 @@ fclose(rng); return 0; } + +/* $Source: /cvs/libtom/libtommath/mtest/mtest.c,v $ */ +/* $Revision: 1.2 $ */ +/* $Date: 2005/05/05 14:38:47 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/pre_gen/mpi.c --- a/libtommath/pre_gen/mpi.c Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/pre_gen/mpi.c Thu Jan 11 03:14:55 2007 +0000 @@ -13,7 +13,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static const struct { @@ -43,6 +43,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_error.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_error.c */ /* Start: bn_fast_mp_invmod.c */ @@ -60,7 +64,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes the modular inverse via binary extended euclidean algorithm, @@ -191,6 +195,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_fast_mp_invmod.c */ /* Start: bn_fast_mp_montgomery_reduce.c */ @@ -208,7 +216,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes xR**-1 == x (mod N) via Montgomery Reduction @@ -363,6 +371,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_fast_mp_montgomery_reduce.c */ /* Start: bn_fast_s_mp_mul_digs.c */ @@ -380,7 +392,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Fast (comba) multiplier @@ -438,6 +450,7 @@ /* execute loop */ for (iz = 0; iz < iy; ++iz) { _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); + } /* store term */ @@ -445,10 +458,7 @@ /* make next carry */ _W = _W >> ((mp_word)DIGIT_BIT); - } - - /* store final carry */ - W[ix] = (mp_digit)(_W & MP_MASK); + } /* setup dest */ olduse = c->used; @@ -472,6 +482,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.7 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_fast_s_mp_mul_digs.c */ /* Start: bn_fast_s_mp_mul_high_digs.c */ @@ -489,7 +503,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* this is a modified version of fast_s_mul_digs that only produces @@ -547,9 +561,6 @@ _W = _W >> ((mp_word)DIGIT_BIT); } - /* store final carry */ - W[ix] = (mp_digit)(_W & MP_MASK); - /* setup dest */ olduse = c->used; c->used = pa; @@ -558,7 +569,7 @@ register mp_digit *tmpc; tmpc = c->dp + digs; - for (ix = digs; ix <= pa; ix++) { + for (ix = digs; ix < pa; ix++) { /* now extract the previous digit [below the carry] */ *tmpc++ = W[ix]; } @@ -573,6 +584,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/11/14 03:46:25 $ */ + /* End: bn_fast_s_mp_mul_high_digs.c */ /* Start: bn_fast_s_mp_sqr.c */ @@ -590,7 +605,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* the jist of squaring... @@ -687,6 +702,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_fast_s_mp_sqr.c */ /* Start: bn_mp_2expt.c */ @@ -704,7 +723,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes a = 2**b @@ -735,6 +754,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_2expt.c */ /* Start: bn_mp_abs.c */ @@ -752,7 +775,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = |a| @@ -778,6 +801,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_abs.c */ /* Start: bn_mp_add.c */ @@ -795,7 +822,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level addition (handles signs) */ @@ -831,6 +858,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_add.c */ /* Start: bn_mp_add_d.c */ @@ -848,7 +879,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* single digit addition */ @@ -876,6 +907,9 @@ /* fix sign */ a->sign = c->sign = MP_NEG; + /* clamp */ + mp_clamp(c); + return res; } @@ -940,6 +974,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_add_d.c */ /* Start: bn_mp_addmod.c */ @@ -957,7 +995,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a + b (mod c) */ @@ -981,6 +1019,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_addmod.c */ /* Start: bn_mp_and.c */ @@ -998,7 +1040,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* AND two ints together */ @@ -1038,6 +1080,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_and.c */ /* Start: bn_mp_clamp.c */ @@ -1055,7 +1101,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* trim unused digits @@ -1082,6 +1128,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_clamp.c */ /* Start: bn_mp_clear.c */ @@ -1099,7 +1149,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* clear one (frees) */ @@ -1126,6 +1176,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_clear.c */ /* Start: bn_mp_clear_multi.c */ @@ -1143,7 +1197,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #include @@ -1160,6 +1214,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_clear_multi.c */ /* Start: bn_mp_cmp.c */ @@ -1177,7 +1235,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare two ints (signed)*/ @@ -1203,6 +1261,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_cmp.c */ /* Start: bn_mp_cmp_d.c */ @@ -1220,7 +1282,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare a digit */ @@ -1247,6 +1309,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_cmp_d.c */ /* Start: bn_mp_cmp_mag.c */ @@ -1264,7 +1330,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* compare maginitude of two ints (unsigned) */ @@ -1302,6 +1368,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_cmp_mag.c */ /* Start: bn_mp_cnt_lsb.c */ @@ -1319,7 +1389,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static const int lnz[16] = { @@ -1355,6 +1425,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_cnt_lsb.c */ /* Start: bn_mp_copy.c */ @@ -1372,7 +1446,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* copy, b = a */ @@ -1423,6 +1497,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_copy.c */ /* Start: bn_mp_count_bits.c */ @@ -1440,7 +1518,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* returns the number of bits in an int */ @@ -1468,6 +1546,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_count_bits.c */ /* Start: bn_mp_div.c */ @@ -1485,7 +1567,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #ifdef BN_MP_DIV_SMALL @@ -1760,6 +1842,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_div.c */ /* Start: bn_mp_div_2.c */ @@ -1777,7 +1863,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = a/2 */ @@ -1828,6 +1914,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_div_2.c */ /* Start: bn_mp_div_2d.c */ @@ -1845,7 +1935,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ @@ -1925,6 +2015,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_div_2d.c */ /* Start: bn_mp_div_3.c */ @@ -1942,7 +2036,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* divide by three (based on routine from MPI and the GMP manual) */ @@ -2004,6 +2098,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_div_3.c */ /* Start: bn_mp_div_d.c */ @@ -2021,7 +2119,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ static int s_is_power_of_two(mp_digit b, int *p) @@ -2114,6 +2212,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_div_d.c */ /* Start: bn_mp_dr_is_modulus.c */ @@ -2131,7 +2233,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if a number is a valid DR modulus */ @@ -2157,6 +2259,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_dr_is_modulus.c */ /* Start: bn_mp_dr_reduce.c */ @@ -2174,7 +2280,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduce "x" in place modulo "n" using the Diminished Radix algorithm. @@ -2251,6 +2357,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_dr_reduce.c */ /* Start: bn_mp_dr_setup.c */ @@ -2268,7 +2378,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -2283,6 +2393,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_dr_setup.c */ /* Start: bn_mp_exch.c */ @@ -2300,7 +2414,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* swap the elements of two integers, for cases where you can't simply swap the @@ -2317,6 +2431,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_exch.c */ /* Start: bn_mp_expt_d.c */ @@ -2334,7 +2452,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* calculate c = a**b using a square-multiply algorithm */ @@ -2374,6 +2492,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_expt_d.c */ /* Start: bn_mp_exptmod.c */ @@ -2391,7 +2513,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ @@ -2445,7 +2567,7 @@ } /* modified diminished radix reduction */ -#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) +#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C) if (mp_reduce_is_2k_l(P) == MP_YES) { return s_mp_exptmod(G, X, P, Y, 1); } @@ -2486,6 +2608,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_exptmod.c */ /* Start: bn_mp_exptmod_fast.c */ @@ -2503,7 +2629,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85 @@ -2807,6 +2933,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_exptmod_fast.c */ /* Start: bn_mp_exteuclid.c */ @@ -2824,7 +2954,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Extended euclidean algorithm of (a, b) produces @@ -2889,6 +3019,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_exteuclid.c */ /* Start: bn_mp_fread.c */ @@ -2906,7 +3040,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read a bigint from a file stream in ASCII */ @@ -2956,6 +3090,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_fread.c */ /* Start: bn_mp_fwrite.c */ @@ -2973,7 +3111,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ int mp_fwrite(mp_int *a, int radix, FILE *stream) @@ -3008,6 +3146,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_fwrite.c */ /* Start: bn_mp_gcd.c */ @@ -3025,7 +3167,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Greatest Common Divisor using the binary method */ @@ -3035,21 +3177,13 @@ int k, u_lsb, v_lsb, res; /* either zero than gcd is the largest */ - if (mp_iszero (a) == 1 && mp_iszero (b) == 0) { + if (mp_iszero (a) == MP_YES) { return mp_abs (b, c); } - if (mp_iszero (a) == 0 && mp_iszero (b) == 1) { + if (mp_iszero (b) == MP_YES) { return mp_abs (a, c); } - /* optimized. At this point if a == 0 then - * b must equal zero too - */ - if (mp_iszero (a) == 1) { - mp_zero(c); - return MP_OKAY; - } - /* get copies of a and b we can modify */ if ((res = mp_init_copy (&u, a)) != MP_OKAY) { return res; @@ -3121,6 +3255,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_gcd.c */ /* Start: bn_mp_get_int.c */ @@ -3138,7 +3276,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the lower 32-bits of an mp_int */ @@ -3166,6 +3304,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_get_int.c */ /* Start: bn_mp_grow.c */ @@ -3183,7 +3325,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* grow as required */ @@ -3223,6 +3365,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_grow.c */ /* Start: bn_mp_init.c */ @@ -3240,7 +3386,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* init a new mp_int */ @@ -3269,6 +3415,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init.c */ /* Start: bn_mp_init_copy.c */ @@ -3286,7 +3436,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* creates "a" then copies b into it */ @@ -3301,6 +3451,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init_copy.c */ /* Start: bn_mp_init_multi.c */ @@ -3318,7 +3472,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #include @@ -3360,6 +3514,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init_multi.c */ /* Start: bn_mp_init_set.c */ @@ -3377,7 +3535,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* initialize and set a digit */ @@ -3392,6 +3550,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init_set.c */ /* Start: bn_mp_init_set_int.c */ @@ -3409,7 +3571,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* initialize and set a digit */ @@ -3423,6 +3585,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init_set_int.c */ /* Start: bn_mp_init_size.c */ @@ -3440,7 +3606,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* init an mp_init for a given size */ @@ -3471,6 +3637,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_init_size.c */ /* Start: bn_mp_invmod.c */ @@ -3488,7 +3658,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* hac 14.61, pp608 */ @@ -3514,6 +3684,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_invmod.c */ /* Start: bn_mp_invmod_slow.c */ @@ -3531,7 +3705,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* hac 14.61, pp608 */ @@ -3689,6 +3863,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_invmod_slow.c */ /* Start: bn_mp_is_square.c */ @@ -3706,7 +3884,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Check if remainders are possible squares - fast exclude non-squares */ @@ -3798,6 +3976,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_is_square.c */ /* Start: bn_mp_jacobi.c */ @@ -3815,7 +3997,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes the jacobi c = (a | n) (or Legendre if n is prime) @@ -3903,6 +4085,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_jacobi.c */ /* Start: bn_mp_karatsuba_mul.c */ @@ -3920,7 +4106,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = |a| * |b| using Karatsuba Multiplication using @@ -3934,12 +4120,12 @@ * b = b1 * B**n + b0 * * Then, a * b => - a1b1 * B**2n + ((a1 - a0)(b1 - b0) + a0b0 + a1b1) * B + a0b0 + a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0 * * Note that a1b1 and a0b0 are used twice and only need to be * computed once. So in total three half size (half # of * digit) multiplications are performed, a0b0, a1b1 and - * (a1-b1)(a0-b0) + * (a1+b1)(a0+b0) * * Note that a multiplication of half the digits requires * 1/4th the number of single precision multiplications so in @@ -4030,19 +4216,19 @@ if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY) goto X1Y1; /* x1y1 = x1*y1 */ - /* now calc x1-x0 and y1-y0 */ - if (mp_sub (&x1, &x0, &t1) != MP_OKAY) + /* now calc x1+x0 and y1+y0 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) goto X1Y1; /* t1 = x1 - x0 */ - if (mp_sub (&y1, &y0, &x0) != MP_OKAY) + if (s_mp_add (&y1, &y0, &x0) != MP_OKAY) goto X1Y1; /* t2 = y1 - y0 */ if (mp_mul (&t1, &x0, &t1) != MP_OKAY) - goto X1Y1; /* t1 = (x1 - x0) * (y1 - y0) */ + goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */ /* add x0y0 */ if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY) goto X1Y1; /* t2 = x0y0 + x1y1 */ - if (mp_sub (&x0, &t1, &t1) != MP_OKAY) - goto X1Y1; /* t1 = x0y0 + x1y1 - (x1-x0)*(y1-y0) */ + if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY) + goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */ /* shift by B */ if (mp_lshd (&t1, B) != MP_OKAY) @@ -4070,6 +4256,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_mul.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_karatsuba_mul.c */ /* Start: bn_mp_karatsuba_sqr.c */ @@ -4087,7 +4277,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Karatsuba squaring, computes b = a*a using three @@ -4155,8 +4345,8 @@ if (mp_sqr (&x1, &x1x1) != MP_OKAY) goto X1X1; /* x1x1 = x1*x1 */ - /* now calc (x1-x0)**2 */ - if (mp_sub (&x1, &x0, &t1) != MP_OKAY) + /* now calc (x1+x0)**2 */ + if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) goto X1X1; /* t1 = x1 - x0 */ if (mp_sqr (&t1, &t1) != MP_OKAY) goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */ @@ -4164,8 +4354,8 @@ /* add x0y0 */ if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY) goto X1X1; /* t2 = x0x0 + x1x1 */ - if (mp_sub (&t2, &t1, &t1) != MP_OKAY) - goto X1X1; /* t1 = x0x0 + x1x1 - (x1-x0)*(x1-x0) */ + if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY) + goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */ /* shift by B */ if (mp_lshd (&t1, B) != MP_OKAY) @@ -4191,6 +4381,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_sqr.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_karatsuba_sqr.c */ /* Start: bn_mp_lcm.c */ @@ -4208,7 +4402,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes least common multiple as |a*b|/(a, b) */ @@ -4251,6 +4445,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_lcm.c */ /* Start: bn_mp_lshd.c */ @@ -4268,7 +4466,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift left a certain amount of digits */ @@ -4318,6 +4516,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_lshd.c */ /* Start: bn_mp_mod.c */ @@ -4335,7 +4537,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = a mod b, 0 <= c < b */ @@ -4366,6 +4568,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mod.c */ /* Start: bn_mp_mod_2d.c */ @@ -4383,7 +4589,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* calc a value mod 2**b */ @@ -4421,6 +4627,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mod_2d.c */ /* Start: bn_mp_mod_d.c */ @@ -4438,7 +4648,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ int @@ -4448,6 +4658,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mod_d.c */ /* Start: bn_mp_montgomery_calc_normalization.c */ @@ -4465,7 +4679,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* @@ -4507,6 +4721,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_montgomery_calc_normalization.c */ /* Start: bn_mp_montgomery_reduce.c */ @@ -4524,7 +4742,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes xR**-1 == x (mod N) via Montgomery Reduction */ @@ -4625,6 +4843,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_montgomery_reduce.c */ /* Start: bn_mp_montgomery_setup.c */ @@ -4642,7 +4864,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* setups the montgomery reduction stuff */ @@ -4678,12 +4900,16 @@ #endif /* rho = -1/m mod b */ - *rho = (((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; + *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; return MP_OKAY; } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/12/04 21:34:03 $ */ + /* End: bn_mp_montgomery_setup.c */ /* Start: bn_mp_mul.c */ @@ -4701,7 +4927,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level multiplication (handles sign) */ @@ -4750,6 +4976,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mul.c */ /* Start: bn_mp_mul_2.c */ @@ -4767,7 +4997,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = a*2 */ @@ -4832,6 +5062,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mul_2.c */ /* Start: bn_mp_mul_2d.c */ @@ -4849,7 +5083,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift left by a certain bit count */ @@ -4917,6 +5151,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mul_2d.c */ /* Start: bn_mp_mul_d.c */ @@ -4934,7 +5172,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiply by a digit */ @@ -4996,6 +5234,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mul_d.c */ /* Start: bn_mp_mulmod.c */ @@ -5013,12 +5255,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a * b (mod c) */ -int -mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) +int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) { int res; mp_int t; @@ -5037,6 +5278,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_mulmod.c */ /* Start: bn_mp_n_root.c */ @@ -5054,7 +5299,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* find the n'th root of an integer @@ -5169,6 +5414,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_n_root.c */ /* Start: bn_mp_neg.c */ @@ -5186,7 +5435,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* b = -a */ @@ -5209,6 +5458,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_neg.c */ /* Start: bn_mp_or.c */ @@ -5226,7 +5479,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* OR two ints together */ @@ -5259,6 +5512,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_or.c */ /* Start: bn_mp_prime_fermat.c */ @@ -5276,7 +5533,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* performs one Fermat test. @@ -5321,6 +5578,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_fermat.c */ /* Start: bn_mp_prime_is_divisible.c */ @@ -5338,7 +5599,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if an integers is divisible by one @@ -5371,6 +5632,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_is_divisible.c */ /* Start: bn_mp_prime_is_prime.c */ @@ -5388,7 +5653,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* performs a variable number of rounds of Miller-Rabin @@ -5454,6 +5719,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_is_prime.c */ /* Start: bn_mp_prime_miller_rabin.c */ @@ -5471,7 +5740,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Miller-Rabin test of "a" to the base of "b" as described in @@ -5557,6 +5826,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_miller_rabin.c */ /* Start: bn_mp_prime_next_prime.c */ @@ -5574,7 +5847,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* finds the next prime after the number "a" using "t" trials @@ -5727,6 +6000,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_next_prime.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_next_prime.c */ /* Start: bn_mp_prime_rabin_miller_trials.c */ @@ -5744,7 +6021,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ @@ -5779,6 +6056,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_rabin_miller_trials.c */ /* Start: bn_mp_prime_random_ex.c */ @@ -5796,7 +6077,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* makes a truly random prime of a given size (bits), @@ -5846,10 +6127,8 @@ maskOR_msb = 0; maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0; if (flags & LTM_PRIME_2MSB_ON) { - maskOR_msb |= 1 << ((size - 2) & 7); - } else if (flags & LTM_PRIME_2MSB_OFF) { - maskAND &= ~(1 << ((size - 2) & 7)); - } + maskOR_msb |= 0x80 >> ((9 - size) & 7); + } /* get the maskOR_lsb */ maskOR_lsb = 1; @@ -5906,6 +6185,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_prime_random_ex.c */ /* Start: bn_mp_radix_size.c */ @@ -5923,7 +6206,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* returns size of ASCII reprensentation */ @@ -5947,7 +6230,7 @@ } if (mp_iszero(a) == MP_YES) { - *size = 2; + *size = 2; return MP_OKAY; } @@ -5984,6 +6267,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_radix_size.c */ /* Start: bn_mp_radix_smap.c */ @@ -6001,13 +6288,17 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* chars used in radix conversions */ const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_radix_smap.c */ /* Start: bn_mp_rand.c */ @@ -6025,7 +6316,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* makes a pseudo-random int of a given size */ @@ -6063,6 +6354,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_rand.c */ /* Start: bn_mp_read_radix.c */ @@ -6080,7 +6375,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read a string [ASCII] in a given radix */ @@ -6089,6 +6384,9 @@ int y, res, neg; char ch; + /* zero the digit bignum */ + mp_zero(a); + /* make sure the radix is ok */ if (radix < 2 || radix > 64) { return MP_VAL; @@ -6145,6 +6443,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_read_radix.c */ /* Start: bn_mp_read_signed_bin.c */ @@ -6162,12 +6464,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* read signed bin, big endian, first byte is 0==positive or 1==negative */ -int -mp_read_signed_bin (mp_int * a, unsigned char *b, int c) +int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c) { int res; @@ -6187,6 +6488,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_read_signed_bin.c */ /* Start: bn_mp_read_unsigned_bin.c */ @@ -6204,12 +6509,11 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reads a unsigned char array, assumes the msb is stored first [big endian] */ -int -mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c) +int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c) { int res; @@ -6243,6 +6547,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_read_unsigned_bin.c */ /* Start: bn_mp_reduce.c */ @@ -6260,7 +6568,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces x mod m, assumes 0 < x < m**2, mu is @@ -6343,6 +6651,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce.c */ /* Start: bn_mp_reduce_2k.c */ @@ -6360,7 +6672,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces a modulo n where n is of the form 2**p - d */ @@ -6404,6 +6716,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_2k.c */ /* Start: bn_mp_reduce_2k_l.c */ @@ -6421,7 +6737,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reduces a modulo n where n is of the form 2**p - d @@ -6466,6 +6782,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_2k_l.c */ /* Start: bn_mp_reduce_2k_setup.c */ @@ -6483,7 +6803,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -6513,6 +6833,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_2k_setup.c */ /* Start: bn_mp_reduce_2k_setup_l.c */ @@ -6530,7 +6854,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines the setup value */ @@ -6557,6 +6881,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_2k_setup_l.c */ /* Start: bn_mp_reduce_is_2k.c */ @@ -6574,7 +6902,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if mp_reduce_2k can be used */ @@ -6609,6 +6937,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_is_2k.c */ /* Start: bn_mp_reduce_is_2k_l.c */ @@ -6626,7 +6958,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* determines if reduce_2k_l can be used */ @@ -6653,6 +6985,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k_l.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_is_2k_l.c */ /* Start: bn_mp_reduce_setup.c */ @@ -6670,7 +7006,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* pre-calculate the value required for Barrett reduction @@ -6687,6 +7023,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_setup.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_reduce_setup.c */ /* Start: bn_mp_rshd.c */ @@ -6704,7 +7044,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shift right a certain amount of digits */ @@ -6759,6 +7099,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_rshd.c */ /* Start: bn_mp_set.c */ @@ -6776,7 +7120,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set to a digit */ @@ -6788,6 +7132,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_set.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_set.c */ /* Start: bn_mp_set_int.c */ @@ -6805,7 +7153,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set a 32-bit const */ @@ -6836,6 +7184,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_set_int.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_set_int.c */ /* Start: bn_mp_shrink.c */ @@ -6853,7 +7205,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* shrink a bignum */ @@ -6871,6 +7223,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_shrink.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_shrink.c */ /* Start: bn_mp_signed_bin_size.c */ @@ -6888,7 +7244,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the size for an signed equivalent */ @@ -6898,6 +7254,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_signed_bin_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_signed_bin_size.c */ /* Start: bn_mp_sqr.c */ @@ -6915,7 +7275,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* computes b = a*a */ @@ -6956,6 +7316,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_sqr.c */ /* Start: bn_mp_sqrmod.c */ @@ -6973,7 +7337,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* c = a * a (mod b) */ @@ -6997,6 +7361,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrmod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_sqrmod.c */ /* Start: bn_mp_sqrt.c */ @@ -7014,7 +7382,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* this function is less generic than mp_n_root, simpler and faster */ @@ -7078,6 +7446,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_sqrt.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_sqrt.c */ /* Start: bn_mp_sub.c */ @@ -7095,7 +7467,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* high level subtraction (handles signs) */ @@ -7137,6 +7509,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_sub.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_sub.c */ /* Start: bn_mp_sub_d.c */ @@ -7154,7 +7530,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* single digit subtraction */ @@ -7178,6 +7554,10 @@ a->sign = MP_ZPOS; res = mp_add_d(a, b, c); a->sign = c->sign = MP_NEG; + + /* clamp */ + mp_clamp(c); + return res; } @@ -7226,6 +7606,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_sub_d.c,v $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_sub_d.c */ /* Start: bn_mp_submod.c */ @@ -7243,7 +7627,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* d = a - b (mod c) */ @@ -7268,6 +7652,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_submod.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_submod.c */ /* Start: bn_mp_to_signed_bin.c */ @@ -7285,7 +7673,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in signed [big endian] format */ @@ -7301,6 +7689,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_to_signed_bin.c */ /* Start: bn_mp_to_signed_bin_n.c */ @@ -7318,7 +7710,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in signed [big endian] format */ @@ -7332,6 +7724,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin_n.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_to_signed_bin_n.c */ /* Start: bn_mp_to_unsigned_bin.c */ @@ -7349,7 +7745,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in unsigned [big endian] format */ @@ -7380,6 +7776,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_to_unsigned_bin.c */ /* Start: bn_mp_to_unsigned_bin_n.c */ @@ -7397,7 +7797,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* store in unsigned [big endian] format */ @@ -7411,6 +7811,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin_n.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_to_unsigned_bin_n.c */ /* Start: bn_mp_toom_mul.c */ @@ -7428,7 +7832,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplication using the Toom-Cook 3-way algorithm @@ -7695,6 +8099,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_mul.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_toom_mul.c */ /* Start: bn_mp_toom_sqr.c */ @@ -7712,7 +8120,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* squaring using Toom-Cook 3-way algorithm */ @@ -7921,6 +8329,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_toom_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_toom_sqr.c */ /* Start: bn_mp_toradix.c */ @@ -7938,7 +8350,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* stores a bignum as a ASCII string in a given radix (2..64) */ @@ -7996,6 +8408,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_toradix.c */ /* Start: bn_mp_toradix_n.c */ @@ -8013,7 +8429,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* stores a bignum as a ASCII string in a given radix (2..64) @@ -8028,12 +8444,12 @@ char *_s = str; /* check range of the maxlen, radix */ - if (maxlen < 3 || radix < 2 || radix > 64) { + if (maxlen < 2 || radix < 2 || radix > 64) { return MP_VAL; } /* quick out if its zero */ - if (mp_iszero(a) == 1) { + if (mp_iszero(a) == MP_YES) { *str++ = '0'; *str = '\0'; return MP_OKAY; @@ -8058,21 +8474,20 @@ digs = 0; while (mp_iszero (&t) == 0) { + if (--maxlen < 1) { + /* no more room */ + break; + } if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { mp_clear (&t); return res; } *str++ = mp_s_rmap[d]; ++digs; - - if (--maxlen == 1) { - /* no more room */ - break; - } } /* reverse the digits of the string. In this case _s points - * to the first digit [exluding the sign] of the number] + * to the first digit [exluding the sign] of the number */ bn_reverse ((unsigned char *)_s, digs); @@ -8085,6 +8500,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_toradix_n.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_toradix_n.c */ /* Start: bn_mp_unsigned_bin_size.c */ @@ -8102,7 +8521,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* get the size for an unsigned equivalent */ @@ -8113,6 +8532,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_unsigned_bin_size.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_unsigned_bin_size.c */ /* Start: bn_mp_xor.c */ @@ -8130,7 +8553,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* XOR two ints together */ @@ -8164,6 +8587,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_xor.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_xor.c */ /* Start: bn_mp_zero.c */ @@ -8181,7 +8608,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* set to zero */ @@ -8200,6 +8627,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_mp_zero.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_mp_zero.c */ /* Start: bn_prime_tab.c */ @@ -8217,7 +8648,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ const mp_digit ltm_prime_tab[] = { 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, @@ -8261,6 +8692,10 @@ }; #endif +/* $Source: /cvs/libtom/libtommath/bn_prime_tab.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_prime_tab.c */ /* Start: bn_reverse.c */ @@ -8278,7 +8713,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* reverse an array, used for radix code */ @@ -8300,6 +8735,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_reverse.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_reverse.c */ /* Start: bn_s_mp_add.c */ @@ -8317,7 +8756,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level addition, based on HAC pp.594, Algorithm 14.7 */ @@ -8409,6 +8848,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_add.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_add.c */ /* Start: bn_s_mp_exptmod.c */ @@ -8426,9 +8869,8 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org - */ - + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com + */ #ifdef MP_LOW_MEM #define TAB_SIZE 32 #else @@ -8662,6 +9104,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_exptmod.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_exptmod.c */ /* Start: bn_s_mp_mul_digs.c */ @@ -8679,7 +9125,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplies |a| * |b| and only computes upto digs digits of result @@ -8752,6 +9198,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_digs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_mul_digs.c */ /* Start: bn_s_mp_mul_high_digs.c */ @@ -8769,7 +9219,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* multiplies |a| * |b| and does not compute the lower digs digits @@ -8833,6 +9283,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_high_digs.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_mul_high_digs.c */ /* Start: bn_s_mp_sqr.c */ @@ -8850,7 +9304,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ @@ -8917,6 +9371,10 @@ } #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sqr.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_sqr.c */ /* Start: bn_s_mp_sub.c */ @@ -8934,7 +9392,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ @@ -9006,6 +9464,10 @@ #endif +/* $Source: /cvs/libtom/libtommath/bn_s_mp_sub.c,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bn_s_mp_sub.c */ /* Start: bncore.c */ @@ -9023,7 +9485,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* Known optimal configurations @@ -9031,17 +9493,21 @@ CPU /Compiler /MUL CUTOFF/SQR CUTOFF ------------------------------------------------------------- Intel P4 Northwood /GCC v3.4.1 / 88/ 128/LTM 0.32 ;-) - AMD Athlon64 /GCC v3.4.4 / 74/ 124/LTM 0.34 + AMD Athlon64 /GCC v3.4.4 / 80/ 120/LTM 0.35 */ -int KARATSUBA_MUL_CUTOFF = 74, /* Min. number of digits before Karatsuba multiplication is used. */ - KARATSUBA_SQR_CUTOFF = 124, /* Min. number of digits before Karatsuba squaring is used. */ +int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsuba multiplication is used. */ + KARATSUBA_SQR_CUTOFF = 120, /* Min. number of digits before Karatsuba squaring is used. */ TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */ TOOM_SQR_CUTOFF = 400; #endif +/* $Source: /cvs/libtom/libtommath/bncore.c,v $ */ +/* $Revision: 1.4 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ + /* End: bncore.c */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/tommath.h --- a/libtommath/tommath.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/tommath.h Thu Jan 11 03:14:55 2007 +0000 @@ -10,7 +10,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ #ifndef BN_H_ #define BN_H_ @@ -21,12 +21,15 @@ #include #include -#include +#include "tommath_class.h" -#undef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) -#undef MAX -#define MAX(x,y) ((x)>(y)?(x):(y)) +#ifndef MIN + #define MIN(x,y) ((x)<(y)?(x):(y)) +#endif + +#ifndef MAX + #define MAX(x,y) ((x)>(y)?(x):(y)) +#endif #ifdef __cplusplus extern "C" { @@ -112,7 +115,7 @@ #else /* prototypes for our heap functions */ extern void *XMALLOC(size_t n); - extern void *REALLOC(void *p, size_t n); + extern void *XREALLOC(void *p, size_t n); extern void *XCALLOC(size_t n, size_t s); extern void XFREE(void *p); #endif @@ -147,7 +150,6 @@ /* Primality generation flags */ #define LTM_PRIME_BBS 0x0001 /* BBS style prime */ #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ -#define LTM_PRIME_2MSB_OFF 0x0004 /* force 2nd MSB to 0 */ #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ typedef int mp_err; @@ -164,7 +166,7 @@ /* default precision */ #ifndef MP_PREC #ifndef MP_LOW_MEM - #define MP_PREC 64 /* default digits of precision */ + #define MP_PREC 32 /* default digits of precision */ #else #define MP_PREC 8 /* default digits of precision */ #endif @@ -518,13 +520,13 @@ int mp_count_bits(mp_int *a); int mp_unsigned_bin_size(mp_int *a); -int mp_read_unsigned_bin(mp_int *a, unsigned char *b, int c); +int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); int mp_to_unsigned_bin(mp_int *a, unsigned char *b); int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); int mp_signed_bin_size(mp_int *a); -int mp_read_signed_bin(mp_int *a, unsigned char *b, int c); -int mp_to_signed_bin(mp_int *a, unsigned char *b); +int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c); +int mp_to_signed_bin(mp_int *a, unsigned char *b); int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); int mp_read_radix(mp_int *a, const char *str, int radix); @@ -576,3 +578,7 @@ #endif + +/* $Source: /cvs/libtom/libtommath/tommath.h,v $ */ +/* $Revision: 1.8 $ */ +/* $Date: 2006/03/31 14:18:44 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/tommath_class.h --- a/libtommath/tommath_class.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/tommath_class.h Thu Jan 11 03:14:55 2007 +0000 @@ -687,6 +687,7 @@ #if defined(BN_MP_READ_RADIX_C) #define BN_MP_ZERO_C #define BN_MP_S_RMAP_C + #define BN_MP_RADIX_SMAP_C #define BN_MP_MUL_D_C #define BN_MP_ADD_D_C #define BN_MP_ISZERO_C @@ -987,8 +988,8 @@ #ifdef LTM3 #define LTM_LAST #endif -#include -#include +#include "tommath_superclass.h" +#include "tommath_class.h" #else #define LTM_LAST #endif @@ -998,3 +999,7 @@ #undef BN_MP_KARATSUBA_SQR_C #undef BN_MP_TOOM_MUL_C #undef BN_MP_TOOM_SQR_C + +/* $Source: /cvs/libtom/libtommath/tommath_class.h,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2005/07/28 11:59:32 $ */ diff -r a05fb340a95d -r 5ff8218bcee9 libtommath/tommath_superclass.h --- a/libtommath/tommath_superclass.h Thu Jan 11 03:05:30 2007 +0000 +++ b/libtommath/tommath_superclass.h Thu Jan 11 03:14:55 2007 +0000 @@ -4,7 +4,7 @@ #define LTM_ALL /* RSA only (does not support DH/DSA/ECC) */ -// #define SC_RSA_1 +/* #define SC_RSA_1 */ /* For reference.... On an Athlon64 optimizing for speed... @@ -70,3 +70,7 @@ #endif #endif + +/* $Source: /cvs/libtom/libtommath/tommath_superclass.h,v $ */ +/* $Revision: 1.3 $ */ +/* $Date: 2005/05/14 13:29:17 $ */