common.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis
  2. *
  3. * LibTomCrypt is a library that provides various cryptographic
  4. * algorithms in a highly modular and flexible manner.
  5. *
  6. * The library is free for all purposes without any express
  7. * guarantee it works.
  8. */
  9. #ifndef DEMOS_COMMON_H_
  10. #define DEMOS_COMMON_H_
  11. #include <tomcrypt.h>
  12. extern prng_state yarrow_prng;
  13. #ifdef LTC_VERBOSE
  14. #define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0)
  15. #define DOX(x, str) do { fprintf(stderr, "%s - %s:\n", #x, (str)); run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0)
  16. #define SHOULD_FAIL(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x) != CRYPT_OK ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR, __LINE__, __FILE__, #x, NULL); } while (0)
  17. #else
  18. #define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0)
  19. #define DOX(x, str) do { run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0)
  20. #define SHOULD_FAIL(x) do { run_cmd((x) != CRYPT_OK ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR, __LINE__, __FILE__, #x, NULL); } while (0)
  21. #endif
  22. void run_cmd(int res, int line, const char *file, const char *cmd, const char *algorithm);
  23. void print_hex(const char* what, const void* v, const unsigned long l);
  24. #endif /* DEMOS_COMMON_H_ */
  25. /* ref: $Format:%D$ */
  26. /* git commit: $Format:%H$ */
  27. /* commit time: $Format:%ai$ */