2 #ifndef CRYPTODEV_INT_H
3 # define CRYPTODEV_INT_H
5 #include <linux/init.h>
6 #include <linux/sched.h>
8 #include <linux/file.h>
9 #include <linux/fdtable.h>
10 #include <linux/miscdevice.h>
11 #include <linux/module.h>
12 #include <linux/moduleparam.h>
13 #include <linux/scatterlist.h>
14 #include <crypto/cryptodev.h>
15 #include <crypto/aead.h>
17 #define PFX "cryptodev: "
18 #define dprintk(level, severity, format, a...) \
20 if (level <= cryptodev_verbosity) \
21 printk(severity PFX "%s[%u] (%s:%u): " format, \
22 current->comm, current->pid, \
27 extern int cryptodev_verbosity
;
30 struct list_head list
;
34 /* compatibility stuff */
36 #include <linux/compat.h>
38 /* input of CIOCGSESSION */
39 struct compat_session_op
{
40 /* Specify either cipher or mac
42 uint32_t cipher
; /* cryptodev_crypto_op_t */
43 uint32_t mac
; /* cryptodev_crypto_op_t */
46 compat_uptr_t key
; /* pointer to key data */
48 compat_uptr_t mackey
; /* pointer to mac key data */
50 uint32_t ses
; /* session identifier */
53 /* input of CIOCCRYPT */
54 struct compat_crypt_op
{
55 uint32_t ses
; /* session identifier */
56 uint16_t op
; /* COP_ENCRYPT or COP_DECRYPT */
57 uint16_t flags
; /* see COP_FLAG_* */
58 uint32_t len
; /* length of source data */
59 compat_uptr_t src
; /* source data */
60 compat_uptr_t dst
; /* pointer to output data */
61 compat_uptr_t mac
;/* pointer to output data for hash/MAC operations */
62 compat_uptr_t iv
;/* initialization vector for encryption operations */
65 /* compat ioctls, defined for the above structs */
66 #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op)
67 #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op)
68 #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op)
69 #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op)
71 #endif /* CONFIG_COMPAT */
73 /* kernel-internal extension to struct crypt_op */
74 struct kernel_crypt_op
{
78 __u8 iv
[EALG_MAX_BLOCK_LEN
];
81 uint8_t hash_output
[AALG_MAX_RESULT_LEN
];
83 struct task_struct
*task
;
87 struct kernel_crypt_auth_op
{
88 struct crypt_auth_op caop
;
90 int dst_len
; /* based on src_len + pad + tag */
92 __u8 iv
[EALG_MAX_BLOCK_LEN
];
94 struct task_struct
*task
;
100 int kcaop_from_user(struct kernel_crypt_auth_op
*kcop
,
101 struct fcrypt
*fcr
, void __user
*arg
);
102 int kcaop_to_user(struct kernel_crypt_auth_op
*kcaop
,
103 struct fcrypt
*fcr
, void __user
*arg
);
104 int crypto_auth_run(struct fcrypt
*fcr
, struct kernel_crypt_auth_op
*kcaop
);
105 int crypto_run(struct fcrypt
*fcr
, struct kernel_crypt_op
*kcop
);
107 #include <cryptlib.h>
109 /* other internal structs */
111 struct list_head entry
;
113 struct cipher_data cdata
;
114 struct hash_data hdata
;
118 unsigned int array_size
;
119 unsigned int used_pages
; /* the number of pages that are used */
120 /* the number of pages marked as writable (first are the readable) */
121 unsigned int readable_pages
;
123 struct scatterlist
*sg
;
126 struct csession
*crypto_get_session_by_sid(struct fcrypt
*fcr
, uint32_t sid
);
128 inline static void crypto_put_session(struct csession
* ses_ptr
)
130 mutex_unlock(&ses_ptr
->sem
);
132 int adjust_sg_array(struct csession
* ses
, int pagecount
);
134 #endif /* CRYPTODEV_INT_H */