aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_crypto_internal.h
blob: f85b76eaa8b0dd86a7024275159982925c04d9ff (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Copyright (c) 2014, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef ODP_CRYPTO_INTERNAL_H_
#define ODP_CRYPTO_INTERNAL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <openssl/des.h>
#include <openssl/aes.h>
#include <openssl/evp.h>

#define MAX_IV_LEN      64
#define OP_RESULT_MAGIC 0x91919191

/** Forward declaration of session structure */
typedef struct odp_crypto_generic_session odp_crypto_generic_session_t;

/**
 * Algorithm handler function prototype
 */
typedef
odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param,
				      odp_crypto_generic_session_t *session);

/**
 * Per crypto session data structure
 */
struct odp_crypto_generic_session {
	struct odp_crypto_generic_session *next;

	/* Session creation parameters */
	odp_crypto_session_param_t p;

	odp_bool_t do_cipher_first;

	struct {
		/* Copy of session IV data */
		uint8_t iv_data[MAX_IV_LEN];

		union {
			struct {
				DES_key_schedule ks1;
				DES_key_schedule ks2;
				DES_key_schedule ks3;
			} des;
			struct {
				AES_KEY key;
			} aes;
			struct {
				EVP_CIPHER_CTX *ctx;
			} aes_gcm;
		} data;
		crypto_func_t func;
	} cipher;

	struct {
		union {
			struct {
				uint8_t  key[16];
				uint32_t bytes;
			} md5;
			struct {
				uint8_t  key[32];
				uint32_t bytes;
			} sha256;
		} data;
		crypto_func_t func;
	} auth;
};

/**
 * Per packet operation result
 */
typedef struct odp_crypto_generic_op_result {
	uint32_t magic;
	odp_crypto_op_result_t result;
} odp_crypto_generic_op_result_t;

/**
 * Per session creation operation result
 */
typedef struct odp_crypto_generic_session_result {
	odp_crypto_ses_create_err_t    rc;
	odp_crypto_session_t           session;
} odp_crypto_generic_session_result_t;

#ifdef __cplusplus
}
#endif

#endif