Deleted Added
full compact
cryptodev.c (158700) cryptodev.c (158703)
1/* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Theo de Raadt
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Effort sponsored in part by the Defense Advanced Research Projects
30 * Agency (DARPA) and Air Force Research Laboratory, Air Force
31 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
32 */
33
34#include <sys/cdefs.h>
1/* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Theo de Raadt
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Effort sponsored in part by the Defense Advanced Research Projects
30 * Agency (DARPA) and Air Force Research Laboratory, Air Force
31 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/opencrypto/cryptodev.c 158700 2006-05-17 18:01:51Z pjd $");
35__FBSDID("$FreeBSD: head/sys/opencrypto/cryptodev.c 158703 2006-05-17 18:24:17Z pjd $");
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/malloc.h>
40#include <sys/mbuf.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>
43#include <sys/sysctl.h>

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

185 mtx_unlock(&Giant);
186 return (EINVAL);
187 }
188
189 switch (sop->mac) {
190 case 0:
191 break;
192 case CRYPTO_MD5_HMAC:
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/malloc.h>
40#include <sys/mbuf.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>
43#include <sys/sysctl.h>

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

185 mtx_unlock(&Giant);
186 return (EINVAL);
187 }
188
189 switch (sop->mac) {
190 case 0:
191 break;
192 case CRYPTO_MD5_HMAC:
193 thash = &auth_hash_hmac_md5_96;
193 thash = &auth_hash_hmac_md5;
194 break;
195 case CRYPTO_SHA1_HMAC:
194 break;
195 case CRYPTO_SHA1_HMAC:
196 thash = &auth_hash_hmac_sha1_96;
196 thash = &auth_hash_hmac_sha1;
197 break;
197 break;
198 case CRYPTO_SHA2_HMAC:
199 if (sop->mackeylen == auth_hash_hmac_sha2_256.keysize)
200 thash = &auth_hash_hmac_sha2_256;
201 else if (sop->mackeylen == auth_hash_hmac_sha2_384.keysize)
202 thash = &auth_hash_hmac_sha2_384;
203 else if (sop->mackeylen == auth_hash_hmac_sha2_512.keysize)
204 thash = &auth_hash_hmac_sha2_512;
205 else {
206 mtx_unlock(&Giant);
207 return (EINVAL);
208 }
198 case CRYPTO_SHA2_256_HMAC:
199 thash = &auth_hash_hmac_sha2_256;
209 break;
200 break;
201 case CRYPTO_SHA2_384_HMAC:
202 thash = &auth_hash_hmac_sha2_384;
203 break;
204 case CRYPTO_SHA2_512_HMAC:
205 thash = &auth_hash_hmac_sha2_512;
206 break;
210 case CRYPTO_RIPEMD160_HMAC:
207 case CRYPTO_RIPEMD160_HMAC:
211 thash = &auth_hash_hmac_ripemd_160_96;
208 thash = &auth_hash_hmac_ripemd_160;
212 break;
213#ifdef notdef
214 case CRYPTO_MD5:
215 thash = &auth_hash_md5;
216 break;
217 case CRYPTO_SHA1:
218 thash = &auth_hash_sha1;
219 break;

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

466 goto bail;
467 }
468
469 if (cop->dst &&
470 (error = copyout(cse->uio.uio_iov[0].iov_base, cop->dst, cop->len)))
471 goto bail;
472
473 if (cop->mac &&
209 break;
210#ifdef notdef
211 case CRYPTO_MD5:
212 thash = &auth_hash_md5;
213 break;
214 case CRYPTO_SHA1:
215 thash = &auth_hash_sha1;
216 break;

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

463 goto bail;
464 }
465
466 if (cop->dst &&
467 (error = copyout(cse->uio.uio_iov[0].iov_base, cop->dst, cop->len)))
468 goto bail;
469
470 if (cop->mac &&
474 (error = copyout(crp->crp_mac, cop->mac, cse->thash->authsize)))
471 (error = copyout(crp->crp_mac, cop->mac, cse->thash->hashsize)))
475 goto bail;
476
477bail:
478 if (crp)
479 crypto_freereq(crp);
480 if (cse->uio.uio_iov[0].iov_base)
481 free(cse->uio.uio_iov[0].iov_base, M_XDATA);
482

--- 347 unchanged lines hidden ---
472 goto bail;
473
474bail:
475 if (crp)
476 crypto_freereq(crp);
477 if (cse->uio.uio_iov[0].iov_base)
478 free(cse->uio.uio_iov[0].iov_base, M_XDATA);
479

--- 347 unchanged lines hidden ---