summaryrefslogtreecommitdiff
path: root/tests/gen_test_keys.sh
diff options
context:
space:
mode:
authorGaurav Shah <gauravsh@google.com>2010-02-10 23:07:02 -0800
committerGaurav Shah <gauravsh@google.com>2010-02-10 23:07:02 -0800
commite3ef9c9f40fdb7f377f4d02031ad125b59c0d6c7 (patch)
tree3db89499f97a037920f7bd857100c72e9e31db93 /tests/gen_test_keys.sh
parent1f81a6f936c0200d3d92286f3126ba672dba5781 (diff)
downloadvboot-e3ef9c9f40fdb7f377f4d02031ad125b59c0d6c7.tar.gz
Vboot Reference: Move test key generation to a separate script and add sample test keys.
Key generation takes a long time. This will be useful in driving the cryptosuite through autotest. Review URL: http://codereview.chromium.org/604016
Diffstat (limited to 'tests/gen_test_keys.sh')
-rwxr-xr-xtests/gen_test_keys.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/gen_test_keys.sh b/tests/gen_test_keys.sh
new file mode 100755
index 00000000..2a8fe83e
--- /dev/null
+++ b/tests/gen_test_keys.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Generate test keys for use by the tests.
+
+KEY_DIR=testkeys
+key_lengths=( 1024 2048 4096 8192 )
+UTIL_DIR=../utils/
+
+# Generate RSA test keys of various lengths.
+function generate_keys {
+ for i in ${key_lengths[@]}
+ do
+ openssl genrsa -F4 -out ${KEY_DIR}/key_rsa$i.pem $i
+ # Generate self-signed certificate from key.
+ openssl req -batch -new -x509 -key ${KEY_DIR}/key_rsa$i.pem \
+ -out ${KEY_DIR}/key_rsa$i.crt
+ # Generate pre-processed key for use by RSA signature verification code.
+ ${UTIL_DIR}/dumpRSAPublicKey ${KEY_DIR}/key_rsa$i.crt \
+ > ${KEY_DIR}/key_rsa$i.keyb
+ done
+}
+
+if [ ! -d "$KEY_DIR" ]
+then
+ mkdir "$KEY_DIR"
+fi
+
+generate_keys