Deleted Added
full compact
g_eli.c (206665) g_eli.c (211927)
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>
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.c 206665 2010-04-15 16:34:06Z pjd $");
28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli.c 211927 2010-08-28 08:30:20Z 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>

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

379 */
380void
381g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv,
382 size_t size)
383{
384 u_char off[8], hash[SHA256_DIGEST_LENGTH];
385 SHA256_CTX ctx;
386
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>

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

379 */
380void
381g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv,
382 size_t size)
383{
384 u_char off[8], hash[SHA256_DIGEST_LENGTH];
385 SHA256_CTX ctx;
386
387 if (!(sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER))
387 if ((sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER) != 0)
388 bcopy(&offset, off, sizeof(off));
389 else
388 le64enc(off, (uint64_t)offset);
389 /* Copy precalculated SHA256 context for IV-Key. */
390 bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx));
390 le64enc(off, (uint64_t)offset);
391 /* Copy precalculated SHA256 context for IV-Key. */
392 bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx));
391 SHA256_Update(&ctx, (uint8_t *)&offset, sizeof(offset));
393 SHA256_Update(&ctx, off, sizeof(off));
392 SHA256_Final(hash, &ctx);
393 bcopy(hash, iv, size);
394}
395
396int
397g_eli_read_metadata(struct g_class *mp, struct g_provider *pp,
398 struct g_eli_metadata *md)
399{

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

539 if (md->md_flags & (G_ELI_FLAG_WO_DETACH | G_ELI_FLAG_RO))
540 gp->access = g_eli_access;
541 else
542 gp->access = g_std_access;
543
544 sc->sc_crypto = G_ELI_CRYPTO_SW;
545 sc->sc_flags = md->md_flags;
546 /* Backward compatibility. */
394 SHA256_Final(hash, &ctx);
395 bcopy(hash, iv, size);
396}
397
398int
399g_eli_read_metadata(struct g_class *mp, struct g_provider *pp,
400 struct g_eli_metadata *md)
401{

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

541 if (md->md_flags & (G_ELI_FLAG_WO_DETACH | G_ELI_FLAG_RO))
542 gp->access = g_eli_access;
543 else
544 gp->access = g_std_access;
545
546 sc->sc_crypto = G_ELI_CRYPTO_SW;
547 sc->sc_flags = md->md_flags;
548 /* Backward compatibility. */
547 if (md->md_version < 2)
549 if (md->md_version < 4)
548 sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER;
549 sc->sc_ealgo = md->md_ealgo;
550 sc->sc_nkey = nkey;
551 /*
552 * Remember the keys in our softc structure.
553 */
554 g_eli_mkey_propagate(sc, mkey);
555 sc->sc_ekeylen = md->md_keylen;

--- 577 unchanged lines hidden ---
550 sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER;
551 sc->sc_ealgo = md->md_ealgo;
552 sc->sc_nkey = nkey;
553 /*
554 * Remember the keys in our softc structure.
555 */
556 g_eli_mkey_propagate(sc, mkey);
557 sc->sc_ekeylen = md->md_keylen;

--- 577 unchanged lines hidden ---