removed ZCOPY flag. It was not used.
[cryptodev-linux.git] / cryptodev.h
blob7c254314830acf28ac5b41d07dc1b98ffdcb05c1
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; /* operational switches, use 0 in doubt */
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 /* struct crypt_op flags */
100 #define COP_FLAG_NONE (0 << 0) /* totally no flag */
102 /* Stuff for bignum arithmetic and public key
103 * cryptography - not supported yet by linux
104 * cryptodev.
107 #define CRYPTO_ALG_FLAG_SUPPORTED 1
108 #define CRYPTO_ALG_FLAG_RNG_ENABLE 2
109 #define CRYPTO_ALG_FLAG_DSA_SHA 4
111 struct crparam {
112 uint8_t* crp_p;
113 uint32_t crp_nbits;
116 #define CRK_MAXPARAM 8
118 /* input of CIOCKEY */
119 struct crypt_kop {
120 uint32_t crk_op; /* cryptodev_crk_ot_t */
121 uint32_t crk_status;
122 uint16_t crk_iparams;
123 uint16_t crk_oparams;
124 uint32_t crk_pad1;
125 struct crparam crk_param[CRK_MAXPARAM];
128 typedef enum {
129 CRK_MOD_EXP=0,
130 CRK_MOD_EXP_CRT=1,
131 CRK_DSA_SIGN=2,
132 CRK_DSA_VERIFY=3,
133 CRK_DH_COMPUTE_KEY=4,
134 CRK_ALGORITHM_ALL
135 } cryptodev_crk_op_t;
137 #define CRK_ALGORITHM_MAX CRK_ALGORITHM_ALL-1
139 /* features to be queried with CIOCASYMFEAT ioctl
141 #define CRF_MOD_EXP (1 << CRK_MOD_EXP)
142 #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
143 #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
144 #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
145 #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
148 /* ioctl's. Compatible with old linux cryptodev.h
150 #define CRIOGET _IOWR('c', 101, uint32_t)
151 #define CIOCGSESSION _IOWR('c', 102, struct session_op)
152 #define CIOCFSESSION _IOW('c', 103, uint32_t)
153 #define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
154 #define CIOCKEY _IOWR('c', 105, struct crypt_kop)
155 #define CIOCASYMFEAT _IOR('c', 106, uint32_t)
157 #endif /* L_CRYPTODEV_H */