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>
16 #define PFX "cryptodev: "
17 #define dprintk(level,severity,format,a...) \
19 if (level <= cryptodev_verbosity) \
20 printk(severity PFX "%s[%u]: " format, \
21 current->comm, current->pid, \
25 extern int cryptodev_verbosity
;
29 int init
; /* 0 uninitialized */
33 struct crypto_ablkcipher
* s
;
34 struct cryptodev_result
*result
;
35 struct ablkcipher_request
*request
;
36 uint8_t iv
[EALG_MAX_BLOCK_LEN
];
40 int cryptodev_cipher_init(struct cipher_data
* out
, const char* alg_name
, __user
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 int cryptodev_cipher_set_iv(struct cipher_data
* cdata
, void* iv
, size_t iv_size
);
49 int init
; /* 0 uninitialized */
52 struct crypto_ahash
*s
;
53 struct cryptodev_result
*result
;
54 struct ahash_request
*request
;
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
, __user
void* mackey
, size_t mackeylen
);
64 /* compatibility stuff */
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 */
76 compat_uptr_t key
; /* pointer to key data */
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 */