Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2172632rwd; Fri, 19 May 2023 01:56:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cRr4LztkmaRbWdRkI801atRc5rH6VZrU9bulBWx7M/yWqtsPgBzsHh//MKxzC2BkC2zv4 X-Received: by 2002:aa7:8893:0:b0:643:849a:dd06 with SMTP id z19-20020aa78893000000b00643849add06mr2279389pfe.34.1684486568917; Fri, 19 May 2023 01:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684486568; cv=none; d=google.com; s=arc-20160816; b=geeaSs2YFCtvMb1diz8d/ZhwTBHltcTHqUHyJtunsJl1+Ra0f3uI0Sn84+qTGZDJH7 Rdq/lKHj/fvYblIfBZ5a6uDK4TZT4EpRtLmuIrDtwJmjWRVlxbJC6qTYwknFOBqMLe4h D9N6O2ymq1YM9aYMrkmsO2nWsXd87WnNanb8ZJAWKTKSfiO9THp+7xRquXVH0Ff/ChFB TXncbqpTxD9z/oEn7zkSHwt51MjXij69IuajxBSVHYjSTLwYBFWZOe7bZiHJ2WfpL7kr kELLotyxnLFofVV/5x2ttHFBR5qvkJUlymRbVcfWBLvQXybQzgVWnDoIswzz9g1//ZiU f1dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=twMD3yAbxvIsFFAVcFsPG2/5EahwkxOrMNSteiMTaiY=; b=gH6GqkRCdLBd2NwgmtMn0d7ENd5UK6neMwDrmNtwrDQyaZ+TSglWs0f8Wyi72Po+jb CqRp+pk3uwKw6TDBdIwpiWaE6BJ/ZyecCbR1xBGMRxqZOmzAkudwf/T4o+KG6esdkdb+ AZOTPuhznmCreiIn/0QY3ws4tpWBSk7MWgPBIkNmLgoNbwPDKmt+DU/vQncgXdpQbWFF ul4Tz23q1zq06jBRdHQ/5tVojGR0nBhlqdq3qBR66iH6Xhvvn7lgSnoa8VElvYsRHcUh dcoMAH9GoQ1vCT1K6cAC6RCCug3zx5MAouOf8z8A5LX0Q3AUHOghF455uzn5EneTlnXx EQyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TLL7EZD0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b123-20020a62cf81000000b006453ad4ff39si2475766pfg.147.2023.05.19.01.55.56; Fri, 19 May 2023 01:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TLL7EZD0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230103AbjESIy6 (ORCPT + 99 others); Fri, 19 May 2023 04:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231299AbjESIy5 (ORCPT ); Fri, 19 May 2023 04:54:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C643410E6; Fri, 19 May 2023 01:54:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 788A06552C; Fri, 19 May 2023 08:54:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD99AC4339C; Fri, 19 May 2023 08:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684486464; bh=l6xWlNTW11M1IArH9XbVsO0LuYjgvFrPFdvjgT2fKsY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TLL7EZD00J0qHP0WIImFoaeP9iS7POWP+jnrXXMOVsvPZf7p0pLPOZmZditjFFg31 hQ44JGMc+sINjBZQV4JnhcqiHZ/mQYoX/q3UD8LQ3fL7avD2osNo6ikbeO+dTVqI8U SLLneongeou+VquX03U5xk32P8IGa+mc28lW+KBpgGF+YcNep+zjvA092liO93u4Po Mr+Hg/2V7r/LSvvS51mmeCcObriQgn7bfCwvJml8+elLZMzpPHkT4iYPgk0FkGLQ/W H2027cYo7hdUiOwfaUuO0jp4YfS9qDFtQWfaHB6t7GSPEli7Z/CzCLg1UuRwwtw8K9 mD5z70YGlVj8g== Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-4f2676d62a2so3346163e87.0; Fri, 19 May 2023 01:54:24 -0700 (PDT) X-Gm-Message-State: AC+VfDwz/1er401cIoV6TLsg0UmhbYPE5TCnAfnokzh6bDmWjvQM2ck7 teEQdq8n/96UESDwnjrg6kSqQteCAOlkqzB54JM= X-Received: by 2002:ac2:43a4:0:b0:4f2:7b65:baeb with SMTP id t4-20020ac243a4000000b004f27b65baebmr455104lfl.53.1684486462868; Fri, 19 May 2023 01:54:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 19 May 2023 10:54:11 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] crypto: cmac - Add support for cloning To: Herbert Xu Cc: Dmitry Safonov , Linux Crypto Mailing List , linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Paolo Abeni , Jakub Kicinski , "David S. Miller" , Andy Lutomirski , Bob Gilligan , Dan Carpenter , David Laight , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers , "Eric W. Biederman" , Francesco Ruggeri , Hideaki YOSHIFUJI , Ivan Delalande , Leonard Crestez , Salam Noureddine , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Herbert, On Fri, 19 May 2023 at 10:29, Herbert Xu wrote: > > Allow hmac to be cloned. The underlying cipher needs to support > cloning by not having a cra_init function (all implementations of > aes that do not require a fallback can be cloned). > > Signed-off-by: Herbert Xu Does this imply that the cmac-aes-ce and cmac-aes-neon implementations for arm64 need a similar treatment? > --- > > crypto/cmac.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/crypto/cmac.c b/crypto/cmac.c > index bcc6f19a4f64..fce6b0f58e88 100644 > --- a/crypto/cmac.c > +++ b/crypto/cmac.c > @@ -213,7 +213,22 @@ static int cmac_init_tfm(struct crypto_shash *tfm) > ctx->child = cipher; > > return 0; > -}; > +} > + > +static int cmac_clone_tfm(struct crypto_shash *tfm, struct crypto_shash *otfm) > +{ > + struct cmac_tfm_ctx *octx = crypto_shash_ctx(otfm); > + struct cmac_tfm_ctx *ctx = crypto_shash_ctx(tfm); > + struct crypto_cipher *cipher; > + > + cipher = crypto_clone_cipher(octx->child); > + if (IS_ERR(cipher)) > + return PTR_ERR(cipher); > + > + ctx->child = cipher; > + > + return 0; > +} > > static void cmac_exit_tfm(struct crypto_shash *tfm) > { > @@ -280,6 +295,7 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb) > inst->alg.final = crypto_cmac_digest_final; > inst->alg.setkey = crypto_cmac_digest_setkey; > inst->alg.init_tfm = cmac_init_tfm; > + inst->alg.clone_tfm = cmac_clone_tfm; > inst->alg.exit_tfm = cmac_exit_tfm; > > inst->free = shash_free_singlespawn_instance;