Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1484274pxv; Fri, 23 Jul 2021 09:21:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiGJEv9iTrrr1IKjHcx9/3NpE2+pFqCSwgazcVZkwocJkItkfWZjHw3KjuplGScjTFZUAS X-Received: by 2002:aa7:da13:: with SMTP id r19mr6594870eds.252.1627057288417; Fri, 23 Jul 2021 09:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627057288; cv=none; d=google.com; s=arc-20160816; b=kJ7N3yZppxS3s3+Avag4msgMV6txJkdwUyG6f4+yYxD+oqIhK0rJDMzvLaJJXCooHf hFV/gc7GCOlD1VJnbe8kKzFl9TKs+ALnv6xTdSZFdYD3wzwl2BtR4QnG3dahJsCybulv 0XBT+U6Yvh8fZMTvux+jSsSsHcqQjPjsLu73xb+ANGvsXF7Xm39BzGxTEpyaxoWHw6+H uCkGGrFdzXtSUGGfcc4Y1IR8x/n6fkMqLrXGI/vtkkKA3tISfeH1p49M+haz9an+WFkP ja9/xXxIU5pzDheWPpTap/VAERCx50r8O4vZVy/kLQu/xtfrynzw33xsBUgWyrFRoQa8 mebg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ObC0PBU3kqAC/vJyw70MS1yBjhB3GUdu1B9ke0irNVk=; b=qegWbazt7kcSSmsQ4Wd6wuYWjxKemokhNA4ppwoPkB2b9etNugTAv27o1J/joZ4pA4 KQd4Cr4pmAoHqzJhO/F2TXF410ATybG+yPF2DmY62ieqfIzDFGAK6QJ7ku2D2+oPEYRe 7gpajX/HVfGLT/2KW5JfMRiur2OsmL1ck1DHbsQA69u/GcQjs8x7RDiuHnkpUlviEeJt Hmkfl5oN/ozSvKJjZilcDaKHKpYIOyTQ/lMOnSd6Kma1ORnqIHNGQ2OPE4+nATMadVqf KC2cf3FQR7ssiAYwIHeNY3qQiv/+HpSlqAwdp6mUyGWI6fi/OpY1ytNh+mjBWABzsB6t GGaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GVmllpAW; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id l20si33492933ejn.131.2021.07.23.09.20.55; Fri, 23 Jul 2021 09:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GVmllpAW; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S229698AbhGWPjy (ORCPT + 99 others); Fri, 23 Jul 2021 11:39:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:58146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbhGWPjx (ORCPT ); Fri, 23 Jul 2021 11:39:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1BCE60E0C; Fri, 23 Jul 2021 16:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627057227; bh=BSKEbzYJ66nESAtFQf4aOIwr905oWBJvxJpIr0z1g3s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GVmllpAWocCrBtift0p+Xav1Nur5S1QohOppiS7Il6MoIUre++paxiWkznrF62hYn +wSEWuTuSGzJqjtZ56EPJQJIDZaNmFy+9Wq6/N9ggn7gdVUdzBSBUQs1iXXKT3u8wO HsPzGynBBgFcFw0kahkmTNiPeITH2JcJkeEdJN+3fYyksdsHhOXCia1nh11VCbWSSJ 4ylfhErQrIcOBJ8jPQbu7Vit9VAvwz34LTHyO4u7p3F0R/AqlBVNwJFg3aS40VlGaL 5+5YIBZ4Pefa9peotRTAoCgpO0nv5EZ4SODH++VDGe/vFN7TYhHX6ifufw42vBitw/ zZ74xSs4vqApw== Date: Fri, 23 Jul 2021 09:20:25 -0700 From: Eric Biggers To: Thara Gopinath Cc: Herbert Xu , linux-crypto@vger.kernel.org Subject: Re: Extending CRYPTO_ALG_OPTIONAL_KEY for cipher algorithms Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Jul 23, 2021 at 06:13:50AM -0400, Thara Gopinath wrote: > Hi > > I have a requirement where the keys for the crypto cipher algorithms are > already programmed in the h/w pipes/channels and thus the ->encrypt() > and ->decrypt() can be called without set_key being called first. > I see that CRYPTO_ALG_OPTIONAL_KEY has been added to take care of > such requirements for CRC-32. My question is can the usage of this flag > be extended for cipher and other crypto algorithms as well. Can setting of > this flag indicate that the algorithm can be used without calling set_key > first and then the individual drivers can handle cases where > both h/w keys and s/w keys need to be supported. CRYPTO_ALG_OPTIONAL_KEY isn't meant for this use case, but rather for algorithms that have both keyed and unkeyed versions such as BLAKE2b and BLAKE2s, and also for algorithms where the "key" isn't actually a key but rather is an initial value that has a default value, such as CRC-32 and xxHash. It appears that that the case you're asking about is handled by using a different algorithm name, e.g. see the "paes" algorithms in drivers/crypto/ccree/cc_cipher.c. - Eric