allow using the null cipher
[cryptodev-linux.git] / cryptodev_int.h
blobbc548c4399e3ec2ed1da92a1180d5819a3ff7115
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
64 #include <linux/compat.h>
66 /* input of CIOCGSESSION */
67 struct compat_session_op {
68 /* Specify either cipher or mac
70 uint32_t cipher; /* cryptodev_crypto_op_t */
71 uint32_t mac; /* cryptodev_crypto_op_t */
73 uint32_t keylen;
74 compat_uptr_t key; /* pointer to key data */
75 uint32_t mackeylen;
76 compat_uptr_t mackey; /* pointer to mac key data */
78 uint32_t ses; /* session identifier */
81 /* input of CIOCCRYPT */
82 struct compat_crypt_op {
83 uint32_t ses; /* session identifier */
84 uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */
85 uint16_t flags; /* no usage so far, use 0 */
86 uint32_t len; /* length of source data */
87 compat_uptr_t src; /* source data */
88 compat_uptr_t dst; /* pointer to output data */
89 compat_uptr_t mac; /* pointer to output data for hash/MAC operations */
90 compat_uptr_t iv; /* initialization vector for encryption operations */
93 /* compat ioctls, defined for the above structs */
94 #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op)
95 #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op)
97 #endif /* CONFIG_COMPAT */
99 #endif /* CRYPTODEV_INT_H */