crypto: atmel-ecc - avoid stale fallback key after set_secret failure
PATCH 1/1 crypto: atmel-ecc - avoid stale fallback key after set_secret failure
Clear ->do_fallback before decoding a new ECDH secret and enable it only after the software fallback accepts a caller-provided private key. This avoids using a stale fallback key should crypto_kpp_set_secret() fail.
Fixes 11105693fa05 ("crypto: atmel-ecc - introduce Microchip / Atmel ECC driver")
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/crypto/atmel-ecc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/atmel-ecc.c +4 -4
@@ -82,6 +82,7 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,kfree (ctx->public_key); ctx->public_key =NULL ; + ctx->do_fallback = false;if (crypto_ecdh_decode_key (buf, len, ¶ms) <0 ) {dev_err (&ctx->client->dev,"crypto_ecdh_decode_key failed\n" );
@@ -89,8 +90,9 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, }if (params.key_size) { - ctx->do_fallback = true; -return crypto_kpp_set_secret (ctx->fallback, buf, len); + ret =crypto_kpp_set_secret (ctx->fallback, buf, len); + ctx->do_fallback = !ret; +return ret; } cmd =kmalloc_obj (*cmd);
@@ -101,8 +103,6 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,if (!public_key) goto free_cmd; - ctx->do_fallback = false; -atmel_i2c_init_genkey_cmd (cmd,DATA_SLOT_2 ); ret =atmel_i2c_send_receive (ctx->client, cmd);
base-commit: e264401ce4776a288524e5b87593d4d864147115
Herbert Xu
maintainerQuoted 10 lines · Thorsten Blum
Clear ->do_fallback before decoding a new ECDH secret and enable it only after the software fallback accepts a caller-provided private key. This avoids using a stale fallback key should
crypto_kpp_set_secret()fail.Fixes 11105693fa05 ("crypto: atmel-ecc - introduce Microchip / Atmel ECC driver")Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/atmel-ecc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt