Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 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 | # Generate test cases for use for the RSA verify benchmark. |
| 8 | |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 9 | # Load common constants and variables. |
| 10 | . "$(dirname "$0")/common.sh" |
| 11 | |
| 12 | TEST_FILE=${TESTCASE_DIR}/test_file |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 13 | TEST_FILE_SIZE=1000000 |
| 14 | |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 15 | # Generate public key signatures on an input file for various combinations |
| 16 | # of message digest algorithms and RSA key sizes. |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 17 | function generate_test_signatures { |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 18 | echo "Generating test signatures..." |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 19 | algorithmcounter=0 |
| 20 | for keylen in ${key_lengths[@]} |
| 21 | do |
| 22 | for hashalgo in ${hash_algos[@]} |
| 23 | do |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 24 | openssl dgst -${hashalgo} -binary ${TEST_FILE} > \ |
| 25 | ${TEST_FILE}.${hashalgo}.digest |
Bill Richardson | 3e3790d | 2014-07-14 15:05:54 -0700 | [diff] [blame] | 26 | ${BIN_DIR}/signature_digest_utility $algorithmcounter \ |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 27 | ${TEST_FILE} | openssl rsautl \ |
| 28 | -sign -pkcs -inkey ${TESTKEY_DIR}/key_rsa${keylen}.pem \ |
| 29 | > ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 30 | let algorithmcounter=algorithmcounter+1 |
| 31 | done |
| 32 | done |
| 33 | } |
| 34 | |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 35 | # Generate a file with random bytes for signature tests. |
| 36 | function generate_test_file { |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 37 | echo "Generating test file..." |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 38 | dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1 |
Gaurav Shah | 52898d3 | 2010-02-17 16:37:33 -0800 | [diff] [blame] | 39 | } |
| 40 | |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 41 | mkdir -p ${TESTCASE_DIR} |
| 42 | check_test_keys |
| 43 | generate_test_file |
| 44 | generate_test_signatures |