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 KEY_DIR=testkeys | 9 # Load common constants and variables. |
10 key_lengths=( 1024 2048 4096 8192 ) | 10 . "$(dirname "$0")/common.sh" |
11 UTIL_DIR=../utils/ | |
12 | 11 |
13 # Generate RSA test keys of various lengths. | 12 # Generate RSA test keys of various lengths. |
14 function generate_keys { | 13 function generate_keys { |
15 for i in ${key_lengths[@]} | 14 for i in ${key_lengths[@]} |
16 do | 15 do |
17 openssl genrsa -F4 -out ${KEY_DIR}/key_rsa$i.pem $i | 16 openssl genrsa -F4 -out ${TESTKEY_DIR}/key_rsa$i.pem $i |
18 # Generate self-signed certificate from key. | 17 # Generate self-signed certificate from key. |
19 openssl req -batch -new -x509 -key ${KEY_DIR}/key_rsa$i.pem \ | 18 openssl req -batch -new -x509 -key ${TESTKEY_DIR}/key_rsa$i.pem \ |
20 -out ${KEY_DIR}/key_rsa$i.crt | 19 -out ${TESTKEY_DIR}/key_rsa$i.crt |
21 # Generate pre-processed key for use by RSA signature verification code. | 20 # Generate pre-processed key for use by RSA signature verification code. |
22 ${UTIL_DIR}/dumpRSAPublicKey ${KEY_DIR}/key_rsa$i.crt \ | 21 ${UTIL_DIR}/dumpRSAPublicKey ${TESTKEY_DIR}/key_rsa$i.crt \ |
23 > ${KEY_DIR}/key_rsa$i.keyb | 22 > ${TESTKEY_DIR}/key_rsa$i.keyb |
24 done | 23 done |
25 } | 24 } |
26 | 25 |
27 if [ ! -d "$KEY_DIR" ] | 26 mkdir -p ${TESTKEY_DIR} |
28 then | |
29 mkdir "$KEY_DIR" | |
30 fi | |
31 | |
32 generate_keys | 27 generate_keys |
OLD | NEW |