Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2225103pxu; Fri, 18 Dec 2020 08:16:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOOwtcVQQWSx5d5PcgvffV8bTrSxLO0zbtCEbgwOvGQDfZQZ5DV5iOUj6DWeqXcAGZVRs5 X-Received: by 2002:a05:6402:1a54:: with SMTP id bf20mr5121673edb.65.1608308185118; Fri, 18 Dec 2020 08:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608308185; cv=none; d=google.com; s=arc-20160816; b=yQ4bX89cudnIDIhXHH3OH76WEBLR3rHIIHmtqH7/tRdubL+LeuNFE9+pQWezQz4E4X BqmN4Fr446N7cR+MUsrRrQgD1wmYzO+j9TuPcgStsdz/nyEBl1A9/S8fakl/FggTDBRi Sso8bqSE+TxiQTQ+oMABFKTUuT8z2W215fseFCmQ3SOAHj3ITDsQ+gePu+2SaTPGjEoq Qn1oNp8j14hV51EwpD59DRZnuzph3wBQQC48YdqFfEkAEuDVsXiWcpJS/dlYomypROBB 3JJATJlHDWRozuZqTfG4aVc95BKnkAAij8BMqLQdvpCNWRXRFywmYVHvICpqhTNfuEBX d8mQ== 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=c4lOknMgNvriScB0hO5RZQd5p0g7UDcK9qKAY5AfEfc=; b=cO1rgkQ4DiYe9Wc4ue9In8jQg3tchiXnX0ZxII8sd9JtjmehzlVNc6hlPZTefwEoit QEhajR/bCIj/1/z7F3vwgXqOD0l8Ox8O0SV8oVmJoB1h04T0hrKNvopAakkyIY26+3kL GoIU7uuUXXfX3wTgmksRBhwktIOe6OPQidREwiMi0dWBC3SgyvXQWsutEpAKaS1qFeDn IwjrPlHdTfeOCz+kvC7IMBOHCVYJFDGvdrhqwtOmNPKfQZmP8+RfHfZrV3654OuXtZJT +6sVYOReL91Cvjysq96n2HMIhRXXyh9IWjdpS5KXNDOV3EPa3/sMdCemHR5XMUZxoFqk S1aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=irunY8bg; 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=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si4209799ejx.39.2020.12.18.08.16.05; Fri, 18 Dec 2020 08:16:25 -0800 (PST) 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=@zx2c4.com header.s=mail header.b=irunY8bg; 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=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725825AbgLRQPw (ORCPT + 99 others); Fri, 18 Dec 2020 11:15:52 -0500 Received: from mail.zx2c4.com ([192.95.5.64]:39225 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbgLRQPw (ORCPT ); Fri, 18 Dec 2020 11:15:52 -0500 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 6a68cfe7 for ; Fri, 18 Dec 2020 16:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=zw4wXqB9HP72y02N0j6ubp0kXb4=; b=irunY8 bgwZz2iFNTvI5C9RA4IUaCQ6Z9Dq7BMOKMCR+THys7QVfbfhPU2pPSXA6vJORFkg 7zWWtL4gEqz6unGrYcoPMM7BFJXPGVAdhq+HwJ+mLmGhRzDbUCyIFNCAEuAMNrzE CnslK3PjqJsEABdqW2l0oLYog9mBMPHpriasiJfEUDQC4IfoYlpJ9CRnpnEWQVqI /qcagHrniR0htGfU2vnv24atPE4CSB0Cw4m5TFOSANJcROddRBhC3lBIr0zxm01C XdbwHgaxAM2nF9Z2BcC76qK1JM+028TMDxDRfQvMQZNVLBvng62dx9ZNT+NTJQu1 UohjMh11q/hT4fEw== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 566a7765 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 18 Dec 2020 16:07:16 +0000 (UTC) Received: by mail-yb1-f179.google.com with SMTP id a16so2384347ybh.5 for ; Fri, 18 Dec 2020 08:15:10 -0800 (PST) X-Gm-Message-State: AOAM533C1korOAF7Of0kqDzRjQmIawYfcx+V5Q6HIJCp+lLJD7En2ge2 7M6z2KmsYjlj8js4bKkq66Dd7ZLC4MacG+dzuOI= X-Received: by 2002:a25:2cd6:: with SMTP id s205mr6815605ybs.279.1608308109522; Fri, 18 Dec 2020 08:15:09 -0800 (PST) MIME-Version: 1.0 References: <20201217222138.170526-1-ebiggers@kernel.org> <20201217222138.170526-10-ebiggers@kernel.org> In-Reply-To: <20201217222138.170526-10-ebiggers@kernel.org> From: "Jason A. Donenfeld" Date: Fri, 18 Dec 2020 17:14:58 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 09/11] crypto: blake2s - share the "shash" API boilerplate code To: Eric Biggers Cc: Linux Crypto Mailing List , linux-arm-kernel , Ard Biesheuvel , Herbert Xu , David Sterba , Paul Crowley Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Dec 17, 2020 at 11:25 PM Eric Biggers wrote: > > From: Eric Biggers > > Move the boilerplate code for setkey(), init(), update(), and final() > from blake2s_generic.ko into a new module blake2s_helpers.ko, and export > it so that it can be used by other shash implementations of BLAKE2s. > > setkey() and init() are exported as-is, while update() and final() have > a blake2s_compress_t function pointer argument added. This allows the > implementation of the compression function to be overridden, which is > the only part that optimized implementations really care about. > > The helper functions are defined in a separate module blake2s_helpers.ko > (rather than just than in blake2s_generic.ko) because we can't simply > select CRYPTO_BLAKE2B from CRYPTO_BLAKE2S_X86. Doing this selection > unconditionally would make the library API select the shash API, while > doing it conditionally on CRYPTO_HASH would create a recursive kconfig > dependency on CRYPTO_HASH. As a bonus, using a separate module also > allows the generic implementation to be omitted when unneeded. > > These helper functions very closely match the ones I defined for > BLAKE2b, except the BLAKE2b ones didn't go in a separate module yet > because BLAKE2b isn't exposed through the library API yet. > > Finally, use these new helper functions in the x86 implementation of > BLAKE2s. (This part should be a separate patch, but unfortunately the > x86 implementation used the exact same function names like > "crypto_blake2s_update()", so it had to be updated at the same time.) There's a similar situation happening with chacha20poly1305 and with curve25519. Each of these uses a mildly different approach to how we split things up between library and crypto api code. The _helpers.ko is another one. There any opportunity here to take a more unified/consistant approach? Or is shash slightly different than the others and benefits from a third way? Jason