aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/xts.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/xts.c')
-rw-r--r--crypto/xts.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/xts.c b/crypto/xts.c
index 8eb08bfaf7c0..d87b0f3102c3 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -77,16 +77,16 @@ static int setkey(struct crypto_tfm *parent, const u8 *key,
77} 77}
78 78
79struct sinfo { 79struct sinfo {
80 be128 t; 80 be128 *t;
81 struct crypto_tfm *tfm; 81 struct crypto_tfm *tfm;
82 void (*fn)(struct crypto_tfm *, u8 *, const u8 *); 82 void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
83}; 83};
84 84
85static inline void xts_round(struct sinfo *s, void *dst, const void *src) 85static inline void xts_round(struct sinfo *s, void *dst, const void *src)
86{ 86{
87 be128_xor(dst, &s->t, src); /* PP <- T xor P */ 87 be128_xor(dst, s->t, src); /* PP <- T xor P */
88 s->fn(s->tfm, dst, dst); /* CC <- E(Key1,PP) */ 88 s->fn(s->tfm, dst, dst); /* CC <- E(Key1,PP) */
89 be128_xor(dst, dst, &s->t); /* C <- T xor CC */ 89 be128_xor(dst, dst, s->t); /* C <- T xor CC */
90} 90}
91 91
92static int crypt(struct blkcipher_desc *d, 92static int crypt(struct blkcipher_desc *d,
@@ -101,7 +101,6 @@ static int crypt(struct blkcipher_desc *d,
101 .tfm = crypto_cipher_tfm(ctx->child), 101 .tfm = crypto_cipher_tfm(ctx->child),
102 .fn = fn 102 .fn = fn
103 }; 103 };
104 be128 *iv;
105 u8 *wsrc; 104 u8 *wsrc;
106 u8 *wdst; 105 u8 *wdst;
107 106
@@ -109,20 +108,20 @@ static int crypt(struct blkcipher_desc *d,
109 if (!w->nbytes) 108 if (!w->nbytes)
110 return err; 109 return err;
111 110
111 s.t = (be128 *)w->iv;
112 avail = w->nbytes; 112 avail = w->nbytes;
113 113
114 wsrc = w->src.virt.addr; 114 wsrc = w->src.virt.addr;
115 wdst = w->dst.virt.addr; 115 wdst = w->dst.virt.addr;
116 116
117 /* calculate first value of T */ 117 /* calculate first value of T */
118 iv = (be128 *)w->iv; 118 tw(crypto_cipher_tfm(ctx->tweak), w->iv, w->iv);
119 tw(crypto_cipher_tfm(ctx->tweak), (void *)&s.t, w->iv);
120 119
121 goto first; 120 goto first;
122 121
123 for (;;) { 122 for (;;) {
124 do { 123 do {
125 gf128mul_x_ble(&s.t, &s.t); 124 gf128mul_x_ble(s.t, s.t);
126 125
127first: 126first:
128 xts_round(&s, wdst, wsrc); 127 xts_round(&s, wdst, wsrc);