2 * Driver for /dev/crypto device (aka CryptoDev)
4 * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs
6 * Structures and ioctl command names were taken from
7 * OpenBSD to preserve compatibility with their API.
18 #define CRYPTODEV_MINOR MISC_DYNAMIC_MINOR
21 #define CRYPTO_FLAG_HMAC 0x0010
22 #define CRYPTO_FLAG_MASK 0x00FF
29 CRYPTO_RIJNDAEL128_CBC
=CRYPTO_AES_CBC
,
31 /* unsupported from here */
44 CRYPTO_RIPEMD160_HMAC
,
52 #define CRYPTO_CIPHER_MAX_KEY_LEN 64
53 #define CRYPTO_HMAC_MAX_KEY_LEN 512
55 #define HASH_MAX_LEN 64
60 /* ioctl parameter to create a session */
62 uint16_t cipher
; /* e.g. CRYPTO_DES_CBC */
63 uint16_t mac
; /* e.g. CRYPTO_MD5_HMAC */
65 size_t keylen
; /* cipher key */
66 size_t mackeylen
; /* mac key */
70 uint32_t ses
; /* session ID */
73 /* ioctl parameter to request a crypt/decrypt operation against a session */
75 uint32_t ses
; /* from session_op->ses */
78 uint32_t op
; /* ie. COP_ENCRYPT */
79 uint32_t flags
; /* unused */
87 /* clone original filedescriptor */
88 #define CRIOGET _IOWR('c', 101, uint32_t)
90 /* create crypto session */
91 #define CIOCGSESSION _IOWR('c', 102, struct session_op)
93 /* finish crypto session */
94 #define CIOCFSESSION _IOW('c', 103, uint32_t)
96 /* request encryption/decryptions of a given buffer */
97 #define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
99 /* ioctl()s for asym-crypto. Not yet supported. */
100 #define CIOCKEY _IOWR('c', 105, void *)
101 #define CIOCASYMFEAT _IOR('c', 106, uint32_t)
103 #endif /* _CRYPTODEV_H */
105 /* unused structures */
111 #define CRK_MAXPARAM 8
114 uint32_t crk_op
; /* ie. CRK_MOD_EXP or other */
115 uint32_t crk_status
; /* return status */
116 uint16_t crk_iparams
; /* # of input parameters */
117 uint16_t crk_oparams
; /* # of output parameters */
118 uint32_t crk_crid
; /* NB: only used by CIOCKEY2 (rw) */
119 struct crparam crk_param
[CRK_MAXPARAM
];
122 /* Definitions from openbsd's cryptodev */
124 #define DES_BLOCK_LEN 8
125 #define DES3_BLOCK_LEN 8
126 #define BLOWFISH_BLOCK_LEN 8
127 #define SKIPJACK_BLOCK_LEN 8
128 #define CAST128_BLOCK_LEN 8
129 #define RIJNDAEL128_BLOCK_LEN 16
130 #define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
131 #define EALG_MAX_BLOCK_LEN AES_BLOCK_LEN /* Keep this updated */
133 #define NULL_HASH_LEN 16
134 #define MD5_HASH_LEN 16
135 #define SHA1_HASH_LEN 20
136 #define RIPEMD160_HASH_LEN 20
137 #define SHA2_256_HASH_LEN 32
138 #define SHA2_384_HASH_LEN 48
139 #define SHA2_512_HASH_LEN 64
140 #define MD5_KPDK_HASH_LEN 16
141 #define SHA1_KPDK_HASH_LEN 20
143 #define CRK_ALGORITM_MIN 0
144 #define CRK_MOD_EXP 0
145 #define CRK_MOD_EXP_CRT 1
146 #define CRK_DSA_SIGN 2
147 #define CRK_DSA_VERIFY 3
148 #define CRK_DH_COMPUTE_KEY 4
149 #define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */
151 #define CRF_MOD_EXP (1 << CRK_MOD_EXP)
152 #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
153 #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
154 #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
155 #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)