crypto_polarssl.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef __crypto_polarssl_h
  2. #define __crypto_polarssl_h
  3. #ifndef CONFIG
  4. #define CONFIG "config.h"
  5. #endif // CONFIG
  6. #include CONFIG
  7. #include <polarssl/version.h>
  8. #include "crypto.h"
  9. #if POLARSSL_VERSION_NUMBER >= 0x01030000
  10. #include <polarssl/sha256.h>
  11. #define Sha256(d, l, h) sha256(d, l, h, 0)
  12. #define Sha256HmacCtx sha256_context
  13. #define Sha256HmacInit(c, k, l) ( sha256_hmac_starts(c, k, l, 0), !0 )
  14. #define Sha256HmacUpdate(c, d, l) ( sha256_hmac_update(c, d, l), !0 )
  15. #define Sha256HmacFinish(c, h) ( sha256_hmac_finish(c, h), !0 )
  16. #define Sha256Hmac(k, d, l, h) ( sha256_hmac(k, 16, d, l, h, FALSE), !0 )
  17. #else // POLARSSL_VERSION_NUMBER
  18. #include <polarssl/sha2.h>
  19. #define Sha256(d, l, h) sha2(d, l, h, 0)
  20. #define Sha256HmacCtx sha2_context
  21. #define Sha256HmacInit(c, k, l) ( sha2_hmac_starts(c, k, l, 0), !0 )
  22. #define Sha256HmacUpdate(c, d, l) ( sha2_hmac_update(c, d, l), !0 )
  23. #define Sha256HmacFinish(c, h) ( sha2_hmac_finish(c, h), !0 )
  24. #define Sha256Hmac(k, d, l, h) ( sha2_hmac(k, 16, d, l, h, FALSE), !0 )
  25. #endif // POLARSSL_VERSION_NUMBER
  26. #endif // __crypto_polarssl_h