Upstream version 8.36.156.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / browser / installer / xpk_package.h
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef XWALK_APPLICATION_BROWSER_INSTALLER_XPK_PACKAGE_H_
6 #define XWALK_APPLICATION_BROWSER_INSTALLER_XPK_PACKAGE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_handle.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "xwalk/application/browser/installer/package.h"
15
16 namespace xwalk {
17 namespace application {
18
19 class XPKPackage : public Package {
20  public:
21   static const char kXPKPackageHeaderMagic[];
22   static const size_t kXPKPackageHeaderMagicSize = 4;
23   static const uint32 kMaxPublicKeySize = 1 << 16;
24   static const uint32 kMaxSignatureKeySize = 1 << 16;
25
26   struct Header {
27     char magic[kXPKPackageHeaderMagicSize];
28     uint32 key_size;
29     uint32 signature_size;
30   };
31   virtual ~XPKPackage();
32   explicit XPKPackage(const base::FilePath& path);
33   virtual bool Extract(base::FilePath* target_path) OVERRIDE;
34
35  private:
36   // verify the signature in the xpk package
37   virtual bool VerifySignature();
38
39   Header header_;
40   std::vector<uint8> signature_;
41   std::vector<uint8> key_;
42   // It's the beginning address of the zip file
43   int zip_addr_;
44 };
45
46 }  // namespace application
47 }  // namespace xwalk
48
49 #endif  // XWALK_APPLICATION_BROWSER_INSTALLER_XPK_PACKAGE_H_