public inbox for nncp-devel@lists.cypherpunks.ru
Atom feed
From: Sergey Matveev <stargrave@stargrave•org>
To: nncp-devel@lists.cypherpunks.ru
Subject: Re: Avoiding double writes
Date: Tue, 2 Nov 2021 20:49:01 +0300	[thread overview]
Message-ID: <YYF6GtlRc56Az0co@stargrave.org> (raw)
In-Reply-To: <87sfweino1.fsf@complete.org>

[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]

*** John Goerzen [2021-11-02 10:26]:
>Yes, and for giving user output, the size of the encrypted packet could be
>used too.

Agreed.

>Yes, exactly.  This metadata could be as simple as a u32 indicating how much
>of the following block is actual data.  Any u32 value beneath 128K
>(including zero) would indicate we've reached EOF of the original data and
>everything past that should be authenticated but discarded, I think.

I assume something like that, indeed. Plus included size of the
padding/junk, to be sure that we received all of it, packet is not
stripped. We have got holidays soon, so I hope will implement that.

>Ahh, that makes sense.  I'm not all up on my crypto algorithms, but if I
>understand correctly, each encrypted block is authenticated with the BLAKE3
>hash of that block plus the unsigned portion of the header?  And since that
>portion of the header contains the public part of the session key, that
>prevents data injection attacks, right?

Mostly you are right. Each (128KiB and SIZE) block uses BLAKE3 hash of
the unsigned part of the header as an associated data, used as an
additional input to AEAD-encryption of the block. So each block is
"tied" to the context it is used with: exactly that sender, recipient
and ephemeral public key. And each block uses implicit increasing nonce
counter, so blocks can not be reordered, thrown away or injected. Blocks
can not be taken from another "context" (another encrypted packet),
because of associated data.

>So it would be possible with this streaming approach to still determine with
>certainty if we have received the entire file's data, and the correct data,
>by processing the hash and header for each block, right?

Do not understand you clear :-(. Yes, we can be sure if we have received
the whole data or not, by looking if we reached "final" payload block,
containing also the size of the padding.

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263  6422 AE1A 8109 E498 57EF

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-11-02 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 17:47 Avoiding double writes John Goerzen
2021-11-01 19:46 ` Sergey Matveev
2021-11-02  0:11   ` John Goerzen
2021-11-02 10:03     ` Sergey Matveev
2021-11-02 15:26       ` John Goerzen
2021-11-02 17:49         ` Sergey Matveev [this message]
2021-11-02 20:48         ` Sergey Matveev