tomcrypt_test.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 store_test(void);
  45. int rsa_test(void);
  46. int dh_test(void);
  47. int katja_test(void);
  48. int ecc_tests(void);
  49. int dsa_test(void);
  50. int der_tests(void);
  51. /* timing */
  52. #define KTIMES 25
  53. #define TIMES 100000
  54. extern struct list {
  55. int id;
  56. unsigned long spd1, spd2, avg;
  57. } results[];
  58. extern int no_results;
  59. int sorter(const void *a, const void *b);
  60. void tally_results(int type);
  61. ulong64 rdtsc (void);
  62. void t_start(void);
  63. ulong64 t_read(void);
  64. void init_timer(void);
  65. /* register default algs */
  66. void reg_algs(void);
  67. int time_keysched(void);
  68. int time_cipher(void);
  69. int time_cipher2(void);
  70. int time_cipher3(void);
  71. int time_hash(void);
  72. void time_mult(void);
  73. void time_sqr(void);
  74. void time_prng(void);
  75. void time_rsa(void);
  76. void time_dsa(void);
  77. void time_katja(void);
  78. void time_ecc(void);
  79. void time_macs_(unsigned long MAC_SIZE);
  80. void time_macs(void);
  81. void time_encmacs(void);
  82. #endif
  83. /* $Source$ */
  84. /* $Revision$ */
  85. /* $Date$ */