• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "native_huks_param.h"
17 
18 #include "hks_param.h"
19 #include "hks_errcode_adapter.h"
20 
ConvertParamResult(int32_t ret)21 static struct OH_Huks_Result ConvertParamResult(int32_t ret)
22 {
23     struct HksResult result = HksConvertErrCode(ret);
24     return *((struct OH_Huks_Result *)(&result));
25 }
26 
OH_Huks_InitParamSet(struct OH_Huks_ParamSet ** paramSet)27 struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet)
28 {
29     int32_t result = HksInitParamSet((struct HksParamSet **) paramSet);
30     return ConvertParamResult(result);
31 }
32 
OH_Huks_AddParams(struct OH_Huks_ParamSet * paramSet,const struct OH_Huks_Param * params,uint32_t paramCnt)33 struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet,
34     const struct OH_Huks_Param *params, uint32_t paramCnt)
35 {
36     int32_t result = HksAddParams((struct HksParamSet *) paramSet,
37         (const struct HksParam *) params, paramCnt);
38     return ConvertParamResult(result);
39 }
40 
OH_Huks_BuildParamSet(struct OH_Huks_ParamSet ** paramSet)41 struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet)
42 {
43     int32_t result = HksBuildParamSet((struct HksParamSet **) paramSet);
44     return ConvertParamResult(result);
45 }
46 
OH_Huks_FreeParamSet(struct OH_Huks_ParamSet ** paramSet)47 void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet)
48 {
49     HksFreeParamSet((struct HksParamSet **) paramSet);
50 }
51 
OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet * fromParamSet,uint32_t fromParamSetSize,struct OH_Huks_ParamSet ** paramSet)52 struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet,
53     uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet)
54 {
55     int32_t result = HksGetParamSet((const struct HksParamSet *) fromParamSet,
56         fromParamSetSize, (struct HksParamSet **) paramSet);
57     return ConvertParamResult(result);
58 }
59 
OH_Huks_GetParam(const struct OH_Huks_ParamSet * paramSet,uint32_t tag,struct OH_Huks_Param ** param)60 struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag,
61     struct OH_Huks_Param **param)
62 {
63     int32_t result = HksGetParam((const struct HksParamSet *) paramSet, tag, (struct HksParam **) param);
64     return ConvertParamResult(result);
65 }
66 
OH_Huks_FreshParamSet(struct OH_Huks_ParamSet * paramSet,bool isCopy)67 struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy)
68 {
69     int32_t result = HksFreshParamSet((struct HksParamSet *) paramSet, isCopy);
70     return ConvertParamResult(result);
71 }
72 
OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet * paramSet)73 struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet)
74 {
75     int32_t result = HksCheckParamSetTag((const struct HksParamSet *) paramSet);
76     return ConvertParamResult(result);
77 }
78 
OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet * paramSet,uint32_t size)79 struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size)
80 {
81     int32_t result = HksCheckParamSet((const struct HksParamSet *) paramSet, size);
82     return ConvertParamResult(result);
83 }
84 
OH_Huks_CheckParamMatch(const struct OH_Huks_Param * baseParam,const struct OH_Huks_Param * param)85 struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param)
86 {
87     int32_t result = HksCheckParamMatch((const struct HksParam *) baseParam, (const struct HksParam *) param);
88     return ConvertParamResult(result);
89 }
90