Pass jshint test.

This commit is contained in:
evanvosberg
2018-09-14 00:35:13 +02:00
parent 70f725bee5
commit 89ce2460ab
10 changed files with 76 additions and 33 deletions
+18 -1
View File
@@ -10,7 +10,24 @@
"strict" : false, // Requires all functions to run in ECMAScript 5's strict mode
"undef" : true, // Require non-global variables to be declared (prevents global leaks)
"asi" : true, // Suppresses warnings about missing semicolons
"funcscope" : false,
"shadow" : true,
"expr" : true,
"-W041" : true,
"-W018" : true,
"globals": {
"CryptoJS": true
"CryptoJS" : true,
"escape" : true,
"unescape" : true,
"Int8Array" : true,
"Int16Array" : true,
"Int32Array" : true,
"Uint8Array" : true,
"Uint16Array" : true,
"Uint32Array" : true,
"Uint8ClampedArray" : true,
"ArrayBuffer" : true,
"Float32Array" : true,
"Float64Array" : true
}
}
+2
View File
@@ -29,6 +29,8 @@ module.exports = function (grunt) {
}
}
});
// Will load the custom tasks
grunt.loadTasks('./grunt/tasks');
+1 -1
View File
@@ -5,7 +5,7 @@
module.exports = {
dev: {
options: {
jshintrc: true,
jshintrc: process.cwd() + '/.jshintrc',
reporterOutput: ''
},
files: {
+3 -1
View File
@@ -76,6 +76,8 @@
*/
var AES = C_algo.AES = BlockCipher.extend({
_doReset: function () {
var t;
// Skip reset of nRounds has been set before and key did not change
if (this._nRounds && this._keyPriorReset === this._key) {
return;
@@ -98,7 +100,7 @@
if (ksRow < keySize) {
keySchedule[ksRow] = keyWords[ksRow];
} else {
var t = keySchedule[ksRow - 1];
t = keySchedule[ksRow - 1];
if (!(ksRow % keySize)) {
// Rot word
+19 -9
View File
@@ -336,17 +336,19 @@ CryptoJS.lib.Cipher || (function (undefined) {
});
function xorBlock(words, offset, blockSize) {
var block;
// Shortcut
var iv = this._iv;
// Choose mixing block
if (iv) {
var block = iv;
block = iv;
// Remove IV for subsequent blocks
this._iv = undefined;
} else {
var block = this._prevBlock;
block = this._prevBlock;
}
// XOR blocks
@@ -438,6 +440,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
}),
reset: function () {
var modeCreator;
// Reset cipher
Cipher.reset.call(this);
@@ -448,9 +452,9 @@ CryptoJS.lib.Cipher || (function (undefined) {
// Reset block mode
if (this._xformMode == this._ENC_XFORM_MODE) {
var modeCreator = mode.createEncryptor;
modeCreator = mode.createEncryptor;
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
var modeCreator = mode.createDecryptor;
modeCreator = mode.createDecryptor;
// Keep at least one block in the buffer for unpadding
this._minBufferSize = 1;
}
@@ -468,6 +472,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
},
_doFinalize: function () {
var finalProcessedBlocks;
// Shortcut
var padding = this.cfg.padding;
@@ -477,10 +483,10 @@ CryptoJS.lib.Cipher || (function (undefined) {
padding.pad(this._data, this.blockSize);
// Process final blocks
var finalProcessedBlocks = this._process(!!'flush');
finalProcessedBlocks = this._process(!!'flush');
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
// Process final blocks
var finalProcessedBlocks = this._process(!!'flush');
finalProcessedBlocks = this._process(!!'flush');
// Unpad data
padding.unpad(finalProcessedBlocks);
@@ -572,15 +578,17 @@ CryptoJS.lib.Cipher || (function (undefined) {
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
*/
stringify: function (cipherParams) {
var wordArray;
// Shortcuts
var ciphertext = cipherParams.ciphertext;
var salt = cipherParams.salt;
// Format
if (salt) {
var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
} else {
var wordArray = ciphertext;
wordArray = ciphertext;
}
return wordArray.toString(Base64);
@@ -600,6 +608,8 @@ CryptoJS.lib.Cipher || (function (undefined) {
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
*/
parse: function (openSSLStr) {
var salt;
// Parse base64
var ciphertext = Base64.parse(openSSLStr);
@@ -609,7 +619,7 @@ CryptoJS.lib.Cipher || (function (undefined) {
// Test for salt
if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
// Extract salt
var salt = WordArray.create(ciphertextWords.slice(2, 4));
salt = WordArray.create(ciphertextWords.slice(2, 4));
// Remove salt from ciphertext
ciphertextWords.splice(0, 4);
+7 -5
View File
@@ -6,7 +6,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
* Local polyfil of Object.create
*/
var create = Object.create || (function () {
function F() {};
function F() {}
return function (obj) {
var subtype;
@@ -289,7 +289,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
random: function (nBytes) {
var words = [];
var r = (function (m_w) {
var r = function (m_w) {
var m_w = m_w;
var m_z = 0x3ade68b1;
var mask = 0xffffffff;
@@ -300,9 +300,9 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
var result = ((m_z << 0x10) + m_w) & mask;
result /= 0x100000000;
result += 0.5;
return result * (Math.random() > .5 ? 1 : -1);
return result * (Math.random() > 0.5 ? 1 : -1);
}
});
};
for (var i = 0, rcache; i < nBytes; i += 4) {
var _r = r((rcache || Math.random()) * 0x100000000);
@@ -539,6 +539,8 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
*/
_process: function (doFlush) {
var processedWords;
// Shortcuts
var data = this._data;
var dataWords = data.words;
@@ -571,7 +573,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
}
// Remove processed words
var processedWords = dataWords.splice(0, nWordsReady);
processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;
}
+3 -1
View File
@@ -53,6 +53,8 @@
* var key = kdf.compute(password, salt);
*/
compute: function (password, salt) {
var block;
// Shortcut
var cfg = this.cfg;
@@ -72,7 +74,7 @@
if (block) {
hasher.update(block);
}
var block = hasher.update(password).finalize(salt);
block = hasher.update(password).finalize(salt);
hasher.reset();
// Iterations
+4 -2
View File
@@ -34,17 +34,19 @@ CryptoJS.mode.CFB = (function () {
});
function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
var keystream;
// Shortcut
var iv = this._iv;
// Generate keystream
if (iv) {
var keystream = iv.slice(0);
keystream = iv.slice(0);
// Remove IV for subsequent blocks
this._iv = undefined;
} else {
var keystream = this._prevBlock;
keystream = this._prevBlock;
}
cipher.encryptBlock(keystream, 0);
+8 -5
View File
@@ -158,6 +158,9 @@
// Rho Pi
for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
var tMsw;
var tLsw;
// Shortcuts
var lane = state[laneIndex];
var laneMsw = lane.high;
@@ -166,11 +169,11 @@
// Rotate lanes
if (rhoOffset < 32) {
var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
} else /* if (rhoOffset >= 32) */ {
var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
}
// Transpose lanes
@@ -205,7 +208,7 @@
var lane = state[0];
var roundConstant = ROUND_CONSTANTS[round];
lane.high ^= roundConstant.high;
lane.low ^= roundConstant.low;;
lane.low ^= roundConstant.low;
}
},
+11 -8
View File
@@ -127,13 +127,16 @@
// Rounds
for (var i = 0; i < 80; i++) {
var Wil;
var Wih;
// Shortcut
var Wi = W[i];
// Extend message
if (i < 16) {
var Wih = Wi.high = M[offset + i * 2] | 0;
var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
Wih = Wi.high = M[offset + i * 2] | 0;
Wil = Wi.low = M[offset + i * 2 + 1] | 0;
} else {
// Gamma0
var gamma0x = W[i - 15];
@@ -158,12 +161,12 @@
var Wi16h = Wi16.high;
var Wi16l = Wi16.low;
var Wil = gamma0l + Wi7l;
var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
var Wil = Wil + gamma1l;
var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
var Wil = Wil + Wi16l;
var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
Wil = gamma0l + Wi7l;
Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
Wil = Wil + gamma1l;
Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
Wil = Wil + Wi16l;
Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
Wi.high = Wih;
Wi.low = Wil;