| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Run tests for RSA Signature verification. | 7 # Run tests for RSA Signature verification. |
| 8 | 8 |
| 9 return_code=0 | 9 return_code=0 |
| 10 hash_algos=( sha1 sha256 sha512 ) | 10 hash_algos=( sha1 sha256 sha512 ) |
| 11 key_lengths=( 1024 2048 4096 8192 ) | 11 key_lengths=( 1024 2048 4096 8192 ) |
| 12 TEST_FILE=test_file | 12 TEST_FILE=test_file |
| 13 TEST_FILE_SIZE=1000000 | 13 TEST_FILE_SIZE=1000000 |
| 14 | 14 |
| 15 COL_RED='\E[31;1m' | 15 COL_RED='\E[31;1m' |
| 16 COL_GREEN='\E[32;1m' | 16 COL_GREEN='\E[32;1m' |
| 17 COL_YELLOW='\E[33;1m' | 17 COL_YELLOW='\E[33;1m' |
| 18 COL_BLUE='\E[34;1m' | 18 COL_BLUE='\E[34;1m' |
| 19 COL_STOP='\E[0;m' | 19 COL_STOP='\E[0;m' |
| 20 | 20 |
| 21 # Generate public key signatures on an input file for various combinations | 21 # Generate public key signatures on an input file for various combinations |
| 22 # of message digest algorithms and RSA key sizes. | 22 # of message digest algorithms and RSA key sizes. |
| 23 function generate_signatures { | 23 function generate_signatures { |
| 24 algorithmcounter=0 | 24 algorithmcounter=0 |
| 25 for keylen in ${key_lengths[@]} | 25 for keylen in ${key_lengths[@]} |
| 26 do | 26 do |
| 27 for hashalgo in ${hash_algos[@]} | 27 for hashalgo in ${hash_algos[@]} |
| 28 do | 28 do |
| 29 ${UTIL_DIR}/signature_digest $algorithmcounter $1 | openssl rsautl -sign \ | 29 ${UTIL_DIR}/signature_digest_utility $algorithmcounter $1 | openssl \ |
| 30 -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \ | 30 rsautl -sign -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \ |
| 31 > $1.rsa${keylen}\_${hashalgo}.sig | 31 > $1.rsa${keylen}\_${hashalgo}.sig |
| 32 let algorithmcounter=algorithmcounter+1 | 32 let algorithmcounter=algorithmcounter+1 |
| 33 done | 33 done |
| 34 done | 34 done |
| 35 } | 35 } |
| 36 | 36 |
| 37 function test_signatures { | 37 function test_signatures { |
| 38 algorithmcounter=0 | 38 algorithmcounter=0 |
| 39 for keylen in ${key_lengths[@]} | 39 for keylen in ${key_lengths[@]} |
| 40 do | 40 do |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 echo | 87 echo |
| 88 echo "Testing signature verification..." | 88 echo "Testing signature verification..." |
| 89 test_signatures | 89 test_signatures |
| 90 | 90 |
| 91 echo | 91 echo |
| 92 echo "Cleaning up..." | 92 echo "Cleaning up..." |
| 93 cleanup | 93 cleanup |
| 94 | 94 |
| 95 exit $return_code | 95 exit $return_code |
| 96 | 96 |
| OLD | NEW |