socsvn commit: r255438 - soc2013/def/crashdump-head/sys/crypto
def at FreeBSD.org
def at FreeBSD.org
Fri Aug 2 00:49:48 UTC 2013
Author: def
Date: Fri Aug 2 00:49:48 2013
New Revision: 255438
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255438
Log:
Add a power of tweak (alpha^j) as a parameter in xts_block_encrypt and xts_block_decrypt.
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 Fri Aug 2 00:31:24 2013 (r255437)
+++ soc2013/def/crashdump-head/sys/crypto/xts.c Fri Aug 2 00:49:48 2013 (r255438)
@@ -97,40 +97,46 @@
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,
- const uint8_t *src, uint8_t *dst)
+ uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_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);
+ if (alpha_j == NULL) {
+ xts_start(alg, tweak_ctx, tweak, sector, xtweak);
+ alpha_j = tweak;
+ }
while (len >= XTS_BLK_BYTES) {
- xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst);
+ xts_fullblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst);
dst += XTS_BLK_BYTES;
src += XTS_BLK_BYTES;
len -= XTS_BLK_BYTES;
}
if (len != 0)
- xts_lastblock(alg->pa_encrypt, data_ctx, tweak, src, dst, len);
+ xts_lastblock(alg->pa_encrypt, data_ctx, alpha_j, src, dst, len);
}
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,
- const uint8_t *src, uint8_t *dst)
+ uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_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);
+ if (alpha_j == NULL) {
+ xts_start(alg, tweak_ctx, tweak, sector, xtweak);
+ alpha_j = tweak;
+ }
if ((len & XTS_BLK_MASK) != 0)
len -= XTS_BLK_BYTES;
while (len >= XTS_BLK_BYTES) {
- xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst);
+ xts_fullblock(alg->pa_decrypt, data_ctx, alpha_j, src, dst);
dst += XTS_BLK_BYTES;
src += XTS_BLK_BYTES;
len -= XTS_BLK_BYTES;
@@ -138,10 +144,10 @@
if (len != 0) {
len += XTS_BLK_BYTES;
- prevtweak[0] = tweak[0];
- prevtweak[1] = tweak[1];
- gf_mul128(tweak, tweak);
- xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst);
+ prevtweak[0] = alpha_j[0];
+ prevtweak[1] = alpha_j[1];
+ gf_mul128(alpha_j, alpha_j);
+ xts_fullblock(alg->pa_decrypt, data_ctx, alpha_j, src, dst);
dst += XTS_BLK_BYTES;
src += XTS_BLK_BYTES;
len -= XTS_BLK_BYTES;
Modified: soc2013/def/crashdump-head/sys/crypto/xts.h
==============================================================================
--- soc2013/def/crashdump-head/sys/crypto/xts.h Fri Aug 2 00:31:24 2013 (r255437)
+++ soc2013/def/crashdump-head/sys/crypto/xts.h Fri Aug 2 00:49:48 2013 (r255438)
@@ -111,13 +111,13 @@
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,
- const uint8_t *src, uint8_t *dst);
+ uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_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,
- const uint8_t *src, uint8_t *dst);
+ uint64_t sector, const uint8_t *xtweak, uint64_t *alpha_j,
+ int len, const uint8_t *src, uint8_t *dst);
algop_crypt_t xts_aes_encrypt;
algop_crypt_t xts_aes_decrypt;
More information about the svn-soc-all
mailing list