Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3521772pxb; Tue, 19 Apr 2022 04:37:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHPnLuEB6nukqU4q7MSwMLWeF64JRu7xB9IqbQCP4eD8eAhm5caru/HNP28L5xpF+Y1sr+ X-Received: by 2002:a17:902:a613:b0:156:b53d:c137 with SMTP id u19-20020a170902a61300b00156b53dc137mr15201762plq.73.1650368264429; Tue, 19 Apr 2022 04:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650368264; cv=none; d=google.com; s=arc-20160816; b=lYe16/RS0DIAK7bQJMmxuzoBiCAsFgVuaymEGEA5Xo4hR1KjjYeFI8w8AnZHs0f+Z3 QQ9A7qgdiIFDd9JlpSphlWPHJGWYFshQZBGY/K1+TQZKW+PiRxTW5yoReuNqb2Z0X+IS wGJeN6q2ChhvtLyKXZeZGM7RwInzdUK7aEO8MASZBnsbsgLtmdW5yTq018Dk7rOoLDyi +Ef5MBTutdtgAJO9wNFcQGYF2mIk7ae+q1KRsyeMfZgtVwIMR13ik4As17JgIBeR6EiG 0YaNGIo/XFhU1jcL26cJJkDjuS5S4mvXK/m2ieTbxAzG8hGBYtAZLMCORqgqtIYIkqF2 HwQg== 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=/vAFyhty+qAOsctFnoPEnU8WztSV7JbQvrazNUwtXc0=; b=WlnNXYxK3f9+UYtkYIVuPkOEGxeq4rQju48k1YMr3TcfivImgIPIi2kyCa4mYc0rF+ bngjPHX5ZylhTJjKlmjgR4w1IrC+hoOFrbbl6DUszM523QZ5k9T/OeBUfXkQ6i7A7CNO N8ddeAO0+q25dEOMZK7o2PYu+xBv6PdWECJ2bu5WoZUaw3vX9y+xZriE6OYH2+1x9ZUS 54x5+GCoVEX7JxRUe/ZRHQVegFARyOxPuCjHs8iOgP0jOtuxayWmMy+NGeDgrkD4vmgW jilvPxpdTjF20mfKPUVsb4xfSiUWZpvDwpycPQsMj69ykCd//4ANuL5BG0fhBBQ3D6Nj QWfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fuRqt7FG; 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 t1-20020a056a0021c100b005083115c6ffsi11716157pfj.296.2022.04.19.04.37.30; Tue, 19 Apr 2022 04:37:44 -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=fuRqt7FG; 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 S237431AbiDRUtM (ORCPT + 99 others); Mon, 18 Apr 2022 16:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231984AbiDRUtM (ORCPT ); Mon, 18 Apr 2022 16:49:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A392E20BE1 for ; Mon, 18 Apr 2022 13:46:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id EB512B810BF for ; 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220412172816.917723-4-nhuck@google.com> X-Spam-Status: No, score=-7.7 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 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 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