Skip to content

Commit 69fba37

Browse files
committed
crypto: cbc - Ensure statesize is zero
The cbc template should not be applied on stream ciphers, especially ones that have internal state. Enforce this by checking the state size when the instance is created. Reported-by: [email protected] Fixes: 47309ea ("crypto: arc4 - Add internal state") Signed-off-by: Herbert Xu <[email protected]>
1 parent ccb88e9 commit 69fba37

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crypto/cbc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
148148
if (!is_power_of_2(inst->alg.co.base.cra_blocksize))
149149
goto out_free_inst;
150150

151+
if (inst->alg.co.statesize)
152+
goto out_free_inst;
153+
151154
inst->alg.encrypt = crypto_cbc_encrypt;
152155
inst->alg.decrypt = crypto_cbc_decrypt;
153156

0 commit comments

Comments
 (0)