Skip to content

Commit b4a70a6

Browse files
author
Eric Elliott
committed
Support different length hash compare.
1 parent 473c019 commit b4a70a6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

credential.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ var crypto = require('crypto'),
132132
/**
133133
* constantEquals(x, y)
134134
*
135-
* Compare two equal-length hashes, x and y with a
136-
* constant-time algorithm to prevent attacks based on
137-
* timing statistics.
135+
* Compare two strings, x and y with a constant-time
136+
* algorithm to prevent attacks based on timing statistics.
138137
*/
139138
constantEquals = function constantEquals(x, y) {
140139
var result = true,
141-
length = y.length,
140+
length = (x.length > y.length) ? x.length : y.length,
142141
i;
143142

144143
for (i=0; i<length; i++) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "credential",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Easy password hashing and verification in Node. Protects against brute force, rainbow tables, and timing attacks.",
55
"main": "credential.js",
66
"directories": {

0 commit comments

Comments
 (0)