mirror of
https://gitee.com/openharmony/security_huks
synced 2024-11-23 14:50:06 +00:00
add code for cycle deps fix 8-9
Signed-off-by: wuxintao <wuxintao5@huawei.com>
This commit is contained in:
parent
3704c88bee
commit
b59ee285cd
@ -26,6 +26,18 @@ if (os_level == "standard") {
|
||||
public_deps = [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/mbedtls:libhuks_mbedtls_standard_static" ]
|
||||
}
|
||||
|
||||
sources = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_ability.c",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_get_main_key.c",
|
||||
]
|
||||
include_dirs = [
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/common/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/include",
|
||||
]
|
||||
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
|
||||
complete_static_lib = true
|
||||
|
||||
branch_protector_ret = "pac_ret"
|
||||
@ -48,6 +60,17 @@ if (os_level == "standard") {
|
||||
"//base/security/huks/frameworks/config/build:l1_small_common_config",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_ability.c",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_get_main_key.c",
|
||||
]
|
||||
include_dirs = [
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/common/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/crypto_common/include",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
]
|
||||
|
||||
if (huks_use_mbedtls) {
|
||||
public_deps = [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/mbedtls:libhuks_mbedtls_small_static" ]
|
||||
} else {
|
||||
|
@ -1,38 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_OPENSSL_GET_MAIN_KEY_H
|
||||
#define HKS_OPENSSL_GET_MAIN_KEY_H
|
||||
|
||||
#ifdef HKS_CONFIG_FILE
|
||||
#include HKS_CONFIG_FILE
|
||||
#else
|
||||
#include "hks_config.h"
|
||||
#endif
|
||||
|
||||
#include "hks_crypto_hal.h"
|
||||
#include "hks_type_inner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t HksOpensslGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HKS_OPENSSL_GET_MAIN_KEY_H */
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
#ifndef HKS_CORE_ABILITY_H
|
||||
#define HKS_CORE_ABILITY_H
|
||||
|
||||
#include "hks_crypto_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t HksCryptoAbilityInitBase(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HKS_CORE_ABILITY_H */
|
@ -1,38 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_MBEDTLS_GET_MAIN_KEY_H
|
||||
#define HKS_MBEDTLS_GET_MAIN_KEY_H
|
||||
|
||||
#ifdef HKS_CONFIG_FILE
|
||||
#include HKS_CONFIG_FILE
|
||||
#else
|
||||
#include "hks_config.h"
|
||||
#endif
|
||||
|
||||
#include "hks_crypto_hal.h"
|
||||
#include "hks_type_inner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t HksMbedtlsGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HKS_MBEDTLS_GET_MAIN_KEY_H */
|
||||
/*
|
||||
* Copyright (c) 2024-2024 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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_CORE_GET_MAIN_KEY_H
|
||||
#define HKS_CORE_GET_MAIN_KEY_H
|
||||
|
||||
#ifdef HKS_CONFIG_FILE
|
||||
#include HKS_CONFIG_FILE
|
||||
#else
|
||||
#include "hks_config.h"
|
||||
#endif
|
||||
|
||||
#include "hks_crypto_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t HksCoreGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey);
|
||||
|
||||
void RegisterAbilityGetMainKey(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HKS_CORE_GET_MAIN_KEY_H */
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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_core_ability.h"
|
||||
#include "hks_core_get_main_key.h"
|
||||
|
||||
int32_t HksCryptoAbilityInit(void)
|
||||
{
|
||||
HksCryptoAbilityInitBase();
|
||||
RegisterAbilityGetMainKey();
|
||||
return HKS_SUCCESS;
|
||||
}
|
@ -1,59 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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_log.h"
|
||||
#include "hks_template.h"
|
||||
#include "hks_openssl_get_main_key.h"
|
||||
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
#include "hks_rkc.h"
|
||||
#endif
|
||||
|
||||
int32_t HksOpensslGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey)
|
||||
{
|
||||
(void)message;
|
||||
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
#ifdef HKS_USE_RKC_IN_STANDARD
|
||||
return HksRkcGetMainKey(mainKey);
|
||||
#else
|
||||
(void)mainKey;
|
||||
return HKS_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* Currently, root key is implemented using stubs.
|
||||
* Product adaptation needs to be performed based on hardware capabilities.
|
||||
*/
|
||||
uint8_t stubBuf[] = {
|
||||
0x0c, 0xb4, 0x29, 0x39, 0xb7, 0x46, 0xa6, 0x4b,
|
||||
0xdd, 0xf3, 0x75, 0x4c, 0xe0, 0x73, 0x91, 0x51,
|
||||
0xc4, 0x88, 0xbe, 0xa4, 0xe1, 0x87, 0xb5, 0x42,
|
||||
0x06, 0x27, 0x08, 0x21, 0xe2, 0x8f, 0x9b, 0xc1,
|
||||
};
|
||||
|
||||
if (memcpy_s(mainKey->data, mainKey->size, stubBuf, sizeof(stubBuf)) != EOK) {
|
||||
HKS_LOG_E("memcpy failed, get stub main key failed");
|
||||
return HKS_ERROR_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
return HKS_SUCCESS;
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 2024 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_core_get_main_key.h"
|
||||
#include "hks_ability.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
#include "hks_rkc.h"
|
||||
|
||||
#ifdef L2_STANDARD
|
||||
static int32_t L2CoreGetMainKey(struct HksBlob *mainKey)
|
||||
{
|
||||
#ifdef HKS_USE_RKC_IN_STANDARD
|
||||
return HksRkcGetMainKey(mainKey);
|
||||
#else
|
||||
(void)mainKey;
|
||||
return HKS_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t HksCoreGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey)
|
||||
{
|
||||
(void)message;
|
||||
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
|
||||
#ifdef L2_STANDARD
|
||||
return L2CoreGetMainKey(mainKey)
|
||||
#else
|
||||
return HksRkcGetMainKey(mainKey);
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*
|
||||
* Currently, root key is implemented using stubs.
|
||||
* Product adaptation needs to be performed based on hardware capabilities.
|
||||
*/
|
||||
uint8_t stubBuf[] = {
|
||||
0x0c, 0xb4, 0x29, 0x39, 0xb7, 0x46, 0xa6, 0x4b,
|
||||
0xdd, 0xf3, 0x75, 0x4c, 0xe0, 0x73, 0x91, 0x51,
|
||||
0xc4, 0x88, 0xbe, 0xa4, 0xe1, 0x87, 0xb5, 0x42,
|
||||
0x06, 0x27, 0x08, 0x21, 0xe2, 0x8f, 0x9b, 0xc1,
|
||||
};
|
||||
|
||||
if (memcpy_s(mainKey->data, mainKey->size, stubBuf, sizeof(stubBuf)) != EOK) {
|
||||
return HKS_ERROR_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
return HKS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RegisterAbilityGetMainKey(void)
|
||||
{
|
||||
(void)RegisterAbility(HKS_CRYPTO_ABILITY_GET_MAIN_KEY, (void *)HksCoreGetMainKey);
|
||||
}
|
@ -18,6 +18,7 @@ if (os_level == "standard") {
|
||||
config("huks_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"../crypto_common/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include",
|
||||
]
|
||||
}
|
||||
@ -38,7 +39,6 @@ if (os_level == "standard") {
|
||||
"src/hks_mbedtls_ecdh.c",
|
||||
"src/hks_mbedtls_ecdsa.c",
|
||||
"src/hks_mbedtls_engine.c",
|
||||
"src/hks_mbedtls_get_main_key.c",
|
||||
"src/hks_mbedtls_hash.c",
|
||||
"src/hks_mbedtls_hmac.c",
|
||||
"src/hks_mbedtls_kdf.c",
|
||||
@ -80,6 +80,7 @@ if (os_level == "standard") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include",
|
||||
]
|
||||
}
|
||||
@ -87,7 +88,10 @@ if (os_level == "standard") {
|
||||
ohos_static_library("libhuks_mbedtls_small_static") {
|
||||
public_configs = [ ":huks_config" ]
|
||||
|
||||
include_dirs = [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include" ]
|
||||
include_dirs = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include",
|
||||
"../crypto_common/include",
|
||||
]
|
||||
|
||||
defines = []
|
||||
|
||||
@ -105,7 +109,6 @@ if (os_level == "standard") {
|
||||
"src/hks_mbedtls_ecdh.c",
|
||||
"src/hks_mbedtls_ecdsa.c",
|
||||
"src/hks_mbedtls_engine.c",
|
||||
"src/hks_mbedtls_get_main_key.c",
|
||||
"src/hks_mbedtls_hash.c",
|
||||
"src/hks_mbedtls_hmac.c",
|
||||
"src/hks_mbedtls_kdf.c",
|
||||
@ -114,9 +117,9 @@ if (os_level == "standard") {
|
||||
]
|
||||
|
||||
sources += [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
]
|
||||
|
||||
if (huks_enable_upgrade_rkc_v1tov2) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "hks_ability.h"
|
||||
#include "hks_core_ability.h"
|
||||
|
||||
#include "hks_crypto_ed25519.h"
|
||||
#include "hks_log.h"
|
||||
@ -31,7 +32,6 @@
|
||||
#include "hks_mbedtls_ecc.h"
|
||||
#include "hks_mbedtls_ecdh.h"
|
||||
#include "hks_mbedtls_ecdsa.h"
|
||||
#include "hks_mbedtls_get_main_key.h"
|
||||
#include "hks_mbedtls_hash.h"
|
||||
#include "hks_mbedtls_hmac.h"
|
||||
#include "hks_mbedtls_kdf.h"
|
||||
@ -216,12 +216,7 @@ static void RegisterAbilityBnExpMod(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void RegisterAbilityGetMainKey(void)
|
||||
{
|
||||
(void)RegisterAbility(HKS_CRYPTO_ABILITY_GET_MAIN_KEY, (void *)HksMbedtlsGetMainKey);
|
||||
}
|
||||
|
||||
int32_t HksCryptoAbilityInit(void)
|
||||
int32_t HksCryptoAbilityInitBase(void)
|
||||
{
|
||||
RegisterAbilityGenerateKey();
|
||||
RegisterAbilityGetPublicKey();
|
||||
@ -235,6 +230,5 @@ int32_t HksCryptoAbilityInit(void)
|
||||
RegisterAbilityHash();
|
||||
RegisterAbilityFillRandom();
|
||||
RegisterAbilityBnExpMod();
|
||||
RegisterAbilityGetMainKey();
|
||||
return HKS_SUCCESS;
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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_mbedtls_get_main_key.h"
|
||||
|
||||
#include "hks_log.h"
|
||||
#include "hks_template.h"
|
||||
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
#include "hks_rkc.h"
|
||||
#endif
|
||||
|
||||
int32_t HksMbedtlsGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey)
|
||||
{
|
||||
(void)message;
|
||||
#ifndef _HARDWARE_ROOT_KEY_
|
||||
return HksRkcGetMainKey(mainKey);
|
||||
#else
|
||||
/*
|
||||
* Currently, root key is implemented using stubs.
|
||||
* Product adaptation needs to be performed based on hardware capabilities.
|
||||
*/
|
||||
uint8_t stubBuf[] = {
|
||||
0x0c, 0xb4, 0x29, 0x39, 0xb7, 0x46, 0xa6, 0x4b,
|
||||
0xdd, 0xf3, 0x75, 0x4c, 0xe0, 0x73, 0x91, 0x51,
|
||||
0xc4, 0x88, 0xbe, 0xa4, 0xe1, 0x87, 0xb5, 0x42,
|
||||
0x06, 0x27, 0x08, 0x21, 0xe2, 0x8f, 0x9b, 0xc1,
|
||||
};
|
||||
|
||||
if (memcpy_s(mainKey->data, mainKey->size, stubBuf, sizeof(stubBuf)) != EOK) {
|
||||
HKS_LOG_E("memcpy failed, get stub main key failed");
|
||||
return HKS_ERROR_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
return HKS_SUCCESS;
|
||||
#endif
|
||||
}
|
@ -12,12 +12,14 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/security/huks/build/config.gni")
|
||||
import("//base/security/huks/huks.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
if (os_level == "standard") {
|
||||
config("huks_config") {
|
||||
include_dirs = [ "include" ]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"../crypto_common/include",
|
||||
]
|
||||
if (huks_use_rkc_in_standard) {
|
||||
include_dirs += [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include" ]
|
||||
}
|
||||
@ -39,7 +41,6 @@ if (os_level == "standard") {
|
||||
"src/hks_openssl_ecc.c",
|
||||
"src/hks_openssl_ed25519tox25519.c",
|
||||
"src/hks_openssl_engine.c",
|
||||
"src/hks_openssl_get_main_key.c",
|
||||
"src/hks_openssl_hash.c",
|
||||
"src/hks_openssl_hmac.c",
|
||||
"src/hks_openssl_kdf.c",
|
||||
@ -51,33 +52,24 @@ if (os_level == "standard") {
|
||||
deps = []
|
||||
defines = []
|
||||
include_dirs = []
|
||||
external_deps = []
|
||||
if (huks_use_rkc_in_standard) {
|
||||
defines += [ "HKS_USE_RKC_IN_STANDARD" ]
|
||||
|
||||
include_dirs += [ "//base/security/huks/services/huks_standard/huks_service/main/core/include" ]
|
||||
include_dirs += [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
]
|
||||
sources += [
|
||||
"../rkc/src/hks_rkc.c",
|
||||
"../rkc/src/hks_rkc_rw.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c",
|
||||
]
|
||||
|
||||
# when uks_use_rkc_in_standard and HKS_ENABLE_CLEAN_FILE are enabled at the same time, add the dependency of HDI to the engine
|
||||
if (huks_enable_hdi_in_standard) {
|
||||
sources += [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_hdi_access.c" ]
|
||||
external_deps += [ "drivers_interface_huks:libhuks_proxy_1.0" ]
|
||||
} else {
|
||||
sources += [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_access.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_core_dynamic_hal.c",
|
||||
]
|
||||
}
|
||||
|
||||
deps += [
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static",
|
||||
"//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static",
|
||||
@ -104,7 +96,7 @@ if (os_level == "standard") {
|
||||
boundary_sanitize = true
|
||||
ubsan = true
|
||||
}
|
||||
external_deps += [
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
@ -119,6 +111,7 @@ if (os_level == "standard") {
|
||||
}
|
||||
} else {
|
||||
ohos_static_library("libhuks_openssl_small_static") {
|
||||
include_dirs = [ "../crypto_common/include" ]
|
||||
sources = [
|
||||
"src/hks_openssl_ability.c",
|
||||
"src/hks_openssl_aes.c",
|
||||
@ -130,7 +123,6 @@ if (os_level == "standard") {
|
||||
"src/hks_openssl_ecc.c",
|
||||
"src/hks_openssl_ed25519tox25519.c",
|
||||
"src/hks_openssl_engine.c",
|
||||
"src/hks_openssl_get_main_key.c",
|
||||
"src/hks_openssl_hash.c",
|
||||
"src/hks_openssl_hmac.c",
|
||||
"src/hks_openssl_kdf.c",
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hks_ability.h"
|
||||
#include "hks_core_ability.h"
|
||||
#include "hks_openssl_aes.h"
|
||||
#include "hks_openssl_bn.h"
|
||||
#include "hks_openssl_common.h"
|
||||
@ -29,7 +30,6 @@
|
||||
#include "hks_openssl_dh.h"
|
||||
#include "hks_openssl_dsa.h"
|
||||
#include "hks_openssl_ecc.h"
|
||||
#include "hks_openssl_get_main_key.h"
|
||||
#include "hks_openssl_hash.h"
|
||||
#include "hks_openssl_hmac.h"
|
||||
#include "hks_openssl_kdf.h"
|
||||
@ -254,11 +254,6 @@ static void RegisterAbilityHmac(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void RegisterAbilityGetMainKey(void)
|
||||
{
|
||||
(void)RegisterAbility(HKS_CRYPTO_ABILITY_GET_MAIN_KEY, HksOpensslGetMainKey);
|
||||
}
|
||||
|
||||
static void RegisterAbilityFillRandom(void)
|
||||
{
|
||||
(void)RegisterAbility(HKS_CRYPTO_ABILITY_FILL_RANDOM, HksOpensslFillRandom);
|
||||
@ -272,9 +267,8 @@ static void RegisterAbilityBnExpMod(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t HksCryptoAbilityInit(void)
|
||||
int32_t HksCryptoAbilityInitBase(void)
|
||||
{
|
||||
RegisterAbilityGetMainKey();
|
||||
RegisterAbilityGenerateKey();
|
||||
RegisterAbilityGetPublicKey();
|
||||
RegisterAbilitySign();
|
||||
|
@ -36,6 +36,7 @@ config("soft_huks_config") {
|
||||
include_dirs = [
|
||||
"../../../frameworks/huks_standard/main/common/include",
|
||||
"../../../frameworks/huks_standard/main/core/include",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/crypto_common/include",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/include",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/openssl/include",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/rkc/include",
|
||||
@ -125,6 +126,8 @@ if (ohos_kernel_type == "liteos_m") {
|
||||
|
||||
if (huks_use_mbedtls == true) {
|
||||
sources += [
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_ability.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/crypto_common/src/hks_core_get_main_key.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_crypto_ed25519.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_ability.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_aes.c",
|
||||
@ -134,7 +137,6 @@ if (ohos_kernel_type == "liteos_m") {
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_ecdh.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_ecdsa.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_engine.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_get_main_key.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_hash.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_hmac.c",
|
||||
"../../../frameworks/huks_standard/main/crypto_engine/mbedtls/src/hks_mbedtls_kdf.c",
|
||||
@ -165,8 +167,8 @@ if (ohos_kernel_type == "liteos_m") {
|
||||
"../../../frameworks/huks_standard/main/os_dependency/posix/hks_util.c",
|
||||
"../../../frameworks/huks_standard/main/os_dependency/sysinfo/src/hks_get_process_info_passthrough.c",
|
||||
"../../../frameworks/huks_standard/main/os_dependency/sysinfo/src/hks_get_udid.c",
|
||||
"../../../interfaces/inner_api/huks_standard/main/src/hks_api.c",
|
||||
"../../../interfaces/inner_api/huks_standard/main/src/hks_api_adapter.c",
|
||||
"../../../interfaces/inner_api/huks_standard/source/hks_api.c",
|
||||
"../../../interfaces/inner_api/huks_standard/source/hks_api_adapter.c",
|
||||
"../../../services/huks_standard/huks_engine/main/core/src/hks_auth.c",
|
||||
"../../../services/huks_standard/huks_engine/main/core/src/hks_core_interfaces.c",
|
||||
"../../../services/huks_standard/huks_engine/main/core/src/hks_core_service.c",
|
||||
@ -199,22 +201,23 @@ if (ohos_kernel_type == "liteos_m") {
|
||||
if (huks_use_lite_storage == true) {
|
||||
sources += [
|
||||
"../../../services/huks_standard/huks_engine/main/core/src/hks_keyblob_lite.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_adapter.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_lite.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_lite.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
]
|
||||
} else {
|
||||
sources += [
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"../../../services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/common/include",
|
||||
"//base/security/huks/services/huks_standard/huks_engine/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/ipc",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/plugin_proxy/include",
|
||||
]
|
||||
@ -288,8 +291,8 @@ if (ohos_kernel_type == "liteos_m") {
|
||||
sources = []
|
||||
|
||||
sources = [
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/src/hks_api.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/src/hks_api_adapter.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/source/hks_api.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/source/hks_api_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/ipc/hks_permission_check.cpp",
|
||||
]
|
||||
|
||||
|
@ -42,13 +42,16 @@ if (os_level == "standard") {
|
||||
"//base/security/huks/frameworks/config/build:l2_standard_common_config",
|
||||
]
|
||||
|
||||
include_dirs = [ "//base/security/huks/utils/crypto_adapter" ]
|
||||
include_dirs = [
|
||||
"//base/security/huks/utils/crypto_adapter",
|
||||
"../source",
|
||||
]
|
||||
if (huks_security_level == "software") {
|
||||
defines = [ "HKS_UNTRUSTED_RUNNING_ENV" ]
|
||||
}
|
||||
sources = [
|
||||
"src/hks_api.c",
|
||||
"src/hks_api_adapter.c",
|
||||
"../source/hks_api.c",
|
||||
"../source/hks_api_adapter.c",
|
||||
]
|
||||
|
||||
deps = [
|
||||
|
@ -107,6 +107,7 @@ if (os_level == "standard") {
|
||||
"//base/security/huks/utils/list",
|
||||
"//base/security/huks/utils/mutex",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@ -129,16 +130,16 @@ if (os_level == "standard") {
|
||||
|
||||
if (huks_use_lite_storage == true) {
|
||||
sources += [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_lite.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_lite.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
]
|
||||
} else {
|
||||
sources += [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1898,8 +1898,11 @@ int32_t HksCoreAttestKey(const struct HksBlob *key, const struct HksParamSet *p
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = CreateAttestCertChain(keyNode, paramSet, certChain);
|
||||
struct HksBlob rawKey;
|
||||
HksGetRawKey(keyNode->paramSet, &rawKey);
|
||||
ret = CreateAttestCertChain(keyNode->paramSet, paramSet, certChain, &rawKey);
|
||||
HksFreeKeyNode(&keyNode);
|
||||
HKS_FREE_BLOB(rawKey);
|
||||
return ret;
|
||||
#else
|
||||
(void)key;
|
||||
|
@ -41,7 +41,10 @@ ohos_static_library("libhuks_core_hal_api_static") {
|
||||
"src/hks_core_useriam_wrap.cpp",
|
||||
]
|
||||
|
||||
deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ]
|
||||
deps = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine:libhuks_crypto_engine_standard_static",
|
||||
]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/security/huks/services/huks_standard/huks_engine/main/core/include",
|
||||
|
@ -120,8 +120,8 @@ struct HksAttestSpec {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t CreateAttestCertChain(struct HksKeyNode *keyNode, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *certChain);
|
||||
int32_t CreateAttestCertChain(const struct HksParamSet *keyNodeParamSet, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *certChain, struct HksBlob *rawKey);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ static int32_t GetCertOrKey(enum HksCertType type, struct HksBlob *out)
|
||||
return HKS_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int32_t GetCertAndKey(const struct HksKeyNode *keyNode, struct HksAttestSpec *attestSpec)
|
||||
static int32_t GetCertAndKey(struct HksAttestSpec *attestSpec)
|
||||
{
|
||||
int32_t ret = GetCertOrKey(HKS_DEVICE_CERT, &attestSpec->devCert);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "get devCert fail")
|
||||
@ -1281,9 +1281,6 @@ static int32_t GetCertAndKey(const struct HksKeyNode *keyNode, struct HksAttestS
|
||||
ret = GetCertOrKey(HKS_DEVICE_KEY, &attestSpec->devKey);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "get devKey fail")
|
||||
|
||||
ret = HksGetRawKey(keyNode->paramSet, &attestSpec->attestKey);
|
||||
HKS_IF_NOT_SUCC_LOGE(ret, "get attestKey fail")
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1327,8 +1324,8 @@ static int32_t CheckAttestUsageSpec(const struct HksUsageSpec *usageSpec)
|
||||
return HKS_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t BuildAttestSpec(const struct HksKeyNode *keyNode, const struct HksParamSet *paramSet,
|
||||
struct HksAttestSpec **outAttestSpec)
|
||||
static int32_t BuildAttestSpec(const struct HksParamSet *keyNodeParamSet, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *rawKey, struct HksAttestSpec **outAttestSpec)
|
||||
{
|
||||
struct HksAttestSpec *attestSpec = HksMalloc(sizeof(struct HksAttestSpec));
|
||||
HKS_IF_NULL_LOGE_RETURN(attestSpec, HKS_ERROR_MALLOC_FAIL, "malloc attestSpec fail\n")
|
||||
@ -1337,22 +1334,26 @@ static int32_t BuildAttestSpec(const struct HksKeyNode *keyNode, const struct Hk
|
||||
|
||||
SetAttestCertValid(&attestSpec->validity);
|
||||
|
||||
HksFillUsageSpec(keyNode->paramSet, &attestSpec->usageSpec);
|
||||
HksFillUsageSpec(keyNodeParamSet, &attestSpec->usageSpec);
|
||||
int32_t ret = CheckAttestUsageSpec(&attestSpec->usageSpec);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
FreeAttestSpec(&attestSpec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = BuildAttestClaims(paramSet, keyNode->paramSet, attestSpec);
|
||||
ret = BuildAttestClaims(paramSet, keyNodeParamSet, attestSpec);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
FreeAttestSpec(&attestSpec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
attestSpec->claimsOid = hksAttestationExtensionOid;
|
||||
attestSpec->attestKey.size = rawKey->size;
|
||||
attestSpec->attestKey.data = HksMalloc(rawKey->size);
|
||||
HKS_IF_NULL_LOGE_RETURN(attestSpec->attestKey.data, HKS_ERROR_MALLOC_FAIL, "fail to malloc raw key")
|
||||
(void)memcpy_s(attestSpec->attestKey.data, rawKey->size, rawKey->data, rawKey->size);
|
||||
|
||||
ret = GetCertAndKey(keyNode, attestSpec);
|
||||
ret = GetCertAndKey(attestSpec);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HKS_LOG_E("get cert and key fail\n");
|
||||
FreeAttestSpec(&attestSpec);
|
||||
@ -1441,11 +1442,11 @@ static int32_t FormatAttestChain(const struct HksBlob *attestCert, const struct
|
||||
return HKS_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CreateAttestCertChain(struct HksKeyNode *keyNode, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *certChain)
|
||||
int32_t CreateAttestCertChain(const struct HksParamSet *keyNodeParamSet, const struct HksParamSet *paramSet,
|
||||
struct HksBlob *certChain, struct HksBlob *rawKey)
|
||||
{
|
||||
struct HksAttestSpec *attestSpec = NULL;
|
||||
int32_t ret = BuildAttestSpec(keyNode, paramSet, &attestSpec);
|
||||
int32_t ret = BuildAttestSpec(keyNodeParamSet, paramSet, rawKey, &attestSpec);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "build attest spec failed")
|
||||
|
||||
struct HksBlob attestCert;
|
||||
|
@ -18,6 +18,8 @@ import("//build/ohos.gni")
|
||||
config("huks_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/dcm/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/plugin_proxy/include",
|
||||
]
|
||||
}
|
||||
@ -36,14 +38,14 @@ if (os_level == "standard") {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
"src/hks_client_check.c",
|
||||
"src/hks_client_service.c",
|
||||
"src/hks_client_service_util.c",
|
||||
"src/hks_session_manager.c",
|
||||
"src/hks_storage.c",
|
||||
"src/hks_storage_file_lock.c",
|
||||
"src/hks_storage_manager.c",
|
||||
"src/hks_storage_utils.c",
|
||||
]
|
||||
|
||||
defines = [ "HKS_ENABLE_CLEAN_FILE" ]
|
||||
@ -53,7 +55,7 @@ if (os_level == "standard") {
|
||||
}
|
||||
|
||||
if (huks_security_level == "trusted_environment") {
|
||||
sources += [ "src/hks_client_service_dcm.cpp" ]
|
||||
sources += [ "//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/dcm/src/hks_client_service_dcm.cpp" ]
|
||||
}
|
||||
|
||||
sources += [ "../plugin_proxy/src/hks_plugin_adapter.cpp" ]
|
||||
@ -64,9 +66,9 @@ if (os_level == "standard") {
|
||||
]
|
||||
|
||||
if (non_rwlock_support) {
|
||||
sources += [ "src/hks_lock_lite.c" ]
|
||||
sources += [ "../hks_storage/src/hks_lock_lite.c" ]
|
||||
} else {
|
||||
sources += [ "src/hks_lock.c" ]
|
||||
sources += [ "../hks_storage/src/hks_lock.c" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
@ -138,14 +140,14 @@ if (os_level == "standard") {
|
||||
defines = [ "HKS_ENABLE_CLEAN_FILE" ]
|
||||
|
||||
sources = [
|
||||
"../hks_storage/src/hks_storage_file_lock.c",
|
||||
"../hks_storage/src/hks_storage_lite.c",
|
||||
"../hks_storage/src/hks_storage_manager.c",
|
||||
"../hks_storage/src/hks_storage_utils.c",
|
||||
"src/hks_client_check.c",
|
||||
"src/hks_client_service.c",
|
||||
"src/hks_client_service_util.c",
|
||||
"src/hks_session_manager.c",
|
||||
"src/hks_storage_file_lock.c",
|
||||
"src/hks_storage_lite.c",
|
||||
"src/hks_storage_manager.c",
|
||||
"src/hks_storage_utils.c",
|
||||
]
|
||||
sources += [
|
||||
"src/hks_hitrace.c",
|
||||
@ -161,16 +163,16 @@ if (os_level == "standard") {
|
||||
|
||||
if (huks_use_lite_storage == true) {
|
||||
sources += [
|
||||
"src/hks_storage_adapter.c",
|
||||
"src/hks_storage_lite.c",
|
||||
"../hks_storage/src/hks_storage_adapter.c",
|
||||
"../hks_storage/src/hks_storage_lite.c",
|
||||
]
|
||||
} else {
|
||||
sources += [ "src/hks_storage.c" ]
|
||||
sources += [ "../hks_storage/src/hks_storage.c" ]
|
||||
}
|
||||
if (non_rwlock_support) {
|
||||
sources += [ "src/hks_lock_lite.c" ]
|
||||
sources += [ "../hks_storage/src/hks_lock_lite.c" ]
|
||||
} else {
|
||||
sources += [ "src/hks_lock.c" ]
|
||||
sources += [ "../hks_storage/src/hks_lock.c" ]
|
||||
}
|
||||
|
||||
cflags = []
|
||||
|
@ -25,9 +25,11 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "hks_type.h"
|
||||
#include "hks_base_check.h" // for HksAttestIsAnonymous
|
||||
#include "hks_base_check.h"
|
||||
#include "hks_client_check.h"
|
||||
#ifdef HKS_SUPPORT_API_ATTEST_KEY
|
||||
#include "hks_client_service_dcm.h"
|
||||
#endif
|
||||
#include "hks_client_service_util.h"
|
||||
#include "hks_common_check.h"
|
||||
#include "hks_hitrace.h"
|
||||
|
@ -1,96 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2024 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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_STORAGE_H
|
||||
#define HKS_STORAGE_H
|
||||
|
||||
#include "hks_storage_utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _CUT_AUTHENTICATE_
|
||||
#ifdef _STORAGE_LITE_
|
||||
int32_t HksStoreKeyBlob(const struct HksStoreFileInfo *fileInfo, const struct HksBlob *keyAlias,
|
||||
uint32_t storageType, const struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreDeleteKeyBlob(const struct HksStoreFileInfo *fileInfo,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType);
|
||||
|
||||
int32_t HksStoreIsKeyBlobExist(const struct HksStoreFileInfo *fileInfo,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType);
|
||||
|
||||
int32_t HksStoreGetKeyBlob(const struct HksStoreInfo *fileInfoPath,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType, struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreGetKeyBlobSize(const struct HksBlob *processName,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType, uint32_t *keyBlobSize);
|
||||
|
||||
int32_t HksGetKeyCountByProcessName(const struct HksBlob *processName, uint32_t *fileCount);
|
||||
#else // _STORAGE_LITE_
|
||||
|
||||
int32_t HksStoreKeyBlob(const struct HksStoreFileInfo *fileInfo, const struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreDeleteKeyBlob(const struct HksStoreFileInfo *fileInfo);
|
||||
|
||||
int32_t HksStoreIsKeyBlobExist(const struct HksStoreFileInfo *fileInfo);
|
||||
|
||||
int32_t HksStoreGetKeyBlob(const struct HksStoreInfo *fileInfoPath, struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreGetKeyBlobSize(const struct HksStoreInfo *fileInfoPath, uint32_t *keyBlobSize);
|
||||
|
||||
int32_t HksGetKeyCountByProcessName(const struct HksStoreFileInfo *fileInfo, uint32_t *fileCount);
|
||||
|
||||
int32_t HksStorageWriteFile(
|
||||
const char *path, const char *fileName, uint32_t offset, const uint8_t *buf, uint32_t len);
|
||||
|
||||
#endif // _STORAGE_LITE_
|
||||
#endif // _CUT_AUTHENTICATE_
|
||||
|
||||
int32_t HksGetKeyAliasByProcessName(const struct HksStoreFileInfo *fileInfo, struct HksKeyInfo *keyInfoList,
|
||||
uint32_t *listCount);
|
||||
|
||||
int32_t HksStoreDestroy(const struct HksBlob *processName);
|
||||
|
||||
void HksServiceDeleteUserIDKeyAliasFile(const struct HksBlob *userId);
|
||||
|
||||
void HksServiceDeleteUIDKeyAliasFile(const struct HksProcessInfo *processInfo);
|
||||
|
||||
int32_t HksListAliasesByProcessName(const struct HksStoreFileInfo *fileInfo, struct HksKeyAliasSet **outData);
|
||||
|
||||
#ifdef HKS_ENABLE_SMALL_TO_SERVICE
|
||||
int32_t HksIsOldKeyPathCleared(uint32_t *keyCount);
|
||||
#endif
|
||||
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#define HKS_KEY_STORE_FILE_NAME "hks_keystore"
|
||||
|
||||
int32_t HksLoadFileToBuffer(void);
|
||||
|
||||
int32_t HksFileBufferRefresh(void);
|
||||
|
||||
int32_t HksStoreGetToatalSize(uint32_t *size);
|
||||
|
||||
int32_t HksStoreGetKeyInfoList(struct HksKeyInfo *keyInfoList, uint32_t *listCount);
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021-2024 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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_STORAGE_H
|
||||
#define HKS_STORAGE_H
|
||||
|
||||
#include "hks_storage_utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _CUT_AUTHENTICATE_
|
||||
#ifdef _STORAGE_LITE_
|
||||
int32_t HksStoreKeyBlob(const struct HksStoreFileInfo *fileInfo, const struct HksBlob *keyAlias,
|
||||
uint32_t storageType, const struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreDeleteKeyBlob(const struct HksStoreFileInfo *fileInfo,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType);
|
||||
|
||||
int32_t HksStoreIsKeyBlobExist(const struct HksStoreFileInfo *fileInfo,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType);
|
||||
|
||||
int32_t HksStoreGetKeyBlob(const struct HksStoreInfo *fileInfoPath,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType, struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreGetKeyBlobSize(const struct HksBlob *processName,
|
||||
const struct HksBlob *keyAlias, uint32_t storageType, uint32_t *keyBlobSize);
|
||||
|
||||
int32_t HksGetKeyCountByProcessName(const struct HksBlob *processName, uint32_t *fileCount);
|
||||
#else // _STORAGE_LITE_
|
||||
|
||||
int32_t HksStoreKeyBlob(const struct HksStoreFileInfo *fileInfo, const struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreDeleteKeyBlob(const struct HksStoreFileInfo *fileInfo);
|
||||
|
||||
int32_t HksStoreIsKeyBlobExist(const struct HksStoreFileInfo *fileInfo);
|
||||
|
||||
int32_t HksStoreGetKeyBlob(const struct HksStoreInfo *fileInfoPath, struct HksBlob *keyBlob);
|
||||
|
||||
int32_t HksStoreGetKeyBlobSize(const struct HksStoreInfo *fileInfoPath, uint32_t *keyBlobSize);
|
||||
|
||||
int32_t HksGetKeyCountByProcessName(const struct HksStoreFileInfo *fileInfo, uint32_t *fileCount);
|
||||
|
||||
int32_t HksStorageWriteFile(
|
||||
const char *path, const char *fileName, uint32_t offset, const uint8_t *buf, uint32_t len);
|
||||
|
||||
#endif // _STORAGE_LITE_
|
||||
#endif // _CUT_AUTHENTICATE_
|
||||
|
||||
int32_t HksGetKeyAliasByProcessName(const struct HksStoreFileInfo *fileInfo, struct HksKeyInfo *keyInfoList,
|
||||
uint32_t *listCount);
|
||||
|
||||
int32_t HksStoreDestroy(const struct HksBlob *processName);
|
||||
|
||||
void HksServiceDeleteUserIDKeyAliasFile(const struct HksBlob *userId);
|
||||
|
||||
void HksServiceDeleteUIDKeyAliasFile(const struct HksProcessInfo *processInfo);
|
||||
|
||||
int32_t HksListAliasesByProcessName(const struct HksStoreFileInfo *fileInfo, struct HksKeyAliasSet **outData);
|
||||
|
||||
#ifdef HKS_ENABLE_SMALL_TO_SERVICE
|
||||
int32_t HksIsOldKeyPathCleared(uint32_t *keyCount);
|
||||
#endif
|
||||
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#define HKS_KEY_STORE_FILE_NAME "hks_keystore"
|
||||
|
||||
int32_t HksLoadFileToBuffer(void);
|
||||
|
||||
int32_t HksFileBufferRefresh(void);
|
||||
|
||||
int32_t HksStoreGetToatalSize(uint32_t *size);
|
||||
|
||||
int32_t HksStoreGetKeyInfoList(struct HksKeyInfo *keyInfoList, uint32_t *listCount);
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HKS_STORAGE_H */
|
@ -1,38 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_STORAGE_ADAPTER_H
|
||||
#define HKS_STORAGE_ADAPTER_H
|
||||
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#include "hks_type_inner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool HksIsKeyInfoLenInvalid(struct HksStoreKeyInfo *keyInfo);
|
||||
|
||||
int32_t TranslateKeyInfoBlobToParamSet(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet **paramSet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#ifndef HKS_STORAGE_ADAPTER_H
|
||||
#define HKS_STORAGE_ADAPTER_H
|
||||
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#include "hks_type_inner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool HksIsKeyInfoLenInvalid(struct HksStoreKeyInfo *keyInfo);
|
||||
|
||||
int32_t TranslateKeyInfoBlobToParamSet(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet **paramSet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
|
||||
#endif /* HKS_STORAGE_ADAPTER_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,136 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#ifndef _CUT_AUTHENTICATE_
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#include "hks_storage_adapter.h"
|
||||
|
||||
#include "hks_log.h"
|
||||
#include "hks_param.h"
|
||||
#include "hks_template.h"
|
||||
|
||||
bool HksIsKeyInfoLenInvalid(struct HksStoreKeyInfo *keyInfo)
|
||||
{
|
||||
return (keyInfo->aliasSize > HKS_MAX_KEY_ALIAS_LEN) || (keyInfo->aliasSize == 0) ||
|
||||
(keyInfo->keySize > HKS_MAX_KEY_MATERIAL_LEN) || (keyInfo->keySize == 0) ||
|
||||
(keyInfo->authIdSize > HKS_MAX_KEY_AUTH_ID_LEN) ||
|
||||
(keyInfo->keyInfoLen != (sizeof(*keyInfo) + keyInfo->aliasSize + keyInfo->authIdSize + keyInfo->keySize));
|
||||
}
|
||||
|
||||
static int32_t AddStorageFixedParams(const struct HksStoreKeyInfo *keyInfo, struct HksParamSet *paramSet)
|
||||
{
|
||||
struct HksParam params[] = {
|
||||
{
|
||||
.tag = HKS_TAG_KEY_FLAG,
|
||||
.uint32Param = keyInfo->flag
|
||||
}, {
|
||||
.tag = HKS_TAG_ALGORITHM,
|
||||
.uint32Param = keyInfo->keyAlg
|
||||
}, {
|
||||
.tag = HKS_TAG_PURPOSE,
|
||||
.uint32Param = keyInfo->purpose
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_SIZE,
|
||||
.uint32Param = keyInfo->keyLen
|
||||
}, {
|
||||
.tag = HKS_TAG_DIGEST,
|
||||
.uint32Param = keyInfo->digest
|
||||
}, {
|
||||
.tag = HKS_TAG_PADDING,
|
||||
.uint32Param = keyInfo->padding
|
||||
}, {
|
||||
.tag = HKS_TAG_BLOCK_MODE,
|
||||
.uint32Param = keyInfo->keyMode
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_ROLE,
|
||||
.uint32Param = keyInfo->role
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_DOMAIN,
|
||||
.uint32Param = keyInfo->domain
|
||||
},
|
||||
};
|
||||
|
||||
int32_t ret = HksAddParams(paramSet, params, sizeof(params) / sizeof(params[0]));
|
||||
HKS_IF_NOT_SUCC_LOGE(ret, "HksAddParams failed!")
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t AddStorageParams(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet *paramSet)
|
||||
{
|
||||
if (keyInfoBlob->size < sizeof(struct HksStoreKeyInfo)) {
|
||||
HKS_LOG_E("invalid keyInfoBlob, size too small, size = %" LOG_PUBLIC "u", keyInfoBlob->size);
|
||||
return HKS_ERROR_INVALID_KEY_INFO;
|
||||
}
|
||||
|
||||
struct HksStoreKeyInfo *keyInfo = (struct HksStoreKeyInfo *)keyInfoBlob->data;
|
||||
if (HksIsKeyInfoLenInvalid(keyInfo)) {
|
||||
HKS_LOG_E("invalid keyInfoBlob len");
|
||||
return HKS_ERROR_INVALID_KEY_INFO;
|
||||
}
|
||||
|
||||
int32_t ret = AddStorageFixedParams(keyInfo, paramSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "add storage fixed params failed!")
|
||||
|
||||
if (keyInfo->authIdSize != 0) {
|
||||
struct HksBlob keyAuthId = { keyInfo->authIdSize, keyInfoBlob->data + sizeof(*keyInfo) + keyInfo->aliasSize };
|
||||
struct HksParam keyAuthIdParam = {
|
||||
.tag = HKS_TAG_KEY_AUTH_ID,
|
||||
.blob = keyAuthId
|
||||
};
|
||||
ret = HksAddParams(paramSet, &keyAuthIdParam, 1);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksAddParams keyAuthId failed!")
|
||||
}
|
||||
|
||||
if (key != NULL) {
|
||||
struct HksParam keyParam = {
|
||||
.tag = HKS_TAG_KEY,
|
||||
.blob = *key
|
||||
};
|
||||
ret = HksAddParams(paramSet, &keyParam, 1);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksAddParams key failed!")
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t TranslateKeyInfoBlobToParamSet(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet **paramSet)
|
||||
{
|
||||
struct HksParamSet *outputParamSet = NULL;
|
||||
int32_t ret = HksInitParamSet(&outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksInitParamSet failed!")
|
||||
|
||||
do {
|
||||
ret = AddStorageParams(key, keyInfoBlob, outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_BREAK(ret, "AddParams failed!")
|
||||
|
||||
ret = HksBuildParamSet(&outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE(ret, "HksBuildParamSet failed!")
|
||||
} while (0);
|
||||
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HKS_LOG_E("ConstructParamSet failed.");
|
||||
HksFreeParamSet(&outputParamSet);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*paramSet = outputParamSet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
#endif /* _CUT_AUTHENTICATE_ */
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#ifndef _CUT_AUTHENTICATE_
|
||||
#ifdef _STORAGE_LITE_
|
||||
|
||||
#include "hks_storage_adapter.h"
|
||||
|
||||
#include "hks_log.h"
|
||||
#include "hks_param.h"
|
||||
#include "hks_template.h"
|
||||
|
||||
bool HksIsKeyInfoLenInvalid(struct HksStoreKeyInfo *keyInfo)
|
||||
{
|
||||
return (keyInfo->aliasSize > HKS_MAX_KEY_ALIAS_LEN) || (keyInfo->aliasSize == 0) ||
|
||||
(keyInfo->keySize > HKS_MAX_KEY_MATERIAL_LEN) || (keyInfo->keySize == 0) ||
|
||||
(keyInfo->authIdSize > HKS_MAX_KEY_AUTH_ID_LEN) ||
|
||||
(keyInfo->keyInfoLen != (sizeof(*keyInfo) + keyInfo->aliasSize + keyInfo->authIdSize + keyInfo->keySize));
|
||||
}
|
||||
|
||||
static int32_t AddStorageFixedParams(const struct HksStoreKeyInfo *keyInfo, struct HksParamSet *paramSet)
|
||||
{
|
||||
struct HksParam params[] = {
|
||||
{
|
||||
.tag = HKS_TAG_KEY_FLAG,
|
||||
.uint32Param = keyInfo->flag
|
||||
}, {
|
||||
.tag = HKS_TAG_ALGORITHM,
|
||||
.uint32Param = keyInfo->keyAlg
|
||||
}, {
|
||||
.tag = HKS_TAG_PURPOSE,
|
||||
.uint32Param = keyInfo->purpose
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_SIZE,
|
||||
.uint32Param = keyInfo->keyLen
|
||||
}, {
|
||||
.tag = HKS_TAG_DIGEST,
|
||||
.uint32Param = keyInfo->digest
|
||||
}, {
|
||||
.tag = HKS_TAG_PADDING,
|
||||
.uint32Param = keyInfo->padding
|
||||
}, {
|
||||
.tag = HKS_TAG_BLOCK_MODE,
|
||||
.uint32Param = keyInfo->keyMode
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_ROLE,
|
||||
.uint32Param = keyInfo->role
|
||||
}, {
|
||||
.tag = HKS_TAG_KEY_DOMAIN,
|
||||
.uint32Param = keyInfo->domain
|
||||
},
|
||||
};
|
||||
|
||||
int32_t ret = HksAddParams(paramSet, params, sizeof(params) / sizeof(params[0]));
|
||||
HKS_IF_NOT_SUCC_LOGE(ret, "HksAddParams failed!")
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t AddStorageParams(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet *paramSet)
|
||||
{
|
||||
if (keyInfoBlob->size < sizeof(struct HksStoreKeyInfo)) {
|
||||
HKS_LOG_E("invalid keyInfoBlob, size too small, size = %" LOG_PUBLIC "u", keyInfoBlob->size);
|
||||
return HKS_ERROR_INVALID_KEY_INFO;
|
||||
}
|
||||
|
||||
struct HksStoreKeyInfo *keyInfo = (struct HksStoreKeyInfo *)keyInfoBlob->data;
|
||||
if (HksIsKeyInfoLenInvalid(keyInfo)) {
|
||||
HKS_LOG_E("invalid keyInfoBlob len");
|
||||
return HKS_ERROR_INVALID_KEY_INFO;
|
||||
}
|
||||
|
||||
int32_t ret = AddStorageFixedParams(keyInfo, paramSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "add storage fixed params failed!")
|
||||
|
||||
if (keyInfo->authIdSize != 0) {
|
||||
struct HksBlob keyAuthId = { keyInfo->authIdSize, keyInfoBlob->data + sizeof(*keyInfo) + keyInfo->aliasSize };
|
||||
struct HksParam keyAuthIdParam = {
|
||||
.tag = HKS_TAG_KEY_AUTH_ID,
|
||||
.blob = keyAuthId
|
||||
};
|
||||
ret = HksAddParams(paramSet, &keyAuthIdParam, 1);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksAddParams keyAuthId failed!")
|
||||
}
|
||||
|
||||
if (key != NULL) {
|
||||
struct HksParam keyParam = {
|
||||
.tag = HKS_TAG_KEY,
|
||||
.blob = *key
|
||||
};
|
||||
ret = HksAddParams(paramSet, &keyParam, 1);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksAddParams key failed!")
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t TranslateKeyInfoBlobToParamSet(const struct HksBlob *key, const struct HksBlob *keyInfoBlob,
|
||||
struct HksParamSet **paramSet)
|
||||
{
|
||||
struct HksParamSet *outputParamSet = NULL;
|
||||
int32_t ret = HksInitParamSet(&outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_RETURN(ret, ret, "HksInitParamSet failed!")
|
||||
|
||||
do {
|
||||
ret = AddStorageParams(key, keyInfoBlob, outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE_BREAK(ret, "AddParams failed!")
|
||||
|
||||
ret = HksBuildParamSet(&outputParamSet);
|
||||
HKS_IF_NOT_SUCC_LOGE(ret, "HksBuildParamSet failed!")
|
||||
} while (0);
|
||||
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HKS_LOG_E("ConstructParamSet failed.");
|
||||
HksFreeParamSet(&outputParamSet);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*paramSet = outputParamSet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* _STORAGE_LITE_ */
|
||||
#endif /* _CUT_AUTHENTICATE_ */
|
File diff suppressed because it is too large
Load Diff
@ -376,6 +376,11 @@ int HksService::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
HKS_LOG_I("OnRemoteRequest code:%" LOG_PUBLIC "d, sessionId = %" LOG_PUBLIC "u", code, g_sessionId);
|
||||
|
||||
if (code < HksIpcInterfaceCode::HKS_MSG_BASE || code >= HksIpcInterfaceCode::HKS_MSG_MAX) {
|
||||
int32_t ret = RetryLoadPlugin();
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HksSendResponse(reinterpret_cast<const uint8_t *>(&reply), ret, nullptr);
|
||||
return HKS_SUCCESS; // send error code by IPC.
|
||||
}
|
||||
return HksPluginOnRemoteRequest(code, &data, &reply, &option);
|
||||
}
|
||||
// this is the temporary version which comments the descriptor check
|
||||
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t HksInitPluginProxy(void);
|
||||
|
||||
int32_t RetryLoadPlugin(void);
|
||||
int32_t HksPluginOnRemoteRequest(uint32_t code, void *data, void *reply, void *option);
|
||||
int32_t HksPluginOnLocalRequest(uint32_t code, const void *data, void *reply);
|
||||
void HksPluginOnReceiveEvent(const void *data);
|
||||
|
@ -95,7 +95,7 @@ ENABLE_CFI(static int32_t HksCreatePluginProxy(void))
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t RetryLoadPlugin(void)
|
||||
int32_t RetryLoadPlugin(void)
|
||||
{
|
||||
if (HksCreatePluginProxy() != HKS_SUCCESS) {
|
||||
HKS_LOG_E("Failed to create the plugin again.");
|
||||
@ -124,12 +124,6 @@ int32_t HksInitPluginProxy(void)
|
||||
|
||||
int32_t HksPluginOnRemoteRequest(uint32_t code, void *data, void *reply, void *option)
|
||||
{
|
||||
int32_t ret = RetryLoadPlugin();
|
||||
if (ret != HKS_SUCCESS) {
|
||||
HksSendResponse(reinterpret_cast<const uint8_t *>(&reply), ret, nullptr);
|
||||
return HKS_SUCCESS; // send error code by IPC.
|
||||
}
|
||||
|
||||
return g_pluginProxy->hksPluginOnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
|
@ -44,3 +44,8 @@ void HksPluginOnReceiveEvent(const void *data)
|
||||
{
|
||||
(void)(data);
|
||||
}
|
||||
|
||||
int32_t RetryLoadPlugin(void)
|
||||
{
|
||||
return HKS_SUCCESS;
|
||||
}
|
||||
|
@ -29,7 +29,10 @@ ohos_static_library("libhuks_upgrade_file_transfer_static") {
|
||||
"src/hks_file_transfer.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "../../core/include" ]
|
||||
include_dirs = [
|
||||
"../../core/include",
|
||||
"../../hks_storage/include",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../../../../../../frameworks/huks_standard/main/common:libhuks_common_standard_static",
|
||||
|
@ -27,6 +27,7 @@ ohos_fuzztest("HksRkcFuzzTest") {
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/src",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/utils/file_operator",
|
||||
]
|
||||
cflags = [
|
||||
|
@ -109,6 +109,7 @@ unittest("huks_3.0_test") {
|
||||
|
||||
deps = [
|
||||
"../../../../frameworks/huks_standard/main/crypto_engine/mbedtls:libhuks_mbedtls_small_static",
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine:libhuks_crypto_engine_small_static",
|
||||
"//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk",
|
||||
"//base/security/huks/test/unittest/huks_lite_test/common:huks_3.0_test_common",
|
||||
]
|
||||
|
@ -81,6 +81,7 @@ ohos_unittest("crypto_engine_unit_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/crypto_engine:libhuks_crypto_engine_standard_static",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_mem_standard_static",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_util_standard_static",
|
||||
|
@ -46,6 +46,7 @@ ohos_unittest("huks_module_test") {
|
||||
"//base/security/huks/test/unittest/huks_common_test/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/ipc", # hks_response.h
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/plugin_proxy/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
]
|
||||
|
||||
sources = []
|
||||
|
@ -29,6 +29,8 @@ config("public_huks_config") {
|
||||
"//base/security/huks/frameworks/huks_standard/main/core/include",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency/sysinfo/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/dcm/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough",
|
||||
"//base/security/huks/utils/crypto_adapter",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/systemapi_wrap/useridm/inc",
|
||||
@ -64,22 +66,22 @@ huks_sources = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency/posix/hks_mem.c",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency/sysinfo/src/hks_get_process_info_passthrough.c",
|
||||
"//base/security/huks/frameworks/huks_standard/main/os_dependency/sysinfo/src/hks_get_udid.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/src/hks_api.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/main/src/hks_api_adapter.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/source/hks_api.c",
|
||||
"//base/security/huks/interfaces/inner_api/huks_standard/source/hks_api_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_client_check.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_client_service.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_client_service_util.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_hitrace.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_report.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_session_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_upgrade_helper.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_upgrade_key_accesser.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_adapter.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/sa/hks_event_observer.cpp",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/plugin_proxy/src/hks_plugin_adapter_mock.c",
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "hks_type_inner.h"
|
||||
#include "hks_param.h"
|
||||
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c"
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace Unittest::HksStorageTest {
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "hks_storage_manager.h"
|
||||
#include "hks_storage_utils.h"
|
||||
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c"
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace Unittest::HksStorageManagerTest {
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "hks_storage_utils.h"
|
||||
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c"
|
||||
#include "base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace Unittest::HksStorageUtilTest {
|
||||
|
@ -21,11 +21,11 @@ ohos_unittest("huks_multithread_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c",
|
||||
"//base/security/huks/utils/file_operator/hks_file_operator.c",
|
||||
"//base/security/huks/utils/mutex/hks_mutex.c",
|
||||
@ -56,6 +56,7 @@ ohos_unittest("huks_multithread_test") {
|
||||
include_dirs = [
|
||||
"//base/security/huks/frameworks/huks_standard/main/common/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/core/include",
|
||||
"//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
|
||||
"//base/security/huks/utils/file_operator",
|
||||
"//base/security/huks/utils/mutex",
|
||||
"unittest/include",
|
||||
|
Loading…
Reference in New Issue
Block a user