Skip to content

Commit 89ce246

Browse files
author
evanvosberg
committed
Pass jshint test.
1 parent 70f725b commit 89ce246

File tree

10 files changed

+76
-33
lines changed

10 files changed

+76
-33
lines changed

.jshintrc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,24 @@
1010
"strict" : false, // Requires all functions to run in ECMAScript 5's strict mode
1111
"undef" : true, // Require non-global variables to be declared (prevents global leaks)
1212
"asi" : true, // Suppresses warnings about missing semicolons
13+
"funcscope" : false,
14+
"shadow" : true,
15+
"expr" : true,
16+
"-W041" : true,
17+
"-W018" : true,
1318
"globals": {
14-
"CryptoJS": true
19+
"CryptoJS" : true,
20+
"escape" : true,
21+
"unescape" : true,
22+
"Int8Array" : true,
23+
"Int16Array" : true,
24+
"Int32Array" : true,
25+
"Uint8Array" : true,
26+
"Uint16Array" : true,
27+
"Uint32Array" : true,
28+
"Uint8ClampedArray" : true,
29+
"ArrayBuffer" : true,
30+
"Float32Array" : true,
31+
"Float64Array" : true
1532
}
1633
}

Gruntfile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module.exports = function (grunt) {
2929
}
3030
}
3131
});
32+
33+
3234

3335
// Will load the custom tasks
3436
grunt.loadTasks('./grunt/tasks');

