On Fri, Mar 23, 2018 at 12:42:16PM +0200, Tudor Ambarus wrote:
> In crypto_authenc_setkey we save pointers to the authenc keys in
> a local variable of type struct crypto_authenc_keys and we don't
> zeroize it after use. Fix this and don't leak pointers to the
> authenc keys.
> 
> Signed-off-by: Tudor Ambarus <tudor.amba...@microchip.com>
> ---
>  crypto/authenc.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/crypto/authenc.c b/crypto/authenc.c
> index d3d6d72..480a08b 100644
> --- a/crypto/authenc.c
> +++ b/crypto/authenc.c
> @@ -87,8 +87,10 @@ static int crypto_authenc_setkey(struct crypto_aead 
> *authenc, const u8 *key,
>       struct crypto_authenc_keys keys;
>       int err = -EINVAL;
>  
> -     if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
> -             goto badkey;
> +     if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) {
> +             crypto_aead_set_flags(authenc, CRYPTO_TFM_RES_BAD_KEY_LEN);
> +             goto out;
> +     }

Why did you change this? The existing goto arrangement should work
fine even with your addition.

Cheers,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Reply via email to