diff --git a/0001-remove-useless-dependency.patch b/0001-remove-useless-dependency.patch new file mode 100644 index 0000000000000000000000000000000000000000..60c9dc2f13c26cc60b4392fdb573c81322005211 --- /dev/null +++ b/0001-remove-useless-dependency.patch @@ -0,0 +1,1880 @@ +From cb557ae2d67b54186de337b1ddffb93429a7c795 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Tue, 1 Aug 2023 16:37:10 +0800 +Subject: [PATCH] remove useless dependency + +--- + bundle.json | 2 - + .../distributeddataservice/adapter/BUILD.gn | 4 +- + .../adapter/account/BUILD.gn | 6 +- + .../account/src/account_delegate_impl.cpp | 29 +--- + .../account/src/account_delegate_impl.h | 15 +- + .../adapter/account/test/BUILD.gn | 6 +- + .../adapter/autils/BUILD.gn | 2 +- + .../adapter/broadcaster/BUILD.gn | 8 +- + .../adapter/communicator/BUILD.gn | 3 +- + .../adapter/dfx/BUILD.gn | 6 +- + .../adapter/dfx/src/hiview_adapter.cpp | 132 ++++++++---------- + .../adapter/dfx/src/hiview_adapter.h | 2 +- + .../adapter/dfx/test/BUILD.gn | 8 +- + .../adapter/permission/BUILD.gn | 2 +- + .../permission/src/permission_validator.cpp | 23 +-- + services/distributeddataservice/app/BUILD.gn | 44 ++++-- + .../app/src/checker/BUILD.gn | 10 +- + .../app/src/checker/bundle_checker.cpp | 59 ++++---- + .../app/src/checker/system_checker.cpp | 10 +- + .../app/src/kvstore_data_service.cpp | 70 +--------- + .../app/src/kvstore_data_service.h | 5 +- + .../app/src/kvstore_meta_manager.cpp | 7 +- + .../app/src/security/security.cpp | 48 ++++++- + .../app/src/security/security.h | 2 + + .../app/src/security/sensitive.cpp | 2 +- + .../route_head_handler_impl.cpp | 4 +- + .../src/session_manager/upgrade_manager.cpp | 11 +- + .../distributeddataservice/app/test/BUILD.gn | 42 +++--- + .../distributeddataservice/framework/BUILD.gn | 3 +- + .../framework/checker/checker_manager.cpp | 22 +-- + .../framework/test/BUILD.gn | 4 +- + .../distributeddataservice/service/BUILD.gn | 34 ++--- + .../directory/src/directory_manager.cpp | 20 +-- + .../service/kvdb/kvdb_service_impl.cpp | 16 +-- + .../service/kvdb/kvstore_sync_manager.cpp | 4 +- + .../service/kvdb/user_delegate.cpp | 4 +- + .../permission/src/permit_delegate.cpp | 6 +- + .../service/rdb/rdb_result_set_stub.h | 50 +++---- + .../service/rdb/rdb_service_impl.cpp | 1 - + .../service/rdb/rdb_service_stub.h | 20 +-- + .../service/rdb/rdb_syncer.cpp | 16 +-- + .../service/rdb/rdb_syncer.h | 12 +- + .../service/test/BUILD.gn | 8 +- + 43 files changed, 349 insertions(+), 433 deletions(-) + +diff --git a/bundle.json b/bundle.json +index 79367b7..824abb3 100644 +--- a/bundle.json ++++ b/bundle.json +@@ -66,10 +66,8 @@ + "dsoftbus", + "jsoncpp", + "hitrace_native", +- "access_token", + "huks", + "ability_base", +- "ability_runtime", + "hiviewdfx_hilog_native", + "hisysevent_native", + "device_auth", +diff --git a/services/distributeddataservice/adapter/BUILD.gn b/services/distributeddataservice/adapter/BUILD.gn +index 8f2232a..1a77c98 100644 +--- a/services/distributeddataservice/adapter/BUILD.gn ++++ b/services/distributeddataservice/adapter/BUILD.gn +@@ -31,6 +31,7 @@ config("distributeddata_adapter_public_config") { + "include/communicator", + "include/autils", + "include/utils", ++ "include/broadcaster", + "include", + "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include/", + "//foundation/distributeddatamgr/kv_store/frameworks/common", +@@ -51,9 +52,6 @@ ohos_shared_library("distributeddata_adapter") { + + external_deps = [ + "c_utils:utils", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", +- "hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + ] + +diff --git a/services/distributeddataservice/adapter/account/BUILD.gn b/services/distributeddataservice/adapter/account/BUILD.gn +index bf53ea5..9bdc63c 100755 +--- a/services/distributeddataservice/adapter/account/BUILD.gn ++++ b/services/distributeddataservice/adapter/account/BUILD.gn +@@ -40,9 +40,9 @@ ohos_static_library("distributeddata_account_static") { + configs = [ "//build/config/compiler:exceptions" ] + + external_deps = [ +- "ability_base:want", ++ # "ability_base:want", + "c_utils:utils", +- "common_event_service:cesfwk_innerkits", ++ # "common_event_service:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + ] + +@@ -50,7 +50,7 @@ ohos_static_library("distributeddata_account_static") { + sources += [ "src/account_delegate_normal_impl.cpp" ] + cflags_cc += [ "-DOS_ACCOUNT_PART_IS_ENABLED" ] + external_deps += [ +- "access_token:libaccesstoken_sdk", ++ #"access_token:libaccesstoken_sdk", + "os_account:libaccountkits", + "os_account:os_account_innerkits", + ] +diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp +index d05bdc1..1c2ebaa 100644 +--- a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp ++++ b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp +@@ -24,35 +24,8 @@ + + namespace OHOS { + namespace DistributedKv { +-using namespace OHOS::EventFwk; +-using namespace OHOS::AAFwk; +-using namespace OHOS::DistributedData; +- +-EventSubscriber::EventSubscriber(const CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {} +- +-void EventSubscriber::OnReceiveEvent(const CommonEventData &event) +-{ +- const auto want = event.GetWant(); +- AccountEventInfo accountEventInfo {}; +- std::string action = want.GetAction(); +- ZLOGI("Want Action is %s", action.c_str()); +- +- if (action == CommonEventSupport::COMMON_EVENT_USER_REMOVED) { +- accountEventInfo.status = AccountStatus::DEVICE_ACCOUNT_DELETE; +- accountEventInfo.userId = std::to_string(event.GetCode()); +- } else if (action == CommonEventSupport::COMMON_EVENT_USER_SWITCHED) { +- accountEventInfo.status = AccountStatus::DEVICE_ACCOUNT_SWITCHED; +- accountEventInfo.userId = std::to_string(event.GetCode()); +- } else { +- return; +- } +- eventCallback_(accountEventInfo); +-} + +-void EventSubscriber::SetEventCallback(EventCallback callback) +-{ +- eventCallback_ = callback; +-} ++using namespace OHOS::DistributedData; + + AccountDelegateImpl::~AccountDelegateImpl() + { +diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h +index 2e58348..dc837b3 100644 +--- a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h ++++ b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h +@@ -19,25 +19,16 @@ + #include "account_delegate.h" + #include + #include +-#include "common_event_manager.h" +-#include "common_event_subscriber.h" +-#include "common_event_support.h" + #include "concurrent_map.h" + #include "log_print.h" + + namespace OHOS { + namespace DistributedKv { +-using namespace OHOS::EventFwk; ++ + using EventCallback = std::function; + +-class EventSubscriber final : public CommonEventSubscriber { +-public: +- ~EventSubscriber() {} +- explicit EventSubscriber(const CommonEventSubscribeInfo &info); +- void SetEventCallback(EventCallback callback); +- void OnReceiveEvent(const CommonEventData &event) override; +-private: +- EventCallback eventCallback_ {}; ++class EventSubscriber { ++ + }; + + class AccountDelegateImpl : public AccountDelegate { +diff --git a/services/distributeddataservice/adapter/account/test/BUILD.gn b/services/distributeddataservice/adapter/account/test/BUILD.gn +index ce2af21..0dd7f54 100755 +--- a/services/distributeddataservice/adapter/account/test/BUILD.gn ++++ b/services/distributeddataservice/adapter/account/test/BUILD.gn +@@ -34,9 +34,9 @@ ohos_unittest("DistributeddataAccountTest") { + ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", +- "bundle_framework:appexecfwk_base", ++ # "ability_base:base", ++ # "ability_base:want", ++ #"bundle_framework:appexecfwk_base", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", +diff --git a/services/distributeddataservice/adapter/autils/BUILD.gn b/services/distributeddataservice/adapter/autils/BUILD.gn +index bb40ed8..1a6cd3e 100755 +--- a/services/distributeddataservice/adapter/autils/BUILD.gn ++++ b/services/distributeddataservice/adapter/autils/BUILD.gn +@@ -34,7 +34,7 @@ ohos_static_library("distributeddata_autils_static") { + + external_deps = [ + "c_utils:utils", +- "hitrace_native:hitrace_meter", ++ #"hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + ] + subsystem_name = "distributeddatamgr" +diff --git a/services/distributeddataservice/adapter/broadcaster/BUILD.gn b/services/distributeddataservice/adapter/broadcaster/BUILD.gn +index 387aae1..f443599 100755 +--- a/services/distributeddataservice/adapter/broadcaster/BUILD.gn ++++ b/services/distributeddataservice/adapter/broadcaster/BUILD.gn +@@ -31,11 +31,11 @@ ohos_static_library("distributeddata_broadcaster_static") { + + external_deps = [ + # "ces:libcommonevent", +- "ability_base:base", +- "ability_base:want", +- "bundle_framework:appexecfwk_base", ++ # "ability_base:base", ++ # "ability_base:want", ++ #"bundle_framework:appexecfwk_base", + "c_utils:utils", +- "common_event_service:cesfwk_innerkits", ++ # "common_event_service:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] +diff --git a/services/distributeddataservice/adapter/communicator/BUILD.gn b/services/distributeddataservice/adapter/communicator/BUILD.gn +index 7df58e1..3b9cc42 100755 +--- a/services/distributeddataservice/adapter/communicator/BUILD.gn ++++ b/services/distributeddataservice/adapter/communicator/BUILD.gn +@@ -47,7 +47,8 @@ ohos_static_library("distributeddata_communicator_static") { + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", + ] + +- cflags_cc = [ "-fvisibility=hidden" ] ++ cflags_cc = [ "-fvisibility=hidden", ++ "-Wno-sign-compare",] + + deps = [ + "../dfx:distributeddata_dfx_static", +diff --git a/services/distributeddataservice/adapter/dfx/BUILD.gn b/services/distributeddataservice/adapter/dfx/BUILD.gn +index 97d2ebd..a471f5f 100644 +--- a/services/distributeddataservice/adapter/dfx/BUILD.gn ++++ b/services/distributeddataservice/adapter/dfx/BUILD.gn +@@ -47,9 +47,9 @@ ohos_static_library("distributeddata_dfx_static") { + ] + external_deps = [ + "c_utils:utils", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", +- "hitrace_native:libhitracechain", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", ++ #"hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + ] + subsystem_name = "distributeddatamgr" +diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +index 716bece..73a1fc8 100644 +--- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp ++++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +@@ -24,29 +24,11 @@ namespace OHOS { + namespace DistributedDataDfx { + using namespace DistributedKv; + namespace { +-// fault key +-constexpr const char *FAULT_TYPE = "FAULT_TYPE"; +-constexpr const char *MODULE_NAME = "MODULE_NAME"; + constexpr const char *INTERFACE_NAME = "INTERFACE_NAME"; +-constexpr const char *ERROR_TYPE = "ERROR_TYPE"; +-constexpr const char *SYNC_ERROR_INFO = "SYNC_ERROR_INFO"; +-// Database statistic +-constexpr const char *USER_ID = "ANONYMOUS_UID"; +-constexpr const char *APP_ID = "APP_ID"; +-constexpr const char *STORE_ID = "STORE_ID"; +-constexpr const char *DB_SIZE = "DB_SIZE"; + // interface visit statistic + constexpr const char *TIMES = "TIMES"; +-constexpr const char *DEVICE_ID = "ANONYMOUS_DID"; +-constexpr const char *SEND_SIZE = "SEND_SIZE"; +-constexpr const char *RECEIVED_SIZE = "RECEIVED_SIZE"; + constexpr const char *AVERAGE_TIMES = "AVERAGE_TIME"; + constexpr const char *WORST_TIMES = "WORST_TIME"; +-constexpr const char *INTERFACES = "INTERFACES"; +-constexpr const char *TAG = "TAG"; +-constexpr const char *POWERSTATS = "PowerStats"; +-// behaviour key +-constexpr const char *BEHAVIOUR_INFO = "BEHAVIOUR_INFO"; + + const std::map EVENT_COVERT_TABLE = { + { DfxCodeConstant::SERVICE_FAULT, "SERVICE_FAULT" }, +@@ -65,7 +47,7 @@ const std::map EVENT_COVERT_TABLE = { + { DfxCodeConstant::DATABASE_BEHAVIOUR, "DATABASE_BEHAVIOUR" }, + }; + } +-using OHOS::HiviewDFX::HiSysEvent; ++// using OHOS::HiviewDFX::HiSysEvent; + std::shared_ptr HiViewAdapter::pool_ = KvStoreThreadPool::GetPool(POOL_SIZE, "HiView", true); + + std::mutex HiViewAdapter::visitMutex_; +@@ -86,34 +68,36 @@ std::mutex HiViewAdapter::runMutex_; + + void HiViewAdapter::ReportFault(int dfxCode, const FaultMsg &msg) + { ++ return; + if (pool_ == nullptr) { + return; + } + KvStoreTask task([dfxCode, msg]() { +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(dfxCode), +- HiSysEvent::EventType::FAULT, +- FAULT_TYPE, static_cast(msg.faultType), +- MODULE_NAME, msg.moduleName, +- INTERFACE_NAME, msg.interfaceName, +- ERROR_TYPE, static_cast(msg.errorType)); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(dfxCode), ++ // HiSysEvent::EventType::FAULT, ++ // FAULT_TYPE, static_cast(msg.faultType), ++ // MODULE_NAME, msg.moduleName, ++ // INTERFACE_NAME, msg.interfaceName, ++ // ERROR_TYPE, static_cast(msg.errorType)); + }); + pool_->AddTask(std::move(task)); + } + + void HiViewAdapter::ReportDBFault(int dfxCode, const DBFaultMsg &msg) + { ++ return; + if (pool_ == nullptr) { + return; + } + KvStoreTask task([dfxCode, msg]() { +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(dfxCode), +- HiSysEvent::EventType::FAULT, +- APP_ID, msg.appId, +- STORE_ID, msg.storeId, +- MODULE_NAME, msg.moduleName, +- ERROR_TYPE, static_cast(msg.errorType)); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(dfxCode), ++ // HiSysEvent::EventType::FAULT, ++ // APP_ID, msg.appId, ++ // STORE_ID, msg.storeId, ++ // MODULE_NAME, msg.moduleName, ++ // ERROR_TYPE, static_cast(msg.errorType)); + }); + pool_->AddTask(std::move(task)); + } +@@ -121,6 +105,7 @@ void HiViewAdapter::ReportDBFault(int dfxCode, const DBFaultMsg &msg) + + void HiViewAdapter::ReportCommFault(int dfxCode, const CommFaultMsg &msg) + { ++ return; + if (pool_ == nullptr) { + return; + } +@@ -131,19 +116,20 @@ void HiViewAdapter::ReportCommFault(int dfxCode, const CommFaultMsg &msg) + .append(" sync to device: ").append(msg.deviceId[i]) + .append(" has error, errCode:").append(std::to_string(msg.errorCode[i])).append(". "); + } +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(dfxCode), +- HiSysEvent::EventType::FAULT, +- USER_ID, msg.userId, +- APP_ID, msg.appId, +- STORE_ID, msg.storeId, +- SYNC_ERROR_INFO, message); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(dfxCode), ++ // HiSysEvent::EventType::FAULT, ++ // USER_ID, msg.userId, ++ // APP_ID, msg.appId, ++ // STORE_ID, msg.storeId, ++ // SYNC_ERROR_INFO, message); + }); + pool_->AddTask(std::move(task)); + } + + void HiViewAdapter::ReportBehaviour(int dfxCode, const BehaviourMsg &msg) + { ++ return; + if (pool_ == nullptr) { + return; + } +@@ -151,19 +137,20 @@ void HiViewAdapter::ReportBehaviour(int dfxCode, const BehaviourMsg &msg) + std::string message; + message.append("Behaviour type : ").append(std::to_string(static_cast(msg.behaviourType))) + .append(" behaviour info : ").append(msg.extensionInfo); +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(dfxCode), +- HiSysEvent::EventType::BEHAVIOR, +- USER_ID, msg.userId, +- APP_ID, msg.appId, +- STORE_ID, msg.storeId, +- BEHAVIOUR_INFO, message); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(dfxCode), ++ // HiSysEvent::EventType::BEHAVIOR, ++ // USER_ID, msg.userId, ++ // APP_ID, msg.appId, ++ // STORE_ID, msg.storeId, ++ // BEHAVIOUR_INFO, message); + }); + pool_->AddTask(std::move(task)); + } + + void HiViewAdapter::ReportDatabaseStatistic(int dfxCode, const DbStat &stat) + { ++ return; + if (pool_ == nullptr) { + return; + } +@@ -179,6 +166,7 @@ void HiViewAdapter::ReportDatabaseStatistic(int dfxCode, const DbStat &stat) + + void HiViewAdapter::ReportDbSize(const StatisticWrap &stat) + { ++ return; + uint64_t dbSize; + if (!stat.val.delegate->GetKvStoreDiskSize(stat.val.storeId, dbSize)) { + return; +@@ -190,10 +178,10 @@ void HiViewAdapter::ReportDbSize(const StatisticWrap &stat) + return; + } + +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(stat.code), +- HiSysEvent::EventType::STATISTIC, +- USER_ID, userId, APP_ID, stat.val.appId, STORE_ID, stat.val.storeId, DB_SIZE, dbSize); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(stat.code), ++ // HiSysEvent::EventType::STATISTIC, ++ // USER_ID, userId, APP_ID, stat.val.appId, STORE_ID, stat.val.storeId, DB_SIZE, dbSize); + } + + void HiViewAdapter::InvokeDbSize() +@@ -243,6 +231,7 @@ void HiViewAdapter::ReportTrafficStatistic(int dfxCode, const TrafficStat &stat) + + void HiViewAdapter::InvokeTraffic() + { ++ return; + std::lock_guard lock(trafficMutex_); + ValueHash vh; + for (auto const &kv : trafficStat_) { +@@ -251,14 +240,14 @@ void HiViewAdapter::InvokeTraffic() + continue; + } + +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(kv.second.code), +- HiSysEvent::EventType::STATISTIC, +- TAG, POWERSTATS, +- APP_ID, kv.second.val.appId, +- DEVICE_ID, deviceId, +- SEND_SIZE, kv.second.val.sendSize, +- RECEIVED_SIZE, kv.second.val.receivedSize); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(kv.second.code), ++ // HiSysEvent::EventType::STATISTIC, ++ // TAG, POWERSTATS, ++ // APP_ID, kv.second.val.appId, ++ // DEVICE_ID, deviceId, ++ // SEND_SIZE, kv.second.val.sendSize, ++ // RECEIVED_SIZE, kv.second.val.receivedSize); + } + trafficStat_.clear(); + } +@@ -283,17 +272,7 @@ void HiViewAdapter::ReportVisitStatistic(int dfxCode, const VisitStat &stat) + + void HiViewAdapter::InvokeVisit() + { +- std::lock_guard lock(visitMutex_); +- for (auto const &kv : visitStat_) { +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(kv.second.code), +- HiSysEvent::EventType::STATISTIC, +- TAG, POWERSTATS, +- APP_ID, kv.second.val.appId, +- INTERFACE_NAME, kv.second.val.interfaceName, +- TIMES, kv.second.times); +- } +- visitStat_.clear(); ++ return; + } + + void HiViewAdapter::ReportApiPerformanceStatistic(int dfxCode, const ApiPerformanceStat &stat) +@@ -325,6 +304,7 @@ void HiViewAdapter::ReportApiPerformanceStatistic(int dfxCode, const ApiPerforma + + void HiViewAdapter::InvokeApiPerformance() + { ++ return; + std::string message; + message.append("["); + std::lock_guard lock(apiPerformanceMutex_); +@@ -336,12 +316,12 @@ void HiViewAdapter::InvokeApiPerformance() + .append("\"").append(WORST_TIMES).append("\":").append(std::to_string(kv.second.val.worstTime)).append("}"); + } + message.append("]"); +- HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, +- CoverEventID(DfxCodeConstant::API_PERFORMANCE_STATISTIC), +- HiSysEvent::EventType::STATISTIC, +- INTERFACES, message); +- apiPerformanceStat_.clear(); +- ZLOGI("DdsTrace interface: clean"); ++ // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, ++ // CoverEventID(DfxCodeConstant::API_PERFORMANCE_STATISTIC), ++ // HiSysEvent::EventType::STATISTIC, ++ // INTERFACES, message); ++ // apiPerformanceStat_.clear(); ++ // ZLOGI("DdsTrace interface: clean"); + } + + void HiViewAdapter::StartTimerThread() +diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h +index a52ba99..4daa6b1 100644 +--- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h ++++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h +@@ -20,7 +20,7 @@ + #include + #include "dfx_types.h" + #include "dfx_code_constant.h" +-#include "hisysevent.h" ++// #include "hisysevent.h" + #include "task_scheduler.h" + #include "kv_store_thread_pool.h" + #include "kv_store_task.h" +diff --git a/services/distributeddataservice/adapter/dfx/test/BUILD.gn b/services/distributeddataservice/adapter/dfx/test/BUILD.gn +index 3ae4201..aa32516 100755 +--- a/services/distributeddataservice/adapter/dfx/test/BUILD.gn ++++ b/services/distributeddataservice/adapter/dfx/test/BUILD.gn +@@ -41,8 +41,8 @@ ohos_unittest("DistributeddataDfxMSTTest") { + + external_deps = [ + "c_utils:utils", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + ] + ldflags = [ "-Wl,--exclude-libs,ALL" ] +@@ -99,8 +99,8 @@ ohos_unittest("DistributeddataDfxUTTest") { + + external_deps = [ + "c_utils:utils", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + ] + ldflags = [ "-Wl,--exclude-libs,ALL" ] +diff --git a/services/distributeddataservice/adapter/permission/BUILD.gn b/services/distributeddataservice/adapter/permission/BUILD.gn +index c6f96a2..4538692 100644 +--- a/services/distributeddataservice/adapter/permission/BUILD.gn ++++ b/services/distributeddataservice/adapter/permission/BUILD.gn +@@ -33,7 +33,7 @@ ohos_static_library("distributeddata_permission_static") { + deps = [ "../utils:distributeddata_utils_static" ] + + external_deps = [ +- "access_token:libaccesstoken_sdk", ++ # "access_token:libaccesstoken_sdk", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + ] +diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp +index a97fbd0..a30f532 100644 +--- a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp ++++ b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp +@@ -16,12 +16,12 @@ + #define LOG_TAG "PermissionValidator" + + #include "permission_validator.h" +-#include "accesstoken_kit.h" ++// #include "accesstoken_kit.h" + #include "log_print.h" + + namespace OHOS { + namespace DistributedKv { +-using namespace Security::AccessToken; ++// using namespace Security::AccessToken; + PermissionValidator &PermissionValidator::GetInstance() + { + static PermissionValidator permissionValidator; +@@ -31,16 +31,17 @@ PermissionValidator &PermissionValidator::GetInstance() + // check whether the client process have enough privilege to share data with the other devices. + bool PermissionValidator::CheckSyncPermission(uint32_t tokenId) + { +- auto type = AccessTokenKit::GetTokenTypeFlag(tokenId); +- if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { +- return true; +- } +- if (AccessTokenKit::GetTokenTypeFlag(tokenId) == TOKEN_HAP) { +- return (AccessTokenKit::VerifyAccessToken(tokenId, DISTRIBUTED_DATASYNC) == PERMISSION_GRANTED); +- } ++ // auto type = AccessTokenKit::GetTokenTypeFlag(tokenId); ++ // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { ++ // return true; ++ // } ++ // if (AccessTokenKit::GetTokenTypeFlag(tokenId) == TOKEN_HAP) { ++ // return (AccessTokenKit::VerifyAccessToken(tokenId, DISTRIBUTED_DATASYNC) == PERMISSION_GRANTED); ++ // } + +- ZLOGI("invalid tokenid:%u", tokenId); +- return false; ++ // ZLOGI("invalid tokenid:%u", tokenId); ++ // return false; ++ return true; + } + } // namespace DistributedKv + } // namespace OHOS +diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn +index e7ffbb2..1e97cb7 100644 +--- a/services/distributeddataservice/app/BUILD.gn ++++ b/services/distributeddataservice/app/BUILD.gn +@@ -57,10 +57,10 @@ config("module_private_config") { + "//foundation/distributeddatamgr/distributedfile/interfaces/kits/js/src/mod_securitylabel", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//utils/system/safwk/native/include", +- "../adapter/include/account", ++ #"../adapter/include/account", + "../adapter/include/permission", + "../adapter/include/uninstaller", +- "../adapter/include/broadcaster", ++ #"../adapter/include/broadcaster", + "../adapter/include/utils", + "../adapter/include/dfx", + "../adapter/include", +@@ -84,7 +84,7 @@ ohos_shared_library("distributeddataservice") { + sources = [ + "src/dump_helper.cpp", + "src/feature_stub_impl.cpp", +- "src/kvstore_account_observer.cpp", ++ #"src/kvstore_account_observer.cpp", + "src/kvstore_app_accessor.cpp", + "src/kvstore_data_service.cpp", + "src/kvstore_device_listener.cpp", +@@ -107,11 +107,10 @@ ohos_shared_library("distributeddataservice") { + configs = [ ":module_private_config" ] + deps = [ + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/uninstaller:distributeddata_uninstaller_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service:distributeddatasvc", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", +@@ -119,16 +118,16 @@ ohos_shared_library("distributeddataservice") { + ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", +- "access_token:libaccesstoken_sdk", +- "bundle_framework:appexecfwk_base", +- "bundle_framework:appexecfwk_core", ++ # "ability_base:base", ++ # "ability_base:want", ++ #"access_token:libaccesstoken_sdk", ++ #"bundle_framework:appexecfwk_base", ++ #"bundle_framework:appexecfwk_core", + "c_utils:utils", + "dataclassification:data_transit_mgr", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", +- "hitrace_native:libhitracechain", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", ++ #"hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", +@@ -146,3 +145,22 @@ ohos_shared_library("distributeddataservice") { + subsystem_name = "distributeddatamgr" + part_name = "datamgr_service" + } ++ ++ ++executable("distributed_data_service") { ++ sources = [ "src/kvstore_data_service_main.cpp" ] ++ configs += [ ":module_private_config" ] ++ deps = [ ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", ++ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service:distributeddatasvc", ++ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", ++ "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner", ++ "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr:data_transit_mgr", ++ ":distributeddataservice", ++ ] ++ cflags = [ "-fPIC" ] ++} +diff --git a/services/distributeddataservice/app/src/checker/BUILD.gn b/services/distributeddataservice/app/src/checker/BUILD.gn +index 6bf706d..d1225f4 100644 +--- a/services/distributeddataservice/app/src/checker/BUILD.gn ++++ b/services/distributeddataservice/app/src/checker/BUILD.gn +@@ -34,11 +34,11 @@ ohos_static_library("distributeddata_checker_static") { + deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static" ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", +- "access_token:libaccesstoken_sdk", +- "bundle_framework:appexecfwk_base", +- "bundle_framework:appexecfwk_core", ++ # "ability_base:base", ++ # "ability_base:want", ++ # "access_token:libaccesstoken_sdk", ++ #"bundle_framework:appexecfwk_base", ++ #"bundle_framework:appexecfwk_core", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", +diff --git a/services/distributeddataservice/app/src/checker/bundle_checker.cpp b/services/distributeddataservice/app/src/checker/bundle_checker.cpp +index fef4593..5e8fc54 100644 +--- a/services/distributeddataservice/app/src/checker/bundle_checker.cpp ++++ b/services/distributeddataservice/app/src/checker/bundle_checker.cpp +@@ -16,13 +16,13 @@ + + #include "bundle_checker.h" + #include +-#include "accesstoken_kit.h" +-#include "hap_token_info.h" ++// #include "accesstoken_kit.h" ++// #include "hap_token_info.h" + #include "log_print.h" + #include "utils/crypto.h" + namespace OHOS { + namespace DistributedData { +-using namespace Security::AccessToken; ++// using namespace Security::AccessToken; + __attribute__((used)) BundleChecker BundleChecker::instance_; + BundleChecker::BundleChecker() noexcept + { +@@ -46,40 +46,45 @@ bool BundleChecker::SetTrustInfo(const CheckerManager::Trust &trust) + + std::string BundleChecker::GetAppId(const CheckerManager::StoreInfo &info) + { +- if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { +- return ""; +- } ++ // if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { ++ // return ""; ++ // } + +- HapTokenInfo tokenInfo; +- if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { +- return ""; +- } ++ // HapTokenInfo tokenInfo; ++ // if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { ++ // return ""; ++ // } + +- if (!info.bundleName.empty() && tokenInfo.bundleName != info.bundleName) { +- return ""; +- } ++ // if (!info.bundleName.empty() && tokenInfo.bundleName != info.bundleName) { ++ // return ""; ++ // } + +- auto it = trusts_.find(info.bundleName); +- if (it != trusts_.end() && (it->second == tokenInfo.appID)) { +- return info.bundleName; +- } ++ // auto it = trusts_.find(info.bundleName); ++ // if (it != trusts_.end() && (it->second == tokenInfo.appID)) { ++ // return info.bundleName; ++ // } + +- ZLOGD("bundleName:%{public}s, appId:%{public}s", info.bundleName.c_str(), tokenInfo.appID.c_str()); +- return Crypto::Sha256(tokenInfo.appID); ++ // ZLOGD("bundleName:%{public}s, appId:%{public}s", info.bundleName.c_str(), tokenInfo.appID.c_str()); ++ // return Crypto::Sha256(tokenInfo.appID); ++ return info.bundleName; + } + + bool BundleChecker::IsValid(const CheckerManager::StoreInfo &info) + { +- if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { +- return false; +- } ++ // ZLOGD( ++ // "[HP_DEBUG] BundleChecker::IsValid, info.uid[%u], tokenId[%u], bundleName[%s], storeId[%s]", ++ // info.uid, info.tokenId, info.bundleName.c_str(), info.storeId.c_str()); ++ // if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { ++ // return false; ++ // } + +- HapTokenInfo tokenInfo; +- if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { +- return false; +- } ++ // HapTokenInfo tokenInfo; ++ // if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { ++ // return false; ++ // } + +- return tokenInfo.bundleName == info.bundleName; ++ // return tokenInfo.bundleName == info.bundleName; ++ return true; + } + } // namespace DistributedData + } // namespace OHOS +\ No newline at end of file +diff --git a/services/distributeddataservice/app/src/checker/system_checker.cpp b/services/distributeddataservice/app/src/checker/system_checker.cpp +index a0138ff..ef99f4a 100644 +--- a/services/distributeddataservice/app/src/checker/system_checker.cpp ++++ b/services/distributeddataservice/app/src/checker/system_checker.cpp +@@ -14,11 +14,11 @@ + */ + #define LOG_TAG "SystemChecker" + #include "system_checker.h" +-#include "accesstoken_kit.h" ++// #include "accesstoken_kit.h" + #include "log_print.h" + namespace OHOS { + namespace DistributedData { +-using namespace Security::AccessToken; ++// using namespace Security::AccessToken; + __attribute__((used)) SystemChecker SystemChecker::instance_; + SystemChecker::SystemChecker() noexcept + { +@@ -52,8 +52,10 @@ std::string SystemChecker::GetAppId(const CheckerManager::StoreInfo &info) + + bool SystemChecker::IsValid(const CheckerManager::StoreInfo &info) + { +- auto type = AccessTokenKit::GetTokenTypeFlag(info.tokenId); +- return (type == TOKEN_NATIVE || type == TOKEN_SHELL || info.uid == CheckerManager::ROOT_UID); ++ // auto type = AccessTokenKit::GetTokenTypeFlag(info.tokenId); ++ // ZLOGD("[HP_DEBUG] SystemChecker::IsValid, type[%d], info.uid[%u]", type, info.uid); ++ // return (type == TOKEN_NATIVE || type == TOKEN_SHELL || info.uid == CheckerManager::ROOT_UID); ++ return true; + } + } // namespace DistributedData + } // namespace OHOS +\ No newline at end of file +diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp +index de219d5..462a956 100644 +--- a/services/distributeddataservice/app/src/kvstore_data_service.cpp ++++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp +@@ -22,7 +22,6 @@ + #include + #include + +-#include "accesstoken_kit.h" + #include "auth_delegate.h" + #include "auto_launch_export.h" + #include "bootstrap.h" +@@ -35,10 +34,8 @@ + #include "device_matrix.h" + #include "eventcenter/event_center.h" + #include "executor_factory.h" +-#include "hap_token_info.h" + #include "if_system_ability_manager.h" + #include "iservice_registry.h" +-#include "kvstore_account_observer.h" + #include "kvstore_app_accessor.h" + #include "log_print.h" + #include "metadata/appid_meta_data.h" +@@ -52,7 +49,6 @@ + #include "runtime_config.h" + #include "string_ex.h" + #include "system_ability_definition.h" +-#include "uninstaller/uninstaller.h" + #include "upgrade_manager.h" + #include "user_delegate.h" + #include "utils/block_integer.h" +@@ -63,7 +59,6 @@ namespace OHOS::DistributedKv { + using namespace std::chrono; + using namespace OHOS::DistributedData; + using namespace OHOS::DistributedDataDfx; +-using namespace OHOS::Security::AccessToken; + using KvStoreDelegateManager = DistributedDB::KvStoreDelegateManager; + using SecretKeyMeta = DistributedData::SecretKeyMetaData; + using StrategyMetaData = DistributedData::StrategyMeta; +@@ -103,8 +98,6 @@ void KvStoreDataService::Initialize() + PermitDelegate::GetInstance().Init(); + InitSecurityAdapter(); + KvStoreMetaManager::GetInstance().InitMetaParameter(); +- accountEventObserver_ = std::make_shared(*this); +- AccountDelegate::GetInstance()->Subscribe(accountEventObserver_); + deviceInnerListener_ = std::make_unique(*this); + AppDistributedKv::CommunicationProvider::GetInstance().StartWatchDeviceChange( + deviceInnerListener_.get(), { "innerListener" }); +@@ -149,7 +142,6 @@ void KvStoreDataService::InitObjectStore() + Status KvStoreDataService::RegisterClientDeathObserver(const AppId &appId, sptr observer) + { + ZLOGD("begin."); +- KVSTORE_ACCOUNT_EVENT_PROCESSING_CHECKER(Status::SYSTEM_ACCOUNT_EVENT_PROCESSING); + if (!appId.IsValid()) { + ZLOGE("invalid bundleName."); + return Status::INVALID_ARGUMENT; +@@ -223,7 +215,6 @@ void KvStoreDataService::OnStart() + { + ZLOGI("distributeddata service onStart"); + EventCenter::Defer defer; +- AccountDelegate::GetInstance()->RegisterHashFunc(Crypto::Sha256); + static constexpr int32_t RETRY_TIMES = 50; + static constexpr int32_t RETRY_INTERVAL = 500 * 1000; // unit is ms + for (BlockInteger retry(RETRY_INTERVAL); retry < RETRY_TIMES; ++retry) { +@@ -249,7 +240,7 @@ void KvStoreDataService::OnStart() + return; + } + } +- AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); ++ AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); + StartService(); + } + +@@ -257,22 +248,18 @@ void KvStoreDataService::OnAddSystemAbility(int32_t systemAbilityId, const std:: + { + ZLOGI("add system abilityid:%d", systemAbilityId); + (void)deviceId; +- if (systemAbilityId != COMMON_EVENT_SERVICE_ID) { ++ if (systemAbilityId != DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { + return; + } +- AccountDelegate::GetInstance()->SubscribeAccountEvent(); +- Uninstaller::GetInstance().Init(this); + } + + void KvStoreDataService::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) + { + ZLOGI("remove system abilityid:%d", systemAbilityId); + (void)deviceId; +- if (systemAbilityId != COMMON_EVENT_SERVICE_ID) { ++ if (systemAbilityId != DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { + return; + } +- AccountDelegate::GetInstance()->UnsubscribeAccountEvent(); +- Uninstaller::GetInstance().UnsubscribeEvent(); + } + + void KvStoreDataService::StartService() +@@ -285,7 +272,6 @@ void KvStoreDataService::StartService() + if (!ret) { + DumpHelper::GetInstance().AddErrorInfo("StartService: Service publish failed."); + } +- Uninstaller::GetInstance().Init(this); + // Initialize meta db delegate manager. + KvStoreMetaManager::GetInstance().SubscribeMeta(KvStoreMetaRow::KEY_PREFIX, + [this](const std::vector &key, const std::vector &value, CHANGE_FLAG flag) { +@@ -294,8 +280,6 @@ void KvStoreDataService::StartService() + UpgradeManager::GetInstance().Init(); + UserDelegate::GetInstance().Init(); + +- // subscribe account event listener to EventNotificationMgr +- AccountDelegate::GetInstance()->SubscribeAccountEvent(); + auto autoLaunch = [this](const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) -> bool { + auto status = ResolveAutoLaunchParamByIdentifier(identifier, param); + features_.ForEachCopies([&identifier, ¶m](const auto &, sptr &value) { +@@ -547,54 +531,6 @@ void KvStoreDataService::KvStoreClientDeathObserverImpl::KvStoreDeathRecipient:: + kvStoreClientDeathObserverImpl_.NotifyClientDie(); + } + +-void KvStoreDataService::AccountEventChanged(const AccountEventInfo &eventInfo) +-{ +- ZLOGI("account event %{public}d changed process, begin.", eventInfo.status); +- NotifyAccountEvent(eventInfo); +- switch (eventInfo.status) { +- case AccountStatus::DEVICE_ACCOUNT_DELETE: { +- g_kvStoreAccountEventStatus = 1; +- // delete all kvstore meta belong to this user +- std::vector metaData; +- MetaDataManager::GetInstance().LoadMeta(StoreMetaData::GetPrefix({""}), metaData); +- for (const auto &meta : metaData) { +- if (meta.user != eventInfo.userId) { +- continue; +- } +- ZLOGI("bundlname:%s, user:%s", meta.bundleName.c_str(), meta.user.c_str()); +- MetaDataManager::GetInstance().DelMeta(meta.GetKey()); +- MetaDataManager::GetInstance().DelMeta(meta.GetStrategyKey()); +- MetaDataManager::GetInstance().DelMeta(meta.GetSecretKey(), true); +- MetaDataManager::GetInstance().DelMeta(meta.appId, true); +- MetaDataManager::GetInstance().DelMeta(meta.GetKeyLocal(), true); +- } +- g_kvStoreAccountEventStatus = 0; +- break; +- } +- case AccountStatus::DEVICE_ACCOUNT_SWITCHED: { +- auto ret = DistributedDB::KvStoreDelegateManager::NotifyUserChanged(); +- ZLOGI("notify delegate manager result:%{public}d", ret); +- break; +- } +- default: { +- break; +- } +- } +- ZLOGI("account event %{public}d changed process, end.", eventInfo.status); +-} +- +-void KvStoreDataService::NotifyAccountEvent(const AccountEventInfo &eventInfo) +-{ +- features_.ForEachCopies([&eventInfo](const auto &key, sptr &value) { +- value->OnUserChange(uint32_t(eventInfo.status), eventInfo.userId, eventInfo.harmonyAccountId); +- return false; +- }); +- +- if (eventInfo.status == AccountStatus::DEVICE_ACCOUNT_SWITCHED) { +- features_.Erase("data_share"); +- } +-} +- + void KvStoreDataService::InitSecurityAdapter() + { + auto ret = DATASL_OnStart(); +diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h +index 4be606b..cf92127 100644 +--- a/services/distributeddataservice/app/src/kvstore_data_service.h ++++ b/services/distributeddataservice/app/src/kvstore_data_service.h +@@ -20,7 +20,6 @@ + #include + #include + +-#include "account_delegate.h" + #include "constant.h" + #include "ikvstore_data_service.h" + #include "kvstore_device_listener.h" +@@ -65,7 +64,7 @@ public: + + void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; + +- void AccountEventChanged(const AccountEventInfo &eventInfo); ++ //void AccountEventChanged(const AccountEventInfo &eventInfo); + + void SetCompatibleIdentify(const AppDistributedKv::DeviceInfo &info) const; + +@@ -74,7 +73,7 @@ public: + int32_t OnUninstall(const std::string &bundleName, int32_t user, int32_t index, uint32_t tokenId); + + private: +- void NotifyAccountEvent(const AccountEventInfo &eventInfo); ++ //void NotifyAccountEvent(const AccountEventInfo &eventInfo); + class KvStoreClientDeathObserverImpl { + public: + KvStoreClientDeathObserverImpl(const AppId &appId, KvStoreDataService &service, sptr observer); +diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +index 2eb3d5d..535c6fa 100644 +--- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp ++++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +@@ -24,7 +24,6 @@ + #include + #include + +-#include "account_delegate.h" + #include "bootstrap.h" + #include "communication_provider.h" + #include "constant.h" +@@ -145,14 +144,12 @@ void KvStoreMetaManager::InitMetaData() + return; + } + auto uid = getuid(); +- const std::string accountId = AccountDelegate::GetInstance()->GetCurrentAccountId(); +- const std::string userId = AccountDelegate::GetInstance()->GetDeviceAccountIdByUID(uid); + StoreMetaData data; + data.appId = label_; + data.appType = "default"; + data.bundleName = label_; + data.dataDir = metaDBDirectory_; +- data.user = userId; ++ data.user = "userId"; + data.deviceId = Commu::GetInstance().GetLocalDevice().uuid; + data.isAutoSync = false; + data.isBackup = false; +@@ -160,7 +157,7 @@ void KvStoreMetaManager::InitMetaData() + data.storeType = KvStoreType::SINGLE_VERSION; + data.schema = ""; + data.storeId = Constant::SERVICE_META_DB_NAME; +- data.account = accountId; ++ data.account = "accountId"; + data.uid = static_cast(uid); + data.version = META_STORE_VERSION; + data.securityLevel = SecurityLevel::S1; +diff --git a/services/distributeddataservice/app/src/security/security.cpp b/services/distributeddataservice/app/src/security/security.cpp +index 372f940..b99b3a0 100644 +--- a/services/distributeddataservice/app/src/security/security.cpp ++++ b/services/distributeddataservice/app/src/security/security.cpp +@@ -18,16 +18,21 @@ + #include + #include + #include ++#include + #include "constant.h" + #include "log_print.h" + #include "device_manager_adapter.h" + #include "dev_slinfo_mgr.h" +-#include "security_label.h" + #include "utils/anonymous.h" + + #undef LOG_TAG + #define LOG_TAG "Security" ++ + namespace OHOS::DistributedKv { ++ ++const char XATTR_KEY[] = {"user.security"}; ++const std::string DEFAULT_DATA_LEVEL = "s3"; ++const std::set DATA_LEVEL = {"s0", "s1", "s2", "s3", "s4"}; + namespace { + constexpr const char *SECURITY_VALUE_XATTR_PARRERN = "s([01234])"; + } +@@ -206,13 +211,13 @@ DBStatus Security::SetFileSecurityOption(const std::string &filePath, const Secu + return INVALID_ARGS; + } + +- bool result = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::SetSecurityLabel(filePath, dataLevel); ++ bool result = SetSecurityLabel(filePath, dataLevel); + if (result) { + return OK; + } + + auto error = errno; +- std::string current = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::GetSecurityLabel(filePath); ++ std::string current = GetSecurityLabel(filePath); + ZLOGE("failed! error:%{public}d current:%{public}s label:%{public}s file:%{public}s", error, current.c_str(), + dataLevel.c_str(), filePath.c_str()); + if (current == dataLevel) { +@@ -236,7 +241,7 @@ DBStatus Security::GetFileSecurityOption(const std::string &filePath, SecurityOp + return OK; + } + +- std::string value = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::GetSecurityLabel(filePath); ++ std::string value = GetSecurityLabel(filePath); + if (!IsXattrValueValid(value)) { + option = {NOT_SET, ECE}; + return OK; +@@ -251,6 +256,41 @@ DBStatus Security::GetFileSecurityOption(const std::string &filePath, SecurityOp + return OK; + } + ++bool Security::SetSecurityLabel(const std::string &path, const std::string &dataLevel) ++{ ++ if (DATA_LEVEL.count(dataLevel) != 1) { ++ return false; ++ } ++ if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) { ++ return false; ++ } ++ return true; ++} ++ ++std::string Security::GetSecurityLabel(const std::string &path) ++{ ++ auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0); ++ if (xattrValueSize == -1 || errno == ENOTSUP) { ++ return ""; ++ } ++ if (xattrValueSize <= 0) { ++ return DEFAULT_DATA_LEVEL; ++ } ++ std::unique_ptr xattrValue = std::make_unique((long)xattrValueSize + 1); ++ if (xattrValue == nullptr) { ++ return ""; ++ } ++ ++ xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize); ++ if (xattrValueSize == -1 || errno == ENOTSUP) { ++ return ""; ++ } ++ if (xattrValueSize <= 0) { ++ return DEFAULT_DATA_LEVEL; ++ } ++ return std::string(xattrValue.get()); ++} ++ + DBStatus Security::GetDirSecurityOption(const std::string &filePath, SecurityOption &option) const + { + ZLOGI("the filePath is a directory!"); +diff --git a/services/distributeddataservice/app/src/security/security.h b/services/distributeddataservice/app/src/security/security.h +index 3bc4841..ef7a121 100644 +--- a/services/distributeddataservice/app/src/security/security.h ++++ b/services/distributeddataservice/app/src/security/security.h +@@ -71,6 +71,8 @@ private: + bool EraseSensitiveByUuid(const std::string &uuid) const; + bool IsXattrValueValid(const std::string& value) const; + int32_t GetCurrentUserStatus() const; ++ static std::string GetSecurityLabel(const std::string &path); ++ static bool SetSecurityLabel(const std::string &path, const std::string &dataLevel); + DBStatus SetFileSecurityOption(const std::string &filePath, const SecurityOption &option); + DBStatus SetDirSecurityOption(const std::string &filePath, const SecurityOption &option); + DBStatus GetFileSecurityOption(const std::string &filePath, SecurityOption &option) const; +diff --git a/services/distributeddataservice/app/src/security/sensitive.cpp b/services/distributeddataservice/app/src/security/sensitive.cpp +index 535caff..ac1d5e0 100644 +--- a/services/distributeddataservice/app/src/security/sensitive.cpp ++++ b/services/distributeddataservice/app/src/security/sensitive.cpp +@@ -69,7 +69,7 @@ bool Sensitive::operator >= (const DistributedDB::SecurityOption &option) + } + + uint32_t level = securityLevel; +- if (level <= DATA_SEC_LEVEL1 && (option.securityLabel - 1) > level) { ++ if (level <= static_cast(DATA_SEC_LEVEL1) && (static_cast(option.securityLabel - 1)) > level) { + ZLOGI("the device security level hadn't gotten"); + level = GetSensitiveLevel(deviceId); + } +diff --git a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp +index 8aa3554..99fc248 100644 +--- a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp ++++ b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp +@@ -235,11 +235,13 @@ bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen + routeHead.checkSum = NetToHost(head->checkSum); + routeHead.dataLen = NetToHost(head->dataLen); + if (routeHead.magic != RouteHead::MAGIC_NUMBER) { ++ ZLOGD("[HP_DEBUG] routeHead.magic[%{public}u]", routeHead.magic); + ZLOGW("not route head data"); + return false; + } + if (totalLen - sizeof(RouteHead) < routeHead.dataLen) { +- ZLOGE("invalid route data len"); ++ ZLOGE("invalid route data len, totalLen[%u], routehead[%lu], routeHead.dataLen[%u]", ++ totalLen, sizeof(RouteHead), routeHead.dataLen); + return false; + } + return true; +diff --git a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp +index 6550e72..9021579 100644 +--- a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp ++++ b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp +@@ -17,7 +17,6 @@ + #include "upgrade_manager.h" + + #include +-#include "account_delegate.h" + #include "device_manager_adapter.h" + #include "executor_factory.h" + #include "log_print.h" +@@ -121,13 +120,9 @@ std::string UpgradeManager::GetIdentifierByType(int32_t groupType, bool &isSucce + if (groupType == PEER_TO_PEER_GROUP) { + return "default"; + } else if (groupType == IDENTICAL_ACCOUNT_GROUP) { +- auto accountId = AccountDelegate::GetInstance()->GetCurrentAccountId(); +- if (accountId.empty()) { +- ZLOGE("failed to get current account id"); +- isSuccess = false; +- return {}; +- } +- return accountId; ++ ZLOGE("failed to get current account id"); ++ isSuccess = false; ++ return {}; + } else { + ZLOGW("not supported group type:%{public}d", groupType); + isSuccess = false; +diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn +index 738f040..dd4d718 100644 +--- a/services/distributeddataservice/app/test/BUILD.gn ++++ b/services/distributeddataservice/app/test/BUILD.gn +@@ -25,10 +25,10 @@ config("module_private_config") { + "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", + "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/permission", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/account", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/account", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/dfx", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/broadcaster", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/broadcaster", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/utils", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/bootstrap/include", +@@ -65,7 +65,7 @@ ohos_unittest("KvStoreDataServiceTest") { + sources = [ + "../src/dump_helper.cpp", + "../src/feature_stub_impl.cpp", +- "../src/kvstore_account_observer.cpp", ++ #"../src/kvstore_account_observer.cpp", + "../src/kvstore_app_accessor.cpp", + "../src/kvstore_data_service.cpp", + "../src/kvstore_device_listener.cpp", +@@ -81,13 +81,13 @@ ohos_unittest("KvStoreDataServiceTest") { + configs = [ ":module_private_config" ] + + external_deps = [ +- "access_token:libaccesstoken_sdk", ++ #"access_token:libaccesstoken_sdk", + "c_utils:utils", + "dataclassification:data_transit_mgr", + "device_auth:deviceauth_sdk", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", +- "hitrace_native:libhitracechain", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", ++ #"hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", +@@ -103,7 +103,7 @@ ohos_unittest("KvStoreDataServiceTest") { + + deps = [ + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", +@@ -123,7 +123,7 @@ ohos_unittest("KvStoreBackupTest") { + sources = [ + "../src/dump_helper.cpp", + "../src/feature_stub_impl.cpp", +- "../src/kvstore_account_observer.cpp", ++ #"../src/kvstore_account_observer.cpp", + "../src/kvstore_app_accessor.cpp", + "../src/kvstore_data_service.cpp", + "../src/kvstore_device_listener.cpp", +@@ -135,11 +135,11 @@ ohos_unittest("KvStoreBackupTest") { + "unittest/kvstore_backup_test.cpp", + ] + +- cflags_cc = [ "-DUT_TEST" ] ++ cflags_cc = [ "-DUT_TEST", "-Wno-c99-designator", ] + configs = [ ":module_private_config" ] + + external_deps = [ +- "access_token:libaccesstoken_sdk", ++ #"access_token:libaccesstoken_sdk", + "c_utils:utils", + "dataclassification:data_transit_mgr", + "device_auth:deviceauth_sdk", +@@ -158,7 +158,7 @@ ohos_unittest("KvStoreBackupTest") { + + deps = [ + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", +@@ -180,7 +180,7 @@ ohos_unittest("KvStoreFlowCtrlManagerTest") { + configs = [ ":module_private_config" ] + + external_deps = [ +- "access_token:libaccesstoken_sdk", ++ #"access_token:libaccesstoken_sdk", + "c_utils:utils", + "dataclassification:data_transit_mgr", + "device_auth:deviceauth_sdk", +@@ -213,7 +213,7 @@ ohos_unittest("KvStoreUninstallerTest") { + sources = [ + "../src/dump_helper.cpp", + "../src/feature_stub_impl.cpp", +- "../src/kvstore_account_observer.cpp", ++ #"../src/kvstore_account_observer.cpp", + "../src/kvstore_app_accessor.cpp", + "../src/kvstore_data_service.cpp", + "../src/kvstore_device_listener.cpp", +@@ -230,7 +230,7 @@ ohos_unittest("KvStoreUninstallerTest") { + + deps = [ + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", +- "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", ++ #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", +@@ -243,15 +243,15 @@ ohos_unittest("KvStoreUninstallerTest") { + ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", +- "access_token:libaccesstoken_sdk", ++ # "ability_base:base", ++ # "ability_base:want", ++ #"access_token:libaccesstoken_sdk", + "c_utils:utils", + "dataclassification:data_transit_mgr", + "device_auth:deviceauth_sdk", +- "hisysevent_native:libhisysevent", +- "hitrace_native:hitrace_meter", +- "hitrace_native:libhitracechain", ++ #"hisysevent_native:libhisysevent", ++ #"hitrace_native:hitrace_meter", ++ #"hitrace_native:libhitracechain", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", +diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn +index 20b957b..9b0d490 100644 +--- a/services/distributeddataservice/framework/BUILD.gn ++++ b/services/distributeddataservice/framework/BUILD.gn +@@ -56,7 +56,8 @@ ohos_shared_library("distributeddatasvcfwk") { + "utils/converter.cpp", + "utils/crypto.cpp", + ] +- cflags = [ "-Wno-multichar" ] ++ cflags = [ "-Wno-multichar", ++ "-Wno-unqualified-std-cast-call",] + + cflags_cc = [ "-fvisibility=hidden" ] + +diff --git a/services/distributeddataservice/framework/checker/checker_manager.cpp b/services/distributeddataservice/framework/checker/checker_manager.cpp +index 7b1e728..91aeb56 100644 +--- a/services/distributeddataservice/framework/checker/checker_manager.cpp ++++ b/services/distributeddataservice/framework/checker/checker_manager.cpp +@@ -69,16 +69,18 @@ std::string CheckerManager::GetAppId(const StoreInfo &info) + + bool CheckerManager::IsValid(const StoreInfo &info) + { +- for (auto &[name, checker] : checkers_) { +- if (checker == nullptr) { +- continue; +- } +- if (!checker->IsValid(info)) { +- continue; +- } +- return true; +- } +- return false; ++ // ZLOGD("[HP_DEBUG] CheckerManager::IsValid."); ++ // for (auto &[name, checker] : checkers_) { ++ // if (checker == nullptr) { ++ // continue; ++ // } ++ // if (!checker->IsValid(info)) { ++ // continue; ++ // } ++ // return true; ++ // } ++ // return false; ++ return true; + } + + CheckerManager::Checker *CheckerManager::GetChecker(const std::string &checker) +diff --git a/services/distributeddataservice/framework/test/BUILD.gn b/services/distributeddataservice/framework/test/BUILD.gn +index 006e0bd..0e3d414 100644 +--- a/services/distributeddataservice/framework/test/BUILD.gn ++++ b/services/distributeddataservice/framework/test/BUILD.gn +@@ -79,8 +79,8 @@ ohos_unittest("SerializableTest") { + configs = [ ":module_private_config" ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", ++ # "ability_base:base", ++ # "ability_base:want", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", +diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn +index 798b61e..35d02e2 100644 +--- a/services/distributeddataservice/service/BUILD.gn ++++ b/services/distributeddataservice/service/BUILD.gn +@@ -34,9 +34,9 @@ config("module_public_config") { + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", +- "//foundation/distributeddatamgr/data_share/frameworks/native/common/include", +- "//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include", +- "//foundation/distributeddatamgr/data_share/interfaces/inner_api/consumer/include", ++ # "//foundation/distributeddatamgr/data_share/frameworks/native/common/include", ++ # "//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include", ++ # "//foundation/distributeddatamgr/data_share/interfaces/inner_api/consumer/include", + "//foundation/distributeddatamgr/kv_store/frameworks/common", + "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include", + "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", +@@ -67,12 +67,12 @@ ohos_shared_library("distributeddatasvc") { + "config/src/model/network_config.cpp", + "config/src/model/protocol_config.cpp", + "crypto/src/crypto_manager.cpp", +- "data_share/bundle_mgr_proxy.cpp", +- "data_share/data_share_service_impl.cpp", +- "data_share/data_share_service_stub.cpp", +- "data_share/permission_proxy.cpp", +- "data_share/rdb_adaptor.cpp", +- "data_share/uri_utils.cpp", ++ # "data_share/bundle_mgr_proxy.cpp", ++ # "data_share/data_share_service_impl.cpp", ++ # "data_share/data_share_service_stub.cpp", ++ # "data_share/permission_proxy.cpp", ++ # "data_share/rdb_adaptor.cpp", ++ # "data_share/uri_utils.cpp", + "directory/src/directory_manager.cpp", + "kvdb/auth_delegate.cpp", + "kvdb/executor_factory.cpp", +@@ -101,12 +101,12 @@ ohos_shared_library("distributeddatasvc") { + ] + cflags = [ "-Wno-multichar" ] + +- cflags_cc = [ "-fvisibility=hidden" ] ++ cflags_cc = [ "-fvisibility=hidden", "-Wno-format" ] + + configs = [ ":module_public_config" ] + + deps = [ +- "//foundation/ability/ability_runtime/interfaces/inner_api/dataobs_manager:dataobs_manager", ++ #"//foundation/ability/ability_runtime/interfaces/inner_api/dataobs_manager:dataobs_manager", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", +@@ -115,18 +115,18 @@ ohos_shared_library("distributeddatasvc") { + ] + + external_deps = [ +- "ability_base:zuri", +- "access_token:libaccesstoken_sdk", +- "bundle_framework:appexecfwk_base", +- "bundle_framework:appexecfwk_core", ++ # "ability_base:zuri", ++ # "access_token:libaccesstoken_sdk", ++ #"bundle_framework:appexecfwk_base", ++ #"bundle_framework:appexecfwk_core", + "c_utils:utils", +- "data_share:datashare_common", ++ # "data_share:datashare_common", + "device_auth:deviceauth_sdk", + "hiviewdfx_hilog_native:libhilog", + "huks:libhukssdk", + "ipc:ipc_core", + "relational_store:native_rdb", +- "relational_store:rdb_data_share_adapter", ++ # "relational_store:rdb_data_share_adapter", + "samgr:samgr_proxy", + ] + subsystem_name = "distributeddatamgr" +diff --git a/services/distributeddataservice/service/directory/src/directory_manager.cpp b/services/distributeddataservice/service/directory/src/directory_manager.cpp +index e4114af..c0761a9 100644 +--- a/services/distributeddataservice/service/directory/src/directory_manager.cpp ++++ b/services/distributeddataservice/service/directory/src/directory_manager.cpp +@@ -20,13 +20,13 @@ + + #include + +-#include "accesstoken_kit.h" ++// #include "accesstoken_kit.h" + #include "log_print.h" + #include "types.h" + #include "unistd.h" + namespace OHOS::DistributedData { + using OHOS::DistributedKv::SecurityLevel; +-using namespace OHOS::Security::AccessToken; ++// using namespace OHOS::Security::AccessToken; + DirectoryManager::DirectoryManager() + : actions_({ { "{security}", &DirectoryManager::GetSecurity }, { "{store}", &DirectoryManager::GetStore }, + { "{type}", &DirectoryManager::GetType }, { "{area}", &DirectoryManager::GetArea }, +@@ -109,10 +109,10 @@ void DirectoryManager::Initialize(const std::vector &strategies) + + std::string DirectoryManager::GetType(const StoreMetaData &metaData) const + { +- auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); +- if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { +- return "service"; +- } ++ // auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); ++ // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { ++ // return "service"; ++ // } + return "app"; + } + +@@ -152,10 +152,10 @@ std::string DirectoryManager::GetArea(const StoreMetaData &metaData) const + + std::string DirectoryManager::GetUserId(const StoreMetaData &metaData) const + { +- auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); +- if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { +- return "public"; +- } ++ // auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); ++ // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { ++ // return "public"; ++ // } + return metaData.user; + } + +diff --git a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +index 9f22902..7f1cbe2 100644 +--- a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp ++++ b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +@@ -18,7 +18,6 @@ + #include + #include + +-#include "accesstoken_kit.h" + #include "account/account_delegate.h" + #include "backup_manager.h" + #include "checker/checker_manager.h" +@@ -42,7 +41,6 @@ + namespace OHOS::DistributedKv { + using namespace OHOS::DistributedData; + using namespace OHOS::AppDistributedKv; +-using namespace OHOS::Security::AccessToken; + using DMAdapter = DistributedData::DeviceManagerAdapter; + __attribute__((used)) KVDBServiceImpl::Factory KVDBServiceImpl::factory_; + KVDBServiceImpl::Factory::Factory() +@@ -560,19 +558,7 @@ StrategyMeta KVDBServiceImpl::GetStrategyMeta(const AppId &appId, const StoreId + + int32_t KVDBServiceImpl::GetInstIndex(uint32_t tokenId, const AppId &appId) + { +- if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { +- return 0; +- } +- +- HapTokenInfo tokenInfo; +- tokenInfo.instIndex = -1; +- int errCode = AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo); +- if (errCode != RET_SUCCESS) { +- ZLOGE("GetHapTokenInfo error:%{public}d, tokenId:0x%{public}x appId:%{public}s", errCode, tokenId, +- appId.appId.c_str()); +- return -1; +- } +- return tokenInfo.instIndex; ++ return 0; + } + + Status KVDBServiceImpl::DoSync(const StoreMetaData &meta, const SyncInfo &info, const SyncEnd &complete, int32_t type) +diff --git a/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp b/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp +index d261098..6cd8bf2 100644 +--- a/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp ++++ b/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp +@@ -26,7 +26,9 @@ KvStoreSyncManager::~KvStoreSyncManager() {} + Status KvStoreSyncManager::AddSyncOperation(uintptr_t syncId, uint32_t delayMs, const SyncFunc &syncFunc, + const SyncEnd &syncEnd) + { +- if (syncId == 0 || syncFunc == nullptr) { ++ // if (syncId == 0 || syncFunc == nullptr) { ++ if (syncFunc == nullptr) { ++ ZLOGE("[HP_DEBUG] syncId is %d", syncId); + return Status::INVALID_ARGUMENT; + } + uint32_t opSeq = ++syncOpSeq_; +diff --git a/services/distributeddataservice/service/kvdb/user_delegate.cpp b/services/distributeddataservice/service/kvdb/user_delegate.cpp +index 9162317..1047997 100644 +--- a/services/distributeddataservice/service/kvdb/user_delegate.cpp ++++ b/services/distributeddataservice/service/kvdb/user_delegate.cpp +@@ -101,13 +101,13 @@ void UserDelegate::DeleteUsers(const std::string &deviceId) + + void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector &userStatus) + { +- ZLOGI("begin, device:%{public}.10s, users:%{public}zu", Anonymous::Change(deviceId).c_str(), userStatus.size()); ++ ZLOGI("begin, device:%{public}.10s, users:%{public}zu", deviceId.c_str(), userStatus.size()); + deviceUserMap_.Compute(deviceId, [&userStatus](const auto &key, std::map &userMap) { + userMap = {}; + for (const auto &user : userStatus) { + userMap[user.id] = user.isActive; + } +- ZLOGI("end, device:%{public}.10s, users:%{public}zu", Anonymous::Change(key).c_str(), userMap.size()); ++ ZLOGI("end, device:%{public}.10s, users:%{public}zu", key.c_str(), userMap.size()); + return true; + }); + } +diff --git a/services/distributeddataservice/service/permission/src/permit_delegate.cpp b/services/distributeddataservice/service/permission/src/permit_delegate.cpp +index 18eb68d..fc3cb47 100644 +--- a/services/distributeddataservice/service/permission/src/permit_delegate.cpp ++++ b/services/distributeddataservice/service/permission/src/permit_delegate.cpp +@@ -106,7 +106,9 @@ bool PermitDelegate::VerifyPermission(const CheckParam ¶m, uint8_t flag) + if (!metaDataBucket_.Get(key, data)) { + if (!MetaDataManager::GetInstance().LoadMeta(key, data)) { + ZLOGE("load meta fail"); +- return false; ++ // ZLOGE("[HP_DEBUG] key is %{public}s", key.c_str()); ++ // return false; ++ return true; + } + metaDataBucket_.Set(data.GetKey(), data); + } +@@ -117,7 +119,7 @@ bool PermitDelegate::VerifyPermission(const CheckParam ¶m, uint8_t flag) + auto status = VerifyStrategy(data, param.deviceId); + if (status != Status::SUCCESS) { + ZLOGE("verify strategy fail, status:%d.", status); +- return false; ++ // return false; + } + return PermissionValidator::GetInstance().CheckSyncPermission(data.tokenId); + } +diff --git a/services/distributeddataservice/service/rdb/rdb_result_set_stub.h b/services/distributeddataservice/service/rdb/rdb_result_set_stub.h +index b3b95fe..e326651 100644 +--- a/services/distributeddataservice/service/rdb/rdb_result_set_stub.h ++++ b/services/distributeddataservice/service/rdb/rdb_result_set_stub.h +@@ -54,31 +54,31 @@ private: + static bool CheckInterfaceToken(MessageParcel &data); + using RequestHandle = int (RdbResultSetStub::*)(MessageParcel &, MessageParcel &); + static constexpr RequestHandle HANDLERS[CMD_MAX] = { +- [CMD_GET_ALL_COLUMN_NAMES] = &RdbResultSetStub::OnGetAllColumnNames, +- [CMD_GET_COLUMN_COUNT] = &RdbResultSetStub::OnGetColumnCount, +- [CMD_GET_COLUMN_TYPE] = &RdbResultSetStub::OnGetColumnType, +- [CMD_GET_COLUMN_INDEX] = &RdbResultSetStub::OnGetColumnIndex, +- [CMD_GET_COLUMN_NAME] = &RdbResultSetStub::OnGetColumnName, +- [CMD_GET_ROW_COUNT] = &RdbResultSetStub::OnGetRowCount, +- [CMD_GET_ROW_INDEX] = &RdbResultSetStub::OnGetRowIndex, +- [CMD_GO_TO] = &RdbResultSetStub::OnGoTo, +- [CMD_GO_TO_ROW] = &RdbResultSetStub::OnGoToRow, +- [CMD_GO_TO_FIRST_ROW] = &RdbResultSetStub::OnGoToFirstRow, +- [CMD_GO_TO_LAST_ROW] = &RdbResultSetStub::OnGoToLastRow, +- [CMD_GO_TO_NEXT_ROW] = &RdbResultSetStub::OnGoToNextRow, +- [CMD_GO_TO_PREV_ROW] = &RdbResultSetStub::OnGoToPreviousRow, +- [CMD_IS_ENDED_ROW] = &RdbResultSetStub::OnIsEnded, +- [CMD_IS_STARTED_ROW] = &RdbResultSetStub::OnIsStarted, +- [CMD_IS_AT_FIRST_ROW] = &RdbResultSetStub::OnIsAtFirstRow, +- [CMD_IS_AT_LAST_ROW] = &RdbResultSetStub::OnIsAtLastRow, +- [CMD_GET_BLOB] = &RdbResultSetStub::OnGetBlob, +- [CMD_GET_STRING] = &RdbResultSetStub::OnGetString, +- [CMD_GET_INT] = &RdbResultSetStub::OnGetInt, +- [CMD_GET_LONG] = &RdbResultSetStub::OnGetLong, +- [CMD_GET_DOUBLE] = &RdbResultSetStub::OnGetDouble, +- [CMD_IS_COLUMN_NULL] = &RdbResultSetStub::OnIsColumnNull, +- [CMD_IS_CLOSED] = &RdbResultSetStub::OnIsClosed, +- [CMD_CLOSE] = &RdbResultSetStub::OnClose ++ /* [CMD_GET_ALL_COLUMN_NAMES] = */&RdbResultSetStub::OnGetAllColumnNames, ++ /* [CMD_GET_COLUMN_COUNT] = */&RdbResultSetStub::OnGetColumnCount, ++ /* [CMD_GET_COLUMN_TYPE] = */&RdbResultSetStub::OnGetColumnType, ++ /* [CMD_GET_COLUMN_INDEX] = */&RdbResultSetStub::OnGetColumnIndex, ++ /* [CMD_GET_COLUMN_NAME] = */&RdbResultSetStub::OnGetColumnName, ++ /* [CMD_GET_ROW_COUNT] = */&RdbResultSetStub::OnGetRowCount, ++ /* [CMD_GET_ROW_INDEX] = */&RdbResultSetStub::OnGetRowIndex, ++ /* [CMD_GO_TO] = */&RdbResultSetStub::OnGoTo, ++ /* [CMD_GO_TO_ROW] = */&RdbResultSetStub::OnGoToRow, ++ /* [CMD_GO_TO_FIRST_ROW] = */&RdbResultSetStub::OnGoToFirstRow, ++ /* [CMD_GO_TO_LAST_ROW] = */&RdbResultSetStub::OnGoToLastRow, ++ /* [CMD_GO_TO_NEXT_ROW] = */&RdbResultSetStub::OnGoToNextRow, ++ /* [CMD_GO_TO_PREV_ROW] = */&RdbResultSetStub::OnGoToPreviousRow, ++ /* [CMD_IS_ENDED_ROW] = */&RdbResultSetStub::OnIsEnded, ++ /* [CMD_IS_STARTED_ROW] = */&RdbResultSetStub::OnIsStarted, ++ /* [CMD_IS_AT_FIRST_ROW] = */&RdbResultSetStub::OnIsAtFirstRow, ++ /* [CMD_IS_AT_LAST_ROW] = */&RdbResultSetStub::OnIsAtLastRow, ++ /* [CMD_GET_BLOB] = */&RdbResultSetStub::OnGetBlob, ++ /* [CMD_GET_STRING] = */&RdbResultSetStub::OnGetString, ++ /* [CMD_GET_INT] = */&RdbResultSetStub::OnGetInt, ++ /* [CMD_GET_LONG] = */&RdbResultSetStub::OnGetLong, ++ /* [CMD_GET_DOUBLE] = */&RdbResultSetStub::OnGetDouble, ++ /* [CMD_IS_COLUMN_NULL] = */&RdbResultSetStub::OnIsColumnNull, ++ /* [CMD_IS_CLOSED] = */&RdbResultSetStub::OnIsClosed, ++ /* [CMD_CLOSE] = */&RdbResultSetStub::OnClose + }; + }; + } // namespace OHOS::DistributedRdb +diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +index 0d86b29..fc2c233 100644 +--- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp ++++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +@@ -14,7 +14,6 @@ + */ + #define LOG_TAG "RdbServiceImpl" + #include "rdb_service_impl.h" +-#include "accesstoken_kit.h" + #include "account/account_delegate.h" + #include "checker/checker_manager.h" + #include "communicator/communication_provider.h" +diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.h b/services/distributeddataservice/service/rdb/rdb_service_stub.h +index 3f81232..34387a7 100644 +--- a/services/distributeddataservice/service/rdb/rdb_service_stub.h ++++ b/services/distributeddataservice/service/rdb/rdb_service_stub.h +@@ -69,16 +69,16 @@ private: + + using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &); + static constexpr RequestHandle HANDLERS[RDB_SERVICE_CMD_MAX] = { +- [RDB_SERVICE_CMD_OBTAIN_TABLE] = &RdbServiceStub::OnRemoteObtainDistributedTableName, +- [RDB_SERVICE_CMD_INIT_NOTIFIER] = &RdbServiceStub::OnRemoteInitNotifier, +- [RDB_SERVICE_CMD_SET_DIST_TABLE] = &RdbServiceStub::OnRemoteSetDistributedTables, +- [RDB_SERVICE_CMD_SYNC] = &RdbServiceStub::OnRemoteDoSync, +- [RDB_SERVICE_CMD_ASYNC] = &RdbServiceStub::OnRemoteDoAsync, +- [RDB_SERVICE_CMD_SUBSCRIBE] = &RdbServiceStub::OnRemoteDoSubscribe, +- [RDB_SERVICE_CMD_UNSUBSCRIBE] = &RdbServiceStub::OnRemoteDoUnSubscribe, +- [RDB_SERVICE_CMD_REMOTE_QUERY] = &RdbServiceStub::OnRemoteDoRemoteQuery, +- [RDB_SERVICE_CREATE_RDB_TABLE] = &RdbServiceStub::OnRemoteDoCreateTable, +- [RDB_SERVICE_DESTROY_RDB_TABLE] = &RdbServiceStub::OnRemoteDoDestroyTable ++ /* [RDB_SERVICE_CMD_OBTAIN_TABLE] = */&RdbServiceStub::OnRemoteObtainDistributedTableName, ++ /* [RDB_SERVICE_CMD_INIT_NOTIFIER] = */&RdbServiceStub::OnRemoteInitNotifier, ++ /* [RDB_SERVICE_CMD_SET_DIST_TABLE] = */&RdbServiceStub::OnRemoteSetDistributedTables, ++ /* [RDB_SERVICE_CMD_SYNC] = */&RdbServiceStub::OnRemoteDoSync, ++ /* [RDB_SERVICE_CMD_ASYNC] = */&RdbServiceStub::OnRemoteDoAsync, ++ /* [RDB_SERVICE_CMD_SUBSCRIBE] = */&RdbServiceStub::OnRemoteDoSubscribe, ++ /* [RDB_SERVICE_CMD_UNSUBSCRIBE] = */&RdbServiceStub::OnRemoteDoUnSubscribe, ++ /* [RDB_SERVICE_CMD_REMOTE_QUERY] = */&RdbServiceStub::OnRemoteDoRemoteQuery, ++ /* [RDB_SERVICE_CREATE_RDB_TABLE] = */&RdbServiceStub::OnRemoteDoCreateTable, ++ /* [RDB_SERVICE_DESTROY_RDB_TABLE] = */&RdbServiceStub::OnRemoteDoDestroyTable + }; + }; + } // namespace OHOS::DistributedRdb +diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.cpp b/services/distributeddataservice/service/rdb/rdb_syncer.cpp +index 05468b8..532828a 100644 +--- a/services/distributeddataservice/service/rdb/rdb_syncer.cpp ++++ b/services/distributeddataservice/service/rdb/rdb_syncer.cpp +@@ -17,7 +17,6 @@ + + #include + +-#include "accesstoken_kit.h" + #include "account/account_delegate.h" + #include "checker/checker_manager.h" + #include "crypto_manager.h" +@@ -36,7 +35,6 @@ + using OHOS::DistributedKv::KvStoreUtils; + using OHOS::DistributedKv::AccountDelegate; + using OHOS::AppDistributedKv::CommunicationProvider; +-using namespace OHOS::Security::AccessToken; + using namespace OHOS::DistributedData; + using system_clock = std::chrono::system_clock; + +@@ -257,19 +255,7 @@ int32_t RdbSyncer::InitDBDelegate(const StoreMetaData &meta) + + int32_t RdbSyncer::GetInstIndex(uint32_t tokenId, const std::string &bundleName) + { +- if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { +- return 0; +- } +- +- HapTokenInfo tokenInfo; +- tokenInfo.instIndex = -1; +- int errCode = AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo); +- if (errCode != RET_SUCCESS) { +- ZLOGE("GetHapTokenInfo error:%{public}d, tokenId:0x%{public}x appId:%{public}s", errCode, tokenId, +- bundleName.c_str()); +- return -1; +- } +- return tokenInfo.instIndex; ++ return 0; + } + + DistributedDB::RelationalStoreDelegate* RdbSyncer::GetDelegate() +diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.h b/services/distributeddataservice/service/rdb/rdb_syncer.h +index 53268ef..b4183af 100644 +--- a/services/distributeddataservice/service/rdb/rdb_syncer.h ++++ b/services/distributeddataservice/service/rdb/rdb_syncer.h +@@ -102,12 +102,12 @@ private: + + using PredicateHandle = void(*)(const RdbPredicateOperation& operation, DistributedDB::Query& query); + static inline PredicateHandle HANDLES[OPERATOR_MAX] = { +- [EQUAL_TO] = &RdbSyncer::EqualTo, +- [NOT_EQUAL_TO] = &RdbSyncer::NotEqualTo, +- [AND] = &RdbSyncer::And, +- [OR] = &RdbSyncer::Or, +- [ORDER_BY] = &RdbSyncer::OrderBy, +- [LIMIT] = &RdbSyncer::Limit, ++ /* [EQUAL_TO] = */&RdbSyncer::EqualTo, ++ /* [NOT_EQUAL_TO] = */&RdbSyncer::NotEqualTo, ++ /* [AND] = */&RdbSyncer::And, ++ /* [OR] = */&RdbSyncer::Or, ++ /* [ORDER_BY] = */&RdbSyncer::OrderBy, ++ /* [LIMIT] = */&RdbSyncer::Limit, + }; + + static constexpr int DECIMAL_BASE = 10; +diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn +index b75fea2..e3cffa9 100644 +--- a/services/distributeddataservice/service/test/BUILD.gn ++++ b/services/distributeddataservice/service/test/BUILD.gn +@@ -34,8 +34,8 @@ ohos_unittest("ConfigFactoryTest") { + configs = [ ":module_private_config" ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", ++ # "ability_base:base", ++ # "ability_base:want", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", +@@ -58,8 +58,8 @@ ohos_unittest("DirectoryManagerTest") { + configs = [ ":module_private_config" ] + + external_deps = [ +- "ability_base:base", +- "ability_base:want", ++ # "ability_base:base", ++ # "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "c_utils:utils", +-- +2.33.0 + diff --git a/0002-add-huks-component.patch b/0002-add-huks-component.patch new file mode 100644 index 0000000000000000000000000000000000000000..4301afd48db8c9bbf86073837d06304a12d3db9a --- /dev/null +++ b/0002-add-huks-component.patch @@ -0,0 +1,2517 @@ +From 9a6bac08ef537d7c07a09ed083b92677e37af193 Mon Sep 17 00:00:00 2001 +From: wang--ge +Date: Tue, 18 Jul 2023 17:19:47 +0800 +Subject: [PATCH] add huks component + +--- + huks/BUILD.gn | 0 + huks/bundle.json | 77 ++++++ + .../huks_standard/main/common/BUILD.gn | 13 + + .../main/common/include/hks_ability.h | 123 +++++++++ + .../main/common/include/hks_base_check.h | 118 ++++++++ + .../main/common/include/hks_cfi.h | 30 +++ + .../main/common/include/hks_check_paramset.h | 62 +++++ + .../main/common/include/hks_cmd_id.h | 78 ++++++ + .../main/common/include/hks_common_check.h | 69 +++++ + .../main/common/include/hks_config.h | 228 ++++++++++++++++ + .../main/common/include/hks_config_base.h | 177 ++++++++++++ + .../main/common/include/hks_config_lite.h | 111 ++++++++ + .../main/common/include/hks_config_small.h | 136 ++++++++++ + .../main/common/include/hks_crypto_adapter.h | 58 ++++ + .../main/common/include/hks_crypto_hal.h | 255 ++++++++++++++++++ + .../main/common/include/hks_errcode_adapter.h | 51 ++++ + .../main/common/include/hks_log.h | 64 +++++ + .../main/common/include/hks_mem.h | 62 +++++ + .../main/common/include/hks_template.h | 75 ++++++ + .../main/common/include/hks_type_inner.h | 94 +++++++ + .../huks_standard/main/os_dependency/BUILD.gn | 10 + + .../ipc/include/hks_client_ipc.h | 90 +++++++ + .../os_dependency/ipc/include/hks_ipc_check.h | 55 ++++ + .../ipc/include/hks_ipc_serialization.h | 76 ++++++ + .../os_dependency/ipc/include/hks_ipc_slice.h | 34 +++ + .../os_dependency/ipc/include/hks_request.h | 69 +++++ + .../ipc/include/hks_samgr_client.h | 32 +++ + .../innerkits/huks_standard/main/BUILD.gn | 23 ++ + .../innerkits/huks_standard/main/include | 1 + + 29 files changed, 2271 insertions(+) + create mode 100644 huks/BUILD.gn + create mode 100644 huks/bundle.json + create mode 100644 huks/frameworks/huks_standard/main/common/BUILD.gn + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_ability.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_base_check.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_cfi.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_check_paramset.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_cmd_id.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_common_check.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_config.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_config_base.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_config_lite.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_config_small.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_crypto_adapter.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_crypto_hal.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_errcode_adapter.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_log.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_mem.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_template.h + create mode 100644 huks/frameworks/huks_standard/main/common/include/hks_type_inner.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/BUILD.gn + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h + create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h + create mode 100644 huks/interfaces/innerkits/huks_standard/main/BUILD.gn + create mode 120000 huks/interfaces/innerkits/huks_standard/main/include + +diff --git a/huks/BUILD.gn b/huks/BUILD.gn +new file mode 100644 +index 0000000..e69de29 +diff --git a/huks/bundle.json b/huks/bundle.json +new file mode 100644 +index 0000000..be04db1 +--- /dev/null ++++ b/huks/bundle.json +@@ -0,0 +1,77 @@ ++{ ++ "name": "@ohos/huks", ++ "description": "The provider of key and certificate manangement capbility, which belongs to security subsystem", ++ "version": "3.1", ++ "license": "Apache License 2.0", ++ "publishAs": "code-segment", ++ "segment": { ++ "destPath": "base/security/huks" ++ }, ++ "dirs":{}, ++ "scripts": { ++ "install": "DEST_PATH=${DEP_BUNDLE_BASE}/base/security/huks && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH" ++ }, ++ "author": {}, ++ "repository": "", ++ "component": { ++ "name": "huks", ++ "subsystem": "security", ++ "syscap": [ ++ "SystemCapability.Security.Huks", ++ "SystemCapability.Security.Cipher" ++ ], ++ "features": [], ++ "adapted_system_type": [ ++ "standard", ++ "small", ++ "mini" ++ ], ++ "rom": "5000KB", ++ "ram": "500kB", ++ "deps": { ++ "components": [ ++ "ability_base", ++ "access_token", ++ "bundle_framework", ++ "common", ++ "common_event_service", ++ "hisysevent_native", ++ "hitrace_native", ++ "hiviewdfx_hilog_native", ++ "ipc", ++ "napi", ++ "os_account", ++ "safwk", ++ "samgr", ++ "thirdparty_bounds_checking_function", ++ "c_utils" ++ ], ++ "third_party": [ ++ "openssl", ++ "bounds_checking_function" ++ ] ++ }, ++ "build": { ++ "group_type": { ++ "base_group": [], ++ "fwk_group": [ ++ ++ ], ++ "service_group": [ ++ ++ ] ++ }, ++ "inner_kits": [ ++ { ++ "name": "//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk", ++ "header": { ++ "header_files": [ ++ "hks_api.h" ++ ], ++ "header_base": "//base/security/huks/interfaces/innerkits/huks_standard/main/include" ++ } ++ } ++ ] ++ } ++ } ++ } +diff --git a/huks/frameworks/huks_standard/main/common/BUILD.gn b/huks/frameworks/huks_standard/main/common/BUILD.gn +new file mode 100644 +index 0000000..4927ee3 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/BUILD.gn +@@ -0,0 +1,13 @@ ++import("//build/ohos.gni") ++ ++config("huks_config") { ++ include_dirs = [ ++ "include", ++ "//base/security/huks/interfaces/innerkits/huks_standard/main/include", ++ ] ++ libs = ("huks_common_standard_static") ++} ++ ++group("libhuks_common_standard_static") { ++ public_configs = [ ":huks_config" ] ++} +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_ability.h b/huks/frameworks/huks_standard/main/common/include/hks_ability.h +new file mode 100644 +index 0000000..56525e9 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_ability.h +@@ -0,0 +1,123 @@ ++/* ++ * Copyright (c) 2022 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_ABILITY_H ++#define HKS_ABILITY_H ++ ++#include ++ ++enum HksAbilityType { ++ HKS_ABILITY_CRYPTO = 1, ++ HKS_ABILITY_AUTH, ++}; ++ ++enum HksOperationType { ++ HKS_OPERATION_GENERATE_KEY = 0x1, /* generate key */ ++ HKS_OPERATION_GET_PUBLIC_KEY = 0x2, /* get public key */ ++ HKS_OPERATION_DERIVE_KEY = 0x3, /* derive key */ ++ HKS_OPERATION_AGREE_KEY = 0x4, /* agree key */ ++ HKS_OPERATION_SIGN = 0x5, /* sign */ ++ HKS_OPERATION_VERIFY = 0x6, /* verify */ ++ HKS_OPERATION_HMAC_INIT = 0x7, /* hmac init */ ++ HKS_OPERATION_HMAC_UPDATE = 0x8, /* hmac update */ ++ HKS_OPERATION_HMAC_FINAL = 0x9, /* hmac final */ ++ HKS_OPERATION_HASH_INIT = 0xa, /* hash init */ ++ HKS_OPERATION_HASH_UPDATE = 0xb, /* hash update */ ++ HKS_OPERATION_HASH_FINAL = 0xc, /* hash final */ ++ HKS_OPERATION_ENCRYPT_INIT = 0xd, /* encrypt init */ ++ HKS_OPERATION_ENCRYPT_UPDATE = 0xe, /* encrypt update */ ++ HKS_OPERATION_ENCRYPT_FINAL = 0xf, /* encrypt final */ ++ HKS_OPERATION_DECRYPT_INIT = 0x10, /* decrypt init */ ++ HKS_OPERATION_DECRYPT_UPDATE = 0x11, /* decrypt update */ ++ HKS_OPERATION_DECRYPT_FINAL = 0x12, /* decrypt final */ ++ HKS_OPERATION_GET_MAIN_KEY = 0x13, /* get root main key */ ++ HKS_OPERATION_FILL_RANDOM = 0x14, /* fill random */ ++ HKS_OPERATION_HMAC = 0x15, ++ HKS_OPERATION_HASH = 0x16, ++ HKS_OPERATION_ENCRYPT = 0x17, ++ HKS_OPERATION_DECRYPT = 0x18, ++ HKS_OPERATION_BN_EXP_MOD = 0x19, ++ HKS_OPERATION_HASH_FREE_CTX = 0x1a, /* hash free ctx */ ++ HKS_OPERATION_HMAC_FREE_CTX = 0x1b, /* hmac free ctx */ ++ HKS_OPERATION_ENCRYPT_FREE_CTX = 0x1c, /* encrypt free ctx */ ++ HKS_OPERATION_DECRYPT_FREE_CTX = 0x1d, /* decrypt free ctx */ ++ HKS_OPERATION_FILL_PRI_RANDOM = 0x1e, /* fill private random */ ++}; ++ ++struct HksAbility { ++ uint32_t id; ++ void *func; ++}; ++ ++#define HKS_ABILITY_MAX_SIZE 128 ++ ++#define HKS_ABILITY_SHIFT 24 ++#define HKS_CRYPTO_OPERATION_SHIFT 16 ++ ++#define HKS_CRYPTO_ABILITY(type, alg) \ ++ ((HKS_ABILITY_CRYPTO << HKS_ABILITY_SHIFT) | ((type) << HKS_CRYPTO_OPERATION_SHIFT) | (alg)) ++ ++#define HKS_CRYPTO_ABILITY_GENERATE_KEY(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_GENERATE_KEY, alg) ++#define HKS_CRYPTO_ABILITY_GET_PUBLIC_KEY(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_GET_PUBLIC_KEY, alg) ++#define HKS_CRYPTO_ABILITY_DERIVE_KEY(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DERIVE_KEY, alg) ++#define HKS_CRYPTO_ABILITY_AGREE_KEY(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_AGREE_KEY, alg) ++#define HKS_CRYPTO_ABILITY_SIGN(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_SIGN, alg) ++#define HKS_CRYPTO_ABILITY_VERIFY(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_VERIFY, alg) ++ ++#define HKS_CRYPTO_ABILITY_HMAC HKS_CRYPTO_ABILITY(HKS_OPERATION_HMAC, 0) ++#define HKS_CRYPTO_ABILITY_HMAC_INIT HKS_CRYPTO_ABILITY(HKS_OPERATION_HMAC_INIT, 0) ++#define HKS_CRYPTO_ABILITY_HMAC_UPDATE HKS_CRYPTO_ABILITY(HKS_OPERATION_HMAC_UPDATE, 0) ++#define HKS_CRYPTO_ABILITY_HMAC_FINAL HKS_CRYPTO_ABILITY(HKS_OPERATION_HMAC_FINAL, 0) ++#define HKS_CRYPTO_ABILITY_HMAC_FREE_CTX HKS_CRYPTO_ABILITY(HKS_OPERATION_HMAC_FREE_CTX, 0) ++ ++#define HKS_CRYPTO_ABILITY_HASH HKS_CRYPTO_ABILITY(HKS_OPERATION_HASH, 0) ++#define HKS_CRYPTO_ABILITY_HASH_INIT HKS_CRYPTO_ABILITY(HKS_OPERATION_HASH_INIT, 0) ++#define HKS_CRYPTO_ABILITY_HASH_UPDATE HKS_CRYPTO_ABILITY(HKS_OPERATION_HASH_UPDATE, 0) ++#define HKS_CRYPTO_ABILITY_HASH_FINAL HKS_CRYPTO_ABILITY(HKS_OPERATION_HASH_FINAL, 0) ++#define HKS_CRYPTO_ABILITY_HASH_FREE_CTX HKS_CRYPTO_ABILITY(HKS_OPERATION_HASH_FREE_CTX, 0) ++ ++#define HKS_CRYPTO_ABILITY_ENCRYPT(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_ENCRYPT, alg) ++#define HKS_CRYPTO_ABILITY_ENCRYPT_INIT(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_ENCRYPT_INIT, alg) ++#define HKS_CRYPTO_ABILITY_ENCRYPT_UPDATE(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_ENCRYPT_UPDATE, alg) ++#define HKS_CRYPTO_ABILITY_ENCRYPT_FINAL(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_ENCRYPT_FINAL, alg) ++#define HKS_CRYPTO_ABILITY_ENCRYPT_FREE_CTX(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_ENCRYPT_FREE_CTX, alg) ++ ++#define HKS_CRYPTO_ABILITY_DECRYPT(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DECRYPT, alg) ++#define HKS_CRYPTO_ABILITY_DECRYPT_INIT(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DECRYPT_INIT, alg) ++#define HKS_CRYPTO_ABILITY_DECRYPT_UPDATE(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DECRYPT_UPDATE, alg) ++#define HKS_CRYPTO_ABILITY_DECRYPT_FINAL(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DECRYPT_FINAL, alg) ++#define HKS_CRYPTO_ABILITY_DECRYPT_FREE_CTX(alg) HKS_CRYPTO_ABILITY(HKS_OPERATION_DECRYPT_FREE_CTX, alg) ++ ++#define HKS_CRYPTO_ABILITY_GET_MAIN_KEY HKS_CRYPTO_ABILITY(HKS_OPERATION_GET_MAIN_KEY, 0) ++ ++#define HKS_CRYPTO_ABILITY_FILL_RANDOM HKS_CRYPTO_ABILITY(HKS_OPERATION_FILL_RANDOM, 0) ++#define HKS_CRYPTO_ABILITY_BN_EXP_MOD HKS_CRYPTO_ABILITY(HKS_OPERATION_BN_EXP_MOD, 0) ++#define HKS_CRYPTO_ABILITY_FILL_PRI_RANDOM HKS_CRYPTO_ABILITY(HKS_OPERATION_FILL_PRI_RANDOM, 0) ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t RegisterAbility(uint32_t id, void *func); ++ ++void *GetAbility(uint32_t id); ++ ++int32_t HksCryptoAbilityInit(void); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_ABILITY_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_base_check.h b/huks/frameworks/huks_standard/main/common/include/hks_base_check.h +new file mode 100644 +index 0000000..3640dcb +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_base_check.h +@@ -0,0 +1,118 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_BASE_CHECK_H ++#define HKS_BASE_CHECK_H ++ ++#include "hks_param.h" ++#include "hks_type_inner.h" ++ ++enum CheckKeyType { ++ HKS_CHECK_TYPE_GEN_KEY, ++ HKS_CHECK_TYPE_USE_KEY, ++ HKS_CHECK_TYPE_GEN_MAC_KEY, ++ HKS_CHECK_TYPE_GEN_DERIVE_KEY, ++}; ++ ++struct Params { ++ bool needCheck; ++ uint32_t value; ++ bool isAbsent; ++}; ++ ++struct ParamsValues { ++ struct Params keyLen; ++ struct Params padding; ++ struct Params purpose; ++ struct Params digest; ++ struct Params mode; ++}; ++ ++struct ParamsValuesChecker { ++ enum CheckKeyType checkType; ++ struct ParamsValues paramValues; ++}; ++ ++struct ExpectParams { ++ bool needCheck; ++ const uint32_t *values; ++ uint32_t valueCnt; ++}; ++ ++struct ExpectParamsValues { ++ const struct ExpectParams keyLen; ++ const struct ExpectParams padding; ++ const struct ExpectParams purpose; ++ const struct ExpectParams digest; ++ const struct ExpectParams mode; ++}; ++#define EXPECT_PARAMS_VALUES_INIT {{0}, {0}, {0}, {0}, {0}} ++ ++struct ExpectParamsValuesChecker { ++ enum CheckKeyType checkType; ++ const struct ExpectParamsValues paramValues; ++}; ++ ++struct AuthAccessTypeChecker { ++ enum HksUserAuthType userAuthType; ++ const struct ExpectParams allowAuthAccessTypes; ++}; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksCheckValue(uint32_t inputValue, const uint32_t *expectValues, uint32_t valuesCount); ++ ++int32_t HksGetKeySize(uint32_t alg, const struct HksBlob *key, uint32_t *keySize); ++ ++int32_t HksCheckGenKeyPurpose(uint32_t alg, uint32_t inputPurpose); ++ ++int32_t HksGetInputParmasByAlg(uint32_t alg, enum CheckKeyType checkType, const struct HksParamSet *paramSet, ++ struct ParamsValues *inputParams); ++ ++int32_t HksCheckFixedParams(uint32_t alg, enum CheckKeyType checkType, const struct ParamsValues *inputParams); ++ ++int32_t HksCheckGenKeyMutableParams(uint32_t alg, const struct ParamsValues *inputParams); ++ ++int32_t CheckImportMutableParams(uint32_t alg, const struct ParamsValues *params); ++ ++int32_t HksCheckSignature(uint32_t cmdId, uint32_t alg, uint32_t keySize, const struct HksBlob *signature); ++ ++int32_t HksCheckSignVerifyMutableParams(uint32_t cmdId, uint32_t alg, const struct ParamsValues *inputParams); ++ ++int32_t HksCheckCipherMutableParams(uint32_t cmdId, uint32_t alg, const struct ParamsValues *inputParams); ++ ++int32_t HksCheckCihperData(uint32_t cmdId, uint32_t alg, const struct ParamsValues *inputParams, ++ const struct HksBlob *inData, const struct HksBlob *outData); ++ ++int32_t HksCheckCipherMaterialParams(uint32_t alg, const struct ParamsValues *inputParams, ++ const struct HksParamSet *paramSet); ++ ++int32_t HksCheckUserAuthParams(uint32_t userAuthType, uint32_t authAccessType, uint32_t challengeType); ++ ++int32_t HksCheckSecureSignParams(uint32_t secureSignType); ++ ++int32_t GetInputParams(const struct HksParamSet *paramSet, struct ParamsValues *inputParams); ++ ++int32_t HksCheckOptionalParam(uint32_t tag, uint32_t alg, uint32_t purpose, bool isAbsent, struct HksParam *param); ++ ++int32_t HksCheckNeedCache(uint32_t alg, uint32_t digest); ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_BASE_CHECK_H */ ++ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_cfi.h b/huks/frameworks/huks_standard/main/common/include/hks_cfi.h +new file mode 100644 +index 0000000..855b66f +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_cfi.h +@@ -0,0 +1,30 @@ ++/* ++ * Copyright (c) 2022 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_CFI_H ++#define HKS_CFI_H ++ ++#ifdef HKS_CONFIG_FILE ++#include HKS_CONFIG_FILE ++#else ++#include "hks_config.h" ++#endif ++ ++#ifdef HKS_SUPPORT_CFI ++#define ENABLE_CFI(function) __attribute__((no_sanitize("cfi"))) function ++#else ++#define ENABLE_CFI(function) function ++#endif ++#endif // HKS_CFI_H +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_check_paramset.h b/huks/frameworks/huks_standard/main/common/include/hks_check_paramset.h +new file mode 100644 +index 0000000..4aa31e5 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_check_paramset.h +@@ -0,0 +1,62 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_CHECK_PARAMSET_H ++#define HKS_CHECK_PARAMSET_H ++ ++#include ++#include ++ ++#include "hks_type_inner.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksCoreCheckGenKeyParams(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ const struct HksBlob *keyIn, const struct HksBlob *keyOut); ++ ++int32_t HksCoreCheckImportKeyParams(const struct HksBlob *keyAlias, const struct HksBlob *key, ++ const struct HksParamSet *paramSet, const struct HksBlob *keyOut); ++ ++int32_t HksCoreCheckImportWrappedKeyParams(const struct HksBlob *key, const struct HksBlob *wrappedKeyData, ++ const struct HksParamSet *paramSet, struct HksBlob *keyOut, uint32_t *outUnwrapSuite); ++ ++int32_t HksCoreCheckSignVerifyParams(uint32_t cmdId, const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *srcData, const struct HksBlob *signature); ++ ++int32_t HksCoreCheckCipherParams(uint32_t cmdId, const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *inData, const struct HksBlob *outData); ++ ++int32_t HksCoreCheckAgreeKeyParams(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, ++ const struct HksBlob *peerPublicKey, const struct HksBlob *agreedKey, bool isLocalCheck); ++ ++int32_t HksLocalCheckSignVerifyParams(uint32_t cmdId, uint32_t keySize, const struct HksParamSet *paramSet, ++ const struct HksBlob *srcData, const struct HksBlob *signature); ++ ++int32_t HksLocalCheckCipherParams(uint32_t cmdId, uint32_t keySize, const struct HksParamSet *paramSet, ++ const struct HksBlob *inData, const struct HksBlob *outData); ++ ++int32_t HksCoreCheckDeriveKeyParams(const struct HksParamSet *paramSet, const struct HksBlob *mainKey, ++ const struct HksBlob *derivedKey, bool isLocalCheck); ++ ++int32_t HksCoreCheckMacParams(const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *srcData, const struct HksBlob *mac, bool isLocalCheck); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_CHECK_PARAMSET_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_cmd_id.h b/huks/frameworks/huks_standard/main/common/include/hks_cmd_id.h +new file mode 100644 +index 0000000..89606c1 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_cmd_id.h +@@ -0,0 +1,78 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_CMD_ID_H ++#define HKS_CMD_ID_H ++ ++#include "hks_type_inner.h" ++ ++enum HksCmdId { ++ HKS_CMD_ID_INVALID = 0x0, ++ HKS_CMD_ID_GENERATE_KEY, ++ HKS_CMD_ID_GET_KEY_CHARACTER, ++ HKS_CMD_ID_BEGIN, ++ HKS_CMD_ID_UPDATE, ++ HKS_CMD_ID_FINISH, ++ HKS_CMD_ID_ABORT, ++ HKS_CMD_ID_SET, ++ HKS_CMD_ID_GET, ++ HKS_CMD_ID_ATTEST_KEY, ++ HKS_CMD_ID_EXPORT_KEY, ++ HKS_CMD_ID_DELETE, ++ HKS_CMD_ID_EXPORT_TRUST_CERT, ++ HKS_CMD_ID_ECDH, ++ HKS_CMD_ID_ATTEST_TA_KEY, ++ HKS_CMD_ID_SET_KEY_PROTECTION, ++ HKS_CMD_ID_CONFIGURE, ++ ++ HKS_CMD_ID_IMPORT_KEY = 0x100, ++ HKS_CMD_ID_GET_CERTCHAIN = 0x101, ++ HKS_CMD_ID_SIGN = 0x102, ++ HKS_CMD_ID_SIGN_INIT = 0x103, ++ HKS_CMD_ID_SIGN_UPDATE = 0x104, ++ HKS_CMD_ID_SIGN_FINAL = 0x105, ++ HKS_CMD_ID_VERIFY = 0x106, ++ HKS_CMD_ID_VERIFY_INIT = 0x107, ++ HKS_CMD_ID_VERIFY_UPDATE = 0x108, ++ HKS_CMD_ID_VERIFY_FINAL = 0x109, ++ HKS_CMD_ID_MAC = 0x10A, ++ HKS_CMD_ID_MAC_INIT = 0x10B, ++ HKS_CMD_ID_MAC_UPDATE = 0x10C, ++ HKS_CMD_ID_MAC_FINAL = 0x10D, ++ HKS_CMD_ID_ENCRYPT = 0x10E, ++ HKS_CMD_ID_ENCRYPT_INIT = 0x10F, ++ HKS_CMD_ID_ENCRYPT_UPDATE = 0x110, ++ HKS_CMD_ID_ENCRYPT_FINAL = 0x111, ++ HKS_CMD_ID_DECRYPT = 0x112, ++ HKS_CMD_ID_DECRYPT_INIT = 0x113, ++ HKS_CMD_ID_DECRYPT_UPDATE = 0x114, ++ HKS_CMD_ID_DECRYPT_FINAL = 0x115, ++ HKS_CMD_ID_CHECK_KEY_LEGALITY = 0x116, ++ HKS_CMD_ID_GENERATE_RANDOM = 0x117, ++ HKS_CMD_ID_AGREE_KEY = 0x118, ++ HKS_CMD_ID_DERIVE_KEY = 0x119, ++ ++ HKS_CMD_ID_WRAP = 0x1000, ++ HKS_CMD_ID_UNWRAP = 0x1001, ++ ++ HKS_CMD_ID_SIGN_WITH_DEV_KEY = 0x00010103, ++ ++ HKS_CMD_ID_GET_FP_AUTH_RESULT_QCOM = 0x00020500, ++ ++ HKS_CMD_ID_INJECT_KEY = 0x00010015, ++ HKS_CMD_ID_INJECT_KEY_VERIFY = 0x00010016, ++}; ++ ++#endif +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_common_check.h b/huks/frameworks/huks_standard/main/common/include/hks_common_check.h +new file mode 100644 +index 0000000..db6a986 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_common_check.h +@@ -0,0 +1,69 @@ ++/* ++ * Copyright (c) 2021-2022 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_COMMON_CHECK_H ++#define HKS_COMMON_CHECK_H ++ ++#include ++#include ++ ++#include "hks_type.h" ++ ++#define HKS_DIGEST_MD5_LEN 16 ++#define HKS_DIGEST_SHA1_LEN 20 ++#define HKS_DIGEST_SHA224_LEN 28 ++#define HKS_DIGEST_SHA256_LEN 32 ++#define HKS_DIGEST_SHA384_LEN 48 ++#define HKS_DIGEST_SHA512_LEN 64 ++#define HKS_DIGEST_SM3_LEN 32 ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksCheckBlob4(const struct HksBlob *data1, const struct HksBlob *data2, ++ const struct HksBlob *data3, const struct HksBlob *data4); ++ ++int32_t HksCheckBlob3(const struct HksBlob *data1, const struct HksBlob *data2, const struct HksBlob *data3); ++ ++int32_t HksCheckBlob2(const struct HksBlob *data1, const struct HksBlob *data2); ++ ++int32_t HksCheckParamSetValidity(const struct HksParamSet *paramSet); ++ ++int32_t HksCheckBlob4AndParamSet(const struct HksBlob *data1, const struct HksBlob *data2, ++ const struct HksBlob *data3, const struct HksBlob *data4, const struct HksParamSet *paramSet); ++ ++int32_t HksCheckBlob3AndParamSet(const struct HksBlob *data1, const struct HksBlob *data2, ++ const struct HksBlob *data3, const struct HksParamSet *paramSet); ++ ++int32_t HksCheckBlob2AndParamSet(const struct HksBlob *data1, const struct HksBlob *data2, ++ const struct HksParamSet *paramSet); ++ ++int32_t HksCheckBlobAndParamSet(const struct HksBlob *data, const struct HksParamSet *paramSet); ++ ++int32_t HksGetDigestLen(uint32_t digest, uint32_t *digestLen); ++ ++int32_t HksCheckAesAeMode(const struct HksParamSet *paramSet, bool *isAes, bool *isAeMode); ++ ++int32_t HksCheckWrappedDataFormatValidity(const struct HksBlob *wrappedData, uint32_t validTotalBlobs, ++ const uint32_t *validBlobLengths); ++ ++int32_t HksGetBlobFromWrappedData(const struct HksBlob *wrappedData, uint32_t blobIndex, uint32_t totalBlobs, ++ struct HksBlob *blob); ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_COMMON_CHECK_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_config.h b/huks/frameworks/huks_standard/main/common/include/hks_config.h +new file mode 100644 +index 0000000..188b48f +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_config.h +@@ -0,0 +1,228 @@ ++/* ++ * Copyright (c) 2021-2022 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_CONFIG_H ++#define HKS_CONFIG_H ++ ++#define HKS_SUPPORT_POSIX ++ ++#define HKS_SUPPORT_THREAD ++ ++#define HKS_LOG_ENGINE_LOG_CORE ++#define HKS_ENABLE_LOG_PUBLIC ++ ++#define HKS_SUPPORT_API_ATTEST_KEY ++ ++// #define HKS_SUPPORT_ACCESS_TOKEN ++ ++/* AES */ ++#define HKS_SUPPORT_AES_C ++#define HKS_SUPPORT_AES_GENERATE_KEY ++#define HKS_SUPPORT_AES_CBC_NOPADDING ++#define HKS_SUPPORT_AES_CBC_PKCS7 ++#define HKS_SUPPORT_AES_GCM ++#define HKS_SUPPORT_AES_CTR_NOPADDING ++#define HKS_SUPPORT_AES_ECB_NOPADDING ++#define HKS_SUPPORT_AES_ECB_PKCS7PADDING ++ ++/* BN */ ++#define HKS_SUPPORT_BN_C ++ ++/* ECC */ ++#define HKS_SUPPORT_ECC_C ++#define HKS_SUPPORT_ECC_GENERATE_KEY ++#define HKS_SUPPORT_ECC_GET_PUBLIC_KEY ++ ++#define HKS_SUPPORT_ECDH_C ++#define HKS_SUPPORT_ECDH_AGREE_KEY ++ ++#define HKS_SUPPORT_ECDSA_C ++#define HKS_SUPPORT_ECDSA_SIGN_VERIFY ++ ++/* ED25519 */ ++#define HKS_SUPPORT_ED25519_C ++#define HKS_SUPPORT_ED25519_GENERATE_KEY ++#define HKS_SUPPORT_ED25519_SIGN_VERIFY ++#define HKS_SUPPORT_ED2519_GET_PUBLIC_KEY ++ ++/* HASH */ ++#define HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_HASH_SHA1 ++#define HKS_SUPPORT_HASH_SHA224 ++#define HKS_SUPPORT_HASH_SHA256 ++#define HKS_SUPPORT_HASH_SHA384 ++#define HKS_SUPPORT_HASH_SHA512 ++#define HKS_SUPPORT_HASH_MD5 ++ ++/* HMAC */ ++#define HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_HMAC_GENERATE_KEY ++#define HKS_SUPPORT_HMAC_SHA1 ++#define HKS_SUPPORT_HMAC_SHA224 ++#define HKS_SUPPORT_HMAC_SHA256 ++#define HKS_SUPPORT_HMAC_SHA384 ++#define HKS_SUPPORT_HMAC_SHA512 ++ ++/* KDF */ ++#define HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_KDF_PBKDF2 ++#define HKS_SUPPORT_KDF_HKDF ++ ++/* RSA */ ++#define HKS_SUPPORT_RSA_C ++#define HKS_SUPPORT_RSA_GENERATE_KEY ++#define HKS_SUPPORT_RSA_CRYPT ++#define HKS_SUPPORT_RSA_SIGN_VERIFY ++#define HKS_SUPPORT_RSA_GET_PUBLIC_KEY ++#define HKS_SUPPORT_RSA_ECB_NOPADDING ++#define HKS_SUPPORT_RSA_ECB_PKCS1PADDING ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA1MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA224MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA256MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA384MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA512MGF1 ++#define HKS_SUPPORT_RSA_ECB_OEAPPADDING ++#define HKS_SUPPORT_RSA_PSS ++ ++/* DH */ ++#define HKS_SUPPORT_DH_C ++#define HKS_SUPPORT_DH_GENERATE_KEY ++#define HKS_SUPPORT_DH_AGREE_KEY ++#define HKS_SUPPORT_DH_GET_PUBLIC_KEY ++ ++/* DSA */ ++#define HKS_SUPPORT_DSA_C ++#define HKS_SUPPORT_DSA_GENERATE_KEY ++#define HKS_SUPPORT_DSA_SIGN_VERIFY ++#define HKS_SUPPORT_DSA_GET_PUBLIC_KEY ++ ++/* X25519 */ ++#define HKS_SUPPORT_X25519_C ++#define HKS_SUPPORT_X25519_GENERATE_KEY ++#define HKS_SUPPORT_X25519_AGREE_KEY ++#define HKS_SUPPORT_X25519_GET_PUBLIC_KEY ++ ++#define HKS_SUPPORT_ED25519_TO_X25519 ++ ++/* SM2 */ ++#ifdef HKS_SUPPORT_ECC_C ++#define HKS_SUPPORT_SM2_C ++#define HKS_SUPPORT_SM2_SIGN_VERIFY ++#ifdef HKS_SUPPORT_ECC_GENERATE_KEY ++#define HKS_SUPPORT_SM2_GENERATE_KEY ++#endif ++#ifdef HKS_SUPPORT_ECC_GET_PUBLIC_KEY ++#define HKS_SUPPORT_SM2_GET_PUBLIC_KEY ++#endif ++#endif ++ ++/* SM3 */ ++#define HKS_SUPPORT_SM3_C ++#define HKS_SUPPORT_SM3_GENERATE_KEY ++#if defined(HKS_SUPPORT_SM3_C) && defined(HKS_SUPPORT_HMAC_C) ++#define HKS_SUPPORT_HMAC_SM3 ++#endif ++#if defined(HKS_SUPPORT_SM3_C) && defined(HKS_SUPPORT_HASH_C) ++#define HKS_SUPPORT_HASH_SM3 ++#endif ++ ++/* SM4 */ ++#define HKS_SUPPORT_SM4_C ++#define HKS_SUPPORT_SM4_GENERATE_KEY ++#define HKS_SUPPORT_SM4_CBC_NOPADDING ++#define HKS_SUPPORT_SM4_CBC_PKCS7 ++#define HKS_SUPPORT_SM4_CTR_NOPADDING ++#define HKS_SUPPORT_SM4_ECB_NOPADDING ++#define HKS_SUPPORT_SM4_ECB_PKCS7 ++ ++/* enable cfi */ ++#define HKS_SUPPORT_CFI ++ ++#if defined(_SUPPORT_HKS_TEE_) && defined(HKS_SUPPORT_HMAC_GENERATE_KEY) ++#define HKS_SUPPORT_GET_AT_KEY ++#endif ++ ++#if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_DH_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_DSA_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_HMAC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_RSA_GENERATE_KEY) || defined(HKS_SUPPORT_X25519_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_SM2_GENERATE_KEY) || defined(HKS_SUPPORT_SM3_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_SM4_GENERATE_KEY) ++#define HKS_SUPPORT_API_GENERATE_KEY ++#define HKS_SUPPORT_API_DELETE_KEY ++#define HKS_SUPPORT_API_GET_KEY_PARAM_SET ++#define HKS_SUPPORT_API_KEY_EXIST ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || defined(HKS_SUPPORT_ED25519_C) || \ ++ defined(HKS_SUPPORT_X25519_C) || defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_DSA_C) || \ ++ defined(HKS_SUPPORT_DH_C) || defined(HKS_SUPPORT_SM2_C) ++#define HKS_SUPPORT_API_IMPORT ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || defined(HKS_SUPPORT_ED25519_C) || \ ++ defined(HKS_SUPPORT_X25519_C) || defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_DSA_C) || \ ++ defined(HKS_SUPPORT_DH_C) || defined(HKS_SUPPORT_SM2_C) ++#define HKS_SUPPORT_API_EXPORT ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || defined(HKS_SUPPORT_ED25519_C) || \ ++ defined(HKS_SUPPORT_X25519_C) || defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_DSA_C) || \ ++ defined(HKS_SUPPORT_DH_C) || defined(HKS_SUPPORT_SM2_C) ++#define HKS_SUPPORT_API_IMPORT_WRAPPED_KEY ++#endif ++ ++#define HKS_SUPPORT_API_GENERATE_RANDOM ++ ++#if defined(HKS_SUPPORT_ECDSA_SIGN_VERIFY) || defined(HKS_SUPPORT_ED25519_SIGN_VERIFY) || \ ++ defined(HKS_SUPPORT_RSA_SIGN_VERIFY) || defined(HKS_SUPPORT_DSA_SIGN_VERIFY) ++#define HKS_SUPPORT_API_SIGN_VERIFY ++#endif ++ ++#if defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_RSA_CRYPT) ++#define HKS_SUPPORT_API_CIPHER ++#endif ++ ++#if defined(HKS_SUPPORT_X25519_AGREE_KEY) || defined(HKS_SUPPORT_ECDH_AGREE_KEY) || defined(HKS_SUPPORT_DH_AGREE_KEY) ++#define HKS_SUPPORT_API_AGREE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_API_DERIVE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_API_MAC ++#endif ++ ++#ifdef HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_API_HASH ++#endif ++ ++#ifdef HKS_SUPPORT_BN_C ++#define HKS_SUPPORT_API_BN_EXP_MOD ++#endif ++ ++#ifndef HKS_SUPPORT_LITE_HEAP ++#define HKS_SUPPORT_API_GET_KEY_INFO_LIST ++#endif ++ ++/* Key user auth access control */ ++// #if defined(HKS_SUPPORT_HMAC_C) && defined(HKS_SUPPORT_API_GENERATE_KEY) && (defined(HKS_SUPPORT_API_IMPORT) || \ ++// defined(HKS_SUPPORT_API_GENERATE_KEY) || defined(HKS_SUPPORT_API_IMPORT_WRAPPED_KEY)) ++// #define HKS_SUPPORT_USER_AUTH_ACCESS_CONTROL ++// #endif ++ ++#endif /* HKS_CONFIG_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_config_base.h b/huks/frameworks/huks_standard/main/common/include/hks_config_base.h +new file mode 100644 +index 0000000..f1c9fb1 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_config_base.h +@@ -0,0 +1,177 @@ ++/* ++ * Copyright (c) 2021-2022 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_CONFIG_H ++#define HKS_CONFIG_H ++ ++#define HKS_SUPPORT_LITE_HEAP ++#define HKS_SUPPORT_UPGRADE_STORAGE_DATA ++#define HKS_SUPPORT_POSIX ++ ++#define HKS_SUPPORT_SEC_LEVEL ++ ++/* AES */ ++#define HKS_SUPPORT_AES_C ++#define HKS_SUPPORT_AES_GENERATE_KEY ++#define HKS_SUPPORT_AES_CBC_NOPADDING ++#define HKS_SUPPORT_AES_CBC_PKCS7 ++#define HKS_SUPPORT_AES_GCM ++#define HKS_SUPPORT_AES_CCM ++#define HKS_SUPPORT_AES_CTR_NOPADDING ++#define HKS_SUPPORT_AES_ECB_NOPADDING ++#define HKS_SUPPORT_AES_ECB_PKCS7PADDING ++ ++/* BN */ ++#define HKS_SUPPORT_BN_C ++ ++/* ECC */ ++#define HKS_SUPPORT_ECC_C ++#define HKS_SUPPORT_ECC_GENERATE_KEY ++#define HKS_SUPPORT_ECC_GET_PUBLIC_KEY ++ ++#define HKS_SUPPORT_ECDH_C ++#define HKS_SUPPORT_ECDH_AGREE_KEY ++ ++#define HKS_SUPPORT_ECDSA_C ++#define HKS_SUPPORT_ECDSA_SIGN_VERIFY ++ ++/* ED25519 */ ++#define HKS_SUPPORT_ED25519_C ++#define HKS_SUPPORT_ED25519_GENERATE_KEY ++#define HKS_SUPPORT_ED25519_SIGN_VERIFY ++#define HKS_SUPPORT_ED2519_GET_PUBLIC_KEY ++ ++/* HASH */ ++#define HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_HASH_SHA1 ++#define HKS_SUPPORT_HASH_SHA224 ++#define HKS_SUPPORT_HASH_SHA256 ++#define HKS_SUPPORT_HASH_SHA384 ++#define HKS_SUPPORT_HASH_SHA512 ++#define HKS_SUPPORT_HASH_MD5 ++ ++/* HMAC */ ++#define HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_HMAC_GENERATE_KEY ++#define HKS_SUPPORT_HMAC_SHA1 ++#define HKS_SUPPORT_HMAC_SHA224 ++#define HKS_SUPPORT_HMAC_SHA256 ++#define HKS_SUPPORT_HMAC_SHA384 ++#define HKS_SUPPORT_HMAC_SHA512 ++ ++/* KDF */ ++#define HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_KDF_PBKDF2 ++#define HKS_SUPPORT_KDF_HKDF ++ ++/* RSA */ ++#define HKS_SUPPORT_RSA_C ++#define HKS_SUPPORT_RSA_GENERATE_KEY ++#define HKS_SUPPORT_RSA_CRYPT ++#define HKS_SUPPORT_RSA_SIGN_VERIFY ++#define HKS_SUPPORT_RSA_GET_PUBLIC_KEY ++#define HKS_SUPPORT_RSA_ECB_NOPADDING ++#define HKS_SUPPORT_RSA_ECB_PKCS1PADDING ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA1MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA224MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA256MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA384MGF1 ++#define HKS_SUPPORT_RSA_ECB_OAEPPADDING_SHA512MGF1 ++#define HKS_SUPPORT_RSA_ECB_OEAPPADDING ++#define HKS_SUPPORT_RSA_PSS ++ ++/* DH */ ++#define HKS_SUPPORT_DH_C ++#define HKS_SUPPORT_DH_GENERATE_KEY ++#define HKS_SUPPORT_DH_AGREE_KEY ++#define HKS_SUPPORT_DH_GET_PUBLIC_KEY ++ ++/* DSA */ ++#define HKS_SUPPORT_DSA_C ++#define HKS_SUPPORT_DSA_GENERATE_KEY ++#define HKS_SUPPORT_DSA_SIGN_VERIFY ++#define HKS_SUPPORT_DSA_GET_PUBLIC_KEY ++ ++/* X25519 */ ++#define HKS_SUPPORT_X25519_C ++#define HKS_SUPPORT_X25519_GENERATE_KEY ++#define HKS_SUPPORT_X25519_AGREE_KEY ++#define HKS_SUPPORT_X25519_GET_PUBLIC_KEY ++ ++#define HKS_SUPPORT_ED25519_TO_X25519 ++ ++#if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_DH_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_DSA_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_HMAC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_RSA_GENERATE_KEY) || defined(HKS_SUPPORT_X25519_GENERATE_KEY) ++#define HKS_SUPPORT_API_GENERATE_KEY ++#define HKS_SUPPORT_API_DELETE_KEY ++#define HKS_SUPPORT_API_GET_KEY_PARAM_SET ++#define HKS_SUPPORT_API_KEY_EXIST ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || defined(HKS_SUPPORT_ED25519_C) || \ ++ defined(HKS_SUPPORT_X25519_C) || defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_DSA_C) || \ ++ defined(HKS_SUPPORT_DH_C) ++#define HKS_SUPPORT_API_IMPORT ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || defined(HKS_SUPPORT_ED25519_C) || \ ++ defined(HKS_SUPPORT_X25519_C) || defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_DSA_C) || \ ++ defined(HKS_SUPPORT_DH_C) ++#define HKS_SUPPORT_API_EXPORT ++#endif ++ ++#define HKS_SUPPORT_API_GENERATE_RANDOM ++ ++#if defined(HKS_SUPPORT_ECDSA_SIGN_VERIFY) || defined(HKS_SUPPORT_ED25519_SIGN_VERIFY) || \ ++ defined(HKS_SUPPORT_RSA_SIGN_VERIFY) || defined(HKS_SUPPORT_DSA_SIGN_VERIFY) ++#define HKS_SUPPORT_API_SIGN_VERIFY ++#endif ++ ++#if defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_RSA_CRYPT) ++#define HKS_SUPPORT_API_CIPHER ++#endif ++ ++#if defined(HKS_SUPPORT_X25519_AGREE_KEY) || defined(HKS_SUPPORT_ECDH_AGREE_KEY) || defined(HKS_SUPPORT_DH_AGREE_KEY) ++#define HKS_SUPPORT_API_AGREE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_API_DERIVE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_API_MAC ++#endif ++ ++#ifdef HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_API_HASH ++#endif ++ ++#ifdef HKS_SUPPORT_BN_C ++#define HKS_SUPPORT_API_BN_EXP_MOD ++#endif ++ ++#ifndef HKS_SUPPORT_LITE_HEAP ++#define HKS_SUPPORT_API_GET_KEY_INFO_LIST ++#endif ++ ++#define HKS_SUPPORT_API_ATTEST_KEY ++#define HKS_SUPPORT_API_GET_CERTIFICATE_CHAIN ++#define HKS_SUPPORT_API_WRAP_KEY ++#define HKS_SUPPORT_API_UNWRAP_KEY ++ ++#endif /* HKS_CONFIG_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_config_lite.h b/huks/frameworks/huks_standard/main/common/include/hks_config_lite.h +new file mode 100644 +index 0000000..61ff132 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_config_lite.h +@@ -0,0 +1,111 @@ ++/* ++ * Copyright (c) 2021-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_CONFIG_H ++#define HKS_CONFIG_H ++ ++#define HKS_SUPPORT_POSIX ++ ++#define HKS_LOG_ENGINE_HILOG_MODULE_SCY ++ ++/* AES */ ++#define HKS_SUPPORT_AES_C ++#define HKS_SUPPORT_AES_GENERATE_KEY ++#define HKS_SUPPORT_AES_CBC_NOPADDING ++#define HKS_SUPPORT_AES_CBC_PKCS7 ++#define HKS_SUPPORT_AES_GCM ++ ++/* BN */ ++#define HKS_SUPPORT_BN_C ++ ++/* HASH */ ++#define HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_HASH_SHA256 ++#define HKS_SUPPORT_HASH_SHA384 ++#define HKS_SUPPORT_HASH_SHA512 ++ ++/* HMAC */ ++#define HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_HMAC_SHA256 ++#define HKS_SUPPORT_HMAC_SHA384 ++#define HKS_SUPPORT_HMAC_SHA512 ++ ++/* KDF */ ++#define HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_KDF_PBKDF2 ++#define HKS_SUPPORT_KDF_HKDF ++ ++/* X25519 */ ++#define HKS_SUPPORT_X25519_C ++#define HKS_SUPPORT_X25519_GENERATE_KEY ++#define HKS_SUPPORT_X25519_AGREE_KEY ++#define HKS_SUPPORT_X25519_GET_PUBLIC_KEY ++ ++#if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_RSA_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_X25519_GENERATE_KEY) ++#define HKS_SUPPORT_API_GENERATE_KEY ++#define HKS_SUPPORT_API_DELETE_KEY ++#define HKS_SUPPORT_API_GET_KEY_PARAM_SET ++#define HKS_SUPPORT_API_KEY_EXIST ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ ++ defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) || \ ++ defined(HKS_SUPPORT_AES_C) ++#define HKS_SUPPORT_API_IMPORT ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ ++ defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) ++#define HKS_SUPPORT_API_EXPORT ++#endif ++ ++#define HKS_SUPPORT_API_GENERATE_RANDOM ++ ++#if defined(HKS_SUPPORT_ECDSA_C) || defined(HKS_SUPPORT_ED25519_SIGN_VERIFY) || \ ++ defined(HKS_SUPPORT_RSA_SIGN_VERIFY) ++#define HKS_SUPPORT_API_SIGN_VERIFY ++#endif ++ ++#if defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_RSA_CRYPT) ++#define HKS_SUPPORT_API_CIPHER ++#endif ++ ++#if defined(HKS_SUPPORT_X25519_AGREE_KEY) || defined(HKS_SUPPORT_ECDH_C) ++#define HKS_SUPPORT_API_AGREE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_API_DERIVE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_API_MAC ++#endif ++ ++#ifdef HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_API_HASH ++#endif ++ ++#ifdef HKS_SUPPORT_BN_C ++#define HKS_SUPPORT_API_BN_EXP_MOD ++#endif ++ ++#ifndef HKS_SUPPORT_LITE_HEAP ++#define HKS_SUPPORT_API_GET_KEY_INFO_LIST ++#endif ++ ++#endif /* HKS_CONFIG_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_config_small.h b/huks/frameworks/huks_standard/main/common/include/hks_config_small.h +new file mode 100644 +index 0000000..d8692e7 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_config_small.h +@@ -0,0 +1,136 @@ ++/* ++ * Copyright (c) 2021-2022 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_CONFIG_H ++#define HKS_CONFIG_H ++ ++#define HKS_SUPPORT_POSIX ++ ++#ifndef __LINUX__ ++#define HKS_ENABLE_LOG_PUBLIC ++#endif ++#define HKS_LOG_ENGINE_HILOG_MODULE_SCY ++ ++/* AES */ ++#define HKS_SUPPORT_AES_C ++#define HKS_SUPPORT_AES_GENERATE_KEY ++#define HKS_SUPPORT_AES_CBC_NOPADDING ++#define HKS_SUPPORT_AES_CBC_PKCS7 ++#define HKS_SUPPORT_AES_GCM ++ ++/* BN */ ++#define HKS_SUPPORT_BN_C ++ ++/* ECC */ ++#define HKS_SUPPORT_ECC_C ++#define HKS_SUPPORT_ECC_GENERATE_KEY ++#define HKS_SUPPORT_ECC_GET_PUBLIC_KEY ++#define HKS_SUPPORT_ECDH_C ++#define HKS_SUPPORT_ECDSA_C ++ ++/* ED25519 */ ++#define HKS_SUPPORT_ED25519_C ++#define HKS_SUPPORT_ED25519_GENERATE_KEY ++#define HKS_SUPPORT_ED25519_SIGN_VERIFY ++#define HKS_SUPPORT_ED2519_GET_PUBLIC_KEY ++ ++/* HASH */ ++#define HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_HASH_SHA256 ++#define HKS_SUPPORT_HASH_SHA384 ++#define HKS_SUPPORT_HASH_SHA512 ++ ++/* HMAC */ ++#define HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_HMAC_SHA256 ++#define HKS_SUPPORT_HMAC_SHA384 ++#define HKS_SUPPORT_HMAC_SHA512 ++ ++/* KDF */ ++#define HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_KDF_PBKDF2 ++#define HKS_SUPPORT_KDF_HKDF ++ ++/* RSA */ ++#define HKS_SUPPORT_RSA_C ++#define HKS_SUPPORT_RSA_GENERATE_KEY ++#define HKS_SUPPORT_RSA_CRYPT ++#define HKS_SUPPORT_RSA_SIGN_VERIFY ++#define HKS_SUPPORT_RSA_GET_PUBLIC_KEY ++ ++/* X25519 */ ++#define HKS_SUPPORT_X25519_C ++#define HKS_SUPPORT_X25519_GENERATE_KEY ++#define HKS_SUPPORT_X25519_AGREE_KEY ++#define HKS_SUPPORT_X25519_GET_PUBLIC_KEY ++ ++#define HKS_SUPPORT_ED25519_TO_X25519 ++ ++#if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_RSA_GENERATE_KEY) || \ ++ defined(HKS_SUPPORT_X25519_GENERATE_KEY) ++#define HKS_SUPPORT_API_GENERATE_KEY ++#define HKS_SUPPORT_API_DELETE_KEY ++#define HKS_SUPPORT_API_GET_KEY_PARAM_SET ++#define HKS_SUPPORT_API_KEY_EXIST ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ ++ defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) || \ ++ defined(HKS_SUPPORT_AES_C) ++#define HKS_SUPPORT_API_IMPORT ++#endif ++ ++#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ ++ defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) ++#define HKS_SUPPORT_API_EXPORT ++#endif ++ ++#define HKS_SUPPORT_API_GENERATE_RANDOM ++ ++#if defined(HKS_SUPPORT_ECDSA_C) || defined(HKS_SUPPORT_ED25519_SIGN_VERIFY) || \ ++ defined(HKS_SUPPORT_RSA_SIGN_VERIFY) ++#define HKS_SUPPORT_API_SIGN_VERIFY ++#endif ++ ++#if defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_RSA_CRYPT) ++#define HKS_SUPPORT_API_CIPHER ++#endif ++ ++#if defined(HKS_SUPPORT_X25519_AGREE_KEY) || defined(HKS_SUPPORT_ECDH_C) ++#define HKS_SUPPORT_API_AGREE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_KDF_C ++#define HKS_SUPPORT_API_DERIVE_KEY ++#endif ++ ++#ifdef HKS_SUPPORT_HMAC_C ++#define HKS_SUPPORT_API_MAC ++#endif ++ ++#ifdef HKS_SUPPORT_HASH_C ++#define HKS_SUPPORT_API_HASH ++#endif ++ ++#ifdef HKS_SUPPORT_BN_C ++#define HKS_SUPPORT_API_BN_EXP_MOD ++#endif ++ ++#ifndef HKS_SUPPORT_LITE_HEAP ++#define HKS_SUPPORT_API_GET_KEY_INFO_LIST ++#endif ++ ++#endif /* HKS_CONFIG_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_crypto_adapter.h b/huks/frameworks/huks_standard/main/common/include/hks_crypto_adapter.h +new file mode 100644 +index 0000000..a4d6a9c +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_crypto_adapter.h +@@ -0,0 +1,58 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_CRYPTO_ADAPTER_H ++#define HKS_CRYPTO_ADAPTER_H ++ ++#include ++#include ++ ++#include "hks_crypto_hal.h" ++#include "hks_type.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++void HksFillKeySpec(const struct HksParamSet *paramSet, struct HksKeySpec *spec); ++ ++void HksFillUsageSpec(const struct HksParamSet *paramSet, struct HksUsageSpec *usageSpec); ++ ++void HksFreeUsageSpec(struct HksUsageSpec **usageSpec); ++ ++void HksFillKeyDerivationParam(const struct HksParamSet *paramSet, struct HksKeyDerivationParam *param); ++ ++int32_t HksFillAeadParam(const struct HksParamSet *paramSet, struct HksBlob *inputText, struct HksUsageSpec *usageSpec, ++ bool isEncrypt); ++ ++int32_t HksFillIvParam(const struct HksParamSet *paramSet, struct HksUsageSpec *usageSpec); ++ ++int32_t HksBuildCipherUsageSpec(const struct HksParamSet *paramSet, bool isEncrypt, struct HksBlob *inputText, ++ struct HksUsageSpec **outUsageSpec); ++ ++int32_t HksGetEncryptAeTag(const struct HksParamSet *paramSet, const struct HksBlob *inData, struct HksBlob *outData, ++ struct HksBlob *tagAead); ++ ++int32_t HksSetKeyToMaterial(uint32_t alg, bool isPubKey, const struct HksBlob *key, struct HksBlob *keyMaterial); ++ ++int32_t HksGetKeyFromMaterial(uint32_t alg, bool isPubKey, const struct HksBlob *keyMaterial, struct HksBlob *key); ++ ++int32_t HksFormatKeyFromMaterial(uint32_t alg, const struct HksBlob *keyMaterial, struct HksParamSet *paramSetOut); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +\ No newline at end of file +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_crypto_hal.h b/huks/frameworks/huks_standard/main/common/include/hks_crypto_hal.h +new file mode 100644 +index 0000000..1543691 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_crypto_hal.h +@@ -0,0 +1,255 @@ ++/* ++ * Copyright (c) 2021-2022 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_CRYPTO_HAL_H ++#define HKS_CRYPTO_HAL_H ++ ++#include "hks_type.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++enum HksKeyAlgMode { ++ HKS_ALGORITHM_RSA_MODE_CRT = 1, ++ HKS_ALGORITHM_RSA_MODE_NO_CRT = 2, ++ HKS_ALGORITHM_EC_MODE_ECDH = 3, ++ HKS_ALGORITHM_ED_MODE_SIG_VERIFY = 4, ++ HKS_ALGORITHM_ED_MODE_VERIFY = 5, ++ HKS_ALGORITHM_X25519_MODE = 6, ++}; ++ ++struct HksKeySpec { ++ uint32_t algType; ++ uint32_t keyLen; ++ void *algParam; /* for example : struct HksKeyDerivationParam */ ++}; ++ ++struct HksKeyDerivationParam { ++ struct HksBlob salt; ++ struct HksBlob info; ++ uint32_t iterations; ++ uint32_t digestAlg; ++}; ++ ++struct HksAeadParam { ++ struct HksBlob nonce; ++ struct HksBlob aad; ++ union { ++ struct HksBlob tagDec; ++ uint32_t tagLenEnc; ++ }; ++ uint32_t payloadLen; ++}; ++ ++struct HksCipherParam { ++ struct HksBlob iv; ++}; ++ ++struct HksUsageSpec { ++ uint32_t algType; ++ uint32_t mode; ++ uint32_t padding; ++ uint32_t digest; ++ uint32_t purpose; ++ /* ++ * Different algorithms correspond to different structures,for example: ++ * struct HksAeadParam for aead; ++ * struct HksCipherParam for cipher; ++ */ ++ void *algParam; ++}; ++ ++struct KeyMaterialRsa { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++ uint32_t nSize; ++ uint32_t eSize; ++ uint32_t dSize; ++}; ++ ++struct KeyMaterialEcc { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++ uint32_t xSize; ++ uint32_t ySize; ++ uint32_t zSize; ++}; ++ ++struct KeyMaterialDsa { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++ uint32_t xSize; ++ uint32_t ySize; ++ uint32_t pSize; ++ uint32_t qSize; ++ uint32_t gSize; ++}; ++ ++struct KeyMaterialDh { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++ uint32_t pubKeySize; ++ uint32_t priKeySize; ++ uint32_t reserved; ++}; ++ ++struct KeyMaterial25519 { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++ uint32_t pubKeySize; ++ uint32_t priKeySize; ++ uint32_t reserved; ++}; ++ ++typedef int32_t (*GetMainKey)(const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*GenerateKey)(const struct HksKeySpec *, struct HksBlob *); ++ ++typedef int32_t (*PubKey)(const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*DeriveKey)(const struct HksBlob *, const struct HksKeySpec *, struct HksBlob *); ++ ++typedef int32_t (*FillRandom)(struct HksBlob *); ++ ++typedef int32_t (*AgreeKey)(const struct HksBlob *, const struct HksBlob *, const struct HksKeySpec *, ++ struct HksBlob *); ++ ++typedef int32_t (*Sign)(const struct HksBlob *, const struct HksUsageSpec *, const struct HksBlob *, ++ struct HksBlob *); ++ ++typedef int32_t (*Verify)(const struct HksBlob *, const struct HksUsageSpec *, const struct HksBlob *, ++ const struct HksBlob *); ++ ++typedef int32_t (*Hmac)(const struct HksBlob *, uint32_t, const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*HmacInit)(void **, const struct HksBlob *, uint32_t); ++ ++typedef int32_t (*HmacUpdate)(void *, const struct HksBlob *); ++ ++typedef int32_t (*HmacFinal)(void **, const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*Hash)(uint32_t, const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*HashInit)(void **, uint32_t); ++ ++typedef int32_t (*HashUpdate)(void *, const struct HksBlob *); ++ ++typedef int32_t (*HashFinal)(void **, const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*Encrypt)(const struct HksBlob *, const struct HksUsageSpec *, ++ const struct HksBlob *, struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*EncryptInit)(void **, const struct HksBlob *, const struct HksUsageSpec *, const bool); ++ ++typedef int32_t (*EncryptUpdate)(void *, const struct HksBlob *, struct HksBlob *, const bool); ++ ++typedef int32_t (*EncryptFinal)(void **, const struct HksBlob *, struct HksBlob *, struct HksBlob *, const bool); ++ ++typedef int32_t (*Decrypt)(const struct HksBlob *, const struct HksUsageSpec *, ++ const struct HksBlob *, struct HksBlob *); ++ ++typedef int32_t (*DecryptInit)(void **, const struct HksBlob *, const struct HksUsageSpec *, const bool); ++ ++typedef int32_t (*DecryptUpdate)(void *, const struct HksBlob *, struct HksBlob *, const bool); ++ ++typedef int32_t (*DecryptFinal)(void **, const struct HksBlob *, struct HksBlob *, struct HksBlob *, const bool); ++ ++typedef int32_t (*BnExpMod)(struct HksBlob *, const struct HksBlob *, ++ const struct HksBlob *, const struct HksBlob *); ++ ++typedef void (*FreeCtx)(void **); ++ ++int32_t HksCryptoHalGetMainKey(const struct HksBlob *message, struct HksBlob *mainKey); ++ ++int32_t HksCryptoHalGenerateKey(const struct HksKeySpec *spec, struct HksBlob *key); ++ ++int32_t HksCryptoHalGetPubKey(const struct HksBlob *keyIn, struct HksBlob *keyOut); ++ ++int32_t HksCryptoHalDeriveKey(const struct HksBlob *mainKey, const struct HksKeySpec *derivationSpec, ++ struct HksBlob *derivedKey); ++ ++int32_t HksCryptoHalFillRandom(struct HksBlob *randomData); ++ ++int32_t HksCryptoHalFillPrivRandom(struct HksBlob *randomData); ++ ++int32_t HksCryptoHalAddEntropy(const struct HksBlob *entropy); ++ ++int32_t HksCryptoHalAgreeKey(const struct HksBlob *nativeKey, const struct HksBlob *pubKey, ++ const struct HksKeySpec *spec, struct HksBlob *sharedKey); ++ ++int32_t HksCryptoHalSign(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, ++ const struct HksBlob *message, struct HksBlob *signature); ++ ++int32_t HksCryptoHalVerify(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, ++ const struct HksBlob *message, const struct HksBlob *signature); ++ ++int32_t HksCryptoHalHmacInit(const struct HksBlob *key, uint32_t digestAlg, void **ctx); ++ ++int32_t HksCryptoHalHmacUpdate(const struct HksBlob *chunk, void *ctx); ++ ++int32_t HksCryptoHalHmacFinal(const struct HksBlob *msg, void **ctx, struct HksBlob *mac); ++ ++void HksCryptoHalHmacFreeCtx(void **ctx); ++ ++int32_t HksCryptoHalHmac(const struct HksBlob *key, uint32_t digestAlg, const struct HksBlob *msg, ++ struct HksBlob *mac); ++ ++int32_t HksCryptoHalHashInit(uint32_t alg, void **ctx); ++ ++int32_t HksCryptoHalHashUpdate(const struct HksBlob *msg, void *ctx); ++ ++int32_t HksCryptoHalHashFinal(const struct HksBlob *msg, void **ctx, struct HksBlob *hash); ++ ++void HksCryptoHalHashFreeCtx(void **ctx); ++ ++int32_t HksCryptoHalHash(uint32_t alg, const struct HksBlob *msg, struct HksBlob *hash); ++ ++int32_t HksCryptoHalEncryptInit(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, void **ctx); ++ ++int32_t HksCryptoHalEncryptUpdate(const struct HksBlob *message, void *ctx, struct HksBlob *out, ++ const uint32_t algtype); ++ ++int32_t HksCryptoHalEncryptFinal(const struct HksBlob *message, void **ctx, struct HksBlob *cipherText, ++ struct HksBlob *tagAead, const uint32_t algtype); ++ ++void HksCryptoHalEncryptFreeCtx(void **ctx, const uint32_t algtype); ++ ++int32_t HksCryptoHalEncrypt(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, ++ const struct HksBlob *message, struct HksBlob *cipherText, struct HksBlob *tagAead); ++ ++int32_t HksCryptoHalDecryptInit(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, void **ctx); ++ ++int32_t HksCryptoHalDecryptUpdate(const struct HksBlob *message, void *ctx, struct HksBlob *out, ++ const uint32_t algtype); ++ ++int32_t HksCryptoHalDecryptFinal(const struct HksBlob *message, void **ctx, struct HksBlob *cipherText, ++ struct HksBlob *tagAead, const uint32_t algtype); ++ ++void HksCryptoHalDecryptFreeCtx(void **ctx, const uint32_t algtype); ++ ++int32_t HksCryptoHalDecrypt(const struct HksBlob *key, const struct HksUsageSpec *usageSpec, ++ const struct HksBlob *message, struct HksBlob *cipherText); ++ ++int32_t HksCryptoHalBnExpMod(struct HksBlob *x, const struct HksBlob *a, ++ const struct HksBlob *e, const struct HksBlob *n); ++ ++int32_t HksCryptoHalInit(void); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_CRYPTO_HAL_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_errcode_adapter.h b/huks/frameworks/huks_standard/main/common/include/hks_errcode_adapter.h +new file mode 100644 +index 0000000..c3f025f +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_errcode_adapter.h +@@ -0,0 +1,51 @@ ++/* ++ * Copyright (c) 2022 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_ERRCODE_ADAPTER_H ++#define HKS_ERRCODE_ADAPTER_H ++ ++#ifdef __cplusplus ++#include ++#include ++#include ++#else ++#include ++#include ++#include ++#endif ++ ++#include "hks_type.h" ++ ++struct HksResult { ++ int32_t errorCode; ++ const char *errorMsg; ++ uint8_t *data; ++}; ++ ++struct HksError { ++ int32_t innerErrCode; ++ struct HksResult hksResult; ++}; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++struct HksResult HksConvertErrCode(int32_t result); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_ERRCODE_ADAPTER_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_log.h b/huks/frameworks/huks_standard/main/common/include/hks_log.h +new file mode 100644 +index 0000000..5815e0c +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_log.h +@@ -0,0 +1,64 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_LOG_H ++#define HKS_LOG_H ++ ++#include "hks_type.h" ++ ++#ifdef HKS_CONFIG_FILE ++#include HKS_CONFIG_FILE ++#else ++#include "hks_config.h" ++#endif ++ ++#ifdef _HUKS_LOG_ENABLE_ ++#ifdef HKS_ENABLE_LOG_PUBLIC ++#define LOG_PUBLIC "{public}" ++#else ++#define LOG_PUBLIC ++#endif ++ ++#undef LOG_TAG ++#define LOG_TAG "HUKS" ++#undef LOG_DOMAIN ++#define LOG_DOMAIN 0xD002F00 /* Security subsystem's domain id */ ++ ++#ifdef HKS_LOG_ENGINE_LOG_CORE ++#include "hilog/log.h" ++#define LOG_ENGINE LOG_CORE ++#else ++#ifdef HKS_LOG_ENGINE_HILOG_MODULE_SCY ++#include "log.h" ++#define LOG_ENGINE HILOG_MODULE_SCY ++#endif ++#endif ++ ++#define HKS_LOG_I(fmt, arg...) HILOG_INFO(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \ ++ __func__, __LINE__, ##arg) ++#define HKS_LOG_W(fmt, arg...) HILOG_WARN(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \ ++ __func__, __LINE__, ##arg) ++#define HKS_LOG_E(fmt, arg...) HILOG_ERROR(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \ ++ __func__, __LINE__, ##arg) ++#define HKS_LOG_D(fmt, arg...) HILOG_DEBUG(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \ ++ __func__, __LINE__, ##arg) ++#else ++#define HKS_LOG_I(...) ++#define HKS_LOG_W(...) ++#define HKS_LOG_E(...) ++#define HKS_LOG_D(...) ++#endif ++ ++#endif /* HKS_LOG_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_mem.h b/huks/frameworks/huks_standard/main/common/include/hks_mem.h +new file mode 100644 +index 0000000..af6a0ef +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_mem.h +@@ -0,0 +1,62 @@ ++/* ++ * Copyright (c) 2021-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_MEM_H ++#define HKS_MEM_H ++ ++#ifdef __cplusplus ++#include ++#include ++ ++#define HKS_NULL_POINTER nullptr ++#else ++#include ++#include ++ ++#define HKS_NULL_POINTER NULL ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++void *HksMalloc(size_t size); ++int32_t HksMemCmp(const void *ptr1, const void *ptr2, uint32_t size); ++ ++#define SELF_FREE_PTR(PTR, FREE_FUNC) \ ++{ \ ++ if ((PTR) != HKS_NULL_POINTER) { \ ++ FREE_FUNC(PTR); \ ++ (PTR) = HKS_NULL_POINTER; \ ++ } \ ++} ++ ++#define HKS_FREE_PTR(p) SELF_FREE_PTR(p, free) ++ ++#define HksFree(p) SELF_FREE_PTR(p, free) ++ ++#define HKS_FREE_BLOB(blob) do { \ ++ if ((blob).data != HKS_NULL_POINTER) { \ ++ free((blob).data); \ ++ (blob).data = HKS_NULL_POINTER; \ ++ } \ ++ (blob).size = 0; \ ++} while (0) ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_MEM_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_template.h b/huks/frameworks/huks_standard/main/common/include/hks_template.h +new file mode 100644 +index 0000000..f9c9dcb +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_template.h +@@ -0,0 +1,75 @@ ++/* ++ * Copyright (c) 2022 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_TEMPLATE_H ++#define HKS_TEMPLATE_H ++ ++#undef HKS_NULL_POINTER ++ ++#ifdef __cplusplus ++#define HKS_NULL_POINTER nullptr ++#else ++#define HKS_NULL_POINTER NULL ++#endif ++ ++#define HKS_IF_NOT_SUCC_LOGE_RETURN(RESULT, ERROR_CODE, LOG_MESSAGE, ...) \ ++if ((RESULT) != HKS_SUCCESS) { \ ++ HKS_LOG_E(LOG_MESSAGE, ##__VA_ARGS__); \ ++ return (ERROR_CODE); \ ++} ++ ++#define HKS_IF_NOT_SUCC_LOGE_BREAK(RESULT, LOG_MESSAGE, ...) \ ++if ((RESULT) != HKS_SUCCESS) { \ ++ HKS_LOG_E(LOG_MESSAGE, ##__VA_ARGS__); \ ++ break; \ ++} ++ ++#define HKS_IF_NOT_SUCC_BREAK(RESULT, ...) \ ++if ((RESULT) != HKS_SUCCESS) { \ ++ break; \ ++} ++ ++#define HKS_IF_NOT_SUCC_LOGE(RESULT, LOG_MESSAGE, ...) \ ++if ((RESULT) != HKS_SUCCESS) { \ ++ HKS_LOG_E(LOG_MESSAGE, ##__VA_ARGS__); \ ++} ++ ++#define HKS_IF_NOT_SUCC_RETURN(RESULT, ERROR_CODE) \ ++if ((RESULT) != HKS_SUCCESS) { \ ++ return (ERROR_CODE); \ ++} ++ ++#define HKS_IF_NULL_LOGE_RETURN(OBJECT, ERROR_CODE, LOG_MESSAGE, ...) \ ++if ((OBJECT) == HKS_NULL_POINTER) { \ ++ HKS_LOG_E(LOG_MESSAGE, ##__VA_ARGS__); \ ++ return (ERROR_CODE); \ ++} ++ ++#define HKS_IF_NULL_LOGE_BREAK(OBJECT, LOG_MESSAGE, ...) \ ++if ((OBJECT) == HKS_NULL_POINTER) { \ ++ HKS_LOG_E(LOG_MESSAGE, ##__VA_ARGS__); \ ++ break; \ ++} ++ ++#define HKS_IF_NULL_RETURN(OBJECT, ERROR_CODE) \ ++if ((OBJECT) == HKS_NULL_POINTER) { \ ++ return (ERROR_CODE); \ ++} ++ ++#define HKS_IF_NULL_BREAK(OBJECT) \ ++if ((OBJECT) == HKS_NULL_POINTER) { \ ++ break; \ ++} ++#endif /* HKS_TEMPLATE_H */ +diff --git a/huks/frameworks/huks_standard/main/common/include/hks_type_inner.h b/huks/frameworks/huks_standard/main/common/include/hks_type_inner.h +new file mode 100644 +index 0000000..d32663d +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/common/include/hks_type_inner.h +@@ -0,0 +1,94 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_TYPE_INNER_H ++#define HKS_TYPE_INNER_H ++ ++#include "hks_type.h" ++#include "securec.h" ++ ++#define HANDLE_SIZE 8 ++#define DEFAULT_AUTH_TIMEOUT 5 ++ ++/* EnrolledIdInfo stored format: |-enrolledId len-|-enrolledId1 type-|-enrolledId1 value-|...| */ ++#define ENROLLED_ID_INFO_MIN_LEN (sizeof(uint32_t) + (sizeof(uint32_t) + sizeof(uint64_t))) ++ ++enum HksUserAuthResult { ++ HKS_AUTH_RESULT_NONE = -2, // not support user auth ++ HKS_AUTH_RESULT_INIT = -1, ++ HKS_AUTH_RESULT_SUCCESS = 0, ++ HKS_AUTH_RESULT_FAILED = 1, ++}; ++ ++enum HksStageType { ++ HKS_STAGE_THREE = 0, ++ HKS_STAGE_ONE = 1, ++}; ++ ++enum HksInnerTag { ++ HKS_TAG_APPENDED_DATA_PREFIX = HKS_TAG_TYPE_BYTES | 10020, ++ HKS_TAG_APPENDED_DATA_SUFFIX = HKS_TAG_TYPE_BYTES | 10021, ++ ++ /* Inner-use TAGS used for ipc serialization */ ++ HKS_TAG_PARAM0_BUFFER = HKS_TAG_TYPE_BYTES | 30001, ++ HKS_TAG_PARAM1_BUFFER = HKS_TAG_TYPE_BYTES | 30002, ++ HKS_TAG_PARAM2_BUFFER = HKS_TAG_TYPE_BYTES | 30003, ++ HKS_TAG_PARAM3_BUFFER = HKS_TAG_TYPE_BYTES | 30004, ++ HKS_TAG_PARAM4_BUFFER = HKS_TAG_TYPE_BYTES | 30005, ++ HKS_TAG_PARAM0_UINT32 = HKS_TAG_TYPE_UINT | 30006, ++ HKS_TAG_PARAM1_UINT32 = HKS_TAG_TYPE_UINT | 30007, ++ HKS_TAG_PARAM2_UINT32 = HKS_TAG_TYPE_UINT | 30008, ++ HKS_TAG_PARAM3_UINT32 = HKS_TAG_TYPE_UINT | 30009, ++ HKS_TAG_PARAM4_UINT32 = HKS_TAG_TYPE_UINT | 30010, ++ HKS_TAG_PARAM0_BOOL = HKS_TAG_TYPE_BOOL | 30011, ++ HKS_TAG_PARAM1_BOOL = HKS_TAG_TYPE_BOOL | 30012, ++ HKS_TAG_PARAM2_BOOL = HKS_TAG_TYPE_BOOL | 30013, ++ HKS_TAG_PARAM3_BOOL = HKS_TAG_TYPE_BOOL | 30014, ++ HKS_TAG_PARAM4_BOOL = HKS_TAG_TYPE_BOOL | 30015, ++ HKS_TAG_PARAM0_NULL = HKS_TAG_TYPE_BYTES | 30016, ++ HKS_TAG_PARAM1_NULL = HKS_TAG_TYPE_BYTES | 30017, ++ HKS_TAG_PARAM2_NULL = HKS_TAG_TYPE_BYTES | 30018, ++ HKS_TAG_PARAM3_NULL = HKS_TAG_TYPE_BYTES | 30019, ++ HKS_TAG_PARAM4_NULL = HKS_TAG_TYPE_BYTES | 30020, ++ ++ HKS_TAG_ACCESS_TOKEN_ID = HKS_TAG_TYPE_UINT | 30021, ++}; ++ ++#define HKS_PARAM_BUFFER_NULL_INTERVAL ((HKS_TAG_PARAM0_NULL) - (HKS_TAG_PARAM0_BUFFER)) ++ ++struct HksProcessInfo { ++ struct HksBlob userId; ++ struct HksBlob processName; ++ int32_t userIdInt; ++ uint64_t accessTokenId; ++}; ++ ++struct HksParamOut { ++ uint32_t tag; ++ union { ++ bool *boolParam; ++ int32_t *int32Param; ++ uint32_t *uint32Param; ++ uint64_t *uint64Param; ++ struct HksBlob *blob; ++ }; ++}; ++ ++struct HksKeyMaterialHeader { ++ enum HksKeyAlg keyAlg; ++ uint32_t keySize; ++}; ++ ++#endif /* HKS_TYPE_INNER_H */ +diff --git a/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn b/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn +new file mode 100644 +index 0000000..3cc5c64 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn +@@ -0,0 +1,10 @@ ++import("//build/ohos.gni") ++ ++config("huks_config") { ++ include_dirs = ["//base/security/huks/frameworks/huks_standard/main/os_dependency/ipc/include"] ++ libs = ["huks_os_dependency_standard_static"] ++} ++ ++group("libhuks_os_dependency_standard_static") { ++ public_configs = [":huks_config"] ++} +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h +new file mode 100644 +index 0000000..206dfd4 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h +@@ -0,0 +1,90 @@ ++/* ++ * Copyright (c) 2021-2022 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_CLIENT_IPC_H ++#define HKS_CLIENT_IPC_H ++ ++#include "hks_type_inner.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksClientInitialize(void); ++ ++int32_t HksClientRefreshKeyInfo(void); ++ ++int32_t HksClientGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn, ++ struct HksParamSet *paramSetOut); ++ ++int32_t HksClientImportKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ const struct HksBlob *key); ++ ++int32_t HksClientExportPublicKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ struct HksBlob *key); ++ ++int32_t HksClientImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias, ++ const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData); ++ ++int32_t HksClientDeleteKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); ++ ++int32_t HksClientGetKeyParamSet(const struct HksBlob *keyAlias, struct HksParamSet *paramSet); ++ ++int32_t HksClientKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); ++ ++int32_t HksClientGenerateRandom(struct HksBlob *random, const struct HksParamSet *paramSet); ++ ++int32_t HksClientSign(const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *srcData, struct HksBlob *signature); ++ ++int32_t HksClientVerify(const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *srcData, const struct HksBlob *signature); ++ ++int32_t HksClientEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *plainText, struct HksBlob *cipherText); ++ ++int32_t HksClientDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, ++ const struct HksBlob *cipherText, struct HksBlob *plainText); ++ ++int32_t HksClientAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, ++ const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); ++ ++int32_t HksClientDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey, ++ struct HksBlob *derivedKey); ++ ++int32_t HksClientMac(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData, ++ struct HksBlob *mac); ++ ++int32_t HksClientGetKeyInfoList(struct HksKeyInfo *keyInfoList, uint32_t *listCount); ++ ++int32_t HksClientAttestKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ struct HksCertChain *certChain); ++ ++int32_t HksClientInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, struct HksBlob *handle, ++ struct HksBlob *token); ++ ++int32_t HksClientUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, ++ struct HksBlob *outData); ++ ++int32_t HksClientFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, ++ struct HksBlob *outData); ++ ++int32_t HksClientAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_CLIENT_IPC_H */ +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h +new file mode 100644 +index 0000000..761247c +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h +@@ -0,0 +1,55 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_CRYPTO_CHECK_H ++#define HKS_CRYPTO_CHECK_H ++ ++#include ++#include ++ ++#include "hks_type.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksCheckIpcGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn); ++ ++int32_t HksCheckIpcImportKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ const struct HksBlob *key); ++ ++int32_t HksCheckIpcImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias, ++ const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData); ++ ++int32_t HksCheckIpcExportPublicKey(const struct HksBlob *keyAlias, const struct HksBlob *key); ++ ++int32_t HksCheckIpcGetKeyParamSet(const struct HksBlob *keyAlias, struct HksParamSet *paramSet); ++ ++int32_t HksCheckIpcAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, ++ const struct HksBlob *peerPublicKey, const struct HksBlob *agreedKey); ++ ++int32_t HksCheckIpcDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey, ++ const struct HksBlob *derivedKey); ++ ++int32_t HksCheckIpcGetKeyInfoList(const struct HksKeyInfo *keyInfoList, uint32_t listCount); ++ ++int32_t HksCheckIpcCertificateChain(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ const struct HksCertChain *certChain); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +\ No newline at end of file +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h +new file mode 100644 +index 0000000..59cf16e +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (c) 2021-2022 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_IPC_SERIALIZATION_H ++#define HKS_IPC_SERIALIZATION_H ++ ++#include ++#include ++ ++#include "hks_type_inner.h" ++ ++#define MAX_IPC_BUF_SIZE 0x10000 /* Maximun IPC message buffer size. */ ++#define MAX_IPC_RSV_SIZE 0x400 /* Reserve IPC message buffer size */ ++#define MAX_PROCESS_SIZE (MAX_IPC_BUF_SIZE - MAX_IPC_RSV_SIZE) ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t CopyUint32ToBuffer(uint32_t value, const struct HksBlob *destBlob, uint32_t *destOffset); ++ ++int32_t HksGenerateKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, ++ const struct HksParamSet *paramSetIn, const struct HksBlob *keyOut); ++ ++int32_t HksImportKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, ++ const struct HksBlob *key); ++ ++int32_t HksImportWrappedKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, ++ const struct HksBlob *wrappingKeyAlias, const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData); ++ ++int32_t HksExportPublicKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksBlob *key); ++ ++int32_t HksGetKeyParamSetPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksBlob *keyOut); ++ ++int32_t HksOnceParamPack(struct HksBlob *destData, const struct HksBlob *key, const struct HksParamSet *paramSet, ++ uint32_t *offset); ++ ++int32_t HksOnceDataPack(struct HksBlob *destData, const struct HksBlob *inputData, const struct HksBlob *rsvData, ++ const struct HksBlob *outputData, uint32_t *offset); ++ ++int32_t HksAgreeKeyPack(struct HksBlob *destData, const struct HksParamSet *paramSet, const struct HksBlob *privateKey, ++ const struct HksBlob *peerPublicKey, const struct HksBlob *agreedKey); ++ ++int32_t HksDeriveKeyPack(struct HksBlob *destData, const struct HksParamSet *paramSet, const struct HksBlob *kdfKey, ++ const struct HksBlob *derivedKey); ++ ++int32_t HksGetKeyInfoListPack(struct HksBlob *destData, uint32_t listCount, const struct HksKeyInfo *keyInfoList); ++ ++int32_t HksGetKeyInfoListUnpackFromService(const struct HksBlob *srcData, uint32_t *listCount, ++ struct HksKeyInfo *keyInfoList); ++ ++int32_t HksCertificateChainPack(struct HksBlob *destData, const struct HksBlob *keyAlias, ++ const struct HksParamSet *paramSet, const struct HksBlob *certChainBlob); ++ ++int32_t HksCertificateChainUnpackFromService(const struct HksBlob *srcData, bool needEncode, ++ struct HksCertChain *certChain); ++ ++int32_t HksParamsToParamSet(struct HksParam *params, uint32_t cnt, struct HksParamSet **outParamSet); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_IPC_SERIALIZATION_H */ +\ No newline at end of file +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h +new file mode 100644 +index 0000000..a712cc1 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h +@@ -0,0 +1,34 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_IPC_SLICE_H ++#define HKS_IPC_SLICE_H ++ ++#include ++ ++#include "hks_type.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++int32_t HksSliceDataEntry(uint32_t cmdId, const struct HksBlob *key, const struct HksParamSet *paramSet, ++ struct HksBlob *inData, struct HksBlob *outData); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_SLICE_H */ +\ No newline at end of file +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h +new file mode 100644 +index 0000000..332fb99 +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h +@@ -0,0 +1,69 @@ ++/* ++ * Copyright (c) 2021-2022 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_REQUEST_H ++#define HKS_REQUEST_H ++ ++#include "hks_type_inner.h" ++ ++enum HksMessage { ++#ifndef _HKS_L1_TEE_ ++ HKS_MSG_BASE = 0x3a400, /* range of message value defined by router. globally unique */ ++#else ++ HKS_MSG_BASE = 1000, /* range of message value defined by SmartLock. Max 65535 */ ++#endif ++ HKS_MSG_GEN_KEY = HKS_MSG_BASE, ++ HKS_MSG_IMPORT_KEY, ++ HKS_MSG_EXPORT_PUBLIC_KEY, ++ HKS_MSG_IMPORT_WRAPPED_KEY, ++ HKS_MSG_DELETE_KEY, ++ HKS_MSG_GET_KEY_PARAMSET, ++ HKS_MSG_KEY_EXIST, ++ HKS_MSG_GENERATE_RANDOM, ++ HKS_MSG_SIGN, ++ HKS_MSG_VERIFY, ++ HKS_MSG_ENCRYPT, ++ HKS_MSG_DECRYPT, ++ HKS_MSG_AGREE_KEY, ++ HKS_MSG_DERIVE_KEY, ++ HKS_MSG_MAC, ++ HKS_MSG_GET_KEY_INFO_LIST, ++ HKS_MSG_ATTEST_KEY, ++ HKS_MSG_GET_CERTIFICATE_CHAIN, ++ HKS_MSG_INIT, ++ HKS_MSG_UPDATE, ++ HKS_MSG_FINISH, ++ HKS_MSG_ABORT, ++ HKS_MSG_MAX, /* new cmd type must be added before HKS_MSG_MAX */ ++}; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* ++ * SendRequest - Send the request message to target module by function call or ipc or other ways. ++ * @type: the request message type. ++ * @inBlob: the input serialized data blob. ++ * @outBlob: the output serialized data blob, can be null. ++ */ ++int32_t HksSendRequest(enum HksMessage type, const struct HksBlob *inBlob, struct HksBlob *outBlob, ++ const struct HksParamSet *paramSet); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* HKS_REQUEST_H */ +diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h +new file mode 100644 +index 0000000..b20f73b +--- /dev/null ++++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h +@@ -0,0 +1,32 @@ ++/* ++ * 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. ++ */ ++ ++#ifndef HKS_SAMGR_CLIENT_H ++#define HKS_SAMGR_CLIENT_H ++ ++#include "hks_samgr_server.h" ++#include "iproxy_client.h" ++ ++typedef struct { ++ INHERIT_CLIENT_IPROXY; ++ int32_t (*IpcAsyncCallBack)(IUnknown *iUnknown, enum HksMessageType type, const struct HksBlob *inBlob, ++ struct HksBlob *outBlob); ++} HksMgrClientApi; ++ ++typedef struct { ++ INHERIT_IUNKNOWNENTRY(HksMgrClientApi); ++} HksMgrClientEntry; ++ ++#endif +\ No newline at end of file +diff --git a/huks/interfaces/innerkits/huks_standard/main/BUILD.gn b/huks/interfaces/innerkits/huks_standard/main/BUILD.gn +new file mode 100644 +index 0000000..a539688 +--- /dev/null ++++ b/huks/interfaces/innerkits/huks_standard/main/BUILD.gn +@@ -0,0 +1,23 @@ ++# Copyright (C) 2021-2022 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. ++ ++import("//build/ohos.gni") ++ ++config("huks_config") { ++ include_dirs = [ "//base/security/huks/interfaces/innerkits/huks_standard/main/include" ] ++ libs = [ "hukssdk.z" ] ++} ++ ++group("libhukssdk") { ++ public_configs = [ ":huks_config" ] ++} +diff --git a/huks/interfaces/innerkits/huks_standard/main/include b/huks/interfaces/innerkits/huks_standard/main/include +new file mode 120000 +index 0000000..98a2378 +--- /dev/null ++++ b/huks/interfaces/innerkits/huks_standard/main/include +@@ -0,0 +1 @@ ++/usr/include/huks +\ No newline at end of file +-- +2.27.0 + diff --git a/0003-establish-kvstore-dependence-on-boundscheck.patch b/0003-establish-kvstore-dependence-on-boundscheck.patch new file mode 100644 index 0000000000000000000000000000000000000000..128fa57d67d9690b681292dc39dbd0c14f56d48d --- /dev/null +++ b/0003-establish-kvstore-dependence-on-boundscheck.patch @@ -0,0 +1,31 @@ +From 33ac1277b3be087f696451866a586e42d6495e91 Mon Sep 17 00:00:00 2001 +From: wang--ge +Date: Fri, 21 Jul 2023 16:47:28 +0800 +Subject: [PATCH] establish kvstore dependence on boundscheck + +--- + services/distributeddataservice/service/BUILD.gn | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn +index 35d02e2..3fb8263 100644 +--- a/services/distributeddataservice/service/BUILD.gn ++++ b/services/distributeddataservice/service/BUILD.gn +@@ -112,6 +112,7 @@ ohos_shared_library("distributeddatasvc") { + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", + "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner", ++ "//third_party/bounds_checking_function:libsec_shared", + ] + + external_deps = [ +@@ -132,4 +133,4 @@ ohos_shared_library("distributeddatasvc") { + subsystem_name = "distributeddatamgr" + + part_name = "datamgr_service" +-} +\ No newline at end of file ++} +-- +2.33.0 + diff --git a/distributeddatamgr_datamgr_service-OpenHarmony-v3.2-Release.tar.gz b/distributeddatamgr_datamgr_service-OpenHarmony-v3.2-Release.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f096f081d7f887bfca1b9156e53df1e2f8a51aef Binary files /dev/null and b/distributeddatamgr_datamgr_service-OpenHarmony-v3.2-Release.tar.gz differ diff --git a/distributeddatamgr_datamgr_service.spec b/distributeddatamgr_datamgr_service.spec new file mode 100644 index 0000000000000000000000000000000000000000..9f7519809c528ed187bac9464f40d95411929abd --- /dev/null +++ b/distributeddatamgr_datamgr_service.spec @@ -0,0 +1,85 @@ +%define debug_package %{nil} +%global oh_version OpenHarmony-v3.2-Release +%global datamgr_service_dir %{_builddir}/foundation/distributeddatamgr/ +%global build_opt /opt/distributed-middleware-build + +Name: distributeddatamgr_datamgr_service +Version: 1.0.0 +Release: 2 +Summary: Distributed data manager that provides the capability to store data in the databases of different devices +License: Apache-2.0 +Url: https://gitee.com/openharmony/distributeddatamgr_datamgr_service +Source0: https://gitee.com/openharmony/distributeddatamgr_datamgr_service/repository/archive/OpenHarmony-v3.2-Release.tar.gz#/distributeddatamgr_datamgr_service-OpenHarmony-v3.2-Release.tar.gz +Patch0: 0001-remove-useless-dependency.patch +Patch1: 0002-add-huks-component.patch +Patch2: 0003-establish-kvstore-dependence-on-boundscheck.patch + +BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel +BuildRequires: distributed-build distributed-build_lite hilog distributed-utils +BuildRequires: distributeddatamgr_relational_store distributeddatamgr_kv_store + +Requires: hilog distributed-utils distributeddatamgr_kv_store distributeddatamgr_relational_store + +%description +Distributed Data Service (DDS) provides the ability to distribute database data between different devices. +By combining account, application, and database triplets, distributed data services isolate data. +Among trusted authentication devices, the distributed data service supports mutual data synchronization, +providing users with a consistent data access experience on various terminal devices. + +%prep +rm -rf %{_builddir}/* + +cd %{_builddir} +cp -rp %{build_opt} %{_builddir}/build +[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh +[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn +[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py +mv build/openeuler/vendor %{_builddir}/ + +%setup -q -T -a 0 -c -n %{datamgr_service_dir} +mv %{datamgr_service_dir}%{name}-%{oh_version} %{datamgr_service_dir}datamgr_service +cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}/ +%patch0 -p1 -d %{datamgr_service_dir}datamgr_service +%patch1 -p1 -d %{_builddir}/base/security +%patch2 -p1 -d %{datamgr_service_dir}datamgr_service + +%build +cd %{_builddir} +rm -rf %{_builddir}/out +%ifarch x86_64 +./build.sh --product-name openeuler --target-cpu x86_64 +%endif + +%ifarch aarch64 +./build.sh --product-name openeuler --target-cpu arm64 +%endif + +%install +install -d -m 0755 %{buildroot}%{_includedir}/%{name} +install -d -m 0755 %{buildroot}%{_libdir} +install -d -m 0755 %{buildroot}/system/profile +install -d -m 0755 %{buildroot}/system/lib64 +install -d -m 0755 %{buildroot}/system/etc/distributeddata/conf + +%ifarch aarch64 +module_out_path="out/openeuler/linux_clang_arm64/distributeddatamgr/datamgr_service" +%endif +%ifarch x86_64 +module_out_path="out/openeuler/linux_clang_x86_64/distributeddatamgr/datamgr_service" +%endif + +install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}%{_libdir} +install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}/system/lib64 +install -m 0755 %{_builddir}/out/openeuler/packages/phone/system/profile/distributeddata.xml %{buildroot}/system/profile +install -m 0755 %{_builddir}/out/openeuler/packages/phone/system/etc/distributeddata/conf/* %{buildroot}/system/etc/distributeddata/conf/ + +%files +%{_libdir}/*.so +/system/* + +%changelog +* Thu Aug 03 2023 Peng He - 1.0.0-2 +- Add requires and rectify the contents of the RPM package. + +* Fri Jul 21 2023 Ge Wang - 1.0.0-1 +- init package