summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-01-03 15:07:54 +0100
committertv <tv@krebsco.de>2021-01-03 15:49:25 +0100
commitd3ed6d81900766ec53547623ac3e59a537fa2179 (patch)
treede6b3c3118a3b12fd40c72508644baaaec2fc3c8
parente38bde2eeb31b86746cd2b243f94622ddbd8cd2d (diff)
crxmake: support 1024 and 4096 bit RSA keys
From: https://stackoverflow.com/questions/18693962/pack-chrome-extension-on-server-with-only-command-line-interface/18709204#comment100718141_18709204
-rwxr-xr-xcrxmake28
1 files changed, 25 insertions, 3 deletions
diff --git a/crxmake b/crxmake
index 9418f83..066ef60 100755
--- a/crxmake
+++ b/crxmake
@@ -16,6 +16,11 @@ zip="$name.zip"
tosign="$name.presig"
binary_crx_id="$name.crxid"
+key_size=$(
+ openssl rsa -text -noout -in "$key" |
+ sed -n 's/^.*Private-Key:.*\<\([0-9]\+\)\>\s*bit.*$/\1/p'
+)
+
workdir=$(mktemp -d -t crxmake.XXXXXXXX)
oldworkdir=$PWD
cd "$workdir"
@@ -47,9 +52,26 @@ openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
crmagic_hex="43 72 32 34" # Cr24
version_hex="03 00 00 00" # 3
-header_length="45 02 00 00"
-header_chunk_1="12 AC 04 0A A6 02"
-header_chunk_2="12 80 02"
+case $key_size in
+ 1024)
+ header_length="41 01 00 00"
+ header_chunk_1="12 A8 02 0A A2 01"
+ header_chunk_2="12 80 01"
+ ;;
+ 2048)
+ header_length="45 02 00 00"
+ header_chunk_1="12 AC 04 0A A6 02"
+ header_chunk_2="12 80 02"
+ ;;
+ 4096)
+ header_length="45 04 00 00"
+ header_chunk_1="12 AC 08 0A A6 04"
+ header_chunk_2="12 80 04"
+ ;;
+ *)
+ echo "Error: $key has unsupported key size: $key_size" >&2
+ exit 2
+esac
header_chunk_3="82 F1 04 12 0A 10"
(
echo "$crmagic_hex $version_hex $header_length $header_chunk_1" | xxd -r -p