Skip to content
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

use hash-base #36

Merged
merged 5 commits into from
Nov 10, 2016
Merged

use hash-base #36

merged 5 commits into from
Nov 10, 2016

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Apr 14, 2016

Ref #25


- SHA (SHA-0) -- **legacy, no not use in new systems**
- SHA-1 -- **legacy, no not use in new systems**
Copy link
Member

Choose a reason for hiding this comment

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

do not, not no not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks.
I doubted about this phrase, but decided not change it when edited README.md

var inherits = require('inherits')
var SHA = require('./sha')

var ARRAY80 = new Array(80)
Copy link
Member

@dcousens dcousens Apr 18, 2016

Choose a reason for hiding this comment

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

Maybe just call this var W = new Array(80), and let it be super clear that it is a global used by _getExpandedMessage [by moving it to just above that declaration]

@dcousens
Copy link
Member

utACK e6e054c,

@fanatid fanatid force-pushed the feature/hash-base branch from e6e054c to 7ba67d6 Compare April 18, 2016 05:27
@fanatid fanatid force-pushed the feature/hash-base branch from 7ba67d6 to 7d049ec Compare April 18, 2016 05:30
@fanatid
Copy link
Contributor Author

fanatid commented Apr 18, 2016

@dcousens updated

@dcousens
Copy link
Member

Published as + [email protected]

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

Why did you move the files to lib/?
Seems a bit unnecessary IMHO.

Also, I personally prefer functions before use, but hey, its still standard so whatever.


SHA.prototype._expandMessage = function (W) {
for (var i = 0; i < 16; ++i) W[i] = this._block.readInt32BE(i * 4)
for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
Copy link
Member

@dcousens dcousens Nov 10, 2016

Choose a reason for hiding this comment

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

Where did this come from?

var e = this._e | 0

for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this. All good 👍

}
} else {
usage()
}
Copy link
Member

Choose a reason for hiding this comment

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

Ah, wait.
This is a breaking change.

Can you please re-add so I can release a fixed patch?

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

Why did you remove .bin... it might be used by people.

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

Re-added bin.js, released as v2.4.7
(unpublished v2.4.6)

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

@fanatid please keep PRs atomic.

Don't remove things in the same PR resolving something as useful as #25.

exports.sha224 = require('./sha224')
exports.sha256 = require('./sha256')
exports.sha384 = require('./sha384')
exports.sha512 = require('./sha512')
Copy link
Member

Choose a reason for hiding this comment

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

Sigh

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

@fanatid also please mark things as major bump if they are.

I spent most of my review time looking over the math changes/refactors instead of focusing on the exports... apologies all (as they weren't flagged as changed).

Unpublished v2.4.7.

@dcousens
Copy link
Member

@fanatid can you please re-add the tests, un-change the exports to avoid breaking backwards compatibility and then submit that PR, so we can release this as a non-breaking change?

@fanatid
Copy link
Contributor Author

fanatid commented Nov 10, 2016

@dcousens please revert all change and unpublish, I can't add tests/refactor PR right now.
I mentioned in #39 that this PR need major bump.
Sorry for not atomic commits. We need merge such big PR carefully.

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

@fanatid I already unpublished the changes.
The change need not be reverted, it just needs to be fixed to be non-breaking 👍

I mentioned in #39 that this PR need major bump.

I didn't see that until after.

@fanatid
Copy link
Contributor Author

fanatid commented Nov 10, 2016

I think hash-base makes breaking changes anyway.
utf8 instead binary by default for example

@dcousens
Copy link
Member

@fanatid not willing to be backwards compatible in hash-base?

@fanatid
Copy link
Contributor Author

fanatid commented Nov 10, 2016

are you think that this necessary? 0.12 was last version of node who uses binary by default

@gethinwebster
Copy link

Just to note, as others may come across this as well, this update broke some of our projects which use this module, but don't use browserify. hash-base pulls in a new dependency of stream, which wasn't previously required, and although it's provided as a shim by default in browserify, other packagers vary.

@fanatid
Copy link
Contributor Author

fanatid commented Nov 10, 2016

@gethinwebster sorry hear this, but is not 2.4.7 fix hash-base changes?

@gethinwebster
Copy link

gethinwebster commented Nov 10, 2016

It doesn't seem to - looks like 2.4.7 still uses hash-base unless I'm missing something?

@fanatid
Copy link
Contributor Author

fanatid commented Nov 10, 2016

ah, I see :(
@dcousens what you think about publish 2.4.8 equal to old 2.4.62.4.5 and unpublish 2.4.7?

@gethinwebster
Copy link

2.4.5 is the latest version that works correctly for me

@dominictarr
Copy link
Contributor

Ah, so moving the files into lib was a breaking change.
I was using it like this:
https://github.com/dominictarr/sodium-browserify-tweetnacl/blob/master/index.js#L3

and so I have lots of stuff that is broken now. If it goes into lib it needs a major semver bump

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

Agreed, I commonly use it like sha.js/sha256 as well.
Will need to revert lib/ as well.

  • Revert lib/
  • Revert export uppercasing
  • Revert bin.js removal

@dcousens
Copy link
Member

dcousens commented Nov 10, 2016

Unpublish wasn't working as expected for v2.4.7.
Reverted all changes and published as v2.4.8.

@dominictarr @fanatid please verify.

Sorry for the screw-around @gethinwebster.

@gethinwebster
Copy link

Thanks for the really quick response on this, great work @dcousens @fanatid

@dominictarr
Copy link
Contributor

yup, working again.

@dcousens
Copy link
Member

@fanatid please submit atomic PRs for the changes 👍

@dcousens
Copy link
Member

@fanatid what were the blocks here?
I think we could default to utf8 over binary using the same trick we did in pbkdf2?

@larcho
Copy link

larcho commented Jun 26, 2023

I know this is a very very VERY old PR, but I'd like to double check something. I actually do like this version because it uses readable-stream from hash-base instead of standard Browser/Node Stream. React Native does not include Stream.
I'm aware of the rn-nodeify, but I'm updating a library that depends on the crypto library to not require "nodeification".
Is there any reason I should not use this version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants