New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: fix default encoding of LazyTransform #8611

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@lmoe
Contributor

lmoe commented Sep 17, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto

Description of change

Change the default encoding from latin1 to utf8
and extend the test-crypto tests.

Show outdated Hide outdated test/parallel/test-crypto.js

@zvictor zvictor referenced this pull request Sep 17, 2016

Closed

crypto: fix default encoding of LazyTransform [2] #8624

3 of 3 tasks complete
@addaleax

Looking good so far, thanks for doing this!

/cc @indutny @mscdex ?

Show outdated Hide outdated test/parallel/test-crypto.js
Show outdated Hide outdated test/parallel/test-crypto.js
@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Sep 17, 2016

Member

Also, I’ve tentatively labelled this as semver-major. It aligns the behaviour with our docs, so whether this is actually semver-major is up for debate.

Member

addaleax commented Sep 17, 2016

Also, I’ve tentatively labelled this as semver-major. It aligns the behaviour with our docs, so whether this is actually semver-major is up for debate.

@Fishrock123

This comment has been minimized.

Show comment
Hide comment
@Fishrock123

Fishrock123 Sep 17, 2016

Member

fix default encoding of LazyTransform

I'm not clear on what this fixes? Is there an issue? If not could we please get a description in the commit message? :D

Member

Fishrock123 commented Sep 17, 2016

fix default encoding of LazyTransform

I'm not clear on what this fixes? Is there an issue? If not could we please get a description in the commit message? :D

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Sep 17, 2016

Member

I'm not clear on what this fixes? Is there an issue? If not could we please get a description in the commit message? :D

Not really, I just noticed this while going through or code base. There’s #5522 and #5500, which changed the default encoding for strings that are passed to crypto functions to utf8, but only did so for the non-streaming API… that makes .update() and .write() behave weirdly incongruently. I assumed that to be an oversight, and if I understood @indutny correctly today, he agrees.

A bit on that would be cool for the commit message, yes.

Member

addaleax commented Sep 17, 2016

I'm not clear on what this fixes? Is there an issue? If not could we please get a description in the commit message? :D

Not really, I just noticed this while going through or code base. There’s #5522 and #5500, which changed the default encoding for strings that are passed to crypto functions to utf8, but only did so for the non-streaming API… that makes .update() and .write() behave weirdly incongruently. I assumed that to be an oversight, and if I understood @indutny correctly today, he agrees.

A bit on that would be cool for the commit message, yes.

@addaleax

LGTM

if (!this._options || !this._options.defaultEncoding) {
this._writableState.defaultEncoding = crypto.DEFAULT_ENCODING;
}

This comment has been minimized.

@yorkie

yorkie Sep 22, 2016

Member

