All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Pascal Van Leeuwen <pvanleeuwen@insidesecure.com>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>
Subject: Re: another testmgr question
Date: Thu, 23 May 2019 13:05:59 -0700	[thread overview]
Message-ID: <20190523200557.GA248378@gmail.com> (raw)
In-Reply-To: <AM6PR09MB3523749B0306103E8D2D8315D2010@AM6PR09MB3523.eurprd09.prod.outlook.com>

On Thu, May 23, 2019 at 01:07:25PM +0000, Pascal Van Leeuwen wrote:
> Eric,
>
> I'm running into some trouble with some random vectors that do *zero*
> length operations. Now you can go all formal about how the API does
> not explictly disallow this, but how much sense does it really make
> to essentially encrypt, hash or authenticate absolutely *nothing*?
>
> It makes so little sense that we never bothered to support it in any
> of our hardware developed over the past two decades ... and no
> customer has ever complained about this, to the best of my knowledge.
>
> Can't you just remove those zero length tests?
>

For hashes this is absolutely a valid case.  Try this:

$ touch file
$ sha256sum file
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  file

That shows the SHA-256 digest of the empty message.

For AEADs it's a valid case too.  You still get an authenticated ciphertext even
if the plaintext and/or AAD are empty, telling you that the (plaintext, AAD)
pair is authentically from someone with the key.

It's really only skciphers (length preserving encryption) where it's
questionable, since for those an empty input can only map to an empty output.

Regardless of what we do, I think it's really important that the behavior is
*consistent*, so users see the same behavior no matter what implementation of
the algorithm is used.

Allowing empty messages works out naturally for most skcipher implementations,
and it also conceptually simplifies the length restrictions of the API (e.g. for
most block cipher modes: just need nbytes % blocksize == 0, as opposed to that
*and* nbytes != 0).  So that seems to be how we ended up with it.

If we do change this, IMO we need to make it the behavior for all
implementations, not make it implementation-defined.

Note that it's not necessary that your *hardware* supports empty messages, since
you can simply do this in the driver instead:

	if (req->cryptlen == 0)
		return 0;

- Eric

  reply	other threads:[~2019-05-23 20:06 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AM6PR09MB3523CED0B1587FCBDE4095A0D2010@AM6PR09MB3523.eurprd09.prod.outlook.com>
     [not found] ` <20190523185833.GA243994@google.com>
2019-05-23 19:32   ` another testmgr question Pascal Van Leeuwen
2019-05-23 20:05     ` Eric Biggers [this message]
2019-05-23 21:43       ` Pascal Van Leeuwen
2019-05-23 23:48         ` Eric Biggers
2019-05-24  8:44           ` Pascal Van Leeuwen
2019-05-24  8:46             ` Christophe Leroy
2019-05-24  8:49               ` Jeffrey Walton
2019-05-24  9:42                 ` Pascal Van Leeuwen
2019-05-24  9:21               ` Pascal Van Leeuwen
2019-05-24  9:25                 ` Ard Biesheuvel
2019-05-24  9:34                   ` Pascal Van Leeuwen
2019-05-24  9:45                     ` Ard Biesheuvel
2019-05-24  9:57                       ` Pascal Van Leeuwen
2019-05-24 11:09                         ` Ard Biesheuvel
2019-05-27  9:52                           ` Pascal Van Leeuwen
2019-05-24 10:13                       ` Pascal Van Leeuwen
2019-05-24 10:43                         ` Kamil Konieczny
2019-05-24 10:54                           ` Christophe Leroy
2019-05-27  9:44                       ` Pascal Van Leeuwen
2019-05-27  9:49                         ` Ard Biesheuvel
2019-05-27 10:04                           ` Pascal Van Leeuwen
2019-05-27 10:28                             ` Ard Biesheuvel
2019-05-27 10:43                               ` Pascal Van Leeuwen
2019-05-27 10:57                                 ` Ard Biesheuvel
2019-05-27 12:22                                   ` Pascal Van Leeuwen
2019-05-27 14:59                                     ` Ard Biesheuvel
2019-05-27 15:56                                       ` Pascal Van Leeuwen
2019-05-27 16:21                                         ` Ard Biesheuvel
2019-05-27 20:15                                           ` Pascal Van Leeuwen
2019-05-27 12:41                                   ` Pascal Van Leeuwen
2019-05-27 14:45                                     ` Ard Biesheuvel
2019-05-27 15:16                                       ` Pascal Van Leeuwen
2019-05-27 15:24                                         ` Ard Biesheuvel
2019-05-27 20:46                                           ` Pascal Van Leeuwen
2019-05-25  1:22                   ` Eric Biggers
2019-05-27  9:55                     ` Pascal Van Leeuwen
2019-05-24  9:27                 ` Stephan Mueller
2019-05-24  5:24         ` Ard Biesheuvel
2019-05-24  7:04           ` Kamil Konieczny
2019-05-24  7:47           ` Pascal Van Leeuwen
2019-05-24  9:15             ` Ard Biesheuvel
2019-05-24  9:28               ` Pascal Van Leeuwen
2019-05-24  6:21         ` Christophe Leroy
2019-05-24  8:04           ` Pascal Van Leeuwen
2019-05-24  6:14       ` Jeffrey Walton
2019-05-24  8:00         ` 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=20190523200557.GA248378@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=pvanleeuwen@insidesecure.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.