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 | |
| 64 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2001, xtest_tee_benchmark_2001, |
| 65 | /* Title */ |
| 66 | "TEE SHA Performance test (TA_SHA_SHA1)", |
| 67 | /* Short description */ |
| 68 | "Hashing 1024 bytes buffer with SHA1 algo, offset = 0", |
| 69 | /* Requirement IDs */ "", |
| 70 | /* How to implement */ "" |
| 71 | ); |
| 72 | |
| 73 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2002, xtest_tee_benchmark_2002, |
| 74 | /* Title */ |
| 75 | "TEE SHA Performance test (TA_SHA_SHA226)", |
| 76 | /* Short description */ |
| 77 | "Hashing 4096 bytes buffer with SHA256 algo, offset = 0", |
| 78 | /* Requirement IDs */ "", |
| 79 | /* How to implement */ "" |
| 80 | ); |
| 81 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 82 | |
| 83 | /* ----------------------------------------------------------------------- */ |
| 84 | /* -------------------------- AES Benchmarks ----------------------------- */ |
| 85 | /* ----------------------------------------------------------------------- */ |
| 86 | |
| 87 | static void xtest_tee_benchmark_2011(ADBG_Case_t *c) |
| 88 | { |
| 89 | UNUSED(c); |
| 90 | |
| 91 | int mode = TA_AES_ECB; /* AES mode */ |
| 92 | int decrypt = 0; /* Encrypt */ |
| 93 | int keysize = AES_128; |
| 94 | size_t size = 1024; /* Buffer size */ |
| 95 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame^] | 96 | aes_perf_run_test(mode, keysize, decrypt, size, CRYPTO_DEF_COUNT, |
| 97 | CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, AES_PERF_INPLACE, |
| 98 | CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | static void xtest_tee_benchmark_2012(ADBG_Case_t *c) |
| 102 | { |
| 103 | UNUSED(c); |
| 104 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame^] | 105 | int mode = TA_AES_CBC; /* AES mode */ |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 106 | int decrypt = 0; /* Encrypt */ |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame^] | 107 | int keysize = AES_256; |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 108 | size_t size = 1024; /* Buffer size */ |
| 109 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame^] | 110 | aes_perf_run_test(mode, keysize, decrypt, size, CRYPTO_DEF_COUNT, |
| 111 | CRYPTO_DEF_LOOPS, CRYPTO_USE_RANDOM, AES_PERF_INPLACE, |
| 112 | CRYPTO_DEF_WARMUP, CRYPTO_DEF_VERBOSITY); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2011, xtest_tee_benchmark_2011, |
| 116 | /* Title */ |
| 117 | "TEE AES Performance test (TA_AES_ECB)", |
| 118 | /* Short description */ |
| 119 | "Short description...", |
| 120 | /* Requirement IDs */ "", |
| 121 | /* How to implement */ "" |
| 122 | ); |
| 123 | |
| 124 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2012, xtest_tee_benchmark_2012, |
| 125 | /* Title */ |
| 126 | "TEE AES Performance test (TA_AES_CBC)", |
| 127 | /* Short description */ |
| 128 | "Short description...", |
| 129 | /* Requirement IDs */ "", |
| 130 | /* How to implement */ "" |
| 131 | ); |
| 132 | |