Skip to content

crypto: add support for chacha20-poly1305 for AEAD - #24081

Merged
refack merged 1 commit into
nodejs:masterfrom
chux0519:chacha
Nov 7, 2018
Merged

crypto: add support for chacha20-poly1305 for AEAD#24081
refack merged 1 commit into
nodejs:masterfrom
chux0519:chacha

Conversation

@chux0519

@chux0519chux0519 commented Nov 4, 2018

Copy link
Copy Markdown
Contributor

Openssl support AEAD_CHACHA20_POLY1305(rfc7539) since 1.1.

Fixes: #24080
Refs: https://tools.ietf.org/html/rfc7539

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Nov 4, 2018
@targos

Copy link
Copy Markdown
Member

@nodejs/crypto

Comment threaddoc/api/crypto.md Outdated
Comment threadsrc/node_crypto.cc Outdated
Comment threadsrc/node_crypto.cc Outdated
Comment threadsrc/node_crypto.cc Outdated
@refack

Copy link
Copy Markdown
Contributor

Hello @chux0519 welcome, and thank you for your contribution 🥇
If you are not familiar with our review and landing process, it's covered in CONTRIBUTING.md

P.S. If you have any question you can also feel free to contact me directly.

@chux0519

Copy link
Copy Markdown
ContributorAuthor

Hello @chux0519 welcome, and thank you for your contribution 🥇
If you are not familiar with our review and landing process, it's covered in CONTRIBUTING.md

P.S. If you have any question you can also feel free to contact me directly.

thx, I will change my code to follow that guide

@chux0519

Copy link
Copy Markdown
ContributorAuthor

It seems make lint-md can not check the 80 characters limit.

@ryzokuken

Copy link
Copy Markdown
Contributor

@chux0519lint-md lints the markdown in the codebase. It is geared towards doc-only contributions.

@chux0519

Copy link
Copy Markdown
ContributorAuthor

@chux0519lint-md lints the markdown in the codebase. It is geared towards doc-only contributions.

thx, i see

@Trott

Trott commented Nov 5, 2018

Copy link
Copy Markdown
Member

It seems make lint-md can not check the 80 characters limit.

@chux0519 It does not currently check that line lengths are 80 characters or less, although I've just opened a PR to implement that. #24094

@chux0519

Copy link
Copy Markdown
ContributorAuthor

#24094

It would be great to have that, And will avoid many comments in reviews causing by doc lint like this one above.

Comment threaddoc/api/crypto.md Outdated
Comment threadsrc/node_crypto.cc Outdated
@refack

refack commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

After rebasing to current master, Travis should not fail anymore for lint in commit message - #23739

@sam-githubsam-github left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Comment threadsrc/node_crypto.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would overloading IsSupportedAuthenticatedMode() to also accept the EVP_CIPHER_CTX type make sense? It would shorten these 3 repeated calls.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, It's a good idea, I will add one more IsSupportedAuthenticatedMode to take the EVP_CIPHER_CTX as param

Comment threadsrc/node_crypto.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment here to state that chacha20-poly1305 is an AEAD cipher, but that its mode of 0 doesn't indicate that?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a comment to indicate it

@sam-github

Copy link
Copy Markdown
Contributor

@bnoordhuisbnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM with a request and a suggestion.

Comment threadsrc/node_crypto.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a CHECK here that verifies the cipher is one of these?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis maybe the comment can just be removed? The function is protected by a CHECK(IsAuthenticatedMode()); already, so we know this is an AEAD cipher, and what's happening here is that GCM has some special requirements on tag length that aren't shared by any other AEAD ciphers.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for comment, will remove it

Comment threadsrc/node_crypto.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: should go on the previous line; i.e., no line break after the paren. The next line should have 4 spaces of indent.

If it gets too unwieldy / doesn't fit in 80 columns, assign the cipher to a variable first:

constEVP_CIPHER* cipher = EVP_CIPHER_CTX_cipher(ctx_.get());
if (kind_ == kDecipher && IsSupportedAuthenticatedMode(cipher)) {
// ...
}

(Arguably a good idea in any case; easier to read, IMO.)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I will fix this

Comment threadtest/fixtures/aead-vectors.js Outdated
@refack

refack commented Nov 7, 2018

Copy link
Copy Markdown
Contributor

Resume: https://ci.nodejs.org/job/node-test-commit/22946/

P.S. I'm self-assigned this so I'll get notifications from Github, and so that I will not lose track of it and help steward it to completion.

@refackrefack added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 7, 2018
@refackrefack self-assigned this Nov 7, 2018
@refackrefack removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 7, 2018

@tniessentniessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but it would be best to explicitely mention this change in the changes section of createCipheriv and createDecipheriv (in doc/api/crypto.md) like this:

 - version: REPLACEMEpr-url: https://github.com/nodejs/node/pull/24081description: The cipher `chacha20-poly1305` is now supported.

Could you add this to the top of the respective changes: metadata sections in doc/api/crypto.md? (Probably right above OCB support.)

@chux0519

Copy link
Copy Markdown
ContributorAuthor

@tniessen Of course, I have added them

Comment threaddoc/api/crypto.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- version: v12.0.0
- version: REPLACEME

Comment threaddoc/api/crypto.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- version: v12.0.0
- version: REPLACEME

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v10.14.0 right ? Sorry, I just used the ./out/Release/node -v

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not know yet in which actual release this will land, so instead we write REPLACEME and the value is changed when the release that includes this change is done.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I misunderstood the REPLACEMENT

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for being so patient.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are the one being patient! Thanks.

