1 /*
2 * Copyright (c) 2021-2023 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 "hks_param.h"
17
18 #include <stddef.h>
19
20 #include "hks_log.h"
21 #include "hks_mem.h"
22 #include "hks_template.h"
23 #include "hks_type_inner.h"
24
25 #include "securec.h"
26
27 static uint32_t g_validTags[] = {
28 HKS_TAG_ALGORITHM,
29 HKS_TAG_PURPOSE,
30 HKS_TAG_KEY_SIZE,
31 HKS_TAG_DIGEST,
32 HKS_TAG_PADDING,
33 HKS_TAG_BLOCK_MODE,
34 HKS_TAG_KEY_TYPE,
35 HKS_TAG_ASSOCIATED_DATA,
36 HKS_TAG_NONCE,
37 HKS_TAG_IV,
38
39 HKS_TAG_SALT,
40 HKS_TAG_PWD,
41 HKS_TAG_INFO,
42 HKS_TAG_ITERATION,
43
44 HKS_TAG_KEY_GENERATE_TYPE,
45 HKS_TAG_DERIVE_MAIN_KEY,
46 HKS_TAG_DERIVE_FACTOR,
47 HKS_TAG_DERIVE_ALG,
48 HKS_TAG_AGREE_ALG,
49 HKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS,
50 HKS_TAG_AGREE_PRIVATE_KEY_ALIAS,
51 HKS_TAG_AGREE_PUBLIC_KEY,
52 HKS_TAG_KEY_ALIAS,
53 HKS_TAG_DERIVE_KEY_SIZE,
54 HKS_TAG_IMPORT_KEY_TYPE,
55 HKS_TAG_UNWRAP_ALGORITHM_SUITE,
56 HKS_TAG_DERIVE_AGREE_KEY_STORAGE_FLAG,
57 HKS_TAG_RSA_PSS_SALT_LEN_TYPE,
58 HKS_TAG_MGF_DIGEST,
59
60 HKS_TAG_ACTIVE_DATETIME,
61 HKS_TAG_ORIGINATION_EXPIRE_DATETIME,
62 HKS_TAG_USAGE_EXPIRE_DATETIME,
63 HKS_TAG_CREATION_DATETIME,
64
65 HKS_TAG_ALL_USERS,
66 HKS_TAG_USER_ID,
67 HKS_TAG_FRONT_USER_ID,
68 HKS_TAG_NO_AUTH_REQUIRED,
69 HKS_TAG_USER_AUTH_TYPE,
70 HKS_TAG_AUTH_TIMEOUT,
71 HKS_TAG_AUTH_TOKEN,
72 HKS_TAG_AUTH_STORAGE_LEVEL,
73 HKS_TAG_SPECIFIC_USER_ID,
74
75 HKS_TAG_OS_VERSION,
76 HKS_TAG_OS_PATCHLEVEL,
77
78 HKS_TAG_ATTESTATION_CHALLENGE,
79 HKS_TAG_ATTESTATION_APPLICATION_ID,
80 HKS_TAG_ATTESTATION_APPLICATION_ID_TYPE,
81 HKS_TAG_ATTESTATION_ID_BRAND,
82 HKS_TAG_ATTESTATION_ID_DEVICE,
83 HKS_TAG_ATTESTATION_ID_PRODUCT,
84 HKS_TAG_ATTESTATION_ID_SERIAL,
85 HKS_TAG_ATTESTATION_ID_IMEI,
86 HKS_TAG_ATTESTATION_ID_MEID,
87 HKS_TAG_ATTESTATION_ID_MANUFACTURER,
88 HKS_TAG_ATTESTATION_ID_MODEL,
89 HKS_TAG_ATTESTATION_ID_ALIAS,
90 HKS_TAG_ATTESTATION_ID_SOCID,
91 HKS_TAG_ATTESTATION_ID_UDID,
92 HKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO,
93 HKS_TAG_ATTESTATION_ID_VERSION_INFO,
94 HKS_TAG_ATTESTATION_BASE64,
95 HKS_TAG_ATTESTATION_MODE,
96
97 HKS_TAG_IS_KEY_ALIAS,
98 HKS_TAG_KEY_STORAGE_FLAG,
99 HKS_TAG_IS_ALLOWED_WRAP,
100 HKS_TAG_KEY_WRAP_TYPE,
101 HKS_TAG_DATA_WRAP_TYPE,
102 HKS_TAG_KEY_AUTH_ID,
103 HKS_TAG_KEY_ROLE,
104 HKS_TAG_KEY_FLAG,
105 HKS_TAG_KEY_DOMAIN,
106
107 HKS_TAG_KEY_AUTH_ACCESS_TYPE,
108 HKS_TAG_KEY_SECURE_SIGN_TYPE,
109 HKS_TAG_CHALLENGE_TYPE,
110 HKS_TAG_CHALLENGE_POS,
111 HKS_TAG_KEY_AUTH_PURPOSE,
112 HKS_TAG_BATCH_PURPOSE,
113 HKS_TAG_IS_BATCH_OPERATION,
114 HKS_TAG_BATCH_OPERATION_TIMEOUT,
115
116 HKS_TAG_KEY_INIT_CHALLENGE,
117 HKS_TAG_IS_USER_AUTH_ACCESS,
118 HKS_TAG_USER_AUTH_CHALLENGE,
119 HKS_TAG_USER_AUTH_ENROLL_ID_INFO,
120 HKS_TAG_USER_AUTH_SECURE_UID,
121 HKS_TAG_KEY_AUTH_RESULT,
122 HKS_TAG_IF_NEED_APPEND_AUTH_INFO,
123 HKS_TAG_VERIFIED_AUTH_TOKEN,
124 HKS_TAG_IS_APPEND_UPDATE_DATA,
125
126 HKS_TAG_PROCESS_NAME,
127 HKS_TAG_PACKAGE_NAME,
128 HKS_TAG_PAYLOAD_LEN,
129 HKS_TAG_AE_TAG,
130 HKS_TAG_CRYPTO_CTX,
131 HKS_TAG_KEY,
132 HKS_TAG_KEY_VERSION,
133 HKS_TAG_IS_KEY_HANDLE,
134 HKS_TAG_SYMMETRIC_KEY_DATA,
135 HKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA,
136 HKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA,
137 HKS_TAG_KEY_ACCESS_TIME,
138
139 HKS_TAG_ACCESS_TOKEN_ID,
140 HKS_TAG_BUNDLE_NAME,
141 HKS_TAG_IS_DEVICE_PASSWORD_SET,
142 HKS_TAG_ACCOUNT_ID,
143 HKS_TAG_OWNER_ID,
144 HKS_TAG_OWNER_TYPE,
145 };
146
GetTagType(enum HksTag tag)147 HKS_API_EXPORT enum HksTagType GetTagType(enum HksTag tag)
148 {
149 return (enum HksTagType)((uint32_t)tag & (uint32_t)HKS_TAG_TYPE_MASK);
150 }
151
IsValidTag(uint32_t tag)152 static bool IsValidTag(uint32_t tag)
153 {
154 uint32_t tagSize = HKS_ARRAY_SIZE(g_validTags);
155 for (uint32_t i = 0; i < tagSize; ++i) {
156 if (tag == g_validTags[i]) {
157 return true;
158 }
159 }
160 return false;
161 }
162
HksCheckParamSetTag(const struct HksParamSet * paramSet)163 HKS_API_EXPORT int32_t HksCheckParamSetTag(const struct HksParamSet *paramSet)
164 {
165 HKS_IF_NULL_RETURN(paramSet, HKS_ERROR_NULL_POINTER)
166
167 for (uint32_t i = 0; i < paramSet->paramsCnt; ++i) {
168 uint32_t curTag = paramSet->params[i].tag;
169 if (!IsValidTag(curTag)) {
170 HKS_LOG_E("paramSet contains invalid tag! 0x%" LOG_PUBLIC "x", curTag);
171 return HKS_ERROR_INVALID_ARGUMENT;
172 }
173
174 for (uint32_t j = i + 1; j < paramSet->paramsCnt; ++j) {
175 if (curTag == paramSet->params[j].tag) {
176 HKS_LOG_E("paramSet contains multi-tags! 0x%" LOG_PUBLIC "x", curTag);
177 return HKS_ERROR_INVALID_ARGUMENT;
178 }
179 }
180 }
181
182 return HKS_SUCCESS;
183 }
184
CheckBeforeAddParams(const struct HksParamSet * paramSet,const struct HksParam * params,uint32_t paramCnt)185 static int32_t CheckBeforeAddParams(const struct HksParamSet *paramSet, const struct HksParam *params,
186 uint32_t paramCnt)
187 {
188 if ((params == NULL) || (paramSet == NULL) || (paramSet->paramSetSize > HKS_PARAM_SET_MAX_SIZE) ||
189 (paramCnt > HKS_DEFAULT_PARAM_CNT) || (paramSet->paramsCnt > (HKS_DEFAULT_PARAM_CNT - paramCnt))) {
190 HKS_LOG_E("invalid params or paramset!");
191 return HKS_ERROR_INVALID_ARGUMENT;
192 }
193
194 for (uint32_t i = 0; i < paramCnt; i++) {
195 if ((GetTagType((enum HksTag)(params[i].tag)) == HKS_TAG_TYPE_BYTES) &&
196 (params[i].blob.data == NULL)) {
197 HKS_LOG_E("invalid blob param!");
198 return HKS_ERROR_INVALID_ARGUMENT;
199 }
200 }
201 return HKS_SUCCESS;
202 }
203
BuildParamSet(struct HksParamSet ** paramSet)204 static int32_t BuildParamSet(struct HksParamSet **paramSet)
205 {
206 struct HksParamSet *freshParamSet = *paramSet;
207 uint32_t size = freshParamSet->paramSetSize;
208 uint32_t offset = sizeof(struct HksParamSet) + sizeof(struct HksParam) * freshParamSet->paramsCnt;
209
210 if (size > HKS_DEFAULT_PARAM_SET_SIZE) {
211 freshParamSet = (struct HksParamSet *)HksMalloc(size);
212 HKS_IF_NULL_LOGE_RETURN(freshParamSet, HKS_ERROR_MALLOC_FAIL, "malloc params failed!")
213
214 if (memcpy_s(freshParamSet, size, *paramSet, offset) != EOK) {
215 HKS_FREE(freshParamSet);
216 HKS_LOG_E("copy params failed!");
217 return HKS_ERROR_INSUFFICIENT_MEMORY;
218 }
219 HKS_FREE(*paramSet);
220 *paramSet = freshParamSet;
221 }
222
223 return HksFreshParamSet(freshParamSet, true);
224 }
225
HksCheckParamSet(const struct HksParamSet * paramSet,uint32_t size)226 HKS_API_EXPORT int32_t HksCheckParamSet(const struct HksParamSet *paramSet, uint32_t size)
227 {
228 HKS_IF_NULL_RETURN(paramSet, HKS_ERROR_NULL_POINTER)
229
230 if ((size < sizeof(struct HksParamSet)) || (size > HKS_PARAM_SET_MAX_SIZE) ||
231 (paramSet->paramSetSize != size) ||
232 (paramSet->paramsCnt > ((size - sizeof(struct HksParamSet)) / sizeof(struct HksParam)))) {
233 HKS_LOG_E("invalid param set!");
234 return HKS_ERROR_INVALID_ARGUMENT;
235 }
236 return HKS_SUCCESS;
237 }
238
HksInitParamSet(struct HksParamSet ** paramSet)239 HKS_API_EXPORT int32_t HksInitParamSet(struct HksParamSet **paramSet)
240 {
241 HKS_IF_NULL_LOGE_RETURN(paramSet, HKS_ERROR_NULL_POINTER, "invalid init params!")
242
243 *paramSet = (struct HksParamSet *)HksMalloc(HKS_DEFAULT_PARAM_SET_SIZE);
244 HKS_IF_NULL_LOGE_RETURN(*paramSet, HKS_ERROR_MALLOC_FAIL, "malloc init param set failed!")
245
246 (*paramSet)->paramsCnt = 0;
247 (*paramSet)->paramSetSize = sizeof(struct HksParamSet);
248 return HKS_SUCCESS;
249 }
250
HksAddParams(struct HksParamSet * paramSet,const struct HksParam * params,uint32_t paramCnt)251 HKS_API_EXPORT int32_t HksAddParams(struct HksParamSet *paramSet,
252 const struct HksParam *params, uint32_t paramCnt)
253 {
254 int32_t ret = CheckBeforeAddParams(paramSet, params, paramCnt);
255 HKS_IF_NOT_SUCC_RETURN(ret, ret)
256
257 for (uint32_t i = 0; i < paramCnt; i++) {
258 paramSet->paramSetSize += sizeof(struct HksParam);
259 if (GetTagType((enum HksTag)(params[i].tag)) == HKS_TAG_TYPE_BYTES) {
260 if (IsAdditionOverflow(paramSet->paramSetSize, params[i].blob.size)) {
261 HKS_LOG_E("params size overflow!");
262 paramSet->paramSetSize -= sizeof(struct HksParam);
263 return HKS_ERROR_INVALID_ARGUMENT;
264 }
265 paramSet->paramSetSize += params[i].blob.size;
266 }
267 (void)memcpy_s(¶mSet->params[paramSet->paramsCnt++], sizeof(struct HksParam), ¶ms[i],
268 sizeof(struct HksParam));
269 }
270 return HKS_SUCCESS;
271 }
272
HksBuildParamSet(struct HksParamSet ** paramSet)273 HKS_API_EXPORT int32_t HksBuildParamSet(struct HksParamSet **paramSet)
274 {
275 if ((paramSet == NULL) || (*paramSet == NULL)) {
276 return HKS_ERROR_NULL_POINTER;
277 }
278
279 int ret = HksCheckParamSet(*paramSet, (*paramSet)->paramSetSize);
280 HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "invalid build params!")
281
282 return BuildParamSet(paramSet);
283 }
284
HksFreeParamSet(struct HksParamSet ** paramSet)285 HKS_API_EXPORT void HksFreeParamSet(struct HksParamSet **paramSet)
286 {
287 if (paramSet == NULL) {
288 HKS_LOG_E("invalid free paramset!");
289 return;
290 }
291 HKS_FREE(*paramSet);
292 }
293
HksFreeKeyAliasSet(struct HksKeyAliasSet * aliasSet)294 HKS_API_EXPORT void HksFreeKeyAliasSet(struct HksKeyAliasSet *aliasSet)
295 {
296 if (aliasSet == NULL) {
297 return;
298 }
299
300 if (aliasSet->aliasesCnt > 0 && aliasSet->aliases != NULL) {
301 for (uint32_t i = 0; i < aliasSet->aliasesCnt; i++) {
302 HKS_FREE_BLOB(aliasSet->aliases[i]);
303 }
304 }
305 aliasSet->aliasesCnt = 0;
306
307 HKS_FREE(aliasSet->aliases);
308 HKS_FREE(aliasSet);
309 aliasSet = NULL;
310 }
311
FreshParamSet(struct HksParamSet * paramSet,bool isCopy)312 static int32_t FreshParamSet(struct HksParamSet *paramSet, bool isCopy)
313 {
314 uint32_t size = paramSet->paramSetSize;
315 uint32_t offset = sizeof(struct HksParamSet) + sizeof(struct HksParam) * paramSet->paramsCnt;
316
317 for (uint32_t i = 0; i < paramSet->paramsCnt; i++) {
318 if (offset > size) {
319 HKS_LOG_E("invalid param set offset!");
320 return HKS_ERROR_INVALID_ARGUMENT;
321 }
322 if (GetTagType((enum HksTag)(paramSet->params[i].tag)) == HKS_TAG_TYPE_BYTES) {
323 if (IsAdditionOverflow(offset, paramSet->params[i].blob.size)) {
324 HKS_LOG_E("blob size overflow!");
325 return HKS_ERROR_INVALID_ARGUMENT;
326 }
327 if (isCopy && (memcpy_s((uint8_t *)paramSet + offset, size - offset,
328 paramSet->params[i].blob.data, paramSet->params[i].blob.size) != EOK)) {
329 HKS_LOG_E("copy param blob failed!");
330 return HKS_ERROR_INSUFFICIENT_MEMORY;
331 }
332 paramSet->params[i].blob.data = (uint8_t *)paramSet + offset;
333 offset += paramSet->params[i].blob.size;
334 }
335 }
336
337 if (paramSet->paramSetSize != offset) {
338 HKS_LOG_E("invalid param set size!");
339 return HKS_ERROR_INVALID_ARGUMENT;
340 }
341 return HKS_SUCCESS;
342 }
343
344
HksFreshParamSet(struct HksParamSet * paramSet,bool isCopy)345 HKS_API_EXPORT int32_t HksFreshParamSet(struct HksParamSet *paramSet, bool isCopy)
346 {
347 HKS_IF_NULL_LOGE_RETURN(paramSet, HKS_ERROR_NULL_POINTER, "invalid NULL paramSet")
348
349 int32_t ret = HksCheckParamSet(paramSet, paramSet->paramSetSize);
350 HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "invalid fresh paramSet")
351
352 return FreshParamSet(paramSet, isCopy);
353 }
354
HksGetParam(const struct HksParamSet * paramSet,uint32_t tag,struct HksParam ** param)355 HKS_API_EXPORT int32_t HksGetParam(const struct HksParamSet *paramSet, uint32_t tag, struct HksParam **param)
356 {
357 if ((paramSet == NULL) || (param == NULL)) {
358 HKS_LOG_E("invalid params!");
359 return HKS_ERROR_INVALID_ARGUMENT;
360 }
361
362 HKS_IF_NOT_SUCC_LOGE_RETURN(HksCheckParamSet(paramSet, paramSet->paramSetSize),
363 HKS_ERROR_INVALID_ARGUMENT, "invalid paramSet!")
364
365 for (uint32_t i = 0; i < paramSet->paramsCnt; i++) {
366 if (tag == paramSet->params[i].tag) {
367 *param = (struct HksParam *)¶mSet->params[i];
368 return HKS_SUCCESS;
369 }
370 }
371
372 return HKS_ERROR_PARAM_NOT_EXIST;
373 }
374
HksGetParamSet(const struct HksParamSet * inParamSet,uint32_t inParamSetSize,struct HksParamSet ** outParamSet)375 HKS_API_EXPORT int32_t HksGetParamSet(const struct HksParamSet *inParamSet,
376 uint32_t inParamSetSize, struct HksParamSet **outParamSet)
377 {
378 int32_t ret = HksCheckParamSet(inParamSet, inParamSetSize);
379 HKS_IF_NOT_SUCC_RETURN(ret, ret)
380
381 HKS_IF_NULL_RETURN(outParamSet, HKS_ERROR_NULL_POINTER)
382
383 uint32_t size = inParamSet->paramSetSize;
384 struct HksParamSet *buf = (struct HksParamSet *)HksMalloc(size);
385 HKS_IF_NULL_LOGE_RETURN(buf, HKS_ERROR_MALLOC_FAIL, "malloc from param set failed!")
386
387 (void)memcpy_s(buf, size, inParamSet, size);
388
389 ret = FreshParamSet(buf, false);
390 if (ret != HKS_SUCCESS) {
391 HKS_FREE(buf);
392 return ret;
393 }
394 *outParamSet = buf;
395 return HKS_SUCCESS;
396 }
397
HksCheckParamMatch(const struct HksParam * baseParam,const struct HksParam * param)398 HKS_API_EXPORT int32_t HksCheckParamMatch(const struct HksParam *baseParam, const struct HksParam *param)
399 {
400 if (baseParam == NULL || param == NULL) {
401 return HKS_ERROR_NULL_POINTER;
402 }
403
404 if (baseParam->tag != param->tag) {
405 HKS_LOG_E("unmatch param type!");
406 return HKS_ERROR_INVALID_ARGUMENT;
407 }
408
409 switch (GetTagType((enum HksTag)(baseParam->tag))) {
410 case HKS_TAG_TYPE_INT:
411 return (baseParam->int32Param == param->int32Param) ? HKS_SUCCESS : HKS_ERROR_INVALID_ARGUMENT;
412 case HKS_TAG_TYPE_UINT:
413 return (baseParam->uint32Param == param->uint32Param) ? HKS_SUCCESS : HKS_ERROR_INVALID_ARGUMENT;
414 case HKS_TAG_TYPE_ULONG:
415 return (baseParam->uint64Param == param->uint64Param) ? HKS_SUCCESS : HKS_ERROR_INVALID_ARGUMENT;
416 case HKS_TAG_TYPE_BOOL:
417 return (baseParam->boolParam == param->boolParam) ? HKS_SUCCESS : HKS_ERROR_INVALID_ARGUMENT;
418 case HKS_TAG_TYPE_BYTES:
419 if (baseParam->blob.size != param->blob.size ||
420 baseParam->blob.data == NULL ||(param->blob.data == NULL)) {
421 HKS_LOG_E("unmatch byte type len!");
422 return HKS_ERROR_INVALID_ARGUMENT;
423 }
424 if (HksMemCmp(baseParam->blob.data, param->blob.data, baseParam->blob.size)) {
425 HKS_LOG_E("unmatch byte type content!");
426 return HKS_ERROR_INVALID_ARGUMENT;
427 }
428 return HKS_SUCCESS;
429 default:
430 HKS_LOG_E("invalid tag type:%" LOG_PUBLIC "x", GetTagType((enum HksTag)(baseParam->tag)));
431 return HKS_ERROR_INVALID_ARGUMENT;
432 }
433 }
434
HksCheckIsTagAlreadyExist(const struct HksParam * params,uint32_t paramsCnt,const struct HksParamSet * targetParamSet)435 HKS_API_EXPORT int32_t HksCheckIsTagAlreadyExist(const struct HksParam *params, uint32_t paramsCnt,
436 const struct HksParamSet *targetParamSet)
437 {
438 if (params == NULL || targetParamSet == NULL) {
439 return HKS_ERROR_NULL_POINTER;
440 }
441
442 int32_t ret = HksCheckParamSet(targetParamSet, targetParamSet->paramSetSize);
443 HKS_IF_NOT_SUCC_RETURN(ret, ret)
444
445 for (uint32_t i = 0; i < targetParamSet->paramsCnt; ++i) {
446 for (uint32_t j = 0; j < paramsCnt; ++j) {
447 if (params[j].tag == targetParamSet->params[i].tag) {
448 return HKS_ERROR_INVALID_ARGUMENT;
449 }
450 }
451 }
452
453 return HKS_SUCCESS;
454 }
455
HksDeleteTagsFromParamSet(const uint32_t * tag,uint32_t tagCount,const struct HksParamSet * paramSet,struct HksParamSet ** outParamSet)456 HKS_API_EXPORT int32_t HksDeleteTagsFromParamSet(const uint32_t *tag, uint32_t tagCount,
457 const struct HksParamSet *paramSet, struct HksParamSet **outParamSet)
458 {
459 if (tag == NULL || paramSet == NULL || outParamSet == NULL) {
460 return HKS_ERROR_NULL_POINTER;
461 }
462 int32_t ret = HksFreshParamSet((struct HksParamSet *)paramSet, false);
463 HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "fresh paramset failed")
464
465 struct HksParamSet *newParamSet = NULL;
466 ret = HksInitParamSet(&newParamSet);
467 HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "init param set failed")
468
469 for (uint32_t i = 0; i < paramSet->paramsCnt; ++i) {
470 bool isDeleteTag = false;
471 for (uint32_t j = 0; j < tagCount; ++j) {
472 if (paramSet->params[i].tag == tag[j]) {
473 isDeleteTag = true;
474 break;
475 }
476 }
477 if (!isDeleteTag) {
478 ret = HksAddParams(newParamSet, ¶mSet->params[i], 1);
479 if (ret != HKS_SUCCESS) {
480 HKS_LOG_E("add in params failed");
481 HksFreeParamSet(&newParamSet);
482 return ret;
483 }
484 }
485 }
486
487 ret = HksBuildParamSet(&newParamSet);
488 if (ret != HKS_SUCCESS) {
489 HKS_LOG_E("build paramset failed");
490 HksFreeParamSet(&newParamSet);
491 return ret;
492 }
493
494 *outParamSet = newParamSet;
495 return HKS_SUCCESS;
496 }
497