Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015, Linaro Limited |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation |
| 13 | * and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | * POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 28 | #ifndef XTEST_CRYPTO_COMMON_H |
| 29 | #define XTEST_CRYPTO_COMMON_H |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 30 | |
| 31 | #include "ta_aes_perf.h" |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 32 | #include "ta_sha_perf.h" |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | #define AES_PERF_INPLACE 0 |
| 38 | |
| 39 | #define CRYPTO_DEF_LOOPS 1 /* Default amount of inner loops */ |
| 40 | |
Etienne Carriere | d851fc7 | 2017-04-26 15:08:02 +0200 | [diff] [blame^] | 41 | #define CRYPTO_USE_ZEROS 0 /* Init input data to zero */ |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 42 | #define CRYPTO_USE_RANDOM 1 /* Get input data from /dev/urandom */ |
Etienne Carriere | d851fc7 | 2017-04-26 15:08:02 +0200 | [diff] [blame^] | 43 | #define CRYPTO_NOT_INITED 2 /* Input data are not initialized */ |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 44 | |
| 45 | #define CRYPTO_DEF_WARMUP 2 /* Start with a 2-second busy loop */ |
| 46 | #define CRYPTO_DEF_COUNT 5000 /* Default number of measurements */ |
| 47 | #define CRYPTO_DEF_VERBOSITY 0 |
| 48 | |
| 49 | |
| 50 | #define _verbose(lvl, ...) \ |
| 51 | do { \ |
| 52 | if (verbosity >= lvl) { \ |
| 53 | printf(__VA_ARGS__); \ |
| 54 | fflush(stdout); \ |
| 55 | } \ |
| 56 | } while (0) |
| 57 | |
| 58 | #define verbose(...) _verbose(1, __VA_ARGS__) |
| 59 | #define vverbose(...) _verbose(2, __VA_ARGS__) |
| 60 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 61 | |
| 62 | int aes_perf_runner_cmd_parser(int argc, char *argv[]); |
| 63 | void aes_perf_run_test(int mode, int keysize, int decrypt, size_t size, |
| 64 | unsigned int n, unsigned int l, int random_in, |
| 65 | int in_place, int warmup, int verbosity); |
| 66 | |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 67 | int sha_perf_runner_cmd_parser(int argc, char *argv[]); |
| 68 | void sha_perf_run_test(int algo, size_t size, unsigned int n, |
| 69 | unsigned int l, int random_in, int offset, |
| 70 | int warmup, int verbosity); |
| 71 | |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 72 | #ifdef CFG_SECURE_DATA_PATH |
| 73 | int sdp_basic_runner_cmd_parser(int argc, char *argv[]); |
| 74 | #endif |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 75 | |
| 76 | #endif /* XTEST_CRYPTO_PERF_H */ |