tomcrypt_test.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef __TEST_H_
  2. #define __TEST_H_
  3. #include <tomcrypt.h>
  4. #ifdef USE_LTM
  5. /* Use libtommath as MPI provider */
  6. #elif defined(USE_TFM)
  7. /* Use tomsfastmath as MPI provider */
  8. #elif defined(USE_GMP)
  9. /* Use GNU Multiple Precision Arithmetic Library as MPI provider */
  10. #else
  11. /* The user must define his own MPI provider! */
  12. #ifndef EXT_MATH_LIB
  13. /*
  14. * Yes, you're right, you could also name your instance of the MPI provider
  15. * "EXT_MATH_LIB" and you wouldn't need to define it, but most users won't do
  16. * this and so it's treated as an error and you have to comment out the
  17. * following statement :)
  18. */
  19. #error EXT_MATH_LIB is required to be defined
  20. #endif
  21. #endif
  22. /* enable stack testing */
  23. /* #define STACK_TEST */
  24. /* stack testing, define this if stack usage goes downwards [e.g. x86] */
  25. #define STACK_DOWN
  26. typedef struct {
  27. char *name, *prov, *req;
  28. int (*entry)(void);
  29. } test_entry;
  30. extern prng_state yarrow_prng;
  31. void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm);
  32. #ifdef LTC_VERBOSE
  33. #define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0)
  34. #define DOX(x, str) do { fprintf(stderr, "%s - %s:\n", #x, (str)); run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0)
  35. #else
  36. #define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0)
  37. #define DOX(x, str) do { run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0)
  38. #endif
  39. /* TESTS */
  40. int cipher_hash_test(void);
  41. int modes_test(void);
  42. int mac_test(void);
  43. int pkcs_1_test(void);
  44. int pkcs_1_pss_test(void);
  45. int pkcs_1_oaep_test(void);
  46. int pkcs_1_emsa_test(void);
  47. int pkcs_1_eme_test(void);
  48. int store_test(void);
  49. int rotate_test(void);
  50. int rsa_test(void);
  51. int dh_test(void);
  52. int katja_test(void);
  53. int ecc_tests(void);
  54. int dsa_test(void);
  55. int der_tests(void);
  56. int misc_test(void);
  57. int base64_test(void);
  58. int file_test(void);
  59. /* timing */
  60. #define KTIMES 25
  61. #define TIMES 100000
  62. extern struct list {
  63. int id;
  64. unsigned long spd1, spd2, avg;
  65. } results[];
  66. extern int no_results;
  67. #ifdef LTC_PKCS_1
  68. extern const struct ltc_prng_descriptor no_prng_desc;
  69. #endif
  70. void print_hex(const char* what, const void* v, const unsigned long l);
  71. #ifndef compare_testvector
  72. int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
  73. #endif
  74. int sorter(const void *a, const void *b);
  75. void tally_results(int type);
  76. ulong64 rdtsc (void);
  77. ulong64 epoch_usec(void);
  78. void t_start(void);
  79. ulong64 t_read(void);
  80. void init_timer(void);
  81. /* register default algs */
  82. void reg_algs(void);
  83. int time_keysched(void);
  84. int time_cipher(void);
  85. int time_cipher2(void);
  86. int time_cipher3(void);
  87. int time_cipher4(void);
  88. int time_hash(void);
  89. void time_mult(void);
  90. void time_sqr(void);
  91. void time_prng(void);
  92. void time_rsa(void);
  93. void time_dsa(void);
  94. void time_katja(void);
  95. void time_ecc(void);
  96. void time_macs_(unsigned long MAC_SIZE);
  97. void time_macs(void);
  98. void time_encmacs(void);
  99. #if defined(_WIN32)
  100. #define PRI64 "I64d"
  101. #else
  102. #define PRI64 "ll"
  103. #endif
  104. #endif
  105. /* $Source$ */
  106. /* $Revision$ */
  107. /* $Date$ */