diff options
| author | Ondrej Mosnáček <omosnacek@gmail.com> | 2017-04-02 15:19:14 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-04-05 09:58:37 -0400 |
| commit | e55318c84f199d6056a0bcd98bc4612d01ccfe80 (patch) | |
| tree | b77991aaa7d895773d631dbbdfc10ba960d96dfc /include | |
| parent | acb9b159c784dc0033ede0dadde876ebd93aca4c (diff) | |
crypto: gf128mul - switch gf128mul_x_ble to le128
Currently, gf128mul_x_ble works with pointers to be128, even though it
actually interprets the words as little-endian. Consequently, it uses
cpu_to_le64/le64_to_cpu on fields of type __be64, which is incorrect.
This patch fixes that by changing the function to accept pointers to
le128 and updating all users accordingly.
Signed-off-by: Ondrej Mosnacek <omosnacek@gmail.com>
Reviewd-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include')
| -rw-r--r-- | include/crypto/gf128mul.h | 8 | ||||
| -rw-r--r-- | include/crypto/xts.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/include/crypto/gf128mul.h b/include/crypto/gf128mul.h index 35ced9db70ea..0977fb18ff68 100644 --- a/include/crypto/gf128mul.h +++ b/include/crypto/gf128mul.h | |||
| @@ -205,16 +205,16 @@ static inline void gf128mul_x_bbe(be128 *r, const be128 *x) | |||
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | /* needed by XTS */ | 207 | /* needed by XTS */ |
| 208 | static inline void gf128mul_x_ble(be128 *r, const be128 *x) | 208 | static inline void gf128mul_x_ble(le128 *r, const le128 *x) |
| 209 | { | 209 | { |
| 210 | u64 a = le64_to_cpu(x->a); | 210 | u64 a = le64_to_cpu(x->a); |
| 211 | u64 b = le64_to_cpu(x->b); | 211 | u64 b = le64_to_cpu(x->b); |
| 212 | 212 | ||
| 213 | /* equivalent to gf128mul_table_be[b >> 63] (see crypto/gf128mul.c): */ | 213 | /* equivalent to gf128mul_table_be[b >> 63] (see crypto/gf128mul.c): */ |
| 214 | u64 _tt = gf128mul_mask_from_bit(b, 63) & 0x87; | 214 | u64 _tt = gf128mul_mask_from_bit(a, 63) & 0x87; |
| 215 | 215 | ||
| 216 | r->a = cpu_to_le64((a << 1) ^ _tt); | 216 | r->a = cpu_to_le64((a << 1) | (b >> 63)); |
| 217 | r->b = cpu_to_le64((b << 1) | (a >> 63)); | 217 | r->b = cpu_to_le64((b << 1) ^ _tt); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | /* 4k table optimization */ | 220 | /* 4k table optimization */ |
diff --git a/include/crypto/xts.h b/include/crypto/xts.h index 77b630672b2c..c0bde308b28a 100644 --- a/include/crypto/xts.h +++ b/include/crypto/xts.h | |||
| @@ -11,7 +11,7 @@ struct blkcipher_desc; | |||
| 11 | #define XTS_BLOCK_SIZE 16 | 11 | #define XTS_BLOCK_SIZE 16 |
| 12 | 12 | ||
| 13 | struct xts_crypt_req { | 13 | struct xts_crypt_req { |
| 14 | be128 *tbuf; | 14 | le128 *tbuf; |
| 15 | unsigned int tbuflen; | 15 | unsigned int tbuflen; |
| 16 | 16 | ||
| 17 | void *tweak_ctx; | 17 | void *tweak_ctx; |
