1/* 2 * Copyright (c) 2024 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_api.h" 17 18#include "hks_api_mock_helper.h" 19 20namespace OHOS { 21namespace Security { 22namespace CodeSign { 23int32_t HksKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet) 24{ 25 LOG_INFO("Mock HksKeyExist"); 26 return HKS_SUCCESS; 27} 28 29int32_t HksAttestKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 30 struct HksCertChain *certChain) 31{ 32 LOG_INFO("Mock HksAttestKey"); 33 34 bool ret = GetCertInDer(certChain->certs[0].data, certChain->certs[0].size); 35 if (!ret) { 36 LOG_ERROR("Failed to convert PEM to DER.\n"); 37 return HKS_FAILURE; 38 } 39 return HKS_SUCCESS; 40} 41 42int32_t HksGenerateKey(const struct HksBlob *keyAlias, 43 const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut) 44{ 45 LOG_INFO("Mock HksGenerateKey"); 46 return HKS_SUCCESS; 47} 48 49int32_t HksInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 50 struct HksBlob *handle, struct HksBlob *token) 51{ 52 LOG_INFO("Mock HksInit"); 53 return HKS_SUCCESS; 54} 55 56 57int32_t HksUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, 58 const struct HksBlob *inData, struct HksBlob *outData) 59{ 60 LOG_INFO("Mock HksUpdate"); 61 return HKS_SUCCESS; 62} 63 64int32_t HksFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, 65 const struct HksBlob *inData, struct HksBlob *outData) 66{ 67 LOG_INFO("Mock HksFinish"); 68 return HKS_SUCCESS; 69} 70} 71} 72}