Fixed incorrect result when first bit is 1 of bytes.

pull/22/head v0.7.1
Yi-Cyuan Chen 8 years ago
parent 6aed3e39c4
commit 241405d4fd

@ -1,2 +0,0 @@
/node_modules/
/tests/

3
.gitignore vendored

@ -1,2 +1,3 @@
/node_modules/ /node_modules/
/covreporter/ /coverage/
/.nyc_output/

@ -1,7 +1,7 @@
/node_modules/ /node_modules/
/covreporter/ /coverage/
/.nyc_output/
/tests/ /tests/
.covignore
.travis.yml .travis.yml
.npmignore .npmignore
bower.json bower.json

@ -4,8 +4,7 @@ node_js:
- "8.6.0" - "8.6.0"
before_install: before_install:
- npm install coveralls - npm install coveralls
- npm install mocha-lcov-reporter after_success: npm run coveralls
script: npm run-script coveralls
branches: branches:
only: only:
- master - master

@ -1,5 +1,9 @@
# Change Log # Change Log
## v0.7.1 / 2017-12-21
### Fixed
- incorrect result when first bit is 1 of bytes.
## v0.7.0 / 2017-11-19 ## v0.7.0 / 2017-11-19
### Added ### Added
- support HMAC. #8 - support HMAC. #8

@ -1,6 +1,6 @@
{ {
"name": "js-sha512", "name": "js-sha512",
"version": "0.7.0", "version": "0.7.1",
"main": ["src/sha512.js"], "main": ["src/sha512.js"],
"ignore": [ "ignore": [
"samples", "samples",

File diff suppressed because one or more lines are too long

1817
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,21 +1,21 @@
{ {
"name": "js-sha512", "name": "js-sha512",
"version": "0.7.0", "version": "0.7.1",
"description": "This is a simple SHA-512, SHA-384, SHA-512/224, SHA-512/256 hash functions for JavaScript supports UTF-8 encoding.", "description": "This is a simple SHA-512, SHA-384, SHA-512/224, SHA-512/256 hash functions for JavaScript supports UTF-8 encoding.",
"main": "src/sha512.js", "main": "src/sha512.js",
"devDependencies": { "devDependencies": {
"expect.js": "~0.3.1", "expect.js": "~0.3.1",
"jscoverage": "^0.6.0",
"mocha": "~2.3.4", "mocha": "~2.3.4",
"nyc": "^11.3.0",
"requirejs": "^2.1.22", "requirejs": "^2.1.22",
"uglifyjs": "^2.4.11", "uglify-js": "^3.1.9",
"webworker-threads": "^0.7.11" "webworker-threads": "^0.7.11"
}, },
"scripts": { "scripts": {
"test": "mocha tests/node-test.js -r jscoverage", "test": "nyc mocha tests/node-test.js",
"report": "mocha tests/node-test.js -r jscoverage --covout=html", "report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls", "coveralls": "nyc report --reporter=text-lcov | coveralls",
"build": "uglifyjs src/sha512.js --compress --mangle --comments --output build/sha512.min.js" "build": "uglifyjs src/sha512.js -c -m eval --comments -o build/sha512.min.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -39,5 +39,9 @@
"bugs": { "bugs": {
"url": "https://github.com/emn178/js-sha512/issues" "url": "https://github.com/emn178/js-sha512/issues"
}, },
"dependencies": {} "nyc": {
"exclude": [
"tests"
]
}
} }

@ -1,7 +1,7 @@
/* /*
* [js-sha512]{@link https://github.com/emn178/js-sha512} * [js-sha512]{@link https://github.com/emn178/js-sha512}
* *
* @version 0.7.0 * @version 0.7.1
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017 * @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT * @license MIT
@ -324,7 +324,7 @@
blocks[25] = blocks[26] = blocks[27] = blocks[28] = blocks[25] = blocks[26] = blocks[27] = blocks[28] =
blocks[29] = blocks[30] = blocks[31] = blocks[32] = 0; blocks[29] = blocks[30] = blocks[31] = blocks[32] = 0;
} }
blocks[30] = this.hBytes << 3 | this.bytes >> 29; blocks[30] = this.hBytes << 3 | this.bytes >>> 29;
blocks[31] = this.bytes << 3; blocks[31] = this.bytes << 3;
this.hash(); this.hash();
}; };

@ -109,12 +109,24 @@
'Hi There' 'Hi There'
] ]
}; };
testCases.sha512_hmac['Uint8Array'] = {
'f7688a104326d36c1940f6d28d746c0661d383e0d14fe8a04649444777610f5dd9565a36846ab9e9e734cf380d3a070d8ef021b5f3a50c481710a464968e3419': [
new Uint8Array(0),
'Hi There'
]
};
testCases.sha384_hmac['ArrayBuffer'] = { testCases.sha384_hmac['ArrayBuffer'] = {
'da5393cef424a670d6db42c6ed6e7920779dfa4cbb98bf1c2e9c12ae10d10905d0c9e9d576c2a613be54b8daea246d4b': [ 'da5393cef424a670d6db42c6ed6e7920779dfa4cbb98bf1c2e9c12ae10d10905d0c9e9d576c2a613be54b8daea246d4b': [
new ArrayBuffer(0), new ArrayBuffer(0),
'Hi There' 'Hi There'
] ]
}; };
testCases.sha384_hmac['Uint8Array'] = {
'da5393cef424a670d6db42c6ed6e7920779dfa4cbb98bf1c2e9c12ae10d10905d0c9e9d576c2a613be54b8daea246d4b': [
new Uint8Array(0),
'Hi There'
]
};
} }
var errorTestCases = [null, undefined, { length: 0 }, 0, 1, false, true, NaN, Infinity, function () {}]; var errorTestCases = [null, undefined, { length: 0 }, 0, 1, false, true, NaN, Infinity, function () {}];

Loading…
Cancel
Save