Skip to content

Commit

Permalink
added libtommath-0.37
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom St Denis authored and sjaeckel committed Jul 15, 2010
1 parent 9294e79 commit fde740e
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 146 deletions.
Binary file modified bn.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion bn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
\begin{document}
\frontmatter
\pagestyle{empty}
\title{LibTomMath User Manual \\ v0.36}
\title{LibTomMath User Manual \\ v0.37}
\author{Tom St Denis \\ tomstdenis@iahu.ca}
\maketitle
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
Expand Down
3 changes: 3 additions & 0 deletions bn_mp_add_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
/* fix sign */
a->sign = c->sign = MP_NEG;

/* clamp */
mp_clamp(c);

return res;
}

Expand Down
2 changes: 1 addition & 1 deletion bn_mp_radix_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
}

if (mp_iszero(a) == MP_YES) {
*size = 2;
*size = 2;
return MP_OKAY;
}

Expand Down
3 changes: 3 additions & 0 deletions bn_mp_read_radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
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;
Expand Down
4 changes: 4 additions & 0 deletions bn_mp_sub_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
a->sign = MP_ZPOS;
res = mp_add_d(a, b, c);
a->sign = c->sign = MP_NEG;

/* clamp */
mp_clamp(c);

return res;
}

Expand Down
15 changes: 7 additions & 8 deletions bn_mp_toradix_n.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
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;
Expand All @@ -57,21 +57,20 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)

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);

Expand Down
2 changes: 1 addition & 1 deletion booker.pl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
$str = "chapter eight";
} elsif ($a == 9) {
$str = "chapter nine";
} elsif ($a == 2) {
} elsif ($a == 10) {
$str = "chapter ten";
}
} else {
Expand Down
6 changes: 6 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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
Expand Down
19 changes: 12 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#Tom St Denis

#version of library
VERSION=0.36
VERSION=0.37

CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare

ifndef MAKE
MAKE=make
endif

ifndef IGNORE_SPEED

#for speed
Expand Down Expand Up @@ -124,7 +128,7 @@ timing: $(LIBNAME)

# 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
Expand All @@ -141,7 +145,7 @@ poster: poster.tex
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
Expand All @@ -161,10 +165,10 @@ pretty:

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 `find -type f | grep [~] | xargs` *.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
Expand All @@ -177,4 +181,5 @@ zipup: clean manual poster docs
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)
2 changes: 1 addition & 1 deletion makefile.bcc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ TARGET = libtommath.lib

$(TARGET): $(OBJECTS)

.c.objbjbjbj:
.c.obj:
$(CC) $(CFLAGS) $<
$(LIB) $(TARGET) -+$@
10 changes: 6 additions & 4 deletions makefile.shared
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Makefile for GCC
#
#Tom St Denis
VERSION=0:36
VERSION=0:37

CC = libtool --mode=compile gcc

Expand Down Expand Up @@ -80,11 +80,13 @@ bn_mp_prime_random_ex.o bn_mp_get_int.o bn_mp_sqrt.o bn_mp_is_square.o bn_mp_ini
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)

$(LIBNAME): $(OBJECTS)
libtool --mode=link gcc *.lo -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION)
libtool --mode=link gcc *.o -o $(LIBNAME_S)
ranlib $(LIBNAME_S)
libtool --mode=install install -c $(LIBNAME) $(LIBPATH)/$@

install: $(LIBNAME)
libtool --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME)
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)

Expand Down
Binary file modified poster.pdf
Binary file not shown.
27 changes: 18 additions & 9 deletions pre_gen/mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
/* fix sign */
a->sign = c->sign = MP_NEG;

/* clamp */
mp_clamp(c);

return res;
}

Expand Down Expand Up @@ -6241,7 +6244,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
}

if (mp_iszero(a) == MP_YES) {
*size = 2;
*size = 2;
return MP_OKAY;
}

Expand Down Expand Up @@ -6395,6 +6398,9 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
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;
Expand Down Expand Up @@ -7562,6 +7568,10 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
a->sign = MP_ZPOS;
res = mp_add_d(a, b, c);
a->sign = c->sign = MP_NEG;

/* clamp */
mp_clamp(c);

return res;
}

Expand Down Expand Up @@ -8448,12 +8458,12 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
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;
Expand All @@ -8478,21 +8488,20 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)

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);

Expand Down
Binary file modified tommath.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion tommath.src
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ QUALCOMM Australia \\
}
}
\maketitle
This text has been placed in the public domain. This text corresponds to the v0.36 release of the
This text has been placed in the public domain. This text corresponds to the v0.37 release of the
LibTomMath project.

\begin{alltt}
Expand Down
Loading

0 comments on commit fde740e

Please sign in to comment.