Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/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. | |
| 6 | |
| 7 # Generate test cases for use for the RSA verify benchmark. | |
| 8 | |
| 9 TESTCASE_DIR=fuzz_testcases | |
| 10 TESTKEY_DIR=testkeys | |
| 11 UTIL_DIR=../utils/ | |
| 12 TEST_FILE=test_file | |
| 13 TEST_FILE_SIZE=1000000 | |
| 14 | |
| 15 hash_algos=( sha1 sha256 sha512 ) | |
| 16 key_lengths=( 1024 2048 4096 8192 ) | |
| 17 | |
| 18 # Generate public key signatures and digest on an input file for | |
| 19 # various combinations of message digest algorithms and RSA key sizes. | |
| 20 function generate_fuzzing_images { | |
| 21 echo "Generating signed firmware test image..." | |
| 22 # Generate a test verified boot firmware image and copy root public key. | |
| 23 ${UTIL_DIR}/firmware_utility --generate \ | |
| 24 --in $1 \ | |
| 25 --root_key ${TESTKEY_DIR}/key_rsa8192.pem \ | |
| 26 --firmware_sign_key ${TESTKEY_DIR}/key_rsa4096.pem \ | |
| 27 --firmware_sign_key_pub ${TESTKEY_DIR}/key_rsa4096.keyb \ | |
| 28 --firmware_sign_algorithm 8 \ | |
| 29 --firmware_key_version 1 \ | |
| 30 --firmware_version 1 \ | |
| 31 --out ${TESTCASE_DIR}/firmware.signed | |
| 32 cp ${TESTKEY_DIR}/key_rsa8192.keyb ${TESTCASE_DIR}/root_key.keyb | |
| 33 | |
| 34 echo "Generating signed kernel test image..." | |
| 35 # Generate a test verified boot kernel image and copy firmware public key. | |
| 36 ${UTIL_DIR}/kernel_utility --generate \ | |
| 37 --in $1 \ | |
| 38 --firmware_key ${TESTKEY_DIR}/key_rsa4096.pem \ | |
| 39 --kernel_key ${TESTKEY_DIR}/key_rsa1024.pem \ | |
| 40 --kernel_key_pub ${TESTKEY_DIR}/key_rsa1024.keyb \ | |
| 41 --firmware_sign_algorithm 8 \ | |
| 42 --kernel_sign_algorithm 2 \ | |
| 43 --kernel_key_version 1 \ | |
| 44 --kernel_version 1 \ | |
| 45 --out ${TESTCASE_DIR}/kernel.signed | |
| 46 cp ${TESTKEY_DIR}/key_rsa4096.keyb ${TESTCASE_DIR}/firmware_key.keyb | |
| 47 } | |
| 48 | |
| 49 function pre_work { | |
| 50 # Generate a file with random bytes for signature tests. | |
| 51 echo "Generating test file..." | |
| 52 dd if=/dev/urandom of=${TESTCASE_DIR}/${TEST_FILE} bs=${TEST_FILE_SIZE} count= 1 | |
|
Chris Masone
2010/03/18 03:34:05
80 char
| |
| 53 } | |
| 54 | |
| 55 if [ ! -d "$TESTKEY_DIR" ] | |
|
sosa
2010/03/18 03:37:48
Inconsistent use of {} vs non {} in script
| |
| 56 then | |
| 57 echo "You must run gen_test_keys.sh to generate test keys first." | |
| 58 exit 1 | |
| 59 fi | |
| 60 | |
| 61 if [ ! -d "$TESTCASE_DIR" ] | |
| 62 then | |
| 63 mkdir "$TESTCASE_DIR" | |
| 64 fi | |
| 65 | |
| 66 pre_work | |
| 67 generate_fuzzing_images ${TESTCASE_DIR}/$TEST_FILE | |
| OLD | NEW |