1 /*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16 #include "bsl_err_internal.h"
17 #include "crypt_errno.h"
18 #include "crypt_utils.h"
19 #include "crypt_params_key.h"
20
21 #if defined(HITLS_CRYPTO_PROVIDER) && defined(HITLS_CRYPTO_PKEY)
CRYPT_GetPkeyProcessParams(BSL_Param * params,CRYPT_EAL_ProcessFuncCb * processCb,void ** args)22 int32_t CRYPT_GetPkeyProcessParams(BSL_Param *params, CRYPT_EAL_ProcessFuncCb *processCb, void **args)
23 {
24 BSL_Param *processParam = BSL_PARAM_FindParam(params, CRYPT_PARAM_PKEY_PROCESS_FUNC);
25 if (processParam == NULL) {
26 BSL_ERR_PUSH_ERROR(CRYPT_INVALID_ARG);
27 return CRYPT_INVALID_ARG;
28 }
29 int32_t ret = BSL_PARAM_GetPtrValue(processParam, CRYPT_PARAM_PKEY_PROCESS_FUNC,
30 BSL_PARAM_TYPE_FUNC_PTR, (void **)processCb, NULL);
31 if (ret != BSL_SUCCESS) {
32 BSL_ERR_PUSH_ERROR(ret);
33 return ret;
34 }
35 if (*processCb == NULL) {
36 BSL_ERR_PUSH_ERROR(CRYPT_INVALID_ARG);
37 return CRYPT_INVALID_ARG;
38 }
39 BSL_Param *argsParam = BSL_PARAM_FindParam(params, CRYPT_PARAM_PKEY_PROCESS_ARGS);
40 if (argsParam != NULL) {
41 GOTO_ERR_IF(BSL_PARAM_GetPtrValue(argsParam, CRYPT_PARAM_PKEY_PROCESS_ARGS,
42 BSL_PARAM_TYPE_CTX_PTR, args, NULL), ret);
43 }
44 ERR:
45 return ret;
46 }
47 #endif