The this._options.defaultEncoding is not used yet :(

@yorkie

yorkie Sep 22, 2016

Member

The this._options.defaultEncoding is not used yet :(

This comment has been minimized.

@lmoe

lmoe Sep 28, 2016

Contributor

It seems to be working for me though.
I will look into this near the weekend.

@lmoe

lmoe Sep 28, 2016

Contributor

It seems to be working for me though.
I will look into this near the weekend.

@jasnell

LGTM with green CI.

@addaleax

This comment has been minimized.

Show comment
Hide comment
Member

addaleax commented Sep 30, 2016

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Oct 6, 2016

Member

@nodejs/crypto ... any objections on this?

Member

jasnell commented Oct 6, 2016

@nodejs/crypto ... any objections on this?

@indutny

One style nit, otherwise LGTM

@indutny

LGTM, if CI is green.

@lmoe

This comment has been minimized.

Show comment
Hide comment
@lmoe

lmoe Jan 5, 2017

Contributor

@indutny @addaleax
What should I do about this merge conflict? Just to know it in the future. It seems it occurred a month later or so. Should I resolve this conflict on my own, or will your merge tools handle it on their own when you make a release?

Contributor

lmoe commented Jan 5, 2017

@indutny @addaleax
What should I do about this merge conflict? Just to know it in the future. It seems it occurred a month later or so. Should I resolve this conflict on my own, or will your merge tools handle it on their own when you make a release?

@sam-github

This comment has been minimized.

Show comment
Hide comment
@sam-github

sam-github Jan 9, 2017

Member

@lmoe Please resolve and re-push, it distributes the maintenance work, and if there are any complexities, we may ask you to do so anyhow.

Member

sam-github commented Jan 9, 2017

@lmoe Please resolve and re-push, it distributes the maintenance work, and if there are any complexities, we may ask you to do so anyhow.

@addaleax addaleax added this to the 8.0.0 milestone Feb 3, 2017

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Feb 3, 2017

Member

bump @lmoe – Could you rebase this against master to resolve the conflict?

Member

addaleax commented Feb 3, 2017

bump @lmoe – Could you rebase this against master to resolve the conflict?

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Feb 15, 2017

Member

Ping @lmoe again? Otherwise I’ll pick this up in the next couple of days.

Member

addaleax commented Feb 15, 2017

Ping @lmoe again? Otherwise I’ll pick this up in the next couple of days.

lmoe added some commits Sep 17, 2016

crypto: fix default encoding of LazyTransform
Change the default encoding from latin1 to utf8
and extend the test-crypto tests.
crypto: fix default encoding of LazyTransform
PullRequest #5522 and #5500 described the change
of the default encoding into UTF8 in crypto functions.

This however was only changed for the non-streaming API.
The streaming API still used binary as the default encoding.

This commit will change the default streaming API encoding to UTF8
to make both APIs behave the same.

It will also add tests to validate the behavior.
@lmoe

This comment has been minimized.

Show comment
Hide comment
@lmoe

lmoe Feb 16, 2017

Contributor

@addaleax Sorry, I totally forgot about the mail. I hope the branch is corrected now.

Contributor

lmoe commented Feb 16, 2017

@addaleax Sorry, I totally forgot about the mail. I hope the branch is corrected now.

@addaleax

Thanks, still looks good! Going to land this soon.

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Feb 16, 2017

Member

CI: https://ci.nodejs.org/job/node-test-commit/7947/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/580/

Edit: The electron-prebuilt failure is real and related, I’m reaching out and fixing it.
Edit²: malept/sumchecker#5

Member

addaleax commented Feb 16, 2017

CI: https://ci.nodejs.org/job/node-test-commit/7947/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/580/

Edit: The electron-prebuilt failure is real and related, I’m reaching out and fixing it.
Edit²: malept/sumchecker#5

addaleax added a commit to addaleax/sumchecker that referenced this pull request Feb 16, 2017

Explicitly set default encoding in createHash()
Up until now, the default encoding for this is `binary`, but
this is scheduled to change in Node 8. Since this module is
currently always passing string input to the `Hash` object,
it needs to account for that.

A better fix would likely involve dropping all strings handling
and treating binary data using Buffer objects, but I kept
this change minimal to avoid any breakage.

Refs: nodejs/node#8611

addaleax added a commit to addaleax/sumchecker that referenced this pull request Feb 21, 2017

Explicitly set default encoding in createHash()
Up until now, the default encoding for this is `binary`, but
this is scheduled to change in Node 8. Since this module is
currently always passing string input to the `Hash` object,
it needs to account for that.

A better fix would likely involve dropping all strings handling
and treating binary data using Buffer objects, but I kept
this change minimal to avoid any breakage.

Refs: nodejs/node#8611
@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Mar 10, 2017

Member

Fresh CI:

CI: https://ci.nodejs.org/job/node-test-commit/8359/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/637/
Edit: New CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/638/ (should be a bit better since the electron-prebuilt failure should be fixed now)

I would like to land this unless any new surprises show up. The electron-prebuilt failure is just waiting on a dependency update, and we should definitely have this in Node 8.

(why? because:)
'use strict';
const { createHash } = require('crypto');

const hash1 = createHash('sha256');
hash1.on('data', out => console.log('hash1 => ', out.toString('hex')));
hash1.end('💩');

const hash2 = createHash('sha256');
hash2.on('data', out => console.log('hash2 => ', out.toString('hex')));
hash2.end('⨽⪩');
// Surprise! Different input, same hash.
Member

addaleax commented Mar 10, 2017

Fresh CI:

CI: https://ci.nodejs.org/job/node-test-commit/8359/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/637/
Edit: New CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/638/ (should be a bit better since the electron-prebuilt failure should be fixed now)

I would like to land this unless any new surprises show up. The electron-prebuilt failure is just waiting on a dependency update, and we should definitely have this in Node 8.

(why? because:)
'use strict';
const { createHash } = require('crypto');

const hash1 = createHash('sha256');
hash1.on('data', out => console.log('hash1 => ', out.toString('hex')));
hash1.end('💩');

const hash2 = createHash('sha256');
hash2.on('data', out => console.log('hash2 => ', out.toString('hex')));
hash2.end('⨽⪩');
// Surprise! Different input, same hash.
@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Mar 11, 2017

Member

CITGM failures seem to be known/unrelated. 🎉

Landed in 443691a, thanks for the PR and for bearing with our process!

Member

addaleax commented Mar 11, 2017

CITGM failures seem to be known/unrelated. 🎉

Landed in 443691a, thanks for the PR and for bearing with our process!

@addaleax addaleax closed this Mar 11, 2017

addaleax added a commit that referenced this pull request Mar 11, 2017

crypto: fix default encoding of LazyTransform
PullRequest #5522 and #5500 described the change
of the default encoding into UTF8 in crypto functions.

This however was only changed for the non-streaming API.
The streaming API still used binary as the default encoding.

This commit will change the default streaming API encoding to UTF8
to make both APIs behave the same.

It will also add tests to validate the behavior.

Refs: #5522
Refs: #5500
PR-URL: #8611
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

jungx098 added a commit to jungx098/node that referenced this pull request Mar 21, 2017

crypto: fix default encoding of LazyTransform
PullRequest #5522 and #5500 described the change
of the default encoding into UTF8 in crypto functions.

This however was only changed for the non-streaming API.
The streaming API still used binary as the default encoding.

This commit will change the default streaming API encoding to UTF8
to make both APIs behave the same.

It will also add tests to validate the behavior.

Refs: nodejs#5522
Refs: nodejs#5500
PR-URL: nodejs#8611
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@jasnell jasnell referenced this pull request Apr 4, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment