Re: Possible issue with new inauthentic AEAD in extended crypto tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Dienstag, 28. Januar 2020, 03:34:55 CET schrieb Eric Biggers:

Hi Eric,

> On Mon, Jan 27, 2020 at 10:04:26AM +0200, Gilad Ben-Yossef wrote:
> > When both vec->alen and vec->plen are 0, which can happen as
> > generate_random_bytes will happily generate  zero length from time to
> > time,
> > we seem to be getting a scatterlist with the first entry (as well as
> > the 2nd) being a NULL.
> > 
> > This seems to violate the words of wisdom from aead.h and much more
> > important to me crashes the ccree driver :-)
> > 
> > Is there anything I am missing or is this a valid concern?
> 
> My understanding is that all crypto API functions that take scatterlists
> only forbid zero-length scatterlist elements in the part of the scatterlist
> that's actually passed to the API call.  The input to these functions is
> never simply a scatterlist, but rather a (scatterlist, length) pair. 
> Algorithms shouldn't look beyond 'length', so in the case of 'length == 0',
> they shouldn't look at the scatterlist at all -- which may be just a NULL
> pointer.
> 
> If that's the case, there's no problem with this test code.

I agree with your assessment. Not only when looking at cipher or template 
implementations, but also when looking at the scatterwalk API the SGL length 
field is processed first. If the length field is insufficient then the SGL is 
not processed.
> 
> I'm not sure the comment in aead.h is relevant here.  It sounds like it's
> warning about not providing an empty scatterlist element for the AAD when
> it's followed by a nonempty scatterlist element for the plaintext.  I'm not
> sure it's meant to also cover the case where both are empty.

The statement here (and maybe it could be updated) refers to a valid SGL with 
a size > 0, but where the first SGL entry points to a NULL buffer. This is an 
invalid use of an SGL.

Specifically for AEAD, the SGL must have the form of (assoc data || 
plaintext). As the AAD is not required for a successful cipher operation, the 
caller of the crypto API must guarantee the AAD is either non-NULL or the SGL 
must start with the plaintext as the first entry.
> 
> Herbert and Stephan, any thoughts on what was intended?
> 
> - Eric



Ciao
Stephan





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux