blob: d73f7374d0bc3af61240693b954c2d2628bb861a [file] [log] [blame]
Gaurav Shah322536d2010-01-28 15:01:23 -08001#!/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 Shah445925f2010-03-19 16:19:09 -07006#
Gaurav Shahf67bcaa2010-02-28 19:18:24 -08007# Run tests for RSA Signature verification.
Gaurav Shah322536d2010-01-28 15:01:23 -08008
Gaurav Shah445925f2010-03-19 16:19:09 -07009# Load common constants and variables.
10. "$(dirname "$0")/common.sh"
11
vbendeba222fbc2010-09-29 20:25:29 -070012set -e
13
Gaurav Shah1a055ad2010-02-12 13:05:03 -080014return_code=0
Gaurav Shah445925f2010-03-19 16:19:09 -070015TEST_FILE=${TESTCASE_DIR}/test_file
Gaurav Shah322536d2010-01-28 15:01:23 -080016
17function test_signatures {
18 algorithmcounter=0
Gaurav Shah8bf29d82010-01-28 19:43:24 -080019 for keylen in ${key_lengths[@]}
Gaurav Shah322536d2010-01-28 15:01:23 -080020 do
21 for hashalgo in ${hash_algos[@]}
22 do
Gaurav Shah08df9b82010-02-23 16:16:23 -080023 echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:"
Bill Richardson3e3790d2014-07-14 15:05:54 -070024 ${BIN_DIR}/verify_data $algorithmcounter \
Gaurav Shah445925f2010-03-19 16:19:09 -070025 ${TESTKEY_DIR}/key_rsa${keylen}.keyb \
26 ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig \
27 ${TEST_FILE}
Gaurav Shah1a055ad2010-02-12 13:05:03 -080028 if [ $? -ne 0 ]
vbendeba222fbc2010-09-29 20:25:29 -070029 then
Gaurav Shah1a055ad2010-02-12 13:05:03 -080030 return_code=255
31 fi
Gaurav Shah322536d2010-01-28 15:01:23 -080032 let algorithmcounter=algorithmcounter+1
33 done
34 done
Gaurav Shah7d122e22010-02-24 16:41:32 -080035 echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..."
Gaurav Shah445925f2010-03-19 16:19:09 -070036 ${TEST_DIR}/rsa_padding_test ${TESTKEY_DIR}/rsa_padding_test_pubkey.keyb
Gaurav Shah431b9882010-02-12 15:54:37 -080037}
38
Gaurav Shah445925f2010-03-19 16:19:09 -070039check_test_keys
Gaurav Shah322536d2010-01-28 15:01:23 -080040echo "Testing signature verification..."
Gaurav Shah322536d2010-01-28 15:01:23 -080041test_signatures
42
Gaurav Shah1a055ad2010-02-12 13:05:03 -080043exit $return_code
Gaurav Shah322536d2010-01-28 15:01:23 -080044