linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pascal Van Leeuwen <pvanleeuwen@verimatrix.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: RE: ghash
Date: Fri, 19 Jul 2019 19:26:02 +0000	[thread overview]
Message-ID: <MN2PR20MB297309BE544695C1B7B3CB21CACB0@MN2PR20MB2973.namprd20.prod.outlook.com> (raw)
In-Reply-To: <20190719161606.GA1422@gmail.com>

> -----Original Message-----
> From: linux-crypto-owner@vger.kernel.org <linux-crypto-owner@vger.kernel.org> On Behalf Of Eric Biggers
> Sent: Friday, July 19, 2019 6:16 PM
> To: Pascal Van Leeuwen <pvanleeuwen@verimatrix.com>
> Cc: linux-crypto@vger.kernel.org; Herbert Xu <herbert@gondor.apana.org.au>; davem@davemloft.net
> Subject: Re: ghash
> 
> On Fri, Jul 19, 2019 at 02:05:01PM +0000, Pascal Van Leeuwen wrote:
> > Hi,
> >
> > While implementing GHASH support for the inside-secure driver and wondering why I couldn't get
> > the test vectors to pass I have come to the conclusion that ghash-generic.c actually does *not*
> > implement GHASH at all. It merely implements the underlying chained GF multiplication, which,
> > I understand, is convenient as a building block for e.g. aes-gcm but is is NOT the full GHASH.
> > Most importantly, it does NOT actually close the hash, so you can trivially add more data to the
> > authenticated block (i.e. the resulting output cannot be used directly without external closing)
> >
> > GHASH is defined as GHASH(H,A,C) whereby you do this chained GF multiply on a block of AAD
> > data padded to 16 byte alignment with zeroes, followed by a block of ciphertext padded to 16
> > byte alignment with zeroes, followed by a block that contains both AAD and cipher length.
> >
> > See also https://en.wikipedia.org/wiki/Galois/Counter_Mode
> >
> > Regards,
> > Pascal van Leeuwen
> > Silicon IP Architect, Multi-Protocol Engines @ Verimatrix
> > www.insidesecure.com
> >
> 
> Yes that's correct.  The hash APIs don't support multi-argument hashes, so
> there's no natural way for it to be "full GHASH".  So it relies on the caller to
> format the AAD and ciphertext into a single stream.  IMO it really should be
> called something like "ghash_core".
> 
> Do you have some question or suggestion, or was this just an observation?
> 
Well, considering it's pretending to be GHASH I was more less considering this a bug report ...

There's the inherent danger that someone not aware of the actual implementation tries to
use it as some efficient (e.g. due to instruction set support) secure authentication function.
Which, without proper external data formatting, it's surely not in its current form. This is 
not something you will actually notice when just using it locally for something (until
someone actually breaks it).

And then there was the issue of wanting the offload it to hardware, but that's kind of hard
if the software implementation does not follow the spec where the hardware does ...

I think more care should be taken with the algorithm naming - if it has a certain name, 
you expect it to follow the matching specification (fully). I have already identified 2 cases 
now (xts and ghash) where that is not actually the case.

Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Verimatrix
www.insidesecure.com

  reply	other threads:[~2019-07-19 19:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 14:05 ghash Pascal Van Leeuwen
2019-07-19 16:16 ` ghash Eric Biggers
2019-07-19 19:26   ` Pascal Van Leeuwen [this message]
2019-07-19 19:56     ` ghash Eric Biggers
2019-07-19 20:49       ` ghash Pascal Van Leeuwen
2019-07-19 21:48         ` ghash Eric Biggers
2019-07-19 22:35           ` ghash Eric Biggers
2019-07-19 23:25             ` ghash Pascal Van Leeuwen
2019-07-19 23:09           ` ghash Pascal Van Leeuwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR20MB297309BE544695C1B7B3CB21CACB0@MN2PR20MB2973.namprd20.prod.outlook.com \
    --to=pvanleeuwen@verimatrix.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).