Deleted Added
full compact
g_eli_key.c (213072) g_eli_key.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_key.c 213072 2010-09-23 12:02:08Z pjd $");
28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli_key.c 214225 2010-10-22 22:13:11Z pjd $");
29
30#include <sys/param.h>
31#ifdef _KERNEL
32#include <sys/malloc.h>
33#include <sys/systm.h>
34#include <geom/geom.h>
35#else
36#include <stdio.h>

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

259 */
260 g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x10", 1,
261 sc->sc_ekeys[0], 0);
262 }
263 } else {
264 /* Generate all encryption keys. */
265 g_eli_ekeys_generate(sc);
266 }
29
30#include <sys/param.h>
31#ifdef _KERNEL
32#include <sys/malloc.h>
33#include <sys/systm.h>
34#include <geom/geom.h>
35#else
36#include <stdio.h>

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

259 */
260 g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x10", 1,
261 sc->sc_ekeys[0], 0);
262 }
263 } else {
264 /* Generate all encryption keys. */
265 g_eli_ekeys_generate(sc);
266 }
267
268 if (sc->sc_flags & G_ELI_FLAG_AUTH) {
269 /*
270 * Precalculate SHA256 for HMAC key generation.
271 * This is expensive operation and we can do it only once now or
272 * for every access to sector, so now will be much better.
273 */
274 SHA256_Init(&sc->sc_akeyctx);
275 SHA256_Update(&sc->sc_akeyctx, sc->sc_akey,
276 sizeof(sc->sc_akey));
277 }
278 /*
279 * Precalculate SHA256 for IV generation.
280 * This is expensive operation and we can do it only once now or for
281 * every access to sector, so now will be much better.
282 */
283 switch (sc->sc_ealgo) {
284 case CRYPTO_AES_XTS:
285 break;
286 default:
287 SHA256_Init(&sc->sc_ivctx);
288 SHA256_Update(&sc->sc_ivctx, sc->sc_ivkey,
289 sizeof(sc->sc_ivkey));
290 break;
291 }
267}
268#endif
292}
293#endif