gen_test_cases.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Generate test cases for use for the RSA verify benchmark.
  6. # Load common constants and variables.
  7. . "$(dirname "$0")/common.sh"
  8. TEST_FILE=${TESTCASE_DIR}/test_file
  9. TEST_FILE_SIZE=1000000
  10. # Generate public key signatures on an input file for various combinations
  11. # of message digest algorithms and RSA key sizes.
  12. function generate_test_signatures {
  13. echo "Generating test signatures..."
  14. algorithmcounter=0
  15. for keylen in ${key_lengths[@]}
  16. do
  17. for hashalgo in ${hash_algos[@]}
  18. do
  19. openssl dgst -${hashalgo} -binary ${TEST_FILE} > \
  20. ${TEST_FILE}.${hashalgo}.digest
  21. ${BIN_DIR}/signature_digest_utility $algorithmcounter \
  22. ${TEST_FILE} | openssl rsautl \
  23. -sign -pkcs -inkey ${TESTKEY_DIR}/key_rsa${keylen}.pem \
  24. > ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig
  25. let algorithmcounter=algorithmcounter+1
  26. done
  27. done
  28. }
  29. # Generate a file with random bytes for signature tests.
  30. function generate_test_file {
  31. echo "Generating test file..."
  32. dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
  33. }
  34. mkdir -p ${TESTCASE_DIR}
  35. check_test_keys
  36. generate_test_file
  37. generate_test_signatures