Permalink
Browse files

some linting

  • Loading branch information...
1 parent b529e55 commit e25b57eda9c4352704ba6edb8129b2d35ba41834 @arlolra committed Mar 20, 2013
Showing with 35 additions and 52 deletions.
  1. +4 −5 lib/ake.js
  2. +1 −1 lib/const.js
  3. +5 −11 lib/dsa.js
  4. +5 −7 lib/helpers.js
  5. +7 −9 lib/otr.js
  6. +1 −1 lib/parse.js
  7. +1 −1 lib/sm.js
  8. +4 −6 test/spec/unit/data/keys.js
  9. +1 −1 test/spec/unit/helpers.js
  10. +1 −2 test/spec/unit/libotr.js
  11. +4 −6 test/spec/unit/otr.js
  12. +1 −1 test/spec/unit/parse.js
  13. +0 −1 test/spec/unit/sm.js
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
@@ -20,9 +20,8 @@
DSA = root.DSA
}
- // diffie-hellman modulus and generator
+ // diffie-hellman modulus
// see group 5, RFC 3526
- var G = BigInt.str2bigInt(CONST.G, 10)
var N = BigInt.str2bigInt(CONST.N, 16)
function hMac(gx, gy, pk, kid, m) {
@@ -135,11 +134,11 @@
this.otr.their_priv_pk = this.their_priv_pk
// rotate keys
- this.otr.sessKeys[0] = [ new this.otr.dhSession(
+ this.otr.sessKeys[0] = [ new this.otr.DHSession(
this.otr.our_dh
, this.otr.their_y
), null ]
- this.otr.sessKeys[1] = [ new this.otr.dhSession(
+ this.otr.sessKeys[1] = [ new this.otr.DHSession(
this.otr.our_old_dh
, this.otr.their_y
), null ]
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
View
@@ -2,7 +2,7 @@
// http://www.itl.nist.gov/fipspubs/fip186.htm
;(function () {
- "use strict"
+ "use strict";
var root = this
@@ -136,7 +136,7 @@
var primes = {}
- function SHAbigInt(bi) {
+ function shaBigInt(bi) {
bi = CryptoJS.enc.Latin1.parse(HLP.bigInt2bits(bi))
bi = CryptoJS.SHA1(bi)
return HLP.bits2bigInt(bi.toString(CryptoJS.enc.Latin1))
@@ -170,9 +170,9 @@
tmp = BigInt.dup(seed)
inc_(tmp, TN)
- tmp = SHAbigInt(tmp)
+ tmp = shaBigInt(tmp)
- u = SHAbigInt(seed)
+ u = shaBigInt(seed)
u = HLP.bigBitWise('XOR', u, tmp)
q = HLP.bigBitWise('OR', u, HLP.twotothe(N - 1))
@@ -190,7 +190,7 @@
for (k = 0; k < (n + 1); k ++) {
inc_(offset, TN)
- V = SHAbigInt(offset)
+ V = shaBigInt(offset)
if (k === n) V = BigInt.mod(V, HLP.twotothe(b))
V = BigInt.mult(V, HLP.twotothe(N * k))
W = BigInt.add(W, V)
@@ -498,10 +498,4 @@
return BigInt.equals(v, r)
}
- DSA.inherit = function (key) {
- key.__proto__ = DSA.prototype
- key.constructor = DSA
- key.type = KEY_TYPE
- }
-
}).call(this)
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
@@ -43,9 +43,9 @@
if (Object.hasOwnProperty.call(parent, key))
child[key] = parent[key]
}
- function ctor() { this.constructor = child }
- ctor.prototype = parent.prototype
- child.prototype = new ctor()
+ function Ctor() { this.constructor = child }
+ Ctor.prototype = parent.prototype
+ child.prototype = new Ctor()
child.__super__ = parent.prototype
}
@@ -336,7 +336,7 @@
HLP.splitype = function splitype(arr, msg) {
var data = []
arr.forEach(function (a) {
- var len, str
+ var str
switch (a) {
case 'PUBKEY':
str = splitype(['SHORT', 'MPI', 'MPI', 'MPI', 'MPI'], msg).join('')
@@ -351,15 +351,13 @@
data.push(str)
msg = msg.substring(str.length)
})
-
return data
}
// https://github.com/msgpack/msgpack-javascript/blob/master/msgpack.js
var _bin2num = {}
, _num2bin = {}
- , _b642bin = {}
, _toString = String.fromCharCode
var i = 0, v
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
@@ -166,8 +166,8 @@
}
// session constructor
- OTR.prototype.dhSession = function dhSession(our_dh, their_y) {
- if (!(this instanceof dhSession)) return new dhSession(our_dh, their_y)
+ OTR.prototype.DHSession = function DHSession(our_dh, their_y) {
+ if (!(this instanceof DHSession)) return new DHSession(our_dh, their_y)
// shared secret
var s = BigInt.powMod(their_y, our_dh.privateKey, N)
@@ -217,9 +217,9 @@
this.sessKeys[1][1] = this.sessKeys[0][1]
this.sessKeys[0] = [
this.their_y ?
- new this.dhSession(this.our_dh, this.their_y) : null
+ new this.DHSession(this.our_dh, this.their_y) : null
, this.their_old_y ?
- new this.dhSession(this.our_dh, this.their_old_y) : null
+ new this.DHSession(this.our_dh, this.their_old_y) : null
]
}
@@ -243,8 +243,8 @@
// new keys / sessions
this.their_y = their_y
- this.sessKeys[0][0] = new this.dhSession(this.our_dh, this.their_y)
- this.sessKeys[1][0] = new this.dhSession(this.our_old_dh, this.their_y)
+ this.sessKeys[0][0] = new this.DHSession(this.our_dh, this.their_y)
+ this.sessKeys[1][0] = new this.DHSession(this.our_old_dh, this.their_y)
}
@@ -323,8 +323,6 @@
return
}
- var our_dh = our_keyid ? this.our_old_dh : this.our_dh
-
if (their_keyid < 0 || their_keyid > 1) {
if (!ign) this.error('Not of your latest keys.', true)
return
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
View
@@ -1,5 +1,5 @@
;(function () {
- "use strict"
+ "use strict";
var root = this
@@ -1,23 +1,21 @@
var DSA = require('../../../../lib/dsa.js')
, BigInt = require('../../../../vendor/bigint.js')
-var userA = {
+var userA = DSA({
q: 'AA6B0EFC9135D7DBBC44254C63DA1A941E818BD1',
p: 'C183E9B1029099FE5BECD19610178B943CC62A49D45B1F19BC62E8783334C4A384DD3EE13553CC27118E32786BBD1D82EAED9AA3238C9BC9769703A6000FFD2A415817D97C919FF9BDD13AA82DC16D598881785178BD3D5087F6FAAE1D9415427B85A3CA0EB46E5C8FFA786A8841592644A332E915A5301D624CA80FE54DE0D9',
g: '3B7158464B65769BB847C8107A4CAFA722400DCB300810C02795F7CB1728C9846A8A2B97156C0D22C9B81AA71348ECD27EC42E2BCABF131B4273D24CDD2E81E0DD0F01F1A567448C775094772CEBD8BEE3DF783A20F5E788E660F771EB26A70E615C204B1FFB70DB0FC6BA459D2AB0CDBCB64A93D41F7268A5F767BB851E5BB0',
x: 'A992943DEA115032153A4B1687152D4CC64100E1',
y: 'A92BCA0D2489AEEE94441B6858884A79E7FB1F2E2F699753A76EDDD08C4C94A40D569A426DE23EA2DE11FF73D094879D6D13191C21FEBF6C65ACE518C271EC9D258672CC46EA0BFE354E8B8AD6F6BC6F1E736CE53B1C47F7F5D9EBD9937A7F9D4FE1041B2C235C3B36233187C0FA0A88DFA3970DC1AC70BF3A3989B622F2F454'
-}
-DSA.inherit(userA)
+})
-var userB = {
+var userB = DSA({
q: '9A2DABC81B11A3457D5A4F21401C37A43ECE53BF',
p: 'DDA92042969C3364AA4081778CA5CA2267492FD5AA7168D9F42EBB5ED952921A3CF9099E76479396512E9326EBC6D3F2EBC64E87384280862422F94D89D78A9C2E216DC8AF85FDD7E700515442939729881B3B39FFBF6E81777F8DE5F161CBCCA046E3524BE0A0F3CB6EA5ECEC4EFB8800028D080B7390DFDDBF17351FCAD781',
g: 'A909FFECCCF923A8B4B7EE4C703F275C13BE7ABDB6AC893C7FFC002DEC38930BC54AF3FEEE4EB95EA83CB7A475BB4050671B720A596DB500628846C2A0F600985A158EF6248607E3A8405AAE262E2CE3FD2ACBCF72D127076B55A9B120028253A7C9650BAD29FA93AD23DC74303A380560BA4F5ECFCA7A12123BCBA12CA1EDF5',
x: '9692A2938641E688A46D20E254E68B5DDDB9B2EF',
y: 'B37228D68D313D6215B0E429E78C0824565B847FC88AF1993488B7B01997232A6868A4BAD3D27C4DA4129AC64EAF600F8B76E7115B35E06FA82BAE0EF7FD833EA4894D89A3613A0706188FCF9A5FB4CF9E32BBBEFE978233C051447FB0C64CE12212F9FCC90C18F93BF1E27ED65D778DFAA23331CE43F33CFE3C970D6F39F0E4'
-}
-DSA.inherit(userB)
+})
;['q', 'p', 'g', 'x', 'y' ].forEach(function (k) {
userA[k] = BigInt.str2bigInt(userA[k], 16)
@@ -1,4 +1,4 @@
-/*global describe before it */
+/*global describe it */
var assert = require('assert')
, BigInt = require('../../../vendor/bigint.js')
, HLP = require('../../../lib/helpers.js')
View
@@ -1,6 +1,5 @@
/*global describe it before */
-var assert = require('assert')
- , spawn = require('child_process').spawn
+var spawn = require('child_process').spawn
, keys = require('./data/keys.js')
, OTR = require('../../../lib/otr.js')
, CONST = require('../../../lib/const.js')
View
@@ -1,4 +1,4 @@
-/*global describe before it */
+/*global describe it */
var assert = require('assert')
, keys = require('./data/keys.js')
, CONST = require('../../../lib/const.js')
@@ -8,10 +8,8 @@ var assert = require('assert')
describe('OTR', function () {
- var cb = function () {}
-
it('should initiate a new OTR object', function () {
- var userA = new OTR({ priv: keys.userA })
+ new OTR({ priv: keys.userA })
})
it('should generate an instance tag', function () {
@@ -315,7 +313,7 @@ describe('OTR', function () {
{ u: userA, m: [], c: 0 }
, { u: userB, m: [], c: 0 }
]
- msgs.forEach(function (m, i) {
+ msgs.forEach(function (m) {
ind = Math.floor(Math.random() * 2) // assign the messages randomly
users[ind ? 0 : 1].m.push(m) // expect the other user to receive it
users[ind].u.sendMsg(m)
@@ -372,7 +370,7 @@ describe('OTR', function () {
{ u: userA, m: [], c: 0 }
, { u: userB, m: [], c: 0 }
]
- msgs.forEach(function (m, i) {
+ msgs.forEach(function (m) {
ind = Math.floor(Math.random() * 2) // assign the messages randomly
users[ind ? 0 : 1].m.push(m) // expect the other user to receive it
users[ind].u.sendMsg(m)
View
@@ -1,4 +1,4 @@
-/*global describe before it beforeEach */
+/*global describe it beforeEach */
var assert = require('assert')
, CryptoJS = require('../../../vendor/crypto.js')
, CONST = require('../../../lib/const.js')
View
@@ -2,7 +2,6 @@
var assert = require('assert')
, keys = require('./data/keys.js')
, CONST = require('../../../lib/const.js')
- , SM = require('../../../lib/sm.js')
, OTR = require('../../../lib/otr.js')
describe('SM', function () {

0 comments on commit e25b57e

Please sign in to comment.