Corrected issue in assigning other pages than the first.
[cryptodev-linux.git] / cryptodev_int.h
blobbc3b586a233a3f399321a7a83281acedd27a685b
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 #undef DISABLE_ZCOPY
16 #define PFX "cryptodev: "
17 #define dprintk(level,severity,format,a...) \
18 do { \
19 if (level <= cryptodev_verbosity) \
20 printk(severity PFX "%s[%u]: " format, \
21 current->comm, current->pid, \
22 ##a); \
23 } while (0)
25 extern int cryptodev_verbosity;
27 struct cipher_data
29 int init; /* 0 uninitialized */
30 int blocksize;
31 int ivsize;
32 struct {
33 struct crypto_ablkcipher* s;
34 struct cryptodev_result *result;
35 struct ablkcipher_request *request;
36 uint8_t iv[EALG_MAX_BLOCK_LEN];
37 } async;
40 int cryptodev_cipher_init(struct cipher_data* out, const char* alg_name, uint8_t * key, size_t keylen);
41 void cryptodev_cipher_deinit(struct cipher_data* cdata);
42 ssize_t cryptodev_cipher_decrypt( struct cipher_data* cdata, struct scatterlist *sg1, struct scatterlist *sg2, size_t len);
43 ssize_t cryptodev_cipher_encrypt( struct cipher_data* cdata, struct scatterlist *sg1, struct scatterlist *sg2, size_t len);
44 void cryptodev_cipher_set_iv(struct cipher_data* cdata, void* iv, size_t iv_size);
46 /* hash stuff */
47 struct hash_data
49 int init; /* 0 uninitialized */
50 int digestsize;
51 struct {
52 struct crypto_ahash *s;
53 struct cryptodev_result *result;
54 struct ahash_request *request;
55 } async;
58 int cryptodev_hash_final( struct hash_data* hdata, void* output);
59 ssize_t cryptodev_hash_update( struct hash_data* hdata, struct scatterlist *sg, size_t len);
60 int cryptodev_hash_reset( struct hash_data* hdata);
61 void cryptodev_hash_deinit(struct hash_data* hdata);
62 int cryptodev_hash_init( struct hash_data* hdata, const char* alg_name, int hmac_mode, void* mackey, size_t mackeylen);
64 /* compatibility stuff */
65 #ifdef CONFIG_COMPAT
66 #include <linux/compat.h>
68 /* input of CIOCGSESSION */
69 struct compat_session_op {
70 /* Specify either cipher or mac
72 uint32_t cipher; /* cryptodev_crypto_op_t */
73 uint32_t mac; /* cryptodev_crypto_op_t */
75 uint32_t keylen;
76 compat_uptr_t key; /* pointer to key data */
77 uint32_t mackeylen;
78 compat_uptr_t mackey; /* pointer to mac key data */
80 uint32_t ses; /* session identifier */
83 /* input of CIOCCRYPT */
84 struct compat_crypt_op {
85 uint32_t ses; /* session identifier */
86 uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */
87 uint16_t flags; /* no usage so far, use 0 */
88 uint32_t len; /* length of source data */
89 compat_uptr_t src; /* source data */
90 compat_uptr_t dst; /* pointer to output data */
91 compat_uptr_t mac; /* pointer to output data for hash/MAC operations */
92 compat_uptr_t iv; /* initialization vector for encryption operations */
95 /* compat ioctls, defined for the above structs */
96 #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op)
97 #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op)
99 #endif /* CONFIG_COMPAT */
101 #endif /* CRYPTODEV_INT_H */