From owner-svn-soc-all@FreeBSD.ORG Sat Sep 21 21:57:29 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 89C48D72 for ; Sat, 21 Sep 2013 21:57:29 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6733F2AA9 for ; Sat, 21 Sep 2013 21:57:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8LLvTlF032660 for ; Sat, 21 Sep 2013 21:57:29 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8LLvTRi032657 for svn-soc-all@FreeBSD.org; Sat, 21 Sep 2013 21:57:29 GMT (envelope-from def@FreeBSD.org) Date: Sat, 21 Sep 2013 21:57:29 GMT Message-Id: <201309212157.r8LLvTRi032657@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257576 - soc2013/def/crashdump-head/sys/crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Sep 2013 21:57:29 -0000 Author: def Date: Sat Sep 21 21:57:29 2013 New Revision: 257576 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257576 Log: Provide a sequential number of 128-bits block inside a data unit for xts_block_encrypt and xts_block_decrypt. Multiply tweak by alpha^j. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Sat Sep 21 21:14:05 2013 (r257575) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Sat Sep 21 21:57:29 2013 (r257576) @@ -126,24 +126,30 @@ static __inline void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, - uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) + uint64_t *tweak, uint64_t sector, const uint8_t *xtweak, int j) { + int i; + tweak[0] = htole64(sector); tweak[1] = *((const uint64_t *)xtweak); /* encrypt the tweak */ alg->pa_encrypt(tweak_ctx, (uint8_t *)tweak, (uint8_t *)tweak); + + /* multiply by alpha^j */ + for (i = 0 ; i < j ; i++) + gf_mul128(tweak, tweak); } void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + xts_start(alg, tweak_ctx, tweak, sector, xtweak, j); while (len >= XTS_BLK_BYTES) { xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); @@ -159,13 +165,13 @@ void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; uint64_t prevtweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + xts_start(alg, tweak_ctx, tweak, sector, xtweak, j); if ((len & XTS_BLK_MASK) != 0) len -= XTS_BLK_BYTES; Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Sat Sep 21 21:14:05 2013 (r257575) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Sat Sep 21 21:57:29 2013 (r257576) @@ -60,12 +60,12 @@ void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst); void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst); algop_crypt_t xts_aes_encrypt;