diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-08-06 09:03:08 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:41:01 -0400 |
commit | 25cdbcd9e5d20e431f829cafce48a418830011f4 (patch) | |
tree | 0dff8422d2b0b1da1d3505b0ad0e840f6f0fd66d /crypto/tcrypt.c | |
parent | 58ec4152895b96f047dcf5e490ee49b4c574dec3 (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.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index e52f56c5bd5e..bed225e83231 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -810,6 +810,7 @@ static void test_crc32c(void) | |||
810 | 810 | ||
811 | seed = SEEDTESTVAL; | 811 | seed = SEEDTESTVAL; |
812 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); | 812 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); |
813 | crypto_digest_init(tfm); | ||
813 | crypto_digest_final(tfm, (u8*)&crc); | 814 | crypto_digest_final(tfm, (u8*)&crc); |
814 | printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? | 815 | printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? |
815 | "pass" : "ERROR"); | 816 | "pass" : "ERROR"); |
@@ -821,6 +822,7 @@ static void test_crc32c(void) | |||
821 | for (i = 0; i < NUMVEC; i++) { | 822 | for (i = 0; i < NUMVEC; i++) { |
822 | seed = ~(u32)0; | 823 | seed = ~(u32)0; |
823 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); | 824 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); |
825 | crypto_digest_init(tfm); | ||
824 | crypto_digest_update(tfm, &sg[i], 1); | 826 | crypto_digest_update(tfm, &sg[i], 1); |
825 | crypto_digest_final(tfm, (u8*)&crc); | 827 | crypto_digest_final(tfm, (u8*)&crc); |
826 | if (crc == vec_results[i]) { | 828 | if (crc == vec_results[i]) { |
@@ -836,6 +838,7 @@ static void test_crc32c(void) | |||
836 | for (i = 0; i < NUMVEC; i++) { | 838 | for (i = 0; i < NUMVEC; i++) { |
837 | seed = (crc ^ ~(u32)0); | 839 | seed = (crc ^ ~(u32)0); |
838 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); | 840 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); |
841 | crypto_digest_init(tfm); | ||
839 | crypto_digest_update(tfm, &sg[i], 1); | 842 | crypto_digest_update(tfm, &sg[i], 1); |
840 | crypto_digest_final(tfm, (u8*)&crc); | 843 | crypto_digest_final(tfm, (u8*)&crc); |
841 | } | 844 | } |
@@ -849,6 +852,7 @@ static void test_crc32c(void) | |||
849 | printk("\ntesting crc32c using digest:\n"); | 852 | printk("\ntesting crc32c using digest:\n"); |
850 | seed = ~(u32)0; | 853 | seed = ~(u32)0; |
851 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); | 854 | (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); |
855 | crypto_digest_init(tfm); | ||
852 | crypto_digest_digest(tfm, sg, NUMVEC, (u8*)&crc); | 856 | crypto_digest_digest(tfm, sg, NUMVEC, (u8*)&crc); |
853 | if (crc == tot_vec_results) { | 857 | if (crc == tot_vec_results) { |
854 | printk(" %08x:OK", crc); | 858 | printk(" %08x:OK", crc); |