Skip to content

Commit a8cc312

Browse files
toromanoSTMherbertx
authored andcommitted
crypto: stm32/crc32 - fix run-time self test issue.
Fix wrong crc32 initialisation value: "alg: shash: stm32_crc32 test failed (wrong result) on test vector 0, cfg="init+update+final aligned buffer" cra_name="crc32c" expects an init value of 0XFFFFFFFF, cra_name="crc32" expects an init value of 0. Fixes: b51dbe9 ("crypto: stm32 - Support for STM32 CRC32 crypto module") Signed-off-by: Nicolas Toromanoff <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 49c2c08 commit a8cc312

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/crypto/stm32/stm32-crc32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
/* Registers values */
3030
#define CRC_CR_RESET BIT(0)
31-
#define CRC_INIT_DEFAULT 0xFFFFFFFF
3231
#define CRC_CR_REV_IN_WORD (BIT(6) | BIT(5))
3332
#define CRC_CR_REV_IN_BYTE BIT(5)
3433
#define CRC_CR_REV_OUT BIT(7)
34+
#define CRC32C_INIT_DEFAULT 0xFFFFFFFF
3535

3636
#define CRC_AUTOSUSPEND_DELAY 50
3737

@@ -65,7 +65,7 @@ static int stm32_crc32_cra_init(struct crypto_tfm *tfm)
6565
{
6666
struct stm32_crc_ctx *mctx = crypto_tfm_ctx(tfm);
6767

68-
mctx->key = CRC_INIT_DEFAULT;
68+
mctx->key = 0;
6969
mctx->poly = CRC32_POLY_LE;
7070
return 0;
7171
}
@@ -74,7 +74,7 @@ static int stm32_crc32c_cra_init(struct crypto_tfm *tfm)
7474
{
7575
struct stm32_crc_ctx *mctx = crypto_tfm_ctx(tfm);
7676

77-
mctx->key = CRC_INIT_DEFAULT;
77+
mctx->key = CRC32C_INIT_DEFAULT;
7878
mctx->poly = CRC32C_POLY_LE;
7979
return 0;
8080
}

0 commit comments

Comments
 (0)