Return-Path: Received: from mail-it1-f194.google.com ([209.85.166.194]:35243 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728672AbeJWBhB (ORCPT ); Mon, 22 Oct 2018 21:37:01 -0400 Received: by mail-it1-f194.google.com with SMTP id p64-v6so13536716itp.0 for ; Mon, 22 Oct 2018 10:17:38 -0700 (PDT) MIME-Version: 1.0 References: <20181015175424.97147-1-ebiggers@kernel.org> <20181019190411.GB246441@gmail.com> <20181021222341.GA742@sol.localdomain> In-Reply-To: From: Paul Crowley Date: Mon, 22 Oct 2018 10:17:26 -0700 Message-ID: Subject: Re: [RFC PATCH v2 00/12] crypto: Adiantum support To: Jason@zx2c4.com Cc: ebiggers@kernel.org, linux-crypto@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Herbert Xu , Greg Kaiser , Michael Halcrow , samuel.c.p.neves@gmail.com, tomer.ashur@esat.kuleuven.be Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org List-ID: On Sun, 21 Oct 2018 at 15:52, Jason A. Donenfeld wrote: > > [1] Originally we were going to define Adiantum's hash function to be > > Poly1305(message_length || tweak_length || tweak || NH(message)), which > > would have made it desirable to export the Poly1305 state before NH, so that > > it could be imported for the second hash step to avoid redundantly hashing > > the message length and tweak. But later we changed it to > > Poly1305(message_length || tweak) + Poly1305(NH(message)). > > Out of curiosity, why this change? With the old system, Eric ended up implementing a function which took "message_length || tweak_length || tweak || message" as input and *parsed out* the lengths in the first 16 bytes to know when to start applying NH. That struck me as not nice at all, and we worked together to design something that fitted more naturally into the way that crypto is done in the kernel. With this change, the part that can be kept in common between the two hashing stages is cleanly separated from the part that will be different, and the Poly1305(NH(message)) construction is a relatively clean thing by itself to be part of the Linux kernel, though by itself it is only epsilon-almost-delta-universal over equal-length inputs so it has to be combined with something else to handle varying-length inputs. This is not too dissimilar from the caveats around GHASH which is also part of the kernel.