@targostargos added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 7, 2018
@targos

Copy link
Copy Markdown
Member

I assume this is semver-minor?

@tniessen

Copy link
Copy Markdown
Member

@targos I don't think we have been consistent about that in the past, I'd be okay with marking it semver-minor.

@tniessen

Copy link
Copy Markdown
Member

openSSL supports AEAD_CHACHA20_POLY1305(rfc7539) since 1.1.
PR-URL: nodejs#24081Fixes: nodejs#24080
Refs: https://tools.ietf.org/html/rfc7539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@refack
refack merged commit 5c59622 into nodejs:masterNov 7, 2018
@refack

Copy link
Copy Markdown
Contributor

Landed in 5c59622
Congratulations @chux0519 for GitHub promoting you from
image
to
image

BridgeAR pushed a commit that referenced this pull request Nov 14, 2018
openSSL supports AEAD_CHACHA20_POLY1305(rfc7539) since 1.1.
PR-URL: #24081Fixes: #24080
Refs: https://tools.ietf.org/html/rfc7539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@BridgeARBridgeAR mentioned this pull request Nov 14, 2018
kiyomizumia pushed a commit to kiyomizumia/node that referenced this pull request Nov 15, 2018
openSSL supports AEAD_CHACHA20_POLY1305(rfc7539) since 1.1.
PR-URL: nodejs#24081Fixes: nodejs#24080
Refs: https://tools.ietf.org/html/rfc7539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@rvagg

Copy link
Copy Markdown
Member

Hey @chux0519, thanks for contributing this! I wasn't even aware we didn't support it but it'll help us get closer to solid TLS1.3 support (eventually). You'll note that it's in 11.2.0 now btw.

@chux0519

Copy link
Copy Markdown
ContributorAuthor

Hey @chux0519, thanks for contributing this! I wasn't even aware we didn't support it but it'll help us get closer to solid TLS1.3 support (eventually). You'll note that it's in 11.2.0 now btw.

I'm happy to make this little contrubution to nodejs, thank your all guys' help during the PR process

@refackrefack removed their assignment Mar 11, 2019
@imcottonimcotton mentioned this pull request May 3, 2019
@tniessentniessen mentioned this pull request Oct 21, 2019
BethGriggs pushed a commit that referenced this pull request Oct 21, 2019
openSSL supports AEAD_CHACHA20_POLY1305(rfc7539) since 1.1.
PR-URL: #24081Fixes: #24080
Refs: https://tools.ietf.org/html/rfc7539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
BethGriggs added a commit that referenced this pull request Oct 22, 2019
Notable changes:
* crypto:
* add support for chacha20-poly1305 for AEAD (chux0519)
#24081
* increase maxmem range from 32 to 53 bits (Tobias Nießen)
#28799
* deps:
* update npm to 6.11.3 (claudiahdz)
#29430
* upgrade openssl sources to 1.1.1d (Sam Roberts)
#29921
* dns:
* remove dns.promises experimental warning (cjihrig)
#26592
* fs:
* remove experimental warning for fs.promises (Anna Henningsen)
#26581
* http:
* makes response.writeHead return the response (Mark S. Everitt)
#25974
* http2:
* makes response.writeHead return the response (Mark S. Everitt)
#25974
* n-api:
* make func argument of napi\_create\_threadsafe\_function optional
(legendecas)
#27791
* mark version 5 N-APIs as stable (Gabriel Schulhof)
#29401
* implement date object (Jarrod Connolly)
#25917
* process:
* add --unhandled-rejections flag (Ruben Bridgewater)
#26599
* stream:
* implement Readable.from async iterator utility (Guy Bedford)
#27660
* make Symbol.asyncIterator support stable (Matteo Collina)
#26989
PR-URL: #29875
BethGriggs added a commit that referenced this pull request Oct 22, 2019
Notable changes:
* crypto:
* add support for chacha20-poly1305 for AEAD (chux0519)
#24081
* increase maxmem range from 32 to 53 bits (Tobias Nießen)
#28799
* deps:
* update npm to 6.11.3 (claudiahdz)
#29430
* upgrade openssl sources to 1.1.1d (Sam Roberts)
#29921
* dns:
* remove dns.promises experimental warning (cjihrig)
#26592
* fs:
* remove experimental warning for fs.promises (Anna Henningsen)
#26581
* http:
* makes response.writeHead return the response (Mark S. Everitt)
#25974
* http2:
* makes response.writeHead return the response (Mark S. Everitt)
#25974
* n-api:
* make func argument of napi\_create\_threadsafe\_function optional
(legendecas)
#27791
* mark version 5 N-APIs as stable (Gabriel Schulhof)
#29401
* implement date object (Jarrod Connolly)
#25917
* process:
* add --unhandled-rejections flag (Ruben Bridgewater)
#26599
* stream:
* implement Readable.from async iterator utility (Guy Bedford)
#27660
* make Symbol.asyncIterator support stable (Matteo Collina)
#26989
PR-URL: #29875
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.cryptoIssues and PRs related to the crypto subsystem.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AEAD_CHACHA20_POLY1305 support

12 participants

@chux0519@targos@refack@ryzokuken@Trott@sam-github@tniessen@rvagg@mscdex@bnoordhuis@BethGriggs@nodejs-github-bot