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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/articles/crx.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment in converter.py Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <h1 class="page_title">CRX Package Format</h1>
2 <div id="pageData-showTOC" class="pageData">true</div>
3 <p>
4 CRX files are ZIP files with a special header and the <code>.crx</code> file
5 extension.
6 </p>
7 <h2>Package header</h2>
8 <p>
9 The header contains the author's public key and the extension's signature.
10 The signature is generated from the ZIP file using SHA-1 with the
11 author's private key. The header requires a little-endian byte ordering with
12 4-byte alignment. The following table describes the fields of
13 the <code>.crx</code> header in order:
14 </p>
15 <table>
16 <tr>
17 <th>Field</th><th>Type</th><th>Length</th><th>Value</th><th>Description</th>
18 </tr>
19 <tr>
20 <td><em>magic number</em></td><td>char[]</td><td>32 bits</td><td>Cr24</td>
21 <td>
22 Chrome requires this constant at the beginning of every <code>.crx</code>
23 package.
24 </td>
25 </tr>
26 <tr>
27 <td><em>version</em></td><td>unsigned&nbsp;int</td><td>32 bits</td><td>2</td >
28 <td>The version of the <code>*.crx</code> file format used (currently 2).</t d>
29 </tr>
30 <tr>
31 <td><em>public key length</em></td><td>unsigned&nbsp;int</td><td>32 bits</td >
32 <td><i>pubkey.length</i></td>
33 <td>
34 The length of the RSA public key in <em>bytes</em>.
35 </td>
36 </tr>
37 <tr>
38 <td><em>signature length</em></td><td>unsigned&nbsp;int</td><td>32 bits</td>
39 <td><i>sig.length</i></td>
40 <td>
41 The length of the signature in <em>bytes</em>.
42 </td>
43 </tr>
44 <tr>
45 <td><em>public key</em></td><td>byte[]</td><td><i>pubkey.length</i></i></td>
46 <td><i>pubkey.contents</i></td>
47 <td>
48 The contents of the author's RSA public key, formatted as an X509
49 SubjectPublicKeyInfo block.
50 </td>
51 </tr>
52 <tr>
53 <td><em>signature</em></td><td>byte[]</td><td><i>sig.length</i></td>
54 <td><i>sig.contents</i></td>
55 <td>
56 The signature of the ZIP content using the author's private key. The
57 signature is created using the RSA algorithm with the SHA-1 hash function.
58 </td>
59 </tr>
60 </table>
61 <h2>Extension contents</h2>
62 <p>
63 The extension's ZIP file is appended to the <code>*.crx</code> package after the
64 header. This should be the same ZIP file that the signature in the header
65 was generated from.
66 </p>
67 <h2>Example</h2>
68 <p>
69 The following is an example hex dump from the beginning of a <code>.crx</code>
70 file.
71 </p>
72 <pre>
73 43 72 32 34 # "Cr24" -- the magic number
74 02 00 00 00 # 2 -- the crx format version number
75 A2 00 00 00 # 162 -- length of public key in bytes
76 80 00 00 00 # 128 -- length of signature in bytes
77 ........... # the contents of the public key
78 ........... # the contents of the signature
79 ........... # the contents of the zip file
80 </pre>
81 <h2 id="scripts">Packaging scripts</h2>
82 <p>
83 Members of the community have written the following scripts to package
84 <code>.crx</code> files.
85 </p>
86 <h3 id="ruby">Ruby</h3>
87 <blockquote>
88 <a href="http://github.com/Constellation/crxmake">github: crxmake</a>
89 </blockquote>
90 <h3>Bash</h3>
91 <pre>
92 #!/bin/bash -e
93 #
94 # Purpose: Pack a Chromium extension directory into crx format
95 if test $# -ne 2; then
96 echo "Usage: crxmake.sh &lt;extension dir&gt; &lt;pem path&gt;"
97 exit 1
98 fi
99 dir=$1
100 key=$2
101 name=$(basename "$dir")
102 crx="$name.crx"
103 pub="$name.pub"
104 sig="$name.sig"
105 zip="$name.zip"
106 trap 'rm -f "$pub" "$sig" "$zip"' EXIT
107 # zip up the crx dir
108 cwd=$(pwd -P)
109 (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
110 # signature
111 openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
112 # public key
113 openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
114 byte_swap () {
115 # Take "abcdefgh" and return it as "ghefcdab"
116 echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
117 }
118 crmagic_hex="4372 3234" # Cr24
119 version_hex="0200 0000" # 2
120 pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
121 sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
122 (
123 echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
124 cat "$pub" "$sig" "$zip"
125 ) > "$crx"
126 echo "Wrote $crx"
127 </pre>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698