Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: src/platform/vboot_reference/tests/gen_test_cases.sh

Issue 1101004: Vboot Reference: Spring cleaning of test scripts. (Closed)
Patch Set: review fixes. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cases for use for the RSA verify benchmark. 7 # Generate test cases for use for the RSA verify benchmark.
8 8
9 KEY_DIR=testkeys 9 # Load common constants and variables.
10 TESTCASE_DIR=testcases 10 . "$(dirname "$0")/common.sh"
11 UTIL_DIR=../utils/ 11
12 TEST_FILE=test_file 12 TEST_FILE=${TESTCASE_DIR}/test_file
13 TEST_FILE_SIZE=1000000 13 TEST_FILE_SIZE=1000000
14 14
15 hash_algos=( sha1 sha256 sha512 ) 15 # Generate public key signatures on an input file for various combinations
16 key_lengths=( 1024 2048 4096 8192 ) 16 # of message digest algorithms and RSA key sizes.
17
18 # Generate public key signatures and digest on an input file for
19 # various combinations of message digest algorithms and RSA key sizes.
20 function generate_test_signatures { 17 function generate_test_signatures {
18 echo "Generating test signatures..."
21 algorithmcounter=0 19 algorithmcounter=0
22 for keylen in ${key_lengths[@]} 20 for keylen in ${key_lengths[@]}
23 do 21 do
24 for hashalgo in ${hash_algos[@]} 22 for hashalgo in ${hash_algos[@]}
25 do 23 do
26 openssl dgst -${hashalgo} -binary -out $1.${hashalgo}.digest $1 24 openssl dgst -${hashalgo} -binary ${TEST_FILE} > \
27 ${UTIL_DIR}/signature_digest $algorithmcounter $1 | openssl rsautl -sign \ 25 ${TEST_FILE}.${hashalgo}.digest
28 -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \ 26 ${UTIL_DIR}/signature_digest_utility $algorithmcounter \
29 > $1.rsa${keylen}_${hashalgo}.sig 27 ${TEST_FILE} | openssl rsautl \
28 -sign -pkcs -inkey ${TESTKEY_DIR}/key_rsa${keylen}.pem \
29 > ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig
30 let algorithmcounter=algorithmcounter+1 30 let algorithmcounter=algorithmcounter+1
31 done 31 done
32 done 32 done
33 } 33 }
34 34
35 function pre_work { 35 # Generate a file with random bytes for signature tests.
36 # Generate a file with random bytes for signature tests. 36 function generate_test_file {
37 echo "Generating test file..." 37 echo "Generating test file..."
38 dd if=/dev/urandom of=${TESTCASE_DIR}/${TEST_FILE} bs=${TEST_FILE_SIZE} count= 1 38 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
39 } 39 }
40 40
41 if [ ! -d "$KEY_DIR" ] 41 mkdir -p ${TESTCASE_DIR}
42 then 42 check_test_keys
43 echo "You must run gen_test_cases.sh to generate test keys first." 43 generate_test_file
44 exit 1 44 generate_test_signatures
45 fi
46
47 if [ ! -d "$TESTCASE_DIR" ]
48 then
49 mkdir "$TESTCASE_DIR"
50 fi
51
52 pre_work
53 echo "Generating test signatures..."
54 generate_test_signatures ${TESTCASE_DIR}/$TEST_FILE
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/gen_fuzz_test_cases.sh ('k') | src/platform/vboot_reference/tests/gen_test_keys.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698