122 /* Dynamic Reconfiguration related declarations */
123 kphysm_setup_vector_t rnd_dr_callback_vec = {
124 KPHYSM_SETUP_VECTOR_VERSION,
125 rnd_dr_callback_post_add,
126 rnd_dr_callback_pre_del,
127 rnd_dr_callback_post_del
128 };
129
130 extern struct mod_ops mod_cryptoops;
131
132 /*
133 * Module linkage information for the kernel.
134 */
135 static struct modlcrypto modlcrypto = {
136 &mod_cryptoops,
137 "Kernel Random number Provider"
138 };
139
140 static struct modlinkage modlinkage = {
141 MODREV_1,
142 (void *)&modlcrypto,
143 NULL
144 };
145
146 /*
147 * CSPI information (entry points, provider info, etc.)
148 */
149 static void swrand_provider_status(crypto_provider_handle_t, uint_t *);
150
151 static crypto_control_ops_t swrand_control_ops = {
152 swrand_provider_status
153 };
154
155 static int swrand_seed_random(crypto_provider_handle_t, crypto_session_id_t,
156 uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t);
157 static int swrand_generate_random(crypto_provider_handle_t,
158 crypto_session_id_t, uchar_t *, size_t, crypto_req_handle_t);
159
160 static crypto_random_number_ops_t swrand_random_number_ops = {
161 swrand_seed_random,
162 swrand_generate_random
163 };
164
165 static crypto_ops_t swrand_crypto_ops = {
166 &swrand_control_ops,
167 NULL,
168 NULL,
169 NULL,
170 NULL,
171 NULL,
172 NULL,
173 NULL,
174 &swrand_random_number_ops,
175 NULL,
176 NULL,
177 NULL,
178 NULL,
179 NULL,
180 NULL,
181 NULL,
182 NULL,
183 };
184
185 static crypto_provider_info_t swrand_prov_info = {
186 CRYPTO_SPI_VERSION_4,
187 "Kernel Random Number Provider",
188 CRYPTO_SW_PROVIDER,
189 {&modlinkage},
190 NULL,
191 &swrand_crypto_ops,
192 0,
193 NULL
194 };
195
196 int
197 _init(void)
198 {
199 int ret;
200 hrtime_t ts;
201 time_t now;
202
203 mutex_init(&srndpool_lock, NULL, MUTEX_DEFAULT, NULL);
204 mutex_init(&buffer_lock, NULL, MUTEX_DEFAULT, NULL);
205 cv_init(&srndpool_read_cv, NULL, CV_DEFAULT, NULL);
206 entropy_bits = 0;
207 pindex = 0;
208 bindex = 0;
209 bstart = 0;
210 snum_waiters = 0;
211 leftover_bytes = 0;
212 buffer_bytes = 0;
213
214 /*
|
122 /* Dynamic Reconfiguration related declarations */
123 kphysm_setup_vector_t rnd_dr_callback_vec = {
124 KPHYSM_SETUP_VECTOR_VERSION,
125 rnd_dr_callback_post_add,
126 rnd_dr_callback_pre_del,
127 rnd_dr_callback_post_del
128 };
129
130 extern struct mod_ops mod_cryptoops;
131
132 /*
133 * Module linkage information for the kernel.
134 */
135 static struct modlcrypto modlcrypto = {
136 &mod_cryptoops,
137 "Kernel Random number Provider"
138 };
139
140 static struct modlinkage modlinkage = {
141 MODREV_1,
142 { (void *)&modlcrypto,
143 NULL }
144 };
145
146 /*
147 * CSPI information (entry points, provider info, etc.)
148 */
149 static void swrand_provider_status(crypto_provider_handle_t, uint_t *);
150
151 static crypto_control_ops_t swrand_control_ops = {
152 swrand_provider_status
153 };
154
155 static int swrand_seed_random(crypto_provider_handle_t, crypto_session_id_t,
156 uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t);
157 static int swrand_generate_random(crypto_provider_handle_t,
158 crypto_session_id_t, uchar_t *, size_t, crypto_req_handle_t);
159
160 static crypto_random_number_ops_t swrand_random_number_ops = {
161 swrand_seed_random,
162 swrand_generate_random
163 };
164
165 static crypto_ops_t swrand_crypto_ops = {
166 .co_control_ops = &swrand_control_ops,
167 .co_random_ops = &swrand_random_number_ops
168 };
169
170 static crypto_provider_info_t swrand_prov_info = {{{{
171 CRYPTO_SPI_VERSION_4,
172 "Kernel Random Number Provider",
173 CRYPTO_SW_PROVIDER,
174 {&modlinkage},
175 NULL,
176 &swrand_crypto_ops,
177 0,
178 NULL
179 }}}};
180
181 int
182 _init(void)
183 {
184 int ret;
185 hrtime_t ts;
186 time_t now;
187
188 mutex_init(&srndpool_lock, NULL, MUTEX_DEFAULT, NULL);
189 mutex_init(&buffer_lock, NULL, MUTEX_DEFAULT, NULL);
190 cv_init(&srndpool_read_cv, NULL, CV_DEFAULT, NULL);
191 entropy_bits = 0;
192 pindex = 0;
193 bindex = 0;
194 bstart = 0;
195 snum_waiters = 0;
196 leftover_bytes = 0;
197 buffer_bytes = 0;
198
199 /*
|