1e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler#!/bin/bash
2e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
3e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler# Use of this source code is governed by a BSD-style license that can be
5e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler# found in the LICENSE file.
6e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler#
7e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler# Run tests for RSA Signature verification.
8e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
9e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler# Load common constants and variables.
10e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler. "$(dirname "$0")/common.sh"
11e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
12e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerset -e
13e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
14e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerreturn_code=0
15e166d04e797b605dd2f6784bc863a262c418c0c4Randall SpanglerTEST_FILE=${TESTCASE_DIR}/test_file
16e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
17e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerfunction test_signatures {
18e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler  algorithmcounter=0
19e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler  for keylen in ${key_lengths[@]}
20e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler  do
21e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler    for hashalgo in ${hash_algos[@]}
22e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler    do
23e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler      echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:"
243e3790d00827e75d39b77a14bca2756a14a51b3cBill Richardson      ${BIN_DIR}/verify_data $algorithmcounter \
25e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler        ${TESTKEY_DIR}/key_rsa${keylen}.keyb \
26e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler        ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig \
27e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler        ${TEST_FILE}
28e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler      if [ $? -ne 0 ]
29e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler      then
30e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler        return_code=255
31e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler      fi
32e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler      let algorithmcounter=algorithmcounter+1
33e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler    done
34e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler  done
35e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler  echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..."
366f1b82ac14f341d9733d6e95d518b3ee352002efRandall Spangler  ${TEST_DIR}/vb20_rsa_padding_tests ${TESTKEY_DIR}/rsa_padding_test_pubkey.keyb
37e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler}
38e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
39e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglercheck_test_keys
40e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerecho "Testing signature verification..."
41e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglertest_signatures
42e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
43e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spanglerexit $return_code
44e166d04e797b605dd2f6784bc863a262c418c0c4Randall Spangler
45