Some updates in copy_from_user.
[cryptodev-linux.git] / cryptodev_int.h
blob6f2cc5e77dfd673aedd2d4cf93214cf8604fbe00
1 /* cipher stuff */
2 #ifndef CRYPTODEV_INT_H
3 # define CRYPTODEV_INT_H
5 #include <linux/init.h>
6 #include <linux/sched.h>
7 #include <linux/fs.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>
14 #define PFX "cryptodev: "
15 #define dprintk(level,severity,format,a...) \
16 do { \
17 if (level <= cryptodev_verbosity) \
18 printk(severity PFX "%s[%u]: " format, \
19 current->comm, current->pid, \
20 ##a); \
21 } while (0)
23 extern int cryptodev_verbosity;
25 struct cipher_data
27 int init; /* 0 uninitialized */
28 int blocksize;
29 int ivsize;
30 struct {
31 struct crypto_ablkcipher* s;
32 struct cryptodev_result *result;
33 struct ablkcipher_request *request;
34 uint8_t iv[EALG_MAX_BLOCK_LEN];
35 } async;
38 int cryptodev_cipher_init(struct cipher_data* out, const char* alg_name, __user uint8_t * key, size_t keylen);
39 void cryptodev_cipher_deinit(struct cipher_data* cdata);
40 ssize_t cryptodev_cipher_decrypt( struct cipher_data* cdata, struct scatterlist *sg1, struct scatterlist *sg2, size_t len);
41 ssize_t cryptodev_cipher_encrypt( struct cipher_data* cdata, struct scatterlist *sg1, struct scatterlist *sg2, size_t len);
42 int cryptodev_cipher_set_iv(struct cipher_data* cdata, void* iv, size_t iv_size);
44 /* hash stuff */
45 struct hash_data
47 int init; /* 0 uninitialized */
48 int digestsize;
49 struct {
50 struct crypto_ahash *s;
51 struct cryptodev_result *result;
52 struct ahash_request *request;
53 } async;
56 int cryptodev_hash_final( struct hash_data* hdata, void* output);
57 ssize_t cryptodev_hash_update( struct hash_data* hdata, struct scatterlist *sg, size_t len);
58 int cryptodev_hash_reset( struct hash_data* hdata);
59 void cryptodev_hash_deinit(struct hash_data* hdata);
60 int cryptodev_hash_init( struct hash_data* hdata, const char* alg_name, int hmac_mode, __user void* mackey, size_t mackeylen);
62 /* compatibility stuff */
63 #ifdef CONFIG_COMPAT
65 /* input of CIOCGSESSION */
66 struct compat_session_op {
67 /* Specify either cipher or mac
69 uint32_t cipher; /* cryptodev_crypto_op_t */
70 uint32_t mac; /* cryptodev_crypto_op_t */
72 uint32_t keylen;
73 uint32_t key; /* pointer to key data */
74 uint32_t mackeylen;
75 uint32_t mackey; /* pointer to mac key data */
77 uint32_t ses; /* session identifier */
80 /* input of CIOCCRYPT */
81 struct compat_crypt_op {
82 uint32_t ses; /* session identifier */
83 uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */
84 uint16_t flags; /* no usage so far, use 0 */
85 uint32_t len; /* length of source data */
86 uint32_t src; /* source data */
87 uint32_t dst; /* pointer to output data */
88 uint32_t mac; /* pointer to output data for hash/MAC operations */
89 uint32_t iv; /* initialization vector for encryption operations */
92 /* compat ioctls, defined for the above structs */
93 #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op)
94 #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op)
96 #endif /* CONFIG_COMPAT */
98 #endif /* CRYPTODEV_INT_H */