diff options
| author | Kenny Root <kroot@google.com> | 2013-11-22 10:43:34 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-11-22 10:43:34 -0800 |
| commit | a163fa900395cf8ebc1bbd143becc6bf2433781d (patch) | |
| tree | 6287acd1ef4b4748e032b72bef520dc7454c59bd /tools | |
| parent | b40c1571dc9ecf016f6b3bdba26ab54e0941ad43 (diff) | |
| parent | 7e0d5c29b33f3056aedcb44cb8cbae808c11c35d (diff) | |
am 7e0d5c29: am c9421a7a: Merge "make_key: add EC key generation support"
* commit '7e0d5c29b33f3056aedcb44cb8cbae808c11c35d':
make_key: add EC key generation support
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/make_key | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tools/make_key b/tools/make_key index 209d824f6..a1018177a 100755 --- a/tools/make_key +++ b/tools/make_key @@ -17,12 +17,12 @@ # Generates a public/private key pair suitable for use in signing # android .apks and OTA update packages. -if [ "$#" -ne 2 ]; then +if [ "$#" -lt 2 -o "$#" -gt 3 ]; then cat <<EOF -Usage: $0 <name> <subject> +Usage: $0 <name> <subject> [<keytype>] Creates <name>.pk8 key and <name>.x509.pem cert. Cert contains the -given <subject>. +given <subject>. A keytype of "rsa" or "ec" is accepted. EOF exit 2 fi @@ -49,9 +49,18 @@ chmod 0600 ${one} ${two} read -p "Enter password for '$1' (blank for none; password will be visible): " \ password -( openssl genrsa -f4 2048 | tee ${one} > ${two} ) & +if [ "${3}" = "rsa" -o "$#" -eq 2 ]; then + ( openssl genrsa -f4 2048 | tee ${one} > ${two} ) & + hash="-sha1" +elif [ "${3}" = "ec" ]; then + ( openssl ecparam -name prime256v1 -genkey -noout | tee ${one} > ${two} ) & + hash="-sha256" +else + echo "Only accepts RSA or EC keytypes." + exit 1 +fi -openssl req -new -x509 -sha1 -key ${two} -out $1.x509.pem \ +openssl req -new -x509 ${hash} -key ${two} -out $1.x509.pem \ -days 10000 -subj "$2" & if [ "${password}" == "" ]; then |
