forked from sunflyer/vlmcsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto_openssl.h
53 lines (41 loc) · 1.56 KB
/
crypto_openssl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef __crypto_openssl_h
#define __crypto_openssl_h
#ifndef CONFIG
#define CONFIG "config.h"
#endif // CONFIG
#include CONFIG
#include <openssl/opensslv.h>
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/aes.h>
#include "crypto.h"
#define Sha256(d, l, h) SHA256(d, l, h)
int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac);
#ifndef _OPENSSL_NO_HMAC
#define Sha256HmacCtx HMAC_CTX
#else
typedef struct {
SHA256_CTX ShaCtx;
BYTE OPad[64];
} Sha256HmacCtx;
#endif
#ifndef _OPENSSL_NO_HMAC
#define Sha256HmacInit(c, k, l) Sha256HmacInit_OpenSSL(c, k, l)
#define Sha256HmacFinish(c, h) Sha256HmacFinish_OpenSSL(c, h, NULL)
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
#define Sha256HmacUpdate(c, d, l) HMAC_Update(c, d, l)
#else // OPENSSL_VERSION_NUMBER < 0x10000000L
#define Sha256HmacUpdate(c, d, l) (HMAC_Update(c, d, l), !0)
#endif // OPENSSL_VERSION_NUMBER >= 0x10000000L
int Sha256HmacInit_OpenSSL(HMAC_CTX *c, const void *k, int l);
int Sha256HmacFinish_OpenSSL(HMAC_CTX *c, unsigned char *h, unsigned int *l);
#else // _OPENSSL_NO_HMAC
int _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen);
int _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len);
int _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac, void* dummy);
#define Sha256HmacInit(c, k, l) _Sha256HmacInit(c, k, l)
#define Sha256HmacFinish(c, h) _Sha256HmacFinish(c, h, NULL)
#define Sha256HmacUpdate(c, d, l) _Sha256HmacUpdate(c, d, l)
#endif // _OPENSSL_NO_HMAC
extern const BYTE AesKeyV4[];
#endif // __crypto_openssl_h