18e920a95Sopenharmony_ci/* 28e920a95Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 38e920a95Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48e920a95Sopenharmony_ci * you may not use this file except in compliance with the License. 58e920a95Sopenharmony_ci * You may obtain a copy of the License at 68e920a95Sopenharmony_ci * 78e920a95Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88e920a95Sopenharmony_ci * 98e920a95Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108e920a95Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118e920a95Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128e920a95Sopenharmony_ci * See the License for the specific language governing permissions and 138e920a95Sopenharmony_ci * limitations under the License. 148e920a95Sopenharmony_ci */ 158e920a95Sopenharmony_ci 168e920a95Sopenharmony_ci#include "hks_api.h" 178e920a95Sopenharmony_ci 188e920a95Sopenharmony_ci#include "hks_api_mock_helper.h" 198e920a95Sopenharmony_ci 208e920a95Sopenharmony_cinamespace OHOS { 218e920a95Sopenharmony_cinamespace Security { 228e920a95Sopenharmony_cinamespace CodeSign { 238e920a95Sopenharmony_ciint32_t HksKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet) 248e920a95Sopenharmony_ci{ 258e920a95Sopenharmony_ci LOG_INFO("Mock HksKeyExist"); 268e920a95Sopenharmony_ci return HKS_SUCCESS; 278e920a95Sopenharmony_ci} 288e920a95Sopenharmony_ci 298e920a95Sopenharmony_ciint32_t HksAttestKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 308e920a95Sopenharmony_ci struct HksCertChain *certChain) 318e920a95Sopenharmony_ci{ 328e920a95Sopenharmony_ci LOG_INFO("Mock HksAttestKey"); 338e920a95Sopenharmony_ci 348e920a95Sopenharmony_ci bool ret = GetCertInDer(certChain->certs[0].data, certChain->certs[0].size); 358e920a95Sopenharmony_ci if (!ret) { 368e920a95Sopenharmony_ci LOG_ERROR("Failed to convert PEM to DER.\n"); 378e920a95Sopenharmony_ci return HKS_FAILURE; 388e920a95Sopenharmony_ci } 398e920a95Sopenharmony_ci return HKS_SUCCESS; 408e920a95Sopenharmony_ci} 418e920a95Sopenharmony_ci 428e920a95Sopenharmony_ciint32_t HksGenerateKey(const struct HksBlob *keyAlias, 438e920a95Sopenharmony_ci const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut) 448e920a95Sopenharmony_ci{ 458e920a95Sopenharmony_ci LOG_INFO("Mock HksGenerateKey"); 468e920a95Sopenharmony_ci return HKS_SUCCESS; 478e920a95Sopenharmony_ci} 488e920a95Sopenharmony_ci 498e920a95Sopenharmony_ciint32_t HksInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 508e920a95Sopenharmony_ci struct HksBlob *handle, struct HksBlob *token) 518e920a95Sopenharmony_ci{ 528e920a95Sopenharmony_ci LOG_INFO("Mock HksInit"); 538e920a95Sopenharmony_ci return HKS_SUCCESS; 548e920a95Sopenharmony_ci} 558e920a95Sopenharmony_ci 568e920a95Sopenharmony_ci 578e920a95Sopenharmony_ciint32_t HksUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, 588e920a95Sopenharmony_ci const struct HksBlob *inData, struct HksBlob *outData) 598e920a95Sopenharmony_ci{ 608e920a95Sopenharmony_ci LOG_INFO("Mock HksUpdate"); 618e920a95Sopenharmony_ci return HKS_SUCCESS; 628e920a95Sopenharmony_ci} 638e920a95Sopenharmony_ci 648e920a95Sopenharmony_ciint32_t HksFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, 658e920a95Sopenharmony_ci const struct HksBlob *inData, struct HksBlob *outData) 668e920a95Sopenharmony_ci{ 678e920a95Sopenharmony_ci LOG_INFO("Mock HksFinish"); 688e920a95Sopenharmony_ci return HKS_SUCCESS; 698e920a95Sopenharmony_ci} 708e920a95Sopenharmony_ci} 718e920a95Sopenharmony_ci} 728e920a95Sopenharmony_ci}