Made speed SI system configurable.
[cryptodev-linux.git] / cryptodev.h
blobd7343ba8806259d64f27a674317a0394287ffd3e
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,
43 CRYPTO_AES_ECB = 23,
45 CRYPTO_CAMELLIA_CBC = 101,
46 CRYPTO_RIPEMD160,
47 CRYPTO_SHA2_256,
48 CRYPTO_SHA2_384,
49 CRYPTO_SHA2_512,
50 CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
53 #define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1)
55 /* Values for ciphers */
56 #define DES_BLOCK_LEN 8
57 #define DES3_BLOCK_LEN 8
58 #define RIJNDAEL128_BLOCK_LEN 16
59 #define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
60 #define CAMELLIA_BLOCK_LEN
61 #define BLOWFISH_BLOCK_LEN 8
62 #define SKIPJACK_BLOCK_LEN 8
63 #define CAST128_BLOCK_LEN 8
65 /* the maximum of the above */
66 #define EALG_MAX_BLOCK_LEN 16
68 /* Values for hashes/MAC */
69 #define AALG_MAX_RESULT_LEN 64
71 /* maximum length of verbose alg names (depends on CRYPTO_MAX_ALG_NAME) */
72 #define CRYPTODEV_MAX_ALG_NAME 64
74 /* input of CIOCGSESSION */
75 struct session_op {
76 /* Specify either cipher or mac
78 __u32 cipher; /* cryptodev_crypto_op_t */
79 __u32 mac; /* cryptodev_crypto_op_t */
81 __u32 keylen;
82 __u8 __user *key;
83 __u32 mackeylen;
84 __u8 __user *mackey;
86 __u32 ses; /* session identifier */
88 __u16 alignmask; /* alignment constraints */
91 struct session_info_op {
92 __u32 ses; /* session identifier */
94 /* verbose names for the requested ciphers */
95 struct alg_info {
96 char cra_name[CRYPTODEV_MAX_ALG_NAME];
97 char cra_driver_name[CRYPTODEV_MAX_ALG_NAME];
98 } cipher_info, hash_info;
101 #define COP_ENCRYPT 0
102 #define COP_DECRYPT 1
104 /* input of CIOCCRYPT */
105 struct crypt_op {
106 __u32 ses; /* session identifier */
107 __u16 op; /* COP_ENCRYPT or COP_DECRYPT */
108 __u16 flags; /* no usage so far, use 0 */
109 __u32 len; /* length of source data */
110 __u8 __user *src; /* source data */
111 __u8 __user *dst; /* pointer to output data */
112 /* pointer to output data for hash/MAC operations */
113 __u8 __user *mac;
114 /* initialization vector for encryption operations */
115 __u8 __user *iv;
118 /* struct crypt_op flags */
120 #define COP_FLAG_NONE (0 << 0) /* totally no flag */
121 #define COP_FLAG_UPDATE (1 << 0) /* multi-update hash mode */
122 #define COP_FLAG_FINAL (1 << 1) /* multi-update final hash mode */
124 /* Stuff for bignum arithmetic and public key
125 * cryptography - not supported yet by linux
126 * cryptodev.
129 #define CRYPTO_ALG_FLAG_SUPPORTED 1
130 #define CRYPTO_ALG_FLAG_RNG_ENABLE 2
131 #define CRYPTO_ALG_FLAG_DSA_SHA 4
133 struct crparam {
134 __u8 *crp_p;
135 __u32 crp_nbits;
138 #define CRK_MAXPARAM 8
140 /* input of CIOCKEY */
141 struct crypt_kop {
142 __u32 crk_op; /* cryptodev_crk_ot_t */
143 __u32 crk_status;
144 __u16 crk_iparams;
145 __u16 crk_oparams;
146 __u32 crk_pad1;
147 struct crparam crk_param[CRK_MAXPARAM];
150 enum cryptodev_crk_op_t {
151 CRK_MOD_EXP = 0,
152 CRK_MOD_EXP_CRT = 1,
153 CRK_DSA_SIGN = 2,
154 CRK_DSA_VERIFY = 3,
155 CRK_DH_COMPUTE_KEY = 4,
156 CRK_ALGORITHM_ALL
159 #define CRK_ALGORITHM_MAX (CRK_ALGORITHM_ALL-1)
161 /* features to be queried with CIOCASYMFEAT ioctl
163 #define CRF_MOD_EXP (1 << CRK_MOD_EXP)
164 #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
165 #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
166 #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
167 #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
170 /* ioctl's. Compatible with old linux cryptodev.h
172 #define CRIOGET _IOWR('c', 101, __u32)
173 #define CIOCGSESSION _IOWR('c', 102, struct session_op)
174 #define CIOCFSESSION _IOW('c', 103, __u32)
175 #define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
176 #define CIOCKEY _IOWR('c', 105, struct crypt_kop)
177 #define CIOCASYMFEAT _IOR('c', 106, __u32)
178 #define CIOCGSESSINFO _IOWR('c', 107, struct session_info_op)
180 /* to indicate that CRIOGET is not required in linux
182 #define CRIOGET_NOT_NEEDED 1
184 /* additional ioctls for asynchronous operation */
185 #define CIOCASYNCCRYPT _IOW('c', 107, struct crypt_op)
186 #define CIOCASYNCFETCH _IOR('c', 108, struct crypt_op)
188 #endif /* L_CRYPTODEV_H */