aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api/crypto/util.h
blob: a81a5682025b2a028e4cba444bae52d4ba0bb39d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (c) 2014-2018, Linaro Limited
 * Copyright (c) 2021-2023, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:	BSD-3-Clause
 */

#ifndef UTIL_H
#define UTIL_H

#include <stdint.h>
#include <odp_api.h>
#include <odp_cunit_common.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))

struct suite_context_s {
	odp_crypto_op_mode_t op_mode;
	odp_pool_t pool;
	odp_queue_t queue;
	odp_queue_type_t q_type;
	odp_event_t (*compl_queue_deq)(void);
};

extern struct suite_context_s suite_context;

const char *auth_alg_name(odp_auth_alg_t auth);

const char *cipher_alg_name(odp_cipher_alg_t cipher);

/*
 * Check if given cipher and authentication algorithms are supported
 *
 * cipher      Cipher algorithm
 * auth        Authentication algorithm
 *
 * returns ODP_TEST_ACTIVE when both algorithms are supported or
 *         ODP_TEST_INACTIVE when either algorithm is not supported
 */
int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth);

static inline void fill_with_pattern(uint8_t *buf, uint32_t len)
{
	static uint8_t value;

	for (uint32_t n = 0; n < len; n++)
		buf[n] = value++;
}

#endif