blob: 1cc67a97b1faaa0e19a4e032b636b1a1637aaa99 [file] [log] [blame]
Igor Opaniuk44aff4b2016-09-16 10:18:00 +03001/*
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 Opaniukf9b7fd22016-09-16 16:22:34 +030028#ifndef XTEST_CRYPTO_COMMON_H
29#define XTEST_CRYPTO_COMMON_H
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030030
31#include "ta_aes_perf.h"
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030032#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 Carriered851fc72017-04-26 15:08:02 +020041#define CRYPTO_USE_ZEROS 0 /* Init input data to zero */
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030042#define CRYPTO_USE_RANDOM 1 /* Get input data from /dev/urandom */
Etienne Carriered851fc72017-04-26 15:08:02 +020043#define CRYPTO_NOT_INITED 2 /* Input data are not initialized */
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030044
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
Jerome Forissiera410edb2018-03-08 10:36:37 +010048#define CRYPTO_DEF_UNIT_SIZE 0 /* Process whole buffer */
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030049
50
51#define _verbose(lvl, ...) \
52 do { \
53 if (verbosity >= lvl) { \
54 printf(__VA_ARGS__); \
55 fflush(stdout); \
56 } \
57 } while (0)
58
59#define verbose(...) _verbose(1, __VA_ARGS__)
60#define vverbose(...) _verbose(2, __VA_ARGS__)
61
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030062
63int aes_perf_runner_cmd_parser(int argc, char *argv[]);
64void aes_perf_run_test(int mode, int keysize, int decrypt, size_t size,
Jerome Forissiera410edb2018-03-08 10:36:37 +010065 size_t unit, unsigned int n, unsigned int l,
66 int random_in, int in_place, int warmup, int verbosity);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030067
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030068int sha_perf_runner_cmd_parser(int argc, char *argv[]);
69void sha_perf_run_test(int algo, size_t size, unsigned int n,
70 unsigned int l, int random_in, int offset,
71 int warmup, int verbosity);
72
Etienne Carriere41343db2017-03-17 15:38:52 +010073#ifdef CFG_SECURE_DATA_PATH
74int sdp_basic_runner_cmd_parser(int argc, char *argv[]);
75#endif
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030076
77#endif /* XTEST_CRYPTO_PERF_H */