Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015, Linaro Limited |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <stdio.h> |
| 15 | #include <stdlib.h> |
| 16 | #include <string.h> |
| 17 | |
| 18 | #include "xtest_test.h" |
| 19 | #include "xtest_helpers.h" |
| 20 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 21 | #include <crypto_common.h> |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 22 | #include <util.h> |
| 23 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 24 | /* SHA bechmarks */ |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 25 | static void xtest_tee_benchmark_2001(ADBG_Case_t *Case_p); |
| 26 | static void xtest_tee_benchmark_2002(ADBG_Case_t *Case_p); |
| 27 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 28 | /* AES benchmarks */ |
| 29 | static void xtest_tee_benchmark_2011(ADBG_Case_t *Case_p); |
| 30 | static void xtest_tee_benchmark_2012(ADBG_Case_t *Case_p); |
| 31 | |
| 32 | /* ----------------------------------------------------------------------- */ |
| 33 | /* -------------------------- SHA Benchmarks ----------------------------- */ |
| 34 | /* ----------------------------------------------------------------------- */ |
| 35 | |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 36 | static void xtest_tee_benchmark_2001(ADBG_Case_t *c) |
| 37 | { |
| 38 | UNUSED(c); |
| 39 | |
| 40 | int algo = TA_SHA_SHA1; /* Algorithm */ |
| 41 | size_t size = 1024; /* Buffer size */ |
| 42 | int offset = 0; /* Buffer offset wrt. alloc'ed address */ |
| 43 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 44 | sha_perf_run_test(algo, size, CRYPTO_DEF_COUNT, |
| 45 | CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, offset, |
| 46 | CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 47 | |
| 48 | } |
| 49 | |
| 50 | static void xtest_tee_benchmark_2002(ADBG_Case_t *c) |
| 51 | { |
| 52 | UNUSED(c); |
| 53 | |
| 54 | int algo = TA_SHA_SHA256; /* Algorithm */ |
| 55 | size_t size = 4096; /* Buffer size */ |
| 56 | int offset = 0; /* Buffer offset wrt. alloc'ed address */ |
| 57 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 58 | sha_perf_run_test(algo, size, CRYPTO_DEF_COUNT, |
| 59 | CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, offset, |
| 60 | CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 61 | |
| 62 | } |
| 63 | |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 64 | ADBG_CASE_DEFINE(benchmark, 2001, xtest_tee_benchmark_2001, |
Jens Wiklander | 25a57fe | 2016-12-26 21:46:24 +0100 | [diff] [blame] | 65 | "TEE SHA Performance test (TA_SHA_SHA1)"); |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 66 | ADBG_CASE_DEFINE(benchmark, 2002, xtest_tee_benchmark_2002, |
Jens Wiklander | 25a57fe | 2016-12-26 21:46:24 +0100 | [diff] [blame] | 67 | "TEE SHA Performance test (TA_SHA_SHA226)"); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 68 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 69 | |
| 70 | /* ----------------------------------------------------------------------- */ |
| 71 | /* -------------------------- AES Benchmarks ----------------------------- */ |
| 72 | /* ----------------------------------------------------------------------- */ |
| 73 | |
| 74 | static void xtest_tee_benchmark_2011(ADBG_Case_t *c) |
| 75 | { |
| 76 | UNUSED(c); |
| 77 | |
| 78 | int mode = TA_AES_ECB; /* AES mode */ |
| 79 | int decrypt = 0; /* Encrypt */ |
| 80 | int keysize = AES_128; |
| 81 | size_t size = 1024; /* Buffer size */ |
| 82 | |
Jerome Forissier | a410edb | 2018-03-08 10:36:37 +0100 | [diff] [blame^] | 83 | aes_perf_run_test(mode, keysize, decrypt, size, CRYPTO_DEF_UNIT_SIZE, |
| 84 | CRYPTO_DEF_COUNT, CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, |
| 85 | AES_PERF_INPLACE, CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static void xtest_tee_benchmark_2012(ADBG_Case_t *c) |
| 89 | { |
| 90 | UNUSED(c); |
| 91 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 92 | int mode = TA_AES_CBC; /* AES mode */ |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 93 | int decrypt = 0; /* Encrypt */ |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 94 | int keysize = AES_256; |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 95 | size_t size = 1024; /* Buffer size */ |
| 96 | |
Jerome Forissier | a410edb | 2018-03-08 10:36:37 +0100 | [diff] [blame^] | 97 | aes_perf_run_test(mode, keysize, decrypt, size, CRYPTO_DEF_UNIT_SIZE, |
| 98 | CRYPTO_DEF_COUNT, CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, |
| 99 | AES_PERF_INPLACE, CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 100 | } |
| 101 | |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 102 | ADBG_CASE_DEFINE(benchmark, 2011, xtest_tee_benchmark_2011, |
Jens Wiklander | 25a57fe | 2016-12-26 21:46:24 +0100 | [diff] [blame] | 103 | "TEE AES Performance test (TA_AES_ECB)"); |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 104 | ADBG_CASE_DEFINE(benchmark, 2012, xtest_tee_benchmark_2012, |
Jens Wiklander | 25a57fe | 2016-12-26 21:46:24 +0100 | [diff] [blame] | 105 | "TEE AES Performance test (TA_AES_CBC)"); |