summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_creator.h
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 21:26:32 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 21:26:32 +0000
commita3b8c532a83a41f3a21907973b54570989afcde9 (patch)
tree878f40c8c352e045478fb6af8783e4c90e75ade3 /chrome/browser/extensions/extension_creator.h
parent8e53730a2199f914cbd79cf72c363ad33aea0802 (diff)
downloadchromium_src-a3b8c532a83a41f3a21907973b54570989afcde9.zip
chromium_src-a3b8c532a83a41f3a21907973b54570989afcde9.tar.gz
chromium_src-a3b8c532a83a41f3a21907973b54570989afcde9.tar.bz2
Remove the prepended manifest from the crx format. Now we just have the header, the public key, the signature, and the zip.
Review URL: http://codereview.chromium.org/118490 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_creator.h')
-rwxr-xr-xchrome/browser/extensions/extension_creator.h54
1 files changed, 37 insertions, 17 deletions
diff --git a/chrome/browser/extensions/extension_creator.h b/chrome/browser/extensions/extension_creator.h
index 6cdb6bc..febcecd 100755
--- a/chrome/browser/extensions/extension_creator.h
+++ b/chrome/browser/extensions/extension_creator.h
@@ -17,6 +17,28 @@
// generated randomly (and optionally written to |output_private_key_path|.
class ExtensionCreator {
public:
+ // The size of the magic character sequence at the beginning of each crx file,
+ // in bytes. This should be a multiple of 4.
+ static const size_t kExtensionHeaderMagicSize = 4;
+
+ // The magic character sequence at the beginning of each crx file.
+ static const char kExtensionHeaderMagic[];
+
+ // The current version of the crx format.
+ static const uint32 kCurrentVersion = 2;
+
+ // This header is the first data at the beginning of an extension. Its
+ // contents are purposely 32-bit aligned so that it can just be slurped into
+ // a struct without manual parsing.
+ struct ExtensionHeader {
+ char magic[kExtensionHeaderMagicSize];
+ uint32 version;
+ size_t key_size; // The size of the public key, in bytes.
+ size_t signature_size; // The size of the signature, in bytes.
+ // An ASN.1-encoded PublicKeyInfo structure follows.
+ // The signature follows.
+ };
+
ExtensionCreator() {}
bool Run(const FilePath& extension_dir,
@@ -28,14 +50,14 @@ class ExtensionCreator {
std::string error_message() { return error_message_; }
private:
- // Verifies input directory's existance, and reads manifest. |extension_dir|
- // Is the source directory that should contain all the extension resources.
+ // Verifies input directory's existance. |extension_dir| is the source
+ // directory that should contain all the extension resources.
// |private_key_path| is the optional path to an existing private key to sign
// the extension. If not provided, a random key will be created (in which case
// it is written to |private_key_output_path| -- if provided).
- DictionaryValue* InitializeInput(const FilePath& extension_dir,
- const FilePath& private_key_path,
- const FilePath& private_key_output_path);
+ bool InitializeInput(const FilePath& extension_dir,
+ const FilePath& private_key_path,
+ const FilePath& private_key_output_path);
// Reads private key from |private_key_path|.
base::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path);
@@ -44,21 +66,19 @@ class ExtensionCreator {
// if provided.
base::RSAPrivateKey* GenerateKey(const FilePath& private_key_path);
- // Creates temporary zip file and generates a signature for it.
- bool CreateAndSignZip(const FilePath& extension_dir,
- base::RSAPrivateKey* key_pair,
- FilePath* zip_path,
- std::string* signature);
+ // Creates temporary zip file for the extension.
+ bool CreateZip(const FilePath& extension_dir, FilePath* zip_path);
- // Inserts generated keys (signature, public_key) into manifest.
- bool PrepareManifestForExport(base::RSAPrivateKey* key_pair,
- const std::string& signature,
- DictionaryValue* manifest);
+ // Signs the temporary zip and returns the signature.
+ bool SignZip(const FilePath& zip_path,
+ base::RSAPrivateKey* private_key,
+ std::vector<uint8>* signature);
// Export installable .crx to |crx_path|.
- bool WriteCRX(const FilePath& crx_path,
- DictionaryValue *manifest,
- const FilePath& zip_path);
+ bool WriteCRX(const FilePath& zip_path,
+ base::RSAPrivateKey* private_key,
+ const std::vector<uint8>& signature,
+ const FilePath& crx_path);
// Holds a message for any error that is raised during Run(...).
std::string error_message_;