Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: chrome/browser/extensions/extension_creator.h

Issue 126014: Verify signed .crx extension installations (Closed)
Patch Set: final changes Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_ 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/crypto/rsa_private_key.h" 9 #include "base/crypto/rsa_private_key.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 12
13 // This class create an installable extension (.crx file) given an input 13 // This class create an installable extension (.crx file) given an input
14 // directory that contains a valid manifest.json and the extension's resources 14 // directory that contains a valid manifest.json and the extension's resources
15 // contained within that directory. The output .crx file is always signed with a 15 // contained within that directory. The output .crx file is always signed with a
16 // private key that is either provided in |private_key_path| or is internal 16 // private key that is either provided in |private_key_path| or is internal
17 // generated randomly (and optionally written to |output_private_key_path|. 17 // generated randomly (and optionally written to |output_private_key_path|.
18 class ExtensionCreator { 18 class ExtensionCreator {
19 public: 19 public:
20 // The size of the magic character sequence at the beginning of each crx file,
21 // in bytes. This should be a multiple of 4.
22 static const size_t kExtensionHeaderMagicSize = 4;
23
24 // The magic character sequence at the beginning of each crx file.
25 static const char kExtensionHeaderMagic[];
26
27 // The current version of the crx format.
28 static const uint32 kCurrentVersion = 2;
29
30 // This header is the first data at the beginning of an extension. Its
31 // contents are purposely 32-bit aligned so that it can just be slurped into
32 // a struct without manual parsing.
33 struct ExtensionHeader {
34 char magic[kExtensionHeaderMagicSize];
35 uint32 version;
36 size_t key_size; // The size of the public key, in bytes.
37 size_t signature_size; // The size of the signature, in bytes.
38 // An ASN.1-encoded PublicKeyInfo structure follows.
39 // The signature follows.
40 };
41
42 ExtensionCreator() {} 20 ExtensionCreator() {}
43 21
44 bool Run(const FilePath& extension_dir, 22 bool Run(const FilePath& extension_dir,
45 const FilePath& crx_path, 23 const FilePath& crx_path,
46 const FilePath& private_key_path, 24 const FilePath& private_key_path,
47 const FilePath& private_key_output_path); 25 const FilePath& private_key_output_path);
48 26
49 // Returns the error message that will be present if Run(...) returned false. 27 // Returns the error message that will be present if Run(...) returned false.
50 std::string error_message() { return error_message_; } 28 std::string error_message() { return error_message_; }
51 29
(...skipping 28 matching lines...) Expand all
80 const std::vector<uint8>& signature, 58 const std::vector<uint8>& signature,
81 const FilePath& crx_path); 59 const FilePath& crx_path);
82 60
83 // Holds a message for any error that is raised during Run(...). 61 // Holds a message for any error that is raised during Run(...).
84 std::string error_message_; 62 std::string error_message_;
85 63
86 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator); 64 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator);
87 }; 65 };
88 66
89 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_ 67 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698