Created
May 6, 2019 03:00
-
-
Save iaoedsz2008/9c60cb32659a406f58746b52422311cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void hmac_sha512 (const unsigned char* input, int inputlength, unsigned char* output, unsigned int* outputlength) | |
{ | |
const EVP_MD* engine = EVP_sha512 (); | |
#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
HMAC_CTX ctx; | |
HMAC_CTX_init (&ctx); | |
HMAC_Init_ex (&ctx, API_SECRET, strlen (API_SECRET), engine, NULL); | |
HMAC_Update (&ctx, (const unsigned char*)input, inputlength); | |
HMAC_Final (&ctx, output, outputlength); | |
#else | |
HMAC_CTX* ctx = HMAC_CTX_new (); | |
HMAC_Init_ex (ctx, API_SECRET, strlen (API_SECRET), engine, NULL); | |
HMAC_Update (ctx, (const unsigned char*)input, inputlength); | |
HMAC_Final (ctx, output, outputlength); | |
HMAC_CTX_free (ctx); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment