Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1074055ybx; Tue, 5 Nov 2019 09:52:51 -0800 (PST) X-Google-Smtp-Source: APXvYqySPWpOl4o2SInl63UJwJQs3rzKgGCzsPMsg0N94b2kWu8QD9P2udaE4dDVKkn5gl0umbdj X-Received: by 2002:aa7:d552:: with SMTP id u18mr37589632edr.86.1572976371525; Tue, 05 Nov 2019 09:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572976371; cv=none; d=google.com; s=arc-20160816; b=pPf9EXQYnDsWp2xcrqO//Ethq7MAqyc1HEcrX8bUga6spo5YudgFA6tLtXobGxPNDx 6kZPTtmCxvu30FQrHlWYv/MCuZhcWnBiqSx4SKMrs7BLQMKLZyRcwCyybgVmRnKr3T6q 2zCjVZ43jY4ZAIHKlY4rTM3rufkYj6CjDz0rFirnGfiZOB3ks8uZfM3kYwY/a0wnEWqy r4wntak3IMrBScNnKqvnKb9QMa+VkYqRTRocgwxiiwc3yH9GQ/jQh+8Z3aKCsgMx8uLO aQLuaC1euK+opvftSXQQC/0d/1p35ynNxUIwP/QIwYt3Gqz7Z2J1hNz2p4U9VKo7Lnfu Ex4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=mH267L6EegiKOAEOcceCCumuNbhXlHi5gKXrNaIRduY=; b=Hrkd8pFEBmqA4JXVOVw3Sa4lYFYvXi1r6N3gEmLm+xrH+0ygNpEFWpUj/bzeGA/zbu jVp6eMM+A2FEQX7FUYQFO6SrWtqzzfyihBREhbOlSlnDqIyJd3zTYHkvscVw8plGRs6S I0LmydJaZKsI+cU6NUKR9TzqwAvj+e2QOaDnkAqRk4bvYeNVZLb5FHmobqgQZr6S2eXQ 3RQnVDfGquDITtu4uzwIrX+3953JHxpKkRxbn8oS0eqhF/bfYWZZTX1tRm068kJvzmbX 8xu+SZQk2KxYGC7kI5YIZbiWQ5Ncc9GJ/r9keYVSw+5yLgTXFiZnveg94REumHYHj/Lv 41xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=srDrOLLX; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si10337782ede.132.2019.11.05.09.52.26; Tue, 05 Nov 2019 09:52:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=srDrOLLX; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390551AbfKERwJ (ORCPT + 99 others); Tue, 5 Nov 2019 12:52:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:38554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390346AbfKERwJ (ORCPT ); Tue, 5 Nov 2019 12:52:09 -0500 Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1DB1D20650; Tue, 5 Nov 2019 17:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572976328; bh=p+VFQmkLqCjORwfUsYuCrte2jE7w7TTv8ecEBf5sFgg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=srDrOLLXcIW6gCW3oXZrBlGEV0CAfb6hz8wpyF0zB5fkJqfSCDq2F9LY03JnvrEgx sDKT1bZHpr+8iPIcCDylMkS5Vjsl3QY6li8oE5yiTXO3826kwQscMV2WbszT6NetJc 2zDNDw1mHVRc2B9RyDRzO7q/kW8GqO0b+ok9/poo= Date: Tue, 5 Nov 2019 09:52:06 -0800 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, Herbert Xu , "David S. Miller" , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 28/29] crypto: remove deprecated and unused ablkcipher support Message-ID: <20191105175206.GD757@sol.localdomain> Mail-Followup-To: Ard Biesheuvel , linux-crypto@vger.kernel.org, Herbert Xu , "David S. Miller" , linux-arm-kernel@lists.infradead.org References: <20191105132826.1838-1-ardb@kernel.org> <20191105132826.1838-29-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105132826.1838-29-ardb@kernel.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Nov 05, 2019 at 02:28:25PM +0100, Ard Biesheuvel wrote: > Now that all users of the deprecated ablkcipher interface have been > moved to the skcipher interface, ablkcipher is no longer used and > can be removed. > > Signed-off-by: Ard Biesheuvel Reviewed-by: Eric Biggers Thanks for doing this! A couple ideas for future cleanups below (which, if done, should go in separate patches rather than in this big one): > @@ -786,9 +683,6 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm) > struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm); > struct skcipher_alg *alg = crypto_skcipher_alg(skcipher); > > - if (tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) > - return crypto_init_skcipher_ops_ablkcipher(tfm); > - > skcipher->setkey = skcipher_setkey; > skcipher->encrypt = alg->encrypt; > skcipher->decrypt = alg->decrypt; > skcipher->ivsize = alg->ivsize; > skcipher->keysize = alg->max_keysize; Since a crypto_skcipher will now always be paired with a skcipher_alg (rather than an blkcipher or ablkcipher algorithm), we could remove the 'encrypt', 'decrypt', 'ivsize', and 'keysize' fields of crypto_skcipher, and instead always get them from the skcipher_alg. > @@ -182,27 +171,18 @@ static inline u32 skcipher_request_flags(struct skcipher_request *req) > static inline unsigned int crypto_skcipher_alg_min_keysize( > struct skcipher_alg *alg) > { > - if (alg->base.cra_ablkcipher.encrypt) > - return alg->base.cra_ablkcipher.min_keysize; > - > return alg->min_keysize; > } > > static inline unsigned int crypto_skcipher_alg_max_keysize( > struct skcipher_alg *alg) > { > - if (alg->base.cra_ablkcipher.encrypt) > - return alg->base.cra_ablkcipher.max_keysize; > - > return alg->max_keysize; > } > > static inline unsigned int crypto_skcipher_alg_walksize( > struct skcipher_alg *alg) > { > - if (alg->base.cra_ablkcipher.encrypt) > - return alg->base.cra_blocksize; > - > return alg->walksize; > } > > diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h > index 8c5a31e810da..b4655d91661f 100644 > --- a/include/crypto/skcipher.h > +++ b/include/crypto/skcipher.h > @@ -241,9 +241,6 @@ static inline struct skcipher_alg *crypto_skcipher_alg( > > static inline unsigned int crypto_skcipher_alg_ivsize(struct skcipher_alg *alg) > { > - if (alg->base.cra_ablkcipher.encrypt) > - return alg->base.cra_ablkcipher.ivsize; > - > return alg->ivsize; > } > > @@ -286,9 +283,6 @@ static inline unsigned int crypto_skcipher_blocksize( > static inline unsigned int crypto_skcipher_alg_chunksize( > struct skcipher_alg *alg) > { > - if (alg->base.cra_ablkcipher.encrypt) > - return alg->base.cra_blocksize; > - > return alg->chunksize; > } Now that these helpers are trivial, they could be removed and we could just dereference the struct skcipher_alg directly. - Eric