• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PARSE_H
17 #define PKG_PARSE_H
18 
19 #include "pkg_stream.h"
20 #include "pkg_verify_util.h"
21 
22 namespace Hpackage {
23 class ZipPkgParse {
24 public:
ZipPkgParse()25     ZipPkgParse() {};
26 
~ZipPkgParse()27     ~ZipPkgParse() {};
28 
29     int32_t DoParseZipPkg(PkgStreamPtr pkgStream, PkgSignComment &pkgSignComment,
30         size_t &readLen, const uint16_t &signCommentAppendLen, uint16_t &signCommentTotalLen) const;
31 
32     int32_t ParseZipPkg(Hpackage::PkgStreamPtr pkgStream, PkgSignComment &pkgSignComment) const;
33 
34 private:
35     int32_t ParsePkgFooter(const uint8_t *footer, size_t length, uint16_t &signCommentAppendLen,
36         uint16_t &signCommentTotalLen) const;
37 
38     int32_t CheckZipEocd(const uint8_t *eocd, size_t length, uint16_t signCommentTotalLen) const;
39 };
40 } // namespace Hpackage
41 #endif
42