From: Andy Lutomirski Subject: Re: [RFC PATCH 4.10 1/6] crypto/sha256: Refactor the API so it can be used without shash Date: Fri, 23 Dec 2016 18:26:37 -0800 Message-ID: References: <942b91f25a63b22ec4946378a1fffe78d655cf18.1482545792.git.luto@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Daniel Borkmann , Netdev , LKML , Linux Crypto Mailing List , "Jason A. Donenfeld" , Hannes Frederic Sowa , Alexei Starovoitov , Eric Dumazet , Eric Biggers , Tom Herbert , "David S. Miller" , Ard Biesheuvel , Herbert Xu To: Andy Lutomirski Return-path: Received: from mail-ua0-f175.google.com ([209.85.217.175]:34204 "EHLO mail-ua0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758433AbcLXC1R (ORCPT ); Fri, 23 Dec 2016 21:27:17 -0500 Received: by mail-ua0-f175.google.com with SMTP id 34so86361068uac.1 for ; Fri, 23 Dec 2016 18:26:58 -0800 (PST) In-Reply-To: <942b91f25a63b22ec4946378a1fffe78d655cf18.1482545792.git.luto@kernel.org> Sender: linux-crypto-owner@vger.kernel.org List-ID: On Fri, Dec 23, 2016 at 6:22 PM, Andy Lutomirski wrote: > There are some pieecs of kernel code that want to compute SHA256 > directly without going through the crypto core. Adjust the exported > API to decouple it from the crypto core. > > I suspect this will very slightly speed up the SHA256 shash operations > as well by reducing the amount of indirection involved. > I should also mention: there's a nice potential cleanup that's possible on top of this. Currently, most of the accelerated SHA256 implementations just swap out the block function. Another approach to enabling this would be to restructure sha256_update along the lines of: sha256_block_fn_t fn = arch_sha256_block_fn(len); sha256_base_do_update(sctx, data, len, arch_sha256_block_fn(len)); The idea being that arch code can decide whether to use an accelerated block function based on context (x86, for example, can't always use xmm regs) and length (on x86, using the accelerated versions for short digests is very slow due to the state save/restore that happens) and then the core code can just use it. This would allow a lot of the boilerplate that this patch was forced to modify to be deleted outright. --Andy