diff --git a/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers.c b/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers.c index 13bc096ccea4fa53ef5cfb01463805c98471628a..b4eec9e62724e1e0c7cb13a8b7665f008e3dad68 100644 --- a/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers.c +++ b/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers.c @@ -492,7 +492,7 @@ static int sec_ciphers_async_do_crypto(cipher_engine_ctx_t *e_cipher_ctx, op_don int ret = 0; int cnt = 0; cipher_priv_ctx_t *priv_ctx = e_cipher_ctx->priv_ctx; - enum task_type type = ASYNC_TASK_CIPHER; + enum task_type_wd type = ASYNC_TASK_WD_CIPHER; void *tag = e_cipher_ctx; priv_ctx->do_cipher_len = wd_ciphers_get_do_cipher_len(priv_ctx->offset, priv_ctx->left_len); @@ -891,8 +891,8 @@ int cipher_module_init(void) sec_create_ciphers(); // reg async interface here - async_register_poll_fn_v1(ASYNC_TASK_CIPHER, sec_cipher_engine_ctx_poll); - async_register_poll_fn_v1(ASYNC_TASK_AEAD, sec_aead_engine_ctx_poll); + async_register_poll_fn_v1(ASYNC_TASK_WD_CIPHER, sec_cipher_engine_ctx_poll); + async_register_poll_fn_v1(ASYNC_TASK_WD_AEAD, sec_aead_engine_ctx_poll); return 1; } diff --git a/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers_aead.c b/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers_aead.c index 2f9932e5795da92c1fe36da3ec708047eca42c6f..3fe52dbdebc910002dbe6a88d9d5b42365102aca 100644 --- a/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers_aead.c +++ b/KAEOpensslEngine/src/v1/alg/ciphers/sec_ciphers_aead.c @@ -356,7 +356,7 @@ int wd_aead_do_crypto_impl_async(struct aead_priv_ctx *priv, op_done_t *op_done) { int ret = -WD_EINVAL; int cnt = 0; - enum task_type type = ASYNC_TASK_AEAD; + enum task_type_wd type = ASYNC_TASK_WD_AEAD; if (unlikely(priv == NULL) || unlikely(priv->e_aead_ctx == NULL)) { US_ERR("do cipher priv or e_aead_ctx NULL!"); diff --git a/KAEOpensslEngine/src/v1/alg/dh/hpre_dh.c b/KAEOpensslEngine/src/v1/alg/dh/hpre_dh.c index f4e5d190f51b44a3ff8f38cf87c45f057b1d1c53..69f44906e10ccf8c30d90032a8be112192b202df 100644 --- a/KAEOpensslEngine/src/v1/alg/dh/hpre_dh.c +++ b/KAEOpensslEngine/src/v1/alg/dh/hpre_dh.c @@ -106,7 +106,7 @@ int hpre_module_dh_init(void) #endif /* register async poll func */ - async_register_poll_fn_v1(ASYNC_TASK_DH, hpre_dh_ctx_poll); + async_register_poll_fn_v1(ASYNC_TASK_WD_DH, hpre_dh_ctx_poll); return HPRE_DH_SUCCESS; } diff --git a/KAEOpensslEngine/src/v1/alg/dh/hpre_dh_wd.c b/KAEOpensslEngine/src/v1/alg/dh/hpre_dh_wd.c index 947e484a39d7d22f542244faa1e2270cc154bbd4..d1c9b49183a1d1ae0dbe68c168bf800b0ef13b43 100644 --- a/KAEOpensslEngine/src/v1/alg/dh/hpre_dh_wd.c +++ b/KAEOpensslEngine/src/v1/alg/dh/hpre_dh_wd.c @@ -401,7 +401,7 @@ static int hpre_dh_async(hpre_dh_engine_ctx_t *eng_ctx, { int ret = 0; int cnt = 0; - enum task_type type = ASYNC_TASK_DH; + enum task_type_wd type = ASYNC_TASK_WD_DH; void *tag = eng_ctx; do { diff --git a/KAEOpensslEngine/src/v1/alg/digests/sec_digests.c b/KAEOpensslEngine/src/v1/alg/digests/sec_digests.c index 4d5be4b21497338c04f95f0089d458ec84c957ff..1a27121caad2c7e7eae2d79a57f32944233d30a0 100644 --- a/KAEOpensslEngine/src/v1/alg/digests/sec_digests.c +++ b/KAEOpensslEngine/src/v1/alg/digests/sec_digests.c @@ -386,7 +386,7 @@ static int sec_digests_async_dowork(sec_digest_priv_t *md_ctx, op_done_t *op_don { int ret = 0; int cnt = 0; - enum task_type type = ASYNC_TASK_DIGEST; + enum task_type_wd type = ASYNC_TASK_WD_DIGEST; SEC_DIGESTS_RETURN_FAIL_IF(md_ctx == NULL, "md_ctx is NULL.", KAE_FAIL); digest_engine_ctx_t *e_digest_ctx = md_ctx->e_digest_ctx; @@ -632,7 +632,7 @@ int digest_module_init(void) wd_digests_init_qnode_pool(); sec_create_digests(); // reg async interface here - async_register_poll_fn_v1(ASYNC_TASK_DIGEST, sec_digest_engine_ctx_poll); + async_register_poll_fn_v1(ASYNC_TASK_WD_DIGEST, sec_digest_engine_ctx_poll); return 1; } diff --git a/KAEOpensslEngine/src/v1/alg/pkey/hpre_rsa.c b/KAEOpensslEngine/src/v1/alg/pkey/hpre_rsa.c index bc69e7750d720607c8f01f127e0099fc582764b3..5ba4ba5c12f72c4ab574bfe283a12ffd92cf2d26 100644 --- a/KAEOpensslEngine/src/v1/alg/pkey/hpre_rsa.c +++ b/KAEOpensslEngine/src/v1/alg/pkey/hpre_rsa.c @@ -166,7 +166,7 @@ int hpre_module_init(void) #endif /* register async poll func */ - async_register_poll_fn_v1(ASYNC_TASK_RSA, hpre_engine_ctx_poll); + async_register_poll_fn_v1(ASYNC_TASK_WD_RSA, hpre_engine_ctx_poll); return 1; } @@ -312,7 +312,7 @@ static int hpre_evp_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t s #define PKEY_METHOD_TYPE_NUM 4 -#ifdef EVP_PKEY_SM2 +#ifndef KAE_GMSSL const int g_pkey_method_types[PKEY_METHOD_TYPE_NUM] = {EVP_PKEY_RSA, EVP_PKEY_DH, EVP_PKEY_DHX, EVP_PKEY_SM2}; #else const int g_pkey_method_types[PKEY_METHOD_TYPE_NUM] = {EVP_PKEY_RSA, EVP_PKEY_DH, EVP_PKEY_DHX}; @@ -355,7 +355,7 @@ int hpre_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth, case EVP_PKEY_DHX: *pmeth = (EVP_PKEY_METHOD *)EVP_PKEY_meth_find(EVP_PKEY_DHX); break; -#ifdef EVP_PKEY_SM2 +#ifndef KAE_GMSSL case EVP_PKEY_SM2: *pmeth = get_sm2_pkey_meth(); break; diff --git a/KAEOpensslEngine/src/v1/alg/pkey/hpre_sm2.c b/KAEOpensslEngine/src/v1/alg/pkey/hpre_sm2.c index ecf12747a8c1b4b51c52a5cb4b3b304fdddfe87c..9b7566f078e202fcdb92d27d7276b7949bdcb7cc 100644 --- a/KAEOpensslEngine/src/v1/alg/pkey/hpre_sm2.c +++ b/KAEOpensslEngine/src/v1/alg/pkey/hpre_sm2.c @@ -1021,7 +1021,7 @@ static int hpre_async_do_sm2(struct hpre_sm2_engine_ctx *eng_ctx, { int ret = 0; int cnt = 0; - enum task_type type = ASYNC_TASK_ECC; + enum task_type_wd type = ASYNC_TASK_WD_ECC; void *tag = eng_ctx; do { @@ -2037,7 +2037,7 @@ int hpre_module_sm2_init(void) { (void)get_sm2_pkey_meth(); /* register async poll func */ - async_register_poll_fn_v1(ASYNC_TASK_ECC, sm2_engine_ctx_poll);//ASYNC_TASK_ECC 按SVA代码包含sm2 + async_register_poll_fn_v1(ASYNC_TASK_WD_ECC, sm2_engine_ctx_poll);//ASYNC_TASK_WD_ECC 按SVA代码包含sm2 return OPENSSL_SUCCESS; } \ No newline at end of file diff --git a/KAEOpensslEngine/src/v1/alg/pkey/hpre_wd.c b/KAEOpensslEngine/src/v1/alg/pkey/hpre_wd.c index f7ba08944006da83fa7f99642cea4ff1b6ae5799..778e157d8b551348c4318241302ce4be8077f451 100644 --- a/KAEOpensslEngine/src/v1/alg/pkey/hpre_wd.c +++ b/KAEOpensslEngine/src/v1/alg/pkey/hpre_wd.c @@ -377,7 +377,7 @@ int hpre_rsa_async(hpre_engine_ctx_t *eng_ctx, { int ret = 0; int cnt = 0; - enum task_type type = ASYNC_TASK_RSA; + enum task_type_wd type = ASYNC_TASK_WD_RSA; void *tag = eng_ctx; do { diff --git a/KAEOpensslEngine/src/v1/async/async_task_queue.c b/KAEOpensslEngine/src/v1/async/async_task_queue.c index c97f0afdc896efb6f4f1f6902d93e32cb14f6a89..b2a9d4d511e280727eba27323e5af53080fe9a91 100644 --- a/KAEOpensslEngine/src/v1/async/async_task_queue.c +++ b/KAEOpensslEngine/src/v1/async/async_task_queue.c @@ -42,12 +42,14 @@ async_poll_queue_t g_async_poll_queue = { .init_mark = 0, }; -async_recv_t g_async_recv_func[MAX_ALG_SIZE]; +async_recv_t g_async_recv_func[ASYNC_TASK_WD_MAX]; int async_register_poll_fn_v1(int type, async_recv_t func) { - if (type < 0 || type >= MAX_ALG_SIZE) + if (type < 0 || type >= ASYNC_TASK_WD_MAX) { + US_ERR("alg register async func fail! alg type=%d", type); return -1; + } g_async_recv_func[type] = func; return 0; @@ -116,7 +118,7 @@ async_poll_task *async_get_queue_task_v1(void) return cur_task; } -static int async_add_queue_task(void *eng_ctx, op_done_t *op_done, enum task_type type) +static int async_add_queue_task(void *eng_ctx, op_done_t *op_done, enum task_type_wd type) { async_poll_task *task_queue; async_poll_task *task; @@ -161,7 +163,7 @@ static void async_poll_queue_free(void) g_async_poll_queue.async_poll_task_queue_head = NULL; } -int async_add_poll_task_v1(void *eng_ctx, op_done_t *op_done, enum task_type type) +int async_add_poll_task_v1(void *eng_ctx, op_done_t *op_done, enum task_type_wd type) { US_DEBUG("start to add task to poll queue"); return async_add_queue_task(eng_ctx, op_done, type); diff --git a/KAEOpensslEngine/src/v1/async/async_task_queue.h b/KAEOpensslEngine/src/v1/async/async_task_queue.h index 6be711d106f013ff00b77d8f3e0d5d55002c50df..31bbf351bf52b89bc43f260ea6d3d69b01a7cdec 100644 --- a/KAEOpensslEngine/src/v1/async/async_task_queue.h +++ b/KAEOpensslEngine/src/v1/async/async_task_queue.h @@ -21,16 +21,23 @@ #include #include "async_callback.h" #include -#include "../../v2/async/uadk_async.h" #include -#define MAX_ALG_SIZE 6 +enum task_type_wd { + ASYNC_TASK_WD_CIPHER = 0x1, + ASYNC_TASK_WD_DIGEST, + ASYNC_TASK_WD_AEAD, + ASYNC_TASK_WD_RSA, + ASYNC_TASK_WD_DH, + ASYNC_TASK_WD_ECC, + ASYNC_TASK_WD_MAX +}; typedef int (*async_recv_t)(void *engine_ctx); struct async_wd_polling_arg { - enum task_type type; + enum task_type_wd type; void *eng_ctx; op_done_t *op_done; }; @@ -52,13 +59,13 @@ typedef struct async_poll_queue_t { } async_poll_queue_t; extern async_poll_queue_t g_async_poll_queue; -extern async_recv_t g_async_recv_func[MAX_ALG_SIZE]; +extern async_recv_t g_async_recv_func[ASYNC_TASK_WD_MAX]; int async_register_poll_fn_v1(int type, async_recv_t async_recv); int async_poll_task_init_v1(void); async_poll_task *async_get_queue_task_v1(void); -int async_add_poll_task_v1(void *ctx, op_done_t *op_done, enum task_type type); +int async_add_poll_task_v1(void *ctx, op_done_t *op_done, enum task_type_wd type); void async_poll_task_free_v1(void); #endif