| 1 |
#ifndef AWS_C_CAL_OPENSSLCRYPTO_COMMON_H |
| 2 |
#define AWS_C_CAL_OPENSSLCRYPTO_COMMON_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/cal/cal.h> |
| 10 |
|
| 11 |
#define OPENSSL_SUPPRESS_DEPRECATED |
| 12 |
#include <openssl/crypto.h> |
| 13 |
#include <openssl/evp.h> |
| 14 |
#include <openssl/hmac.h> |
| 15 |
|
| 16 |
#if !defined(OPENSSL_IS_AWSLC) && !defined(OPENSSL_IS_BORINGSSL) |
| 17 |
# define OPENSSL_IS_OPENSSL |
| 18 |
#endif |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
typedef HMAC_CTX *(*hmac_ctx_new)(void); |
| 33 |
typedef void (*hmac_ctx_free)(HMAC_CTX *); |
| 34 |
typedef void (*hmac_ctx_init)(HMAC_CTX *); |
| 35 |
typedef void (*hmac_ctx_clean_up)(HMAC_CTX *); |
| 36 |
typedef int (*hmac_init_ex)(HMAC_CTX *, const void *, size_t, const EVP_MD *, ENGINE *); |
| 37 |
typedef int (*hmac_update)(HMAC_CTX *, const unsigned char *, size_t); |
| 38 |
typedef int (*hmac_final)(HMAC_CTX *, unsigned char *, unsigned int *); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
typedef void (*crypto_generic_fn_ptr)(void); |
| 44 |
|
| 45 |
struct openssl_hmac_ctx_table { |
| 46 |
hmac_ctx_new new_fn; |
| 47 |
hmac_ctx_free free_fn; |
| 48 |
hmac_ctx_init init_fn; |
| 49 |
hmac_ctx_clean_up clean_up_fn; |
| 50 |
hmac_init_ex init_ex_fn; |
| 51 |
hmac_update update_fn; |
| 52 |
hmac_final final_fn; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
struct { |
| 60 |
crypto_generic_fn_ptr init_ex_fn; |
| 61 |
} impl; |
| 62 |
}; |
| 63 |
|
| 64 |
extern struct openssl_hmac_ctx_table *g_aws_openssl_hmac_ctx_table; |
| 65 |
|
| 66 |
typedef EVP_MD_CTX *(*evp_md_ctx_new)(void); |
| 67 |
typedef void (*evp_md_ctx_free)(EVP_MD_CTX *); |
| 68 |
typedef int (*evp_md_ctx_digest_init_ex)(EVP_MD_CTX *, const EVP_MD *, ENGINE *); |
| 69 |
typedef int (*evp_md_ctx_digest_update)(EVP_MD_CTX *, const void *, size_t); |
| 70 |
typedef int (*evp_md_ctx_digest_final_ex)(EVP_MD_CTX *, unsigned char *, unsigned int *); |
| 71 |
|
| 72 |
struct openssl_evp_md_ctx_table { |
| 73 |
evp_md_ctx_new new_fn; |
| 74 |
evp_md_ctx_free free_fn; |
| 75 |
evp_md_ctx_digest_init_ex init_ex_fn; |
| 76 |
evp_md_ctx_digest_update update_fn; |
| 77 |
evp_md_ctx_digest_final_ex final_ex_fn; |
| 78 |
}; |
| 79 |
|
| 80 |
extern struct openssl_evp_md_ctx_table *g_aws_openssl_evp_md_ctx_table; |
| 81 |
|
| 82 |
int aws_reinterpret_lc_evp_error_as_crt(int evp_error, const char *function_name, enum aws_cal_log_subject subject); |
| 83 |
|
| 84 |
void aws_validate_libcrypto_linkage(void); |
| 85 |
|
| 86 |
#endif |