remove dependency of demos to tests/common
This commit is contained in:
parent
da3b61c7b6
commit
fe0b72ef51
@ -15,8 +15,6 @@
|
||||
#define basename(x) x
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if !defined(PATH_MAX) && defined(_MSC_VER)
|
||||
#include <windows.h>
|
||||
#define PATH_MAX MAX_PATH
|
||||
@ -159,7 +157,8 @@ int main(int argc, char **argv)
|
||||
hashsum = strdup(basename(argv[0]));
|
||||
|
||||
/* You need to register algorithms before using them */
|
||||
register_algs();
|
||||
register_all_ciphers();
|
||||
register_all_hashes();
|
||||
if (argc > 1 && (strcmp("-h", argv[1]) == 0 || strcmp("--help", argv[1]) == 0)) {
|
||||
die(EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
#include <tomcrypt.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int usage(char *name)
|
||||
{
|
||||
int x;
|
||||
@ -38,7 +36,8 @@ int main(int argc, char *argv[])
|
||||
int err;
|
||||
|
||||
/* register algs, so they can be printed */
|
||||
register_algs();
|
||||
register_all_ciphers();
|
||||
register_all_hashes();
|
||||
|
||||
if (argc < 4) {
|
||||
if ((argc > 2) && (!strcmp(argv[1], "-t"))) {
|
||||
|
@ -1,4 +1,12 @@
|
||||
#include <common.h>
|
||||
#include <tomcrypt.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define PRI64 "I64d"
|
||||
#else
|
||||
#define PRI64 "ll"
|
||||
#endif
|
||||
|
||||
static prng_state yarrow_prng;
|
||||
|
||||
/* timing */
|
||||
#define KTIMES 25
|
||||
@ -1341,9 +1349,11 @@ static void time_encmacs(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int err;
|
||||
init_timer();
|
||||
register_algs();
|
||||
register_all_ciphers();
|
||||
register_all_hashes();
|
||||
register_all_prngs();
|
||||
|
||||
#ifdef USE_LTM
|
||||
ltc_mp = ltm_desc;
|
||||
@ -1356,6 +1366,11 @@ register_algs();
|
||||
ltc_mp = EXT_MATH_LIB;
|
||||
#endif
|
||||
|
||||
if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) {
|
||||
fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
time_keysched();
|
||||
time_cipher_ecb();
|
||||
time_cipher_cbc();
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include <tomcrypt.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void hash_gen(void)
|
||||
{
|
||||
unsigned char md[MAXBLOCKSIZE], *buf;
|
||||
@ -736,8 +734,22 @@ void lrw_gen(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
register_algs();
|
||||
setup_math();
|
||||
register_all_ciphers();
|
||||
register_all_hashes();
|
||||
register_all_prngs();
|
||||
#ifdef USE_LTM
|
||||
ltc_mp = ltm_desc;
|
||||
#elif defined(USE_TFM)
|
||||
ltc_mp = tfm_desc;
|
||||
#elif defined(USE_GMP)
|
||||
ltc_mp = gmp_desc;
|
||||
#elif defined(EXT_MATH_LIB)
|
||||
extern ltc_math_descriptor EXT_MATH_LIB;
|
||||
ltc_mp = EXT_MATH_LIB;
|
||||
#else
|
||||
fprintf(stderr, "No MPI provider available\n");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
|
||||
printf("Generating hash vectors..."); fflush(stdout); hash_gen(); printf("done\n");
|
||||
printf("Generating cipher vectors..."); fflush(stdout); cipher_gen(); printf("done\n");
|
||||
|
8
makefile
8
makefile
@ -58,11 +58,11 @@ ifneq ($V,1)
|
||||
endif
|
||||
${silent} $(RANLIB) $@
|
||||
|
||||
timing: $(LIBNAME) $(TIMINGS) tests/common.o
|
||||
timing: $(LIBNAME) $(TIMINGS)
|
||||
ifneq ($V,1)
|
||||
@echo " * ${CC} $@"
|
||||
endif
|
||||
${silent} $(CC) $(LDFLAGS) $(TIMINGS) tests/common.o $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
|
||||
${silent} $(CC) $(LDFLAGS) $(TIMINGS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
|
||||
|
||||
test: $(LIBNAME) $(TOBJECTS)
|
||||
ifneq ($V,1)
|
||||
@ -72,11 +72,11 @@ endif
|
||||
|
||||
# build the demos from a template
|
||||
define DEMO_template
|
||||
$(1): demos/$(1).o $$(LIBNAME) tests/common.o
|
||||
$(1): demos/$(1).o $$(LIBNAME)
|
||||
ifneq ($V,1)
|
||||
@echo " * $${CC} $$@"
|
||||
endif
|
||||
$${silent} $$(CC) $$(CFLAGS) $$< tests/common.o $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
|
||||
$${silent} $$(CC) $$(CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
|
||||
endef
|
||||
|
||||
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
||||
|
@ -235,16 +235,16 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
|
||||
$(STRIP) -S $(LIBMAIN_D)
|
||||
|
||||
#Demo tools/utilities
|
||||
hashsum.exe: demos/hashsum.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) $? $(LTC_LDFLAGS) -o $@
|
||||
ltcrypt.exe: demos/ltcrypt.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) $? $(LTC_LDFLAGS) -o $@
|
||||
small.exe: demos/small.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) $? $(LTC_LDFLAGS) -o $@
|
||||
tv_gen.exe: demos/tv_gen.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) $? $(LTC_LDFLAGS) -o $@
|
||||
timing.exe: demos/timing.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) $? $(LTC_LDFLAGS) -o $@
|
||||
hashsum.exe: demos/hashsum.o $(LIBMAIN_S)
|
||||
$(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
crypt.exe: demos/crypt.o $(LIBMAIN_S)
|
||||
$(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
small.exe: demos/small.o $(LIBMAIN_S)
|
||||
$(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
tv_gen.exe: demos/tv_gen.o $(LIBMAIN_S)
|
||||
$(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
timing.exe: demos/timing.o $(LIBMAIN_S)
|
||||
$(CC) demos/timing.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
|
||||
#Tests
|
||||
test.exe: $(TOBJECTS) $(LIBMAIN_S)
|
||||
|
@ -46,12 +46,12 @@ install_bins: .common_install_bins
|
||||
test: $(LIBNAME) $(TOBJECTS)
|
||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
|
||||
|
||||
timing: $(TIMINGS) tests/common.o $(LIBNAME)
|
||||
timing: $(TIMINGS) $(LIBNAME)
|
||||
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $^ $(EXTRALIBS)
|
||||
|
||||
# build the demos from a template
|
||||
define DEMO_template
|
||||
$(1): demos/$(1).o tests/common.o $$(LIBNAME)
|
||||
$(1): demos/$(1).o $$(LIBNAME)
|
||||
ifneq ($V,1)
|
||||
@echo " * $${CC} $$@"
|
||||
endif
|
||||
|
@ -237,16 +237,16 @@ $(LIBMAIN_S): $(OBJECTS)
|
||||
$(RANLIB) $@
|
||||
|
||||
#Demo tools/utilities
|
||||
hashsum: demos/hashsum.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) demos/hashsum.o tests/common.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
ltcrypt: demos/ltcrypt.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) demos/ltcrypt.o tests/common.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
small: demos/small.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) demos/small.o tests/common.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
tv_gen: demos/tv_gen.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) demos/tv_gen.o tests/common.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
timing: demos/timing.o tests/common.o $(LIBMAIN_S)
|
||||
$(CC) demos/timing.o tests/common.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
hashsum: demos/hashsum.o $(LIBMAIN_S)
|
||||
$(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
ltcrypt: demos/ltcrypt.o $(LIBMAIN_S)
|
||||
$(CC) demos/ltcrypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
small: demos/small.o $(LIBMAIN_S)
|
||||
$(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
tv_gen: demos/tv_gen.o $(LIBMAIN_S)
|
||||
$(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
timing: demos/timing.o $(LIBMAIN_S)
|
||||
$(CC) demos/timing.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
|
||||
|
||||
#Tests
|
||||
test: $(TOBJECTS) $(LIBMAIN_S)
|
||||
|
@ -3,12 +3,6 @@
|
||||
|
||||
#include <tomcrypt.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define PRI64 "I64d"
|
||||
#else
|
||||
#define PRI64 "ll"
|
||||
#endif
|
||||
|
||||
extern prng_state yarrow_prng;
|
||||
|
||||
#ifdef LTC_VERBOSE
|
||||
|
Loading…
Reference in New Issue
Block a user