compat: use compat_ptr() and ptr_to_compat()
[cryptodev-linux.git] / cryptodev.h
blob572b3c30dc76c82e44e0b1857082e91ac889873a
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 #ifndef __KERNEL__
9 #include <inttypes.h>
10 #endif
12 /* API extensions for linux */
13 #define CRYPTO_HMAC_MAX_KEY_LEN 512
14 #define CRYPTO_CIPHER_MAX_KEY_LEN 64
16 /* All the supported algorithms
18 typedef enum {
19 CRYPTO_DES_CBC=1,
20 CRYPTO_3DES_CBC=2,
21 CRYPTO_BLF_CBC=3,
22 CRYPTO_CAST_CBC=4,
23 CRYPTO_SKIPJACK_CBC=5,
24 CRYPTO_MD5_HMAC=6,
25 CRYPTO_SHA1_HMAC=7,
26 CRYPTO_RIPEMD160_HMAC=8,
27 CRYPTO_MD5_KPDK=9,
28 CRYPTO_SHA1_KPDK=10,
29 CRYPTO_RIJNDAEL128_CBC=11,
30 CRYPTO_AES_CBC=CRYPTO_RIJNDAEL128_CBC,
31 CRYPTO_ARC4=12,
32 CRYPTO_MD5=13,
33 CRYPTO_SHA1=14,
34 CRYPTO_DEFLATE_COMP=15,
35 CRYPTO_NULL=16,
36 CRYPTO_LZS_COMP=17,
37 CRYPTO_SHA2_256_HMAC=18,
38 CRYPTO_SHA2_384_HMAC=19,
39 CRYPTO_SHA2_512_HMAC=20,
40 CRYPTO_AES_CTR=21,
41 CRYPTO_AES_XTS=22,
43 CRYPTO_CAMELLIA_CBC=101,
44 CRYPTO_RIPEMD160,
45 CRYPTO_SHA2_256,
46 CRYPTO_SHA2_384,
47 CRYPTO_SHA2_512,
48 CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
49 } cryptodev_crypto_op_t;
50 #define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1)
52 /* Values for ciphers */
53 #define DES_BLOCK_LEN 8
54 #define DES3_BLOCK_LEN 8
55 #define RIJNDAEL128_BLOCK_LEN 16
56 #define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
57 #define CAMELLIA_BLOCK_LEN
58 #define BLOWFISH_BLOCK_LEN 8
59 #define SKIPJACK_BLOCK_LEN 8
60 #define CAST128_BLOCK_LEN 8
62 /* the maximum of the above */
63 #define EALG_MAX_BLOCK_LEN 16
65 /* Values for hashes/MAC */
66 #define AALG_MAX_RESULT_LEN 64
68 /* input of CIOCGSESSION */
69 struct session_op {
70 /* Specify either cipher or mac
72 uint32_t cipher; /* cryptodev_crypto_op_t */
73 uint32_t mac; /* cryptodev_crypto_op_t */
75 uint32_t keylen;
76 uint8_t * key;
77 uint32_t mackeylen;
78 uint8_t * mackey;
80 uint32_t ses; /* session identifier */
83 #define COP_ENCRYPT 0
84 #define COP_DECRYPT 1
86 /* input of CIOCCRYPT */
87 struct crypt_op {
88 uint32_t ses; /* session identifier */
89 uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */
90 uint16_t flags; /* no usage so far, use 0 */
91 uint32_t len; /* length of source data */
92 uint8_t * src; /* source data */
93 uint8_t * dst; /* pointer to output data */
94 uint8_t * mac; /* pointer to output data for hash/MAC operations */
95 uint8_t * iv; /* initialization vector for encryption operations */
98 /* Stuff for bignum arithmetic and public key
99 * cryptography - not supported yet by linux
100 * cryptodev.
103 #define CRYPTO_ALG_FLAG_SUPPORTED 1
104 #define CRYPTO_ALG_FLAG_RNG_ENABLE 2
105 #define CRYPTO_ALG_FLAG_DSA_SHA 4
107 struct crparam {
108 uint8_t* crp_p;
109 uint32_t crp_nbits;
112 #define CRK_MAXPARAM 8
114 /* input of CIOCKEY */
115 struct crypt_kop {
116 uint32_t crk_op; /* cryptodev_crk_ot_t */
117 uint32_t crk_status;
118 uint16_t crk_iparams;
119 uint16_t crk_oparams;
120 uint32_t crk_pad1;
121 struct crparam crk_param[CRK_MAXPARAM];
124 typedef enum {
125 CRK_MOD_EXP=0,
126 CRK_MOD_EXP_CRT=1,
127 CRK_DSA_SIGN=2,
128 CRK_DSA_VERIFY=3,
129 CRK_DH_COMPUTE_KEY=4,
130 CRK_ALGORITHM_ALL
131 } cryptodev_crk_op_t;
133 #define CRK_ALGORITHM_MAX CRK_ALGORITHM_ALL-1
135 /* features to be queried with CIOCASYMFEAT ioctl
137 #define CRF_MOD_EXP (1 << CRK_MOD_EXP)
138 #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
139 #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
140 #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
141 #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
144 /* ioctl's. Compatible with old linux cryptodev.h
146 #define CRIOGET _IOWR('c', 101, uint32_t)
147 #define CIOCGSESSION _IOWR('c', 102, struct session_op)
148 #define CIOCFSESSION _IOW('c', 103, uint32_t)
149 #define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
150 #define CIOCKEY _IOWR('c', 105, struct crypt_kop)
151 #define CIOCASYMFEAT _IOR('c', 106, uint32_t)
153 #endif /* L_CRYPTODEV_H */