| 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 cryptographic routine implementations - Message digests | 7 # Run tests for RSA Signature verification. |
| 8 # and RSA Signature verification. | |
| 9 | 8 |
| 10 return_code=0 | 9 return_code=0 |
| 11 hash_algos=( sha1 sha256 sha512 ) | 10 hash_algos=( sha1 sha256 sha512 ) |
| 12 key_lengths=( 1024 2048 4096 8192 ) | 11 key_lengths=( 1024 2048 4096 8192 ) |
| 13 TEST_FILE=test_file | 12 TEST_FILE=test_file |
| 14 TEST_FILE_SIZE=1000000 | 13 TEST_FILE_SIZE=1000000 |
| 15 | 14 |
| 16 COL_RED='\E[31;1m' | 15 COL_RED='\E[31;1m' |
| 17 COL_GREEN='\E[32;1m' | 16 COL_GREEN='\E[32;1m' |
| 18 COL_YELLOW='\E[33;1m' | 17 COL_YELLOW='\E[33;1m' |
| (...skipping 26 matching lines...) Expand all Loading... |
| 45 ${UTIL_DIR}/verify_data $algorithmcounter \ | 44 ${UTIL_DIR}/verify_data $algorithmcounter \ |
| 46 ${KEY_DIR}/key_rsa${keylen}.keyb \ | 45 ${KEY_DIR}/key_rsa${keylen}.keyb \ |
| 47 ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig ${TEST_FILE} | 46 ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig ${TEST_FILE} |
| 48 if [ $? -ne 0 ] | 47 if [ $? -ne 0 ] |
| 49 then | 48 then |
| 50 return_code=255 | 49 return_code=255 |
| 51 fi | 50 fi |
| 52 let algorithmcounter=algorithmcounter+1 | 51 let algorithmcounter=algorithmcounter+1 |
| 53 done | 52 done |
| 54 done | 53 done |
| 55 } | |
| 56 | |
| 57 function test_verification { | |
| 58 algorithmcounter=0 | |
| 59 for keylen in ${key_lengths[@]} | |
| 60 do | |
| 61 for hashalgo in ${hash_algos[@]} | |
| 62 do | |
| 63 echo -e "For ${COL_YELLOW}RSA-$keylen and $hashalgo${COL_STOP}:" | |
| 64 cd ${UTIL_DIR} && ${TEST_DIR}/firmware_image_tests $algorithmcounter \ | |
| 65 ${TEST_DIR}/testkeys/key_rsa8192.pem \ | |
| 66 ${TEST_DIR}/testkeys/key_rsa8192.keyb \ | |
| 67 ${TEST_DIR}/testkeys/key_rsa${keylen}.pem \ | |
| 68 ${TEST_DIR}/testkeys/key_rsa${keylen}.keyb | |
| 69 let algorithmcounter=algorithmcounter+1 | |
| 70 done | |
| 71 done | |
| 72 echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..." | 54 echo -e "Peforming ${COL_YELLOW}PKCS #1 v1.5 Padding Tests${COL_STOP}..." |
| 73 ${TEST_DIR}/rsa_padding_test ${TEST_DIR}/testkeys/rsa_padding_test_pubkey.keyb | 55 ${TEST_DIR}/rsa_padding_test ${TEST_DIR}/testkeys/rsa_padding_test_pubkey.keyb |
| 74 } | 56 } |
| 75 | 57 |
| 76 function pre_work { | 58 function pre_work { |
| 77 # Generate a file with random bytes for signature tests. | 59 # Generate a file with random bytes for signature tests. |
| 78 echo "Generating test file..." | 60 echo "Generating test file..." |
| 79 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1 | 61 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1 |
| 80 echo "Generating signatures..." | 62 echo "Generating signatures..." |
| 81 generate_signatures $TEST_FILE | 63 generate_signatures $TEST_FILE |
| (...skipping 18 matching lines...) Expand all Loading... |
| 100 TEST_DIR=${SCRIPT_DIR}/ | 82 TEST_DIR=${SCRIPT_DIR}/ |
| 101 | 83 |
| 102 echo "Generating test cases..." | 84 echo "Generating test cases..." |
| 103 pre_work | 85 pre_work |
| 104 | 86 |
| 105 echo | 87 echo |
| 106 echo "Testing signature verification..." | 88 echo "Testing signature verification..." |
| 107 test_signatures | 89 test_signatures |
| 108 | 90 |
| 109 echo | 91 echo |
| 110 echo "Testing high-level image verification..." | 92 echo "Testing high-level firmware image verification..." |
| 111 test_verification | 93 test_firmware_verification |
| 94 |
| 95 echo |
| 96 echo "Testing high-level kernel image verification..." |
| 97 test_kernel_verification |
| 112 | 98 |
| 113 echo | 99 echo |
| 114 echo "Cleaning up..." | 100 echo "Cleaning up..." |
| 115 cleanup | 101 cleanup |
| 116 | 102 |
| 117 exit $return_code | 103 exit $return_code |
| 118 | 104 |
| OLD | NEW |