From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH 04/11] crypto: testmgr - handle endianness correctly in alg_test_crc32c()
Date: Thu, 10 Jan 2019 12:17:55 -0800 [thread overview]
Message-ID: <20190110201802.82442-5-ebiggers@kernel.org> (raw)
In-Reply-To: <20190110201802.82442-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
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>
---
crypto/testmgr.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 0f684a414acbe..10b7208bd40be 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1889,7 +1889,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
const char *driver, u32 type, u32 mask)
{
struct crypto_shash *tfm;
- u32 val;
+ __le32 val;
int err;
err = alg_test_hash(desc, driver, type, mask);
@@ -1911,7 +1911,7 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
shash->tfm = tfm;
shash->flags = 0;
- *ctx = le32_to_cpu(420553207);
+ *ctx = 420553207;
err = crypto_shash_final(shash, (u8 *)&val);
if (err) {
printk(KERN_ERR "alg: crc32c: Operation failed for "
@@ -1919,9 +1919,9 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
break;
}
- if (val != ~420553207) {
- printk(KERN_ERR "alg: crc32c: Test failed for %s: "
- "%d\n", driver, val);
+ if (val != cpu_to_le32(~420553207)) {
+ pr_err("alg: crc32c: Test failed for %s: %u\n",
+ driver, le32_to_cpu(val));
err = -EINVAL;
}
} while (0);
--
2.20.1.97.g81188d93c3-goog
next prev parent reply other threads:[~2019-01-10 20:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 20:17 [PATCH 00/11] crypto: misc fixes/cleanups Eric Biggers
2019-01-10 20:17 ` [PATCH 01/11] crypto: gcm - use correct endianness type in gcm_hash_len() Eric Biggers
2019-01-10 20:17 ` [PATCH 02/11] crypto: rsa-pkcs1pad - include <crypto/internal/rsa.h> Eric Biggers
2019-01-10 20:17 ` [PATCH 03/11] crypto: streebog - use correct endianness type Eric Biggers
2019-01-10 20:17 ` Eric Biggers [this message]
2019-01-10 20:17 ` [PATCH 05/11] crypto: user - forward declare crypto_nlsk Eric Biggers
2019-01-10 20:17 ` [PATCH 06/11] crypto: x86/aesni-gcm - make 'struct aesni_gcm_tfm_s' static const Eric Biggers
2019-01-10 20:17 ` [PATCH 07/11] crypto: tgr192 - fix unaligned memory access Eric Biggers
2019-01-10 20:17 ` [PATCH 08/11] crypto: stat - remove unused mutex Eric Biggers
2019-01-10 20:18 ` [PATCH 09/11] crypto: af_alg - make some functions static Eric Biggers
2019-01-10 20:18 ` [PATCH 10/11] crypto: af_alg - use list_for_each_entry() in af_alg_count_tsgl() Eric Biggers
2019-01-10 20:18 ` [PATCH 11/11] crypto: af_alg - remove redundant initializations of sk_family Eric Biggers
2019-01-18 10:57 ` [PATCH 00/11] crypto: misc fixes/cleanups Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190110201802.82442-5-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).