33 #include <sys/cmn_err.h>
34 #include <sys/ddi.h>
35 #include <sys/crypto/common.h>
36 #include <sys/crypto/spi.h>
37 #include <sys/sysmacros.h>
38 #include <sys/strsun.h>
39 #include <arcfour.h>
40
41 extern struct mod_ops mod_cryptoops;
42
43 /*
44 * Module linkage information for the kernel.
45 */
46 static struct modlcrypto modlcrypto = {
47 &mod_cryptoops,
48 "RC4 Kernel SW Provider"
49 };
50
51 static struct modlinkage modlinkage = {
52 MODREV_1,
53 (void *)&modlcrypto,
54 NULL
55 };
56
57 /*
58 * CSPI information (entry points, provider info, etc.)
59 */
60
61 #define RC4_MECH_INFO_TYPE 0
62 /*
63 * Mechanism info structure passed to KCF during registration.
64 */
65 static crypto_mech_info_t rc4_mech_info_tab[] = {
66 {SUN_CKM_RC4, RC4_MECH_INFO_TYPE,
67 CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
68 CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
69 ARCFOUR_MIN_KEY_BITS, ARCFOUR_MAX_KEY_BITS,
70 CRYPTO_KEYSIZE_UNIT_IN_BITS | CRYPTO_CAN_SHARE_OPSTATE}
71 };
72
73 static void rc4_provider_status(crypto_provider_handle_t, uint_t *);
74
97 rc4_common_init,
98 rc4_crypt,
99 rc4_crypt_update,
100 rc4_crypt_final,
101 rc4_crypt_atomic,
102 rc4_common_init,
103 rc4_crypt,
104 rc4_crypt_update,
105 rc4_crypt_final,
106 rc4_crypt_atomic
107 };
108
109 static int rc4_free_context(crypto_ctx_t *);
110
111 static crypto_ctx_ops_t rc4_ctx_ops = {
112 NULL,
113 rc4_free_context
114 };
115
116 static crypto_ops_t rc4_crypto_ops = {
117 &rc4_control_ops,
118 NULL,
119 &rc4_cipher_ops,
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL,
125 NULL,
126 NULL,
127 NULL,
128 NULL,
129 NULL,
130 &rc4_ctx_ops
131 };
132
133 static crypto_provider_info_t rc4_prov_info = {
134 CRYPTO_SPI_VERSION_1,
135 "RC4 Software Provider",
136 CRYPTO_SW_PROVIDER,
137 {&modlinkage},
138 NULL,
139 &rc4_crypto_ops,
140 sizeof (rc4_mech_info_tab)/sizeof (crypto_mech_info_t),
141 rc4_mech_info_tab
142 };
143
144 static crypto_kcf_provider_handle_t rc4_prov_handle = NULL;
145
146 static mblk_t *advance_position(mblk_t *, off_t, uchar_t **);
147 static int crypto_arcfour_crypt(ARCFour_key *, uchar_t *, crypto_data_t *,
148 int);
149
150 int
151 _init(void)
152 {
153 int ret;
154
155 if ((ret = mod_install(&modlinkage)) != 0)
156 return (ret);
157
158 /* Register with KCF. If the registration fails, remove the module. */
159 if (crypto_register_provider(&rc4_prov_info, &rc4_prov_handle)) {
160 (void) mod_remove(&modlinkage);
161 return (EACCES);
162 }
|
33 #include <sys/cmn_err.h>
34 #include <sys/ddi.h>
35 #include <sys/crypto/common.h>
36 #include <sys/crypto/spi.h>
37 #include <sys/sysmacros.h>
38 #include <sys/strsun.h>
39 #include <arcfour.h>
40
41 extern struct mod_ops mod_cryptoops;
42
43 /*
44 * Module linkage information for the kernel.
45 */
46 static struct modlcrypto modlcrypto = {
47 &mod_cryptoops,
48 "RC4 Kernel SW Provider"
49 };
50
51 static struct modlinkage modlinkage = {
52 MODREV_1,
53 { (void *)&modlcrypto,
54 NULL }
55 };
56
57 /*
58 * CSPI information (entry points, provider info, etc.)
59 */
60
61 #define RC4_MECH_INFO_TYPE 0
62 /*
63 * Mechanism info structure passed to KCF during registration.
64 */
65 static crypto_mech_info_t rc4_mech_info_tab[] = {
66 {SUN_CKM_RC4, RC4_MECH_INFO_TYPE,
67 CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
68 CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
69 ARCFOUR_MIN_KEY_BITS, ARCFOUR_MAX_KEY_BITS,
70 CRYPTO_KEYSIZE_UNIT_IN_BITS | CRYPTO_CAN_SHARE_OPSTATE}
71 };
72
73 static void rc4_provider_status(crypto_provider_handle_t, uint_t *);
74
97 rc4_common_init,
98 rc4_crypt,
99 rc4_crypt_update,
100 rc4_crypt_final,
101 rc4_crypt_atomic,
102 rc4_common_init,
103 rc4_crypt,
104 rc4_crypt_update,
105 rc4_crypt_final,
106 rc4_crypt_atomic
107 };
108
109 static int rc4_free_context(crypto_ctx_t *);
110
111 static crypto_ctx_ops_t rc4_ctx_ops = {
112 NULL,
113 rc4_free_context
114 };
115
116 static crypto_ops_t rc4_crypto_ops = {
117 .co_control_ops = &rc4_control_ops,
118 .co_digest_ops = NULL,
119 .co_cipher_ops = &rc4_cipher_ops,
120 .co_mac_ops = NULL,
121 .co_sign_ops = NULL,
122 .co_verify_ops = NULL,
123 .co_dual_ops = NULL,
124 .co_dual_cipher_mac_ops = NULL,
125 .co_random_ops = NULL,
126 .co_session_ops = NULL,
127 .co_object_ops = NULL,
128 .co_key_ops = NULL,
129 .co_provider_ops = NULL,
130 .co_ctx_ops = &rc4_ctx_ops
131 };
132
133 static crypto_provider_info_t rc4_prov_info = {{{{
134 CRYPTO_SPI_VERSION_1,
135 "RC4 Software Provider",
136 CRYPTO_SW_PROVIDER,
137 {&modlinkage},
138 NULL,
139 &rc4_crypto_ops,
140 sizeof (rc4_mech_info_tab)/sizeof (crypto_mech_info_t),
141 rc4_mech_info_tab
142 }}}};
143
144 static crypto_kcf_provider_handle_t rc4_prov_handle = NULL;
145
146 static mblk_t *advance_position(mblk_t *, off_t, uchar_t **);
147 static int crypto_arcfour_crypt(ARCFour_key *, uchar_t *, crypto_data_t *,
148 int);
149
150 int
151 _init(void)
152 {
153 int ret;
154
155 if ((ret = mod_install(&modlinkage)) != 0)
156 return (ret);
157
158 /* Register with KCF. If the registration fails, remove the module. */
159 if (crypto_register_provider(&rc4_prov_info, &rc4_prov_handle)) {
160 (void) mod_remove(&modlinkage);
161 return (EACCES);
162 }
|