-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from vapor/c-namespace
add c namespace
- Loading branch information
Showing
4 changed files
with
28 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
#include "include/c_jwtkit_crypto.h" | ||
|
||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) | ||
EVP_MD_CTX *EVP_MD_CTX_new(void) { | ||
EVP_MD_CTX *jwtkit_EVP_MD_CTX_new(void) { | ||
return EVP_MD_CTX_create(); | ||
}; | ||
|
||
void EVP_MD_CTX_free(EVP_MD_CTX *ctx) { | ||
void jwtkit_EVP_MD_CTX_free(EVP_MD_CTX *ctx) { | ||
EVP_MD_CTX_cleanup(ctx); | ||
free(ctx); | ||
}; | ||
|
||
int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { | ||
r->n = n; | ||
r->e = e; | ||
r->d = d; | ||
return 0; | ||
}; | ||
|
||
HMAC_CTX *HMAC_CTX_new(void) { | ||
HMAC_CTX *jwtkit_HMAC_CTX_new(void) { | ||
HMAC_CTX *ptr = malloc(sizeof(HMAC_CTX)); | ||
HMAC_CTX_init(ptr); | ||
return ptr; | ||
}; | ||
|
||
void HMAC_CTX_free(HMAC_CTX *ctx) { | ||
void jwtkit_HMAC_CTX_free(HMAC_CTX *ctx) { | ||
HMAC_CTX_cleanup(ctx); | ||
free(ctx); | ||
}; | ||
#else | ||
EVP_MD_CTX *jwtkit_EVP_MD_CTX_new(void) { | ||
return EVP_MD_CTX_new(); | ||
}; | ||
|
||
void jwtkit_EVP_MD_CTX_free(EVP_MD_CTX *ctx) { | ||
EVP_MD_CTX_free(ctx); | ||
}; | ||
|
||
HMAC_CTX *jwtkit_HMAC_CTX_new(void) { | ||
return HMAC_CTX_new(); | ||
}; | ||
|
||
void jwtkit_HMAC_CTX_free(HMAC_CTX *ctx) { | ||
HMAC_CTX_free(ctx); | ||
}; | ||
#endif |
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
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
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