Gaurav Shah | 322536d | 2010-01-28 15:01:23 -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. |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 6 | # |
Gaurav Shah | f67bcaa | 2010-02-28 19:18:24 -0800 | [diff] [blame] | 7 | # Run tests for RSA Signature verification. |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 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 | |
vbendeb | a222fbc | 2010-09-29 20:25:29 -0700 | [diff] [blame] | 12 | set -e |
| 13 | |
Gaurav Shah | 1a055ad | 2010-02-12 13:05:03 -0800 | [diff] [blame] | 14 | return_code=0 |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 15 | TEST_FILE=${TESTCASE_DIR}/test_file |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 16 | |
| 17 | function test_signatures { |
| 18 | algorithmcounter=0 |
Gaurav Shah | 8bf29d8 | 2010-01-28 19:43:24 -0800 | [diff] [blame] | 19 | for keylen in ${key_lengths[@]} |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 20 | do |
| 21 | for hashalgo in ${hash_algos[@]} |
| 22 | do |
Gaurav Shah | 08df9b8 | 2010-02-23 16:16:23 -0800 | [diff] [blame] | 23 | echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:" |
Bill Richardson | 3e3790d | 2014-07-14 15:05:54 -0700 | [diff] [blame] | 24 | ${BIN_DIR}/verify_data $algorithmcounter \ |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 25 | ${TESTKEY_DIR}/key_rsa${keylen}.keyb \ |
| 26 | ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig \ |
| 27 | ${TEST_FILE} |
Gaurav Shah | 1a055ad | 2010-02-12 13:05:03 -0800 | [diff] [blame] | 28 | if [ $? -ne 0 ] |
vbendeb | a222fbc | 2010-09-29 20:25:29 -0700 | [diff] [blame] | 29 | then |
Gaurav Shah | 1a055ad | 2010-02-12 13:05:03 -0800 | [diff] [blame] | 30 | return_code=255 |
| 31 | fi |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 32 | let algorithmcounter=algorithmcounter+1 |
| 33 | done |
| 34 | done |
Gaurav Shah | 7d122e2 | 2010-02-24 16:41:32 -0800 | [diff] [blame] | 35 | echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..." |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 36 | ${TEST_DIR}/rsa_padding_test ${TESTKEY_DIR}/rsa_padding_test_pubkey.keyb |
Gaurav Shah | 431b988 | 2010-02-12 15:54:37 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Gaurav Shah | 445925f | 2010-03-19 16:19:09 -0700 | [diff] [blame] | 39 | check_test_keys |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 40 | echo "Testing signature verification..." |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 41 | test_signatures |
| 42 | |
Gaurav Shah | 1a055ad | 2010-02-12 13:05:03 -0800 | [diff] [blame] | 43 | exit $return_code |
Gaurav Shah | 322536d | 2010-01-28 15:01:23 -0800 | [diff] [blame] | 44 | |