diff options
author | vbendeb <vbendeb@chromium.org> | 2010-09-29 20:25:29 -0700 |
---|---|---|
committer | vbendeb <vbendeb@chromium.org> | 2010-09-29 20:25:29 -0700 |
commit | a222fbc00eb470c104602be262b97c9c8c7be7a2 (patch) | |
tree | f0ce6194e47401998a6ac1d3f748385f6326c2c3 /tests/gen_test_keys.sh | |
parent | 395d9c6e41809e40af18de4f1fc5462dac21d700 (diff) | |
download | vboot-a222fbc00eb470c104602be262b97c9c8c7be7a2.tar.gz |
Fix test suite deficiencies.
While trying to debug/test some vbutil_kernel changes
(coming in a different CL) it was noticed that this utility
is not covered by tests, and the script which runs it to set
up further testing (tests/gen_fuzz_test_cases.sh) fails
because of the key format mismatch.
Some investigation has shown that this was left behind when
vboot_reference key storage format was changed.
To make gen_fuzz_test_cases.sh work again a new set of test
keys is required, the keys are generated by
tests/gen_test_keys.sh. This utility had to be changed to
generate the proper set of wrapped public and private keys.
Actually code in tests/gen_test_keys.shgenerate_keys() is
copied in pasted in many scripts in this tree, this has to
be refactored, but under a different CL.
Once the changes were made, two scripts were run:
./tests/gen_test_keys.sh
./gen_test_cases.sh
resulting in the new and updated keys generated.
firmware/stub/tpm_lite_stub.c was edited to fix compilation
warning issued when compiling with debugging enabled.
Change-Id: I26a45cbad00d21a29195f2a89b4df7d3559133fe
BUG=chromium-os:7178
TEST=described below
The following commands succeed:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
make
make runtests
./tests/gen_fuzz_test_cases.sh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note that ./tests/gen_fuzz_test_cases.sh was failing
before this change.
The upcoming CL modifying vbutil_kernel will make sure
gen_fuzz_test_cases.sh is executed when tests are run and
will enhance it to cover vbutil_kernel testing.
Review URL: http://codereview.chromium.org/3423022
Diffstat (limited to 'tests/gen_test_keys.sh')
-rwxr-xr-x | tests/gen_test_keys.sh | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/tests/gen_test_keys.sh b/tests/gen_test_keys.sh index edc3d204..1bf995b2 100755 --- a/tests/gen_test_keys.sh +++ b/tests/gen_test_keys.sh @@ -9,20 +9,51 @@ # Load common constants and variables. . "$(dirname "$0")/common.sh" -# Generate RSA test keys of various lengths. +set -e + +PATH="$(dirname "$0")/../build/utility:${PATH}" + +sha_types=( 1 256 512 ) + +# Generate RSA test keys of various lengths. function generate_keys { + key_index=0 + key_name_base="${TESTKEY_DIR}/key_rsa" for i in ${key_lengths[@]} do - if [ -f ${TESTKEY_DIR}/key_rsa$i.keyb ]; then + key_base="${key_name_base}${i}" + if [ -f "${key_base}.keyb" ]; then continue fi - openssl genrsa -F4 -out ${TESTKEY_DIR}/key_rsa$i.pem $i + + openssl genrsa -F4 -out ${key_base}.pem $i # Generate self-signed certificate from key. - openssl req -batch -new -x509 -key ${TESTKEY_DIR}/key_rsa$i.pem \ - -out ${TESTKEY_DIR}/key_rsa$i.crt + openssl req -batch -new -x509 -key ${key_base}.pem \ + -out ${key_base}.crt + # Generate pre-processed key for use by RSA signature verification code. - ${UTIL_DIR}/dumpRSAPublicKey ${TESTKEY_DIR}/key_rsa$i.crt \ - > ${TESTKEY_DIR}/key_rsa$i.keyb + ${UTIL_DIR}/dumpRSAPublicKey ${key_base}.crt \ + > ${key_base}.keyb + + alg_index=0 + for sha_type in ${sha_types[@]} + do + alg=$((${key_index} * 3 + ${alg_index})) + # wrap the public key + vbutil_key \ + --pack "${key_base}.sha${sha_type}.vbpubk" \ + --key "${key_base}.keyb" \ + --version 1 \ + --algorithm ${alg} + + # wrap the private key + vbutil_key \ + --pack "${key_base}.sha${sha_type}.vbprivk" \ + --key "${key_base}.pem" \ + --algorithm ${alg} + alg_index=$((${alg_index} + 1)) + done + key_index=$((${key_index} + 1)) done } |