1
2
3
4
5
6#ifndef _UAPICRYPTOCOP_H
7#define _UAPICRYPTOCOP_H
8
9#include <linux/uio.h>
10
11
12#define CRYPTOCOP_SESSION_ID_NONE (0)
13
14typedef unsigned long long int cryptocop_session_id;
15
16
17#define ETRAXCRYPTOCOP_IOCTYPE (250)
18
19#define CRYPTOCOP_IO_CREATE_SESSION _IOWR(ETRAXCRYPTOCOP_IOCTYPE, 1, struct strcop_session_op)
20#define CRYPTOCOP_IO_CLOSE_SESSION _IOW(ETRAXCRYPTOCOP_IOCTYPE, 2, struct strcop_session_op)
21#define CRYPTOCOP_IO_PROCESS_OP _IOWR(ETRAXCRYPTOCOP_IOCTYPE, 3, struct strcop_crypto_op)
22#define CRYPTOCOP_IO_MAXNR (3)
23
24typedef enum {
25 cryptocop_cipher_des = 0,
26 cryptocop_cipher_3des = 1,
27 cryptocop_cipher_aes = 2,
28 cryptocop_cipher_m2m = 3,
29 cryptocop_cipher_none
30} cryptocop_cipher_type;
31
32typedef enum {
33 cryptocop_digest_sha1 = 0,
34 cryptocop_digest_md5 = 1,
35 cryptocop_digest_none
36} cryptocop_digest_type;
37
38typedef enum {
39 cryptocop_csum_le = 0,
40 cryptocop_csum_be = 1,
41 cryptocop_csum_none
42} cryptocop_csum_type;
43
44typedef enum {
45 cryptocop_cipher_mode_ecb = 0,
46 cryptocop_cipher_mode_cbc,
47 cryptocop_cipher_mode_none
48} cryptocop_cipher_mode;
49
50typedef enum {
51 cryptocop_3des_eee = 0,
52 cryptocop_3des_eed = 1,
53 cryptocop_3des_ede = 2,
54 cryptocop_3des_edd = 3,
55 cryptocop_3des_dee = 4,
56 cryptocop_3des_ded = 5,
57 cryptocop_3des_dde = 6,
58 cryptocop_3des_ddd = 7
59} cryptocop_3des_mode;
60
61
62struct strcop_session_op{
63 cryptocop_session_id ses_id;
64
65 cryptocop_cipher_type cipher;
66
67 cryptocop_cipher_mode cmode;
68 cryptocop_3des_mode des3_mode;
69
70 cryptocop_digest_type digest;
71
72 cryptocop_csum_type csum;
73
74 unsigned char *key;
75 size_t keylen;
76};
77
78#define CRYPTOCOP_CSUM_LENGTH (2)
79#define CRYPTOCOP_MAX_DIGEST_LENGTH (20)
80#define CRYPTOCOP_MAX_IV_LENGTH (16)
81#define CRYPTOCOP_MAX_KEY_LENGTH (32)
82
83struct strcop_crypto_op{
84 cryptocop_session_id ses_id;
85
86
87 unsigned char *indata;
88 size_t inlen;
89
90
91 unsigned char do_cipher:1;
92 unsigned char decrypt:1;
93 unsigned char cipher_explicit:1;
94 size_t cipher_start;
95 size_t cipher_len;
96
97
98
99 unsigned char cipher_iv[CRYPTOCOP_MAX_IV_LENGTH];
100
101 unsigned char *cipher_outdata;
102 size_t cipher_outlen;
103
104
105 unsigned char do_digest:1;
106 size_t digest_start;
107 size_t digest_len;
108
109 unsigned char digest[CRYPTOCOP_MAX_DIGEST_LENGTH];
110
111
112 unsigned char do_csum:1;
113 size_t csum_start;
114 size_t csum_len;
115
116 unsigned char csum[CRYPTOCOP_CSUM_LENGTH];
117};
118
119
120
121
122#endif
123