2005-04-17 11:37:13 +00:00
|
|
|
#include <tomcrypt_test.h>
|
|
|
|
|
2017-03-01 14:00:04 +00:00
|
|
|
#define LTC_TEST_FN(f) { f, #f }
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
int (*fn)(void);
|
|
|
|
const char* name;
|
|
|
|
} test_functions[] =
|
|
|
|
{
|
|
|
|
LTC_TEST_FN(store_test),
|
2017-03-27 17:32:05 +00:00
|
|
|
LTC_TEST_FN(rotate_test),
|
2017-03-01 14:00:04 +00:00
|
|
|
LTC_TEST_FN(misc_test),
|
|
|
|
LTC_TEST_FN(cipher_hash_test),
|
|
|
|
LTC_TEST_FN(mac_test),
|
|
|
|
LTC_TEST_FN(modes_test),
|
|
|
|
LTC_TEST_FN(der_tests),
|
|
|
|
LTC_TEST_FN(pkcs_1_test),
|
|
|
|
LTC_TEST_FN(pkcs_1_pss_test),
|
|
|
|
LTC_TEST_FN(pkcs_1_oaep_test),
|
|
|
|
LTC_TEST_FN(pkcs_1_emsa_test),
|
|
|
|
LTC_TEST_FN(pkcs_1_eme_test),
|
|
|
|
LTC_TEST_FN(rsa_test),
|
|
|
|
LTC_TEST_FN(dh_test),
|
|
|
|
LTC_TEST_FN(ecc_tests),
|
|
|
|
LTC_TEST_FN(dsa_test),
|
|
|
|
LTC_TEST_FN(katja_test),
|
|
|
|
};
|
|
|
|
|
2017-03-29 18:52:30 +00:00
|
|
|
int main(int argc, char **argv)
|
2005-04-17 11:37:13 +00:00
|
|
|
{
|
2017-03-29 18:52:30 +00:00
|
|
|
int x, pass = 0, fail = 0, nop = 0;
|
2017-03-01 14:00:04 +00:00
|
|
|
size_t fn_len, i, dots;
|
2017-03-29 18:52:30 +00:00
|
|
|
char *single_test = NULL;
|
|
|
|
ulong64 ts, dur = 0;
|
2005-04-17 11:37:13 +00:00
|
|
|
reg_algs();
|
2005-08-01 16:36:47 +00:00
|
|
|
|
2017-03-26 13:46:41 +00:00
|
|
|
printf("build == \n%s\n", crypt_build_settings);
|
|
|
|
|
2005-08-01 16:36:47 +00:00
|
|
|
#ifdef USE_LTM
|
|
|
|
ltc_mp = ltm_desc;
|
2017-03-26 13:46:41 +00:00
|
|
|
printf("math provider = libtommath\n");
|
2005-08-01 16:36:47 +00:00
|
|
|
#elif defined(USE_TFM)
|
|
|
|
ltc_mp = tfm_desc;
|
2017-03-26 13:46:41 +00:00
|
|
|
printf("math provider = tomsfastmath\n");
|
2006-04-06 19:48:32 +00:00
|
|
|
#elif defined(USE_GMP)
|
|
|
|
ltc_mp = gmp_desc;
|
2017-03-26 13:46:41 +00:00
|
|
|
printf("math provider = gnump\n");
|
2005-08-01 16:36:47 +00:00
|
|
|
#else
|
|
|
|
extern ltc_math_descriptor EXT_MATH_LIB;
|
|
|
|
ltc_mp = EXT_MATH_LIB;
|
2017-03-26 13:46:41 +00:00
|
|
|
printf("math provider = EXT_MATH_LIB\n");
|
2005-08-01 16:36:47 +00:00
|
|
|
#endif
|
2014-09-30 11:26:18 +00:00
|
|
|
printf("MP_DIGIT_BIT = %d\n", MP_DIGIT_BIT);
|
2017-03-01 14:00:04 +00:00
|
|
|
|
|
|
|
fn_len = 0;
|
|
|
|
for (i = 0; i < sizeof(test_functions)/sizeof(test_functions[0]); ++i) {
|
|
|
|
size_t len = strlen(test_functions[i].name);
|
|
|
|
if (fn_len < len) fn_len = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn_len = fn_len + (4 - (fn_len % 4));
|
|
|
|
|
2017-03-29 18:52:30 +00:00
|
|
|
/* single test name from commandline */
|
|
|
|
if (argc > 1) single_test = argv[1];
|
|
|
|
|
2017-03-01 14:00:04 +00:00
|
|
|
for (i = 0; i < sizeof(test_functions)/sizeof(test_functions[0]); ++i) {
|
2017-03-29 18:52:30 +00:00
|
|
|
if (single_test && strcmp(test_functions[i].name, single_test)) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-01 14:00:04 +00:00
|
|
|
dots = fn_len - strlen(test_functions[i].name);
|
|
|
|
|
|
|
|
printf("\n%s", test_functions[i].name);
|
|
|
|
while(dots--) printf(".");
|
|
|
|
fflush(stdout);
|
|
|
|
|
2017-03-29 18:52:30 +00:00
|
|
|
ts = epoch_usec();
|
2017-03-01 14:00:04 +00:00
|
|
|
x = test_functions[i].fn();
|
2017-03-29 18:52:30 +00:00
|
|
|
ts = epoch_usec() - ts;
|
|
|
|
dur += ts;
|
2017-03-01 14:00:04 +00:00
|
|
|
|
2017-03-29 18:52:30 +00:00
|
|
|
if (x == CRYPT_OK) {
|
|
|
|
printf("passed %10.3fms", (double)(ts)/1000);
|
|
|
|
pass++;
|
|
|
|
}
|
|
|
|
else if (x == CRYPT_NOP) {
|
|
|
|
printf("nop");
|
|
|
|
nop++;
|
2017-03-01 14:00:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-03-29 18:52:30 +00:00
|
|
|
printf("failed %10.3fms", (double)(ts)/1000);
|
|
|
|
fail++;
|
2017-03-01 14:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-29 18:52:30 +00:00
|
|
|
if (fail > 0 || fail+pass+nop == 0) {
|
|
|
|
printf("\n\nFAILURE: passed=%d failed=%d nop=%d duration=%.1fsec\n", pass, fail, nop, (double)(dur)/(1000*1000));
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("\n\nSUCCESS: passed=%d failed=%d nop=%d duration=%.1fsec\n", pass, fail, nop, (double)(dur)/(1000*1000));
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
2005-04-17 11:37:13 +00:00
|
|
|
}
|
2005-06-09 00:08:13 +00:00
|
|
|
|
|
|
|
/* $Source$ */
|
|
|
|
/* $Revision$ */
|
|
|
|
/* $Date$ */
|