| 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 # Generate test cases for use for the RSA verify benchmark. | 7 # Generate test cases for use for the RSA verify benchmark. |
| 8 | 8 |
| 9 TESTCASE_DIR=fuzz_testcases | 9 # Load common constants and variables. |
| 10 TESTKEY_DIR=testkeys | 10 . "$(dirname "$0")/common.sh" |
| 11 UTIL_DIR=../utils/ | |
| 12 TEST_FILE=test_file | |
| 13 TEST_FILE_SIZE=1000000 | |
| 14 | 11 |
| 15 hash_algos=( sha1 sha256 sha512 ) | 12 # Use a different directory for fuzzing test cases. |
| 16 key_lengths=( 1024 2048 4096 8192 ) | 13 TESTCASE_DIR=${SCRIPT_DIR}/fuzz_testcases |
| 14 TEST_FILE=${TESTCASE_DIR}/testfile |
| 15 TEST_FILE_SIZE=500000 |
| 17 | 16 |
| 18 # Generate public key signatures and digest on an input file for | 17 # Generate public key signatures and digest on an input file for |
| 19 # various combinations of message digest algorithms and RSA key sizes. | 18 # various combinations of message digest algorithms and RSA key sizes. |
| 20 function generate_fuzzing_images { | 19 function generate_fuzzing_images { |
| 21 echo "Generating signed firmware test image..." | 20 echo "Generating signed firmware test image..." |
| 22 # Generate a test verified boot firmware image and copy root public key. | 21 # Generate a test verified boot firmware image and copy root public key. |
| 23 ${UTIL_DIR}/firmware_utility --generate \ | 22 ${UTIL_DIR}/firmware_utility --generate \ |
| 24 --in $1 \ | 23 --in $1 \ |
| 25 --root_key ${TESTKEY_DIR}/key_rsa8192.pem \ | 24 --root_key ${TESTKEY_DIR}/key_rsa8192.pem \ |
| 26 --firmware_sign_key ${TESTKEY_DIR}/key_rsa4096.pem \ | 25 --firmware_sign_key ${TESTKEY_DIR}/key_rsa4096.pem \ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 --kernel_key_pub ${TESTKEY_DIR}/key_rsa1024.keyb \ | 39 --kernel_key_pub ${TESTKEY_DIR}/key_rsa1024.keyb \ |
| 41 --firmware_sign_algorithm 8 \ | 40 --firmware_sign_algorithm 8 \ |
| 42 --kernel_sign_algorithm 2 \ | 41 --kernel_sign_algorithm 2 \ |
| 43 --kernel_key_version 1 \ | 42 --kernel_key_version 1 \ |
| 44 --kernel_version 1 \ | 43 --kernel_version 1 \ |
| 45 --out ${TESTCASE_DIR}/kernel.signed | 44 --out ${TESTCASE_DIR}/kernel.signed |
| 46 cp ${TESTKEY_DIR}/key_rsa4096.keyb ${TESTCASE_DIR}/firmware_key.keyb | 45 cp ${TESTKEY_DIR}/key_rsa4096.keyb ${TESTCASE_DIR}/firmware_key.keyb |
| 47 } | 46 } |
| 48 | 47 |
| 49 function pre_work { | 48 function pre_work { |
| 50 # Generate a file with random bytes for signature tests. | 49 # Generate a file to serve as random bytes for firmware/kernel contents. |
| 51 echo "Generating test file..." | 50 echo "Generating test file..." |
| 52 dd if=/dev/urandom of=${TESTCASE_DIR}/${TEST_FILE} bs=${TEST_FILE_SIZE} \ | 51 dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1 |
| 53 count=1 | |
| 54 } | 52 } |
| 55 | 53 mkdir -p ${TESTCASE_DIR} |
| 56 if [ ! -d ${TESTKEY_DIR} ] | |
| 57 then | |
| 58 echo "You must run gen_test_keys.sh to generate test keys first." | |
| 59 exit 1 | |
| 60 fi | |
| 61 | |
| 62 if [ ! -d ${TESTCASE_DIR} ] | |
| 63 then | |
| 64 mkdir ${TESTCASE_DIR} | |
| 65 fi | |
| 66 | |
| 67 pre_work | 54 pre_work |
| 68 generate_fuzzing_images ${TESTCASE_DIR}/$TEST_FILE | 55 check_test_keys |
| 56 generate_fuzzing_images ${TEST_FILE} |
| OLD | NEW |