diff options
author | Gaurav Shah <gauravsh@google.com> | 2010-02-17 16:37:33 -0800 |
---|---|---|
committer | Gaurav Shah <gauravsh@google.com> | 2010-02-17 16:37:33 -0800 |
commit | 52898d3c268e1cdb695b1c9a25fb4190d84a24f8 (patch) | |
tree | 466246ec78ca4493292d3776bc6e04abc0d42fa6 /tests/gen_test_cases.sh | |
parent | 27bfc8be07935ccb0dab251c5d084c64830163c2 (diff) | |
download | vboot-52898d3c268e1cdb695b1c9a25fb4190d84a24f8.tar.gz |
Vboot Reference: Add a RSA verify benchmark.
In addtion, add test cases and a script to generate them for benchmarking. Also fixes a path problem with the run_rsa_tests.sh script.
Review URL: http://codereview.chromium.org/626011
Diffstat (limited to 'tests/gen_test_cases.sh')
-rwxr-xr-x | tests/gen_test_cases.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/gen_test_cases.sh b/tests/gen_test_cases.sh new file mode 100755 index 00000000..b15921d6 --- /dev/null +++ b/tests/gen_test_cases.sh @@ -0,0 +1,54 @@ +#!/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 cases for use for the RSA verify benchmark. + +KEY_DIR=testkeys +TESTCASE_DIR=testcases +UTIL_DIR=../utils/ +TEST_FILE=test_file +TEST_FILE_SIZE=1000000 + +hash_algos=( sha1 sha256 sha512 ) +key_lengths=( 1024 2048 4096 8192 ) + +# Generate public key signatures and digest on an input file for +# various combinations of message digest algorithms and RSA key sizes. +function generate_test_signatures { + algorithmcounter=0 + for keylen in ${key_lengths[@]} + do + for hashalgo in ${hash_algos[@]} + do + openssl dgst -${hashalgo} -binary -out $1.${hashalgo}.digest $1 + ${UTIL_DIR}/signature_digest $algorithmcounter $1 | openssl rsautl -sign \ + -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \ + > $1.rsa${keylen}_${hashalgo}.sig + let algorithmcounter=algorithmcounter+1 + done + done +} + +function pre_work { + # Generate a file with random bytes for signature tests. + echo "Generating test file..." + dd if=/dev/urandom of=${TESTCASE_DIR}/${TEST_FILE} bs=${TEST_FILE_SIZE} count=1 +} + +if [ ! -d "$KEY_DIR" ] +then + echo "You must run gen_test_cases.sh to generate test keys first." + exit 1 +fi + +if [ ! -d "$TESTCASE_DIR" ] +then + mkdir "$TESTCASE_DIR" +fi + +pre_work +echo "Generating test signatures..." +generate_test_signatures ${TESTCASE_DIR}/$TEST_FILE |