diff --git a/services/package/pkg_verify/pkcs7_signed_data.cpp b/services/package/pkg_verify/pkcs7_signed_data.cpp index fb38f77d9b488ce75c966f5002510956734e52ef..f554b6777ef9521e12ea253d2abe74f8dca26296 100644 --- a/services/package/pkg_verify/pkcs7_signed_data.cpp +++ b/services/package/pkg_verify/pkcs7_signed_data.cpp @@ -281,15 +281,15 @@ Pkcs7VerifyHelper::~Pkcs7VerifyHelper() return; } -int32_t Pkcs7VerifyHelper::GetDigestFromSubBlocks(std::vector &digestBlock, - HwSigningSigntureInfo &signatureInfo, std::vector &digest) +int32_t Pkcs7VerifyHelper::GetDigestFromSubBlocks( + std::vector &digestBlock, SignatureInfo &signatureInfo, std::vector &digest) { PKG_LOGE("Pkcs7VerifyHelper in"); return -1; } -int32_t Pkcs7SignedData::GetDigest(std::vector &digestBlock, - HwSigningSigntureInfo &signatureInfo, std::vector &digest) +int32_t Pkcs7SignedData::GetDigest( + std::vector &digestBlock, SignatureInfo &signatureInfo, std::vector &digest) { if (helper_ == nullptr) { PKG_LOGE("helper_ null error"); diff --git a/services/package/pkg_verify/pkcs7_signed_data.h b/services/package/pkg_verify/pkcs7_signed_data.h index 20618a76c81d838a75b98ac677d57eee2c8dba1a..015eda31490fa7b32cc4ee9348adc5920a4f3106 100644 --- a/services/package/pkg_verify/pkcs7_signed_data.h +++ b/services/package/pkg_verify/pkcs7_signed_data.h @@ -27,7 +27,7 @@ using DataBuffer = struct { size_t length; }; -using HwSigningSigntureInfo = struct { +using SignatureInfo = struct { DataBuffer overall; DataBuffer hashResult; int nid; @@ -55,8 +55,8 @@ enum { class VerifyHelper { public: - virtual int32_t GetDigestFromSubBlocks(std::vector &digestBlock, - HwSigningSigntureInfo &signatureInfo, std::vector &digest) = 0; + virtual int32_t GetDigestFromSubBlocks( + std::vector &digestBlock, SignatureInfo &signatureInfo, std::vector &digest) = 0; virtual ~VerifyHelper() {} }; @@ -80,8 +80,7 @@ public: static Pkcs7SignedData &GetInstance(); - int32_t GetDigest(std::vector &digestBlock, - HwSigningSigntureInfo &signatureInfo, std::vector &digest); + int32_t GetDigest(std::vector &digestBlock, SignatureInfo &signatureInfo, std::vector &digest); int32_t ReadSig(const uint8_t *sourceData, const uint32_t sourceDataLen, std::vector> &sigs); private: @@ -100,7 +99,7 @@ private: PKCS7 *pkcs7_; std::vector digest_; std::vector signerInfos_; - HwSigningSigntureInfo signatureInfo; + SignatureInfo signatureInfo; std::unique_ptr helper_ {}; }; @@ -110,8 +109,8 @@ public: ~Pkcs7VerifyHelper() override; - int32_t GetDigestFromSubBlocks(std::vector &digestBlock, - HwSigningSigntureInfo &signatureInfo, std::vector &digest) override; + int32_t GetDigestFromSubBlocks( + std::vector &digestBlock, SignatureInfo &signatureInfo, std::vector &digest) override; }; } // namespace Hpackage #endif diff --git a/services/updater_main.cpp b/services/updater_main.cpp index 5ce2aae57b017d6ab93b4f95d461ce64681b2a50..b1cb2b5e2667a63b8e708221688682985cd90ed5 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -224,7 +224,7 @@ int OtaUpdatePreCheck(PkgManager::PkgManagerPtr pkgManager, const std::string &p return PKG_INVALID_FILE; } - int32_t ret = pkgManager->VerifyOtaPackage(packagePath); + int32_t ret = pkgManager->VerifyOtaPackage(realPath); if (ret != PKG_SUCCESS) { LOG(INFO) << "VerifyOtaPackage fail ret :" << ret; UPDATER_LAST_WORD("sign", ret); diff --git a/test/unittest/package/BUILD.gn b/test/unittest/package/BUILD.gn index d9de02af89066ac70040c0937f4b1d6a20a3e3df..74d417560205130058062a3f4f8e5fe62f957542 100644 --- a/test/unittest/package/BUILD.gn +++ b/test/unittest/package/BUILD.gn @@ -31,6 +31,7 @@ ohos_unittest("package_unittest") { "pkg_manager_unittest.cpp", "pkg_package_unittest.cpp", "pkg_verify_unittest.cpp", + "pkg_signature_info_unittest.cpp", ] sources += [ diff --git a/test/unittest/package/pkg_signature_info_unittest.cpp b/test/unittest/package/pkg_signature_info_unittest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d6b5db545499b0a9a1ca9051f8c7f92fd2747e36 --- /dev/null +++ b/test/unittest/package/pkg_signature_info_unittest.cpp @@ -0,0 +1,65 @@ + /* + * Copyright (c) 2025 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. + */ + +#include +#include "log.h" +#include "pkcs7_signed_data.h" + +using namespace testing::ext; +using namespace Hpackage; +using namespace Updater; + +namespace UpdaterUt { +class PkgSignatureTest : public ::testing::Test { +public: + static void SetUpTestSuite(); + static void TearDownTestSuite(); + + void SetUp() override; + void TearDown() override; + +private: +}; + +void PkgSignatureTest::SetUpTestSuite() +{ +} + +void PkgSignatureTest::TearDownTestSuite() +{ +} + +void PkgSignatureTest::SetUp() +{ +} + +void PkgSignatureTest::TearDown() +{ +} + +HWTEST_F(PkgSignatureTest, TestDefaultPkcs7VerifyHelper, TestSize.Level1) +{ + std::vector digestBlock{}; // input + SignatureInfo signatureInfo{}; // output + std::vector digest{}; // output + + EXPECT_EQ(Pkcs7SignedData::GetInstance().GetDigest(digestBlock, signatureInfo, digest), -1); + EXPECT_TRUE(signatureInfo.overall.buffer.empty()); + EXPECT_EQ(signatureInfo.overall.length, 0); + EXPECT_TRUE(signatureInfo.hashResult.buffer.empty()); + EXPECT_EQ(signatureInfo.hashResult.length, 0); + EXPECT_EQ(signatureInfo.nid, 0); +} +} // namespace UpdaterUt diff --git a/updater_ux_guide.md b/updater_ux_guide.md index 7fe3a6b4ae9c5d90229294a3d1e61e19c1586b2d..43994485c5d045367e125d8debae69cdd8625284 100644 --- a/updater_ux_guide.md +++ b/updater_ux_guide.md @@ -148,7 +148,7 @@ updater部件是在升级模式下的轻量小系统,ux组件是一套系统 "coms": [ { "type": "UIImageView", - "id": "HarmonyOSIcon_Image", + "id": "OpenHarmonyIcon_Image", "x": 120, "y": 426, "w": 480, @@ -160,7 +160,7 @@ updater部件是在升级模式下的轻量小系统,ux组件是一套系统 "coms": [ { "type": "UIImageView", - "id": "HarmonyOSIcon_Image", + "id": "OpenHarmonyIcon_Image", "x": 0, "y": 0, "w": 480,