g_eli.c (214163) | g_eli.c (214225) |
---|---|
1/*- 2 * Copyright (c) 2005-2010 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> | 1/*- 2 * Copyright (c) 2005-2010 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.c 214163 2010-10-21 19:44:28Z pjd $"); | 28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli.c 214225 2010-10-22 22:13:11Z 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> --- 775 unchanged lines hidden (view full) --- 812 sc->sc_mediasize *= sc->sc_sectorsize; 813 } 814 815 /* 816 * Remember the keys in our softc structure. 817 */ 818 g_eli_mkey_propagate(sc, mkey); 819 sc->sc_ekeylen = md->md_keylen; | 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> --- 775 unchanged lines hidden (view full) --- 812 sc->sc_mediasize *= sc->sc_sectorsize; 813 } 814 815 /* 816 * Remember the keys in our softc structure. 817 */ 818 g_eli_mkey_propagate(sc, mkey); 819 sc->sc_ekeylen = md->md_keylen; |
820 if (sc->sc_flags & G_ELI_FLAG_AUTH) { 821 /* 822 * Precalculate SHA256 for HMAC key generation. 823 * This is expensive operation and we can do it only once now or 824 * for every access to sector, so now will be much better. 825 */ 826 SHA256_Init(&sc->sc_akeyctx); 827 SHA256_Update(&sc->sc_akeyctx, sc->sc_akey, 828 sizeof(sc->sc_akey)); 829 } 830 /* 831 * Precalculate SHA256 for IV generation. 832 * This is expensive operation and we can do it only once now or for 833 * every access to sector, so now will be much better. 834 */ 835 switch (sc->sc_ealgo) { 836 case CRYPTO_AES_XTS: 837 break; 838 default: 839 SHA256_Init(&sc->sc_ivctx); 840 SHA256_Update(&sc->sc_ivctx, sc->sc_ivkey, 841 sizeof(sc->sc_ivkey)); 842 break; 843 } | |
844 845 LIST_INIT(&sc->sc_workers); 846 847 threads = g_eli_threads; 848 if (threads == 0) 849 threads = mp_ncpus; 850 else if (threads > mp_ncpus) { 851 /* There is really no need for too many worker threads. */ --- 470 unchanged lines hidden --- | 820 821 LIST_INIT(&sc->sc_workers); 822 823 threads = g_eli_threads; 824 if (threads == 0) 825 threads = mp_ncpus; 826 else if (threads > mp_ncpus) { 827 /* There is really no need for too many worker threads. */ --- 470 unchanged lines hidden --- |