Skip to content

Commit

Permalink
Fix some lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobond committed May 31, 2016
1 parent d0edb31 commit 97be4f7
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 59 deletions.
8 changes: 4 additions & 4 deletions browserTest/browserUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ browserUtil.cpsIterate = function (f, start, end, pause, callback) {
browserUtil.cpsMap = function (map, list, pause, callback) {
browserUtil.cpsIterate(function (i, cb) { map(list[i], i, list.length, cb); },
0, list.length, pause, callback);
}
};

/** Cache for remotely loaded scripts. */
browserUtil.scriptCache = {}
browserUtil.scriptCache = {};

/** Load several scripts, then call back */
browserUtil.loadScripts = function(scriptNames, cbSuccess, cbError) {
Expand Down Expand Up @@ -101,7 +101,7 @@ browserUtil.loadScripts = function(scriptNames, cbSuccess, cbError) {
cbError && cbError(script, xhr.status, cb);
}
}
}
};
xhr.open("GET", script+"?"+(new Date().valueOf()), true);
xhr.send();
}
Expand Down Expand Up @@ -150,7 +150,7 @@ browserUtil.writeTable = function (headers) {

d2.appendChild(d4);
}};
}
};

/** Write a newline. Does nothing in the browser. */
browserUtil.writeNewline = function () { };
Expand Down
6 changes: 3 additions & 3 deletions browserTest/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sjcl.perf.PerfCase = function PerfCase (name, cases, runCase) {
this.cases = cases;
this.runCase = runCase;
sjcl.perf.all[name] = this;
}
};

