mirror of
https://gitee.com/openharmony/security_huks
synced 2025-03-05 00:47:28 +00:00
!122 上传hks_ca_access.c文件
Merge pull request !122 from zhao_zhen_zhou/myfeature
This commit is contained in:
commit
1c336e44a9
121
services/huks_standard/huks_service/main/os_dependency/ca/hks_ca_access.c
Executable file
121
services/huks_standard/huks_service/main/os_dependency/ca/hks_ca_access.c
Executable file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HKS_CONFIG_FILE
|
||||
#include HKS_CONFIG_FILE
|
||||
#else
|
||||
#include "hks_config.h"
|
||||
#endif
|
||||
|
||||
#include "hks_access.h"
|
||||
#include "hks_teec.h"
|
||||
|
||||
int32_t HksAccessInitialize(void)
|
||||
{
|
||||
return HKS_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t HksAccessRefresh(void)
|
||||
{
|
||||
return HKS_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t HksAccessGenerateKey(const struct HksBlob *keyBlob, const struct HksParamSet *paramSetIn,
|
||||
const struct HksBlob *keyIn, struct HksBlob *keyOut)
|
||||
{
|
||||
(void)keyIn;
|
||||
return HksTeeGenerateKey(keyBlob, paramSetIn, keyOut);
|
||||
}
|
||||
|
||||
int32_t HksAccessSign(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
const struct HksBlob *srcData, struct HksBlob *signature)
|
||||
{
|
||||
return HksTeeSign(key, paramSet, srcData, signature);
|
||||
}
|
||||
|
||||
int32_t HksAccessVerify(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
const struct HksBlob *srcData, const struct HksBlob *signature)
|
||||
{
|
||||
return HksTeeVerify(key, paramSet, srcData, signature);
|
||||
}
|
||||
|
||||
int32_t HksAccessEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
const struct HksBlob *plainText, struct HksBlob *cipherText)
|
||||
{
|
||||
return HksTeeEncrypt(key, paramSet, plainText, cipherText);
|
||||
}
|
||||
|
||||
int32_t HksAccessDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
const struct HksBlob *cipherText, struct HksBlob *plainText)
|
||||
{
|
||||
return HksTeeDecrypt(key, paramSet, cipherText, plainText);
|
||||
}
|
||||
|
||||
int32_t HksAccessGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random)
|
||||
{
|
||||
return HksTeeGenerateRandom(paramSet, random);
|
||||
}
|
||||
|
||||
int32_t HksAccessImportKey(const struct HksBlob *keyAlias, const struct HksBlob *key,
|
||||
const struct HksParamSet *paramSet, struct HksBlob *keyOut)
|
||||
{
|
||||
(void)keyAlias;
|
||||
return HksTeeImportKey(key, paramSet, keyOut);
|
||||
}
|
||||
|
||||
int32_t HksAccessExportPublicKey(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *keyOut)
|
||||
{
|
||||
return HksTeeExportPublicKey(key, paramSet, keyOut);
|
||||
}
|
||||
|
||||
int32_t HksAccessAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
|
||||
const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey)
|
||||
{
|
||||
return HksTeeAgreeKey(paramSet, privateKey, peerPublicKey, agreedKey);
|
||||
}
|
||||
|
||||
int32_t HksAccessDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *kdfKey,
|
||||
struct HksBlob *derivedKey)
|
||||
{
|
||||
return HksTeeDeriveKey(paramSet, kdfKey, derivedKey);
|
||||
}
|
||||
|
||||
int32_t HksAccessMac(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
const struct HksBlob *srcData, struct HksBlob *mac)
|
||||
{
|
||||
return HksTeeMac(key, paramSet, srcData, mac);
|
||||
}
|
||||
|
||||
int32_t HksAccessCheckKeyValidity(const struct HksParamSet *paramSet, const struct HksBlob *key)
|
||||
{
|
||||
return HksTeeCheckKeyLegality(paramSet, key);
|
||||
}
|
||||
|
||||
int32_t HksAccessExportTrustCerts(struct HksBlob *certChain)
|
||||
{
|
||||
return HksTeeExportTrustCerts(certChain);
|
||||
}
|
||||
|
||||
int32_t HksAccessImportTrustCerts(const struct HksBlob *certChain)
|
||||
{
|
||||
return HksTeeImportTrustCerts(certChain);
|
||||
}
|
||||
|
||||
int32_t HcmAccessIsDeviceKeyExist(const struct HksParamSet *paramSet)
|
||||
{
|
||||
(void)paramSet;
|
||||
return HcmTeeIsDeviceKeyExist();
|
||||
}
|
@ -691,44 +691,6 @@ int32_t HksTeeImportTrustCerts(const struct HksBlob *certChain)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HKS_SUPPORT_API_EXPORT_DEVICE_PRI_KEY_MOD
|
||||
int32_t HksTeeExportDevPriKey(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *devPriKey)
|
||||
{
|
||||
uint32_t paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT,
|
||||
TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
|
||||
struct HksParam params[MAX_TEE_PARAMS_NUMS];
|
||||
|
||||
InitializeBlob(¶ms[0].blob, key->size, key->data);
|
||||
InitializeBlob(¶ms[1].blob, paramSet->paramSetSize, (uint8_t *)paramSet);
|
||||
InitializeBlob(¶ms[2].blob, devPriKey->size, devPriKey->data); /* 2 is array index */
|
||||
|
||||
TEEC_Operation operation;
|
||||
int32_t ret = HksTeeCommand(paramTypes, params, HKS_CMD_ID_EXPORT_DEV_PRIVATE_KEY, &operation);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HKS_LOG_E("Invoke HKS_CMD_ID_EXPORT_DEV_PRIVATE_KEY failed");
|
||||
return ret;
|
||||
}
|
||||
devPriKey->size = operation.params[2].tmpref.size; /* 2 is array index */
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HKS_SUPPORT_API_DELETE_DEVICE_CERTS_MOD
|
||||
int32_t HksTeeDeleteTrustCerts(void)
|
||||
{
|
||||
uint32_t paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
|
||||
struct HksParam params[MAX_TEE_PARAMS_NUMS] = {0};
|
||||
|
||||
TEEC_Operation operation;
|
||||
int32_t ret = HksTeeCommand(paramTypes, params, HKS_CMD_ID_DELETE_TRUST_CERT, &operation);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HKS_LOG_E("Invoke HKS_CMD_ID_DELETE_TRUST_CERT failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t HcmTeeIsDeviceKeyExist(void)
|
||||
{
|
||||
HKS_LOG_D("enter");
|
||||
|
@ -77,11 +77,6 @@ int32_t HksTeeExportTrustCerts(struct HksBlob *certChain);
|
||||
|
||||
int32_t HksTeeImportTrustCerts(const struct HksBlob *certChain);
|
||||
|
||||
int32_t HksTeeExportDevPriKey(const struct HksBlob *key, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *devPriKey);
|
||||
|
||||
int32_t HksTeeDeleteTrustCerts(void);
|
||||
|
||||
int32_t HcmTeeIsDeviceKeyExist(void);
|
||||
|
||||
int32_t HksTeeProvision(const struct HksBlob *keybox, struct HksBlob *challenge,
|
||||
|
Loading…
x
Reference in New Issue
Block a user