From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18F49C433F5 for ; Mon, 18 Apr 2022 20:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u6lBiuutLhtTHNU1kGrMaApO9ORbyjh7Sj3GuUvBaxs=; b=rxkqJbYftXP/N3 lsZICAyBYTQAQLJQL/PICsXLyaGbNHX0y25s+6nqwDHyZAaI5B9rTuLWv/kzHCYhy61uY2i4HnPO2 /bldTOZZPn/tCcZDSaM1bJmjUr5jmdjwGDFowx/ZlSvgVlO52Qv4yKU6JUukw3fh6UqgPH30L3bov Jn0aRmJIgvnO2zPGfdsRAmIbc/yBCy3Ee4tb22M+G4GF3xzQxRNsveidztrFQ0rzsOQanenDa16HJ eA0KegfaRS9HMSnUhKebI/LSpMeT63wXbAvSJnNFfzg0nHStRiQXfqzYR1xYxWVlOHSS0F1OyDGtE qRIFcF69xKubaNeLIV9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngYGZ-000YYJ-En; Mon, 18 Apr 2022 20:46:35 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngYGV-000YXQ-HQ for linux-arm-kernel@lists.infradead.org; Mon, 18 Apr 2022 20:46:32 +0000 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 3E37C60FB3; Mon, 18 Apr 2022 20:46:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F35FC385A1; Mon, 18 Apr 2022 20:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650314788; bh=7WRNotIpr2rO8OMkXe6YR/zlvSemzZ4fIi0nEfMDJYs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fuRqt7FG6MkXGSPG9Xyy8NtPLvZNq3MVVMJGnHNlOfKVmaA+5n9ekx5C7G4v0JXSd WScDQ0ugZREHhjqlICMCiTvHVMvxjYURdYX8FvKw3bYJRKPCN0XR/oAzX/GBal7ceA 4Z7+EZK3gwV14W7yGYNO5dLsrjWogNlcUdMdP5AgrfJpg6T/zngMqijrXkvKXy0izA rQpfxFf9qCefHKEX2+J/CTAx2ZsJOh9eOPxWpwC3NTsWBf/in7CsRJjJqtp5FH4vyK g21yo8KeA+/TdYLAIyIE2WWthZkRzb5uH6olAN/4pV0wI433QAMeSpzl54lbWkmhrM bgQhaiGqNl86w== Date: Mon, 18 Apr 2022 13:46:26 -0700 From: Eric Biggers To: Nathan Huckleberry Cc: linux-crypto@vger.kernel.org, Herbert Xu , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Paul Crowley , Sami Tolvanen , Ard Biesheuvel Subject: Re: [PATCH v4 3/8] crypto: hctr2 - Add HCTR2 support Message-ID: References: <20220412172816.917723-1-nhuck@google.com> <20220412172816.917723-4-nhuck@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220412172816.917723-4-nhuck@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_134631_664472_92E0B9BD X-CRM114-Status: GOOD ( 17.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org One more comment: On Tue, Apr 12, 2022 at 05:28:11PM +0000, Nathan Huckleberry wrote: > +/* > + * Check for a supported set of inner algorithms. > + * See the comment at the beginning of this file. > + */ > +static bool hctr2_supported_algorithms(struct skcipher_alg *xctr_alg, > + struct crypto_alg *blockcipher_alg, > + struct shash_alg *polyval_alg) > +{ > + if (strncmp(xctr_alg->base.cra_name, "xctr(", 4) != 0) > + return false; > + > + if (blockcipher_alg->cra_blocksize != BLOCKCIPHER_BLOCK_SIZE) > + return false; > + > + if (strcmp(polyval_alg->base.cra_name, "polyval") != 0) > + return false; > + > + return true; > +} There are a couple issues here: - "See the comment at the beginning of this file" doesn't make sense. I guess this was copied from adiantum.c where there is indeed a comment at the beginning of the file that explains which "inner" algorithms are allowed. However, in hctr2.c there is no such comment (and that's fine; there aren't as many special considerations in this area for hctr2 as for adiantum). - The strncmp() expression uses a string of 5 characters but only compares 4. Also this check is redundant anyway, since hctr2_create_common() already does this check (correctly, with 5 characters). How about deleting the hctr2_supported_algorithms() function and putting the 2 needed checks directly in hctr2_create_common()? I.e., check blockcipher_alg->cra_blocksize right after the line: blockcipher_alg = crypto_spawn_cipher_alg(&ictx->blockcipher_spawn); ... and check polyval_alg->base.cra_name right after the line: polyval_alg = crypto_spawn_shash_alg(&ictx->polyval_spawn); Note, the pr_warn() message "Unsupported HCTR2 instantiation" isn't very important, and it arguably shouldn't be there since it is user-triggerable. So you can just delete it. - Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel