1/*-
2 * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli_privacy.c 213070 2010-09-23 11:58:36Z pjd $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/linker.h>
34#include <sys/module.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
--- 217 unchanged lines hidden (view full) ---
254 crd->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT;
255 if (sc->sc_nekeys > 1)
256 crd->crd_flags |= CRD_F_KEY_EXPLICIT;
257 if (bp->bio_cmd == BIO_WRITE)
258 crd->crd_flags |= CRD_F_ENCRYPT;
259 crd->crd_alg = sc->sc_ealgo;
260 crd->crd_key = g_eli_crypto_key(sc, dstoff, secsize);
261 crd->crd_klen = sc->sc_ekeylen;
262 if (sc->sc_ealgo == CRYPTO_AES_XTS)
263 crd->crd_klen <<= 1;
264 g_eli_crypto_ivgen(sc, dstoff, crd->crd_iv,
265 sizeof(crd->crd_iv));
266 crd->crd_next = NULL;
267
268 crp->crp_etype = 0;
269 err = crypto_dispatch(crp);
270 if (error == 0)
271 error = err;
272 }
273 if (bp->bio_error == 0)
274 bp->bio_error = error;
275}
2 * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli_privacy.c 213070 2010-09-23 11:58:36Z pjd $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/linker.h>
34#include <sys/module.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
--- 217 unchanged lines hidden (view full) ---
254 crd->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT;
255 if (sc->sc_nekeys > 1)
256 crd->crd_flags |= CRD_F_KEY_EXPLICIT;
257 if (bp->bio_cmd == BIO_WRITE)
258 crd->crd_flags |= CRD_F_ENCRYPT;
259 crd->crd_alg = sc->sc_ealgo;
260 crd->crd_key = g_eli_crypto_key(sc, dstoff, secsize);
261 crd->crd_klen = sc->sc_ekeylen;
262 if (sc->sc_ealgo == CRYPTO_AES_XTS)
263 crd->crd_klen <<= 1;
264 g_eli_crypto_ivgen(sc, dstoff, crd->crd_iv,
265 sizeof(crd->crd_iv));
266 crd->crd_next = NULL;
267
268 crp->crp_etype = 0;
269 err = crypto_dispatch(crp);
270 if (error == 0)
271 error = err;
272 }
273 if (bp->bio_error == 0)
274 bp->bio_error = error;
275}