Chrome Extensions | Browsers

Standards Based Development

CRX (.crx) Package Format

CRX files are ZIP files with a special header and the .crx file extension.

Package header

The header contains the author's public key and the extension's signature. The signature is generated from the ZIP file using SHA-1 with the author's private key. The header requires a little-endian byte ordering with 4-byte alignment. The following table describes the fields of the .crx header in order:

.crxHeader Fields in Order
FieldTypeLengthValueDescription
magic numberchar[]32 bitsCr24Chrome requires this constant at the beginning of every .crx package.
versionunsigned int32 bits2The version of the *.crx file format used (currently 2).
public key length unsigned int32 bits pubkey.length The length of the RSA public key in bytes.
signature length unsigned int32 bits sig.length The length of the signature in bytes.
public key byte[] pubkey.length pubkey.contents The contents of the author's RSA public key, formatted as an X509 SubjectPublicKeyInfo block.
signature byte[] sig.length sig.contents The signature of the ZIP content using the author's private key. The signature is created using the RSA algorithm with the SHA-1 hash function.

Extension Contents

The extension's ZIP file is appended to the *.crx package after the header. This should be the same ZIP file that the signature in the header was generated from as shown in the next example. The following is an example hex dump from the beginning of a .crx file:


43 72 32 34   # "Cr24" -- the magic number
02 00 00 00   # 2 -- the crx format version number
A2 00 00 00   # 162 -- length of public key in bytes
80 00 00 00   # 128 -- length of signature in bytes
...........   # the contents of the public key
...........   # the contents of the signature
...........   # the contents of the zip file

Packaging Scripts

Roll your own packaging script(s): there's already a Ruby script (crxmake), and a Bash script available for use in packaging .crx files.

crx Package Format

SOMETHING

Chrome Extensions are small software programs built on html, css, and JavaScript, that have the ability to modify and enhance Chrome's functionality.

Chrome Extensions bundle all of their files into a single file for the user to download and install. The way Chrome Extensions bundle ensures that Chrome Extensions do not need to depend on content from the web, unlike typical web applications.

Chrome Extensions can be distributed using the Chrome Developer Dashboard to publish to the Chrome Web Store.

Getting Started

Check Chrome Extension Boilerplate and Chrome Extension css.

Extenzionizr

Extenzionizr allows you to download a chrome extension boilerplate, with simple configuration of the manifest.json file.

Extenzionizr works like this, on pageload zip.js imports the pre-made zip file. Once the user has selected some options, they are collected and a list of properties is created to add and remove from the zip. The removing is done twice, because some of the properties are manifest entries (omnibox permission), some are plain files (jQuery), and some are both (page action). Once all of the settings get collected, and the user clicks download file, Extenzionizr runs through the properties, and edits the zip file, removing any unnesecary files, while also updating manifest.json. After this is done, it spits the Base64 blob into an a element. Using Chrome's a [download] property, the file then is downloaded to the user's machine.

More documentation on Extenzionizr can be found in this introduction blog post, as well as on GitHub.

Extension Demos

References and Resources