sjcl.perf.PerfCase.prototype.run = function (callback) {
var thiz = this;
Expand All @@ -16,7 +16,7 @@ sjcl.perf.PerfCase.prototype.run = function (callback) {
thiz.runCase(this.cases[0]); // cold start

browserUtil.cpsMap(function (t, i, n, cb) {
var runs = []
var runs = [];

// do 3 runs and average them
for (var k = 0; k < 3; k++) {
Expand All @@ -36,7 +36,7 @@ sjcl.perf.PerfCase.prototype.run = function (callback) {
callback();

});
}
};

sjcl.perf.run = function (perfs, callback) {
browserUtil.status("Profiling...");
Expand Down
18 changes: 9 additions & 9 deletions core/bn.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ sjcl.bn.prototype = {
RP = RP.normalize();
NP = NP.normalize();

RR.doubleM()
RR.doubleM();
var R2 = RR.mulmod(RR, N);

// Check whether the invariant holds.
Expand All @@ -379,7 +379,7 @@ sjcl.bn.prototype = {
return false;
}

var montIn = function(c) { return montMul(c, R2) },
var montIn = function(c) { return montMul(c, R2); },
montMul = function(a, b) {
// Standard Montgomery reduction
var k, carry, ab, right, abBar, mask = (1 << (s + 1)) - 1;
Expand All @@ -401,14 +401,14 @@ sjcl.bn.prototype = {
// Division. Equivelent to calling *.halveM() s times.
for (k=0; k < abBar.limbs.length; k++) {
if (k > 0) {
abBar.limbs[k - 1] |= (abBar.limbs[k] & mask) << (radix - s - 1)
abBar.limbs[k - 1] |= (abBar.limbs[k] & mask) << (radix - s - 1);
}

abBar.limbs[k] = abBar.limbs[k] >> (s + 1)
abBar.limbs[k] = abBar.limbs[k] >> (s + 1);
}

if (abBar.greaterEquals(N)) {
abBar.subM(N)
abBar.subM(N);
}

return abBar;
Expand All @@ -432,13 +432,13 @@ sjcl.bn.prototype = {
var off = i % exp.radix;

return (exp.limbs[Math.floor(i / exp.radix)] & (1 << off)) >> off;
}
};

for (i = x.bitLength() - 1; i >= 0; ) {
if (getBit(x, i) == 0) {
// If the next bit is zero:
// Square, move forward one bit.
out = montMul(out, out)
out = montMul(out, out);
i = i - 1;
} else {
// If the next bit is one:
Expand All @@ -453,11 +453,11 @@ sjcl.bn.prototype = {

var indx = 0;
for (j = l; j <= i; j++) {
indx += getBit(x, j) << (j - l)
indx += getBit(x, j) << (j - l);
out = montMul(out, out);
}

out = montMul(out, precomp[indx])
out = montMul(out, precomp[indx]);

i = l - 1;
}
Expand Down
22 changes: 11 additions & 11 deletions core/codecArrayBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ sjcl.codec.arrayBuffer = {
* Will default to 8byte padding if padding is undefined*/
fromBits: function (arr, padding, padding_count) {
var out, i, ol, tmp, smallest;
padding = padding==undefined ? true : padding
padding_count = padding_count || 8
padding = padding==undefined ? true : padding;
padding_count = padding_count || 8;

if (arr.length === 0) {
return new ArrayBuffer(0);
Expand All @@ -33,7 +33,7 @@ sjcl.codec.arrayBuffer = {
//check to make sure the bitLength is divisible by 8, if it isn't
//we can't do anything since arraybuffers work with bytes, not bits
if ( sjcl.bitArray.bitLength(arr)%8 !== 0 ) {
throw new sjcl.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly")
throw new sjcl.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly");
}

if (padding && ol%padding_count !== 0){
Expand Down Expand Up @@ -61,7 +61,7 @@ sjcl.codec.arrayBuffer = {
}


return out.buffer
return out.buffer;
},

toBits: function (buffer) {
Expand Down Expand Up @@ -95,22 +95,22 @@ sjcl.codec.arrayBuffer = {

/** Prints a hex output of the buffer contents, akin to hexdump **/
hexDumpBuffer: function(buffer){
var stringBufferView = new DataView(buffer)
var string = ''
var stringBufferView = new DataView(buffer);
var string = '';
var pad = function (n, width) {
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
}
};

for (var i = 0; i < stringBufferView.byteLength; i+=2) {
if (i%16 == 0) string += ('\n'+(i).toString(16)+'\t')
string += ( pad(stringBufferView.getUint16(i).toString(16),4) + ' ')
if (i%16 == 0) string += ('\n'+(i).toString(16)+'\t');
string += ( pad(stringBufferView.getUint16(i).toString(16),4) + ' ');
}

if ( typeof console === undefined ){
console = console || {log:function(){}} //fix for IE
console = console || {log:function(){}}; //fix for IE
}
console.log(string.toUpperCase())
console.log(string.toUpperCase());
}
};

2 changes: 1 addition & 1 deletion core/codecBase32.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sjcl.codec.base32 = {

if (_hex) {
c = sjcl.codec.base32._hexChars;
format = "base32hex"
format = "base32hex";
}

for (i=0; i<str.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion core/ocb2progressive.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ sjcl.mode.ocb2progressive = {
}
};
}
}
};
12 changes: 6 additions & 6 deletions core/ripemd160.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sjcl.hash.ripemd160.prototype = {
zp = z % 32;

if ( zp > 0 )
b = sjcl.bitArray.concat( b, [ sjcl.bitArray.partial(zp,0) ] )
b = sjcl.bitArray.concat( b, [ sjcl.bitArray.partial(zp,0) ] );
for ( ; z >= 32; z -= 32 )
b.push(0);

Expand Down Expand Up @@ -134,23 +134,23 @@ var _s2 = [ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,

function _f0(x,y,z) {
return x ^ y ^ z;
};
}

function _f1(x,y,z) {
return (x & y) | (~x & z);
};
}

function _f2(x,y,z) {
return (x | ~y) ^ z;
};
}

function _f3(x,y,z) {
return (x & z) | (y & ~z);
};
}

function _f4(x,y,z) {
return x ^ (y | ~z);
};
}

function _rol(n,l) {
return (n << l) | (n >>> (32-l));
Expand Down
16 changes: 8 additions & 8 deletions core/scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ sjcl.misc.scrypt = function (password, salt, N, r, p, length, Prff) {
self.reverse(blocks);

return sjcl.misc.pbkdf2(password, blocks, 1, length, Prff);
}
};

sjcl.misc.scrypt.salsa20Core = function (word, rounds) {
var R = function(a, b) { return (a << b) | (a >>> (32 - b)); }
var R = function(a, b) { return (a << b) | (a >>> (32 - b)); };
var x = word.slice(0);

for (var i = rounds; i > 0; i -= 2) {
Expand All @@ -76,7 +76,7 @@ sjcl.misc.scrypt.salsa20Core = function (word, rounds) {
}

for (i = 0; i < 16; i++) word[i] = x[i]+word[i];
}
};

sjcl.misc.scrypt.blockMix = function(blocks) {
var X = blocks.slice(-16),
Expand All @@ -96,7 +96,7 @@ sjcl.misc.scrypt.blockMix = function(blocks) {
}

return out;
}
};

sjcl.misc.scrypt.ROMix = function(block, N) {
var X = block.slice(0),
Expand All @@ -116,7 +116,7 @@ sjcl.misc.scrypt.ROMix = function(block, N) {
}

return X;
}
};

sjcl.misc.scrypt.reverse = function (words) { // Converts Big <-> Little Endian words
for (var i in words) {
Expand All @@ -127,20 +127,20 @@ sjcl.misc.scrypt.reverse = function (words) { // Converts Big <-> Little Endian

words[i] = out;
}
}
};

sjcl.misc.scrypt.blockcopy = function (S, Si, D, Di, len) {
var i;

len = len || (S.length - Si);

for (i = 0; i < len; i++) D[Di + i] = S[Si + i] | 0;
}
};

sjcl.misc.scrypt.blockxor = function(S, Si, D, Di, len) {
var i;

len = len || (S.length - Si);

for (i = 0; i < len; i++) D[Di + i] = (D[Di + i] ^ S[Si + i]) | 0;
}
};
8 changes: 4 additions & 4 deletions demo/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ formElement.prototype = {
}
el.value = x;
}
}
};

