implement asynchronous operation mode
[cryptodev-linux.git] / cryptodev.h
blobadfc374b4c117d9a5959334b11c6cbfb11b03bc3
1 /* This is a source compatible implementation with the original API of
2 * cryptodev by Angelos D. Keromytis, found at openbsd cryptodev.h.
3 * Placed under public domain */
5 #ifndef L_CRYPTODEV_H
6 #define L_CRYPTODEV_H
8 #include <linux/types.h>
9 #ifndef __KERNEL__
10 #define __user
11 #endif
13 /* API extensions for linux */
14 #define CRYPTO_HMAC_MAX_KEY_LEN 512
15 #define CRYPTO_CIPHER_MAX_KEY_LEN 64
17 /* All the supported algorithms
19 enum cryptodev_crypto_op_t {
20 CRYPTO_DES_CBC = 1,
21 CRYPTO_3DES_CBC = 2,
22 CRYPTO_BLF_CBC = 3,
23 CRYPTO_CAST_CBC = 4,
24 CRYPTO_SKIPJACK_CBC = 5,
25 CRYPTO_MD5_HMAC = 6,
26 CRYPTO_SHA1_HMAC = 7,
27 CRYPTO_RIPEMD160_HMAC = 8,
28 CRYPTO_MD5_KPDK = 9,
29 CRYPTO_SHA1_KPDK = 10,
30 CRYPTO_RIJNDAEL128_CBC = 11,
31 CRYPTO_AES_CBC = CRYPTO_RIJNDAEL128_CBC,
32 CRYPTO_ARC4 = 12,
33 CRYPTO_MD5 = 13,
34 CRYPTO_SHA1 = 14,
35 CRYPTO_DEFLATE_COMP = 15,
36 CRYPTO_NULL = 16,
37 CRYPTO_LZS_COMP = 17,
38 CRYPTO_SHA2_256_HMAC = 18,
39 CRYPTO_SHA2_384_HMAC = 19,
40 CRYPTO_SHA2_512_HMAC = 20,
41 CRYPTO_AES_CTR = 21,
42 CRYPTO_AES_XTS = 22,
44 CRYPTO_CAMELLIA_CBC = 101,
45 CRYPTO_RIPEMD160,
46 CRYPTO_SHA2_256,
47 CRYPTO_SHA2_384,
48 CRYPTO_SHA2_512,
49 CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
52 #define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1)
54 /* Values for ciphers */
55 #define DES_BLOCK_LEN 8
56 #define DES3_BLOCK_LEN 8
57 #define RIJNDAEL128_BLOCK_LEN 16
58 #define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
59 #define CAMELLIA_BLOCK_LEN
60 #define BLOWFISH_BLOCK_LEN 8
61 #define SKIPJACK_BLOCK_LEN 8
62 #define CAST128_BLOCK_LEN 8
64 /* the maximum of the above */
65 #define EALG_MAX_BLOCK_LEN 16
67 /* Values for hashes/MAC */
68 #define AALG_MAX_RESULT_LEN 64
70 /* input of CIOCGSESSION */
71 struct session_op {
72 /* Specify either cipher or mac
74 __u32 cipher; /* cryptodev_crypto_op_t */
75 __u32 mac; /* cryptodev_crypto_op_t */
77 __u32 keylen;
78 __u8 __user *key;
79 __u32 mackeylen;
80 __u8 __user *mackey;
82 __u32 ses; /* session identifier */
85 #define COP_ENCRYPT 0
86 #define COP_DECRYPT 1
88 /* input of CIOCCRYPT */
89 struct crypt_op {
90 __u32 ses; /* session identifier */
91 __u16 op; /* COP_ENCRYPT or COP_DECRYPT */
92 __u16 flags; /* no usage so far, use 0 */
93 __u32 len; /* length of source data */
94 __u8 __user *src; /* source data */
95 __u8 __user *dst; /* pointer to output data */
96 /* pointer to output data for hash/MAC operations */
97 __u8 __user *mac;
98 /* initialization vector for encryption operations */
99 __u8 __user *iv;
102 /* struct crypt_op flags */
104 #define COP_FLAG_NONE (0 << 0) /* totally no flag */
105 #define COP_FLAG_UPDATE (1 << 0) /* multi-update hash mode */
106 #define COP_FLAG_FINAL (1 << 1) /* multi-update final hash mode */
108 /* Stuff for bignum arithmetic and public key
109 * cryptography - not supported yet by linux
110 * cryptodev.
113 #define CRYPTO_ALG_FLAG_SUPPORTED 1
114 #define CRYPTO_ALG_FLAG_RNG_ENABLE 2
115 #define CRYPTO_ALG_FLAG_DSA_SHA 4
117 struct crparam {
118 __u8 *crp_p;
119 __u32 crp_nbits;
122 #define CRK_MAXPARAM 8
124 /* input of CIOCKEY */
125 struct crypt_kop {
126 __u32 crk_op; /* cryptodev_crk_ot_t */
127 __u32 crk_status;
128 __u16 crk_iparams;
129 __u16 crk_oparams;
130 __u32 crk_pad1;
131 struct crparam crk_param[CRK_MAXPARAM];
134 enum cryptodev_crk_op_t {
135 CRK_MOD_EXP = 0,
136 CRK_MOD_EXP_CRT = 1,
137 CRK_DSA_SIGN = 2,
138 CRK_DSA_VERIFY = 3,
139 CRK_DH_COMPUTE_KEY = 4,
140 CRK_ALGORITHM_ALL
143 #define CRK_ALGORITHM_MAX (CRK_ALGORITHM_ALL-1)
145 /* features to be queried with CIOCASYMFEAT ioctl
147 #define CRF_MOD_EXP (1 << CRK_MOD_EXP)
148 #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
149 #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
150 #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
151 #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
154 /* ioctl's. Compatible with old linux cryptodev.h
156 #define CRIOGET _IOWR('c', 101, __u32)
157 #define CIOCGSESSION _IOWR('c', 102, struct session_op)
158 #define CIOCFSESSION _IOW('c', 103, __u32)
159 #define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
160 #define CIOCKEY _IOWR('c', 105, struct crypt_kop)
161 #define CIOCASYMFEAT _IOR('c', 106, __u32)
163 /* to indicate that CRIOGET is not required in linux
165 #define CRIOGET_NOT_NEEDED 1
167 /* additional ioctls for asynchronous operation */
168 #define CIOCASYNCCRYPT _IOW('c', 107, struct crypt_op)
169 #define CIOCASYNCFETCH _IOR('c', 108, struct crypt_op)
171 #endif /* L_CRYPTODEV_H */