aboutsummaryrefslogtreecommitdiffstats
path: root/fastboot/genkey.sh
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53 (patch)
tree54fd1b2695a591d2306d41264df67c53077b752c /fastboot/genkey.sh
downloadsystem_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.tar.gz
system_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.tar.bz2
system_core-4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53.zip
Initial Contribution
Diffstat (limited to 'fastboot/genkey.sh')
-rwxr-xr-xfastboot/genkey.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/fastboot/genkey.sh b/fastboot/genkey.sh
new file mode 100755
index 00000000..011e902e
--- /dev/null
+++ b/fastboot/genkey.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]
+then
+ echo "Usage: $0 alias \"pass phrase\""
+ exit -1
+fi
+
+# Generate a 2048 bit RSA key with public exponent 3.
+# Encrypt private key with provided password.
+openssl genrsa -3 -out $1.pem -passout pass:"$2" 2048
+
+# Create a self-signed cert for this key.
+openssl req -new -x509 -key $1.pem -passin pass:"$2" \
+ -out $1-cert.pem \
+ -batch -days 10000
+
+# Create a PKCS12 store containing the generated private key.
+# Protect the keystore and the private key with the provided password.
+openssl pkcs12 -export -in $1-cert.pem -inkey $1.pem -passin pass:"$2" \
+ -out $1.p12 -name $1 -passout pass:"$2"
+
+rm $1.pem
+rm $1-cert.pem
+