diff --git a/app/src/core/data.ts b/app/src/core/data.ts index 432cc1156..9da89e4dd 100644 --- a/app/src/core/data.ts +++ b/app/src/core/data.ts @@ -27,21 +27,24 @@ export class Record { uuid: string; updated: Date; removed: boolean; + lastUsed?: Date; constructor(name = "", fields?: Array, category?: string, - id?: string, updated?: Date, removed = false) { + id?: string, updated?: Date, removed = false, lastUsed?: Date) { this.name = name; this.fields = fields || new Array(); this.category = category || ""; this.uuid = id || uuid(); this.updated = updated || new Date(); this.removed = removed; + this.lastUsed = lastUsed; } static fromRaw(obj: any): Record { let fields = obj.fields && >obj.fields; let updated = obj.updated && (obj.updated instanceof Date ? obj.updated : new Date(obj.updated)); - return new Record(obj.name, fields, obj.category, obj.uuid, updated, obj.removed); + let lastUsed = obj.lastUsed && (obj.lastUsed instanceof Date ? obj.lastUsed : new Date(obj.lastUsed)); + return new Record(obj.name, fields, obj.category, obj.uuid, updated, obj.removed, lastUsed); } static compare(a: Record, b: Record): number { @@ -63,7 +66,8 @@ export class Record { category: this.category, uuid: this.uuid, updated: this.updated, - removed: this.removed + removed: this.removed, + lastUsed: this.lastUsed }; } diff --git a/app/src/padlock.js b/app/src/padlock.js index 81b37a66c..0ea43b4da 100644 --- a/app/src/padlock.js +++ b/app/src/padlock.js @@ -50,6 +50,7 @@ function request(method, url, body, headers) { }); } exports.request = request; + },{}],2:[function(require,module,exports){ (function (Buffer){ "use strict"; @@ -253,9 +254,10 @@ class Container { } } exports.Container = Container; + }).call(this,require("buffer").Buffer) -},{"./platform":9,"buffer":58,"sjcl":164}],3:[function(require,module,exports){ +},{"./platform":9,"buffer":57,"sjcl":163}],3:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { @@ -279,18 +281,20 @@ const compareCategory = compareProperty("category"); const compareName = compareProperty("name"); const compareUuid = compareProperty("uuid"); class Record { - constructor(name = "", fields, category, id, updated, removed = false) { + constructor(name = "", fields, category, id, updated, removed = false, lastUsed) { this.name = name; this.fields = fields || new Array(); this.category = category || ""; this.uuid = id || util_1.uuid(); this.updated = updated || new Date(); this.removed = removed; + this.lastUsed = lastUsed; } static fromRaw(obj) { let fields = obj.fields && obj.fields; let updated = obj.updated && (obj.updated instanceof Date ? obj.updated : new Date(obj.updated)); - return new Record(obj.name, fields, obj.category, obj.uuid, updated, obj.removed); + let lastUsed = obj.lastUsed && (obj.lastUsed instanceof Date ? obj.lastUsed : new Date(obj.lastUsed)); + return new Record(obj.name, fields, obj.category, obj.uuid, updated, obj.removed, lastUsed); } static compare(a, b) { return compareName(a, b) || compareCategory(a, b) || compareUuid(a, b); @@ -309,7 +313,8 @@ class Record { category: this.category, uuid: this.uuid, updated: this.updated, - removed: this.removed + removed: this.removed, + lastUsed: this.lastUsed }; } } @@ -409,7 +414,7 @@ class Settings { } Settings.defaults = { autoLock: true, - peekValuesOnHover: true, + peekValues: false, // Auto lock delay in minutes autoLockDelay: 1, syncHostUrl: "https://cloud.padlock.io", @@ -428,6 +433,7 @@ Settings.defaults = { version: "" }; exports.Settings = Settings; + },{"./platform":9,"./util":11}],4:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -501,7 +507,8 @@ function toPadlock(records, password) { }); } exports.toPadlock = toPadlock; -},{"./data":3,"./source":10,"papaparse":120}],5:[function(require,module,exports){ + +},{"./data":3,"./source":10,"papaparse":119}],5:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { @@ -633,6 +640,7 @@ class NodeFileManager { } } exports.NodeFileManager = NodeFileManager; + },{}],6:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -835,7 +843,8 @@ function isFromLastPass(data) { return data.split("\n")[0] === "url,username,password,extra,name,grouping,fav"; } exports.isFromLastPass = isFromLastPass; -},{"./crypto":2,"./data":3,"papaparse":120}],7:[function(require,module,exports){ + +},{"./crypto":2,"./data":3,"papaparse":119}],7:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util = require("./util"); @@ -858,6 +867,7 @@ const file = require("./file"); exports.file = file; const messages = require("./messages"); exports.messages = messages; + },{"./ajax":1,"./crypto":2,"./data":3,"./export":4,"./file":5,"./import":6,"./messages":8,"./platform":9,"./source":10,"./util":11}],8:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -941,7 +951,8 @@ class Messages { } } exports.Messages = Messages; -},{"./ajax":1,"./platform":9,"./util":11,"semver":155}],9:[function(require,module,exports){ + +},{"./ajax":1,"./platform":9,"./util":11,"semver":154}],9:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { @@ -1207,6 +1218,7 @@ function getDeviceInfo() { }); } exports.getDeviceInfo = getDeviceInfo; + },{}],10:[function(require,module,exports){ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -1496,6 +1508,7 @@ class FileSource { } } exports.FileSource = FileSource; + },{"./ajax":1,"./crypto":2,"./file":5,"./platform":9}],11:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -1563,6 +1576,7 @@ function applyMixins(baseClass, ...mixins) { return mixins.reduce((cls, mixin) => mixin(cls), baseClass); } exports.applyMixins = applyMixins; + },{}],12:[function(require,module,exports){ var asn1 = exports; @@ -1637,7 +1651,7 @@ Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { return this._getEncoder(enc).encode(data, reporter); }; -},{"../asn1":12,"inherits":112,"vm":168}],14:[function(require,module,exports){ +},{"../asn1":12,"inherits":111,"vm":167}],14:[function(require,module,exports){ var inherits = require('inherits'); var Reporter = require('../base').Reporter; var Buffer = require('buffer').Buffer; @@ -1755,7 +1769,7 @@ EncoderBuffer.prototype.join = function join(out, offset) { return out; }; -},{"../base":15,"buffer":58,"inherits":112}],15:[function(require,module,exports){ +},{"../base":15,"buffer":57,"inherits":111}],15:[function(require,module,exports){ var base = exports; base.Reporter = require('./reporter').Reporter; @@ -2399,7 +2413,7 @@ Node.prototype._isPrintstr = function isPrintstr(str) { return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); }; -},{"../base":15,"minimalistic-assert":118}],17:[function(require,module,exports){ +},{"../base":15,"minimalistic-assert":117}],17:[function(require,module,exports){ var inherits = require('inherits'); function Reporter(options) { @@ -2522,7 +2536,7 @@ ReporterError.prototype.rethrow = function rethrow(msg) { return this; }; -},{"inherits":112}],18:[function(require,module,exports){ +},{"inherits":111}],18:[function(require,module,exports){ var constants = require('../constants'); exports.tagClass = { @@ -2913,7 +2927,7 @@ function derDecodeLen(buf, primitive, fail) { return len; } -},{"../../asn1":12,"inherits":112}],21:[function(require,module,exports){ +},{"../../asn1":12,"inherits":111}],21:[function(require,module,exports){ var decoders = exports; decoders.der = require('./der'); @@ -2970,7 +2984,7 @@ PEMDecoder.prototype.decode = function decode(data, options) { return DERDecoder.prototype.decode.call(this, input, options); }; -},{"./der":20,"buffer":58,"inherits":112}],23:[function(require,module,exports){ +},{"./der":20,"buffer":57,"inherits":111}],23:[function(require,module,exports){ var inherits = require('inherits'); var Buffer = require('buffer').Buffer; @@ -3267,7 +3281,7 @@ function encodeTag(tag, primitive, cls, reporter) { return res; } -},{"../../asn1":12,"buffer":58,"inherits":112}],24:[function(require,module,exports){ +},{"../../asn1":12,"buffer":57,"inherits":111}],24:[function(require,module,exports){ var encoders = exports; encoders.der = require('./der'); @@ -3296,7 +3310,7 @@ PEMEncoder.prototype.encode = function encode(data, options) { return out.join('\n'); }; -},{"./der":23,"inherits":112}],26:[function(require,module,exports){ +},{"./der":23,"inherits":111}],26:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -6911,115 +6925,69 @@ if (typeof self === 'object') { },{"crypto":29}],29:[function(require,module,exports){ },{}],30:[function(require,module,exports){ +(function (Buffer){ // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec + // which is in turn based on the one from crypto-js // https://code.google.com/p/crypto-js/ -var Buffer = require('safe-buffer').Buffer - -function asUInt32Array (buf) { - if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) - - var len = (buf.length / 4) | 0 - var out = new Array(len) - - for (var i = 0; i < len; i++) { - out[i] = buf.readUInt32BE(i * 4) - } - - return out +var uint_max = Math.pow(2, 32) +function fixup_uint32 (x) { + var ret, x_pos + ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x + return ret } - -function scrubVec (v) { +function scrub_vec (v) { for (var i = 0; i < v.length; v++) { v[i] = 0 } + return false } -function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) { - var SUB_MIX0 = SUB_MIX[0] - var SUB_MIX1 = SUB_MIX[1] - var SUB_MIX2 = SUB_MIX[2] - var SUB_MIX3 = SUB_MIX[3] - - var s0 = M[0] ^ keySchedule[0] - var s1 = M[1] ^ keySchedule[1] - var s2 = M[2] ^ keySchedule[2] - var s3 = M[3] ^ keySchedule[3] - var t0, t1, t2, t3 - var ksRow = 4 - - for (var round = 1; round < nRounds; round++) { - t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++] - t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++] - t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++] - t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++] - s0 = t0 - s1 = t1 - s2 = t2 - s3 = t3 - } +function Global () { + this.SBOX = [] + this.INV_SBOX = [] + this.SUB_MIX = [[], [], [], []] + this.INV_SUB_MIX = [[], [], [], []] + this.init() + this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] +} - t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] - t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] - t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] - t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] - t0 = t0 >>> 0 - t1 = t1 >>> 0 - t2 = t2 >>> 0 - t3 = t3 >>> 0 - - return [t0, t1, t2, t3] -} - -// AES constants -var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] -var G = (function () { - // Compute double table - var d = new Array(256) - for (var j = 0; j < 256; j++) { - if (j < 128) { - d[j] = j << 1 - } else { - d[j] = (j << 1) ^ 0x11b +Global.prototype.init = function () { + var d, i, sx, t, x, x2, x4, x8, xi, _i + d = (function () { + var _i, _results + _results = [] + for (i = _i = 0; _i < 256; i = ++_i) { + if (i < 128) { + _results.push(i << 1) + } else { + _results.push((i << 1) ^ 0x11b) + } } - } - - var SBOX = [] - var INV_SBOX = [] - var SUB_MIX = [[], [], [], []] - var INV_SUB_MIX = [[], [], [], []] - - // Walk GF(2^8) - var x = 0 - var xi = 0 - for (var i = 0; i < 256; ++i) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) + return _results + })() + x = 0 + xi = 0 + for (i = _i = 0; _i < 256; i = ++_i) { + sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 - SBOX[x] = sx - INV_SBOX[sx] = x - - // Compute multiplication - var x2 = d[x] - var x4 = d[x2] - var x8 = d[x4] - - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100) - SUB_MIX[0][x] = (t << 24) | (t >>> 8) - SUB_MIX[1][x] = (t << 16) | (t >>> 16) - SUB_MIX[2][x] = (t << 8) | (t >>> 24) - SUB_MIX[3][x] = t - - // Compute inv sub bytes, inv mix columns tables + this.SBOX[x] = sx + this.INV_SBOX[sx] = x + x2 = d[x] + x4 = d[x2] + x8 = d[x4] + t = (d[sx] * 0x101) ^ (sx * 0x1010100) + this.SUB_MIX[0][x] = (t << 24) | (t >>> 8) + this.SUB_MIX[1][x] = (t << 16) | (t >>> 16) + this.SUB_MIX[2][x] = (t << 8) | (t >>> 24) + this.SUB_MIX[3][x] = t t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) - INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) - INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) - INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) - INV_SUB_MIX[3][sx] = t - + this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) + this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) + this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) + this.INV_SUB_MIX[3][sx] = t if (x === 0) { x = xi = 1 } else { @@ -7027,87 +6995,56 @@ var G = (function () { xi ^= d[d[xi]] } } - - return { - SBOX: SBOX, - INV_SBOX: INV_SBOX, - SUB_MIX: SUB_MIX, - INV_SUB_MIX: INV_SUB_MIX - } -})() - -function AES (key) { - this._key = asUInt32Array(key) - this._reset() + return true } -AES.blockSize = 4 * 4 -AES.keySize = 256 / 8 -AES.prototype.blockSize = AES.blockSize -AES.prototype.keySize = AES.keySize -AES.prototype._reset = function () { - var keyWords = this._key - var keySize = keyWords.length - var nRounds = keySize + 6 - var ksRows = (nRounds + 1) * 4 - - var keySchedule = [] - for (var k = 0; k < keySize; k++) { - keySchedule[k] = keyWords[k] - } - - for (k = keySize; k < ksRows; k++) { - var t = keySchedule[k - 1] +var G = new Global() - if (k % keySize === 0) { - t = (t << 8) | (t >>> 24) - t = - (G.SBOX[t >>> 24] << 24) | - (G.SBOX[(t >>> 16) & 0xff] << 16) | - (G.SBOX[(t >>> 8) & 0xff] << 8) | - (G.SBOX[t & 0xff]) +AES.blockSize = 4 * 4 - t ^= RCON[(k / keySize) | 0] << 24 - } else if (keySize > 6 && k % keySize === 4) { - t = - (G.SBOX[t >>> 24] << 24) | - (G.SBOX[(t >>> 16) & 0xff] << 16) | - (G.SBOX[(t >>> 8) & 0xff] << 8) | - (G.SBOX[t & 0xff]) - } +AES.prototype.blockSize = AES.blockSize - keySchedule[k] = keySchedule[k - keySize] ^ t - } +AES.keySize = 256 / 8 - var invKeySchedule = [] - for (var ik = 0; ik < ksRows; ik++) { - var ksR = ksRows - ik - var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)] +AES.prototype.keySize = AES.keySize - if (ik < 4 || ksR <= 4) { - invKeySchedule[ik] = tt - } else { - invKeySchedule[ik] = - G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ - G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^ - G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^ - G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]] - } +function bufferToArray (buf) { + var len = buf.length / 4 + var out = new Array(len) + var i = -1 + while (++i < len) { + out[i] = buf.readUInt32BE(i * 4) } - - this._nRounds = nRounds - this._keySchedule = keySchedule - this._invKeySchedule = invKeySchedule + return out +} +function AES (key) { + this._key = bufferToArray(key) + this._doReset() } -AES.prototype.encryptBlockRaw = function (M) { - M = asUInt32Array(M) - return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds) +AES.prototype._doReset = function () { + var invKsRow, keySize, keyWords, ksRow, ksRows, t + keyWords = this._key + keySize = keyWords.length + this._nRounds = keySize + 6 + ksRows = (this._nRounds + 1) * 4 + this._keySchedule = [] + for (ksRow = 0; ksRow < ksRows; ksRow++) { + this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[ksRow - keySize] ^ t) + } + this._invKeySchedule = [] + for (invKsRow = 0; invKsRow < ksRows; invKsRow++) { + ksRow = ksRows - invKsRow + t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)] + this._invKeySchedule[invKsRow] = invKsRow < 4 || ksRow <= 4 ? t : G.INV_SUB_MIX[0][G.SBOX[t >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[(t >>> 16) & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[(t >>> 8) & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[t & 0xff]] + } + return true } AES.prototype.encryptBlock = function (M) { - var out = this.encryptBlockRaw(M) - var buf = Buffer.allocUnsafe(16) + M = bufferToArray(new Buffer(M)) + var out = this._doCryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX) + var buf = new Buffer(16) buf.writeUInt32BE(out[0], 0) buf.writeUInt32BE(out[1], 4) buf.writeUInt32BE(out[2], 8) @@ -7116,15 +7053,12 @@ AES.prototype.encryptBlock = function (M) { } AES.prototype.decryptBlock = function (M) { - M = asUInt32Array(M) - - // swap - var m1 = M[1] - M[1] = M[3] - M[3] = m1 - - var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds) - var buf = Buffer.allocUnsafe(16) + M = bufferToArray(new Buffer(M)) + var temp = [M[3], M[1]] + M[1] = temp[0] + M[3] = temp[1] + var out = this._doCryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX) + var buf = new Buffer(16) buf.writeUInt32BE(out[0], 0) buf.writeUInt32BE(out[3], 4) buf.writeUInt32BE(out[2], 8) @@ -7133,65 +7067,86 @@ AES.prototype.decryptBlock = function (M) { } AES.prototype.scrub = function () { - scrubVec(this._keySchedule) - scrubVec(this._invKeySchedule) - scrubVec(this._key) + scrub_vec(this._keySchedule) + scrub_vec(this._invKeySchedule) + scrub_vec(this._key) +} + +AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) { + var ksRow, s0, s1, s2, s3, t0, t1, t2, t3 + + s0 = M[0] ^ keySchedule[0] + s1 = M[1] ^ keySchedule[1] + s2 = M[2] ^ keySchedule[2] + s3 = M[3] ^ keySchedule[3] + ksRow = 4 + for (var round = 1; round < this._nRounds; round++) { + t0 = SUB_MIX[0][s0 >>> 24] ^ SUB_MIX[1][(s1 >>> 16) & 0xff] ^ SUB_MIX[2][(s2 >>> 8) & 0xff] ^ SUB_MIX[3][s3 & 0xff] ^ keySchedule[ksRow++] + t1 = SUB_MIX[0][s1 >>> 24] ^ SUB_MIX[1][(s2 >>> 16) & 0xff] ^ SUB_MIX[2][(s3 >>> 8) & 0xff] ^ SUB_MIX[3][s0 & 0xff] ^ keySchedule[ksRow++] + t2 = SUB_MIX[0][s2 >>> 24] ^ SUB_MIX[1][(s3 >>> 16) & 0xff] ^ SUB_MIX[2][(s0 >>> 8) & 0xff] ^ SUB_MIX[3][s1 & 0xff] ^ keySchedule[ksRow++] + t3 = SUB_MIX[0][s3 >>> 24] ^ SUB_MIX[1][(s0 >>> 16) & 0xff] ^ SUB_MIX[2][(s1 >>> 8) & 0xff] ^ SUB_MIX[3][s2 & 0xff] ^ keySchedule[ksRow++] + s0 = t0 + s1 = t1 + s2 = t2 + s3 = t3 + } + t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] + t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] + t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] + t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] + return [ + fixup_uint32(t0), + fixup_uint32(t1), + fixup_uint32(t2), + fixup_uint32(t3) + ] } -module.exports.AES = AES +exports.AES = AES + +}).call(this,require("buffer").Buffer) -},{"safe-buffer":154}],31:[function(require,module,exports){ +},{"buffer":57}],31:[function(require,module,exports){ +(function (Buffer){ var aes = require('./aes') -var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') var inherits = require('inherits') var GHASH = require('./ghash') var xor = require('buffer-xor') - -function xorTest (a, b) { - var out = 0 - if (a.length !== b.length) out++ - - var len = Math.min(a.length, b.length) - for (var i = 0; i < len; ++i) { - out += (a[i] ^ b[i]) - } - - return out -} +inherits(StreamCipher, Transform) +module.exports = StreamCipher function StreamCipher (mode, key, iv, decrypt) { + if (!(this instanceof StreamCipher)) { + return new StreamCipher(mode, key, iv) + } Transform.call(this) - - this._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]) - iv = Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]) - + this._finID = Buffer.concat([iv, new Buffer([0, 0, 0, 1])]) + iv = Buffer.concat([iv, new Buffer([0, 0, 0, 2])]) this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) - this._cache = Buffer.allocUnsafe(0) - this._secCache = Buffer.allocUnsafe(0) + this._prev = new Buffer(iv.length) + this._cache = new Buffer('') + this._secCache = new Buffer('') this._decrypt = decrypt this._alen = 0 this._len = 0 + iv.copy(this._prev) this._mode = mode - - var h = Buffer.alloc(4, 0) + var h = new Buffer(4) + h.fill(0) this._ghash = new GHASH(this._cipher.encryptBlock(h)) this._authTag = null this._called = false } - -inherits(StreamCipher, Transform) - StreamCipher.prototype._update = function (chunk) { if (!this._called && this._alen) { var rump = 16 - (this._alen % 16) if (rump < 16) { - rump = Buffer.alloc(rump, 0) + rump = new Buffer(rump) + rump.fill(0) this._ghash.update(rump) } } - this._called = true var out = this._mode.encrypt(this, chunk) if (this._decrypt) { @@ -7202,76 +7157,94 @@ StreamCipher.prototype._update = function (chunk) { this._len += chunk.length return out } - StreamCipher.prototype._final = function () { - if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data') - + if (this._decrypt && !this._authTag) { + throw new Error('Unsupported state or unable to authenticate data') + } var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID)) - if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data') - - this._authTag = tag + if (this._decrypt) { + if (xorTest(tag, this._authTag)) { + throw new Error('Unsupported state or unable to authenticate data') + } + } else { + this._authTag = tag + } this._cipher.scrub() } - StreamCipher.prototype.getAuthTag = function getAuthTag () { - if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state') - - return this._authTag + if (!this._decrypt && Buffer.isBuffer(this._authTag)) { + return this._authTag + } else { + throw new Error('Attempting to get auth tag in unsupported state') + } } - StreamCipher.prototype.setAuthTag = function setAuthTag (tag) { - if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state') - - this._authTag = tag + if (this._decrypt) { + this._authTag = tag + } else { + throw new Error('Attempting to set auth tag in unsupported state') + } } - StreamCipher.prototype.setAAD = function setAAD (buf) { - if (this._called) throw new Error('Attempting to set AAD in unsupported state') - - this._ghash.update(buf) - this._alen += buf.length + if (!this._called) { + this._ghash.update(buf) + this._alen += buf.length + } else { + throw new Error('Attempting to set AAD in unsupported state') + } +} +function xorTest (a, b) { + var out = 0 + if (a.length !== b.length) { + out++ + } + var len = Math.min(a.length, b.length) + var i = -1 + while (++i < len) { + out += (a[i] ^ b[i]) + } + return out } -module.exports = StreamCipher +}).call(this,require("buffer").Buffer) -},{"./aes":30,"./ghash":35,"buffer-xor":57,"cipher-base":59,"inherits":112,"safe-buffer":154}],32:[function(require,module,exports){ +},{"./aes":30,"./ghash":35,"buffer":57,"buffer-xor":56,"cipher-base":58,"inherits":111}],32:[function(require,module,exports){ var ciphers = require('./encrypter') -var deciphers = require('./decrypter') -var modes = require('./modes/list.json') - -function getCiphers () { - return Object.keys(modes) -} - exports.createCipher = exports.Cipher = ciphers.createCipher exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv +var deciphers = require('./decrypter') exports.createDecipher = exports.Decipher = deciphers.createDecipher exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv +var modes = require('./modes') +function getCiphers () { + return Object.keys(modes) +} exports.listCiphers = exports.getCiphers = getCiphers -},{"./decrypter":33,"./encrypter":34,"./modes/list.json":43}],33:[function(require,module,exports){ -var AuthCipher = require('./authCipher') -var Buffer = require('safe-buffer').Buffer -var MODES = require('./modes') -var StreamCipher = require('./streamCipher') -var Transform = require('cipher-base') +},{"./decrypter":33,"./encrypter":34,"./modes":36}],33:[function(require,module,exports){ +(function (Buffer){ var aes = require('./aes') -var ebtk = require('evp_bytestokey') +var Transform = require('cipher-base') var inherits = require('inherits') +var modes = require('./modes') +var StreamCipher = require('./streamCipher') +var AuthCipher = require('./authCipher') +var ebtk = require('evp_bytestokey') +inherits(Decipher, Transform) function Decipher (mode, key, iv) { + if (!(this instanceof Decipher)) { + return new Decipher(mode, key, iv) + } Transform.call(this) - this._cache = new Splitter() this._last = void 0 this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) + this._prev = new Buffer(iv.length) + iv.copy(this._prev) this._mode = mode this._autopadding = true } - -inherits(Decipher, Transform) - Decipher.prototype._update = function (data) { this._cache.add(data) var chunk @@ -7283,7 +7256,6 @@ Decipher.prototype._update = function (data) { } return Buffer.concat(out) } - Decipher.prototype._final = function () { var chunk = this._cache.flush() if (this._autopadding) { @@ -7292,16 +7264,16 @@ Decipher.prototype._final = function () { throw new Error('data not multiple of block length') } } - Decipher.prototype.setAutoPadding = function (setTo) { this._autopadding = !!setTo return this } - function Splitter () { - this.cache = Buffer.allocUnsafe(0) + if (!(this instanceof Splitter)) { + return new Splitter() + } + this.cache = new Buffer('') } - Splitter.prototype.add = function (data) { this.cache = Buffer.concat([this.cache, data]) } @@ -7321,14 +7293,13 @@ Splitter.prototype.get = function (autoPadding) { return out } } - return null } - Splitter.prototype.flush = function () { - if (this.cache.length) return this.cache + if (this.cache.length) { + return this.cache + } } - function unpad (last) { var padded = last[15] var i = -1 @@ -7337,102 +7308,116 @@ function unpad (last) { throw new Error('unable to decrypt data') } } - if (padded === 16) return - + if (padded === 16) { + return + } return last.slice(0, 16 - padded) } -function createDecipheriv (suite, password, iv) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - if (typeof iv === 'string') iv = Buffer.from(iv) - if (iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - - if (typeof password === 'string') password = Buffer.from(password) - if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) +var modelist = { + ECB: require('./modes/ecb'), + CBC: require('./modes/cbc'), + CFB: require('./modes/cfb'), + CFB8: require('./modes/cfb8'), + CFB1: require('./modes/cfb1'), + OFB: require('./modes/ofb'), + CTR: require('./modes/ctr'), + GCM: require('./modes/ctr') +} +function createDecipheriv (suite, password, iv) { + var config = modes[suite.toLowerCase()] + if (!config) { + throw new TypeError('invalid suite type') + } + if (typeof iv === 'string') { + iv = new Buffer(iv) + } + if (typeof password === 'string') { + password = new Buffer(password) + } + if (password.length !== config.key / 8) { + throw new TypeError('invalid key length ' + password.length) + } + if (iv.length !== config.iv) { + throw new TypeError('invalid iv length ' + iv.length) + } if (config.type === 'stream') { - return new StreamCipher(config.module, password, iv, true) + return new StreamCipher(modelist[config.mode], password, iv, true) } else if (config.type === 'auth') { - return new AuthCipher(config.module, password, iv, true) + return new AuthCipher(modelist[config.mode], password, iv, true) } - - return new Decipher(config.module, password, iv) + return new Decipher(modelist[config.mode], password, iv) } function createDecipher (suite, password) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - + var config = modes[suite.toLowerCase()] + if (!config) { + throw new TypeError('invalid suite type') + } var keys = ebtk(password, false, config.key, config.iv) return createDecipheriv(suite, keys.key, keys.iv) } - exports.createDecipher = createDecipher exports.createDecipheriv = createDecipheriv -},{"./aes":30,"./authCipher":31,"./modes":42,"./streamCipher":45,"cipher-base":59,"evp_bytestokey":95,"inherits":112,"safe-buffer":154}],34:[function(require,module,exports){ -var MODES = require('./modes') -var AuthCipher = require('./authCipher') -var Buffer = require('safe-buffer').Buffer -var StreamCipher = require('./streamCipher') -var Transform = require('cipher-base') +}).call(this,require("buffer").Buffer) + +},{"./aes":30,"./authCipher":31,"./modes":36,"./modes/cbc":37,"./modes/cfb":38,"./modes/cfb1":39,"./modes/cfb8":40,"./modes/ctr":41,"./modes/ecb":42,"./modes/ofb":43,"./streamCipher":44,"buffer":57,"cipher-base":58,"evp_bytestokey":94,"inherits":111}],34:[function(require,module,exports){ +(function (Buffer){ var aes = require('./aes') -var ebtk = require('evp_bytestokey') +var Transform = require('cipher-base') var inherits = require('inherits') - +var modes = require('./modes') +var ebtk = require('evp_bytestokey') +var StreamCipher = require('./streamCipher') +var AuthCipher = require('./authCipher') +inherits(Cipher, Transform) function Cipher (mode, key, iv) { + if (!(this instanceof Cipher)) { + return new Cipher(mode, key, iv) + } Transform.call(this) - this._cache = new Splitter() this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) + this._prev = new Buffer(iv.length) + iv.copy(this._prev) this._mode = mode this._autopadding = true } - -inherits(Cipher, Transform) - Cipher.prototype._update = function (data) { this._cache.add(data) var chunk var thing var out = [] - while ((chunk = this._cache.get())) { thing = this._mode.encrypt(this, chunk) out.push(thing) } - return Buffer.concat(out) } - -var PADDING = Buffer.alloc(16, 0x10) - Cipher.prototype._final = function () { var chunk = this._cache.flush() if (this._autopadding) { chunk = this._mode.encrypt(this, chunk) this._cipher.scrub() return chunk - } - - if (!chunk.equals(PADDING)) { + } else if (chunk.toString('hex') !== '10101010101010101010101010101010') { this._cipher.scrub() throw new Error('data not multiple of block length') } } - Cipher.prototype.setAutoPadding = function (setTo) { this._autopadding = !!setTo return this } function Splitter () { - this.cache = Buffer.allocUnsafe(0) + if (!(this instanceof Splitter)) { + return new Splitter() + } + this.cache = new Buffer('') } - Splitter.prototype.add = function (data) { this.cache = Buffer.concat([this.cache, data]) } @@ -7445,42 +7430,57 @@ Splitter.prototype.get = function () { } return null } - Splitter.prototype.flush = function () { var len = 16 - this.cache.length - var padBuff = Buffer.allocUnsafe(len) + var padBuff = new Buffer(len) var i = -1 while (++i < len) { padBuff.writeUInt8(len, i) } - - return Buffer.concat([this.cache, padBuff]) + var out = Buffer.concat([this.cache, padBuff]) + return out +} +var modelist = { + ECB: require('./modes/ecb'), + CBC: require('./modes/cbc'), + CFB: require('./modes/cfb'), + CFB8: require('./modes/cfb8'), + CFB1: require('./modes/cfb1'), + OFB: require('./modes/ofb'), + CTR: require('./modes/ctr'), + GCM: require('./modes/ctr') } function createCipheriv (suite, password, iv) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - - if (typeof password === 'string') password = Buffer.from(password) - if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) - - if (typeof iv === 'string') iv = Buffer.from(iv) - if (iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - + var config = modes[suite.toLowerCase()] + if (!config) { + throw new TypeError('invalid suite type') + } + if (typeof iv === 'string') { + iv = new Buffer(iv) + } + if (typeof password === 'string') { + password = new Buffer(password) + } + if (password.length !== config.key / 8) { + throw new TypeError('invalid key length ' + password.length) + } + if (iv.length !== config.iv) { + throw new TypeError('invalid iv length ' + iv.length) + } if (config.type === 'stream') { - return new StreamCipher(config.module, password, iv) + return new StreamCipher(modelist[config.mode], password, iv) } else if (config.type === 'auth') { - return new AuthCipher(config.module, password, iv) + return new AuthCipher(modelist[config.mode], password, iv) } - - return new Cipher(config.module, password, iv) + return new Cipher(modelist[config.mode], password, iv) } - function createCipher (suite, password) { - var config = MODES[suite.toLowerCase()] - if (!config) throw new TypeError('invalid suite type') - + var config = modes[suite.toLowerCase()] + if (!config) { + throw new TypeError('invalid suite type') + } var keys = ebtk(password, false, config.key, config.iv) return createCipheriv(suite, keys.key, keys.iv) } @@ -7488,34 +7488,19 @@ function createCipher (suite, password) { exports.createCipheriv = createCipheriv exports.createCipher = createCipher -},{"./aes":30,"./authCipher":31,"./modes":42,"./streamCipher":45,"cipher-base":59,"evp_bytestokey":95,"inherits":112,"safe-buffer":154}],35:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var ZEROES = Buffer.alloc(16, 0) - -function toArray (buf) { - return [ - buf.readUInt32BE(0), - buf.readUInt32BE(4), - buf.readUInt32BE(8), - buf.readUInt32BE(12) - ] -} - -function fromArray (out) { - var buf = Buffer.allocUnsafe(16) - buf.writeUInt32BE(out[0] >>> 0, 0) - buf.writeUInt32BE(out[1] >>> 0, 4) - buf.writeUInt32BE(out[2] >>> 0, 8) - buf.writeUInt32BE(out[3] >>> 0, 12) - return buf -} +}).call(this,require("buffer").Buffer) +},{"./aes":30,"./authCipher":31,"./modes":36,"./modes/cbc":37,"./modes/cfb":38,"./modes/cfb1":39,"./modes/cfb8":40,"./modes/ctr":41,"./modes/ecb":42,"./modes/ofb":43,"./streamCipher":44,"buffer":57,"cipher-base":58,"evp_bytestokey":94,"inherits":111}],35:[function(require,module,exports){ +(function (Buffer){ +var zeros = new Buffer(16) +zeros.fill(0) +module.exports = GHASH function GHASH (key) { this.h = key - this.state = Buffer.alloc(16, 0) - this.cache = Buffer.allocUnsafe(0) + this.state = new Buffer(16) + this.state.fill(0) + this.cache = new Buffer('') } - // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html // by Juho Vähä-Herttua GHASH.prototype.ghash = function (block) { @@ -7529,20 +7514,17 @@ GHASH.prototype.ghash = function (block) { GHASH.prototype._multiply = function () { var Vi = toArray(this.h) var Zi = [0, 0, 0, 0] - var j, xi, lsbVi + var j, xi, lsb_Vi var i = -1 while (++i < 128) { - xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0 + xi = (this.state[~~(i / 8)] & (1 << (7 - i % 8))) !== 0 if (xi) { // Z_i+1 = Z_i ^ V_i - Zi[0] ^= Vi[0] - Zi[1] ^= Vi[1] - Zi[2] ^= Vi[2] - Zi[3] ^= Vi[3] + Zi = xor(Zi, Vi) } // Store the value of LSB(V_i) - lsbVi = (Vi[3] & 1) !== 0 + lsb_Vi = (Vi[3] & 1) !== 0 // V_i+1 = V_i >> 1 for (j = 3; j > 0; j--) { @@ -7551,13 +7533,12 @@ GHASH.prototype._multiply = function () { Vi[0] = Vi[0] >>> 1 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R - if (lsbVi) { + if (lsb_Vi) { Vi[0] = Vi[0] ^ (0xe1 << 24) } } this.state = fromArray(Zi) } - GHASH.prototype.update = function (buf) { this.cache = Buffer.concat([this.cache, buf]) var chunk @@ -7567,19 +7548,225 @@ GHASH.prototype.update = function (buf) { this.ghash(chunk) } } - GHASH.prototype.final = function (abl, bl) { if (this.cache.length) { - this.ghash(Buffer.concat([this.cache, ZEROES], 16)) + this.ghash(Buffer.concat([this.cache, zeros], 16)) } - - this.ghash(fromArray([0, abl, 0, bl])) + this.ghash(fromArray([ + 0, abl, + 0, bl + ])) return this.state } -module.exports = GHASH +function toArray (buf) { + return [ + buf.readUInt32BE(0), + buf.readUInt32BE(4), + buf.readUInt32BE(8), + buf.readUInt32BE(12) + ] +} +function fromArray (out) { + out = out.map(fixup_uint32) + var buf = new Buffer(16) + buf.writeUInt32BE(out[0], 0) + buf.writeUInt32BE(out[1], 4) + buf.writeUInt32BE(out[2], 8) + buf.writeUInt32BE(out[3], 12) + return buf +} +var uint_max = Math.pow(2, 32) +function fixup_uint32 (x) { + var ret, x_pos + ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x + return ret +} +function xor (a, b) { + return [ + a[0] ^ b[0], + a[1] ^ b[1], + a[2] ^ b[2], + a[3] ^ b[3] + ] +} -},{"safe-buffer":154}],36:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"buffer":57}],36:[function(require,module,exports){ +exports['aes-128-ecb'] = { + cipher: 'AES', + key: 128, + iv: 0, + mode: 'ECB', + type: 'block' +} +exports['aes-192-ecb'] = { + cipher: 'AES', + key: 192, + iv: 0, + mode: 'ECB', + type: 'block' +} +exports['aes-256-ecb'] = { + cipher: 'AES', + key: 256, + iv: 0, + mode: 'ECB', + type: 'block' +} +exports['aes-128-cbc'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'CBC', + type: 'block' +} +exports['aes-192-cbc'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'CBC', + type: 'block' +} +exports['aes-256-cbc'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'CBC', + type: 'block' +} +exports['aes128'] = exports['aes-128-cbc'] +exports['aes192'] = exports['aes-192-cbc'] +exports['aes256'] = exports['aes-256-cbc'] +exports['aes-128-cfb'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'CFB', + type: 'stream' +} +exports['aes-192-cfb'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'CFB', + type: 'stream' +} +exports['aes-256-cfb'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'CFB', + type: 'stream' +} +exports['aes-128-cfb8'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'CFB8', + type: 'stream' +} +exports['aes-192-cfb8'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'CFB8', + type: 'stream' +} +exports['aes-256-cfb8'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'CFB8', + type: 'stream' +} +exports['aes-128-cfb1'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'CFB1', + type: 'stream' +} +exports['aes-192-cfb1'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'CFB1', + type: 'stream' +} +exports['aes-256-cfb1'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'CFB1', + type: 'stream' +} +exports['aes-128-ofb'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'OFB', + type: 'stream' +} +exports['aes-192-ofb'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'OFB', + type: 'stream' +} +exports['aes-256-ofb'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'OFB', + type: 'stream' +} +exports['aes-128-ctr'] = { + cipher: 'AES', + key: 128, + iv: 16, + mode: 'CTR', + type: 'stream' +} +exports['aes-192-ctr'] = { + cipher: 'AES', + key: 192, + iv: 16, + mode: 'CTR', + type: 'stream' +} +exports['aes-256-ctr'] = { + cipher: 'AES', + key: 256, + iv: 16, + mode: 'CTR', + type: 'stream' +} +exports['aes-128-gcm'] = { + cipher: 'AES', + key: 128, + iv: 12, + mode: 'GCM', + type: 'auth' +} +exports['aes-192-gcm'] = { + cipher: 'AES', + key: 192, + iv: 12, + mode: 'GCM', + type: 'auth' +} +exports['aes-256-gcm'] = { + cipher: 'AES', + key: 256, + iv: 12, + mode: 'GCM', + type: 'auth' +} + +},{}],37:[function(require,module,exports){ var xor = require('buffer-xor') exports.encrypt = function (self, block) { @@ -7598,26 +7785,18 @@ exports.decrypt = function (self, block) { return xor(out, pad) } -},{"buffer-xor":57}],37:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer +},{"buffer-xor":56}],38:[function(require,module,exports){ +(function (Buffer){ var xor = require('buffer-xor') -function encryptStart (self, data, decrypt) { - var len = data.length - var out = xor(data, self._cache) - self._cache = self._cache.slice(len) - self._prev = Buffer.concat([self._prev, decrypt ? data : out]) - return out -} - exports.encrypt = function (self, data, decrypt) { - var out = Buffer.allocUnsafe(0) + var out = new Buffer('') var len while (data.length) { if (self._cache.length === 0) { self._cache = self._cipher.encryptBlock(self._prev) - self._prev = Buffer.allocUnsafe(0) + self._prev = new Buffer('') } if (self._cache.length <= data.length) { @@ -7632,10 +7811,18 @@ exports.encrypt = function (self, data, decrypt) { return out } +function encryptStart (self, data, decrypt) { + var len = data.length + var out = xor(data, self._cache) + self._cache = self._cache.slice(len) + self._prev = Buffer.concat([self._prev, decrypt ? data : out]) + return out +} -},{"buffer-xor":57,"safe-buffer":154}],38:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer +}).call(this,require("buffer").Buffer) +},{"buffer":57,"buffer-xor":56}],39:[function(require,module,exports){ +(function (Buffer){ function encryptByte (self, byteParam, decrypt) { var pad var i = -1 @@ -7651,61 +7838,49 @@ function encryptByte (self, byteParam, decrypt) { } return out } - -function shiftIn (buffer, value) { - var len = buffer.length +exports.encrypt = function (self, chunk, decrypt) { + var len = chunk.length + var out = new Buffer(len) var i = -1 - var out = Buffer.allocUnsafe(buffer.length) - buffer = Buffer.concat([buffer, Buffer.from([value])]) - while (++i < len) { - out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) + out[i] = encryptByte(self, chunk[i], decrypt) } - return out } - -exports.encrypt = function (self, chunk, decrypt) { - var len = chunk.length - var out = Buffer.allocUnsafe(len) +function shiftIn (buffer, value) { + var len = buffer.length var i = -1 - + var out = new Buffer(buffer.length) + buffer = Buffer.concat([buffer, new Buffer([value])]) while (++i < len) { - out[i] = encryptByte(self, chunk[i], decrypt) + out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) } - return out } -},{"safe-buffer":154}],39:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"buffer":57}],40:[function(require,module,exports){ (function (Buffer){ function encryptByte (self, byteParam, decrypt) { var pad = self._cipher.encryptBlock(self._prev) var out = pad[0] ^ byteParam - - self._prev = Buffer.concat([ - self._prev.slice(1), - Buffer.from([decrypt ? byteParam : out]) - ]) - + self._prev = Buffer.concat([self._prev.slice(1), new Buffer([decrypt ? byteParam : out])]) return out } - exports.encrypt = function (self, chunk, decrypt) { var len = chunk.length - var out = Buffer.allocUnsafe(len) + var out = new Buffer(len) var i = -1 - while (++i < len) { out[i] = encryptByte(self, chunk[i], decrypt) } - return out } }).call(this,require("buffer").Buffer) -},{"buffer":58}],40:[function(require,module,exports){ +},{"buffer":57}],41:[function(require,module,exports){ (function (Buffer){ var xor = require('buffer-xor') @@ -7725,26 +7900,14 @@ function incr32 (iv) { } function getBlock (self) { - var out = self._cipher.encryptBlockRaw(self._prev) + var out = self._cipher.encryptBlock(self._prev) incr32(self._prev) return out } -var blockSize = 16 exports.encrypt = function (self, chunk) { - var chunkNum = Math.ceil(chunk.length / blockSize) - var start = self._cache.length - self._cache = Buffer.concat([ - self._cache, - Buffer.allocUnsafe(chunkNum * blockSize) - ]) - for (var i = 0; i < chunkNum; i++) { - var out = getBlock(self) - var offset = start + i * blockSize - self._cache.writeUInt32BE(out[0], offset + 0) - self._cache.writeUInt32BE(out[1], offset + 4) - self._cache.writeUInt32BE(out[2], offset + 8) - self._cache.writeUInt32BE(out[3], offset + 12) + while (self._cache.length < chunk.length) { + self._cache = Buffer.concat([self._cache, getBlock(self)]) } var pad = self._cache.slice(0, chunk.length) self._cache = self._cache.slice(chunk.length) @@ -7753,229 +7916,15 @@ exports.encrypt = function (self, chunk) { }).call(this,require("buffer").Buffer) -},{"buffer":58,"buffer-xor":57}],41:[function(require,module,exports){ +},{"buffer":57,"buffer-xor":56}],42:[function(require,module,exports){ exports.encrypt = function (self, block) { return self._cipher.encryptBlock(block) } - exports.decrypt = function (self, block) { return self._cipher.decryptBlock(block) } -},{}],42:[function(require,module,exports){ -var modeModules = { - ECB: require('./ecb'), - CBC: require('./cbc'), - CFB: require('./cfb'), - CFB8: require('./cfb8'), - CFB1: require('./cfb1'), - OFB: require('./ofb'), - CTR: require('./ctr'), - GCM: require('./ctr') -} - -var modes = require('./list.json') - -for (var key in modes) { - modes[key].module = modeModules[modes[key].mode] -} - -module.exports = modes - -},{"./cbc":36,"./cfb":37,"./cfb1":38,"./cfb8":39,"./ctr":40,"./ecb":41,"./list.json":43,"./ofb":44}],43:[function(require,module,exports){ -module.exports={ - "aes-128-ecb": { - "cipher": "AES", - "key": 128, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-192-ecb": { - "cipher": "AES", - "key": 192, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-256-ecb": { - "cipher": "AES", - "key": 256, - "iv": 0, - "mode": "ECB", - "type": "block" - }, - "aes-128-cbc": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-192-cbc": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-256-cbc": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes128": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes192": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes256": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CBC", - "type": "block" - }, - "aes-128-cfb": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-192-cfb": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-256-cfb": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB", - "type": "stream" - }, - "aes-128-cfb8": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-192-cfb8": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-256-cfb8": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB8", - "type": "stream" - }, - "aes-128-cfb1": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-192-cfb1": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-256-cfb1": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CFB1", - "type": "stream" - }, - "aes-128-ofb": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-192-ofb": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-256-ofb": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "OFB", - "type": "stream" - }, - "aes-128-ctr": { - "cipher": "AES", - "key": 128, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-192-ctr": { - "cipher": "AES", - "key": 192, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-256-ctr": { - "cipher": "AES", - "key": 256, - "iv": 16, - "mode": "CTR", - "type": "stream" - }, - "aes-128-gcm": { - "cipher": "AES", - "key": 128, - "iv": 12, - "mode": "GCM", - "type": "auth" - }, - "aes-192-gcm": { - "cipher": "AES", - "key": 192, - "iv": 12, - "mode": "GCM", - "type": "auth" - }, - "aes-256-gcm": { - "cipher": "AES", - "key": 256, - "iv": 12, - "mode": "GCM", - "type": "auth" - } -} - -},{}],44:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ (function (Buffer){ var xor = require('buffer-xor') @@ -7996,36 +7945,37 @@ exports.encrypt = function (self, chunk) { }).call(this,require("buffer").Buffer) -},{"buffer":58,"buffer-xor":57}],45:[function(require,module,exports){ +},{"buffer":57,"buffer-xor":56}],44:[function(require,module,exports){ +(function (Buffer){ var aes = require('./aes') -var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') var inherits = require('inherits') +inherits(StreamCipher, Transform) +module.exports = StreamCipher function StreamCipher (mode, key, iv, decrypt) { + if (!(this instanceof StreamCipher)) { + return new StreamCipher(mode, key, iv) + } Transform.call(this) - this._cipher = new aes.AES(key) - this._prev = Buffer.from(iv) - this._cache = Buffer.allocUnsafe(0) - this._secCache = Buffer.allocUnsafe(0) + this._prev = new Buffer(iv.length) + this._cache = new Buffer('') + this._secCache = new Buffer('') this._decrypt = decrypt + iv.copy(this._prev) this._mode = mode } - -inherits(StreamCipher, Transform) - StreamCipher.prototype._update = function (chunk) { return this._mode.encrypt(this, chunk, this._decrypt) } - StreamCipher.prototype._final = function () { this._cipher.scrub() } -module.exports = StreamCipher +}).call(this,require("buffer").Buffer) -},{"./aes":30,"cipher-base":59,"inherits":112,"safe-buffer":154}],46:[function(require,module,exports){ +},{"./aes":30,"buffer":57,"cipher-base":58,"inherits":111}],45:[function(require,module,exports){ var ebtk = require('evp_bytestokey') var aes = require('browserify-aes/browser') var DES = require('browserify-des') @@ -8100,7 +8050,7 @@ function getCiphers () { } exports.listCiphers = exports.getCiphers = getCiphers -},{"browserify-aes/browser":32,"browserify-aes/modes":42,"browserify-des":47,"browserify-des/modes":48,"evp_bytestokey":95}],47:[function(require,module,exports){ +},{"browserify-aes/browser":32,"browserify-aes/modes":36,"browserify-des":46,"browserify-des/modes":47,"evp_bytestokey":94}],46:[function(require,module,exports){ (function (Buffer){ var CipherBase = require('cipher-base') var des = require('des.js') @@ -8148,7 +8098,7 @@ DES.prototype._final = function () { }).call(this,require("buffer").Buffer) -},{"buffer":58,"cipher-base":59,"des.js":68,"inherits":112}],48:[function(require,module,exports){ +},{"buffer":57,"cipher-base":58,"des.js":67,"inherits":111}],47:[function(require,module,exports){ exports['des-ecb'] = { key: 8, iv: 0 @@ -8174,7 +8124,7 @@ exports['des-ede'] = { iv: 0 } -},{}],49:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ (function (Buffer){ var bn = require('bn.js'); var randomBytes = require('randombytes'); @@ -8219,10 +8169,10 @@ function getr(priv) { }).call(this,require("buffer").Buffer) -},{"bn.js":27,"buffer":58,"randombytes":139}],50:[function(require,module,exports){ +},{"bn.js":27,"buffer":57,"randombytes":138}],49:[function(require,module,exports){ module.exports = require('./browser/algorithms.json') -},{"./browser/algorithms.json":51}],51:[function(require,module,exports){ +},{"./browser/algorithms.json":50}],50:[function(require,module,exports){ module.exports={ "sha224WithRSAEncryption": { "sign": "rsa", @@ -8376,7 +8326,7 @@ module.exports={ } } -},{}],52:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ module.exports={ "1.3.132.0.10": "secp256k1", "1.3.132.0.33": "p224", @@ -8386,7 +8336,7 @@ module.exports={ "1.3.132.0.35": "p521" } -},{}],53:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ (function (Buffer){ var createHash = require('create-hash') var stream = require('stream') @@ -8482,7 +8432,7 @@ module.exports = { }).call(this,require("buffer").Buffer) -},{"./algorithms.json":51,"./sign":54,"./verify":55,"buffer":58,"create-hash":62,"inherits":112,"stream":165}],54:[function(require,module,exports){ +},{"./algorithms.json":50,"./sign":53,"./verify":54,"buffer":57,"create-hash":61,"inherits":111,"stream":164}],53:[function(require,module,exports){ (function (Buffer){ // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js var createHmac = require('create-hmac') @@ -8632,7 +8582,7 @@ module.exports.makeKey = makeKey }).call(this,require("buffer").Buffer) -},{"./curves.json":52,"bn.js":27,"browserify-rsa":49,"buffer":58,"create-hmac":65,"elliptic":78,"parse-asn1":125}],55:[function(require,module,exports){ +},{"./curves.json":51,"bn.js":27,"browserify-rsa":48,"buffer":57,"create-hmac":64,"elliptic":77,"parse-asn1":124}],54:[function(require,module,exports){ (function (Buffer){ // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js var BN = require('bn.js') @@ -8720,7 +8670,7 @@ module.exports = verify }).call(this,require("buffer").Buffer) -},{"./curves.json":52,"bn.js":27,"buffer":58,"elliptic":78,"parse-asn1":125}],56:[function(require,module,exports){ +},{"./curves.json":51,"bn.js":27,"buffer":57,"elliptic":77,"parse-asn1":124}],55:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -8943,7 +8893,7 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":58}],57:[function(require,module,exports){ +},{"buffer":57}],56:[function(require,module,exports){ (function (Buffer){ module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) @@ -8958,7 +8908,7 @@ module.exports = function xor (a, b) { }).call(this,require("buffer").Buffer) -},{"buffer":58}],58:[function(require,module,exports){ +},{"buffer":57}],57:[function(require,module,exports){ (function (global){ /*! * The buffer module from node.js, for the browser. @@ -10752,7 +10702,7 @@ function isnan (val) { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"base64-js":26,"ieee754":110,"isarray":114}],59:[function(require,module,exports){ +},{"base64-js":26,"ieee754":109,"isarray":113}],58:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var StringDecoder = require('string_decoder').StringDecoder @@ -10853,7 +10803,7 @@ CipherBase.prototype._toString = function (value, enc, fin) { module.exports = CipherBase -},{"inherits":112,"safe-buffer":154,"stream":165,"string_decoder":56}],60:[function(require,module,exports){ +},{"inherits":111,"safe-buffer":153,"stream":164,"string_decoder":55}],59:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -10965,7 +10915,7 @@ function objectToString(o) { }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":113}],61:[function(require,module,exports){ +},{"../../is-buffer/index.js":112}],60:[function(require,module,exports){ (function (Buffer){ var elliptic = require('elliptic'); var BN = require('bn.js'); @@ -11092,7 +11042,7 @@ function formatReturnValue(bn, enc, len) { }).call(this,require("buffer").Buffer) -},{"bn.js":27,"buffer":58,"elliptic":78}],62:[function(require,module,exports){ +},{"bn.js":27,"buffer":57,"elliptic":77}],61:[function(require,module,exports){ (function (Buffer){ 'use strict' var inherits = require('inherits') @@ -11149,7 +11099,7 @@ module.exports = function createHash (alg) { }).call(this,require("buffer").Buffer) -},{"./md5":64,"buffer":58,"cipher-base":59,"inherits":112,"ripemd160":153,"sha.js":157}],63:[function(require,module,exports){ +},{"./md5":63,"buffer":57,"cipher-base":58,"inherits":111,"ripemd160":152,"sha.js":156}],62:[function(require,module,exports){ (function (Buffer){ 'use strict' var intSize = 4 @@ -11184,7 +11134,7 @@ module.exports = function hash (buf, fn) { }).call(this,require("buffer").Buffer) -},{"buffer":58}],64:[function(require,module,exports){ +},{"buffer":57}],63:[function(require,module,exports){ 'use strict' /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message @@ -11337,7 +11287,7 @@ module.exports = function md5 (buf) { return makeHash(buf, core_md5) } -},{"./make-hash":63}],65:[function(require,module,exports){ +},{"./make-hash":62}],64:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Legacy = require('./legacy') @@ -11401,7 +11351,7 @@ module.exports = function createHmac (alg, key) { return new Hmac(alg, key) } -},{"./legacy":66,"cipher-base":59,"create-hash/md5":64,"inherits":112,"ripemd160":153,"safe-buffer":154,"sha.js":157}],66:[function(require,module,exports){ +},{"./legacy":65,"cipher-base":58,"create-hash/md5":63,"inherits":111,"ripemd160":152,"safe-buffer":153,"sha.js":156}],65:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Buffer = require('safe-buffer').Buffer @@ -11449,7 +11399,7 @@ Hmac.prototype._final = function () { } module.exports = Hmac -},{"cipher-base":59,"inherits":112,"safe-buffer":154}],67:[function(require,module,exports){ +},{"cipher-base":58,"inherits":111,"safe-buffer":153}],66:[function(require,module,exports){ 'use strict' exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') @@ -11543,7 +11493,7 @@ exports.constants = { 'POINT_CONVERSION_HYBRID': 6 } -},{"browserify-cipher":46,"browserify-sign":53,"browserify-sign/algos":50,"create-ecdh":61,"create-hash":62,"create-hmac":65,"diffie-hellman":74,"pbkdf2":126,"public-encrypt":133,"randombytes":139}],68:[function(require,module,exports){ +},{"browserify-cipher":45,"browserify-sign":52,"browserify-sign/algos":49,"create-ecdh":60,"create-hash":61,"create-hmac":64,"diffie-hellman":73,"pbkdf2":125,"public-encrypt":132,"randombytes":138}],67:[function(require,module,exports){ 'use strict'; exports.utils = require('./des/utils'); @@ -11552,7 +11502,7 @@ exports.DES = require('./des/des'); exports.CBC = require('./des/cbc'); exports.EDE = require('./des/ede'); -},{"./des/cbc":69,"./des/cipher":70,"./des/des":71,"./des/ede":72,"./des/utils":73}],69:[function(require,module,exports){ +},{"./des/cbc":68,"./des/cipher":69,"./des/des":70,"./des/ede":71,"./des/utils":72}],68:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -11619,7 +11569,7 @@ proto._update = function _update(inp, inOff, out, outOff) { } }; -},{"inherits":112,"minimalistic-assert":118}],70:[function(require,module,exports){ +},{"inherits":111,"minimalistic-assert":117}],69:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -11762,7 +11712,7 @@ Cipher.prototype._finalDecrypt = function _finalDecrypt() { return this._unpad(out); }; -},{"minimalistic-assert":118}],71:[function(require,module,exports){ +},{"minimalistic-assert":117}],70:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -11907,7 +11857,7 @@ DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { utils.rip(l, r, out, off); }; -},{"../des":68,"inherits":112,"minimalistic-assert":118}],72:[function(require,module,exports){ +},{"../des":67,"inherits":111,"minimalistic-assert":117}],71:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -11964,7 +11914,7 @@ EDE.prototype._update = function _update(inp, inOff, out, outOff) { EDE.prototype._pad = DES.prototype._pad; EDE.prototype._unpad = DES.prototype._unpad; -},{"../des":68,"inherits":112,"minimalistic-assert":118}],73:[function(require,module,exports){ +},{"../des":67,"inherits":111,"minimalistic-assert":117}],72:[function(require,module,exports){ 'use strict'; exports.readUInt32BE = function readUInt32BE(bytes, off) { @@ -12222,7 +12172,7 @@ exports.padSplit = function padSplit(num, size, group) { return out.join(' '); }; -},{}],74:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ (function (Buffer){ var generatePrime = require('./lib/generatePrime') var primes = require('./lib/primes.json') @@ -12269,7 +12219,7 @@ exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman }).call(this,require("buffer").Buffer) -},{"./lib/dh":75,"./lib/generatePrime":76,"./lib/primes.json":77,"buffer":58}],75:[function(require,module,exports){ +},{"./lib/dh":74,"./lib/generatePrime":75,"./lib/primes.json":76,"buffer":57}],74:[function(require,module,exports){ (function (Buffer){ var BN = require('bn.js'); var MillerRabin = require('miller-rabin'); @@ -12438,7 +12388,7 @@ function formatReturnValue(bn, enc) { }).call(this,require("buffer").Buffer) -},{"./generatePrime":76,"bn.js":27,"buffer":58,"miller-rabin":117,"randombytes":139}],76:[function(require,module,exports){ +},{"./generatePrime":75,"bn.js":27,"buffer":57,"miller-rabin":116,"randombytes":138}],75:[function(require,module,exports){ var randomBytes = require('randombytes'); module.exports = findPrime; findPrime.simpleSieve = simpleSieve; @@ -12545,7 +12495,7 @@ function findPrime(bits, gen) { } -},{"bn.js":27,"miller-rabin":117,"randombytes":139}],77:[function(require,module,exports){ +},{"bn.js":27,"miller-rabin":116,"randombytes":138}],76:[function(require,module,exports){ module.exports={ "modp1": { "gen": "02", @@ -12580,7 +12530,7 @@ module.exports={ "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" } } -},{}],78:[function(require,module,exports){ +},{}],77:[function(require,module,exports){ 'use strict'; var elliptic = exports; @@ -12595,7 +12545,7 @@ elliptic.curves = require('./elliptic/curves'); elliptic.ec = require('./elliptic/ec'); elliptic.eddsa = require('./elliptic/eddsa'); -},{"../package.json":93,"./elliptic/curve":81,"./elliptic/curves":84,"./elliptic/ec":85,"./elliptic/eddsa":88,"./elliptic/utils":92,"brorand":28}],79:[function(require,module,exports){ +},{"../package.json":92,"./elliptic/curve":80,"./elliptic/curves":83,"./elliptic/ec":84,"./elliptic/eddsa":87,"./elliptic/utils":91,"brorand":28}],78:[function(require,module,exports){ 'use strict'; var BN = require('bn.js'); @@ -12972,7 +12922,7 @@ BasePoint.prototype.dblp = function dblp(k) { return r; }; -},{"../../elliptic":78,"bn.js":27}],80:[function(require,module,exports){ +},{"../../elliptic":77,"bn.js":27}],79:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -13407,7 +13357,7 @@ Point.prototype.eqXToP = function eqXToP(x) { Point.prototype.toP = Point.prototype.normalize; Point.prototype.mixedAdd = Point.prototype.add; -},{"../../elliptic":78,"../curve":81,"bn.js":27,"inherits":112}],81:[function(require,module,exports){ +},{"../../elliptic":77,"../curve":80,"bn.js":27,"inherits":111}],80:[function(require,module,exports){ 'use strict'; var curve = exports; @@ -13417,7 +13367,7 @@ curve.short = require('./short'); curve.mont = require('./mont'); curve.edwards = require('./edwards'); -},{"./base":79,"./edwards":80,"./mont":82,"./short":83}],82:[function(require,module,exports){ +},{"./base":78,"./edwards":79,"./mont":81,"./short":82}],81:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -13599,7 +13549,7 @@ Point.prototype.getX = function getX() { return this.x.fromRed(); }; -},{"../../elliptic":78,"../curve":81,"bn.js":27,"inherits":112}],83:[function(require,module,exports){ +},{"../../elliptic":77,"../curve":80,"bn.js":27,"inherits":111}],82:[function(require,module,exports){ 'use strict'; var curve = require('../curve'); @@ -14539,7 +14489,7 @@ JPoint.prototype.isInfinity = function isInfinity() { return this.z.cmpn(0) === 0; }; -},{"../../elliptic":78,"../curve":81,"bn.js":27,"inherits":112}],84:[function(require,module,exports){ +},{"../../elliptic":77,"../curve":80,"bn.js":27,"inherits":111}],83:[function(require,module,exports){ 'use strict'; var curves = exports; @@ -14746,7 +14696,7 @@ defineCurve('secp256k1', { ] }); -},{"../elliptic":78,"./precomputed/secp256k1":91,"hash.js":97}],85:[function(require,module,exports){ +},{"../elliptic":77,"./precomputed/secp256k1":90,"hash.js":96}],84:[function(require,module,exports){ 'use strict'; var BN = require('bn.js'); @@ -14988,7 +14938,7 @@ EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { throw new Error('Unable to find valid recovery factor'); }; -},{"../../elliptic":78,"./key":86,"./signature":87,"bn.js":27,"hmac-drbg":109}],86:[function(require,module,exports){ +},{"../../elliptic":77,"./key":85,"./signature":86,"bn.js":27,"hmac-drbg":108}],85:[function(require,module,exports){ 'use strict'; var BN = require('bn.js'); @@ -15109,7 +15059,7 @@ KeyPair.prototype.inspect = function inspect() { ' pub: ' + (this.pub && this.pub.inspect()) + ' >'; }; -},{"../../elliptic":78,"bn.js":27}],87:[function(require,module,exports){ +},{"../../elliptic":77,"bn.js":27}],86:[function(require,module,exports){ 'use strict'; var BN = require('bn.js'); @@ -15246,7 +15196,7 @@ Signature.prototype.toDER = function toDER(enc) { return utils.encode(res, enc); }; -},{"../../elliptic":78,"bn.js":27}],88:[function(require,module,exports){ +},{"../../elliptic":77,"bn.js":27}],87:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -15366,7 +15316,7 @@ EDDSA.prototype.isPoint = function isPoint(val) { return val instanceof this.pointClass; }; -},{"../../elliptic":78,"./key":89,"./signature":90,"hash.js":97}],89:[function(require,module,exports){ +},{"../../elliptic":77,"./key":88,"./signature":89,"hash.js":96}],88:[function(require,module,exports){ 'use strict'; var elliptic = require('../../elliptic'); @@ -15464,7 +15414,7 @@ KeyPair.prototype.getPublic = function getPublic(enc) { module.exports = KeyPair; -},{"../../elliptic":78}],90:[function(require,module,exports){ +},{"../../elliptic":77}],89:[function(require,module,exports){ 'use strict'; var BN = require('bn.js'); @@ -15532,7 +15482,7 @@ Signature.prototype.toHex = function toHex() { module.exports = Signature; -},{"../../elliptic":78,"bn.js":27}],91:[function(require,module,exports){ +},{"../../elliptic":77,"bn.js":27}],90:[function(require,module,exports){ module.exports = { doubles: { step: 4, @@ -16314,7 +16264,7 @@ module.exports = { } }; -},{}],92:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -16436,45 +16386,23 @@ function intFromLE(bytes) { utils.intFromLE = intFromLE; -},{"bn.js":27,"minimalistic-assert":118,"minimalistic-crypto-utils":119}],93:[function(require,module,exports){ +},{"bn.js":27,"minimalistic-assert":117,"minimalistic-crypto-utils":118}],92:[function(require,module,exports){ module.exports={ - "_args": [ - [ - { - "raw": "elliptic@^6.0.0", - "scope": null, - "escapedName": "elliptic", - "name": "elliptic", - "rawSpec": "^6.0.0", - "spec": ">=6.0.0 <7.0.0", - "type": "range" - }, - "D:\\vs\\padlock\\node_modules\\browserify-sign" - ] - ], - "_from": "elliptic@>=6.0.0 <7.0.0", + "_from": "elliptic@^6.0.0", "_id": "elliptic@6.4.0", - "_inCache": true, + "_inBundle": false, + "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", "_location": "/elliptic", - "_nodeVersion": "7.0.0", - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/elliptic-6.4.0.tgz_1487798866428_0.30510620190761983" - }, - "_npmUser": { - "name": "indutny", - "email": "fedor@indutny.com" - }, - "_npmVersion": "3.10.8", "_phantomChildren": {}, "_requested": { + "type": "range", + "registry": true, "raw": "elliptic@^6.0.0", - "scope": null, - "escapedName": "elliptic", "name": "elliptic", + "escapedName": "elliptic", "rawSpec": "^6.0.0", - "spec": ">=6.0.0 <7.0.0", - "type": "range" + "saveSpec": null, + "fetchSpec": "^6.0.0" }, "_requiredBy": [ "/browserify-sign", @@ -16482,9 +16410,8 @@ module.exports={ ], "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", "_shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df", - "_shrinkwrap": null, "_spec": "elliptic@^6.0.0", - "_where": "D:\\vs\\padlock\\node_modules\\browserify-sign", + "_where": "/Users/martin/workspace/padlock/node_modules/browserify-sign", "author": { "name": "Fedor Indutny", "email": "fedor@indutny.com" @@ -16492,6 +16419,7 @@ module.exports={ "bugs": { "url": "https://github.com/indutny/elliptic/issues" }, + "bundleDependencies": false, "dependencies": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -16501,6 +16429,7 @@ module.exports={ "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.0" }, + "deprecated": false, "description": "EC cryptography", "devDependencies": { "brfs": "^1.4.3", @@ -16518,15 +16447,9 @@ module.exports={ "jshint": "^2.6.0", "mocha": "^2.1.0" }, - "directories": {}, - "dist": { - "shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df", - "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz" - }, "files": [ "lib" ], - "gitHead": "6b0d2b76caae91471649c8e21f0b1d3ba0f96090", "homepage": "https://github.com/indutny/elliptic", "keywords": [ "EC", @@ -16536,15 +16459,7 @@ module.exports={ ], "license": "MIT", "main": "lib/elliptic.js", - "maintainers": [ - { - "name": "indutny", - "email": "fedor@indutny.com" - } - ], "name": "elliptic", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", "repository": { "type": "git", "url": "git+ssh://git@github.com/indutny/elliptic.git" @@ -16560,7 +16475,7 @@ module.exports={ "version": "6.4.0" } -},{}],94:[function(require,module,exports){ +},{}],93:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -16864,21 +16779,20 @@ function isUndefined(arg) { return arg === void 0; } -},{}],95:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var MD5 = require('md5.js') /* eslint-disable camelcase */ -function EVP_BytesToKey (password, salt, keyBits, ivLen) { +function EVP_BytesToKey (password, salt, keyLen, ivLen) { if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') if (salt) { if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') } - var keyLen = keyBits / 8 var key = Buffer.alloc(keyLen) - var iv = Buffer.alloc(ivLen || 0) + var iv = Buffer.alloc(ivLen) var tmp = Buffer.alloc(0) while (keyLen > 0 || ivLen > 0) { @@ -16911,7 +16825,7 @@ function EVP_BytesToKey (password, salt, keyBits, ivLen) { module.exports = EVP_BytesToKey -},{"md5.js":115,"safe-buffer":154}],96:[function(require,module,exports){ +},{"md5.js":114,"safe-buffer":153}],95:[function(require,module,exports){ (function (Buffer){ 'use strict' var Transform = require('stream').Transform @@ -16999,7 +16913,7 @@ module.exports = HashBase }).call(this,require("buffer").Buffer) -},{"buffer":58,"inherits":112,"stream":165}],97:[function(require,module,exports){ +},{"buffer":57,"inherits":111,"stream":164}],96:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -17016,7 +16930,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":98,"./hash/hmac":99,"./hash/ripemd":100,"./hash/sha":101,"./hash/utils":108}],98:[function(require,module,exports){ +},{"./hash/common":97,"./hash/hmac":98,"./hash/ripemd":99,"./hash/sha":100,"./hash/utils":107}],97:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -17110,7 +17024,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":108,"minimalistic-assert":118}],99:[function(require,module,exports){ +},{"./utils":107,"minimalistic-assert":117}],98:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -17159,7 +17073,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":108,"minimalistic-assert":118}],100:[function(require,module,exports){ +},{"./utils":107,"minimalistic-assert":117}],99:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -17307,7 +17221,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":98,"./utils":108}],101:[function(require,module,exports){ +},{"./common":97,"./utils":107}],100:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -17316,7 +17230,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":102,"./sha/224":103,"./sha/256":104,"./sha/384":105,"./sha/512":106}],102:[function(require,module,exports){ +},{"./sha/1":101,"./sha/224":102,"./sha/256":103,"./sha/384":104,"./sha/512":105}],101:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17392,7 +17306,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":98,"../utils":108,"./common":107}],103:[function(require,module,exports){ +},{"../common":97,"../utils":107,"./common":106}],102:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17424,7 +17338,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":108,"./256":104}],104:[function(require,module,exports){ +},{"../utils":107,"./256":103}],103:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17531,7 +17445,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":98,"../utils":108,"./common":107,"minimalistic-assert":118}],105:[function(require,module,exports){ +},{"../common":97,"../utils":107,"./common":106,"minimalistic-assert":117}],104:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17568,7 +17482,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":108,"./512":106}],106:[function(require,module,exports){ +},{"../utils":107,"./512":105}],105:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17900,7 +17814,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":98,"../utils":108,"minimalistic-assert":118}],107:[function(require,module,exports){ +},{"../common":97,"../utils":107,"minimalistic-assert":117}],106:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -17951,7 +17865,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":108}],108:[function(require,module,exports){ +},{"../utils":107}],107:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -18206,7 +18120,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":112,"minimalistic-assert":118}],109:[function(require,module,exports){ +},{"inherits":111,"minimalistic-assert":117}],108:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -18321,7 +18235,7 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":97,"minimalistic-assert":118,"minimalistic-crypto-utils":119}],110:[function(require,module,exports){ +},{"hash.js":96,"minimalistic-assert":117,"minimalistic-crypto-utils":118}],109:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -18407,7 +18321,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],111:[function(require,module,exports){ +},{}],110:[function(require,module,exports){ var indexOf = [].indexOf; @@ -18418,7 +18332,7 @@ module.exports = function(arr, obj){ } return -1; }; -},{}],112:[function(require,module,exports){ +},{}],111:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -18443,7 +18357,7 @@ if (typeof Object.create === 'function') { } } -},{}],113:[function(require,module,exports){ +},{}],112:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -18466,14 +18380,14 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],114:[function(require,module,exports){ +},{}],113:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],115:[function(require,module,exports){ +},{}],114:[function(require,module,exports){ (function (Buffer){ 'use strict' var inherits = require('inherits') @@ -18623,7 +18537,7 @@ module.exports = MD5 }).call(this,require("buffer").Buffer) -},{"buffer":58,"hash-base":116,"inherits":112}],116:[function(require,module,exports){ +},{"buffer":57,"hash-base":115,"inherits":111}],115:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform @@ -18720,7 +18634,7 @@ HashBase.prototype._digest = function () { module.exports = HashBase -},{"inherits":112,"safe-buffer":154,"stream":165}],117:[function(require,module,exports){ +},{"inherits":111,"safe-buffer":153,"stream":164}],116:[function(require,module,exports){ var bn = require('bn.js'); var brorand = require('brorand'); @@ -18733,24 +18647,20 @@ MillerRabin.create = function create(rand) { return new MillerRabin(rand); }; -MillerRabin.prototype._randbelow = function _randbelow(n) { +MillerRabin.prototype._rand = function _rand(n) { var len = n.bitLength(); - var min_bytes = Math.ceil(len / 8); + var buf = this.rand.generate(Math.ceil(len / 8)); - // Generage random bytes until a number less than n is found. - // This ensures that 0..n-1 have an equal probability of being selected. - do - var a = new bn(this.rand.generate(min_bytes)); - while (a.cmp(n) >= 0); + // Set low bits + buf[0] |= 3; - return a; -}; + // Mask high bits + var mask = len & 0x7; + if (mask !== 0) + buf[buf.length - 1] >>= 7 - mask; -MillerRabin.prototype._randrange = function _randrange(start, stop) { - // Generate a random number greater than or equal to start and less than stop. - var size = stop.sub(start); - return start.add(this._randbelow(size)); -}; + return new bn(buf); +} MillerRabin.prototype.test = function test(n, k, cb) { var len = n.bitLength(); @@ -18762,6 +18672,7 @@ MillerRabin.prototype.test = function test(n, k, cb) { // Find d and s, (n - 1) = (2 ^ s) * d; var n1 = n.subn(1); + var n2 = n1.subn(1); for (var s = 0; !n1.testn(s); s++) {} var d = n.shrn(s); @@ -18769,7 +18680,7 @@ MillerRabin.prototype.test = function test(n, k, cb) { var prime = true; for (; k > 0; k--) { - var a = this._randrange(new bn(2), n1); + var a = this._rand(n2); if (cb) cb(a); @@ -18803,13 +18714,14 @@ MillerRabin.prototype.getDivisor = function getDivisor(n, k) { // Find d and s, (n - 1) = (2 ^ s) * d; var n1 = n.subn(1); + var n2 = n1.subn(1); for (var s = 0; !n1.testn(s); s++) {} var d = n.shrn(s); var rn1 = n1.toRed(red); for (; k > 0; k--) { - var a = this._randrange(new bn(2), n1); + var a = this._rand(n2); var g = n.gcd(a); if (g.cmpn(1) !== 0) @@ -18837,7 +18749,7 @@ MillerRabin.prototype.getDivisor = function getDivisor(n, k) { return false; }; -},{"bn.js":27,"brorand":28}],118:[function(require,module,exports){ +},{"bn.js":27,"brorand":28}],117:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -18850,7 +18762,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],119:[function(require,module,exports){ +},{}],118:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -18910,10 +18822,10 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],120:[function(require,module,exports){ +},{}],119:[function(require,module,exports){ /*! Papa Parse - v4.3.6 + v4.3.5 https://github.com/mholt/PapaParse License: MIT */ @@ -20163,7 +20075,6 @@ utils.encode = function encode(arr, enc) { // Find closing quote var quoteSearch = input.indexOf(quoteChar, quoteSearch+1); - //No other quotes are found - no other delimiters if (quoteSearch === -1) { if (!ignoreLastRow) { @@ -20179,9 +20090,9 @@ utils.encode = function encode(arr, enc) { return finish(); } - // Closing quote at EOF if (quoteSearch === inputLen-1) { + // Closing quote at EOF var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar); return finish(value); } @@ -20193,9 +20104,9 @@ utils.encode = function encode(arr, enc) { continue; } - // Closing quote followed by delimiter if (input[quoteSearch+1] === delim) { + // Closing quote followed by delimiter row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar)); cursor = quoteSearch + 1 + delimLen; nextDelim = input.indexOf(delim, cursor); @@ -20203,9 +20114,9 @@ utils.encode = function encode(arr, enc) { break; } - // Closing quote followed by newline if (input.substr(quoteSearch+1, newlineLen) === newline) { + // Closing quote followed by newline row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar)); saveRow(quoteSearch + 1 + newlineLen); nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field @@ -20222,20 +20133,6 @@ utils.encode = function encode(arr, enc) { break; } - - - // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string - errors.push({ - type: 'Quotes', - code: 'InvalidQuotes', - message: 'Trailing quote on quoted field is malformed', - row: data.length, // row has yet to be inserted - index: cursor - }); - - quoteSearch++; - continue; - } continue; @@ -20501,7 +20398,7 @@ utils.encode = function encode(arr, enc) { return Papa; })); -},{}],121:[function(require,module,exports){ +},{}],120:[function(require,module,exports){ module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", "2.16.840.1.101.3.4.1.2": "aes-128-cbc", "2.16.840.1.101.3.4.1.3": "aes-128-ofb", @@ -20515,7 +20412,7 @@ module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", "2.16.840.1.101.3.4.1.43": "aes-256-ofb", "2.16.840.1.101.3.4.1.44": "aes-256-cfb" } -},{}],122:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js // Fedor, you are amazing. 'use strict' @@ -20639,7 +20536,7 @@ exports.signature = asn1.define('signature', function () { ) }) -},{"./certificate":123,"asn1.js":12}],123:[function(require,module,exports){ +},{"./certificate":122,"asn1.js":12}],122:[function(require,module,exports){ // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js // thanks to @Rantanen @@ -20729,7 +20626,7 @@ var X509Certificate = asn.define('X509Certificate', function () { module.exports = X509Certificate -},{"asn1.js":12}],124:[function(require,module,exports){ +},{"asn1.js":12}],123:[function(require,module,exports){ (function (Buffer){ // adapted from https://github.com/apatil/pemstrip var findProc = /Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m @@ -20764,7 +20661,7 @@ module.exports = function (okey, password) { }).call(this,require("buffer").Buffer) -},{"browserify-aes":32,"buffer":58,"evp_bytestokey":95}],125:[function(require,module,exports){ +},{"browserify-aes":32,"buffer":57,"evp_bytestokey":94}],124:[function(require,module,exports){ (function (Buffer){ var asn1 = require('./asn1') var aesid = require('./aesid.json') @@ -20875,13 +20772,13 @@ function decrypt (data, password) { }).call(this,require("buffer").Buffer) -},{"./aesid.json":121,"./asn1":122,"./fixProc":124,"browserify-aes":32,"buffer":58,"pbkdf2":126}],126:[function(require,module,exports){ +},{"./aesid.json":120,"./asn1":121,"./fixProc":123,"browserify-aes":32,"buffer":57,"pbkdf2":125}],125:[function(require,module,exports){ exports.pbkdf2 = require('./lib/async') exports.pbkdf2Sync = require('./lib/sync') -},{"./lib/async":127,"./lib/sync":130}],127:[function(require,module,exports){ +},{"./lib/async":126,"./lib/sync":129}],126:[function(require,module,exports){ (function (process,global){ var checkParameters = require('./precondition') var defaultEncoding = require('./default-encoding') @@ -20984,7 +20881,7 @@ module.exports = function (password, salt, iterations, keylen, digest, callback) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./default-encoding":128,"./precondition":129,"./sync":130,"_process":132,"safe-buffer":154}],128:[function(require,module,exports){ +},{"./default-encoding":127,"./precondition":128,"./sync":129,"_process":131,"safe-buffer":153}],127:[function(require,module,exports){ (function (process){ var defaultEncoding /* istanbul ignore next */ @@ -20999,7 +20896,7 @@ module.exports = defaultEncoding }).call(this,require('_process')) -},{"_process":132}],129:[function(require,module,exports){ +},{"_process":131}],128:[function(require,module,exports){ var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs module.exports = function (iterations, keylen) { if (typeof iterations !== 'number') { @@ -21019,7 +20916,7 @@ module.exports = function (iterations, keylen) { } } -},{}],130:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ var md5 = require('create-hash/md5') var rmd160 = require('ripemd160') var sha = require('sha.js') @@ -21122,7 +21019,7 @@ function pbkdf2 (password, salt, iterations, keylen, digest) { module.exports = pbkdf2 -},{"./default-encoding":128,"./precondition":129,"create-hash/md5":64,"ripemd160":153,"safe-buffer":154,"sha.js":157}],131:[function(require,module,exports){ +},{"./default-encoding":127,"./precondition":128,"create-hash/md5":63,"ripemd160":152,"safe-buffer":153,"sha.js":156}],130:[function(require,module,exports){ (function (process){ 'use strict'; @@ -21170,7 +21067,7 @@ function nextTick(fn, arg1, arg2, arg3) { }).call(this,require('_process')) -},{"_process":132}],132:[function(require,module,exports){ +},{"_process":131}],131:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -21356,7 +21253,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],133:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ exports.publicEncrypt = require('./publicEncrypt'); exports.privateDecrypt = require('./privateDecrypt'); @@ -21367,7 +21264,7 @@ exports.privateEncrypt = function privateEncrypt(key, buf) { exports.publicDecrypt = function publicDecrypt(key, buf) { return exports.privateDecrypt(key, buf, true); }; -},{"./privateDecrypt":135,"./publicEncrypt":136}],134:[function(require,module,exports){ +},{"./privateDecrypt":134,"./publicEncrypt":135}],133:[function(require,module,exports){ (function (Buffer){ var createHash = require('create-hash'); module.exports = function (seed, len) { @@ -21387,7 +21284,7 @@ function i2ops(c) { } }).call(this,require("buffer").Buffer) -},{"buffer":58,"create-hash":62}],135:[function(require,module,exports){ +},{"buffer":57,"create-hash":61}],134:[function(require,module,exports){ (function (Buffer){ var parseKeys = require('parse-asn1'); var mgf = require('./mgf'); @@ -21499,7 +21396,7 @@ function compare(a, b){ } }).call(this,require("buffer").Buffer) -},{"./mgf":134,"./withPublic":137,"./xor":138,"bn.js":27,"browserify-rsa":49,"buffer":58,"create-hash":62,"parse-asn1":125}],136:[function(require,module,exports){ +},{"./mgf":133,"./withPublic":136,"./xor":137,"bn.js":27,"browserify-rsa":48,"buffer":57,"create-hash":61,"parse-asn1":124}],135:[function(require,module,exports){ (function (Buffer){ var parseKeys = require('parse-asn1'); var randomBytes = require('randombytes'); @@ -21598,7 +21495,7 @@ function nonZero(len, crypto) { } }).call(this,require("buffer").Buffer) -},{"./mgf":134,"./withPublic":137,"./xor":138,"bn.js":27,"browserify-rsa":49,"buffer":58,"create-hash":62,"parse-asn1":125,"randombytes":139}],137:[function(require,module,exports){ +},{"./mgf":133,"./withPublic":136,"./xor":137,"bn.js":27,"browserify-rsa":48,"buffer":57,"create-hash":61,"parse-asn1":124,"randombytes":138}],136:[function(require,module,exports){ (function (Buffer){ var bn = require('bn.js'); function withPublic(paddedMsg, key) { @@ -21612,7 +21509,7 @@ function withPublic(paddedMsg, key) { module.exports = withPublic; }).call(this,require("buffer").Buffer) -},{"bn.js":27,"buffer":58}],138:[function(require,module,exports){ +},{"bn.js":27,"buffer":57}],137:[function(require,module,exports){ module.exports = function xor(a, b) { var len = a.length; var i = -1; @@ -21621,7 +21518,7 @@ module.exports = function xor(a, b) { } return a }; -},{}],139:[function(require,module,exports){ +},{}],138:[function(require,module,exports){ (function (process,global){ 'use strict' @@ -21664,10 +21561,10 @@ function randomBytes (size, cb) { }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":132,"safe-buffer":154}],140:[function(require,module,exports){ +},{"_process":131,"safe-buffer":153}],139:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); -},{"./lib/_stream_duplex.js":141}],141:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":140}],140:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -21792,7 +21689,7 @@ function forEach(xs, f) { f(xs[i], i); } } -},{"./_stream_readable":143,"./_stream_writable":145,"core-util-is":60,"inherits":112,"process-nextick-args":131}],142:[function(require,module,exports){ +},{"./_stream_readable":142,"./_stream_writable":144,"core-util-is":59,"inherits":111,"process-nextick-args":130}],141:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -21840,7 +21737,7 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":144,"core-util-is":60,"inherits":112}],143:[function(require,module,exports){ +},{"./_stream_transform":143,"core-util-is":59,"inherits":111}],142:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -22851,7 +22748,7 @@ function indexOf(xs, x) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":141,"./internal/streams/BufferList":146,"./internal/streams/destroy":147,"./internal/streams/stream":148,"_process":132,"core-util-is":60,"events":94,"inherits":112,"isarray":114,"process-nextick-args":131,"safe-buffer":154,"string_decoder/":166,"util":29}],144:[function(require,module,exports){ +},{"./_stream_duplex":140,"./internal/streams/BufferList":145,"./internal/streams/destroy":146,"./internal/streams/stream":147,"_process":131,"core-util-is":59,"events":93,"inherits":111,"isarray":113,"process-nextick-args":130,"safe-buffer":153,"string_decoder/":165,"util":29}],143:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -23066,7 +22963,7 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":141,"core-util-is":60,"inherits":112}],145:[function(require,module,exports){ +},{"./_stream_duplex":140,"core-util-is":59,"inherits":111}],144:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -23734,7 +23631,7 @@ Writable.prototype._destroy = function (err, cb) { }; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":141,"./internal/streams/destroy":147,"./internal/streams/stream":148,"_process":132,"core-util-is":60,"inherits":112,"process-nextick-args":131,"safe-buffer":154,"util-deprecate":167}],146:[function(require,module,exports){ +},{"./_stream_duplex":140,"./internal/streams/destroy":146,"./internal/streams/stream":147,"_process":131,"core-util-is":59,"inherits":111,"process-nextick-args":130,"safe-buffer":153,"util-deprecate":166}],145:[function(require,module,exports){ 'use strict'; /**/ @@ -23809,7 +23706,7 @@ module.exports = function () { return BufferList; }(); -},{"safe-buffer":154}],147:[function(require,module,exports){ +},{"safe-buffer":153}],146:[function(require,module,exports){ 'use strict'; /**/ @@ -23882,13 +23779,13 @@ module.exports = { destroy: destroy, undestroy: undestroy }; -},{"process-nextick-args":131}],148:[function(require,module,exports){ +},{"process-nextick-args":130}],147:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":94}],149:[function(require,module,exports){ +},{"events":93}],148:[function(require,module,exports){ module.exports = require('./readable').PassThrough -},{"./readable":150}],150:[function(require,module,exports){ +},{"./readable":149}],149:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -23897,13 +23794,13 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":141,"./lib/_stream_passthrough.js":142,"./lib/_stream_readable.js":143,"./lib/_stream_transform.js":144,"./lib/_stream_writable.js":145}],151:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":140,"./lib/_stream_passthrough.js":141,"./lib/_stream_readable.js":142,"./lib/_stream_transform.js":143,"./lib/_stream_writable.js":144}],150:[function(require,module,exports){ module.exports = require('./readable').Transform -},{"./readable":150}],152:[function(require,module,exports){ +},{"./readable":149}],151:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_writable.js":145}],153:[function(require,module,exports){ +},{"./lib/_stream_writable.js":144}],152:[function(require,module,exports){ (function (Buffer){ 'use strict' var inherits = require('inherits') @@ -24199,7 +24096,7 @@ module.exports = RIPEMD160 }).call(this,require("buffer").Buffer) -},{"buffer":58,"hash-base":96,"inherits":112}],154:[function(require,module,exports){ +},{"buffer":57,"hash-base":95,"inherits":111}],153:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -24263,7 +24160,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":58}],155:[function(require,module,exports){ +},{"buffer":57}],154:[function(require,module,exports){ (function (process){ exports = module.exports = SemVer; @@ -25564,79 +25461,68 @@ function intersects(r1, r2, loose) { }).call(this,require('_process')) -},{"_process":132}],156:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer - +},{"_process":131}],155:[function(require,module,exports){ +(function (Buffer){ // prototype class for hash functions function Hash (blockSize, finalSize) { - this._block = Buffer.alloc(blockSize) + this._block = new Buffer(blockSize) this._finalSize = finalSize this._blockSize = blockSize this._len = 0 + this._s = 0 } Hash.prototype.update = function (data, enc) { if (typeof data === 'string') { enc = enc || 'utf8' - data = Buffer.from(data, enc) + data = new Buffer(data, enc) } - var block = this._block - var blockSize = this._blockSize - var length = data.length - var accum = this._len + var l = this._len += data.length + var s = this._s || 0 + var f = 0 + var buffer = this._block - for (var offset = 0; offset < length;) { - var assigned = accum % blockSize - var remainder = Math.min(length - offset, blockSize - assigned) + while (s < l) { + var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize)) + var ch = (t - f) - for (var i = 0; i < remainder; i++) { - block[assigned + i] = data[offset + i] + for (var i = 0; i < ch; i++) { + buffer[(s % this._blockSize) + i] = data[i + f] } - accum += remainder - offset += remainder + s += ch + f += ch - if ((accum % blockSize) === 0) { - this._update(block) + if ((s % this._blockSize) === 0) { + this._update(buffer) } } + this._s = s - this._len += length return this } Hash.prototype.digest = function (enc) { - var rem = this._len % this._blockSize + // Suppose the length of the message M, in bits, is l + var l = this._len * 8 - this._block[rem] = 0x80 + // Append the bit 1 to the end of the message + this._block[this._len % this._blockSize] = 0x80 - // zero (rem + 1) trailing bits, where (rem + 1) is the smallest - // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize - this._block.fill(0, rem + 1) + // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize + this._block.fill(0, this._len % this._blockSize + 1) - if (rem >= this._finalSize) { + if (l % (this._blockSize * 8) >= this._finalSize * 8) { this._update(this._block) this._block.fill(0) } - var bits = this._len * 8 + // to this append the block which is equal to the number l written in binary + // TODO: handle case where l is > Math.pow(2, 29) + this._block.writeInt32BE(l, this._blockSize - 4) - // uint32 - if (bits <= 0xffffffff) { - this._block.writeUInt32BE(bits, this._blockSize - 4) - - // uint64 - } else { - var lowBits = bits & 0xffffffff - var highBits = (bits - lowBits) / 0x100000000 - - this._block.writeUInt32BE(highBits, this._blockSize - 8) - this._block.writeUInt32BE(lowBits, this._blockSize - 4) - } - - this._update(this._block) - var hash = this._hash() + var hash = this._update(this._block) || this._hash() return enc ? hash.toString(enc) : hash } @@ -25647,7 +25533,9 @@ Hash.prototype._update = function () { module.exports = Hash -},{"safe-buffer":154}],157:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"buffer":57}],156:[function(require,module,exports){ var exports = module.exports = function SHA (algorithm) { algorithm = algorithm.toLowerCase() @@ -25664,7 +25552,8 @@ exports.sha256 = require('./sha256') exports.sha384 = require('./sha384') exports.sha512 = require('./sha512') -},{"./sha":158,"./sha1":159,"./sha224":160,"./sha256":161,"./sha384":162,"./sha512":163}],158:[function(require,module,exports){ +},{"./sha":157,"./sha1":158,"./sha224":159,"./sha256":160,"./sha384":161,"./sha512":162}],157:[function(require,module,exports){ +(function (Buffer){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined * in FIPS PUB 180-1 @@ -25675,7 +25564,6 @@ exports.sha512 = require('./sha512') var inherits = require('inherits') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var K = [ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 @@ -25747,7 +25635,7 @@ Sha.prototype._update = function (M) { } Sha.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) + var H = new Buffer(20) H.writeInt32BE(this._a | 0, 0) H.writeInt32BE(this._b | 0, 4) @@ -25760,7 +25648,10 @@ Sha.prototype._hash = function () { module.exports = Sha -},{"./hash":156,"inherits":112,"safe-buffer":154}],159:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"buffer":57,"inherits":111}],158:[function(require,module,exports){ +(function (Buffer){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 @@ -25772,7 +25663,6 @@ module.exports = Sha var inherits = require('inherits') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var K = [ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 @@ -25848,7 +25738,7 @@ Sha1.prototype._update = function (M) { } Sha1.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) + var H = new Buffer(20) H.writeInt32BE(this._a | 0, 0) H.writeInt32BE(this._b | 0, 4) @@ -25861,7 +25751,10 @@ Sha1.prototype._hash = function () { module.exports = Sha1 -},{"./hash":156,"inherits":112,"safe-buffer":154}],160:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"buffer":57,"inherits":111}],159:[function(require,module,exports){ +(function (Buffer){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -25873,7 +25766,6 @@ module.exports = Sha1 var inherits = require('inherits') var Sha256 = require('./sha256') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var W = new Array(64) @@ -25901,7 +25793,7 @@ Sha224.prototype.init = function () { } Sha224.prototype._hash = function () { - var H = Buffer.allocUnsafe(28) + var H = new Buffer(28) H.writeInt32BE(this._a, 0) H.writeInt32BE(this._b, 4) @@ -25916,7 +25808,10 @@ Sha224.prototype._hash = function () { module.exports = Sha224 -},{"./hash":156,"./sha256":161,"inherits":112,"safe-buffer":154}],161:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"./sha256":160,"buffer":57,"inherits":111}],160:[function(require,module,exports){ +(function (Buffer){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -25927,7 +25822,6 @@ module.exports = Sha224 var inherits = require('inherits') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var K = [ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, @@ -26037,7 +25931,7 @@ Sha256.prototype._update = function (M) { } Sha256.prototype._hash = function () { - var H = Buffer.allocUnsafe(32) + var H = new Buffer(32) H.writeInt32BE(this._a, 0) H.writeInt32BE(this._b, 4) @@ -26053,11 +25947,13 @@ Sha256.prototype._hash = function () { module.exports = Sha256 -},{"./hash":156,"inherits":112,"safe-buffer":154}],162:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"buffer":57,"inherits":111}],161:[function(require,module,exports){ +(function (Buffer){ var inherits = require('inherits') var SHA512 = require('./sha512') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var W = new Array(160) @@ -26093,7 +25989,7 @@ Sha384.prototype.init = function () { } Sha384.prototype._hash = function () { - var H = Buffer.allocUnsafe(48) + var H = new Buffer(48) function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) @@ -26112,10 +26008,12 @@ Sha384.prototype._hash = function () { module.exports = Sha384 -},{"./hash":156,"./sha512":163,"inherits":112,"safe-buffer":154}],163:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"./sha512":162,"buffer":57,"inherits":111}],162:[function(require,module,exports){ +(function (Buffer){ var inherits = require('inherits') var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer var K = [ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, @@ -26353,7 +26251,7 @@ Sha512.prototype._update = function (M) { } Sha512.prototype._hash = function () { - var H = Buffer.allocUnsafe(64) + var H = new Buffer(64) function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) @@ -26374,7 +26272,9 @@ Sha512.prototype._hash = function () { module.exports = Sha512 -},{"./hash":156,"inherits":112,"safe-buffer":154}],164:[function(require,module,exports){ +}).call(this,require("buffer").Buffer) + +},{"./hash":155,"buffer":57,"inherits":111}],163:[function(require,module,exports){ "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; sjcl.cipher.aes=function(a){this.s[0][0][0]||this.O();var b,c,d,e,f=this.s[0][4],g=this.s[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& 255]]}; @@ -26436,7 +26336,7 @@ null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|s b){var c={},d;for(d=0;d
- [[ _sectionHeader(item) ]] + [[ _sectionHeader(index, records) ]]
!r.removed && filterByString(this._filterString, r)) - .sort((a, b) => Record.compare(a, b)); + let records = this.collection.records + .filter((r) => !r.removed && filterByString(this._filterString, r)); + + this._recentCount = records.length > 10 ? 3 : 0; + + const recent = records.sort((a, b) => { + return (b.lastUsed || b.updated).getTime() - (a.lastUsed || a.updated).getTime(); + }).slice(0, this._recentCount); + + records = records.slice(this._recentCount); + return recent.concat(records.sort((a, b) => Record.compare(a, b))); } _isEmpty() { @@ -396,42 +404,29 @@ } _firstInSection(records, index) { - const prev = records[index - 1]; - const curr = records[index]; - - if (!curr) { - return false; - } - - return !prev || this._sectionHeader(prev) !== this._sectionHeader(curr); + return index === 0 || this._sectionHeader(index - 1) !== this._sectionHeader(index); } _lastInSection(records, index) { - const curr = records[index]; - const next = records[index + 1]; - - if (!curr) { - return false; - } - - return !next || this._sectionHeader(next) !== this._sectionHeader(curr); + return this._sectionHeader(index + 1) !== this._sectionHeader(index); } - _sectionHeader(record) { - return record.name[0] && record.name[0].toUpperCase(); + _sectionHeader(index) { + const record = this.records[index]; + return index < this._recentCount ? $l("Recently Used") : + record && record.name[0] && record.name[0].toUpperCase(); } _updateCurrentSection() { - const record = this.records[this.$.list.firstVisibleIndex]; - this._currentSection = record && this._sectionHeader(record); + this._currentSection = this._sectionHeader(this.$.list.firstVisibleIndex); } _selectSection() { - const sections = Array.from(this.records.reduce((s, r) => s.add(this._sectionHeader(r)), new Set())); + const sections = Array.from(this.records.reduce((s, r, i) => s.add(this._sectionHeader(i)), new Set())); if (sections.length > 1) { this.$.sectionSelector.choose("", sections) .then((i) => { - const record = this.records.find((r) => this._sectionHeader(r) === sections[i]); + const record = this.records.find((r, j) => this._sectionHeader(j) === sections[i]); this.$.list.scrollToItem(record); }); } diff --git a/app/src/ui/record-item/record-item.html b/app/src/ui/record-item/record-item.html index cf89506a8..e3b312f67 100644 --- a/app/src/ui/record-item/record-item.html +++ b/app/src/ui/record-item/record-item.html @@ -234,6 +234,8 @@ setClipboard(e.model.item.value); const field = this.root.querySelectorAll(".field")[e.model.index]; field.classList.add("copied"); + this.record.lastUsed = new Date(); + this.saveCollection(); setTimeout(() => field.classList.remove("copied"), 1000); } }