OLD | NEW |
(Empty) | |
| 1 #!/bin/sh |
| 2 |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # This script is used to generate the test keys for the unit test in |
| 8 # android/keystore_unittest.c. |
| 9 # |
| 10 # These are test RSA / DSA / ECDSA private keys in PKCS#8 format, as well |
| 11 # as the corresponding DSA / ECDSA public keys. |
| 12 # |
| 13 |
| 14 # Exit script as soon a something fails. |
| 15 set -e |
| 16 |
| 17 mkdir -p out |
| 18 rm -rf out/* |
| 19 |
| 20 # Generate a single 2048-bits RSA private key in PKCS#8 format. |
| 21 KEY=android-test-key-rsa |
| 22 openssl genrsa \ |
| 23 -out out/$KEY.pem \ |
| 24 2048 |
| 25 |
| 26 openssl pkcs8 \ |
| 27 -topk8 \ |
| 28 -nocrypt \ |
| 29 -inform PEM \ |
| 30 -outform DER \ |
| 31 -in out/$KEY.pem \ |
| 32 -out out/$KEY.pkcs8 |
| 33 |
| 34 rm out/$KEY.pem |
| 35 |
| 36 # Generate a 2048-bits DSA private key in PKCS#8 format, |
| 37 # as well as its public key in X.509 DER format. |
| 38 KEY=android-test-key-dsa |
| 39 openssl dsaparam \ |
| 40 -out out/$KEY.param.pem \ |
| 41 2048 |
| 42 |
| 43 openssl gendsa \ |
| 44 -out out/$KEY.pem \ |
| 45 out/$KEY.param.pem |
| 46 |
| 47 openssl pkcs8 \ |
| 48 -topk8 \ |
| 49 -nocrypt \ |
| 50 -inform PEM \ |
| 51 -outform DER \ |
| 52 -in out/$KEY.pem \ |
| 53 -out out/$KEY.pkcs8 |
| 54 |
| 55 openssl dsa \ |
| 56 -in out/$KEY.pem \ |
| 57 -outform DER \ |
| 58 -out out/$KEY-public.der \ |
| 59 -pubout |
| 60 |
| 61 rm out/$KEY.param.pem |
| 62 rm out/$KEY.pem |
| 63 |
| 64 # Generate an ECDSA private key, in PKCS#8 format, |
| 65 # as well as its public key in X.509 DER format. |
| 66 KEY=android-test-key-ecdsa |
| 67 openssl ecparam -genkey -name prime256v1 -out out/$KEY.pem |
| 68 openssl pkcs8 \ |
| 69 -topk8 \ |
| 70 -nocrypt \ |
| 71 -inform PEM \ |
| 72 -outform DER \ |
| 73 -in out/$KEY.pem \ |
| 74 -out out/$KEY.pkcs8 |
| 75 |
| 76 openssl ec \ |
| 77 -in out/$KEY.pem \ |
| 78 -outform DER \ |
| 79 -out out/$KEY-public.der \ |
| 80 -pubout |
| 81 |
| 82 rm out/$KEY.pem |
| 83 |
| 84 # We're done here. |
OLD | NEW |