Commit cb9dde88 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: testmgr - handle endianness correctly in alg_test_crc32c()

The crc32c context is in CPU endianness, whereas the final digest is
little endian.  alg_test_crc32c() got this mixed up.  Fix it.

The test passes both before and after, but this patch fixes the
following sparse warning:

    crypto/testmgr.c:1912:24: warning: cast to restricted __le32
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 73381da5
...@@ -1889,7 +1889,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, ...@@ -1889,7 +1889,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
const char *driver, u32 type, u32 mask) const char *driver, u32 type, u32 mask)
{ {
struct crypto_shash *tfm; struct crypto_shash *tfm;
u32 val; __le32 val;
int err; int err;
err = alg_test_hash(desc, driver, type, mask); err = alg_test_hash(desc, driver, type, mask);
...@@ -1911,7 +1911,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, ...@@ -1911,7 +1911,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
shash->tfm = tfm; shash->tfm = tfm;
shash->flags = 0; shash->flags = 0;
*ctx = le32_to_cpu(420553207); *ctx = 420553207;
err = crypto_shash_final(shash, (u8 *)&val); err = crypto_shash_final(shash, (u8 *)&val);
if (err) { if (err) {
printk(KERN_ERR "alg: crc32c: Operation failed for " printk(KERN_ERR "alg: crc32c: Operation failed for "
...@@ -1919,9 +1919,9 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, ...@@ -1919,9 +1919,9 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
break; break;
} }
if (val != ~420553207) { if (val != cpu_to_le32(~420553207)) {
printk(KERN_ERR "alg: crc32c: Test failed for %s: " pr_err("alg: crc32c: Test failed for %s: %u\n",
"%d\n", driver, val); driver, le32_to_cpu(val));
err = -EINVAL; err = -EINVAL;
} }
} while (0); } while (0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment