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

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

Issue 553023: RSA signature verification and SHA-1/256/512 reference implementation for verified boot. (Closed)
Patch Set: Fixes. Created 10 years, 11 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
(Empty)
1 #!/bin/bash
2
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
5 # found in the LICENSE file.
6
7 # Run tests for cryptographic routine implementations - Message digests
8 # and RSA Signature verification.
9
10 hash_algos=( sha1 sha256 sha512 )
11 key_lengths=( 1024 2048 4096 8192 )
12 TEST_FILE=test_file
13 TEST_FILE_SIZE=1000000
14 UTILDIR=../utils/
15
16 # Generate RSA test keys of various lengths.
17 function generate_keys {
18 for i in ${key_lengths[@]}
19 do
20 openssl genrsa -F4 -out key_rsa$i.pem $i
21 # Generate self-signed certificate from key.
22 openssl req -batch -new -x509 -key key_rsa$i.pem -out key_rsa$i.crt
23 # Generate pre-processed key for use by RSA signature verification code.
24 ${UTILDIR}/dumpRSAPublicKey key_rsa$i.crt > key_rsa$i.keyb
25 done
26 }
27
28 # Generate public key signatures on an input file for various combinations
29 # of message digest algorithms and RSA key sizes.
30 function generate_signatures {
31 for i in ${hash_algos[@]}
32 do
33 for j in ${key_lengths[@]}
34 do
35 openssl dgst -binary -$i $1 >$1.digest.$i
36 openssl pkeyutl -in $1.digest.$i -inkey key_rsa$j.pem \
37 -pkeyopt digest:$i > $1.rsa$j\_$i.sig
38 done
39 done
40 }
41
42 function test_signatures {
43 algorithmcounter=0
44 for rsaalgo in ${key_lengths[@]}
45 do
46 for hashalgo in ${hash_algos[@]}
47 do
48 echo "For RSA-$rsaalgo and $hashalgo:"
49 ./verify_data $algorithmcounter key_rsa${rsaalgo}.keyb \
50 ${TEST_FILE}.rsa${rsaalgo}_${hashalgo}.sig ${TEST_FILE}
51 let algorithmcounter=algorithmcounter+1
52 done
53 done
54 }
55
56
57 function pre_work {
58 # Generate a file with random bytes for signature tests.
59 echo "Generating test file..."
60 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
61 echo "Generating test keys..."
62 generate_keys
63 echo "Generating signatures..."
64 generate_signatures $TEST_FILE
65 }
66
67 function cleanup {
68 rm ${TEST_FILE} ${TEST_FILE}.digest.* ${TEST_FILE}.*.sig key_rsa*.*
69 }
70
71 echo "Testing message digests..."
72 ./sha_tests
73
74 echo
75 echo "Testing signature verification..."
76 pre_work
77 test_signatures
78
79 echo
80 echo "Cleaning up..."
81 cleanup
82
83
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698