diff options
author | Eric Biggers <ebiggers@google.com> | 2019-01-10 15:17:55 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-01-18 05:43:43 -0500 |
commit | cb9dde8801292e31e3964236a72f04926cf500b7 (patch) | |
tree | 89fb81c6f85ad61d82f72fed0c33439ace6c394e /crypto | |
parent | 73381da5f9ec333b1fbe38a156e7764a90e36a74 (diff) |
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: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/testmgr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 1ce53f8058d2..fd31cfa872fb 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -1889,7 +1889,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, | |||
1889 | const char *driver, u32 type, u32 mask) | 1889 | const char *driver, u32 type, u32 mask) |
1890 | { | 1890 | { |
1891 | struct crypto_shash *tfm; | 1891 | struct crypto_shash *tfm; |
1892 | u32 val; | 1892 | __le32 val; |
1893 | int err; | 1893 | int err; |
1894 | 1894 | ||
1895 | err = alg_test_hash(desc, driver, type, mask); | 1895 | err = alg_test_hash(desc, driver, type, mask); |
@@ -1911,7 +1911,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, | |||
1911 | shash->tfm = tfm; | 1911 | shash->tfm = tfm; |
1912 | shash->flags = 0; | 1912 | shash->flags = 0; |
1913 | 1913 | ||
1914 | *ctx = le32_to_cpu(420553207); | 1914 | *ctx = 420553207; |
1915 | err = crypto_shash_final(shash, (u8 *)&val); | 1915 | err = crypto_shash_final(shash, (u8 *)&val); |
1916 | if (err) { | 1916 | if (err) { |
1917 | printk(KERN_ERR "alg: crc32c: Operation failed for " | 1917 | printk(KERN_ERR "alg: crc32c: Operation failed for " |
@@ -1919,9 +1919,9 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, | |||
1919 | break; | 1919 | break; |
1920 | } | 1920 | } |
1921 | 1921 | ||
1922 | if (val != ~420553207) { | 1922 | if (val != cpu_to_le32(~420553207)) { |
1923 | printk(KERN_ERR "alg: crc32c: Test failed for %s: " | 1923 | pr_err("alg: crc32c: Test failed for %s: %u\n", |
1924 | "%d\n", driver, val); | 1924 | driver, le32_to_cpu(val)); |
1925 | err = -EINVAL; | 1925 | err = -EINVAL; |
1926 | } | 1926 | } |
1927 | } while (0); | 1927 | } while (0); |