• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "log.h"
18 #include "pkcs7_signed_data.h"
19 
20 using namespace testing::ext;
21 using namespace Hpackage;
22 using namespace Updater;
23 
24 namespace UpdaterUt {
25 class PkgSignatureTest : public ::testing::Test {
26 public:
27     static void SetUpTestSuite();
28     static void TearDownTestSuite();
29 
30     void SetUp() override;
31     void TearDown() override;
32 
33 private:
34 };
35 
SetUpTestSuite()36 void PkgSignatureTest::SetUpTestSuite()
37 {
38 }
39 
TearDownTestSuite()40 void PkgSignatureTest::TearDownTestSuite()
41 {
42 }
43 
SetUp()44 void PkgSignatureTest::SetUp()
45 {
46 }
47 
TearDown()48 void PkgSignatureTest::TearDown()
49 {
50 }
51 
52 HWTEST_F(PkgSignatureTest, TestDefaultPkcs7VerifyHelper, TestSize.Level1)
53 {
54     std::vector<uint8_t> digestBlock{};  // input
55     SignatureInfo signatureInfo{};       // output
56     std::vector<uint8_t> digest{};       // output
57 
58     EXPECT_EQ(Pkcs7SignedData::GetInstance().GetDigest(digestBlock, signatureInfo, digest), -1);
59     EXPECT_TRUE(signatureInfo.overall.buffer.empty());
60     EXPECT_EQ(signatureInfo.overall.length, 0);
61     EXPECT_TRUE(signatureInfo.hashResult.buffer.empty());
62     EXPECT_EQ(signatureInfo.hashResult.length, 0);
63     EXPECT_EQ(signatureInfo.nid, 0);
64 }
65 }  // namespace UpdaterUt
66