1 /* 2 * Copyright (c) 2022 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 #ifndef PKG_VERIFY_UTIL_H 17 #define PKG_VERIFY_UTIL_H 18 19 #include <vector> 20 #include "pkcs7_signed_data.h" 21 #include "pkg_stream.h" 22 23 namespace Hpackage { 24 class PkgVerifyUtil { 25 public: PkgVerifyUtil()26 PkgVerifyUtil() {} 27 ~PkgVerifyUtil()28 ~PkgVerifyUtil() {} 29 30 int32_t VerifyPackageSign(const Hpackage::PkgStreamPtr PkgStream) const; 31 int32_t VerifySign(std::vector<uint8_t> &signData, std::vector<uint8_t> &digest) const; 32 33 int32_t GetSignature(const PkgStreamPtr pkgStream, size_t &signatureSize, 34 std::vector<uint8_t> &signature, uint16_t &commentTotalLenAll) const; 35 #ifndef UPDATER_UT 36 private: 37 #else 38 public: 39 #endif 40 41 int32_t ParsePackage(const PkgStreamPtr pkgStream, size_t &signatureStart, 42 size_t &signatureSize, uint16_t &commentTotalLenAll) const; 43 44 int32_t Pkcs7verify(std::vector<uint8_t> &signature, std::vector<uint8_t> &hash) const; 45 46 int32_t HashCheck(const PkgStreamPtr srcData, const size_t dataLen, 47 const std::vector<uint8_t> &hash) const; 48 }; 49 } // namespace Hpackage 50 #endif 51