bench.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-License-Identifier: GPL-2.0-or-later
  4. #
  5. # Parametrisation to this script is as follows:
  6. # * The first argument will be taken as suffix to the result folder
  7. # e.g. `./bench.sh _config0`
  8. # * It is possible to make its output a bit more verbose by setting
  9. # the `VERBOSE` environment variable to '1', e.g. via
  10. # `VERBOSE=1 ./bench.sh` or to make it quiet by setting it to '0'
  11. # * Per default we read from /dev/ttyUSB2, by setting the `WC_TTY`
  12. # environment variable this can adapted
  13. # e.g. `WC_TTY=/dev/ttyACM0 ./bench.sh`
  14. ###
  15. # Preamble
  16. ###
  17. my_path=$(dirname $(readlink -f $0)) || exit $?
  18. readonly my_path
  19. readonly csv_path_suffix="$1"
  20. readonly common_opts="-blocks 128"
  21. readonly ccm_gcm_opts="-all_aad -aad_size 13"
  22. # options used in `small_block()`
  23. readonly cbc_opts="$common_opts"
  24. readonly ccm_opts="$common_opts $ccm_gcm_opts"
  25. readonly gcm_opts="$common_opts $ccm_gcm_opts"
  26. readonly small_block_ciphers="cbc ccm gcm"
  27. readonly small_block_ciphers_hw="gcm"
  28. readonly small_block_sizes="16 528 1024 4112 7696 15888 32768 65536 131072"
  29. # options used in `large_block()`
  30. readonly ccm_fast_opts="$common_opts -all_aad"
  31. readonly gcm_fast_opts="$common_opts -all_aad"
  32. # 512 MiB transfer, 128 MiB max. blocksize
  33. readonly large_block_ciphers="gcm"
  34. readonly large_num_bytes=$((512 * 1024 * 1024))
  35. readonly large_max_blocksize=$((128 * 1024 * 1024))
  36. source "$my_path"/../../scripts/bench/bench_functions.sh
  37. ###
  38. # Implementation
  39. ###
  40. [ "$1" == "_HW" ] && small_block "$small_block_ciphers_hw" \
  41. || small_block "$small_block_ciphers"
  42. # No large blocksizes for analysis
  43. #[ "$1" == "_HW" ] && large_block
  44. # Benchmark only on HW and SW
  45. if [ "$1" != "_ARMv8" ]; then
  46. bench "ecc" "-ecc -ecc-all -ecc-kg"
  47. bench "sha3" "-sha3-384"
  48. for keysize in 2048 3072 4096
  49. do
  50. bench "rsa" "-rsa-sz -rsa-kg $keysize" "_$keysize"
  51. done
  52. bench "rng" "-rng"
  53. fi
  54. # Benchmark only on ARMv8 and SW
  55. if [ "$1" != "_HW" ]; then
  56. bench "sha2" "-sha2"
  57. bench "cmac" "-cmac"
  58. fi
  59. #eof