summaryrefslogtreecommitdiff
path: root/crypto/lrw.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-17 20:00:11 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2009-02-17 20:00:11 +0800
commiteccd4ec34ac5e03d56c6a1bcf86f3b3182b2a460 (patch)
treecde7dca7d0d9364f3042bc709e8508b3cd4a4295 /crypto/lrw.c
parentab2867eed88e7823dc312e585a65c1c86040edc4 (diff)
downloadlinux-crypto-eccd4ec34ac5e03d56c6a1bcf86f3b3182b2a460.tar.gz
linux-crypto-eccd4ec34ac5e03d56c6a1bcf86f3b3182b2a460.zip
crypto: lrw - Fix big endian support
It turns out that LRW has never worked properly on big endian. This was never discussed because nobody actually used it that way. In fact, it was only discovered when Geert Uytterhoeven loaded it through tcrypt which failed the test on it. The fix is straightforward, on big endian the to find the nth bit we should be grouping them by words instead of bytes. So setbit128_bbe should xor with 128 - BITS_PER_LONG instead of 128 - BITS_PER_BYTE == 0x78. Tested-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/lrw.c')
-rw-r--r--crypto/lrw.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/lrw.c b/crypto/lrw.c
index 8ef664e3..358f80be 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -45,7 +45,13 @@ struct priv {
static inline void setbit128_bbe(void *b, int bit)
{
- __set_bit(bit ^ 0x78, b);
+ __set_bit(bit ^ (0x80 -
+#ifdef __BIG_ENDIAN
+ BITS_PER_LONG
+#else
+ BITS_PER_BYTE
+#endif
+ ), b);
}
static int setkey(struct crypto_tfm *parent, const u8 *key,