1 #ifndef __crypto_openssl_h
2 #define __crypto_openssl_h
5 #define CONFIG "config.h"
9 #include <openssl/opensslv.h>
10 #include <openssl/sha.h>
11 #include <openssl/hmac.h>
12 #include <openssl/aes.h>
15 #define Sha256(d, l, h) SHA256(d, l, h)
16 int_fast8_t Sha256Hmac(BYTE
* key
, BYTE
* restrict data
, DWORD len
, BYTE
* restrict hmac
);
18 #ifndef _OPENSSL_NO_HMAC
19 #define Sha256HmacCtx HMAC_CTX
27 #ifndef _OPENSSL_NO_HMAC
29 #define Sha256HmacInit(c, k, l) Sha256HmacInit_OpenSSL(c, k, l)
30 #define Sha256HmacFinish(c, h) Sha256HmacFinish_OpenSSL(c, h, NULL)
32 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
33 #define Sha256HmacUpdate(c, d, l) HMAC_Update(c, d, l)
34 #else // OPENSSL_VERSION_NUMBER < 0x10000000L
35 #define Sha256HmacUpdate(c, d, l) (HMAC_Update(c, d, l), !0)
36 #endif // OPENSSL_VERSION_NUMBER >= 0x10000000L
38 int Sha256HmacInit_OpenSSL(HMAC_CTX
*c
, const void *k
, int l
);
39 int Sha256HmacFinish_OpenSSL(HMAC_CTX
*c
, unsigned char *h
, unsigned int *l
);
41 #else // _OPENSSL_NO_HMAC
43 int _Sha256HmacInit(Sha256HmacCtx
*Ctx
, BYTE
*key
, size_t klen
);
44 int _Sha256HmacUpdate(Sha256HmacCtx
*Ctx
, BYTE
*data
, size_t len
);
45 int _Sha256HmacFinish(Sha256HmacCtx
*Ctx
, BYTE
*hmac
, void* dummy
);
46 #define Sha256HmacInit(c, k, l) _Sha256HmacInit(c, k, l)
47 #define Sha256HmacFinish(c, h) _Sha256HmacFinish(c, h, NULL)
48 #define Sha256HmacUpdate(c, d, l) _Sha256HmacUpdate(c, d, l)
50 #endif // _OPENSSL_NO_HMAC
52 extern const BYTE AesKeyV4
[];
53 #endif // __crypto_openssl_h