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 */
8 #include <linux/types.h>
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
{
24 CRYPTO_SKIPJACK_CBC
= 5,
27 CRYPTO_RIPEMD160_HMAC
= 8,
29 CRYPTO_SHA1_KPDK
= 10,
30 CRYPTO_RIJNDAEL128_CBC
= 11,
31 CRYPTO_AES_CBC
= CRYPTO_RIJNDAEL128_CBC
,
35 CRYPTO_DEFLATE_COMP
= 15,
38 CRYPTO_SHA2_256_HMAC
= 18,
39 CRYPTO_SHA2_384_HMAC
= 19,
40 CRYPTO_SHA2_512_HMAC
= 20,
45 CRYPTO_CAMELLIA_CBC
= 101,
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 */
76 /* Specify either cipher or mac
78 __u32 cipher
; /* cryptodev_crypto_op_t */
79 __u32 mac
; /* cryptodev_crypto_op_t */
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 */
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 */
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 */
114 /* initialization vector for encryption operations */
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
129 #define CRYPTO_ALG_FLAG_SUPPORTED 1
130 #define CRYPTO_ALG_FLAG_RNG_ENABLE 2
131 #define CRYPTO_ALG_FLAG_DSA_SHA 4
138 #define CRK_MAXPARAM 8
140 /* input of CIOCKEY */
142 __u32 crk_op
; /* cryptodev_crk_ot_t */
147 struct crparam crk_param
[CRK_MAXPARAM
];
150 enum cryptodev_crk_op_t
{
155 CRK_DH_COMPUTE_KEY
= 4,
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 */