72
73 extern int _des_crypt(char *buf, size_t len, struct desparams *desp);
74
75 extern struct mod_ops mod_cryptoops;
76
77 /*
78 * Module linkage information for the kernel.
79 */
80 static struct modlmisc modlmisc = {
81 &mod_miscops,
82 "des encryption",
83 };
84
85 static struct modlcrypto modlcrypto = {
86 &mod_cryptoops,
87 "DES Kernel SW Provider"
88 };
89
90 static struct modlinkage modlinkage = {
91 MODREV_1,
92 &modlmisc,
93 &modlcrypto,
94 NULL
95 };
96
97 #define DES_MIN_KEY_LEN DES_MINBYTES
98 #define DES_MAX_KEY_LEN DES_MAXBYTES
99 #define DES3_MIN_KEY_LEN DES3_MAXBYTES /* no CKK_DES2 support */
100 #define DES3_MAX_KEY_LEN DES3_MAXBYTES
101
102 #ifndef DES_MIN_KEY_LEN
103 #define DES_MIN_KEY_LEN 0
104 #endif
105
106 #ifndef DES_MAX_KEY_LEN
107 #define DES_MAX_KEY_LEN 0
108 #endif
109
110 #ifndef DES3_MIN_KEY_LEN
111 #define DES3_MIN_KEY_LEN 0
112 #endif
113
114 #ifndef DES3_MAX_KEY_LEN
198 static int des_free_context(crypto_ctx_t *);
199
200 static crypto_ctx_ops_t des_ctx_ops = {
201 des_create_ctx_template,
202 des_free_context
203 };
204
205 static int des_key_check(crypto_provider_handle_t, crypto_mechanism_t *,
206 crypto_key_t *);
207
208 static crypto_key_ops_t des_key_ops = {
209 NULL,
210 NULL,
211 NULL,
212 NULL,
213 NULL,
214 des_key_check
215 };
216
217 static crypto_ops_t des_crypto_ops = {
218 &des_control_ops,
219 NULL,
220 &des_cipher_ops,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 NULL,
226 NULL,
227 NULL,
228 NULL,
229 &des_key_ops,
230 NULL,
231 &des_ctx_ops,
232 NULL,
233 NULL,
234 NULL
235 };
236
237 static crypto_provider_info_t des_prov_info = {
238 CRYPTO_SPI_VERSION_4,
239 "DES Software Provider",
240 CRYPTO_SW_PROVIDER,
241 {&modlinkage},
242 NULL,
243 &des_crypto_ops,
244 sizeof (des_mech_info_tab)/sizeof (crypto_mech_info_t),
245 des_mech_info_tab
246 };
247
248 static crypto_kcf_provider_handle_t des_prov_handle = NULL;
249
250 int
251 _init(void)
252 {
253 int ret;
254
255 if ((ret = mod_install(&modlinkage)) != 0)
256 return (ret);
257
258 /*
259 * Register with KCF. If the registration fails, kcf will log an
260 * error but do not uninstall the module, since the functionality
261 * provided by misc/des should still be available.
262 *
263 */
264 (void) crypto_register_provider(&des_prov_info, &des_prov_handle);
265
266 return (0);
|
72
73 extern int _des_crypt(char *buf, size_t len, struct desparams *desp);
74
75 extern struct mod_ops mod_cryptoops;
76
77 /*
78 * Module linkage information for the kernel.
79 */
80 static struct modlmisc modlmisc = {
81 &mod_miscops,
82 "des encryption",
83 };
84
85 static struct modlcrypto modlcrypto = {
86 &mod_cryptoops,
87 "DES Kernel SW Provider"
88 };
89
90 static struct modlinkage modlinkage = {
91 MODREV_1,
92 { &modlmisc,
93 &modlcrypto,
94 NULL
95 }
96 };
97
98 #define DES_MIN_KEY_LEN DES_MINBYTES
99 #define DES_MAX_KEY_LEN DES_MAXBYTES
100 #define DES3_MIN_KEY_LEN DES3_MAXBYTES /* no CKK_DES2 support */
101 #define DES3_MAX_KEY_LEN DES3_MAXBYTES
102
103 #ifndef DES_MIN_KEY_LEN
104 #define DES_MIN_KEY_LEN 0
105 #endif
106
107 #ifndef DES_MAX_KEY_LEN
108 #define DES_MAX_KEY_LEN 0
109 #endif
110
111 #ifndef DES3_MIN_KEY_LEN
112 #define DES3_MIN_KEY_LEN 0
113 #endif
114
115 #ifndef DES3_MAX_KEY_LEN
199 static int des_free_context(crypto_ctx_t *);
200
201 static crypto_ctx_ops_t des_ctx_ops = {
202 des_create_ctx_template,
203 des_free_context
204 };
205
206 static int des_key_check(crypto_provider_handle_t, crypto_mechanism_t *,
207 crypto_key_t *);
208
209 static crypto_key_ops_t des_key_ops = {
210 NULL,
211 NULL,
212 NULL,
213 NULL,
214 NULL,
215 des_key_check
216 };
217
218 static crypto_ops_t des_crypto_ops = {
219 .co_control_ops = &des_control_ops,
220 .co_cipher_ops = &des_cipher_ops,
221 .co_key_ops = &des_key_ops,
222 .co_ctx_ops = &des_ctx_ops
223 };
224
225 static crypto_provider_info_t des_prov_info = {{{{
226 CRYPTO_SPI_VERSION_4,
227 "DES Software Provider",
228 CRYPTO_SW_PROVIDER,
229 {&modlinkage},
230 NULL,
231 &des_crypto_ops,
232 sizeof (des_mech_info_tab)/sizeof (crypto_mech_info_t),
233 des_mech_info_tab
234 }}}};
235
236 static crypto_kcf_provider_handle_t des_prov_handle = NULL;
237
238 int
239 _init(void)
240 {
241 int ret;
242
243 if ((ret = mod_install(&modlinkage)) != 0)
244 return (ret);
245
246 /*
247 * Register with KCF. If the registration fails, kcf will log an
248 * error but do not uninstall the module, since the functionality
249 * provided by misc/des should still be available.
250 *
251 */
252 (void) crypto_register_provider(&des_prov_info, &des_prov_handle);
253
254 return (0);
|