Commit 32f3ba18 authored by Niels Möller's avatar Niels Möller

Merge branch 'ecc-support'.

parents 11609bf3 33304507
RCS
SCCS
CVS
CVS.adm
RCSLOG
cvslog.*
tags
TAGS
.make.state
.nse_depinfo
*~
#*
.#*
,*
_$*
*$
*.old
*.bak
*.BAK
*.orig
*.rej
.del-*
*.a
*.olb
*.o
*.obj
*.so
*.exe
*.Z
*.elc
*.ln
core
/*.d
/*.po
......@@ -37,9 +18,7 @@ core
/*.tar.gz.asc
/.lib
/*.asm
/autom4te.cache
/Makefile
/aesdata
/config.cache
/config.h
/config.h.in
......@@ -48,12 +27,27 @@ core
/config.make
/config.status
/configure
/autom4te.cache
/stamp-h
/stamp-h.in
/nettle-stdint.h
/*.pc
/machine.m4
/aesdata
/desdata
/eccdata
/eccdata.stamp
/gcmdata
/shadata
/twofishdata
/keymap.h
/nettle-stdint.h
/parity.h
/rotors.h
/ecc-192.h
/ecc-224.h
/ecc-256.h
/ecc-384.h
/ecc-521.h
/nettle.aux
/nettle.cp
/nettle.cps
......@@ -71,8 +65,3 @@ core
/nettle.tps
/nettle.vr
/nettle.vrs
/parity.h
/rotors.h
/shadata
/stamp-h
/stamp-h.in
2013-03-07 Niels Möller <nisse@lysator.liu.se>
* gmp-glue.c (mpz_limbs_cmp): Don't use PTR and SIZ macros.
* Makefile.in (aesdata, desdata, twofishdata, shadata, gcmdata)
(eccdata): Arrange for compiling these programs for running on the
build system, also when cross compiling everything else.
* config.make.in (CC_FOR_BUILD, EXEEXT_FOR_BUILD): New variables.
* configure.ac: Use GMP_PROG_CC_FOR_BUILD and
GMP_PROG_EXEEXT_FOR_BUILD.
* aclocal.m4 (GMP_PROG_CC_FOR_BUILD, GMP_PROG_CC_FOR_BUILD_WORKS)
(GMP_PROG_EXEEXT_FOR_BUILD): New macros, based on GMP's.
* aesdata.c: Deleted includes of config.h and nettle-types.h. Use
unsigned char and unsigned long instead of stdint.h types.
* desdata.c: Deleted includes of config.h and desCode.h.
(main): Return 1 on invalid argument. Don't use ROR macro. Use
unsigned long instead of uint32_t, and make it work if unsigned
long is larger than 32 bits.
* gcmdata.c: Deleted include of config.h and use UNUSED macro.
* shadata.c: Likewise.
* twofishdata.c: Deleted include of nettle-types.h. Use unsigned
char instead of stdint.h types.
* x86_64/ecc-521-modp.asm: New file. 2.4 time speedup.
2013-03-06 Niels Möller <nisse@lysator.liu.se>
* x86_64/ecc-384-modp.asm: New file, 3 time speedup.
* x86_64/ecc-256-redc.asm: New file, 2.5 time speedup.
* x86_64/ecc-224-modp.asm: New file, 5 time speedup over C
version.
2013-03-05 Niels Möller <nisse@lysator.liu.se>
* configure.ac (asm_optional_list): Added ecc-521-modp.asm.
* ecc-521.c: Check HAVE_NATIVE_ecc_521_modp, and use native
version if available.
* armv7/ecc-521-modp.asm: New file, 2 time speedup over C version.
2013-03-04 Niels Möller <nisse@lysator.liu.se>
* configure.ac (asm_optional_list): Added ecc-384-modp.asm. Deleted
bogus reference to $asm_search_list.
* ecc-384.c: Check HAVE_NATIVE_ecc_384_modp, and use native
version if available.
* armv7/ecc-384-modp.asm: New file, 3 time speedup over C version.
2013-03-03 Niels Möller <nisse@lysator.liu.se>
* ecc-256.c: Fixed definition of USE_REDC.
2013-03-01 Niels Möller <nisse@lysator.liu.se>
* ecc-256.c: Check HAVE_NATIVE_ecc_256_redc, and use native
version if available.
* armv7/ecc-256-redc.asm: New file, 4 time speedup over C version.
* testsuite/ecc-redc-test.c: Increased test count.
* ecc-224.c: Check HAVE_NATIVE_ecc_224_modp, and use native
version if available.
* armv7/ecc-224-modp.asm: New file, 4.5 time speedup over C
version.
* configure.ac (asm_optional_list): Added ecc-224-modp.asm.
(OPT_ASM_SOURCES): Fixed assignment.
2013-02-28 Niels Möller <nisse@lysator.liu.se>
* x86_64/ecc-192-modp.asm: Reorganized to reduce number of
additions. Use setc instruction.
* examples/Makefile.in: Let $(HOGWEED_TARGETS) depend on
../libhogweed.a.
* armv7/ecc-192-modp.asm: New file. 2.5 time speedup over C
version.
2013-02-27 Niels Möller <nisse@lysator.liu.se>
* ecc-192.c: Check HAVE_NATIVE_ecc_192_modp, and use native
version if available.
(ecc_192_modp): Fixed carry handling bug in 32-bit version.
* x86_64/ecc-192-modp.asm: New file. 3.8 times speedup over C
version.
* configure.ac (OPT_ASM_SOURCES): New substituted variable.
(asm_replace_list, asm_optional_list): New variables. For files in
asm_optional_list, also add them to OPT_ASM_SOURCES and define
appropriate HAVE_NATIVE_* symbols found.
* Makefile.in (OPT_ASM_SOURCES): New variable. Used for setting
hogweed_OBJS and hogweed_PURE_OBJS.
* testsuite/ecc-mod-test.c: Increased test count.
* ecc-384.c (ecc_384_modp): Fixed typo which broke carry handling
in the 64-bit version.
* examples/ecc-benchmark.c (bench_add_jjj): Typo fix, benchmark
the right function.
* gmp-glue.h: Check if GMP provides mpz_limbs_read (expected in
next release).
* gmp-glue.c: Use GMP's mpz_limbs_read and friends if available.
Renamed all functions for consistency with GMP. Updated all
callers.
2013-02-20 Niels Möller <nisse@lysator.liu.se>
* examples/Makefile.in (HOGWEED_TARGETS): Added
hogweed-benchmark$(EXEEXT).
(SOURCES): Added hogweed-benchmark.c.
(hogweed-benchmark$(EXEEXT)): New target.
* examples/hogweed-benchmark.c: New file.
* ecdsa-keygen.c (ecdsa_generate_keypair): New file and function.
* Makefile.in (hogweed_SOURCES): Added ecdsa-keygen.c.
* testsuite/ecdsa-keygen-test.c: New testcase.
* testsuite/Makefile.in (TS_HOGWEED_SOURCES): Added
ecdsa-keygen-test.c.
* nettle-internal.h (TMP_ALLOC): Added missing parentheses.
2013-02-18 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecdsa-verify-test.c: New testcase.
* testsuite/ecdsa-sign-test.c: New testcase.
* testsuite/Makefile.in (TS_HOGWEED_SOURCES): Added
ecdsa-sign-test.c and ecdsa-verify-test.c.
* testsuite/testutils.h: Include ecdsa.h.
(SHEX): Deleted const cast.
* ecc-point.c: New file, struct ecc_point abstraction.
* ecc-scalar.c: New file, struct ecc_scalar abstraction.
* ecc-random.c (ecc_modq_random, ecc_scalar_random): New file, new
functions.
* ecc-hash.c (ecc_hash): New file and function.
* ecc-ecdsa-sign.c: New file, low-level signing interface.
* ecc-ecdsa-verify.c: New file, low-level ecdsa verify.
* ecdsa-sign.c: (ecdsa_sign): New file and function.
* ecdsa-verify.c (ecdsa_verify): New file and function.
* ecdsa.h: New header file.
* ecc.h: Declare ecc_point and ecc_scalar functions.
* ecc-internal.h: Added declarations.
* Makefile.in (hogweed_SOURCES): Added new source files.
(HEADERS): Added ecdsa.h.
* gmp-glue.c (_mpz_set_mpn): New convenience function.
(_mpn_set_base256): New function.
(_gmp_alloc_limbs): New function.
(_gmp_free_limbs): New function.
* gmp-glue.h: Corresponding declarations. Include nettle-stdinh.h.
* examples/Makefile.in (HOGWEED_TARGETS): Renamed, was
RSA_TARGETS. Added ecc-benchmark$(EXEEXT).
(SOURCES): Added ecc-benchmark.c.
(ecc-benchmark$(EXEEXT)): New target.
* examples/ecc-benchmark.c: New file, benchmarking ecc primitives.
2013-02-15 Niels Möller <nisse@lysator.liu.se>
Integrate ecc_mul_a.
* ecc-a-to-j.c: New file.
* ecc-add-jjj.c: New file.
* ecc-mul-a.c: New file.
* Makefile.in (hogweed_SOURCES): Added new files.
* testsuite/ecc-mul-a-test.c: New file.
* testsuite/Makefile.in (TS_HOGWEED_SOURCES): Added
ecc-mul-a-test.c.
* testsuite/testutils.c: Removed redundant includes.
(die): New function.
Integrate ecc_mul_g.
* ecc.h: New file.
* ecc-j-to-a.c: New file.
* ecc-size.c: New file.
* ecc-add-jja.c: New file.
* ecc-dup-jj.c: New file.
* ecc-mul-g.c: New file.
* sec-tabselect.c: New file.
* Makefile.in (hogweed_SOURCES): Added new files.
(HEADERS): Added ecc.h
* testsuite/ecc-mul-g-test.c: New file.
* testsuite/Makefile.in (TS_HOGWEED_SOURCES): Added
ecc-mul-g-test.c.
* testsuite/testutils.c (xalloc_limbs): New function.
(test_mpn): New function.
(test_ecc_point): New function.
(test_ecc_mul_a): New function.
(test_ecc_mul_j): New function.
* testsuite/testutils.h: Corresponding declarations.
Integrate ECC internals.
* ecc-curve.h: New file.
* ecc-internal.h: New file.
* cnd-copy.c: New file.
* ecc-192.c: New file.
* ecc-224.c: New file.
* ecc-256.c: New file.
* ecc-384.c: New file.
* ecc-521.c: New file.
* ecc-generic-modp.c: New file.
* ecc-generic-modq.c: New file.
* ecc-generic-redc.c: New file.
* ecc-mod.c: New file.
* ecc-modp.c: New file.
* ecc-modq.c: New file.
* sec-add-1.c: New file.
* sec-modinv.c: New file.
* sec-sub-1.c: New file.
* Makefile.in (hogweed_SOURCES): Added new files.
(HEADERS): Added ecc-curve.h.
(DISTFILES): Added ecc-internal.h.
* testsuite/ecc-mod-test.c: New file.
* testsuite/ecc-modinv-test.c: New file.
* testsuite/ecc-redc-test.c: New file.
* testsuite/testutils.c (ecc_curves): New constant array.
* testsuite/testutils.h: Include ecc-related headers. Declare
ecc_curves array.
* testsuite/Makefile.in (TS_HOGWEED_SOURCES): Added ecc-mod-test.c
ecc-modinv-test.c ecc-redc-test.c.
* gmp-glue.c: New file, mpn <-> mpz conversions.
* gmp-glue.h: New file.
* Makefile.in: Added to hogweed_SOURCES and DISTFILES, respectively.
* eccdata.c: New program, for generating ECC-related tables.
* Makefile.in (ecc-192.h, ecc-224.h, ecc-256.h, ecc-384.h)
(ecc-512.h): New generated files.
2013-02-19 Niels Möller <nisse@lysator.liu.se>
* armv7/memxor.asm (memxor): Software pipelining for the aligned
......@@ -8,6 +250,9 @@
2013-02-14 Niels Möller <nisse@lysator.liu.se>
* configure.ac: Find GMP's GMP_NUMB_BITS. Substitute in Makefile.
* config.make.in (GMP_NUMB_BITS): New variable.
* examples/rsa-keygen.c (uint_arg): New function.
(main): New options -s and -e, to specify key size and public
exponent. Increased default key size to 2048.
......
......@@ -14,6 +14,8 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = $(INSTALL_PROGRAM) -s
MKDIR_P = @MKDIR_P@
OPT_ASM_SOURCES = @OPT_ASM_SOURCES@
SUBDIRS = tools testsuite examples
include config.make
......@@ -30,7 +32,7 @@ internal_SOURCES = nettle-internal.c
internal_TARGETS = $(internal_SOURCES:.c=.$(OBJEXT))
TARGETS = aesdata$(EXEEXT) desdata$(EXEEXT) twofishdata$(EXEEXT) \
shadata$(EXEEXT) gcmdata$(EXEEXT) \
shadata$(EXEEXT) gcmdata$(EXEEXT) eccdata$(EXEEXT) \
$(getopt_TARGETS) $(internal_TARGETS) \
$(LIBTARGETS) $(SHLIBTARGETS)
IMPLICIT_TARGETS = @IF_DLL@ $(LIBNETTLE_FILE) $(LIBHOGWEED_FILE)
......@@ -122,21 +124,31 @@ hogweed_SOURCES = sexp.c sexp-format.c \
dsa-sha256-sign.c dsa-sha256-verify.c \
dsa2sexp.c sexp2dsa.c \
pgp-encode.c rsa2openpgp.c \
der-iterator.c der2rsa.c der2dsa.c
der-iterator.c der2rsa.c der2dsa.c \
sec-add-1.c sec-sub-1.c sec-modinv.c sec-tabselect.c \
gmp-glue.c cnd-copy.c \
ecc-mod.c ecc-generic-modp.c ecc-generic-modq.c \
ecc-modp.c ecc-modq.c ecc-generic-redc.c \
ecc-192.c ecc-224.c ecc-256.c ecc-384.c ecc-521.c \
ecc-size.c ecc-j-to-a.c ecc-a-to-j.c \
ecc-dup-jj.c ecc-add-jja.c ecc-add-jjj.c \
ecc-mul-g.c ecc-mul-a.c ecc-hash.c ecc-random.c \
ecc-point.c ecc-scalar.c \
ecc-ecdsa-sign.c ecdsa-sign.c \
ecc-ecdsa-verify.c ecdsa-verify.c ecdsa-keygen.c
HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \
base16.h base64.h buffer.h camellia.h cast128.h \
cbc.h ctr.h gcm.h \
des.h des-compat.h dsa.h \
hmac.h \
pbkdf2.h \
cbc.h ctr.h \
des.h des-compat.h dsa.h ecc-curve.h ecc.h ecdsa.h \
gcm.h gosthash94.h hmac.h \
knuth-lfib.h \
macros.h \
md2.h md4.h \
gosthash94.h \
md5.h md5-compat.h \
memxor.h \
nettle-meta.h nettle-types.h \
pbkdf2.h \
pgp.h pkcs1.h realloc.h ripemd160.h rsa.h rsa-compat.h \
salsa20.h sexp.h \
serpent.h sha.h sha1.h sha2.h sha3.h twofish.h \
......@@ -146,7 +158,7 @@ INSTALL_HEADERS = $(HEADERS) nettle-stdint.h
SOURCES = $(nettle_SOURCES) $(hogweed_SOURCES) \
$(getopt_SOURCES) $(internal_SOURCES) \
aesdata.c desdata.c twofishdata.c shadata.c gcmdata.c
aesdata.c desdata.c twofishdata.c shadata.c gcmdata.c eccdata.c
DISTFILES = $(SOURCES) $(HEADERS) getopt.h .bootstrap run-tests \
aclocal.m4 configure.ac \
......@@ -159,6 +171,7 @@ DISTFILES = $(SOURCES) $(HEADERS) getopt.h .bootstrap run-tests \
aes-internal.h camellia-internal.h serpent-internal.h \
cast128_sboxes.h desinfo.h desCode.h \
nettle-internal.h nettle-write.h prime-list.h \
gmp-glue.h ecc-internal.h \
asm.m4 \
nettle.texinfo nettle.info nettle.html nettle.pdf sha-example.c
......@@ -166,8 +179,8 @@ DISTFILES = $(SOURCES) $(HEADERS) getopt.h .bootstrap run-tests \
nettle_OBJS = $(nettle_SOURCES:.c=.$(OBJEXT)) $(LIBOBJS)
nettle_PURE_OBJS = $(nettle_OBJS:.$(OBJEXT)=.p$(OBJEXT))
hogweed_OBJS = $(hogweed_SOURCES:.c=.$(OBJEXT))
hogweed_PURE_OBJS = $(hogweed_OBJS:.$(OBJEXT)=.p$(OBJEXT))
hogweed_OBJS = $(hogweed_SOURCES:.c=.$(OBJEXT)) $(OPT_ASM_SOURCES:.asm=.$(OBJEXT))
hogweed_PURE_OBJS = $(hogweed_OBJS:.$(OBJEXT)=.p$(OBJEXT)) $(OPT_ASM_SOURCES:.asm=.p$(OBJEXT))
libnettle.a: $(nettle_OBJS)
-rm -f $@
......@@ -208,24 +221,32 @@ $(LIBHOGWEED_FORLINK): $(hogweed_PURE_OBJS) $(LIBNETTLE_FORLINK)
$(COMPILE) $(SHLIBCFLAGS) -c $< -o $@ \
&& $(DEP_PROCESS)
# For Solaris and BSD make, we have to use an explicit rule for each executable
aesdata$(EXEEXT): aesdata.$(OBJEXT)
$(LINK) aesdata.$(OBJEXT) $(LIBS) -o aesdata$(EXEEXT)
# For Solaris and BSD make, we have to use an explicit rule for each
# executable. Avoid object file targets to make it easy to run the
# right compiler.
aesdata$(EXEEXT_FOR_BUILD): aesdata.c
$(CC_FOR_BUILD) `test -f aesdata.c || echo '$(srcdir)/'`aesdata.c \
-o aesdata$(EXEEXT_FOR_BUILD)
desdata$(EXEEXT): desdata.$(OBJEXT)
$(LINK) desdata.$(OBJEXT) $(LIBS) -o desdata$(EXEEXT)
desdata$(EXEEXT_FOR_BUILD): desdata.c
$(CC_FOR_BUILD) `test -f desdata.c || echo '$(srcdir)/'`desdata.c \
-o desdata$(EXEEXT_FOR_BUILD)
twofishdata$(EXEEXT): twofishdata.$(OBJEXT)
$(LINK) twofishdata.$(OBJEXT) $(LIBS) -o twofishdata$(EXEEXT)
twofishdata$(EXEEXT_FOR_BUILD): twofishdata.c
$(CC_FOR_BUILD) `test -f twofishdata.c || echo '$(srcdir)/'`twofishdata.c \
-o twofishdata$(EXEEXT_FOR_BUILD)
shadata$(EXEEXT): shadata.$(OBJEXT)
$(LINK) shadata.$(OBJEXT) $(LIBS) -lm -o shadata$(EXEEXT)
shadata$(EXEEXT_FOR_BUILD): shadata.c
$(CC_FOR_BUILD) `test -f shadata.c || echo '$(srcdir)/'`shadata.c -lm \
-o shadata$(EXEEXT_FOR_BUILD)
gcmdata$(EXEEXT): gcmdata.$(OBJEXT)
$(LINK) gcmdata.$(OBJEXT) $(LIBS) -o gcmdata$(EXEEXT)
gcmdata$(EXEEXT_FOR_BUILD): gcmdata.c
$(CC_FOR_BUILD) `test -f gcmdata.c || echo '$(srcdir)/'`gcmdata.c \
-o gcmdata$(EXEEXT_FOR_BUILD)
# .$(OBJEXT)$(EXEEXT):
# $(LINK) $< $(LIBS) -o $@
eccdata$(EXEEXT_FOR_BUILD): eccdata.c
$(CC_FOR_BUILD) `test -f eccdata.c || echo '$(srcdir)/'`eccdata.c -lgmp \
-o eccdata$(EXEEXT_FOR_BUILD)
# desCore rules
# It seems using $(srcdir)/ doesn't work with GNU make 3.79.1
......@@ -241,6 +262,64 @@ $(des_headers): desdata.c
des.$(OBJEXT): des.c des.h $(des_headers)
# Generate ECC files.
# Some possible choices for 192:
# k = 15, c = 4, 64 entries, ~3 KB
# k = 20, c = 6, 128 entries, ~6 KB
# k = 10, c = 6, 256 entries, ~12 KB
# k = 7, c = 6, 320 entries, ~15 KB
# k = 9, c = 7, 512 entries, ~24 KB
ecc-192.h: eccdata.stamp
./eccdata$(EXEEXT) 192 7 6 $(GMP_NUMB_BITS) > $@T && mv $@T $@
# Some possible choices for 224:
# k = 18, c = 4, 64 entries, ~4 KB
# k = 24, c = 6, 128 entries, ~8 KB
# k = 12, c = 6, 256 entries, ~16 KB
# k = 8, c = 6, 320 entries, ~20 KB
# k = 10, c = 7, 512 entries, ~32 KB
ecc-224.h: eccdata.stamp
./eccdata$(EXEEXT) 224 12 6 $(GMP_NUMB_BITS) > $@T && mv $@T $@
# Some possible choices for 256:
# k = 20, c = 4, 64 entries, ~4 KB
# k = 27, c = 6, 128 entries, ~8 KB
# k = 14, c = 6, 256 entries, ~16 KB
# k = 9, c = 6, 320 entries, ~20 KB
# k = 12, c = 7, 512 entries, ~32 KB
ecc-256.h: eccdata.stamp
./eccdata$(EXEEXT) 256 14 6 $(GMP_NUMB_BITS) > $@T && mv $@T $@
# Some possible choices for 384:
# k = 31, c = 4, 64 entries, ~6 KB
# k = 41, c = 6, 128 entries, ~12 KB
# k = 20, c = 6, 256 entries, ~24 KB
# k = 14, c = 6, 320 entries, ~30 KB
# k = 18, c = 7, 512 entries, ~48 KB
ecc-384.h: eccdata.stamp
./eccdata$(EXEEXT) 384 41 6 $(GMP_NUMB_BITS) > $@T && mv $@T $@
# Some possible choices for 521:
# k = 42, c = 4, 64 entries, ~9 KB
# k = 56, c = 6, 128 entries, ~18 KB
# k = 28, c = 6, 256 entries, ~35 KB
# k = 19, c = 6, 320 entries, ~44 KB
# k = 24, c = 7, 512 entries, ~70 KB
ecc-521.h: eccdata.stamp
./eccdata$(EXEEXT) 521 56 6 $(GMP_NUMB_BITS) > $@T && mv $@T $@
eccdata.stamp: eccdata.c
$(MAKE) eccdata$(EXEEXT)
echo stamp > eccdata.stamp
ecc-192.$(OBJEXT): ecc-192.h
ecc-224.$(OBJEXT): ecc-224.h
ecc-256.$(OBJEXT): ecc-256.h
ecc-384.$(OBJEXT): ecc-384.h
ecc-521.$(OBJEXT): ecc-521.h
ecc-192.p$(OBJEXT): ecc-192.h
ecc-224.p$(OBJEXT): ecc-224.h
ecc-256.p$(OBJEXT): ecc-256.h
ecc-384.p$(OBJEXT): ecc-384.h
ecc-521.p$(OBJEXT): ecc-521.h
.asm.s:
$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$@T \
&& test -s $@T && mv -f $@T $@
......@@ -490,7 +569,8 @@ distcheck: dist
$(rm_distcheck)
clean-here:
-rm -f $(TARGETS) $(IMPLICIT_TARGETS) *.$(OBJEXT) *.p$(OBJEXT) *.s
-rm -f $(TARGETS) $(IMPLICIT_TARGETS) *.$(OBJEXT) *.p$(OBJEXT) *.s \
ecc-192.h ecc-224.h ecc-256.h ecc-384.h ecc-521.h eccdata.stamp
-rm -rf .lib
distclean-here: clean-here
......
......@@ -496,6 +496,118 @@ fi
rm -f conftest*
])
dnl GMP_PROG_CC_FOR_BUILD
dnl ---------------------
dnl Establish CC_FOR_BUILD, a C compiler for the build system.
dnl
dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old
dnl style HOST_CC, otherwise some likely candidates are tried, the same as
dnl configfsf.guess.
AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
[AC_REQUIRE([AC_PROG_CC])
if test -n "$CC_FOR_BUILD"; then
GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
[AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
elif test -n "$HOST_CC"; then
GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
[CC_FOR_BUILD=$HOST_CC],
[AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
elif test $cross_compiling = no ; then
CC_FOR_BUILD="$CC"
else
for i in cc gcc c89 c99; do
GMP_PROG_CC_FOR_BUILD_WORKS($i,
[CC_FOR_BUILD=$i
break])
done
if test -z "$CC_FOR_BUILD"; then
AC_MSG_ERROR([Cannot find a build system compiler])
fi
fi
AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
AC_SUBST(CC_FOR_BUILD)
])
dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
dnl -------------------------------------------------------------------------
dnl See if the given cc/cflags works on the build system.
dnl
dnl It seems easiest to just use the default compiler output, rather than
dnl figuring out the .exe or whatever at this stage.
AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
[AC_MSG_CHECKING([build system compiler $1])
# remove anything that might look like compiler output to our "||" expression
rm -f conftest* a.out b.out a.exe a_out.exe
cat >conftest.c <<EOF
int
main ()
{
exit(0);
}
EOF
gmp_compile="$1 conftest.c"
cc_for_build_works=no
if AC_TRY_EVAL(gmp_compile); then
if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
cc_for_build_works=yes
fi
fi
rm -f conftest* a.out b.out a.exe a_out.exe
AC_MSG_RESULT($cc_for_build_works)
if test "$cc_for_build_works" = yes; then
ifelse([$2],,:,[$2])
else
ifelse([$3],,:,[$3])
fi
])
dnl GMP_PROG_EXEEXT_FOR_BUILD
dnl -------------------------
dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.
dnl
dnl The idea is to find what "-o conftest$foo" will make it possible to run
dnl the program with ./conftest. On Unix-like systems this is of course
dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
dnl system cross compile it can be ",ff8" apparently. Not sure if the
dnl latter actually applies to a build-system executable, maybe it doesn't,
dnl but it won't hurt to try.
AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
AC_CACHE_CHECK([for build system executable suffix],
gmp_cv_prog_exeext_for_build,
[if test $cross_compiling = no ; then
gmp_cv_prog_exeext_for_build="$EXEEXT"
else
cat >conftest.c <<EOF
int
main ()
{
exit (0);
}
EOF
for i in .exe ,ff8 ""; do
gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
if AC_TRY_EVAL(gmp_compile); then
if (./conftest) 2>&AC_FD_CC; then
gmp_cv_prog_exeext_for_build=$i
break
fi
fi
done
rm -f conftest*
if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
AC_MSG_ERROR([Cannot determine executable suffix])
fi
fi
])
AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
])
dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
dnl
dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
......
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "nettle-types.h"
#if 1
# define BYTE_FORMAT "0x%02x"
# define BYTE_COLUMNS 8
......@@ -17,18 +11,18 @@
# define BYTE_COLUMNS 0x10
#endif
#define WORD_FORMAT "0x%08x"
#define WORD_FORMAT "0x%08lx"
#define WORD_COLUMNS 4
uint8_t sbox[0x100];
uint8_t isbox[0x100];
unsigned char sbox[0x100];
unsigned char isbox[0x100];
uint8_t gf2_log[0x100];
uint8_t gf2_exp[0x100];
unsigned char gf2_log[0x100];
unsigned char gf2_exp[0x100];
uint32_t dtable[4][0x100];
uint32_t itable[4][0x100];
uint32_t mtable[4][0x100];
unsigned long dtable[4][0x100];
unsigned long itable[4][0x100];
unsigned long mtable[4][0x100];
static unsigned
xtime(unsigned x)
......@@ -109,7 +103,7 @@ compute_dtable(void)
{
unsigned s = sbox[i];
unsigned j;
uint32_t t =( ( (s ^ xtime(s)) << 24)
unsigned long t =( ( (s ^ xtime(s)) << 24)
| (s << 16) | (s << 8)
| xtime(s) );
......@@ -128,10 +122,10 @@ compute_itable(void)