Deleted Added
full compact
cryptodev.c (109153) cryptodev.c (109623)
1/* $FreeBSD: head/sys/opencrypto/cryptodev.c 109153 2003-01-13 00:33:17Z dillon $ */
1/* $FreeBSD: head/sys/opencrypto/cryptodev.c 109623 2003-01-21 08:56:16Z alfred $ */
2/* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */
3
4/*
5 * Copyright (c) 2001 Theo de Raadt
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 213 unchanged lines hidden (view full) ---

223 crie.cri_klen = sop->keylen * 8;
224 if (sop->keylen > txform->maxkey ||
225 sop->keylen < txform->minkey) {
226 error = EINVAL;
227 goto bail;
228 }
229
230 MALLOC(crie.cri_key, u_int8_t *,
2/* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */
3
4/*
5 * Copyright (c) 2001 Theo de Raadt
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 213 unchanged lines hidden (view full) ---

223 crie.cri_klen = sop->keylen * 8;
224 if (sop->keylen > txform->maxkey ||
225 sop->keylen < txform->minkey) {
226 error = EINVAL;
227 goto bail;
228 }
229
230 MALLOC(crie.cri_key, u_int8_t *,
231 crie.cri_klen / 8, M_XDATA, M_WAITOK);
231 crie.cri_klen / 8, M_XDATA, 0);
232 if ((error = copyin(sop->key, crie.cri_key,
233 crie.cri_klen / 8)))
234 goto bail;
235 if (thash)
236 crie.cri_next = &cria;
237 }
238
239 if (thash) {
240 cria.cri_alg = thash->type;
241 cria.cri_klen = sop->mackeylen * 8;
242 if (sop->mackeylen != thash->keysize) {
243 error = EINVAL;
244 goto bail;
245 }
246
247 if (cria.cri_klen) {
248 MALLOC(cria.cri_key, u_int8_t *,
232 if ((error = copyin(sop->key, crie.cri_key,
233 crie.cri_klen / 8)))
234 goto bail;
235 if (thash)
236 crie.cri_next = &cria;
237 }
238
239 if (thash) {
240 cria.cri_alg = thash->type;
241 cria.cri_klen = sop->mackeylen * 8;
242 if (sop->mackeylen != thash->keysize) {
243 error = EINVAL;
244 goto bail;
245 }
246
247 if (cria.cri_klen) {
248 MALLOC(cria.cri_key, u_int8_t *,
249 cria.cri_klen / 8, M_XDATA, M_WAITOK);
249 cria.cri_klen / 8, M_XDATA, 0);
250 if ((error = copyin(sop->mackey, cria.cri_key,
251 cria.cri_klen / 8)))
252 goto bail;
253 }
254 }
255
256 error = crypto_newsession(&sid, (txform ? &crie : &cria), 1);
257 if (error)

--- 69 unchanged lines hidden (view full) ---

327 cse->uio.uio_iovcnt = 1;
328 cse->uio.uio_resid = 0;
329 cse->uio.uio_segflg = UIO_SYSSPACE;
330 cse->uio.uio_rw = UIO_WRITE;
331 cse->uio.uio_td = td;
332 cse->uio.uio_iov = cse->iovec;
333 bzero(&cse->iovec, sizeof(cse->iovec));
334 cse->uio.uio_iov[0].iov_len = cop->len;
250 if ((error = copyin(sop->mackey, cria.cri_key,
251 cria.cri_klen / 8)))
252 goto bail;
253 }
254 }
255
256 error = crypto_newsession(&sid, (txform ? &crie : &cria), 1);
257 if (error)

--- 69 unchanged lines hidden (view full) ---

327 cse->uio.uio_iovcnt = 1;
328 cse->uio.uio_resid = 0;
329 cse->uio.uio_segflg = UIO_SYSSPACE;
330 cse->uio.uio_rw = UIO_WRITE;
331 cse->uio.uio_td = td;
332 cse->uio.uio_iov = cse->iovec;
333 bzero(&cse->iovec, sizeof(cse->iovec));
334 cse->uio.uio_iov[0].iov_len = cop->len;
335 cse->uio.uio_iov[0].iov_base = malloc(cop->len, M_XDATA, M_WAITOK);
335 cse->uio.uio_iov[0].iov_base = malloc(cop->len, M_XDATA, 0);
336 for (i = 0; i < cse->uio.uio_iovcnt; i++)
337 cse->uio.uio_resid += cse->uio.uio_iov[0].iov_len;
338
339 crp = crypto_getreq((cse->txform != NULL) + (cse->thash != NULL));
340 if (crp == NULL) {
341 error = ENOMEM;
342 goto bail;
343 }

--- 163 unchanged lines hidden (view full) ---

507 case CRK_DH_COMPUTE_KEY:
508 if (in == 3 && out == 1)
509 break;
510 return (EINVAL);
511 default:
512 return (EINVAL);
513 }
514
336 for (i = 0; i < cse->uio.uio_iovcnt; i++)
337 cse->uio.uio_resid += cse->uio.uio_iov[0].iov_len;
338
339 crp = crypto_getreq((cse->txform != NULL) + (cse->thash != NULL));
340 if (crp == NULL) {
341 error = ENOMEM;
342 goto bail;
343 }

--- 163 unchanged lines hidden (view full) ---

507 case CRK_DH_COMPUTE_KEY:
508 if (in == 3 && out == 1)
509 break;
510 return (EINVAL);
511 default:
512 return (EINVAL);
513 }
514
515 krp = (struct cryptkop *)malloc(sizeof *krp, M_XDATA, M_WAITOK);
515 krp = (struct cryptkop *)malloc(sizeof *krp, M_XDATA, 0);
516 if (!krp)
517 return (ENOMEM);
518 bzero(krp, sizeof *krp);
519 krp->krp_op = kop->crk_op;
520 krp->krp_status = kop->crk_status;
521 krp->krp_iparams = kop->crk_iparams;
522 krp->krp_oparams = kop->crk_oparams;
523 krp->krp_status = 0;
524 krp->krp_callback = (int (*) (struct cryptkop *)) cryptodevkey_cb;
525
526 for (i = 0; i < CRK_MAXPARAM; i++)
527 krp->krp_param[i].crp_nbits = kop->crk_param[i].crp_nbits;
528 for (i = 0; i < krp->krp_iparams + krp->krp_oparams; i++) {
529 size = (krp->krp_param[i].crp_nbits + 7) / 8;
530 if (size == 0)
531 continue;
516 if (!krp)
517 return (ENOMEM);
518 bzero(krp, sizeof *krp);
519 krp->krp_op = kop->crk_op;
520 krp->krp_status = kop->crk_status;
521 krp->krp_iparams = kop->crk_iparams;
522 krp->krp_oparams = kop->crk_oparams;
523 krp->krp_status = 0;
524 krp->krp_callback = (int (*) (struct cryptkop *)) cryptodevkey_cb;
525
526 for (i = 0; i < CRK_MAXPARAM; i++)
527 krp->krp_param[i].crp_nbits = kop->crk_param[i].crp_nbits;
528 for (i = 0; i < krp->krp_iparams + krp->krp_oparams; i++) {
529 size = (krp->krp_param[i].crp_nbits + 7) / 8;
530 if (size == 0)
531 continue;
532 MALLOC(krp->krp_param[i].crp_p, caddr_t, size, M_XDATA, M_WAITOK);
532 MALLOC(krp->krp_param[i].crp_p, caddr_t, size, M_XDATA, 0);
533 if (i >= krp->krp_iparams)
534 continue;
535 error = copyin(kop->crk_param[i].crp_p, krp->krp_param[i].crp_p, size);
536 if (error)
537 goto fail;
538 }
539
540 error = crypto_kdispatch(krp);

--- 173 unchanged lines hidden (view full) ---

714{
715 struct file *f;
716 struct fcrypt *fcr;
717 int fd, error;
718
719 switch (cmd) {
720 case CRIOGET:
721 MALLOC(fcr, struct fcrypt *,
533 if (i >= krp->krp_iparams)
534 continue;
535 error = copyin(kop->crk_param[i].crp_p, krp->krp_param[i].crp_p, size);
536 if (error)
537 goto fail;
538 }
539
540 error = crypto_kdispatch(krp);

--- 173 unchanged lines hidden (view full) ---

714{
715 struct file *f;
716 struct fcrypt *fcr;
717 int fd, error;
718
719 switch (cmd) {
720 case CRIOGET:
721 MALLOC(fcr, struct fcrypt *,
722 sizeof(struct fcrypt), M_XDATA, M_WAITOK);
722 sizeof(struct fcrypt), M_XDATA, 0);
723 TAILQ_INIT(&fcr->csessions);
724 fcr->sesn = 0;
725
726 error = falloc(td, &f, &fd);
727
728 if (error) {
729 FREE(fcr, M_XDATA);
730 return (error);

--- 65 unchanged lines hidden ---
723 TAILQ_INIT(&fcr->csessions);
724 fcr->sesn = 0;
725
726 error = falloc(td, &f, &fd);
727
728 if (error) {
729 FREE(fcr, M_XDATA);
730 return (error);

--- 65 unchanged lines hidden ---