grunt/config/jshint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module.exports = {
66
dev: {
77
options: {
8-
jshintrc: true,
8+
jshintrc: process.cwd() + '/.jshintrc',
99
reporterOutput: ''
1010
},
1111
files: {

src/aes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
*/
7777
var AES = C_algo.AES = BlockCipher.extend({
7878
_doReset: function () {
79+
var t;
80+
7981
// Skip reset of nRounds has been set before and key did not change
8082
if (this._nRounds && this._keyPriorReset === this._key) {
8183
return;
@@ -98,7 +100,7 @@
98100
if (ksRow < keySize) {
99101
keySchedule[ksRow] = keyWords[ksRow];
100102
} else {
101-
var t = keySchedule[ksRow - 1];
103+
t = keySchedule[ksRow - 1];
102104

103105
if (!(ksRow % keySize)) {
104106
// Rot word

src/cipher-core.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,19 @@ CryptoJS.lib.Cipher || (function (undefined) {
336336
});
337337

338338
function xorBlock(words, offset, blockSize) {
339+
var block;
340+
339341
// Shortcut
340342
var iv = this._iv;
341343

342344
// Choose mixing block
343345
if (iv) {
344-
var block = iv;
346+
block = iv;
345347

346348
// Remove IV for subsequent blocks
347349
this._iv = undefined;
348350
} else {
349-
var block = this._prevBlock;
351+
block = this._prevBlock;
350352
}
351353

352354
// XOR blocks
@@ -438,6 +440,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
438440
}),
439441

440442
reset: function () {
443+
var modeCreator;
444+
441445
// Reset cipher
442446
Cipher.reset.call(this);
443447

@@ -448,9 +452,9 @@ CryptoJS.lib.Cipher || (function (undefined) {
448452

449453
// Reset block mode
450454
if (this._xformMode == this._ENC_XFORM_MODE) {
451-
var modeCreator = mode.createEncryptor;
455+
modeCreator = mode.createEncryptor;
452456
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
453-
var modeCreator = mode.createDecryptor;
457+
modeCreator = mode.createDecryptor;
454458
// Keep at least one block in the buffer for unpadding
455459
this._minBufferSize = 1;
456460
}
@@ -468,6 +472,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
468472
},
469473

470474
_doFinalize: function () {
475+
var finalProcessedBlocks;
476+
471477
// Shortcut
472478
var padding = this.cfg.padding;
473479

@@ -477,10 +483,10 @@ CryptoJS.lib.Cipher || (function (undefined) {
477483
padding.pad(this._data, this.blockSize);
478484

479485
// Process final blocks
480-
var finalProcessedBlocks = this._process(!!'flush');
486+
finalProcessedBlocks = this._process(!!'flush');
481487
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
482488
// Process final blocks
483-
var finalProcessedBlocks = this._process(!!'flush');
489+
finalProcessedBlocks = this._process(!!'flush');
484490

485491
// Unpad data
486492
padding.unpad(finalProcessedBlocks);
@@ -572,15 +578,17 @@ CryptoJS.lib.Cipher || (function (undefined) {
572578
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
573579
*/
574580
stringify: function (cipherParams) {
581+
var wordArray;
582+
575583
// Shortcuts
576584
var ciphertext = cipherParams.ciphertext;
577585
var salt = cipherParams.salt;
578586

579587
// Format
580588
if (salt) {
581-
var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
589+
wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
582590
} else {
583-
var wordArray = ciphertext;
591+
wordArray = ciphertext;
584592
}
585593

586594
return wordArray.toString(Base64);
@@ -600,6 +608,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
600608
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
601609
*/
602610
parse: function (openSSLStr) {
611+
var salt;
612+
603613
// Parse base64
604614
var ciphertext = Base64.parse(openSSLStr);
605615

@@ -609,7 +619,7 @@ CryptoJS.lib.Cipher || (function (undefined) {
609619
// Test for salt
610620
if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
611621
// Extract salt
612-
var salt = WordArray.create(ciphertextWords.slice(2, 4));
622+
salt = WordArray.create(ciphertextWords.slice(2, 4));
613623

614624
// Remove salt from ciphertext
615625
ciphertextWords.splice(0, 4);

src/core.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
66
* Local polyfil of Object.create
77
*/
88
var create = Object.create || (function () {
9-
function F() {};
9+
function F() {}
1010

1111
return function (obj) {
1212
var subtype;
@@ -289,7 +289,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
289289
random: function (nBytes) {
290290
var words = [];
291291

292-
var r = (function (m_w) {
292+
var r = function (m_w) {
293293
var m_w = m_w;
294294
var m_z = 0x3ade68b1;
295295
var mask = 0xffffffff;
@@ -300,9 +300,9 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
300300
var result = ((m_z << 0x10) + m_w) & mask;
301301
result /= 0x100000000;
302302
result += 0.5;
303-
return result * (Math.random() > .5 ? 1 : -1);
303+
return result * (Math.random() > 0.5 ? 1 : -1);
304304
}
305-
});
305+
};
306306

307307
for (var i = 0, rcache; i < nBytes; i += 4) {
308308
var _r = r((rcache || Math.random()) * 0x100000000);
@@ -539,6 +539,8 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
539539
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
540540
*/
541541
_process: function (doFlush) {
542+
var processedWords;
543+
542544
// Shortcuts
543545
var data = this._data;
544546
var dataWords = data.words;
@@ -571,7 +573,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
571573
}
572574

573575
// Remove processed words
574-
var processedWords = dataWords.splice(0, nWordsReady);
576+
processedWords = dataWords.splice(0, nWordsReady);
575577
data.sigBytes -= nBytesReady;
576578
}
577579

src/evpkdf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
* var key = kdf.compute(password, salt);
5454
*/
5555
compute: function (password, salt) {
56+
var block;
57+
5658
// Shortcut
5759
var cfg = this.cfg;
5860

@@ -72,7 +74,7 @@
7274
if (block) {
7375
hasher.update(block);
7476
}
75-
var block = hasher.update(password).finalize(salt);
77+
block = hasher.update(password).finalize(salt);
7678
hasher.reset();
7779

7880
// Iterations

src/mode-cfb.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ CryptoJS.mode.CFB = (function () {
3434
});
3535

3636
function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
37+
var keystream;
38+
3739
// Shortcut
3840
var iv = this._iv;
3941

4042
// Generate keystream
4143
if (iv) {
42-
var keystream = iv.slice(0);
44+
keystream = iv.slice(0);
4345

4446
// Remove IV for subsequent blocks
4547
this._iv = undefined;
4648
} else {
47-
var keystream = this._prevBlock;
49+
keystream = this._prevBlock;
4850
}
4951
cipher.encryptBlock(keystream, 0);
5052

src/sha3.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158

159159
// Rho Pi
160160
for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
161+
var tMsw;
162+
var tLsw;
163+
161164
// Shortcuts
162165
var lane = state[laneIndex];
163166
var laneMsw = lane.high;
@@ -166,11 +169,11 @@
166169

167170
// Rotate lanes
168171
if (rhoOffset < 32) {
169-
var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
170-
var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
172+
tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
173+
tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
171174
} else /* if (rhoOffset >= 32) */ {
172-
var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
173-
var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
175+
tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
176+
tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
174177
}
175178

176179
// Transpose lanes
@@ -205,7 +208,7 @@
205208
var lane = state[0];
206209
var roundConstant = ROUND_CONSTANTS[round];
207210
lane.high ^= roundConstant.high;
208-
lane.low ^= roundConstant.low;;
211+
lane.low ^= roundConstant.low;
209212
}
210213
},
211214

src/sha512.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,16 @@
127127

128128
// Rounds
129129
for (var i = 0; i < 80; i++) {
130+
var Wil;
131+
var Wih;
132+
130133
// Shortcut
131134
var Wi = W[i];
132135

133136
// Extend message
134137
if (i < 16) {
135-
var Wih = Wi.high = M[offset + i * 2] | 0;
136-
var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
138+
Wih = Wi.high = M[offset + i * 2] | 0;
139+
Wil = Wi.low = M[offset + i * 2 + 1] | 0;
137140
} else {
138141
// Gamma0
139142
var gamma0x = W[i - 15];
@@ -158,12 +161,12 @@
158161
var Wi16h = Wi16.high;
159162
var Wi16l = Wi16.low;
160163

161-
var Wil = gamma0l + Wi7l;
162-
var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
163-
var Wil = Wil + gamma1l;
164-
var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
165-
var Wil = Wil + Wi16l;
166-
var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
164+
Wil = gamma0l + Wi7l;
165+
Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
166+
Wil = Wil + gamma1l;
167+
Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
168+
Wil = Wil + Wi16l;
169+
Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
167170

168171
Wi.high = Wih;
169172
Wi.low = Wil;

0 commit comments

Comments
 (0)