function radioGroup(name) {
this.name = name;
Expand All @@ -66,7 +66,7 @@ radioGroup.prototype = {
els[i].checked = (els[i].value == x);
}
}
}
};

function formHandler(formName, enterActions) {
var i, els = [], tmp, name;
Expand Down Expand Up @@ -100,7 +100,7 @@ function formHandler(formName, enterActions) {
} else if (hasClass(e, 'hex') && ev.charCode && !keyst.match(/[0-9a-fA-F ]/)) {
stopPropagation(ev); return false;
}
}
};
})(els[i]);

if (els[i].type == 'radio') {
Expand Down Expand Up @@ -133,5 +133,5 @@ formHandler.prototype = {
}
}
}
}
};

6 changes: 3 additions & 3 deletions test/bn_vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sjcl.test.vector.bn_mod = [
0b5db8e54827a16018fee6c111c9a8e66897f849ccd9114639ab086f8ecfa558b58555\
47b1eb110e245f51598bc98486af1813423877189e66a84cd7ead55"
}
]
];

// Verify with Mathematica:
// BaseForm[Mod[16^^a * 16^^b, 16^^N], 16]
Expand All @@ -22,7 +22,7 @@ sjcl.test.vector.bn_mulmod = [
N: "EEAF0AB9ADB38D8775FF3C0B9EA27496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3",
r: "266bd21de6da4ce62c7919c0b34b9f125124c574bac9738edb0998bfa8f5b8076c5266ae06e1b9121303d7ff8f0380a2f51de2fdc93bba83b4c4f49e2ddc65c24a8e2ecbac374e49181792aeeada8fc5438073187b2cf3d63f93d560144ced0a078454a727d24db5d09e56"
}
]
];

sjcl.test.vector.bn_powermod = [
{
Expand Down Expand Up @@ -79,4 +79,4 @@ sjcl.test.vector.bn_powermod = [
N: "b48130d6e07674df740e1d33b4816e0d5d8e20e2050b98be48e457674df74096ea",
v: "9c3219b694befb9caac51a13eb1ac7053b02c654b6a0541cfa60c483592d478630"
}
]
];
4 changes: 2 additions & 2 deletions test/ecc_conv.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ new sjcl.test.TestCase("ECC convenience test", function (cb) {
-200096675,
-1271344660 ];

sjcl.random.addEntropy(random, 8 * 4 * random.length, "crypto.randomBytes")
sjcl.random.addEntropy(random, 8 * 4 * random.length, "crypto.randomBytes");

var keys = sjcl.ecc.elGamal.generateKeys(192,0);

Expand All @@ -26,7 +26,7 @@ new sjcl.test.TestCase("ECC convenience test", function (cb) {

this.require(plaintext == "hello world");
} catch(e) {
console.log(e.stack)
console.log(e.stack);
this.fail(e);
}
cb && cb();
Expand Down
2 changes: 1 addition & 1 deletion test/ecdsa_vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,4 +1117,4 @@ sjcl.test.vector.ecdsa = {
S: "bbf6424a3b70166fa799f49e918439d515327039258ef9bd88435a59c9c19659f8ec3c8660720b0c08354ff60e0f5a76"
}
]
}
};
2 changes: 1 addition & 1 deletion test/hmac_vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ sjcl.test.vector.hmac = [
data: "5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e",
mac: "9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2"
}
]
];
2 changes: 1 addition & 1 deletion test/sha1_vectors_long_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
sjcl.test.vector.sha1long =
[
[Array(100000).join('a123456'), "fd8513d5ba504eacf786091af50b75dcfe25b145"]
]
];
2 changes: 1 addition & 1 deletion test/sha256_vectors_long_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
sjcl.test.vector.sha256long =
[
[Array(100000).join('a123456'), "397df3bf09b046b41b65edebd20e440308188e441c7e57e400cad21b86333d77"]
]
];
Loading

0 comments on commit 97be4f7

Please sign in to comment.