Date: Sat, 21 Sep 2013 21:57:29 GMT From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257576 - soc2013/def/crashdump-head/sys/crypto Message-ID: <201309212157.r8LLvTRi032657@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309212157.r8LLvTRi032657>