summaryrefslogtreecommitdiff
path: root/crypto/tcrypt.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-08-06 23:03:08 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2006-09-21 11:41:01 +1000
commit25cdbcd9e5d20e431f829cafce48a418830011f4 (patch)
tree0dff8422d2b0b1da1d3505b0ad0e840f6f0fd66d /crypto/tcrypt.c
parent58ec4152895b96f047dcf5e490ee49b4c574dec3 (diff)
[CRYPTO] crc32c: Fix unconventional setkey usage
The convention for setkey is that once it is set it should not change, in particular, init must not wipe out the key set by it. In fact, init should always be used after setkey before any digestion is performed. The only user of crc32c that sets the key is tcrypt. This patch adds the necessary init calls there. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r--crypto/tcrypt.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index e52f56c5bd5..bed225e8323 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -810,6 +810,7 @@ static void test_crc32c(void)
seed = SEEDTESTVAL;
(void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
+ crypto_digest_init(tfm);
crypto_digest_final(tfm, (u8*)&crc);
printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ?
"pass" : "ERROR");
@@ -821,6 +822,7 @@ static void test_crc32c(void)
for (i = 0; i < NUMVEC; i++) {
seed = ~(u32)0;
(void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
+ crypto_digest_init(tfm);
crypto_digest_update(tfm, &sg[i], 1);
crypto_digest_final(tfm, (u8*)&crc);
if (crc == vec_results[i]) {
@@ -836,6 +838,7 @@ static void test_crc32c(void)
for (i = 0; i < NUMVEC; i++) {
seed = (crc ^ ~(u32)0);
(void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
+ crypto_digest_init(tfm);
crypto_digest_update(tfm, &sg[i], 1);
crypto_digest_final(tfm, (u8*)&crc);
}
@@ -849,6 +852,7 @@ static void test_crc32c(void)
printk("\ntesting crc32c using digest:\n");
seed = ~(u32)0;
(void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
+ crypto_digest_init(tfm);
crypto_digest_digest(tfm, sg, NUMVEC, (u8*)&crc);
if (crc == tot_vec_results) {
printk(" %08x:OK", crc);