Lines Matching defs:dca

37 #include <sys/crypto/dca.h>
48 int dca_random_buffer(dca_t *dca, caddr_t buf, int len);
53 dca_rng(dca_t *dca, uchar_t *buf, size_t len, crypto_req_handle_t req)
59 if ((reqp = dca_getreq(dca, MCR2, 1)) == NULL) {
60 dca_error(dca, "unable to allocate request for RNG");
75 rv = dca_rngstart(dca, reqp);
86 dca_rngstart(dca_t *dca, dca_request_t *reqp)
93 if (dca->dca_flags & DCA_RNGSHA1) {
108 dca_sgcheck(dca, reqp->dr_out, DCA_SG_WALIGN)) {
145 return (dca_start(dca, reqp, MCR2, 1));
214 dca_random_init(dca_t *dca)
217 mutex_init(&dca->dca_random_lock, NULL, MUTEX_DRIVER, NULL);
219 if ((dca->dca_buf1 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP)) ==
221 mutex_destroy(&dca->dca_random_lock);
225 if ((dca->dca_buf2 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP)) ==
227 mutex_destroy(&dca->dca_random_lock);
228 kmem_free(dca->dca_buf1, RANDOM_BUFFER_SIZE);
236 dca_random_fini(dca_t *dca)
238 kmem_free(dca->dca_buf1, RANDOM_BUFFER_SIZE);
239 kmem_free(dca->dca_buf2, RANDOM_BUFFER_SIZE);
240 dca->dca_buf1 = dca->dca_buf2 = dca->dca_buf_ptr = NULL;
241 (void) mutex_destroy(&dca->dca_random_lock);
245 dca_random_buffer(dca_t *dca, caddr_t buf, int len)
251 mutex_enter(&dca->dca_random_lock);
253 if (dca->dca_buf_ptr == NULL) {
254 if (dca->dca_buf1 == NULL || dca->dca_buf2 == NULL) {
255 mutex_exit(&dca->dca_random_lock);
260 if (dca_rng(dca, (uchar_t *)dca->dca_buf1, RANDOM_BUFFER_SIZE,
262 mutex_exit(&dca->dca_random_lock);
266 atomic_or_32(&dca->dca_random_filling, 0x1);
269 dca->dca_buf_ptr = dca->dca_buf2;
270 dca->dca_index = RANDOM_BUFFER_SIZE;
275 if (dca->dca_index >= RANDOM_BUFFER_SIZE) {
277 while (dca->dca_random_filling) {
285 mutex_exit(&dca->dca_random_lock);
290 if (dca->dca_buf_ptr == dca->dca_buf1) {
291 dca->dca_buf_ptr = dca->dca_buf2;
292 fill_buf = dca->dca_buf1;
294 dca->dca_buf_ptr = dca->dca_buf1;
295 fill_buf = dca->dca_buf2;
298 atomic_or_32(&dca->dca_random_filling, 0x1);
299 dca->dca_index = 0;
301 if ((rv = dca_rng(dca, (uchar_t *)fill_buf,
303 mutex_exit(&dca->dca_random_lock);
308 if (dca->dca_buf_ptr[dca->dca_index] != '\0')
309 buf[i++] = dca->dca_buf_ptr[dca->dca_index];
311 dca->dca_index++;
314 mutex_exit(&dca->dca_random_lock);
321 dca_random_done(dca_t *dca)
324 atomic_and_32(&dca->dca_random_filling, 0x0);