var _r;
!(function(e) {
var i = {};
function r(t) {
if (i[t])
return i[t].exports;
var n = i[t] = {
i: t,
l: !1,
exports: {}
};
return e[t].call(n.exports, n, n.exports, r),
n.l = !0,
n.exports
}
r = r;
})({
409: function(t, e, i) {
"use strict";
var n, r, o, a, c, b = {
cipher: {},
hash: {},
keyexchange: {},
mode: {},
misc: {},
codec: {},
exception: {
corrupt: function(t) {
this.toString = function() {
return "CORRUPT: " + this.message
}
,
this.message = t
},
invalid: function(t) {
this.toString = function() {
return "INVALID: " + this.message
}
,
this.message = t
},
bug: function(t) {
this.toString = function() {
return "BUG: " + this.message
}
,
this.message = t
},
notReady: function(t) {
this.toString = function() {
return "NOT READY: " + this.message
}
,
this.message = t
}
}
};
function s(t, e, i) {
if (4 !== e.length)
throw new b.exception.invalid("invalid aes block size");
var n = t.b[i]
, r = e[0] ^ n[0]
, o = e[i ? 3 : 1] ^ n[1]
, a = e[2] ^ n[2];
e = e[i ? 1 : 3] ^ n[3];
var c, s, h = n.length / 4 - 2, l = 4, d = [0, 0, 0, 0], u = t.s[i];
t = u[0];
for (var f = u[1], p = u[2], m = u[3], y = u[4], g = 0; g < h; g++)
u = t[r >>> 24] ^ f[o >> 16 & 255] ^ p[a >> 8 & 255] ^ m[255 & e] ^ n[l],
c = t[o >>> 24] ^ f[a >> 16 & 255] ^ p[e >> 8 & 255] ^ m[255 & r] ^ n[l + 1],
s = t[a >>> 24] ^ f[e >> 16 & 255] ^ p[r >> 8 & 255] ^ m[255 & o] ^ n[l + 2],
e = t[e >>> 24] ^ f[r >> 16 & 255] ^ p[o >> 8 & 255] ^ m[255 & a] ^ n[l + 3],
l += 4,
r = u,
o = c,
a = s;
for (g = 0; g < 4; g++)
d[i ? 3 & -g : g] = y[r >>> 24] << 24 ^ y[o >> 16 & 255] << 16 ^ y[a >> 8 & 255] << 8 ^ y[255 & e] ^ n[l++],
u = r,
r = o,
o = a,
a = e,
e = u;
return d
}
function h(t, e) {
for (var i, n, r = t.F, o = t.b, a = r[0], c = r[1], s = r[2], h = r[3], l = r[4], d = r[5], u = r[6], f = r[7], p = 0; p < 64; p++)
i = (i = p < 16 ? e[p] : (i = e[p + 1 & 15],
n = e[p + 14 & 15],
e[15 & p] = (i >>> 7 ^ i >>> 18 ^ i >>> 3 ^ i << 25 ^ i << 14) + (n >>> 17 ^ n >>> 19 ^ n >>> 10 ^ n << 15 ^ n << 13) + e[15 & p] + e[p + 9 & 15] | 0)) + f + (l >>> 6 ^ l >>> 11 ^ l >>> 25 ^ l << 26 ^ l << 21 ^ l << 7) + (u ^ l & (d ^ u)) + o[p],
f = u,
u = d,
d = l,
l = h + i | 0,
h = s,
s = c,
a = i + ((c = a) & s ^ h & (c ^ s)) + (c >>> 2 ^ c >>> 13 ^ c >>> 22 ^ c << 30 ^ c << 19 ^ c << 10) | 0;
r[0] = r[0] + a | 0,
r[1] = r[1] + c | 0,
r[2] = r[2] + s | 0,
r[3] = r[3] + h | 0,
r[4] = r[4] + l | 0,
r[5] = r[5] + d | 0,
r[6] = r[6] + u | 0,
r[7] = r[7] + f | 0
}
function l(t, e) {
var i, n = b.random.K[t], r = [];
for (i in n)
n.hasOwnProperty(i) && r.push(n[i]);
for (i = 0; i < r.length; i++)
ri
}
function d(t, e) {
"undefined" != typeof window && window.performance && "function" == typeof window.performance.now ? t.addEntropy(window.performance.now(), e, "loadtime") : t.addEntropy((new Date).valueOf(), e, "loadtime")
}
function u(t) {
t.b = f(t).concat(f(t)),
t.L = new b.cipher.aes(t.b)
}
function f(t) {
for (var e = 0; e < 4 && (t.h[e] = t.h[e] + 1 | 0,
!t.h[e]); e++)
;
return t.L.encrypt(t.h)
}
function p(t, e) {
return function() {
e.apply(t, arguments)
}
}
b.cipher.aes = function(t) {
this.s[0][0][0] || this.O();
var e, i, n, r = this.s[0][4], o = this.s[1], a = t.length, c = 1;
if (4 !== a && 6 !== a && 8 !== a)
throw new b.exception.invalid("invalid aes key size");
for (this.b = [i = t.slice(0), n = []],
t = a; t < 4 a + 28; t++)
e = i[t - 1],
(0 == t % a || 8 === a && 4 == t % a) && (e = r[e >>> 24] << 24 ^ r[e >> 16 & 255] << 16 ^ r[e >> 8 & 255] << 8 ^ r[255 & e],
0 == t % a && (e = e << 8 ^ e >>> 24 ^ c << 24,
c = c << 1 ^ 283 (c >> 7))),
i[t] = i[t - a] ^ e;
for (a = 0; t; a++,
t--)
e = i[3 & a ? t : t - 4],
n[a] = t <= 4 || a < 4 ? e : o[0][r[e >>> 24]] ^ o[1][r[e >> 16 & 255]] ^ o[2][r[e >> 8 & 255]] ^ o[3][r[255 & e]]
}
,
b.cipher.aes.prototype = {
encrypt: function(t) {
return s(this, t, 0)
},
decrypt: function(t) {
return s(this, t, 1)
},
s: [[[], [], [], [], []], [[], [], [], [], []]],
O: function() {
for (var t, e, i, n, r, o, a = this.s[0], c = this.s[1], s = a[4], h = c[4], l = [], d = [], u = 0; u < 256; u++)
d[(l[u] = u << 1 ^ 283 (u >> 7)) ^ u] = u;
for (t = e = 0; !s[t]; t ^= i || 1,
e = d[e] || 1)
for (o = 16843009 (n = l[u = l[i = l[h[s[t] = r = (r = e ^ e << 1 ^ e << 2 ^ e << 3 ^ e << 4) >> 8 ^ 255 & r ^ 99] = t]]]) ^ 65537 u ^ 257 i ^ 16843008 t,
n = 257 l[r] ^ 16843008 r,
u = 0; u < 4; u++)
a[u][t] = n = n << 24 ^ n >>> 8,
c[u][r] = o = o << 24 ^ o >>> 8;
for (u = 0; u < 5; u++)
a[u] = a[u].slice(0),
c[u] = c[u].slice(0)
}
},
b.bitArray = {
bitSlice: function(t, e, i) {
return t = b.bitArray.$(t.slice(e / 32), 32 - (31 & e)).slice(1),
void 0 === i ? t : b.bitArray.clamp(t, i - e)
},
extract: function(t, e, i) {
var n = Math.floor(-e - i & 31);
return (-32 & (e + i - 1 ^ e) ? t[e / 32 | 0] << 32 - n ^ t[e / 32 + 1 | 0] >>> n : t[e / 32 | 0] >>> n) & (1 << i) - 1
},
concat: function(t, e) {
if (0 === t.length || 0 === e.length)
return t.concat(e);
var i = t[t.length - 1]
, n = b.bitArray.getPartial(i);
return 32 === n ? t.concat(e) : b.bitArray.$(e, n, 0 | i, t.slice(0, t.length - 1))
},
bitLength: function(t) {
var e = t.length;
return 0 === e ? 0 : 32 (e - 1) + b.bitArray.getPartial(t[e - 1])
},
clamp: function(t, e) {
if (32 t.length < e)
return t;
var i = (t = t.slice(0, Math.ceil(e / 32))).length;
return e &= 31,
0 < i && e && (t[i - 1] = b.bitArray.partial(e, t[i - 1] & 2147483648 >> e - 1, 1)),
t
},
partial: function(t, e, i) {
return 32 === t ? e : (i ? 0 | e : e << 32 - t) + 1099511627776 t
},
getPartial: function(t) {
return Math.round(t / 1099511627776) || 32
},
equal: function(t, e) {
if (b.bitArray.bitLength(t) !== b.bitArray.bitLength(e))
return !1;
for (var i = 0, n = 0; n < t.length; n++)
i |= t[n] ^ e[n];
return 0 === i
},
$: function(t, e, i, n) {
var r = 0;
for (void 0 === n && (n = []); 32 <= e; e -= 32)
n.push(i),
i = 0;
if (0 === e)
return n.concat(t);
for (r = 0; r < t.length; r++)
n.push(i | t[r] >>> e),
i = t[r] << 32 - e;
return r = t.length ? t[t.length - 1] : 0,
t = b.bitArray.getPartial(r),
n.push(b.bitArray.partial(e + t & 31, 32 < e + t ? i : n.pop(), 1)),
n
},
i: function(t, e) {
return [t[0] ^ e[0], t[1] ^ e[1], t[2] ^ e[2], t[3] ^ e[3]]
},
byteswapM: function(t) {
for (var e, i = 0; i < t.length; ++i)
e = t[i],
t[i] = e >>> 24 | e >>> 8 & 65280 | (65280 & e) << 8 | e << 24;
return t
}
},
b.codec.utf8String = {
fromBits: function(t) {
for (var e, i = "", n = b.bitArray.bitLength(t), r = 0; r < n / 8; r++)
0 == (3 & r) && (e = t[r / 4]),
i += String.fromCharCode(e >>> 8 >>> 8 >>> 8),
e <<= 8;
return decodeURIComponent(escape(i))
},
toBits: function(t) {
t = unescape(encodeURIComponent(t));
for (var e = [], i = 0, n = 0; n < t.length; n++)
i = i << 8 | t.charCodeAt(n),
3 == (3 & n) && (e.push(i),
i = 0);
return 3 & n && e.push(b.bitArray.partial(8 (3 & n), i)),
e
}
},
b.codec.hex = {
fromBits: function(t) {
for (var e = "", i = 0; i < t.length; i++)
e += (0xf00000000000 + (0 | t[i])).toString(16).substr(4);
return e.substr(0, b.bitArray.bitLength(t) / 4)
},
toBits: function(t) {
var e, i = [], n = (t = t.replace(/\s|0x/g, "")).length;
for (t += "00000000",
e = 0; e < t.length; e += 8)
i.push(0 ^ parseInt(t.substr(e, 8), 16));
return b.bitArray.clamp(i, 4 n)
}
},
b.codec.base32 = {
B: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
X: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
BITS: 32,
BASE: 5,
REMAINING: 27,
fromBits: function(t, e, i) {
var n = b.codec.base32.BASE
, r = b.codec.base32.REMAINING
, o = ""
, a = 0
, c = b.codec.base32.B
, s = 0
, h = b.bitArray.bitLength(t);
for (i && (c = b.codec.base32.X),
i = 0; o.length * n < h; )
o += c.charAt((s ^ t[i] >>> a) >>> r),
a < n ? (s = t[i] << n - a,
a += r,
i++) : (s <<= n,
a -= n);
for (; 7 & o.length && !e; )
o += "=";
return o
},
toBits: function(t, e) {
t = t.replace(/\s|=/g, "").toUpperCase();
var i, n, r = b.codec.base32.BITS, o = b.codec.base32.BASE, a = b.codec.base32.REMAINING, c = [], s = 0, h = b.codec.base32.B, l = 0, d = "base32";
for (e && (h = b.codec.base32.X,
d = "base32hex"),
i = 0; i < t.length; i++) {
if ((n = h.indexOf(t.charAt(i))) < 0) {
if (!e)
try {
return b.codec.base32hex.toBits(t)
} catch (t) {}
throw new b.exception.invalid("this isn't " + d + "!")
}
a < s ? (s -= a,
c.push(l ^ n >>> s),
l = n << r - s) : l ^= n << r - (s += o)
}
return 56 & s && c.push(b.bitArray.partial(56 & s, l, 1)),
c
}
},
b.codec.base32hex = {
fromBits: function(t, e) {
return b.codec.base32.fromBits(t, e, 1)
},
toBits: function(t) {
return b.codec.base32.toBits(t, 1)
}
},
b.codec.base64 = {
B: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
fromBits: function(t, e, i) {
var n = ""
, r = 0
, o = b.codec.base64.B
, a = 0
, c = b.bitArray.bitLength(t);
for (i && (o = o.substr(0, 62) + "-"),
i = 0; 6 n.length < c; )
n += o.charAt((a ^ t[i] >>> r) >>> 26),
r < 6 ? (a = t[i] << 6 - r,
r += 26,
i++) : (a <<= 6,
r -= 6);
for (; 3 & n.length && !e; )
n += "=";
return n
},
toBits: function(t, e) {
t = t.replace(/\s|=/g, "");
var i, n, r = [], o = 0, a = b.codec.base64.B, c = 0;
for (e && (a = a.substr(0, 62) + "-_"),
i = 0; i < t.length; i++) {
if ((n = a.indexOf(t.charAt(i))) < 0)
throw new b.exception.invalid("this isn't base64!");
26 < o ? (o -= 26,
r.push(c ^ n >>> o),
c = n << 32 - o) : c ^= n << 32 - (o += 6)
}
return 56 & o && r.push(b.bitArray.partial(56 & o, c, 1)),
r
}
},
b.codec.base64url = {
fromBits: function(t) {
return b.codec.base64.fromBits(t, 1, 1)
},
toBits: function(t) {
return b.codec.base64.toBits(t, 1)
}
},
b.hash.sha256 = function(t) {
this.b[0] || this.O(),
t ? (this.F = t.F.slice(0),
this.A = t.A.slice(0),
this.l = t.l) : this.reset()
}
,
b.hash.sha256.hash = function(t) {
return (new b.hash.sha256).update(t).finalize()
}
,
b.hash.sha256.prototype = {
blockSize: 512,
reset: function() {
return this.F = this.Y.slice(0),
this.A = [],
this.l = 0,
this
},
update: function(t) {
"string" == typeof t && (t = b.codec.utf8String.toBits(t));
var e = this.A = b.bitArray.concat(this.A, t);
if (r = this.l,
9007199254740991 < (t = this.l = r + b.bitArray.bitLength(t)))
throw new b.exception.invalid("Cannot hash more than 2^53 - 1 bits");
if ("undefined" != typeof Uint32Array) {
for (var i = new Uint32Array(e), n = 0, r = 512 + r - (512 + r & 511); r <= t; r += 512)
h(this, i.subarray(16 n, 16 (n + 1))),
n += 1;
e.splice(0, 16 n)
} else
for (r = 512 + r - (512 + r & 511); r <= t; r += 512)
h(this, e.splice(0, 16));
return this
},
finalize: function() {
for (var t = this.A, e = this.F, i = (t = b.bitArray.concat(t, [b.bitArray.partial(1, 1)])).length + 2; 15 & i; i++)
t.push(0);
for (t.push(Math.floor(this.l / 4294967296)),
t.push(0 | this.l); t.length; )
h(this, t.splice(0, 16));
return this.reset(),
e
},
Y: [],
b: [],
O: function() {
function t(t) {
return 4294967296 (t - Math.floor(t)) | 0
}
for (var e, i, n = 0, r = 2; n < 64; r++) {
for (i = !0,
e = 2; e e <= r; e++)
if (0 == r % e) {
i = !1;
break
}
i && (n < 8 && (this.Y[n] = t(Math.pow(r, .5))),
this.b[n] = t(Math.pow(r, 1 / 3)),
n++)
}
}
},
b.mode.ccm = {
name: "ccm",
G: [],
listenProgress: function(t) {
b.mode.ccm.G.push(t)
},
unListenProgress: function(t) {
-1 < (t = b.mode.ccm.G.indexOf(t)) && b.mode.ccm.G.splice(t, 1)
},
fa: function(t) {
for (var e = b.mode.ccm.G.slice(), i = 0; i < e.length; i += 1)
ei
},
encrypt: function(t, e, i, n, r) {
var o, a = e.slice(0), c = b.bitArray, s = c.bitLength(i) / 8, h = c.bitLength(a) / 8;
if (r = r || 64,
n = n || [],
s < 7)
throw new b.exception.invalid("ccm: iv must be at least 7 bytes");
for (o = 2; o < 4 && h >>> 8 o; o++)
;
return i = c.clamp(i, 8 (15 - (o = o < 15 - s ? 15 - s : o))),
e = b.mode.ccm.V(t, e, i, n, r, o),
a = b.mode.ccm.C(t, a, i, e, r, o),
c.concat(a.data, a.tag)
},
decrypt: function(t, e, i, n, r) {
r = r || 64,
n = n || [];
var o = b.bitArray
, a = o.bitLength(i) / 8
, c = o.bitLength(e)
, s = o.clamp(e, c - r)
, h = o.bitSlice(e, c - r)
, c = (c - r) / 8;
if (a < 7)
throw new b.exception.invalid("ccm: iv must be at least 7 bytes");
for (e = 2; e < 4 && c >>> 8 e; e++)
;
if (i = o.clamp(i, 8 (15 - (e = e < 15 - a ? 15 - a : e))),
s = b.mode.ccm.C(t, s, i, h, r, e),
t = b.mode.ccm.V(t, s.data, i, n, r, e),
!o.equal(s.tag, t))
throw new b.exception.corrupt("ccm: tag doesn't match");
return s.data
},
na: function(t, e, i, n, r, o) {
var a = []
, c = b.bitArray
, s = c.i;
if (n = [c.partial(8, (e.length ? 64 : 0) | n - 2 << 2 | o - 1)],
(n = c.concat(n, i))[3] |= r,
n = t.encrypt(n),
e.length)
for ((i = c.bitLength(e) / 8) <= 65279 ? a = [c.partial(16, i)] : i <= 4294967295 && (a = c.concat([c.partial(16, 65534)], [i])),
a = c.concat(a, e),
e = 0; e < a.length; e += 4)
n = t.encrypt(s(n, a.slice(e, e + 4).concat([0, 0, 0])));
return n
},
V: function(t, e, i, n, r, o) {
var a = b.bitArray
, c = a.i;
if ((r /= 8) % 2 || r < 4 || 16 < r)
throw new b.exception.invalid("ccm: invalid tag length");
if (4294967295 < n.length || 4294967295 < e.length)
throw new b.exception.bug("ccm: can't deal with 4GiB or more data");
for (i = b.mode.ccm.na(t, n, i, r, a.bitLength(e) / 8, o),
n = 0; n < e.length; n += 4)
i = t.encrypt(c(i, e.slice(n, n + 4).concat([0, 0, 0])));
return a.clamp(i, 8 r)
},
C: function(t, e, i, n, r, o) {
var a = b.bitArray
, c = a.i
, s = e.length
, h = a.bitLength(e)
, l = s / 50
, d = l;
if (i = a.concat([a.partial(8, o - 1)], i).concat([0, 0, 0]).slice(0, 4),
n = a.bitSlice(c(n, t.encrypt(i)), 0, r),
!s)
return {
tag: n,
data: []
};
for (c = 0; c < s; c += 4)
l < c && (b.mode.ccm.fa(c / s),
l += d),
i[3]++,
r = t.encrypt(i),
e[c] ^= r[0],
e[c + 1] ^= r[1],
e[c + 2] ^= r[2],
e[c + 3] ^= r[3];
return {
tag: n,
data: a.clamp(e, h)
}
}
},
b.mode.ocb2 = {
name: "ocb2",
encrypt: function(t, e, i, n, r, o) {
if (128 !== b.bitArray.bitLength(i))
throw new b.exception.invalid("ocb iv must be 128 bits");
var a, c = b.mode.ocb2.S, s = b.bitArray, h = s.i, l = [0, 0, 0, 0];
i = c(t.encrypt(i));
var d, u = [];
for (n = n || [],
r = r || 64,
a = 0; a + 4 < e.length; a += 4)
l = h(l, d = e.slice(a, a + 4)),
u = u.concat(h(i, t.encrypt(h(i, d)))),
i = c(i);
return d = e.slice(a),
e = s.bitLength(d),
a = t.encrypt(h(i, [0, 0, 0, e])),
d = s.clamp(h(d.concat([0, 0, 0]), a), e),
l = h(l, h(d.concat([0, 0, 0]), a)),
l = t.encrypt(h(l, h(i, c(i)))),
n.length && (l = h(l, o ? n : b.mode.ocb2.pmac(t, n))),
u.concat(s.concat(d, s.clamp(l, r)))
},
decrypt: function(t, e, i, n, r, o) {
if (128 !== b.bitArray.bitLength(i))
throw new b.exception.invalid("ocb iv must be 128 bits");
r = r || 64;
var a, c, s = b.mode.ocb2.S, h = b.bitArray, l = h.i, d = [0, 0, 0, 0], u = s(t.encrypt(i)), f = b.bitArray.bitLength(e) - r, p = [];
for (n = n || [],
i = 0; i + 4 < f / 32; i += 4)
a = l(u, t.decrypt(l(u, e.slice(i, i + 4)))),
d = l(d, a),
p = p.concat(a),
u = s(u);
if (a = t.encrypt(l(u, [0, 0, 0, c = f - 32 i])),
a = l(a, h.clamp(e.slice(i), c).concat([0, 0, 0])),
d = l(d, a),
d = t.encrypt(l(d, l(u, s(u)))),
n.length && (d = l(d, o ? n : b.mode.ocb2.pmac(t, n))),
!h.equal(h.clamp(d, r), h.bitSlice(e, f)))
throw new b.exception.corrupt("ocb: tag doesn't match");
return p.concat(h.clamp(a, c))
},
pmac: function(t, e) {
for (var i = b.mode.ocb2.S, n = b.bitArray, r = n.i, o = [0, 0, 0, 0], a = r(a = t.encrypt([0, 0, 0, 0]), i(i(a))), c = 0; c + 4 < e.length; c += 4)
a = i(a),
o = r(o, t.encrypt(r(a, e.slice(c, c + 4))));
return c = e.slice(c),
n.bitLength(c) < 128 && (a = r(a, i(a)),
c = n.concat(c, [-2147483648, 0, 0, 0])),
o = r(o, c),
t.encrypt(r(i(r(a, i(a))), o))
},
S: function(t) {
return [t[0] << 1 ^ t[1] >>> 31, t[1] << 1 ^ t[2] >>> 31, t[2] << 1 ^ t[3] >>> 31, t[3] << 1 ^ 135 (t[0] >>> 31)]
}
},
b.mode.gcm = {
name: "gcm",
encrypt: function(t, e, i, n, r) {
var o = e.slice(0);
return e = b.bitArray,
t = b.mode.gcm.C(!0, t, o, n = n || [], i, r || 128),
e.concat(t.data, t.tag)
},
decrypt: function(t, e, i, n, r) {
var o = e.slice(0)
, a = b.bitArray
, c = a.bitLength(o);
if (n = n || [],
o = (r = r || 128) <= c ? (e = a.bitSlice(o, c - r),
a.bitSlice(o, 0, c - r)) : (e = o,
[]),
t = b.mode.gcm.C(!1, t, o, n, i, r),
!a.equal(t.tag, e))
throw new b.exception.corrupt("gcm: tag doesn't match");
return t.data
},
ka: function(t, e) {
for (var i, n, r = b.bitArray.i, o = [0, 0, 0, 0], a = e.slice(0), c = 0; c < 128; c++) {
for ((i = 0 != (t[Math.floor(c / 32)] & 1 << 31 - c % 32)) && (o = r(o, a)),
n = 0 != (1 & a[3]),
i = 3; 0 < i; i--)
a[i] = a[i] >>> 1 | (1 & a[i - 1]) << 31;
a[0] >>>= 1,
n && (a[0] ^= -520093696)
}
return o
},
j: function(t, e, i) {
var n, r = i.length;
for (e = e.slice(0),
n = 0; n < r; n += 4)
e[0] ^= 4294967295 & i[n],
e[1] ^= 4294967295 & i[n + 1],
e[2] ^= 4294967295 & i[n + 2],
e[3] ^= 4294967295 & i[n + 3],
e = b.mode.gcm.ka(e, t);
return e
},
C: function(t, e, i, n, r, o) {
var a, c, s, h = b.bitArray, l = i.length, d = h.bitLength(i), u = h.bitLength(n), f = h.bitLength(r), p = e.encrypt([0, 0, 0, 0]);
for (r = 96 === f ? (r = r.slice(0),
h.concat(r, [1])) : (r = b.mode.gcm.j(p, [0, 0, 0, 0], r),
b.mode.gcm.j(p, r, [0, 0, Math.floor(f / 4294967296), 4294967295 & f])),
f = b.mode.gcm.j(p, [0, 0, 0, 0], n),
s = r.slice(0),
n = f.slice(0),
t || (n = b.mode.gcm.j(p, f, i)),
c = 0; c < l; c += 4)
s[3]++,
a = e.encrypt(s),
i[c] ^= a[0],
i[c + 1] ^= a[1],
i[c + 2] ^= a[2],
i[c + 3] ^= a[3];
return i = h.clamp(i, d),
t && (n = b.mode.gcm.j(p, f, i)),
t = [Math.floor(u / 4294967296), 4294967295 & u, Math.floor(d / 4294967296), 4294967295 & d],
n = b.mode.gcm.j(p, n, t),
a = e.encrypt(r),
n[0] ^= a[0],
n[1] ^= a[1],
n[2] ^= a[2],
n[3] ^= a[3],
{
tag: h.bitSlice(n, 0, o),
data: i
}
}
},
b.misc.hmac = function(t, e) {
this.W = e = e || b.hash.sha256;
var i, n = [[], []], r = e.prototype.blockSize / 32;
for (this.w = [new e, new e],
t.length > r && (t = e.hash(t)),
i = 0; i < r; i++)
n[0][i] = 909522486 ^ t[i],
n[1][i] = 1549556828 ^ t[i];
this.w[0].update(n[0]),
this.w[1].update(n[1]),
this.R = new e(this.w[0])
}
,
b.misc.hmac.prototype.encrypt = b.misc.hmac.prototype.mac = function(t) {
if (this.aa)
throw new b.exception.invalid("encrypt on already updated hmac called!");
return this.update(t),
this.digest(t)
}
,
b.misc.hmac.prototype.reset = function() {
this.R = new this.W(this.w[0]),
this.aa = !1
}
,
b.misc.hmac.prototype.update = function(t) {
this.aa = !0,
this.R.update(t)
}
,
b.misc.hmac.prototype.digest = function() {
var t = this.R.finalize()
, t = new this.W(this.w[1]).update(t).finalize();
return this.reset(),
t
}
,
b.misc.pbkdf2 = function(t, e, i, n, r) {
if (i = i || 1e4,
n < 0 || i < 0)
throw new b.exception.invalid("invalid params to pbkdf2");
"string" == typeof t && (t = b.codec.utf8String.toBits(t)),
"string" == typeof e && (e = b.codec.utf8String.toBits(e)),
t = new (r = r || b.misc.hmac)(t);
for (var o, a, c, s = [], h = b.bitArray, l = 1; 32 s.length < (n || 1); l++) {
for (r = o = t.encrypt(h.concat(e, [l])),
a = 1; a < i; a++)
for (o = t.encrypt(o),
c = 0; c < o.length; c++)
r[c] ^= o[c];
s = s.concat(r)
}
return s = n ? h.clamp(s, n) : s
}
,
b.prng = function(t) {
this.c = [new b.hash.sha256],
this.m = [0],
this.P = 0,
this.H = {},
this.N = 0,
this.U = {},
this.Z = this.f = this.o = this.ha = 0,
this.b = [0, 0, 0, 0, 0, 0, 0, 0],
this.h = [0, 0, 0, 0],
this.L = void 0,
this.M = t,
this.D = !1,
this.K = {
progress: {},
seeded: {}
},
this.u = this.ga = 0,
this.I = 1,
this.J = 2,
this.ca = 65536,
this.T = [0, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024],
this.da = 3e4,
this.ba = 80
}
,
b.prng.prototype = {
randomWords: function(t, e) {
var i = [];
if ((r = this.isReady(e)) === this.u)
throw new b.exception.notReady("generator isn't seeded");
if (r & this.J) {
var n, r = !(r & this.I), o = [], a = 0;
for (this.Z = o[0] = (new Date).valueOf() + this.da,
n = 0; n < 16; n++)
o.push(4294967296 Math.random() | 0);
for (n = 0; n < this.c.length && (o = o.concat(this.c[n].finalize()),
a += this.m[n],
this.m[n] = 0,
r || !(this.P & 1 << n)); n++)
;
for (this.P >= 1 << this.c.length && (this.c.push(new b.hash.sha256),
this.m.push(0)),
this.f -= a,
a > this.o && (this.o = a),
this.P++,
this.b = b.hash.sha256.hash(this.b.concat(o)),
this.L = new b.cipher.aes(this.b),
r = 0; r < 4 && (this.h[r] = this.h[r] + 1 | 0,
!this.h[r]); r++)
;
}
for (r = 0; r < t; r += 4)
0 == (r + 1) % this.ca && u(this),
o = f(this),
i.push(o[0], o[1], o[2], o[3]);
return u(this),
i.slice(0, t)
},
setDefaultParanoia: function(t, e) {
if (0 === t && "Setting paranoia=0 will ruin your security; use it only for testing" !== e)
throw new b.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");
this.M = t
},
addEntropy: function(t, e, i) {
i = i || "user";
var n, r = (new Date).valueOf(), o = this.H[i], a = this.isReady(), c = 0, s = this.U[i];
switch (void 0 === s && (s = this.U[i] = this.ha++),
void 0 === o && (o = this.H[i] = 0),
this.H[i] = (this.H[i] + 1) % this.c.length,
typeof t) {
case "number":
void 0 === e && (e = 1),
this.c[o].update([s, this.N++, 1, e, r, 1, 0 | t]);
break;
case "object":
if ("[object Uint32Array]" === (i = Object.prototype.toString.call(t))) {
for (n = [],
i = 0; i < t.length; i++)
n.push(t[i]);
t = n
} else
for ("[object Array]" !== i && (c = 1),
i = 0; i < t.length && !c; i++)
"number" != typeof t[i] && (c = 1);
if (!c) {
if (void 0 === e)
for (i = e = 0; i < t.length; i++)
for (n = t[i]; 0 < n; )
e++,
n >>>= 1;
this.c[o].update([s, this.N++, 2, e, r, t.length].concat(t))
}
break;
case "string":
void 0 === e && (e = t.length),
this.c[o].update([s, this.N++, 3, e, r, t.length]),
this.c[o].update(t);
break;
default:
c = 1
}
if (c)
throw new b.exception.bug("random: addEntropy only supports number, array of numbers or string");
this.m[o] += e,
this.f += e,
a === this.u && (this.isReady() !== this.u && l("seeded", Math.max(this.o, this.f)),
l("progress", this.getProgress()))
},
isReady: function(t) {
return t = this.T[void 0 !== t ? t : this.M],
this.o && this.o >= t ? this.m[0] > this.ba && (new Date).valueOf() > this.Z ? this.J | this.I : this.I : this.f >= t ? this.J | this.u : this.u
},
getProgress: function(t) {
return t = this.T[t || this.M],
this.o >= t || this.f > t ? 1 : this.f / t
},
startCollectors: function() {
if (!this.D) {
if (this.a = {
loadTimeCollector: p(this, this.ma),
mouseCollector: p(this, this.oa),
keyboardCollector: p(this, this.la),
accelerometerCollector: p(this, this.ea),
touchCollector: p(this, this.qa)
},
window.addEventListener)
window.addEventListener("load", this.a.loadTimeCollector, !1),
window.addEventListener("mousemove", this.a.mouseCollector, !1),
window.addEventListener("keypress", this.a.keyboardCollector, !1),
window.addEventListener("devicemotion", this.a.accelerometerCollector, !1),
window.addEventListener("touchmove", this.a.touchCollector, !1);
else {
if (!document.attachEvent)
throw new b.exception.bug("can't attach event");
document.attachEvent("onload", this.a.loadTimeCollector),
document.attachEvent("onmousemove", this.a.mouseCollector),
document.attachEvent("keypress", this.a.keyboardCollector)
}
this.D = !0
}
},
stopCollectors: function() {
this.D && (window.removeEventListener ? (window.removeEventListener("load", this.a.loadTimeCollector, !1),
window.removeEventListener("mousemove", this.a.mouseCollector, !1),
window.removeEventListener("keypress", this.a.keyboardCollector, !1),
window.removeEventListener("devicemotion", this.a.accelerometerCollector, !1),
window.removeEventListener("touchmove", this.a.touchCollector, !1)) : document.detachEvent && (document.detachEvent("onload", this.a.loadTimeCollector),
document.detachEvent("onmousemove", this.a.mouseCollector),
document.detachEvent("keypress", this.a.keyboardCollector)),
this.D = !1)
},
addEventListener: function(t, e) {
this.K[t][this.ga++] = e
},
removeEventListener: function(t, e) {
var i, n, r = this.K[t], o = [];
for (n in r)
r.hasOwnProperty(n) && r[n] === e && o.push(n);
for (i = 0; i < o.length; i++)
delete r[n = o[i]]
},
la: function() {
d(this, 1)
},
oa: function(t) {
var e, i;
try {
e = t.x || t.clientX || t.offsetX || 0,
i = t.y || t.clientY || t.offsetY || 0
} catch (t) {
i = e = 0
}
0 != e && 0 != i && this.addEntropy([e, i], 2, "mouse"),
d(this, 0)
},
qa: function(t) {
t = t.touches[0] || t.changedTouches[0],
this.addEntropy([t.pageX || t.clientX, t.pageY || t.clientY], 1, "touch"),
d(this, 0)
},
ma: function() {
d(this, 2)
},
ea: function(t) {
var e;
t = t.accelerationIncludingGravity.x || t.accelerationIncludingGravity.y || t.accelerationIncludingGravity.z,
!window.orientation || "number" == typeof (e = window.orientation) && this.addEntropy(e, 1, "accelerometer"),
t && this.addEntropy(t, 2, "accelerometer"),
d(this, 0)
}
},
b.random = new b.prng(6);
t: try {
if (a = t.exports) {
try {
c = i(1084)
} catch (t) {
c = null
}
a = r = c
}
if (a && r.randomBytes)
n = r.randomBytes(128),
n = new Uint32Array(new Uint8Array(n).buffer),
b.random.addEntropy(n, 1024, "crypto['randomBytes']");
else if ("undefined" != typeof window && "undefined" != typeof Uint32Array) {
if (o = new Uint32Array(32),
window.crypto && window.crypto.getRandomValues)
window.crypto.getRandomValues(o);
else {
if (!window.msCrypto || !window.msCrypto.getRandomValues)
break t;
window.msCrypto.getRandomValues(o)
}
b.random.addEntropy(o, 1024, "crypto['getRandomValues']")
}
} catch (t) {}
b.json = {
defaults: {
v: 1,
iter: 1e4,
ks: 128,
ts: 64,
mode: "ccm",
adata: "",
cipher: "aes"
},
ja: function(t, e, i, n) {
i = i || {},
n = n || {};
var r, o = b.json, a = o.g({
iv: b.random.randomWords(4, 0)
}, o.defaults);
if (o.g(a, i),
i = a.adata,
"string" == typeof a.salt && (a.salt = b.codec.base64.toBits(a.salt)),
"string" == typeof a.iv && (a.iv = b.codec.base64.toBits(a.iv)),
!b.mode[a.mode] || !b.cipher[a.cipher] || "string" == typeof t && a.iter <= 100 || 64 !== a.ts && 96 !== a.ts && 128 !== a.ts || 128 !== a.ks && 192 !== a.ks && 256 !== a.ks || a.iv.length < 2 || 4 < a.iv.length)
throw new b.exception.invalid("json encrypt: invalid parameters");
return "string" == typeof t ? (t = (r = b.misc.cachedPbkdf2(t, a)).key.slice(0, a.ks / 32),
a.salt = r.salt) : b.ecc && t instanceof b.ecc.elGamal.publicKey && (r = t.kem(),
a.kemtag = r.tag,
t = r.key.slice(0, a.ks / 32)),
"string" == typeof e && (e = b.codec.utf8String.toBits(e)),
"string" == typeof i && (a.adata = i = b.codec.utf8String.toBits(i)),
r = new b.ciphera.cipher,
o.g(n, a),
n.key = t,
a.ct = ("ccm" === a.mode && b.arrayBuffer && b.arrayBuffer.ccm && e instanceof ArrayBuffer ? b.arrayBuffer.ccm : b.mode[a.mode]).encrypt(r, e, a.iv, i, a.ts),
a
},
encrypt: function(t, e, i, n) {
var r = b.json
, o = r.ja.apply(r, arguments);
return r.encode(o)
},
ia: function(t, e, i, n) {
i = i || {},
n = n || {};
var r, o = b.json, a = (e = o.g(o.g(o.g({}, o.defaults), e), i, !0)).adata;
if ("string" == typeof e.salt && (e.salt = b.codec.base64.toBits(e.salt)),
"string" == typeof e.iv && (e.iv = b.codec.base64.toBits(e.iv)),
!b.mode[e.mode] || !b.cipher[e.cipher] || "string" == typeof t && e.iter <= 100 || 64 !== e.ts && 96 !== e.ts && 128 !== e.ts || 128 !== e.ks && 192 !== e.ks && 256 !== e.ks || !e.iv || e.iv.length < 2 || 4 < e.iv.length)
throw new b.exception.invalid("json decrypt: invalid parameters");
return "string" == typeof t ? (t = (r = b.misc.cachedPbkdf2(t, e)).key.slice(0, e.ks / 32),
e.salt = r.salt) : b.ecc && t instanceof b.ecc.elGamal.secretKey && (t = t.unkem(b.codec.base64.toBits(e.kemtag)).slice(0, e.ks / 32)),
"string" == typeof a && (a = b.codec.utf8String.toBits(a)),
r = new b.ciphere.cipher,
a = "ccm" === e.mode && b.arrayBuffer && b.arrayBuffer.ccm && e.ct instanceof ArrayBuffer ? b.arrayBuffer.ccm.decrypt(r, e.ct, e.iv, e.tag, a, e.ts) : b.mode[e.mode].decrypt(r, e.ct, e.iv, a, e.ts),
o.g(n, e),
n.key = t,
1 === i.raw ? a : b.codec.utf8String.fromBits(a)
},
decrypt: function(t, e, i, n) {
var r = b.json;
return r.ia(t, r.decode(e), i, n)
},
encode: function(t) {
var e, i = "{", n = "";
for (e in t)
if (t.hasOwnProperty(e)) {
if (!e.match(/^[a-z0-9]+$/i))
throw new b.exception.invalid("json encode: invalid property name");
switch (i += n + '"' + e + '":',
n = ",",
typeof t[e]) {
case "number":
case "boolean":
i += t[e];
break;
case "string":
i += '"' + escape(t[e]) + '"';
break;
case "object":
i += '"' + b.codec.base64.fromBits(t[e], 0) + '"';
break;
default:
throw new b.exception.bug("json encode: unsupported type")
}
}
return i + "}"
},
decode: function(t) {
if (!(t = t.replace(/\s/g, "")).match(/^{.}$/))
throw new b.exception.invalid("json decode: this isn't json!");
t = t.replace(/^{|}$/g, "").split(/,/);
for (var e, i = {}, n = 0; n < t.length; n++) {
if (!(e = t[n].match(/^\s(?:(["']?)([a-z][a-z0-9])\1)\s:\s(?:(-?\d+)|"([a-z0-9+\/%_.@=-])"|(true|false))$/i)))
throw new b.exception.invalid("json decode: this isn't json!");
null != e[3] ? i[e[2]] = parseInt(e[3], 10) : null != e[4] ? i[e[2]] = e[2].match(/^(ct|adata|salt|iv)$/) ? b.codec.base64.toBits(e[4]) : unescape(e[4]) : null != e[5] && (i[e[2]] = "true" === e[5])
}
return i
},
g: function(t, e, i) {
if (void 0 === t && (t = {}),
void 0 === e)
return t;
for (var n in e)
if (e.hasOwnProperty(n)) {
if (i && void 0 !== t[n] && t[n] !== e[n])
throw new b.exception.invalid("required parameter overridden");
t[n] = e[n]
}
return t
},
sa: function(t, e) {
var i, n = {};
for (i in t)
t.hasOwnProperty(i) && t[i] !== e[i] && (n[i] = t[i]);
return n
},
ra: function(t, e) {
for (var i = {}, n = 0; n < e.length; n++)
void 0 !== t[e[n]] && (i[e[n]] = t[e[n]]);
return i
}
},
b.encrypt = b.json.encrypt,
b.decrypt = b.json.decrypt,
b.misc.pa = {},
b.misc.cachedPbkdf2 = function(t, e) {
var i = b.misc.pa
, n = (e = e || {}).iter || 1e3;
return (n = (i = i[t] = i[t] || {})[n] = i[n] || {
firstSalt: e.salt && e.salt.length ? e.salt.slice(0) : b.random.randomWords(2, 0)
})[i = void 0 === e.salt ? n.firstSalt : e.salt] = n[i] || b.misc.pbkdf2(t, i, e.iter),
{
key: n[i].slice(0),
salt: i.slice(0)
}
}
,
t.exports && (t.exports = b),
void 0 === (e = function() {
return b
}
.apply(e, [])) || (t.exports = e)
}
})
function GCM_encrypt (w){
var k = _r('409'),
n = w,
//t = k.codec.utf8String.toBits(JSON.stringify(n)),
t = k.codec.utf8String.toBits(n),
e = k.random.randomWords(3, 0),
i = k.random.randomWords(2, 0),
n = k.misc.pbkdf2("dhdejje-*@dfg", i, 1e3),
n = new k.cipher.aes(n),
t = k.mode.gcm.encrypt(n, t, e, 0, 128),
i = (i = i.concat(e)).concat(t);
return k.codec.base64.fromBits(i);
}
function GCM_decrypt (w){
var k = _r('409'),
i = w,
e = k.codec.base64.toBits(i),
t = k.bitArray.bitSlice(e, 0, 64),
i = k.bitArray.bitSlice(e, 64, 160),
e = k.bitArray.bitSlice(e, 160),
t = k.misc.pbkdf2("dhdejje-*@dfg", t, 1e3),
t = new k.cipher.aes(t),
i = k.mode.gcm.decrypt(t, e, i, 0, 128);
return k.codec.base64.fromBits(i);
}