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 RSA Signature verification.
8
9# Load common constants and variables.
10. "$(dirname "$0")/common.sh"
11
12set -e
13
14return_code=0
15TEST_FILE=${TESTCASE_DIR}/test_file
16
17function test_signatures {
18  algorithmcounter=0
19  for keylen in ${key_lengths[@]}
20  do
21    for hashalgo in ${hash_algos[@]}
22    do
23      echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:"
24      ${BIN_DIR}/verify_data $algorithmcounter \
25        ${TESTKEY_DIR}/key_rsa${keylen}.keyb \
26        ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig \
27        ${TEST_FILE}
28      if [ $? -ne 0 ]
29      then
30        return_code=255
31      fi
32      let algorithmcounter=algorithmcounter+1
33    done
34  done
35  echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..."
36  ${TEST_DIR}/rsa_padding_test ${TESTKEY_DIR}/rsa_padding_test_pubkey.keyb
37}
38
39check_test_keys
40echo "Testing signature verification..."
41test_signatures
42
43exit $return_code
44
45