From owner-svn-src-all@FreeBSD.ORG Sat Aug 28 08:30:21 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F35C51065672; Sat, 28 Aug 2010 08:30:20 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C87C38FC14; Sat, 28 Aug 2010 08:30:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7S8UK1k024160; Sat, 28 Aug 2010 08:30:20 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7S8UKK3024157; Sat, 28 Aug 2010 08:30:20 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201008280830.o7S8UKK3024157@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 28 Aug 2010 08:30:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211927 - head/sys/geom/eli X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2010 08:30:21 -0000 Author: pjd Date: Sat Aug 28 08:30:20 2010 New Revision: 211927 URL: http://svn.freebsd.org/changeset/base/211927 Log: Correct offset conversion to little endian. It was implemented in version 2, but because of a bug it was a no-op, so we were still using offsets in native byte order for the host. Do it properly this time, bump version to 4 and set the G_ELI_FLAG_NATIVE_BYTE_ORDER flag when version is under 4. MFC after: 2 weeks Modified: head/sys/geom/eli/g_eli.c head/sys/geom/eli/g_eli.h Modified: head/sys/geom/eli/g_eli.c ============================================================================== --- head/sys/geom/eli/g_eli.c Sat Aug 28 08:18:20 2010 (r211926) +++ head/sys/geom/eli/g_eli.c Sat Aug 28 08:30:20 2010 (r211927) @@ -384,11 +384,13 @@ g_eli_crypto_ivgen(struct g_eli_softc *s u_char off[8], hash[SHA256_DIGEST_LENGTH]; SHA256_CTX ctx; - if (!(sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER)) + if ((sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER) != 0) + bcopy(&offset, off, sizeof(off)); + else le64enc(off, (uint64_t)offset); /* Copy precalculated SHA256 context for IV-Key. */ bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx)); - SHA256_Update(&ctx, (uint8_t *)&offset, sizeof(offset)); + SHA256_Update(&ctx, off, sizeof(off)); SHA256_Final(hash, &ctx); bcopy(hash, iv, size); } @@ -544,7 +546,7 @@ g_eli_create(struct gctl_req *req, struc sc->sc_crypto = G_ELI_CRYPTO_SW; sc->sc_flags = md->md_flags; /* Backward compatibility. */ - if (md->md_version < 2) + if (md->md_version < 4) sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; sc->sc_ealgo = md->md_ealgo; sc->sc_nkey = nkey; Modified: head/sys/geom/eli/g_eli.h ============================================================================== --- head/sys/geom/eli/g_eli.h Sat Aug 28 08:18:20 2010 (r211926) +++ head/sys/geom/eli/g_eli.h Sat Aug 28 08:30:20 2010 (r211927) @@ -57,11 +57,11 @@ * 1 - Added data authentication support (md_aalgo field and * G_ELI_FLAG_AUTH flag). * 2 - Added G_ELI_FLAG_READONLY. - * - IV is generated from offset converted to little-endian - * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions). * 3 - Added 'configure' subcommand. + * 4 - IV is generated from offset converted to little-endian + * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions). */ -#define G_ELI_VERSION 3 +#define G_ELI_VERSION 4 /* ON DISK FLAGS. */ /* Use random, onetime keys. */ @@ -394,7 +394,7 @@ g_eli_keylen(u_int algo, u_int keylen) keylen = 0; } return (keylen); - case CRYPTO_AES_CBC: /* FALLTHROUGH */ + case CRYPTO_AES_CBC: case CRYPTO_CAMELLIA_CBC: switch (keylen) { case 0: