1
2
3
4
5#ifndef CRYPTOCOP_H
6#define CRYPTOCOP_H
7
8#include <uapi/arch-v32/arch/cryptocop.h>
9
10
11
12
13#include <arch/hwregs/dma.h>
14
15typedef enum {
16 cryptocop_alg_csum = 0,
17 cryptocop_alg_mem2mem,
18 cryptocop_alg_md5,
19 cryptocop_alg_sha1,
20 cryptocop_alg_des,
21 cryptocop_alg_3des,
22 cryptocop_alg_aes,
23 cryptocop_no_alg,
24} cryptocop_algorithm;
25
26typedef u8 cryptocop_tfrm_id;
27
28
29struct cryptocop_operation;
30
31typedef void (cryptocop_callback)(struct cryptocop_operation*, void*);
32
33struct cryptocop_transform_init {
34 cryptocop_algorithm alg;
35
36 unsigned char key[CRYPTOCOP_MAX_KEY_LENGTH];
37 unsigned int keylen;
38 cryptocop_cipher_mode cipher_mode;
39 cryptocop_3des_mode tdes_mode;
40 cryptocop_csum_type csum_mode;
41
42 cryptocop_tfrm_id tid;
43 struct cryptocop_transform_init *next;
44};
45
46
47typedef enum {
48 cryptocop_source_dma = 0,
49 cryptocop_source_des,
50 cryptocop_source_3des,
51 cryptocop_source_aes,
52 cryptocop_source_md5,
53 cryptocop_source_sha1,
54 cryptocop_source_csum,
55 cryptocop_source_none,
56} cryptocop_source;
57
58
59struct cryptocop_desc_cfg {
60 cryptocop_tfrm_id tid;
61 cryptocop_source src;
62 unsigned int last:1;
63 struct cryptocop_desc_cfg *next;
64};
65
66struct cryptocop_desc {
67 size_t length;
68 struct cryptocop_desc_cfg *cfg;
69 struct cryptocop_desc *next;
70};
71
72
73
74#define CRYPTOCOP_NO_FLAG (0x00)
75#define CRYPTOCOP_ENCRYPT (0x01)
76#define CRYPTOCOP_DECRYPT (0x02)
77#define CRYPTOCOP_EXPLICIT_IV (0x04)
78
79struct cryptocop_tfrm_cfg {
80 cryptocop_tfrm_id tid;
81
82 unsigned int flags;
83
84
85 u8 iv[CRYPTOCOP_MAX_IV_LENGTH];
86
87
88
89
90
91 size_t inject_ix;
92
93 struct cryptocop_tfrm_cfg *next;
94};
95
96
97
98struct cryptocop_dma_list_operation{
99
100
101
102
103 dma_descr_data *outlist;
104 char *out_data_buf;
105 dma_descr_data *inlist;
106 char *in_data_buf;
107
108 cryptocop_3des_mode tdes_mode;
109 cryptocop_csum_type csum_mode;
110};
111
112
113struct cryptocop_tfrm_operation{
114
115 struct cryptocop_tfrm_cfg *tfrm_cfg;
116 struct cryptocop_desc *desc;
117
118 struct iovec *indata;
119 size_t incount;
120 size_t inlen;
121
122 struct iovec *outdata;
123 size_t outcount;
124 size_t outlen;
125};
126
127
128struct cryptocop_operation {
129 cryptocop_callback *cb;
130 void *cb_data;
131
132 cryptocop_session_id sid;
133
134
135 int operation_status;
136
137
138 unsigned int use_dmalists:1;
139 unsigned int in_interrupt:1;
140 unsigned int fast_callback:1;
141
142 union{
143 struct cryptocop_dma_list_operation list_op;
144 struct cryptocop_tfrm_operation tfrm_op;
145 };
146};
147
148
149int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_init *tinit, int alloc_flag);
150int cryptocop_free_session(cryptocop_session_id sid);
151
152int cryptocop_job_queue_insert_csum(struct cryptocop_operation *operation);
153
154int cryptocop_job_queue_insert_crypto(struct cryptocop_operation *operation);
155
156int cryptocop_job_queue_insert_user_job(struct cryptocop_operation *operation);
157
158#endif
159