openssl icon indicating copy to clipboard operation
openssl copied to clipboard

AEAD: XChaCha20-Poly1305

Open paragonie-scott opened this issue 7 years ago • 14 comments
trafficstars

The main difference between XChaCha20-Poly1305 and the original ChaCha20-Poly1305 is that the nonce size is 24 bytes instead of 8 bytes. The first 16 bytes of the nonce is used, along with the key, with HChaCha20 to derive a key, which is then used in ChaCha20-Poly1305.

The advantage of this extended-nonce variant is that you can use the same key for 2^96 messages before worrying about nonce reuse (the birthday bound), rather than 2^32 messages.

XChaCha20-Poly1305 is implemented in libsodium.

What would the steps be to get XChaCha20-Poly1305 considered for inclusion in OpenSSL for EVP encryption (i.e. for building application-layer cryptography protocols with OpenSSL)? Do I need to convince the IETF to bless it for inclusion in TLS first, even if that's presently a non-goal of my feature request?

paragonie-scott avatar Mar 05 '18 23:03 paragonie-scott

No, it doesn't have to be in TLS, but some external third-party has to review (and approve) this before we will consider it. And it seems highly doubtful that it will be done in time for the upcoming release.

richsalz avatar Mar 06 '18 00:03 richsalz

That's fine, I wasn't aware of an upcoming release and have no qualms about tabling its inclusion until the upcoming release has concluded. I just wanted to open the discussion about its inclusion now so, when it's reviewed/approved/ready, the developers who use OpenSSL have the chance to use an extended-nonce AEAD mode.

paragonie-scott avatar Mar 06 '18 00:03 paragonie-scott

Is it standardised? We only accept standardised crypto.

mattcaswell avatar Mar 06 '18 09:03 mattcaswell

@mattcaswell The CFRG has made it working group item, and an IETF RFC is expected in the near future.

paragonie-scott avatar Oct 23 '19 20:10 paragonie-scott

Nothing stops anyone from making a separate provider that provides this. In fact, there could be a separate project producing a provider with algorithms that haven't been accepted in the OpenSSL main source yet (and possibly never will). A little like, in the C++ universe, Boost is a set of C++ templates that haven't been accepted into the STL yet (and possibly never will)

levitte avatar Oct 24 '19 05:10 levitte

Is it standardised? We only accept standardised crypto.

The IETF now has an active Internet-Draft for this protocol: https://tools.ietf.org/html/draft-irtf-cfrg-xchacha-03 https://datatracker.ietf.org/doc/draft-irtf-cfrg-xchacha/

Does that meet this requirement so that this protocol can be considered to include in OpenSSL? Or would you require it to reach a final RFC first?

gnprice avatar Jun 10 '20 00:06 gnprice

It has to reach a final RFC first.

kaduk avatar Jun 10 '20 00:06 kaduk

It has to reach a final RFC first.

That wasn't the case for TLS 1.3.

richsalz avatar Jun 10 '20 02:06 richsalz

It has to reach a final RFC first.

That wasn't the case for TLS 1.3.

We held the release for the final RFC. Getting the code in earlier (and incrementally) was okay, because we knew in advance that we were going to hold the release for TLS 1.3.

kaduk avatar Jun 10 '20 02:06 kaduk

The key point is the work started well before the RFC was published, and your comment implied, at least to me, that nothing will start until the RFC is published which is not correct. (We also did some CMS update work IIRC)

richsalz avatar Jun 10 '20 02:06 richsalz

It is not going to be "included in OpenSSL" until the final RFC is published. (Not my decision, for what little it counts.) Whether it means anything to "consider" it beforehand is probably subjective...

kaduk avatar Jun 10 '20 02:06 kaduk

FYI for Go programmers watching this ticket: it's fairly straightforward to get fast* XChaCha20-Poly1305 by combining HChaCha20 from Go x/crypto with EVP_chacha20_poly1305 from OpenSSL.

If there is interest, I can make my implementation importable as a library.

* 5 x faster than x/crypto/chacha20poly1305 on armv7

rfjakob avatar Sep 10 '21 10:09 rfjakob

Hi @rfjakob Your approach is quite interesting, I was wondering if such approach would support streamed encryption/decryption. That is processing large files that wouldn't normally fit in RAM, whilst using Poly1305 to generate/verify authenticated tag.

tomekit avatar Jan 28 '23 17:01 tomekit

Looking at the diagram at https://pkg.go.dev/github.com/rfjakob/gocryptfs/v2/internal/stupidgcm#hdr-XChaCha20_Poly1305 again, I don't see why not.

On Sat, 28 Jan 2023, 18:31 Tomasz Raganowicz, @.***> wrote:

Hi @rfjakob https://github.com/rfjakob Your approach is quite interesting, I was wondering if such approach would support streamed encryption/decryption. That is processing large files that wouldn't normally fit in RAM, whilst using Poly1305 to generate/verify authenticated tag.

— Reply to this email directly, view it on GitHub https://github.com/openssl/openssl/issues/5523#issuecomment-1407446348, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACGA7ZAKYEWYCBRNT5WGG3WUVJW3ANCNFSM4ETXPTUQ . You are receiving this because you were mentioned.Message ID: @.***>

rfjakob avatar Jan 28 '23 17:01 rfjakob

Are there any updates on this?

smessmer avatar May 24 '23 19:05 smessmer

I do not think there is any official standard specifying XChaCha20-Poly1305 so there is no progress. I am going to close the PR. Please re-open or open a new issue if there is any official standard for this algorithm.

t8m avatar May 25 '23 12:05 t8m