3 #ifndef CRYPTODEV_INT_H
4 # define CRYPTODEV_INT_H
6 #include <linux/init.h>
7 #include <linux/sched.h>
9 #include <linux/file.h>
10 #include <linux/fdtable.h>
11 #include <linux/miscdevice.h>
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
15 #define PFX "cryptodev: "
16 #define dprintk(level,severity,format,a...) \
18 if (level <= cryptodev_verbosity) \
19 printk(severity PFX "%s[%u]: " format, \
20 current->comm, current->pid, \
24 extern int cryptodev_verbosity
;
28 int init
; /* 0 uninitialized */
32 struct crypto_ablkcipher
* s
;
33 struct cryptodev_result
*result
;
34 struct ablkcipher_request
*request
;
35 uint8_t iv
[EALG_MAX_BLOCK_LEN
];
39 int cryptodev_cipher_init(struct cipher_data
* out
, const char* alg_name
, __user
uint8_t * key
, size_t keylen
);
40 void cryptodev_cipher_deinit(struct cipher_data
* cdata
);
41 ssize_t
cryptodev_cipher_decrypt( struct cipher_data
* cdata
, struct scatterlist
*sg1
, struct scatterlist
*sg2
, size_t len
);
42 ssize_t
cryptodev_cipher_encrypt( struct cipher_data
* cdata
, struct scatterlist
*sg1
, struct scatterlist
*sg2
, size_t len
);
43 void cryptodev_cipher_set_iv(struct cipher_data
* cdata
, void* iv
, size_t iv_size
);
48 int init
; /* 0 uninitialized */
51 struct crypto_ahash
*s
;
52 struct cryptodev_result
*result
;
53 struct ahash_request
*request
;
57 int cryptodev_hash_final( struct hash_data
* hdata
, void* output
);
58 ssize_t
cryptodev_hash_update( struct hash_data
* hdata
, struct scatterlist
*sg
, size_t len
);
59 int cryptodev_hash_reset( struct hash_data
* hdata
);
60 void cryptodev_hash_deinit(struct hash_data
* hdata
);
61 int cryptodev_hash_init( struct hash_data
* hdata
, const char* alg_name
, int hmac_mode
, __user
void* mackey
, size_t mackeylen
);
63 /* compatibility stuff */
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 */
74 uint32_t key
; /* pointer to key data */
76 uint32_t mackey
; /* pointer to mac key data */
78 uint32_t ses
; /* session identifier */
79 } __attribute__((packed
));
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 uint32_t src
; /* source data */
88 uint32_t dst
; /* pointer to output data */
89 uint32_t mac
; /* pointer to output data for hash/MAC operations */
90 uint32_t iv
; /* initialization vector for encryption operations */
91 } __attribute__((packed
));
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 */