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

Side by Side Diff: src/platform/vboot_reference/tests/run_rsa_tests.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
« no previous file with comments | « src/platform/vboot_reference/tests/run_image_verification_tests.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # Run tests for RSA Signature verification. 7 # Run tests for RSA Signature verification.
8 8
9 # Load common constants and variables.
10 . "$(dirname "$0")/common.sh"
11
9 return_code=0 12 return_code=0
10 hash_algos=( sha1 sha256 sha512 ) 13 TEST_FILE=${TESTCASE_DIR}/test_file
11 key_lengths=( 1024 2048 4096 8192 )
12 TEST_FILE=test_file
13 TEST_FILE_SIZE=1000000
14
15 COL_RED='\E[31;1m'
16 COL_GREEN='\E[32;1m'
17 COL_YELLOW='\E[33;1m'
18 COL_BLUE='\E[34;1m'
19 COL_STOP='\E[0;m'
20
21 # Generate public key signatures on an input file for various combinations
22 # of message digest algorithms and RSA key sizes.
23 function generate_signatures {
24 algorithmcounter=0
25 for keylen in ${key_lengths[@]}
26 do
27 for hashalgo in ${hash_algos[@]}
28 do
29 ${UTIL_DIR}/signature_digest_utility $algorithmcounter $1 | openssl \
30 rsautl -sign -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \
31 > $1.rsa${keylen}\_${hashalgo}.sig
32 let algorithmcounter=algorithmcounter+1
33 done
34 done
35 }
36 14
37 function test_signatures { 15 function test_signatures {
38 algorithmcounter=0 16 algorithmcounter=0
39 for keylen in ${key_lengths[@]} 17 for keylen in ${key_lengths[@]}
40 do 18 do
41 for hashalgo in ${hash_algos[@]} 19 for hashalgo in ${hash_algos[@]}
42 do 20 do
43 echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:" 21 echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:"
44 ${UTIL_DIR}/verify_data $algorithmcounter \ 22 ${UTIL_DIR}/verify_data $algorithmcounter \
45 ${KEY_DIR}/key_rsa${keylen}.keyb \ 23 ${TESTKEY_DIR}/key_rsa${keylen}.keyb \
46 ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig ${TEST_FILE} 24 ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig \
25 ${TEST_FILE}
47 if [ $? -ne 0 ] 26 if [ $? -ne 0 ]
48 then 27 then
49 return_code=255 28 return_code=255
50 fi 29 fi
51 let algorithmcounter=algorithmcounter+1 30 let algorithmcounter=algorithmcounter+1
52 done 31 done
53 done 32 done
54 echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..." 33 echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..."
55 ${TEST_DIR}/rsa_padding_test ${TEST_DIR}/testkeys/rsa_padding_test_pubkey.keyb 34 ${TEST_DIR}/rsa_padding_test ${TESTKEY_DIR}/rsa_padding_test_pubkey.keyb
56 } 35 }
57 36
58 function pre_work { 37 check_test_keys
59 # Generate a file with random bytes for signature tests.
60 echo "Generating test file..."
61 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
62 echo "Generating signatures..."
63 generate_signatures $TEST_FILE
64 }
65
66 function cleanup {
67 rm ${SCRIPT_DIR}/${TEST_FILE} ${SCRIPT_DIR}/${TEST_FILE}.*.sig
68 }
69
70 # Determine script directory.
71 if [[ $0 == '/'* ]];
72 then
73 SCRIPT_DIR="`dirname $0`"
74 elif [[ $0 == './'* ]];
75 then
76 SCRIPT_DIR="`pwd`"
77 else
78 SCRIPT_DIR="`pwd`"/"`dirname $0`"
79 fi
80 UTIL_DIR=`dirname ${SCRIPT_DIR}`/utils
81 KEY_DIR=${SCRIPT_DIR}/testkeys
82 TEST_DIR=${SCRIPT_DIR}/
83
84 echo "Generating test cases..."
85 pre_work
86
87 echo
88 echo "Testing signature verification..." 38 echo "Testing signature verification..."
89 test_signatures 39 test_signatures
90 40
91 echo
92 echo "Cleaning up..."
93 cleanup
94
95 exit $return_code 41 exit $return_code
96 42
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/run_image_verification_tests.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698