blob: cd9edd4cf429cebedbe085c1a520aad894b1545c [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
41#define CRYPTO_USE_RANDOM 1 /* Get input data from /dev/urandom */
42#define CRYPTO_NOT_RANDOM 0
43
44#define CRYPTO_DEF_WARMUP 2 /* Start with a 2-second busy loop */
45#define CRYPTO_DEF_COUNT 5000 /* Default number of measurements */
46#define CRYPTO_DEF_VERBOSITY 0
47
48
49#define _verbose(lvl, ...) \
50 do { \
51 if (verbosity >= lvl) { \
52 printf(__VA_ARGS__); \
53 fflush(stdout); \
54 } \
55 } while (0)
56
57#define verbose(...) _verbose(1, __VA_ARGS__)
58#define vverbose(...) _verbose(2, __VA_ARGS__)
59
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030060
61int aes_perf_runner_cmd_parser(int argc, char *argv[]);
62void aes_perf_run_test(int mode, int keysize, int decrypt, size_t size,
63 unsigned int n, unsigned int l, int random_in,
64 int in_place, int warmup, int verbosity);
65
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030066int sha_perf_runner_cmd_parser(int argc, char *argv[]);
67void sha_perf_run_test(int algo, size_t size, unsigned int n,
68 unsigned int l, int random_in, int offset,
69 int warmup, int verbosity);
70
71
72
73#endif /* XTEST_CRYPTO_PERF_H */