OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # Generate test keys for use by the tests. | 7 # Generate test keys for use by the tests. |
8 | 8 |
9 # Load common constants and variables. | 9 # Load common constants and variables. |
10 . "$(dirname "$0")/common.sh" | 10 . "$(dirname "$0")/common.sh" |
11 | 11 |
12 # Generate RSA test keys of various lengths. | 12 # Generate RSA test keys of various lengths. |
13 function generate_keys { | 13 function generate_keys { |
14 for i in ${key_lengths[@]} | 14 for i in ${key_lengths[@]} |
15 do | 15 do |
| 16 if [ -f ${TESTKEY_DIR}/key_rsa$i.keyb ]; then |
| 17 continue |
| 18 fi |
16 openssl genrsa -F4 -out ${TESTKEY_DIR}/key_rsa$i.pem $i | 19 openssl genrsa -F4 -out ${TESTKEY_DIR}/key_rsa$i.pem $i |
17 # Generate self-signed certificate from key. | 20 # Generate self-signed certificate from key. |
18 openssl req -batch -new -x509 -key ${TESTKEY_DIR}/key_rsa$i.pem \ | 21 openssl req -batch -new -x509 -key ${TESTKEY_DIR}/key_rsa$i.pem \ |
19 -out ${TESTKEY_DIR}/key_rsa$i.crt | 22 -out ${TESTKEY_DIR}/key_rsa$i.crt |
20 # Generate pre-processed key for use by RSA signature verification code. | 23 # Generate pre-processed key for use by RSA signature verification code. |
21 ${UTIL_DIR}/dumpRSAPublicKey ${TESTKEY_DIR}/key_rsa$i.crt \ | 24 ${UTIL_DIR}/dumpRSAPublicKey ${TESTKEY_DIR}/key_rsa$i.crt \ |
22 > ${TESTKEY_DIR}/key_rsa$i.keyb | 25 > ${TESTKEY_DIR}/key_rsa$i.keyb |
23 done | 26 done |
24 } | 27 } |
25 | 28 |
26 mkdir -p ${TESTKEY_DIR} | 29 mkdir -p ${TESTKEY_DIR} |
27 generate_keys | 30 generate_keys |
OLD | NEW |