var sm2ciphermode = { c1c2c3: "0", c1c3c2: "1" }; var cryptojs = cryptojs || function (a, b) { var c = {} , d = c.lib = {} , e = d.base = function () { function a() { } return { extend: function (c) { a.prototype = this; var b = new a; c && b.mixin(c); b.hasownproperty("init") || (b.init = function () { b.$super.init.apply(this, arguments) } ); b.init.prototype = b; b.$super = this; return b }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixin: function (a) { for (var c in a) a.hasownproperty(c) && (this[c] = a[c]); a.hasownproperty("tostring") && (this.tostring = a.tostring) }, clone: function () { return this.init.prototype.extend(this) } } } () , f = d.wordarray = e.extend({ init: function (a, c) { a = this.words = a || []; this.sigbytes = c != b ? c : 4 * a.length }, tostring: function (a) { return (a || h).stringify(this) }, concat: function (a) { var c = this.words , b = a.words , d = this.sigbytes; a = a.sigbytes; this.clamp(); if (d % 4) for (var e = 0; e < a; e++) c[d + e >>> 2] |= (b[e >>> 2] >>> 24 - e % 4 * 8 & 255) << 24 - (d + e) % 4 * 8; else if (65535 < b.length) for (e = 0; e < a; e += 4) c[d + e >>> 2] = b[e >>> 2]; else c.push.apply(c, b); this.sigbytes += a; return this }, clamp: function () { var c = this.words , b = this.sigbytes; c[b >>> 2] &= 4294967295 << 32 - b % 4 * 8; c.length = a.ceil(b / 4) }, clone: function () { var a = e.clone.call(this); a.words = this.words.slice(0); return a }, random: function (c) { for (var b = [], d = 0; d < c; d += 4) b.push(4294967296 * a.random() | 0); return new f.init(b, c) } }) , g = c.enc = {} , h = g.hex = { stringify: function (a) { var c = a.words; a = a.sigbytes; for (var b = [], d = 0; d < a; d++) { var e = c[d >>> 2] >>> 24 - d % 4 * 8 & 255; b.push((e >>> 4).tostring(16)); b.push((e & 15).tostring(16)) } return b.join("") }, parse: function (a) { for (var c = a.length, b = [], d = 0; d < c; d += 2) b[d >>> 3] |= parseint(a.substr(d, 2), 16) << 24 - d % 8 * 4; return new f.init(b, c / 2) } } , k = g.latin1 = { stringify: function (a) { var c = a.words; a = a.sigbytes; for (var b = [], d = 0; d < a; d++) b.push(string.fromcharcode(c[d >>> 2] >>> 24 - d % 4 * 8 & 255)); return b.join("") }, parse: function (a) { for (var c = a.length, b = [], d = 0; d < c; d++) b[d >>> 2] |= (a.charcodeat(d) & 255) << 24 - d % 4 * 8; return new f.init(b, c) } } , l = g.utf8 = { stringify: function (a) { try { return decodeuricomponent(escape(k.stringify(a))) } catch (c) { throw error("malformed utf-8 data"); } }, parse: function (a) { return k.parse(unescape(encodeuricomponent(a))) } } , p = d.bufferedblockalgorithm = e.extend({ reset: function () { this._data = new f.init; this._ndatabytes = 0 }, _append: function (a) { "string" == typeof a && (a = l.parse(a)); this._data.concat(a); this._ndatabytes += a.sigbytes }, _process: function (c) { var b = this._data , d = b.words , e = b.sigbytes , g = this.blocksize , h = e / (4 * g) , h = c ? a.ceil(h) : a.max((h | 0) - this._minbuffersize, 0); c = h * g; e = a.min(4 * c, e); if (c) { for (var k = 0; k < c; k += g) this._doprocessblock(d, k); k = d.splice(0, c); b.sigbytes -= e } return new f.init(k, e) }, clone: function () { var a = e.clone.call(this); a._data = this._data.clone(); return a }, _minbuffersize: 0 }); d.hasher = p.extend({ cfg: e.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { p.reset.call(this); this._doreset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._dofinalize() }, blocksize: 16, _createhelper: function (a) { return function (c, b) { return (new a.init(b)).finalize(c) } }, _createhmachelper: function (a) { return function (c, b) { return (new n.hmac.init(a, b)).finalize(c) } } }); var n = c.algo = {}; return c } (math); cryptojs.lib.cipher || function (a) { var b = cryptojs , c = b.lib , d = c.base , e = c.wordarray , f = c.bufferedblockalgorithm , g = b.enc.base64 , h = b.algo.evpkdf , k = c.cipher = f.extend({ cfg: d.extend(), createencryptor: function (a, c) { return this.create(this._enc_xform_mode, a, c) }, createdecryptor: function (a, c) { return this.create(this._dec_xform_mode, a, c) }, init: function (a, c, b) { this.cfg = this.cfg.extend(b); this._xformmode = a; this._key = c; this.reset() }, reset: function () { f.reset.call(this); this._doreset() }, process: function (a) { this._append(a); return this._process() }, finalize: function (a) { a && this._append(a); return this._dofinalize() }, keysize: 4, ivsize: 4, _enc_xform_mode: 1, _dec_xform_mode: 2, _createhelper: function () { return function (a) { return { encrypt: function (c, b, d) { return ("string" == typeof b ? r : m).encrypt(a, c, b, d) }, decrypt: function (c, b, d) { return ("string" == typeof b ? r : m).decrypt(a, c, b, d) } } } } () }); c.streamcipher = k.extend({ _dofinalize: function () { return this._process(!0) }, blocksize: 1 }); var l = b.mode = {} , p = c.blockciphermode = d.extend({ createencryptor: function (a, c) { return this.encryptor.create(a, c) }, createdecryptor: function (a, c) { return this.decryptor.create(a, c) }, init: function (a, c) { this._cipher = a; this._iv = c } }) , l = l.cbc = function () { function c(b, d, e) { var f = this._iv; f ? this._iv = a : f = this._prevblock; for (var g = 0; g < e; g++) b[d + g] ^= f[g] } var b = p.extend(); b.encryptor = b.extend({ processblock: function (a, b) { var d = this._cipher , e = d.blocksize; c.call(this, a, b, e); d.encryptblock(a, b); this._prevblock = a.slice(b, b + e) } }); b.decryptor = b.extend({ processblock: function (a, b) { var d = this._cipher , e = d.blocksize , f = a.slice(b, b + e); d.decryptblock(a, b); c.call(this, a, b, e); this._prevblock = f } }); return b } () , n = (b.pad = {}).pkcs7 = { pad: function (a, c) { for (var b = 4 * c, b = b - a.sigbytes % b, d = b << 24 | b << 16 | b << 8 | b, f = [], g = 0; g < b; g += 4) f.push(d); b = e.create(f, b); a.concat(b) }, unpad: function (a) { a.sigbytes -= a.words[a.sigbytes - 1 >>> 2] & 255 } }; c.blockcipher = k.extend({ cfg: k.cfg.extend({ mode: l, padding: n }), reset: function () { k.reset.call(this); var a = this.cfg , c = a.iv , a = a.mode; if (this._xformmode == this._enc_xform_mode) var b = a.createencryptor; else b = a.createdecryptor, this._minbuffersize = 1; this._mode = b.call(a, this, c && c.words) }, _doprocessblock: function (a, c) { this._mode.processblock(a, c) }, _dofinalize: function () { var a = this.cfg.padding; if (this._xformmode == this._enc_xform_mode) { a.pad(this._data, this.blocksize); var c = this._process(!0) } else c = this._process(!0), a.unpad(c); return c }, blocksize: 4 }); var q = c.cipherparams = d.extend({ init: function (a) { this.mixin(a) }, tostring: function (a) { return (a || this.formatter).stringify(this) } }) , l = (b.format = {}).openssl = { stringify: function (a) { var c = a.ciphertext; a = a.salt; return (a ? e.create([1398893684, 1701076831]).concat(a).concat(c) : c).tostring(g) }, parse: function (a) { a = g.parse(a); var c = a.words; if (1398893684 == c[0] && 1701076831 == c[1]) { var b = e.create(c.slice(2, 4)); c.splice(0, 4); a.sigbytes -= 16 } return q.create({ ciphertext: a, salt: b }) } } , m = c.serializablecipher = d.extend({ cfg: d.extend({ format: l }), encrypt: function (a, c, b, d) { d = this.cfg.extend(d); var e = a.createencryptor(b, d); c = e.finalize(c); e = e.cfg; return q.create({ ciphertext: c, key: b, iv: e.iv, algorithm: a, mode: e.mode, padding: e.padding, blocksize: a.blocksize, formatter: d.format }) }, decrypt: function (a, c, b, d) { d = this.cfg.extend(d); c = this._parse(c, d.format); return a.createdecryptor(b, d).finalize(c.ciphertext) }, _parse: function (a, c) { return "string" == typeof a ? c.parse(a, this) : a } }) , b = (b.kdf = {}).openssl = { execute: function (a, c, b, d) { d || (d = e.random(8)); a = h.create({ keysize: c + b }).compute(a, d); b = e.create(a.words.slice(c), 4 * b); a.sigbytes = 4 * c; return q.create({ key: a, iv: b, salt: d }) } } , r = c.passwordbasedcipher = m.extend({ cfg: m.cfg.extend({ kdf: b }), encrypt: function (a, c, b, d) { d = this.cfg.extend(d); b = d.kdf.execute(b, a.keysize, a.ivsize); d.iv = b.iv; a = m.encrypt.call(this, a, c, b.key, d); a.mixin(b); return a }, decrypt: function (a, c, b, d) { d = this.cfg.extend(d); c = this._parse(c, d.format); b = d.kdf.execute(b, a.keysize, a.ivsize, c.salt); d.iv = b.iv; return m.decrypt.call(this, a, c, b.key, d) } }) } (); (function () { function a(a, c) { var b = (this._lblock >>> a ^ this._rblock) & c; this._rblock ^= b; this._lblock ^= b << a } function b(a, c) { var b = (this._rblock >>> a ^ this._lblock) & c; this._lblock ^= b; this._rblock ^= b << a } var c = cryptojs , d = c.lib , e = d.wordarray , d = d.blockcipher , f = c.algo , g = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4] , h = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32] , k = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28] , l = [{ 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 }] , p = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679] , n = f.des = d.extend({ _doreset: function () { for (var a = this._key.words, c = [], b = 0; 56 > b; b++) { var d = g[b] - 1; c[b] = a[d >>> 5] >>> 31 - d % 32 & 1 } a = this._subkeys = []; for (d = 0; 16 > d; d++) { for (var e = a[d] = [], f = k[d], b = 0; 24 > b; b++) e[b / 6 | 0] |= c[(h[b] - 1 + f) % 28] << 31 - b % 6, e[4 + (b / 6 | 0)] |= c[28 + (h[b + 24] - 1 + f) % 28] << 31 - b % 6; e[0] = e[0] << 1 | e[0] >>> 31; for (b = 1; 7 > b; b++) e[b] >>>= 4 * (b - 1) + 3; e[7] = e[7] << 5 | e[7] >>> 27 } c = this._invsubkeys = []; for (b = 0; 16 > b; b++) c[b] = a[15 - b] }, encryptblock: function (a, c) { this._docryptblock(a, c, this._subkeys) }, decryptblock: function (a, c) { this._docryptblock(a, c, this._invsubkeys) }, _docryptblock: function (c, d, e) { this._lblock = c[d]; this._rblock = c[d + 1]; a.call(this, 4, 252645135); a.call(this, 16, 65535); b.call(this, 2, 858993459); b.call(this, 8, 16711935); a.call(this, 1, 1431655765); for (var f = 0; 16 > f; f++) { for (var g = e[f], h = this._lblock, k = this._rblock, n = 0, u = 0; 8 > u; u++) n |= l[u][((k ^ g[u]) & p[u]) >>> 0]; this._lblock = k; this._rblock = h ^ n } e = this._lblock; this._lblock = this._rblock; this._rblock = e; a.call(this, 1, 1431655765); b.call(this, 8, 16711935); b.call(this, 2, 858993459); a.call(this, 16, 65535); a.call(this, 4, 252645135); c[d] = this._lblock; c[d + 1] = this._rblock }, keysize: 2, ivsize: 2, blocksize: 2 }); c.des = d._createhelper(n); f = f.tripledes = d.extend({ _doreset: function () { var a = this._key.words; this._des1 = n.createencryptor(e.create(a.slice(0, 2))); this._des2 = n.createencryptor(e.create(a.slice(2, 4))); this._des3 = n.createencryptor(e.create(a.slice(4, 6))) }, encryptblock: function (a, c) { this._des1.encryptblock(a, c); this._des2.decryptblock(a, c); this._des3.encryptblock(a, c) }, decryptblock: function (a, c) { this._des3.decryptblock(a, c); this._des2.encryptblock(a, c); this._des1.decryptblock(a, c) }, keysize: 6, ivsize: 2, blocksize: 2 }); c.tripledes = d._createhelper(f) })(); (function () { var a = cryptojs , b = a.lib.wordarray; a.enc.base64 = { stringify: function (a) { var b = a.words , e = a.sigbytes , f = this._map; a.clamp(); a = []; for (var g = 0; g < e; g += 3) for (var h = (b[g >>> 2] >>> 24 - g % 4 * 8 & 255) << 16 | (b[g + 1 >>> 2] >>> 24 - (g + 1) % 4 * 8 & 255) << 8 | b[g + 2 >>> 2] >>> 24 - (g + 2) % 4 * 8 & 255, k = 0; 4 > k && g + .75 * k < e; k++) a.push(f.charat(h >>> 6 * (3 - k) & 63)); if (b = f.charat(64)) for (; a.length % 4;) a.push(b); return a.join("") }, parse: function (a) { var d = a.length , e = this._map , f = e.charat(64); f && (f = a.indexof(f), -1 != f && (d = f)); for (var f = [], g = 0, h = 0; h < d; h++) if (h % 4) { var k = e.indexof(a.charat(h - 1)) << h % 4 * 2 , l = e.indexof(a.charat(h)) >>> 6 - h % 4 * 2; f[g >>> 2] |= (k | l) << 24 - g % 4 * 8; g++ } return b.create(f, g) }, _map: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/=" } })(); var dbits, canary = 0xdeadbeefcafe, j_lm = 15715070 == (canary & 16777215); function biginteger(a, b, c) { null != a && ("number" == typeof a ? this.fromnumber(a, b, c) : null == b && "string" != typeof a ? this.fromstring(a, 256) : this.fromstring(a, b)) } function nbi() { return new biginteger(null) } function am1(a, b, c, d, e, f) { for (; 0 <= --f;) { var g = b * this[a++] + c[d] + e; e = math.floor(g / 67108864); c[d++] = g & 67108863 } return e } function am2(a, b, c, d, e, f) { var g = b & 32767; for (b >>= 15; 0 <= --f;) { var h = this[a] & 32767 , k = this[a++] >> 15 , l = b * h + k * g , h = g * h + ((l & 32767) << 15) + c[d] + (e & 1073741823); e = (h >>> 30) + (l >>> 15) + b * k + (e >>> 30); c[d++] = h & 1073741823 } return e } function am3(a, b, c, d, e, f) { var g = b & 16383; for (b >>= 14; 0 <= --f;) { var h = this[a] & 16383 , k = this[a++] >> 14 , l = b * h + k * g , h = g * h + ((l & 16383) << 14) + c[d] + e; e = (h >> 28) + (l >> 14) + b * k; c[d++] = h & 268435455 } return e } j_lm && "microsoft internet explorer" == navigator.appname ? (biginteger.prototype.am = am2, dbits = 30) : j_lm && "netscape" != navigator.appname ? (biginteger.prototype.am = am1, dbits = 26) : (biginteger.prototype.am = am3, dbits = 28); biginteger.prototype.db = dbits; biginteger.prototype.dm = (1 << dbits) - 1; biginteger.prototype.dv = 1 << dbits; var bi_fp = 52; biginteger.prototype.fv = math.pow(2, bi_fp); biginteger.prototype.f1 = bi_fp - dbits; biginteger.prototype.f2 = 2 * dbits - bi_fp; var bi_rm = "0123456789abcdefghijklmnopqrstuvwxyz", bi_rc = [], rr, vv; rr = 48; for (vv = 0; 9 >= vv; ++vv) bi_rc[rr++] = vv; rr = 97; for (vv = 10; 36 > vv; ++vv) bi_rc[rr++] = vv; rr = 65; for (vv = 10; 36 > vv; ++vv) bi_rc[rr++] = vv; function int2char(a) { return bi_rm.charat(a) } function intat(a, b) { var c = bi_rc[a.charcodeat(b)]; return null == c ? -1 : c } function bnpcopyto(a) { for (var b = this.t - 1; 0 <= b; --b) a[b] = this[b]; a.t = this.t; a.s = this.s } function bnpfromint(a) { this.t = 1; this.s = 0 > a ? -1 : 0; 0 < a ? this[0] = a : -1 > a ? this[0] = a + this.dv : this.t = 0 } function nbv(a) { var b = nbi(); b.fromint(a); return b } function bnpfromstring(a, b) { var c; if (16 == b) c = 4; else if (8 == b) c = 3; else if (256 == b) c = 8; else if (2 == b) c = 1; else if (32 == b) c = 5; else if (4 == b) c = 2; else { this.fromradix(a, b); return } this.s = this.t = 0; for (var d = a.length, e = !1, f = 0; 0 <= --d;) { var g = 8 == c ? a[d] & 255 : intat(a, d); 0 > g ? "-" == a.charat(d) && (e = !0) : (e = !1, 0 == f ? this[this.t++] = g : f + c > this.db ? (this[this.t - 1] |= (g & (1 << this.db - f) - 1) << f, this[this.t++] = g >> this.db - f) : this[this.t - 1] |= g << f, f += c, f >= this.db && (f -= this.db)) } 8 == c && 0 != (a[0] & 128) && (this.s = -1, 0 < f && (this[this.t - 1] |= (1 << this.db - f) - 1 << f)); this.clamp(); e && biginteger.zero.subto(this, this) } function bnpclamp() { for (var a = this.s & this.dm; 0 < this.t && this[this.t - 1] == a;) --this.t } function bntostring(a) { if (0 > this.s) return "-" + this.negate().tostring(a); if (16 == a) a = 4; else if (8 == a) a = 3; else if (2 == a) a = 1; else if (32 == a) a = 5; else if (4 == a) a = 2; else return this.toradix(a); var b = (1 << a) - 1, c, d = !1, e = "", f = this.t, g = this.db - f * this.db % a; if (0 < f--) for (g < this.db && 0 < (c = this[f] >> g) && (d = !0, e = int2char(c)); 0 <= f;) g < a ? (c = (this[f] & (1 << g) - 1) << a - g, c |= this[--f] >> (g += this.db - a)) : (c = this[f] >> (g -= a) & b, 0 >= g && (g += this.db, --f)), 0 < c && (d = !0), d && (e += int2char(c)); return d ? e : "0" } function bnnegate() { var a = nbi(); biginteger.zero.subto(this, a); return a } function bnabs() { return 0 > this.s ? this.negate() : this } function bncompareto(a) { var b = this.s - a.s; if (0 != b) return b; var c = this.t , b = c - a.t; if (0 != b) return 0 > this.s ? -b : b; for (; 0 <= --c;) if (0 != (b = this[c] - a[c])) return b; return 0 } function nbits(a) { var b = 1, c; 0 != (c = a >>> 16) && (a = c, b += 16); 0 != (c = a >> 8) && (a = c, b += 8); 0 != (c = a >> 4) && (a = c, b += 4); 0 != (c = a >> 2) && (a = c, b += 2); 0 != a >> 1 && (b += 1); return b } function bnbitlength() { return 0 >= this.t ? 0 : this.db * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.dm) } function bnpdlshiftto(a, b) { var c; for (c = this.t - 1; 0 <= c; --c) b[c + a] = this[c]; for (c = a - 1; 0 <= c; --c) b[c] = 0; b.t = this.t + a; b.s = this.s } function bnpdrshiftto(a, b) { for (var c = a; c < this.t; ++c) b[c - a] = this[c]; b.t = math.max(this.t - a, 0); b.s = this.s } function bnplshiftto(a, b) { var c = a % this.db, d = this.db - c, e = (1 << d) - 1, f = math.floor(a / this.db), g = this.s << c & this.dm, h; for (h = this.t - 1; 0 <= h; --h) b[h + f + 1] = this[h] >> d | g, g = (this[h] & e) << c; for (h = f - 1; 0 <= h; --h) b[h] = 0; b[f] = g; b.t = this.t + f + 1; b.s = this.s; b.clamp() } function bnprshiftto(a, b) { b.s = this.s; var c = math.floor(a / this.db); if (c >= this.t) b.t = 0; else { var d = a % this.db , e = this.db - d , f = (1 << d) - 1; b[0] = this[c] >> d; for (var g = c + 1; g < this.t; ++g) b[g - c - 1] |= (this[g] & f) << e, b[g - c] = this[g] >> d; 0 < d && (b[this.t - c - 1] |= (this.s & f) << e); b.t = this.t - c; b.clamp() } } function bnpsubto(a, b) { for (var c = 0, d = 0, e = math.min(a.t, this.t); c < e;) d += this[c] - a[c], b[c++] = d & this.dm, d >>= this.db; if (a.t < this.t) { for (d -= a.s; c < this.t;) d += this[c], b[c++] = d & this.dm, d >>= this.db; d += this.s } else { for (d += this.s; c < a.t;) d -= a[c], b[c++] = d & this.dm, d >>= this.db; d -= a.s } b.s = 0 > d ? -1 : 0; -1 > d ? b[c++] = this.dv + d : 0 < d && (b[c++] = d); b.t = c; b.clamp() } function bnpmultiplyto(a, b) { var c = this.abs() , d = a.abs() , e = c.t; for (b.t = e + d.t; 0 <= --e;) b[e] = 0; for (e = 0; e < d.t; ++e) b[e + c.t] = c.am(0, d[e], b, e, 0, c.t); b.s = 0; b.clamp(); this.s != a.s && biginteger.zero.subto(b, b) } function bnpsquareto(a) { for (var b = this.abs(), c = a.t = 2 * b.t; 0 <= --c;) a[c] = 0; for (c = 0; c < b.t - 1; ++c) { var d = b.am(c, b[c], a, 2 * c, 0, 1); (a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.dv && (a[c + b.t] -= b.dv, a[c + b.t + 1] = 1) } 0 < a.t && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1)); a.s = 0; a.clamp() } function bnpdivremto(a, b, c) { var d = a.abs(); if (!(0 >= d.t)) { var e = this.abs(); if (e.t < d.t) null != b && b.fromint(0), null != c && this.copyto(c); else { null == c && (c = nbi()); var f = nbi() , g = this.s; a = a.s; var h = this.db - nbits(d[d.t - 1]); 0 < h ? (d.lshiftto(h, f), e.lshiftto(h, c)) : (d.copyto(f), e.copyto(c)); d = f.t; e = f[d - 1]; if (0 != e) { var k = e * (1 << this.f1) + (1 < d ? f[d - 2] >> this.f2 : 0) , l = this.fv / k , k = (1 << this.f1) / k , p = 1 << this.f2 , n = c.t , q = n - d , m = null == b ? nbi() : b; f.dlshiftto(q, m); 0 <= c.compareto(m) && (c[c.t++] = 1, c.subto(m, c)); biginteger.one.dlshiftto(d, m); for (m.subto(f, f); f.t < d;) f[f.t++] = 0; for (; 0 <= --q;) { var r = c[--n] == e ? this.dm : math.floor(c[n] * l + (c[n - 1] + p) * k); if ((c[n] += f.am(0, r, c, q, 0, d)) < r) for (f.dlshiftto(q, m), c.subto(m, c); c[n] < --r;) c.subto(m, c) } null != b && (c.drshiftto(d, b), g != a && biginteger.zero.subto(b, b)); c.t = d; c.clamp(); 0 < h && c.rshiftto(h, c); 0 > g && biginteger.zero.subto(c, c) } } } } function bnmod(a) { var b = nbi(); this.abs().divremto(a, null, b); 0 > this.s && 0 < b.compareto(biginteger.zero) && a.subto(b, b); return b } function classic(a) { this.m = a } function cconvert(a) { return 0 > a.s || 0 <= a.compareto(this.m) ? a.mod(this.m) : a } function crevert(a) { return a } function creduce(a) { a.divremto(this.m, null, a) } function cmulto(a, b, c) { a.multiplyto(b, c); this.reduce(c) } function csqrto(a, b) { a.squareto(b); this.reduce(b) } classic.prototype.convert = cconvert; classic.prototype.revert = crevert; classic.prototype.reduce = creduce; classic.prototype.multo = cmulto; classic.prototype.sqrto = csqrto; function bnpinvdigit() { if (1 > this.t) return 0; var a = this[0]; if (0 == (a & 1)) return 0; var b = a & 3 , b = b * (2 - (a & 15) * b) & 15 , b = b * (2 - (a & 255) * b) & 255 , b = b * (2 - ((a & 65535) * b & 65535)) & 65535 , b = b * (2 - a * b % this.dv) % this.dv; return 0 < b ? this.dv - b : -b } function montgomery(a) { this.m = a; this.mp = a.invdigit(); this.mpl = this.mp & 32767; this.mph = this.mp >> 15; this.um = (1 << a.db - 15) - 1; this.mt2 = 2 * a.t } function montconvert(a) { var b = nbi(); a.abs().dlshiftto(this.m.t, b); b.divremto(this.m, null, b); 0 > a.s && 0 < b.compareto(biginteger.zero) && this.m.subto(b, b); return b } function montrevert(a) { var b = nbi(); a.copyto(b); this.reduce(b); return b } function montreduce(a) { for (; a.t <= this.mt2;) a[a.t++] = 0; for (var b = 0; b < this.m.t; ++b) { var c = a[b] & 32767 , d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.dm , c = b + this.m.t; for (a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >= a.dv;) a[c] -= a.dv, a[++c]++ } a.clamp(); a.drshiftto(this.m.t, a); 0 <= a.compareto(this.m) && a.subto(this.m, a) } function montsqrto(a, b) { a.squareto(b); this.reduce(b) } function montmulto(a, b, c) { a.multiplyto(b, c); this.reduce(c) } montgomery.prototype.convert = montconvert; montgomery.prototype.revert = montrevert; montgomery.prototype.reduce = montreduce; montgomery.prototype.multo = montmulto; montgomery.prototype.sqrto = montsqrto; function bnpiseven() { return 0 == (0 < this.t ? this[0] & 1 : this.s) } function bnpexp(a, b) { if (4294967295 < a || 1 > a) return biginteger.one; var c = nbi() , d = nbi() , e = b.convert(this) , f = nbits(a) - 1; for (e.copyto(c); 0 <= --f;) if (b.sqrto(c, d), 0 < (a & 1 << f)) b.multo(d, e, c); else var g = c , c = d , d = g; return b.revert(c) } function bnmodpowint(a, b) { var c; c = 256 > a || b.iseven() ? new classic(b) : new montgomery(b); return this.exp(a, c) } biginteger.prototype.copyto = bnpcopyto; biginteger.prototype.fromint = bnpfromint; biginteger.prototype.fromstring = bnpfromstring; biginteger.prototype.clamp = bnpclamp; biginteger.prototype.dlshiftto = bnpdlshiftto; biginteger.prototype.drshiftto = bnpdrshiftto; biginteger.prototype.lshiftto = bnplshiftto; biginteger.prototype.rshiftto = bnprshiftto; biginteger.prototype.subto = bnpsubto; biginteger.prototype.multiplyto = bnpmultiplyto; biginteger.prototype.squareto = bnpsquareto; biginteger.prototype.divremto = bnpdivremto; biginteger.prototype.invdigit = bnpinvdigit; biginteger.prototype.iseven = bnpiseven; biginteger.prototype.exp = bnpexp; biginteger.prototype.tostring = bntostring; biginteger.prototype.negate = bnnegate; biginteger.prototype.abs = bnabs; biginteger.prototype.compareto = bncompareto; biginteger.prototype.bitlength = bnbitlength; biginteger.prototype.mod = bnmod; biginteger.prototype.modpowint = bnmodpowint; biginteger.zero = nbv(0); biginteger.one = nbv(1); function bnclone() { var a = nbi(); this.copyto(a); return a } function bnintvalue() { if (0 > this.s) { if (1 == this.t) return this[0] - this.dv; if (0 == this.t) return -1 } else { if (1 == this.t) return this[0]; if (0 == this.t) return 0 } return (this[1] & (1 << 32 - this.db) - 1) << this.db | this[0] } function bnbytevalue() { return 0 == this.t ? this.s : this[0] << 24 >> 24 } function bnshortvalue() { return 0 == this.t ? this.s : this[0] << 16 >> 16 } function bnpchunksize(a) { return math.floor(math.ln2 * this.db / math.log(a)) } function bnsignum() { return 0 > this.s ? -1 : 0 >= this.t || 1 == this.t && 0 >= this[0] ? 0 : 1 } function bnptoradix(a) { null == a && (a = 10); if (0 == this.signum() || 2 > a || 36 < a) return "0"; var b = this.chunksize(a) , b = math.pow(a, b) , c = nbv(b) , d = nbi() , e = nbi() , f = ""; for (this.divremto(c, d, e); 0 < d.signum();) f = (b + e.intvalue()).tostring(a).substr(1) + f, d.divremto(c, d, e); return e.intvalue().tostring(a) + f } function bnpfromradix(a, b) { this.fromint(0); null == b && (b = 10); for (var c = this.chunksize(b), d = math.pow(b, c), e = !1, f = 0, g = 0, h = 0; h < a.length; ++h) { var k = intat(a, h); 0 > k ? "-" == a.charat(h) && 0 == this.signum() && (e = !0) : (g = b * g + k, ++f >= c && (this.dmultiply(d), this.daddoffset(g, 0), g = f = 0)) } 0 < f && (this.dmultiply(math.pow(b, f)), this.daddoffset(g, 0)); e && biginteger.zero.subto(this, this) } function bnpfromnumber(a, b, c) { if ("number" == typeof b) if (2 > a) this.fromint(1); else for (this.fromnumber(a, c), this.testbit(a - 1) || this.bitwiseto(biginteger.one.shiftleft(a - 1), op_or, this), this.iseven() && this.daddoffset(1, 0); !this.isprobableprime(b);) this.daddoffset(2, 0), this.bitlength() > a && this.subto(biginteger.one.shiftleft(a - 1), this); else { c = []; var d = a & 7; c.length = (a >> 3) + 1; b.nextbytes(c); c[0] = 0 < d ? c[0] & (1 << d) - 1 : 0; this.fromstring(c, 256) } } function bntobytearray() { var a = this.t , b = []; b[0] = this.s; var c = this.db - a * this.db % 8, d, e = 0; if (0 < a--) for (c < this.db && (d = this[a] >> c) != (this.s & this.dm) >> c && (b[e++] = d | this.s << this.db - c); 0 <= a;) if (8 > c ? (d = (this[a] & (1 << c) - 1) << 8 - c, d |= this[--a] >> (c += this.db - 8)) : (d = this[a] >> (c -= 8) & 255, 0 >= c && (c += this.db, --a)), 0 != (d & 128) && (d |= -256), 0 == e && (this.s & 128) != (d & 128) && ++e, 0 < e || d != this.s) b[e++] = d; return b } function bnequals(a) { return 0 == this.compareto(a) } function bnmin(a) { return 0 > this.compareto(a) ? this : a } function bnmax(a) { return 0 < this.compareto(a) ? this : a } function bnpbitwiseto(a, b, c) { var d, e, f = math.min(a.t, this.t); for (d = 0; d < f; ++d) c[d] = b(this[d], a[d]); if (a.t < this.t) { e = a.s & this.dm; for (d = f; d < this.t; ++d) c[d] = b(this[d], e); c.t = this.t } else { e = this.s & this.dm; for (d = f; d < a.t; ++d) c[d] = b(e, a[d]); c.t = a.t } c.s = b(this.s, a.s); c.clamp() } function op_and(a, b) { return a & b } function bnand(a) { var b = nbi(); this.bitwiseto(a, op_and, b); return b } function op_or(a, b) { return a | b } function bnor(a) { var b = nbi(); this.bitwiseto(a, op_or, b); return b } function op_xor(a, b) { return a ^ b } function bnxor(a) { var b = nbi(); this.bitwiseto(a, op_xor, b); return b } function op_andnot(a, b) { return a & ~b } function bnandnot(a) { var b = nbi(); this.bitwiseto(a, op_andnot, b); return b } function bnnot() { for (var a = nbi(), b = 0; b < this.t; ++b) a[b] = this.dm & ~this[b]; a.t = this.t; a.s = ~this.s; return a } function bnshiftleft(a) { var b = nbi(); 0 > a ? this.rshiftto(-a, b) : this.lshiftto(a, b); return b } function bnshiftright(a) { var b = nbi(); 0 > a ? this.lshiftto(-a, b) : this.rshiftto(a, b); return b } function lbit(a) { if (0 == a) return -1; var b = 0; 0 == (a & 65535) && (a >>= 16, b += 16); 0 == (a & 255) && (a >>= 8, b += 8); 0 == (a & 15) && (a >>= 4, b += 4); 0 == (a & 3) && (a >>= 2, b += 2); 0 == (a & 1) && ++b; return b } function bngetlowestsetbit() { for (var a = 0; a < this.t; ++a) if (0 != this[a]) return a * this.db + lbit(this[a]); return 0 > this.s ? this.t * this.db : -1 } function cbit(a) { for (var b = 0; 0 != a;) a &= a - 1, ++b; return b } function bnbitcount() { for (var a = 0, b = this.s & this.dm, c = 0; c < this.t; ++c) a += cbit(this[c] ^ b); return a } function bntestbit(a) { var b = math.floor(a / this.db); return b >= this.t ? 0 != this.s : 0 != (this[b] & 1 << a % this.db) } function bnpchangebit(a, b) { var c = biginteger.one.shiftleft(a); this.bitwiseto(c, b, c); return c } function bnsetbit(a) { return this.changebit(a, op_or) } function bnclearbit(a) { return this.changebit(a, op_andnot) } function bnflipbit(a) { return this.changebit(a, op_xor) } function bnpaddto(a, b) { for (var c = 0, d = 0, e = math.min(a.t, this.t); c < e;) d += this[c] + a[c], b[c++] = d & this.dm, d >>= this.db; if (a.t < this.t) { for (d += a.s; c < this.t;) d += this[c], b[c++] = d & this.dm, d >>= this.db; d += this.s } else { for (d += this.s; c < a.t;) d += a[c], b[c++] = d & this.dm, d >>= this.db; d += a.s } b.s = 0 > d ? -1 : 0; 0 < d ? b[c++] = d : -1 > d && (b[c++] = this.dv + d); b.t = c; b.clamp() } function bnadd(a) { var b = nbi(); this.addto(a, b); return b } function bnsubtract(a) { var b = nbi(); this.subto(a, b); return b } function bnmultiply(a) { var b = nbi(); this.multiplyto(a, b); return b } function bnsquare() { var a = nbi(); this.squareto(a); return a } function bndivide(a) { var b = nbi(); this.divremto(a, b, null); return b } function bnremainder(a) { var b = nbi(); this.divremto(a, null, b); return b } function bndivideandremainder(a) { var b = nbi() , c = nbi(); this.divremto(a, b, c); return [b, c] } function bnpdmultiply(a) { this[this.t] = this.am(0, a - 1, this, 0, 0, this.t); ++this.t; this.clamp() } function bnpdaddoffset(a, b) { if (0 != a) { for (; this.t <= b;) this[this.t++] = 0; for (this[b] += a; this[b] >= this.dv;) this[b] -= this.dv, ++b >= this.t && (this[this.t++] = 0), ++this[b] } } function nullexp() { } function nnop(a) { return a } function nmulto(a, b, c) { a.multiplyto(b, c) } function nsqrto(a, b) { a.squareto(b) } nullexp.prototype.convert = nnop; nullexp.prototype.revert = nnop; nullexp.prototype.multo = nmulto; nullexp.prototype.sqrto = nsqrto; function bnpow(a) { return this.exp(a, new nullexp) } function bnpmultiplylowerto(a, b, c) { var d = math.min(this.t + a.t, b); c.s = 0; for (c.t = d; 0 < d;) c[--d] = 0; var e; for (e = c.t - this.t; d < e; ++d) c[d + this.t] = this.am(0, a[d], c, d, 0, this.t); for (e = math.min(a.t, b); d < e; ++d) this.am(0, a[d], c, d, 0, b - d); c.clamp() } function bnpmultiplyupperto(a, b, c) { --b; var d = c.t = this.t + a.t - b; for (c.s = 0; 0 <= --d;) c[d] = 0; for (d = math.max(b - this.t, 0); d < a.t; ++d) c[this.t + d - b] = this.am(b - d, a[d], c, 0, 0, this.t + d - b); c.clamp(); c.drshiftto(1, c) } function barrett(a) { this.r2 = nbi(); this.q3 = nbi(); biginteger.one.dlshiftto(2 * a.t, this.r2); this.mu = this.r2.divide(a); this.m = a } function barrettconvert(a) { if (0 > a.s || a.t > 2 * this.m.t) return a.mod(this.m); if (0 > a.compareto(this.m)) return a; var b = nbi(); a.copyto(b); this.reduce(b); return b } function barrettrevert(a) { return a } function barrettreduce(a) { a.drshiftto(this.m.t - 1, this.r2); a.t > this.m.t + 1 && (a.t = this.m.t + 1, a.clamp()); this.mu.multiplyupperto(this.r2, this.m.t + 1, this.q3); for (this.m.multiplylowerto(this.q3, this.m.t + 1, this.r2); 0 > a.compareto(this.r2);) a.daddoffset(1, this.m.t + 1); for (a.subto(this.r2, a); 0 <= a.compareto(this.m);) a.subto(this.m, a) } function barrettsqrto(a, b) { a.squareto(b); this.reduce(b) } function barrettmulto(a, b, c) { a.multiplyto(b, c); this.reduce(c) } barrett.prototype.convert = barrettconvert; barrett.prototype.revert = barrettrevert; barrett.prototype.reduce = barrettreduce; barrett.prototype.multo = barrettmulto; barrett.prototype.sqrto = barrettsqrto; function bnmodpow(a, b) { var c = a.bitlength(), d, e = nbv(1), f; if (0 >= c) return e; d = 18 > c ? 1 : 48 > c ? 3 : 144 > c ? 4 : 768 > c ? 5 : 6; f = 8 > c ? new classic(b) : b.iseven() ? new barrett(b) : new montgomery(b); var g = [] , h = 3 , k = d - 1 , l = (1 << d) - 1; g[1] = f.convert(this); if (1 < d) for (c = nbi(), f.sqrto(g[1], c); h <= l;) g[h] = nbi(), f.multo(c, g[h - 2], g[h]), h += 2; for (var p = a.t - 1, n, q = !0, m = nbi(), c = nbits(a[p]) - 1; 0 <= p;) { c >= k ? n = a[p] >> c - k & l : (n = (a[p] & (1 << c + 1) - 1) << k - c, 0 < p && (n |= a[p - 1] >> this.db + c - k)); for (h = d; 0 == (n & 1);) n >>= 1, --h; 0 > (c -= h) && (c += this.db, --p); if (q) g[n].copyto(e), q = !1; else { for (; 1 < h;) f.sqrto(e, m), f.sqrto(m, e), h -= 2; 0 < h ? f.sqrto(e, m) : (h = e, e = m, m = h); f.multo(m, g[n], e) } for (; 0 <= p && 0 == (a[p] & 1 << c);) f.sqrto(e, m), h = e, e = m, m = h, 0 > --c && (c = this.db - 1, --p) } return f.revert(e) } function bngcd(a) { var b = 0 > this.s ? this.negate() : this.clone(); a = 0 > a.s ? a.negate() : a.clone(); if (0 > b.compareto(a)) { var c = b , b = a; a = c } var c = b.getlowestsetbit() , d = a.getlowestsetbit(); if (0 > d) return b; c < d && (d = c); 0 < d && (b.rshiftto(d, b), a.rshiftto(d, a)); for (; 0 < b.signum();) 0 < (c = b.getlowestsetbit()) && b.rshiftto(c, b), 0 < (c = a.getlowestsetbit()) && a.rshiftto(c, a), 0 <= b.compareto(a) ? (b.subto(a, b), b.rshiftto(1, b)) : (a.subto(b, a), a.rshiftto(1, a)); 0 < d && a.lshiftto(d, a); return a } function bnpmodint(a) { if (0 >= a) return 0; var b = this.dv % a , c = 0 > this.s ? a - 1 : 0; if (0 < this.t) if (0 == b) c = this[0] % a; else for (var d = this.t - 1; 0 <= d; --d) c = (b * c + this[d]) % a; return c } function bnmodinverse(a) { var b = a.iseven(); if (this.iseven() && b || 0 == a.signum()) return biginteger.zero; for (var c = a.clone(), d = this.clone(), e = nbv(1), f = nbv(0), g = nbv(0), h = nbv(1); 0 != c.signum();) { for (; c.iseven();) c.rshiftto(1, c), b ? (e.iseven() && f.iseven() || (e.addto(this, e), f.subto(a, f)), e.rshiftto(1, e)) : f.iseven() || f.subto(a, f), f.rshiftto(1, f); for (; d.iseven();) d.rshiftto(1, d), b ? (g.iseven() && h.iseven() || (g.addto(this, g), h.subto(a, h)), g.rshiftto(1, g)) : h.iseven() || h.subto(a, h), h.rshiftto(1, h); 0 <= c.compareto(d) ? (c.subto(d, c), b && e.subto(g, e), f.subto(h, f)) : (d.subto(c, d), b && g.subto(e, g), h.subto(f, h)) } if (0 != d.compareto(biginteger.one)) return biginteger.zero; if (0 <= h.compareto(a)) return h.subtract(a); if (0 > h.signum()) h.addto(a, h); else return h; return 0 > h.signum() ? h.add(a) : h } var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997] , lplim = 67108864 / lowprimes[lowprimes.length - 1]; function bnisprobableprime(a) { var b, c = this.abs(); if (1 == c.t && c[0] <= lowprimes[lowprimes.length - 1]) { for (b = 0; b < lowprimes.length; ++b) if (c[0] == lowprimes[b]) return !0; return !1 } if (c.iseven()) return !1; for (b = 1; b < lowprimes.length;) { for (var d = lowprimes[b], e = b + 1; e < lowprimes.length && d < lplim;) d *= lowprimes[e++]; for (d = c.modint(d); b < e;) if (0 == d % lowprimes[b++]) return !1 } return c.millerrabin(a) } function bnpmillerrabin(a) { var b = this.subtract(biginteger.one) , c = b.getlowestsetbit(); if (0 >= c) return !1; var d = b.shiftright(c); a = a + 1 >> 1; a > lowprimes.length && (a = lowprimes.length); for (var e = nbi(), f = 0; f < a; ++f) { e.fromint(lowprimes[math.floor(math.random() * lowprimes.length)]); var g = e.modpow(d, this); if (0 != g.compareto(biginteger.one) && 0 != g.compareto(b)) { for (var h = 1; h++ < c && 0 != g.compareto(b);) if (g = g.modpowint(2, this), 0 == g.compareto(biginteger.one)) return !1; if (0 != g.compareto(b)) return !1 } } return !0 } biginteger.prototype.chunksize = bnpchunksize; biginteger.prototype.toradix = bnptoradix; biginteger.prototype.fromradix = bnpfromradix; biginteger.prototype.fromnumber = bnpfromnumber; biginteger.prototype.bitwiseto = bnpbitwiseto; biginteger.prototype.changebit = bnpchangebit; biginteger.prototype.addto = bnpaddto; biginteger.prototype.dmultiply = bnpdmultiply; biginteger.prototype.daddoffset = bnpdaddoffset; biginteger.prototype.multiplylowerto = bnpmultiplylowerto; biginteger.prototype.multiplyupperto = bnpmultiplyupperto; biginteger.prototype.modint = bnpmodint; biginteger.prototype.millerrabin = bnpmillerrabin; biginteger.prototype.clone = bnclone; biginteger.prototype.intvalue = bnintvalue; biginteger.prototype.bytevalue = bnbytevalue; biginteger.prototype.shortvalue = bnshortvalue; biginteger.prototype.signum = bnsignum; biginteger.prototype.tobytearray = bntobytearray; biginteger.prototype.equals = bnequals; biginteger.prototype.min = bnmin; biginteger.prototype.max = bnmax; biginteger.prototype.and = bnand; biginteger.prototype.or = bnor; biginteger.prototype.xor = bnxor; biginteger.prototype.andnot = bnandnot; biginteger.prototype.not = bnnot; biginteger.prototype.shiftleft = bnshiftleft; biginteger.prototype.shiftright = bnshiftright; biginteger.prototype.getlowestsetbit = bngetlowestsetbit; biginteger.prototype.bitcount = bnbitcount; biginteger.prototype.testbit = bntestbit; biginteger.prototype.setbit = bnsetbit; biginteger.prototype.clearbit = bnclearbit; biginteger.prototype.flipbit = bnflipbit; biginteger.prototype.add = bnadd; biginteger.prototype.subtract = bnsubtract; biginteger.prototype.multiply = bnmultiply; biginteger.prototype.divide = bndivide; biginteger.prototype.remainder = bnremainder; biginteger.prototype.divideandremainder = bndivideandremainder; biginteger.prototype.modpow = bnmodpow; biginteger.prototype.modinverse = bnmodinverse; biginteger.prototype.pow = bnpow; biginteger.prototype.gcd = bngcd; biginteger.prototype.isprobableprime = bnisprobableprime; biginteger.prototype.square = bnsquare; function arcfour() { this.j = this.i = 0; this.s = [] } function arc4init(a) { var b, c, d; for (b = 0; 256 > b; ++b) this.s[b] = b; for (b = c = 0; 256 > b; ++b) c = c + this.s[b] + a[b % a.length] & 255, d = this.s[b], this.s[b] = this.s[c], this.s[c] = d; this.j = this.i = 0 } function arc4next() { var a; this.i = this.i + 1 & 255; this.j = this.j + this.s[this.i] & 255; a = this.s[this.i]; this.s[this.i] = this.s[this.j]; this.s[this.j] = a; return this.s[a + this.s[this.i] & 255] } arcfour.prototype.init = arc4init; arcfour.prototype.next = arc4next; function prng_newstate() { return new arcfour } var rng_psize = 256, rng_state, rng_pool, rng_pptr; function rng_seed_int(a) { rng_pool[rng_pptr++] ^= a & 255; rng_pool[rng_pptr++] ^= a >> 8 & 255; rng_pool[rng_pptr++] ^= a >> 16 & 255; rng_pool[rng_pptr++] ^= a >> 24 & 255; rng_pptr >= rng_psize && (rng_pptr -= rng_psize) } function rng_seed_time() { rng_seed_int((new date).gettime()) } if (null == rng_pool) { rng_pool = []; rng_pptr = 0; var t; if ("netscape" == navigator.appname && "5" > navigator.appversion && window.crypto) { var z = window.crypto.random(32); for (t = 0; t < z.length; ++t) rng_pool[rng_pptr++] = z.charcodeat(t) & 255 } for (; rng_pptr < rng_psize;) t = math.floor(65536 * math.random()), rng_pool[rng_pptr++] = t >>> 8, rng_pool[rng_pptr++] = t & 255; rng_pptr = 0; rng_seed_time() } function rng_get_byte() { if (null == rng_state) { rng_seed_time(); rng_state = prng_newstate(); rng_state.init(rng_pool); for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0; rng_pptr = 0 } return rng_state.next() } function rng_get_bytes(a) { var b; for (b = 0; b < a.length; ++b) a[b] = rng_get_byte() } function securerandom() { } securerandom.prototype.nextbytes = rng_get_bytes; var kjur = {}; // "undefined" != typeof kjur && kjur || (kjur = {}); "undefined" != typeof kjur.crypto && kjur.crypto || (kjur.crypto = {}); kjur.crypto.util = new function () { this.digestinfohead = { sha1: "3021300906052b0e03021a05000414", sha224: "302d300d06096086480165030402040500041c", sha256: "3031300d060960864801650304020105000420", sha384: "3041300d060960864801650304020205000430", sha512: "3051300d060960864801650304020305000440", md2: "3020300c06082a864886f70d020205000410", md5: "3020300c06082a864886f70d020505000410", ripemd160: "3021300906052b2403020105000414" }; this.defaultprovider = { md5: "cryptojs", sha1: "cryptojs", sha224: "cryptojs", sha256: "cryptojs", sha384: "cryptojs", sha512: "cryptojs", ripemd160: "cryptojs", hmacmd5: "cryptojs", hmacsha1: "cryptojs", hmacsha224: "cryptojs", hmacsha256: "cryptojs", hmacsha384: "cryptojs", hmacsha512: "cryptojs", hmacripemd160: "cryptojs", sm3: "cryptojs", md5withrsa: "cryptojs/jsrsa", sha1withrsa: "cryptojs/jsrsa", sha224withrsa: "cryptojs/jsrsa", sha256withrsa: "cryptojs/jsrsa", sha384withrsa: "cryptojs/jsrsa", sha512withrsa: "cryptojs/jsrsa", ripemd160withrsa: "cryptojs/jsrsa", md5withecdsa: "cryptojs/jsrsa", sha1withecdsa: "cryptojs/jsrsa", sha224withecdsa: "cryptojs/jsrsa", sha256withecdsa: "cryptojs/jsrsa", sha384withecdsa: "cryptojs/jsrsa", sha512withecdsa: "cryptojs/jsrsa", ripemd160withecdsa: "cryptojs/jsrsa", sha1withdsa: "cryptojs/jsrsa", sha224withdsa: "cryptojs/jsrsa", sha256withdsa: "cryptojs/jsrsa", md5withrsaandmgf1: "cryptojs/jsrsa", sha1withrsaandmgf1: "cryptojs/jsrsa", sha224withrsaandmgf1: "cryptojs/jsrsa", sha256withrsaandmgf1: "cryptojs/jsrsa", sha384withrsaandmgf1: "cryptojs/jsrsa", sha512withrsaandmgf1: "cryptojs/jsrsa", ripemd160withrsaandmgf1: "cryptojs/jsrsa" }; this.cryptojsmessagedigestname = { md5: "cryptojs.algo.md5", sha1: "cryptojs.algo.sha1", sha224: "cryptojs.algo.sha224", sha256: "cryptojs.algo.sha256", sha384: "cryptojs.algo.sha384", sha512: "cryptojs.algo.sha512", ripemd160: "cryptojs.algo.ripemd160", sm3: "cryptojs.algo.sm3" }; this.getdigestinfohex = function (a, b) { if ("undefined" == typeof this.digestinfohead[b]) throw "alg not supported in util.digestinfohead: " + b; return this.digestinfohead[b] + a } ; this.getpaddeddigestinfohex = function (a, b, c) { var d = this.getdigestinfohex(a, b); a = c / 4; if (d.length + 22 > a) throw "key is too short for sigalg: keylen=" + c + "," + b; b = "00" + d; c = ""; a = a - 4 - b.length; for (d = 0; d < a; d += 2) c += "ff"; return "0001" + c + b } ; this.hashstring = function (a, b) { return (new kjur.crypto.messagedigest({ alg: b })).digeststring(a) } ; this.hashhex = function (a, b) { return (new kjur.crypto.messagedigest({ alg: b })).digesthex(a) } ; this.sha1 = function (a) { return (new kjur.crypto.messagedigest({ alg: "sha1", prov: "cryptojs" })).digeststring(a) } ; this.sha256 = function (a) { return (new kjur.crypto.messagedigest({ alg: "sha256", prov: "cryptojs" })).digeststring(a) } ; this.sha256hex = function (a) { return (new kjur.crypto.messagedigest({ alg: "sha256", prov: "cryptojs" })).digesthex(a) } ; this.sha512 = function (a) { return (new kjur.crypto.messagedigest({ alg: "sha512", prov: "cryptojs" })).digeststring(a) } ; this.sha512hex = function (a) { return (new kjur.crypto.messagedigest({ alg: "sha512", prov: "cryptojs" })).digesthex(a) } ; this.md5 = function (a) { return (new kjur.crypto.messagedigest({ alg: "md5", prov: "cryptojs" })).digeststring(a) } ; this.ripemd160 = function (a) { return (new kjur.crypto.messagedigest({ alg: "ripemd160", prov: "cryptojs" })).digeststring(a) } ; this.getcryptojsmdbyname = function (a) { } } ; kjur.crypto.messagedigest = function (a) { this.setalgandprovider = function (a, c) { null != a && void 0 === c && (c = kjur.crypto.util.defaultprovider[a]); if (-1 != ":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:sm3:".indexof(a) && "cryptojs" == c) { try { this.md = eval(kjur.crypto.util.cryptojsmessagedigestname[a]).create() } catch (d) { throw "setalgandprovider hash alg set fail alg=" + a + "/" + d; } this.updatestring = function (a) { this.md.update(a) } ; this.updatehex = function (a) { a = cryptojs.enc.hex.parse(a); this.md.update(a) } ; this.digest = function () { return this.md.finalize().tostring(cryptojs.enc.hex) } ; this.digeststring = function (a) { this.updatestring(a); return this.digest() } ; this.digesthex = function (a) { this.updatehex(a); return this.digest() } } if (-1 != ":sha256:".indexof(a) && "sjcl" == c) { try { this.md = new sjcl.hash.sha256 } catch (d) { throw "setalgandprovider hash alg set fail alg=" + a + "/" + d; } this.updatestring = function (a) { this.md.update(a) } ; this.updatehex = function (a) { a = sjcl.codec.hex.tobits(a); this.md.update(a) } ; this.digest = function () { var a = this.md.finalize(); return sjcl.codec.hex.frombits(a) } ; this.digeststring = function (a) { this.updatestring(a); return this.digest() } ; this.digesthex = function (a) { this.updatehex(a); return this.digest() } } } ; this.updatestring = function (a) { throw "updatestring(str) not supported for this alg/prov: " + this.algname + "/" + this.provname; } ; this.updatehex = function (a) { throw "updatehex(hex) not supported for this alg/prov: " + this.algname + "/" + this.provname; } ; this.digest = function () { throw "digest() not supported for this alg/prov: " + this.algname + "/" + this.provname; } ; this.digeststring = function (a) { throw "digeststring(str) not supported for this alg/prov: " + this.algname + "/" + this.provname; } ; this.digesthex = function (a) { throw "digesthex(hex) not supported for this alg/prov: " + this.algname + "/" + this.provname; } ; void 0 !== a && void 0 !== a.alg && (this.algname = a.alg, void 0 === a.prov && (this.provname = kjur.crypto.util.defaultprovider[this.algname]), this.setalgandprovider(this.algname, this.provname)) } ; kjur.crypto.mac = function (a) { this.setalgandprovider = function (a, c) { null == a && (a = "hmacsha1"); a = a.tolowercase(); if ("hmac" != a.substr(0, 4)) throw "setalgandprovider unsupported hmac alg: " + a; void 0 === c && (c = kjur.crypto.util.defaultprovider[a]); this.algprov = a + "/" + c; var d = a.substr(4); if (-1 != ":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexof(d) && "cryptojs" == c) { try { var e = eval(kjur.crypto.util.cryptojsmessagedigestname[d]); this.mac = cryptojs.algo.hmac.create(e, this.pass) } catch (f) { throw "setalgandprovider hash alg set fail hashalg=" + d + "/" + f; } this.updatestring = function (a) { this.mac.update(a) } ; this.updatehex = function (a) { a = cryptojs.enc.hex.parse(a); this.mac.update(a) } ; this.dofinal = function () { return this.mac.finalize().tostring(cryptojs.enc.hex) } ; this.dofinalstring = function (a) { this.updatestring(a); return this.dofinal() } ; this.dofinalhex = function (a) { this.updatehex(a); return this.dofinal() } } } ; this.updatestring = function (a) { throw "updatestring(str) not supported for this alg/prov: " + this.algprov; } ; this.updatehex = function (a) { throw "updatehex(hex) not supported for this alg/prov: " + this.algprov; } ; this.dofinal = function () { throw "digest() not supported for this alg/prov: " + this.algprov; } ; this.dofinalstring = function (a) { throw "digeststring(str) not supported for this alg/prov: " + this.algprov; } ; this.dofinalhex = function (a) { throw "digesthex(hex) not supported for this alg/prov: " + this.algprov; } ; void 0 !== a && (void 0 !== a.pass && (this.pass = a.pass), void 0 !== a.alg && (this.algname = a.alg, void 0 === a.prov && (this.provname = kjur.crypto.util.defaultprovider[this.algname]), this.setalgandprovider(this.algname, this.provname))) } ; kjur.crypto.signature = function (a) { var b = null; this._setalgnames = function () { this.algname.match(/^(.+)with(.+)$/) && (this.mdalgname = regexp.$1.tolowercase(), this.pubkeyalgname = regexp.$2.tolowercase()) } ; this._zeropaddingofsignature = function (a, b) { for (var e = "", f = b / 4 - a.length, g = 0; g < f; g++) e += "0"; return e + a } ; this.setalgandprovider = function (a, b) { this._setalgnames(); if ("cryptojs/jsrsa" != b) throw "provider not supported: " + b; if (-1 != ":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:sm3:".indexof(this.mdalgname)) { try { this.md = new kjur.crypto.messagedigest({ alg: this.mdalgname }) } catch (e) { throw "setalgandprovider hash alg set fail alg=" + this.mdalgname + "/" + e; } this.init = function (a, c) { var b = null; try { b = void 0 === c ? keyutil.getkey(a) : keyutil.getkey(a, c) } catch (d) { throw "init failed:" + d; } if (!0 === b.isprivate) this.prvkey = b, this.state = "sign"; else if (!0 === b.ispublic) this.pubkey = b, this.state = "verify"; else throw "init failed.:" + b; } ; this.initsign = function (a) { "string" == typeof a.ecprvhex && "string" == typeof a.eccurvename ? (this.ecprvhex = a.ecprvhex, this.eccurvename = a.eccurvename) : this.prvkey = a; this.state = "sign" } ; this.initverifybypublickey = function (a) { "string" == typeof a.ecpubhex && "string" == typeof a.eccurvename ? (this.ecpubhex = a.ecpubhex, this.eccurvename = a.eccurvename) : a instanceof kjur.crypto.ecdsa ? this.pubkey = a : a instanceof rsakey && (this.pubkey = a); this.state = "verify" } ; this.initverifybycertificatepem = function (a) { var c = new x509; c.readcertpem(a); this.pubkey = c.subjectpublickeyrsa; this.state = "verify" } ; this.updatestring = function (a) { this.md.updatestring(a) } ; this.updatehex = function (a) { this.md.updatehex(a) } ; this.sign = function () { "sm2" != this.eccurvename && (this.shashhex = this.md.digest()); if ("undefined" != typeof this.ecprvhex && "undefined" != typeof this.eccurvename) { if ("sm2" == this.eccurvename) { var a = new kjur.crypto.sm3withsm2({ curve: this.eccurvename }) , c = a.ecparams.g , b = c.multiply(new biginteger(this.ecprvhex, 16)) , d = b.getx().tobiginteger().toradix(16) + b.gety().tobiginteger().toradix(16) , b = new sm3digest , c = (new sm3digest).getz(c, d) , c = b.getwords(b.gethex(c).tostring()) , d = cryptojs.enc.utf8.stringify(this.md.md._data) , d = cryptojs.enc.utf8.parse(d).tostring() , d = b.getwords(d) , k = array(b.getdigestsize()); b.blockupdate(c, 0, c.length); b.blockupdate(d, 0, d.length); b.dofinal(k, 0); this.shashhex = b.gethex(k).tostring() } else a = new kjur.crypto.ecdsa({ curve: this.eccurvename }); this.hsign = a.signhex(this.shashhex, this.ecprvhex) } else if ("rsaandmgf1" == this.pubkeyalgname) this.hsign = this.prvkey.signwithmessagehashpss(this.shashhex, this.mdalgname, this.psssaltlen); else if ("rsa" == this.pubkeyalgname) this.hsign = this.prvkey.signwithmessagehash(this.shashhex, this.mdalgname); else if (this.prvkey instanceof kjur.crypto.ecdsa) this.hsign = this.prvkey.signwithmessagehash(this.shashhex); else if (this.prvkey instanceof kjur.crypto.dsa) this.hsign = this.prvkey.signwithmessagehash(this.shashhex); else throw "signature: unsupported public key alg: " + this.pubkeyalgname; return this.hsign } ; this.signstring = function (a) { this.updatestring(a); this.sign() } ; this.signhex = function (a) { this.updatehex(a); this.sign() } ; this.verify = function (a) { "sm2" != this.eccurvename && (this.shashhex = this.md.digest()); if ("undefined" != typeof this.ecpubhex && "undefined" != typeof this.eccurvename) { if ("sm2" == this.eccurvename) { var c = new kjur.crypto.sm3withsm2({ curve: this.eccurvename }) , b = c.ecparams.g , d = this.ecpubhex.substr(2, 128) , k = new sm3digest , b = (new sm3digest).getz(b, d) , b = k.getwords(k.gethex(b).tostring()) , d = cryptojs.enc.utf8.stringify(this.md.md._data) , d = cryptojs.enc.utf8.parse(d).tostring() , d = k.getwords(d) , l = array(k.getdigestsize()); k.blockupdate(b, 0, b.length); k.blockupdate(d, 0, d.length); k.dofinal(l, 0); this.shashhex = k.gethex(l).tostring() } else c = new kjur.crypto.ecdsa({ curve: this.eccurvename }); return c.verifyhex(this.shashhex, a, this.ecpubhex) } if ("rsaandmgf1" == this.pubkeyalgname) return this.pubkey.verifywithmessagehashpss(this.shashhex, a, this.mdalgname, this.psssaltlen); if ("rsa" == this.pubkeyalgname || this.pubkey instanceof kjur.crypto.ecdsa || this.pubkey instanceof kjur.crypto.dsa) return this.pubkey.verifywithmessagehash(this.shashhex, a); throw "signature: unsupported public key alg: " + this.pubkeyalgname; } } } ; this.init = function (a, b) { throw "init(key, pass) not supported for this alg:prov=" + this.algprovname; } ; this.initverifybypublickey = function (a) { throw "initverifybypublickey(rsapubkeyy) not supported for this alg:prov=" + this.algprovname; } ; this.initverifybycertificatepem = function (a) { throw "initverifybycertificatepem(certpem) not supported for this alg:prov=" + this.algprovname; } ; this.initsign = function (a) { throw "initsign(prvkey) not supported for this alg:prov=" + this.algprovname; } ; this.updatestring = function (a) { throw "updatestring(str) not supported for this alg:prov=" + this.algprovname; } ; this.updatehex = function (a) { throw "updatehex(hex) not supported for this alg:prov=" + this.algprovname; } ; this.sign = function () { throw "sign() not supported for this alg:prov=" + this.algprovname; } ; this.signstring = function (a) { throw "digeststring(str) not supported for this alg:prov=" + this.algprovname; } ; this.signhex = function (a) { throw "digesthex(hex) not supported for this alg:prov=" + this.algprovname; } ; this.verify = function (a) { throw "verify(hsigval) not supported for this alg:prov=" + this.algprovname; } ; this.initparams = a; if (void 0 !== a && (void 0 !== a.alg && (this.algname = a.alg, this.provname = void 0 === a.prov ? kjur.crypto.util.defaultprovider[this.algname] : a.prov, this.algprovname = this.algname + ":" + this.provname, this.setalgandprovider(this.algname, this.provname), this._setalgnames()), void 0 !== a.psssaltlen && (this.psssaltlen = a.psssaltlen), void 0 !== a.prvkeypem)) { if (void 0 !== a.prvkeypas) throw "both prvkeypem and prvkeypas parameters not supported"; try { b = new rsakey, b.readprivatekeyfrompemstring(a.prvkeypem), this.initsign(b) } catch (c) { throw "fatal error to load pem private key: " + c; } } } ; kjur.crypto.oid = new function () { this.oidhex2name = { "2a864886f70d010101": "rsaencryption", "2a8648ce3d0201": "ecpublickey", "2a8648ce380401": "dsa", "2a8648ce3d030107": "secp256r1", "2b8104001f": "secp192k1", "2b81040021": "secp224r1", "2b8104000a": "secp256k1", "2b81040023": "secp521r1", "2b81040022": "secp384r1", "2a8648ce380403": "sha1withdsa", "608648016503040301": "sha224withdsa", "608648016503040302": "sha256withdsa" } } ; function ecfieldelementfp(a, b) { this.x = b; this.q = a } function fefpequals(a) { return a == this ? !0 : this.q.equals(a.q) && this.x.equals(a.x) } function fefptobiginteger() { return this.x } function fefpnegate() { return new ecfieldelementfp(this.q, this.x.negate().mod(this.q)) } function fefpadd(a) { return new ecfieldelementfp(this.q, this.x.add(a.tobiginteger()).mod(this.q)) } function fefpsubtract(a) { return new ecfieldelementfp(this.q, this.x.subtract(a.tobiginteger()).mod(this.q)) } function fefpmultiply(a) { return new ecfieldelementfp(this.q, this.x.multiply(a.tobiginteger()).mod(this.q)) } function fefpsquare() { return new ecfieldelementfp(this.q, this.x.square().mod(this.q)) } function fefpdivide(a) { return new ecfieldelementfp(this.q, this.x.multiply(a.tobiginteger().modinverse(this.q)).mod(this.q)) } ecfieldelementfp.prototype.equals = fefpequals; ecfieldelementfp.prototype.tobiginteger = fefptobiginteger; ecfieldelementfp.prototype.negate = fefpnegate; ecfieldelementfp.prototype.add = fefpadd; ecfieldelementfp.prototype.subtract = fefpsubtract; ecfieldelementfp.prototype.multiply = fefpmultiply; ecfieldelementfp.prototype.square = fefpsquare; ecfieldelementfp.prototype.divide = fefpdivide; function ecpointfp(a, b, c, d) { this.curve = a; this.x = b; this.y = c; this.z = null == d ? biginteger.one : d; this.zinv = null } function pointfpgetx() { null == this.zinv && (this.zinv = this.z.modinverse(this.curve.q)); return this.curve.frombiginteger(this.x.tobiginteger().multiply(this.zinv).mod(this.curve.q)) } function pointfpgety() { null == this.zinv && (this.zinv = this.z.modinverse(this.curve.q)); return this.curve.frombiginteger(this.y.tobiginteger().multiply(this.zinv).mod(this.curve.q)) } function pointfpequals(a) { return a == this ? !0 : this.isinfinity() ? a.isinfinity() : a.isinfinity() ? this.isinfinity() : a.y.tobiginteger().multiply(this.z).subtract(this.y.tobiginteger().multiply(a.z)).mod(this.curve.q).equals(biginteger.zero) ? a.x.tobiginteger().multiply(this.z).subtract(this.x.tobiginteger().multiply(a.z)).mod(this.curve.q).equals(biginteger.zero) : !1 } function pointfpisinfinity() { return null == this.x && null == this.y ? !0 : this.z.equals(biginteger.zero) && !this.y.tobiginteger().equals(biginteger.zero) } function pointfpnegate() { return new ecpointfp(this.curve, this.x, this.y.negate(), this.z) } function pointfpadd(a) { if (this.isinfinity()) return a; if (a.isinfinity()) return this; var b = a.y.tobiginteger().multiply(this.z).subtract(this.y.tobiginteger().multiply(a.z)).mod(this.curve.q) , c = a.x.tobiginteger().multiply(this.z).subtract(this.x.tobiginteger().multiply(a.z)).mod(this.curve.q); if (biginteger.zero.equals(c)) return biginteger.zero.equals(b) ? this.twice() : this.curve.getinfinity(); var d = new biginteger("3") , e = this.x.tobiginteger() , f = this.y.tobiginteger(); a.x.tobiginteger(); a.y.tobiginteger(); var g = c.square() , h = g.multiply(c) , e = e.multiply(g) , g = b.square().multiply(this.z) , c = g.subtract(e.shiftleft(1)).multiply(a.z).subtract(h).multiply(c).mod(this.curve.q) , b = e.multiply(d).multiply(b).subtract(f.multiply(h)).subtract(g.multiply(b)).multiply(a.z).add(b.multiply(h)).mod(this.curve.q); a = h.multiply(this.z).multiply(a.z).mod(this.curve.q); return new ecpointfp(this.curve, this.curve.frombiginteger(c), this.curve.frombiginteger(b), a) } function pointfptwice() { if (this.isinfinity()) return this; if (0 == this.y.tobiginteger().signum()) return this.curve.getinfinity(); var a = new biginteger("3") , b = this.x.tobiginteger() , c = this.y.tobiginteger() , d = c.multiply(this.z) , e = d.multiply(c).mod(this.curve.q) , c = this.curve.a.tobiginteger() , f = b.square().multiply(a); biginteger.zero.equals(c) || (f = f.add(this.z.square().multiply(c))); f = f.mod(this.curve.q); c = f.square().subtract(b.shiftleft(3).multiply(e)).shiftleft(1).multiply(d).mod(this.curve.q); a = f.multiply(a).multiply(b).subtract(e.shiftleft(1)).shiftleft(2).multiply(e).subtract(f.square().multiply(f)).mod(this.curve.q); d = d.square().multiply(d).shiftleft(3).mod(this.curve.q); return new ecpointfp(this.curve, this.curve.frombiginteger(c), this.curve.frombiginteger(a), d) } function pointfpmultiply(a) { if (this.isinfinity()) return this; if (0 == a.signum()) return this.curve.getinfinity(); var b = a.multiply(new biginteger("3")), c = this.negate(), d = this, e; for (e = b.bitlength() - 2; 0 < e; --e) { var d = d.twice() , f = b.testbit(e) , g = a.testbit(e); f != g && (d = d.add(f ? this : c)) } return d } function pointfpmultiplytwo(a, b, c) { var d; d = a.bitlength() > c.bitlength() ? a.bitlength() - 1 : c.bitlength() - 1; for (var e = this.curve.getinfinity(), f = this.add(b); 0 <= d;) e = e.twice(), a.testbit(d) ? e = c.testbit(d) ? e.add(f) : e.add(this) : c.testbit(d) && (e = e.add(b)), --d; return e } ecpointfp.prototype.getx = pointfpgetx; ecpointfp.prototype.gety = pointfpgety; ecpointfp.prototype.equals = pointfpequals; ecpointfp.prototype.isinfinity = pointfpisinfinity; ecpointfp.prototype.negate = pointfpnegate; ecpointfp.prototype.add = pointfpadd; ecpointfp.prototype.twice = pointfptwice; ecpointfp.prototype.multiply = pointfpmultiply; ecpointfp.prototype.multiplytwo = pointfpmultiplytwo; function eccurvefp(a, b, c) { this.q = a; this.a = this.frombiginteger(b); this.b = this.frombiginteger(c); this.infinity = new ecpointfp(this, null, null) } function curvefpgetq() { return this.q } function curvefpgeta() { return this.a } function curvefpgetb() { return this.b } function curvefpequals(a) { return a == this ? !0 : this.q.equals(a.q) && this.a.equals(a.a) && this.b.equals(a.b) } function curvefpgetinfinity() { return this.infinity } function curvefpfrombiginteger(a) { return new ecfieldelementfp(this.q, a) } function curvefpdecodepointhex(a) { switch (parseint(a.substr(0, 2), 16)) { case 0: return this.infinity; case 2: case 3: return null; case 4: case 6: case 7: var b = (a.length - 2) / 2 , c = a.substr(2, b); a = a.substr(b + 2, b); return new ecpointfp(this, this.frombiginteger(new biginteger(c, 16)), this.frombiginteger(new biginteger(a, 16))); default: return null } } eccurvefp.prototype.getq = curvefpgetq; eccurvefp.prototype.geta = curvefpgeta; eccurvefp.prototype.getb = curvefpgetb; eccurvefp.prototype.equals = curvefpequals; eccurvefp.prototype.getinfinity = curvefpgetinfinity; eccurvefp.prototype.frombiginteger = curvefpfrombiginteger; eccurvefp.prototype.decodepointhex = curvefpdecodepointhex; ecfieldelementfp.prototype.getbytelength = function () { return math.floor((this.tobiginteger().bitlength() + 7) / 8) } ; ecpointfp.prototype.getencoded = function (a) { var b = function (a, c) { var b = a.tobytearrayunsigned(); if (c < b.length) b = b.slice(b.length - c); else for (; c > b.length;) b.unshift(0); return b } , c = this.getx().tobiginteger() , d = this.gety().tobiginteger() , c = b(c, 32); a ? d.iseven() ? c.unshift(2) : c.unshift(3) : (c.unshift(4), c = c.concat(b(d, 32))); return c } ; ecpointfp.decodefrom = function (a, b) { var c = b.length - 1 , d = b.slice(1, 1 + c / 2) , c = b.slice(1 + c / 2, 1 + c); d.unshift(0); c.unshift(0); d = new biginteger(d); c = new biginteger(c); return new ecpointfp(a, a.frombiginteger(d), a.frombiginteger(c)) } ; ecpointfp.decodefromhex = function (a, b) { b.substr(0, 2); var c = b.length - 2 , d = b.substr(2, c / 2) , c = b.substr(2 + c / 2, c / 2) , d = new biginteger(d, 16) , c = new biginteger(c, 16); return new ecpointfp(a, a.frombiginteger(d), a.frombiginteger(c)) } ; ecpointfp.prototype.add2d = function (a) { if (this.isinfinity()) return a; if (a.isinfinity()) return this; if (this.x.equals(a.x)) return this.y.equals(a.y) ? this.twice() : this.curve.getinfinity(); var b = a.x.subtract(this.x) , b = a.y.subtract(this.y).divide(b); a = b.square().subtract(this.x).subtract(a.x); b = b.multiply(this.x.subtract(a)).subtract(this.y); return new ecpointfp(this.curve, a, b) } ; ecpointfp.prototype.twice2d = function () { if (this.isinfinity()) return this; if (0 == this.y.tobiginteger().signum()) return this.curve.getinfinity(); var a = this.curve.frombiginteger(biginteger.valueof(2)) , b = this.curve.frombiginteger(biginteger.valueof(3)) , b = this.x.square().multiply(b).add(this.curve.a).divide(this.y.multiply(a)) , a = b.square().subtract(this.x.multiply(a)) , b = b.multiply(this.x.subtract(a)).subtract(this.y); return new ecpointfp(this.curve, a, b) } ; ecpointfp.prototype.multiply2d = function (a) { if (this.isinfinity()) return this; if (0 == a.signum()) return this.curve.getinfinity(); var b = a.multiply(new biginteger("3")), c = this.negate(), d = this, e; for (e = b.bitlength() - 2; 0 < e; --e) { var d = d.twice() , f = b.testbit(e) , g = a.testbit(e); f != g && (d = d.add2d(f ? this : c)) } return d } ; ecpointfp.prototype.isoncurve = function () { var a = this.getx().tobiginteger() , b = this.gety().tobiginteger() , c = this.curve.geta().tobiginteger() , d = this.curve.getb().tobiginteger() , e = this.curve.getq() , b = b.multiply(b).mod(e) , a = a.multiply(a).multiply(a).add(c.multiply(a)).add(d).mod(e); return b.equals(a) } ; ecpointfp.prototype.tostring = function () { return "(" + this.getx().tobiginteger().tostring() + "," + this.gety().tobiginteger().tostring() + ")" } ; ecpointfp.prototype.validate = function () { var a = this.curve.getq(); if (this.isinfinity()) throw error("point is at infinity."); var b = this.getx().tobiginteger() , c = this.gety().tobiginteger(); if (0 > b.compareto(biginteger.one) || 0 < b.compareto(a.subtract(biginteger.one))) throw error("x coordinate out of bounds"); if (0 > c.compareto(biginteger.one) || 0 < c.compareto(a.subtract(biginteger.one))) throw error("y coordinate out of bounds"); if (!this.isoncurve()) throw error("point is not on the curve."); if (this.multiply(a).isinfinity()) throw error("point is not a scalar multiple of g."); return !0 } ; "undefined" != typeof kjur && kjur || (kjur = {}); "undefined" != typeof kjur.crypto && kjur.crypto || (kjur.crypto = {}); kjur.crypto.ecdsa = function (a) { var b = new securerandom; this.type = "ec"; this.getbigrandom = function (a) { return (new biginteger(a.bitlength(), b)).mod(a.subtract(biginteger.one)).add(biginteger.one) } ; this.setnamedcurve = function (a) { this.ecparams = kjur.crypto.ecparameterdb.getbyname(a); this.pubkeyhex = this.prvkeyhex = null; this.curvename = a } ; this.setprivatekeyhex = function (a) { this.isprivate = !0; this.prvkeyhex = a } ; this.setpublickeyhex = function (a) { this.ispublic = !0; this.pubkeyhex = a } ; this.generatekeypairhex = function () { var a = this.getbigrandom(this.ecparams.n) , b = this.ecparams.g.multiply(a) , e = b.getx().tobiginteger() , b = b.gety().tobiginteger() , f = this.ecparams.keylen / 4 , a = ("0000000000" + a.tostring(16)).slice(-f) , e = ("0000000000" + e.tostring(16)).slice(-f) , b = ("0000000000" + b.tostring(16)).slice(-f) , e = "04" + e + b; this.setprivatekeyhex(a); this.setpublickeyhex(e); return { ecprvhex: a, ecpubhex: e } } ; this.signwithmessagehash = function (a) { return this.signhex(a, this.prvkeyhex) } ; this.signhex = function (a, b) { var e = new biginteger(b, 16) , f = this.ecparams.n , g = new biginteger(a, 16); do var h = this.getbigrandom(f) , k = this.ecparams.g.multiply(h).getx().tobiginteger().mod(f); while (0 >= k.compareto(biginteger.zero)); e = h.modinverse(f).multiply(g.add(e.multiply(k))).mod(f); return kjur.crypto.ecdsa.birssigtoasn1sig(k, e) } ; this.sign = function (a, b) { var e = this.ecparams.n , f = biginteger.frombytearrayunsigned(a); do var g = this.getbigrandom(e) , h = this.ecparams.g.multiply(g).getx().tobiginteger().mod(e); while (0 >= h.compareto(biginteger.zero)); e = g.modinverse(e).multiply(f.add(b.multiply(h))).mod(e); return this.serializesig(h, e) } ; this.verifywithmessagehash = function (a, b) { return this.verifyhex(a, b, this.pubkeyhex) } ; this.verifyhex = function (a, b, e) { var f; f = kjur.crypto.ecdsa.parsesighex(b); b = f.r; f = f.s; e = ecpointfp.decodefromhex(this.ecparams.curve, e); a = new biginteger(a, 16); return this.verifyraw(a, b, f, e) } ; this.verify = function (a, b, e) { var f; if (bitcoin.util.isarray(b)) b = this.parsesig(b), f = b.r, b = b.s; else if ("object" === typeof b && b.r && b.s) f = b.r, b = b.s; else throw "invalid value for signature"; if (!(e instanceof ecpointfp)) if (bitcoin.util.isarray(e)) e = ecpointfp.decodefrom(this.ecparams.curve, e); else throw "invalid format for pubkey value, must be byte array or ecpointfp"; a = biginteger.frombytearrayunsigned(a); return this.verifyraw(a, f, b, e) } ; this.verifyraw = function (a, b, e, f) { var g = this.ecparams.n , h = this.ecparams.g; if (0 > b.compareto(biginteger.one) || 0 <= b.compareto(g) || 0 > e.compareto(biginteger.one) || 0 <= e.compareto(g)) return !1; e = e.modinverse(g); a = a.multiply(e).mod(g); e = b.multiply(e).mod(g); return h.multiply(a).add(f.multiply(e)).getx().tobiginteger().mod(g).equals(b) } ; this.serializesig = function (a, b) { var e = a.tobytearraysigned() , f = b.tobytearraysigned() , g = []; g.push(2); g.push(e.length); g = g.concat(e); g.push(2); g.push(f.length); g = g.concat(f); g.unshift(g.length); g.unshift(48); return g } ; this.parsesig = function (a) { var b; if (48 != a[0]) throw error("signature not a valid dersequence"); b = 2; if (2 != a[b]) throw error("first element in signature must be a derinteger"); var e = a.slice(b + 2, b + 2 + a[b + 1]); b += 2 + a[b + 1]; if (2 != a[b]) throw error("second element in signature must be a derinteger"); a = a.slice(b + 2, b + 2 + a[b + 1]); e = biginteger.frombytearrayunsigned(e); a = biginteger.frombytearrayunsigned(a); return { r: e, s: a } } ; this.parsesigcompact = function (a) { if (65 !== a.length) throw "signature has the wrong length"; var b = a[0] - 27; if (0 > b || 7 < b) throw "invalid signature type"; var e = this.ecparams.n , f = biginteger.frombytearrayunsigned(a.slice(1, 33)).mod(e); a = biginteger.frombytearrayunsigned(a.slice(33, 65)).mod(e); return { r: f, s: a, i: b } } ; void 0 !== a && void 0 !== a.curve && (this.curvename = a.curve); void 0 === this.curvename && (this.curvename = "secp256r1"); this.setnamedcurve(this.curvename); void 0 !== a && (void 0 !== a.prv && this.setprivatekeyhex(a.prv), void 0 !== a.pub && this.setpublickeyhex(a.pub)) } ; kjur.crypto.ecdsa.parsesighex = function (a) { var b = kjur.crypto.ecdsa.parsesighexinhexrs(a); a = new biginteger(b.r, 16); b = new biginteger(b.s, 16); return { r: a, s: b } } ; kjur.crypto.ecdsa.parsesighexinhexrs = function (a) { if ("30" != a.substr(0, 2)) throw "signature is not a asn.1 sequence"; var b = asn1hex.getposarrayofchildren_atobj(a, 0); if (2 != b.length) throw "number of signature asn.1 sequence elements seem wrong"; var c = b[0] , b = b[1]; if ("02" != a.substr(c, 2)) throw "1st item of sequene of signature is not asn.1 integer"; if ("02" != a.substr(b, 2)) throw "2nd item of sequene of signature is not asn.1 integer"; c = asn1hex.gethexofv_atobj(a, c); a = asn1hex.gethexofv_atobj(a, b); return { r: c, s: a } } ; kjur.crypto.ecdsa.asn1sigtoconcatsig = function (a) { var b = kjur.crypto.ecdsa.parsesighexinhexrs(a); a = b.r; b = b.s; "00" == a.substr(0, 2) && 8 == a.length / 2 * 8 % 128 && (a = a.substr(2)); "00" == b.substr(0, 2) && 8 == b.length / 2 * 8 % 128 && (b = b.substr(2)); if (0 != a.length / 2 * 8 % 128) throw "unknown ecdsa sig r length error"; if (0 != b.length / 2 * 8 % 128) throw "unknown ecdsa sig s length error"; return a + b } ; kjur.crypto.ecdsa.concatsigtoasn1sig = function (a) { if (0 != a.length / 2 * 8 % 128) throw "unknown ecdsa concatinated r-s sig length error"; var b = a.substr(0, a.length / 2); a = a.substr(a.length / 2); return kjur.crypto.ecdsa.hexrssigtoasn1sig(b, a) } ; kjur.crypto.ecdsa.hexrssigtoasn1sig = function (a, b) { var c = new biginteger(a, 16) , d = new biginteger(b, 16); return kjur.crypto.ecdsa.birssigtoasn1sig(c, d) } ; kjur.crypto.ecdsa.birssigtoasn1sig = function (a, b) { var c = new kjur.asn1.derinteger({ bigint: a }) , d = new kjur.asn1.derinteger({ bigint: b }); return (new kjur.asn1.dersequence({ array: [c, d] })).getencodedhex() } ; (function () { var a = cryptojs , b = a.lib , c = b.wordarray , d = b.hasher , e = [] , b = a.algo.sm3 = d.extend({ _doreset: function () { this._hash = new c.init([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]) }, _doprocessblock: function (a, b) { for (var c = this._hash.words, d = c[0], l = c[1], p = c[2], n = c[3], q = c[4], m = 0; 80 > m; m++) { if (16 > m) e[m] = a[b + m] | 0; else { var r = e[m - 3] ^ e[m - 8] ^ e[m - 14] ^ e[m - 16]; e[m] = r << 1 | r >>> 31 } r = (d << 5 | d >>> 27) + q + e[m]; r = 20 > m ? r + ((l & p | ~l & n) + 1518500249) : 40 > m ? r + ((l ^ p ^ n) + 1859775393) : 60 > m ? r + ((l & p | l & n | p & n) - 1894007588) : r + ((l ^ p ^ n) - 899497514); q = n; n = p; p = l << 30 | l >>> 2; l = d; d = r } c[0] = c[0] + d | 0; c[1] = c[1] + l | 0; c[2] = c[2] + p | 0; c[3] = c[3] + n | 0; c[4] = c[4] + q | 0 }, _dofinalize: function () { var a = this._data , b = a.words , c = 8 * this._ndatabytes , d = 8 * a.sigbytes; b[d >>> 5] |= 128 << 24 - d % 32; b[(d + 64 >>> 9 << 4) + 14] = math.floor(c / 4294967296); b[(d + 64 >>> 9 << 4) + 15] = c; a.sigbytes = 4 * b.length; this._process(); return this._hash }, clone: function () { var a = d.clone.call(this); a._hash = this._hash.clone(); return a } }); a.sm3 = d._createhelper(b); a.hmacsm3 = d._createhmachelper(b) })(); function sm3digest() { this.byte_length = 64; this.xbuf = []; this.bytecount = this.xbufoff = 0; this.digest_length = 32; this.v0 = [1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]; this.v0 = [1937774191, 1226093241, 388252375, -628488704, -1452330820, 372324522, -477237683, -1325724082]; this.v = array(8); this.v_ = array(8); this.x0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; this.x = array(68); this.xoff = 0; this.t_00_15 = 2043430169; this.t_16_63 = 2055708042; 0 < arguments.length ? this.initdigest(arguments[0]) : this.init() } sm3digest.prototype = { init: function () { this.xbuf = array(4); this.reset() }, initdigest: function (a) { this.xbuf = array(a.xbuf.length); array.copy(a.xbuf, 0, this.xbuf, 0, a.xbuf.length); this.xbufoff = a.xbufoff; this.bytecount = a.bytecount; array.copy(a.x, 0, this.x, 0, a.x.length); this.xoff = a.xoff; array.copy(a.v, 0, this.v, 0, a.v.length) }, getdigestsize: function () { return this.digest_length }, reset: function () { this.xbufoff = this.bytecount = 0; array.clear(this.xbuf, 0, this.xbuf.length); array.copy(this.v0, 0, this.v, 0, this.v0.length); this.xoff = 0; array.copy(this.x0, 0, this.x, 0, this.x0.length) }, getbytelength: function () { return this.byte_length }, processblock: function () { var a, b = this.x, c = array(64); for (a = 16; 68 > a; a++) b[a] = this.p1(b[a - 16] ^ b[a - 9] ^ this.rotate(b[a - 3], 15)) ^ this.rotate(b[a - 13], 7) ^ b[a - 6]; for (a = 0; 64 > a; a++) c[a] = b[a] ^ b[a + 4]; var d = this.v , e = this.v_; array.copy(d, 0, e, 0, this.v0.length); var f, g; for (a = 0; 16 > a; a++) g = this.rotate(e[0], 12), f = int32.parse(int32.parse(g + e[4]) + this.rotate(this.t_00_15, a)), f = this.rotate(f, 7), g ^= f, g = int32.parse(int32.parse(this.ff_00_15(e[0], e[1], e[2]) + e[3]) + g) + c[a], f = int32.parse(int32.parse(this.gg_00_15(e[4], e[5], e[6]) + e[7]) + f) + b[a], e[3] = e[2], e[2] = this.rotate(e[1], 9), e[1] = e[0], e[0] = g, e[7] = e[6], e[6] = this.rotate(e[5], 19), e[5] = e[4], e[4] = this.p0(f); for (a = 16; 64 > a; a++) g = this.rotate(e[0], 12), f = int32.parse(int32.parse(g + e[4]) + this.rotate(this.t_16_63, a)), f = this.rotate(f, 7), g ^= f, g = int32.parse(int32.parse(this.ff_16_63(e[0], e[1], e[2]) + e[3]) + g) + c[a], f = int32.parse(int32.parse(this.gg_16_63(e[4], e[5], e[6]) + e[7]) + f) + b[a], e[3] = e[2], e[2] = this.rotate(e[1], 9), e[1] = e[0], e[0] = g, e[7] = e[6], e[6] = this.rotate(e[5], 19), e[5] = e[4], e[4] = this.p0(f); for (a = 0; 8 > a; a++) d[a] ^= int32.parse(e[a]); this.xoff = 0; array.copy(this.x0, 0, this.x, 0, this.x0.length) }, processword: function (a, b) { var c = a[b] << 24 , c = c | (a[++b] & 255) << 16 , c = c | (a[++b] & 255) << 8 , c = c | a[++b] & 255; this.x[this.xoff] = c; 16 == ++this.xoff && this.processblock() }, processlength: function (a) { 14 < this.xoff && this.processblock(); this.x[14] = this.urshiftlong(a, 32); this.x[15] = a & 4294967295 }, inttobigendian: function (a, b, c) { b[c] = int32.parsebyte(this.urshift(a, 24)); b[++c] = int32.parsebyte(this.urshift(a, 16)); b[++c] = int32.parsebyte(this.urshift(a, 8)); b[++c] = int32.parsebyte(a) }, dofinal: function (a, b) { this.finish(); for (var c = 0; 8 > c; c++) this.inttobigendian(this.v[c], a, b + 4 * c); this.reset(); for (var d = a.length, c = 0; c < d; c++) a[c] &= 255; return this.digest_length }, update: function (a) { this.xbuf[this.xbufoff++] = a; this.xbufoff == this.xbuf.length && (this.processword(this.xbuf, 0), this.xbufoff = 0); this.bytecount++ }, blockupdate: function (a, b, c) { for (; 0 != this.xbufoff && 0 < c;) this.update(a[b]), b++ , c--; for (; c > this.xbuf.length;) this.processword(a, b), b += this.xbuf.length, c -= this.xbuf.length, this.bytecount += this.xbuf.length; for (; 0 < c;) this.update(a[b]), b++ , c-- }, finish: function () { var a = this.bytecount << 3; for (this.update(128); 0 != this.xbufoff;) this.update(0); this.processlength(a); this.processblock() }, rotate: function (a, b) { return a << b | this.urshift(a, 32 - b) }, p0: function (a) { return a ^ this.rotate(a, 9) ^ this.rotate(a, 17) }, p1: function (a) { return a ^ this.rotate(a, 15) ^ this.rotate(a, 23) }, ff_00_15: function (a, b, c) { return a ^ b ^ c }, ff_16_63: function (a, b, c) { return a & b | a & c | b & c }, gg_00_15: function (a, b, c) { return a ^ b ^ c }, gg_16_63: function (a, b, c) { return a & b | ~a & c }, urshift: function (a, b) { if (a > int32.maxvalue || a < int32.minvalue) a = int32.parse(a); return 0 <= a ? a >> b : (a >> b) + (2 << ~b) }, urshiftlong: function (a, b) { var c; c = new biginteger; c.fromint(a); if (0 <= c.signum()) c = c.shiftright(b).intvalue(); else { var d = new biginteger; d.fromint(2); var e = ~b; c = ""; if (0 > e) { d = 64 + e; for (e = 0; e < d; e++) c += "0"; d = new biginteger; d.fromint(a >> b); c = new biginteger("10" + c, 2); c.toradix(10); c = c.add(d).toradix(10) } else c = d.shiftleft(~b).intvalue(), c = (a >> b) + c } return c }, getz: function (a, b) { var c = cryptojs.enc.utf8.parse("1234567812345678") , d = 32 * c.words.length; this.update(d >> 8 & 255); this.update(d & 255); c = this.getwords(c.tostring()); this.blockupdate(c, 0, c.length); var c = this.getwords(a.curve.a.tobiginteger().toradix(16)) , d = this.getwords(a.curve.b.tobiginteger().toradix(16)) , e = this.getwords(a.getx().tobiginteger().toradix(16)) , f = this.getwords(a.gety().tobiginteger().toradix(16)) , g = this.getwords(b.substr(0, 64)) , h = this.getwords(b.substr(64, 64)); this.blockupdate(c, 0, c.length); this.blockupdate(d, 0, d.length); this.blockupdate(e, 0, e.length); this.blockupdate(f, 0, f.length); this.blockupdate(g, 0, g.length); this.blockupdate(h, 0, h.length); c = array(this.getdigestsize()); this.dofinal(c, 0); return c }, getwords: function (a) { for (var b = [], c = a.length, d = 0; d < c; d += 2) b[b.length] = parseint(a.substr(d, 2), 16); return b }, gethex: function (a) { for (var b = [], c = 0, d = 0; d < 2 * a.length; d += 2) b[d >>> 3] |= parseint(a[c]) << 24 - d % 8 * 4, c++; return new cryptojs.lib.wordarray.init(b, a.length) } }; array.clear = function (a, b, c) { for (var elm in a) a[elm] = null }; array.copy = function (a, b, c, d, e) { a = a.slice(b, b + e); for (b = 0; b < a.length; b++) c[d] = a[b], d++ }; var int32 = {// zdk minvalue: -parseint("10000000000000000000000000000000", 2), maxvalue: 2147483647, parse: function (a) { if (a < this.minvalue) { a = new number(-a); a = a.tostring(2); a = a.substr(a.length - 31, 31); for (var b = "", c = 0; c < a.length; c++) var d = a.substr(c, 1) , b = b + ("0" == d ? "1" : "0"); a = parseint(b, 2); return a + 1 } if (a > this.maxvalue) { a = number(a); a = a.tostring(2); a = a.substr(a.length - 31, 31); b = ""; for (c = 0; c < a.length; c++) d = a.substr(c, 1), b += "0" == d ? "1" : "0"; a = parseint(b, 2); return -(a + 1) } return a }, parsebyte: function (a) { if (0 > a) { a = new number(-a); a = a.tostring(2); a = a.substr(a.length - 8, 8); for (var b = "", c = 0; c < a.length; c++) var d = a.substr(c, 1) , b = b + ("0" == d ? "1" : "0"); return parseint(b, 2) + 1 } return 255 < a ? (a = number(a), a = a.tostring(2), parseint(a.substr(a.length - 8, 8), 2)) : a } }; "undefined" != typeof kjur && kjur || (kjur = {}); "undefined" != typeof kjur.crypto && kjur.crypto || (kjur.crypto = {}); kjur.crypto.sm3withsm2 = function (a) { var b = new securerandom; this.type = "sm2"; this.getbigrandom = function (a) { return (new biginteger(a.bitlength(), b)).mod(a.subtract(biginteger.one)).add(biginteger.one) } ; this.setnamedcurve = function (a) { this.ecparams = kjur.crypto.ecparameterdb.getbyname(a); this.pubkeyhex = this.prvkeyhex = null; this.curvename = a } ; this.setprivatekeyhex = function (a) { this.isprivate = !0; this.prvkeyhex = a } ; this.setpublickeyhex = function (a) { this.ispublic = !0; this.pubkeyhex = a } ; this.generatekeypairhex = function () { var a = this.getbigrandom(this.ecparams.n) , b = this.ecparams.g.multiply(a) , e = b.getx().tobiginteger() , b = b.gety().tobiginteger() , f = this.ecparams.keylen / 4 , a = ("0000000000" + a.tostring(16)).slice(-f) , e = ("0000000000" + e.tostring(16)).slice(-f) , b = ("0000000000" + b.tostring(16)).slice(-f) , e = "04" + e + b; this.setprivatekeyhex(a); this.setpublickeyhex(e); return { ecprvhex: a, ecpubhex: e } } ; this.signwithmessagehash = function (a) { return this.signhex(a, this.prvkeyhex) } ; this.signhex = function (a, b) { var e = new biginteger(b, 16) , f = this.ecparams.n , g = new biginteger(a, 16) , h = null , k = null , l = k = null; do { do k = this.generatekeypairhex(), h = new biginteger(k.ecprvhex, 16), k = ecpointfp.decodefromhex(this.ecparams.curve, k.ecpubhex), k = g.add(k.getx().tobiginteger()), k = k.mod(f); while (k.equals(biginteger.zero) || k.add(h).equals(f)); var p = e.add(biginteger.one) , p = p.modinverse(f) , l = k.multiply(e) , l = h.subtract(l).mod(f) , l = p.multiply(l).mod(f) } while (l.equals(biginteger.zero)); return kjur.crypto.ecdsa.birssigtoasn1sig(k, l) } ; this.sign = function (a, b) { var e = this.ecparams.n , f = biginteger.frombytearrayunsigned(a); do var g = this.getbigrandom(e) , h = this.ecparams.g.multiply(g).getx().tobiginteger().mod(e); while (0 >= h.compareto(biginteger.zero)); e = g.modinverse(e).multiply(f.add(b.multiply(h))).mod(e); return this.serializesig(h, e) } ; this.verifywithmessagehash = function (a, b) { return this.verifyhex(a, b, this.pubkeyhex) } ; this.verifyhex = function (a, b, e) { var f; f = kjur.crypto.ecdsa.parsesighex(b); b = f.r; f = f.s; e = ecpointfp.decodefromhex(this.ecparams.curve, e); a = new biginteger(a, 16); return this.verifyraw(a, b, f, e) } ; this.verify = function (a, b, e) { var f; if (bitcoin.util.isarray(b)) b = this.parsesig(b), f = b.r, b = b.s; else if ("object" === typeof b && b.r && b.s) f = b.r, b = b.s; else throw "invalid value for signature"; if (!(e instanceof ecpointfp)) if (bitcoin.util.isarray(e)) e = ecpointfp.decodefrom(this.ecparams.curve, e); else throw "invalid format for pubkey value, must be byte array or ecpointfp"; a = biginteger.frombytearrayunsigned(a); return this.verifyraw(a, f, b, e) } ; this.verifyraw = function (a, b, e, f) { var g = this.ecparams.n , h = this.ecparams.g , k = b.add(e).mod(g); if (k.equals(biginteger.zero)) return !1; e = h.multiply(e); e = e.add(f.multiply(k)); a = a.add(e.getx().tobiginteger()).mod(g); return b.equals(a) } ; this.serializesig = function (a, b) { var e = a.tobytearraysigned() , f = b.tobytearraysigned() , g = []; g.push(2); g.push(e.length); g = g.concat(e); g.push(2); g.push(f.length); g = g.concat(f); g.unshift(g.length); g.unshift(48); return g } ; this.parsesig = function (a) { var b; if (48 != a[0]) throw error("signature not a valid dersequence"); b = 2; if (2 != a[b]) throw error("first element in signature must be a derinteger"); var e = a.slice(b + 2, b + 2 + a[b + 1]); b += 2 + a[b + 1]; if (2 != a[b]) throw error("second element in signature must be a derinteger"); a = a.slice(b + 2, b + 2 + a[b + 1]); e = biginteger.frombytearrayunsigned(e); a = biginteger.frombytearrayunsigned(a); return { r: e, s: a } } ; this.parsesigcompact = function (a) { if (65 !== a.length) throw "signature has the wrong length"; var b = a[0] - 27; if (0 > b || 7 < b) throw "invalid signature type"; var e = this.ecparams.n , f = biginteger.frombytearrayunsigned(a.slice(1, 33)).mod(e); a = biginteger.frombytearrayunsigned(a.slice(33, 65)).mod(e); return { r: f, s: a, i: b } } ; void 0 !== a && void 0 !== a.curve && (this.curvename = a.curve); void 0 === this.curvename && (this.curvename = "sm2"); this.setnamedcurve(this.curvename); void 0 !== a && (void 0 !== a.prv && this.setprivatekeyhex(a.prv), void 0 !== a.pub && this.setpublickeyhex(a.pub)) } ; "undefined" != typeof kjur && kjur || (kjur = {}); "undefined" != typeof kjur.crypto && kjur.crypto || (kjur.crypto = {}); kjur.crypto.ecparameterdb = new function () { var a = {} , b = {}; this.getbyname = function (c) { var d = c; "undefined" != typeof b[d] && (d = b[c]); if ("undefined" != typeof a[d]) return a[d]; throw "unregistered ec curve name: " + d; } ; this.regist = function (c, d, e, f, g, h, k, l, p, n, q, m) { a[c] = {}; e = new biginteger(e, 16); f = new biginteger(f, 16); g = new biginteger(g, 16); h = new biginteger(h, 16); k = new biginteger(k, 16); e = new eccurvefp(e, f, g); l = e.decodepointhex("04" + l + p); a[c].name = c; a[c].keylen = d; a[c].curve = e; a[c].g = l; a[c].n = h; a[c].h = k; a[c].oid = q; a[c].info = m; for (d = 0; d < n.length; d++) b[n[d]] = c } } ; kjur.crypto.ecparameterdb.regist("secp128r1", 128, "fffffffdffffffffffffffffffffffff", "fffffffdfffffffffffffffffffffffc", "e87579c11079f43dd824993c2cee5ed3", "fffffffe0000000075a30d1b9038a115", "1", "161ff7528b899b2d0c28607ca52c5b86", "cf5ac8395bafeb13c02da292dded7a83", [], "", "secp128r1 : secg curve over a 128 bit prime field"); kjur.crypto.ecparameterdb.regist("secp160k1", 160, "fffffffffffffffffffffffffffffffeffffac73", "0", "7", "0100000000000000000001b8fa16dfab9aca16b6b3", "1", "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", "938cf935318fdced6bc28286531733c3f03c4fee", [], "", "secp160k1 : secg curve over a 160 bit prime field"); kjur.crypto.ecparameterdb.regist("secp160r1", 160, "ffffffffffffffffffffffffffffffff7fffffff", "ffffffffffffffffffffffffffffffff7ffffffc", "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", "0100000000000000000001f4c8f927aed3ca752257", "1", "4a96b5688ef573284664698968c38bb913cbfc82", "23a628553168947d59dcc912042351377ac5fb32", [], "", "secp160r1 : secg curve over a 160 bit prime field"); kjur.crypto.ecparameterdb.regist("secp192k1", 192, "fffffffffffffffffffffffffffffffffffffffeffffee37", "0", "3", "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", "1", "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d", []); kjur.crypto.ecparameterdb.regist("secp192r1", 192, "fffffffffffffffffffffffffffffffeffffffffffffffff", "fffffffffffffffffffffffffffffffefffffffffffffffc", "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", "ffffffffffffffffffffffff99def836146bc9b1b4d22831", "1", "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", "07192b95ffc8da78631011ed6b24cdd573f977a11e794811", []); kjur.crypto.ecparameterdb.regist("secp224r1", 224, "ffffffffffffffffffffffffffffffff000000000000000000000001", "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe", "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4", "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d", "1", "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21", "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", []); kjur.crypto.ecparameterdb.regist("secp256k1", 256, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", "0", "7", "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", "1", "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", []); kjur.crypto.ecparameterdb.regist("secp256r1", 256, "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", "1", "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5", ["nist p-256", "p-256", "prime256v1"]); kjur.crypto.ecparameterdb.regist("secp384r1", 384, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc", "b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef", "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973", "1", "aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7", "3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f", ["nist p-384", "p-384"]); kjur.crypto.ecparameterdb.regist("secp521r1", 521, "1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc", "051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", "1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409", "1", "c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66", "011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", ["nist p-521", "p-521"]); kjur.crypto.ecparameterdb.regist("sm2", 256, "fffffffeffffffffffffffffffffffffffffffff00000000ffffffffffffffff", "fffffffeffffffffffffffffffffffffffffffff00000000fffffffffffffffc", "28e9fa9e9d9f5e344d5a9e4bcf6509a7f39789f515ab8f92ddbcbd414d940e93", "fffffffeffffffffffffffffffffffff7203df6b21c6052b53bbf40939d54123", "1", "32c4ae2c1f1981195f9904466a39c9948fe30bbff2660be1715a4589334c74c7", "bc3736a2f4f6779c59bdcee36b692153d0a9877cc62a474002df32e52139f0a0", ["sm2", "sm2"]); function sm2cipher(a) { this.ct = 1; this.sm3c3 = this.sm3keybase = this.p2 = null; this.key = array(32); this.keyoff = 0; this.ciphermode = "undefined" != typeof a ? a : sm2ciphermode.c1c3c2 } sm2cipher.prototype = { reset: function () { this.sm3keybase = new sm3digest; this.sm3c3 = new sm3digest; for (var a = this.p2.getx().tobiginteger().toradix(16); 64 > a.length;) a = "0" + a; for (var a = this.getwords(a), b = this.p2.gety().tobiginteger().toradix(16); 64 > b.length;) b = "0" + b; b = this.getwords(b); this.sm3keybase.blockupdate(a, 0, a.length); this.sm3c3.blockupdate(a, 0, a.length); this.sm3keybase.blockupdate(b, 0, b.length); this.ct = 1; this.nextkey() }, nextkey: function () { var a = new sm3digest(this.sm3keybase); a.update(this.ct >> 24 & 255); a.update(this.ct >> 16 & 255); a.update(this.ct >> 8 & 255); a.update(this.ct & 255); a.dofinal(this.key, 0); this.keyoff = 0; this.ct++ }, kdf: function (a) { var b = array(a) , c = new sm3digest , d = array(32) , e = 1 , f = a / 32; a %= 32; for (var g = this.p2.getx().tobiginteger().toradix(16); 64 > g.length;) g = "0" + g; for (var g = this.getwords(g), h = this.p2.gety().tobiginteger().toradix(16); 64 > h.length;) h = "0" + h; for (var h = this.getwords(h), k = 0, l = 0; l < f; l++) c.blockupdate(g, 0, g.length), c.blockupdate(h, 0, h.length), c.update(e >> 24 & 255), c.update(e >> 16 & 255), c.update(e >> 8 & 255), c.update(e & 255), c.dofinal(b, k), k += 32, e++; 0 != a && (c.blockupdate(g, 0, g.length), c.blockupdate(h, 0, h.length), c.update(e >> 24 & 255), c.update(e >> 16 & 255), c.update(e >> 8 & 255), c.update(e & 255), c.dofinal(d, 0)); array.copy(d, 0, b, k, a); for (l = 0; l < b.length; l++) b[l] &= 255; return b }, initencipher: function (a) { var b = null , c = null , c = new kjur.crypto.ecdsa({ curve: "sm2" }) , d = c.generatekeypairhex() , b = new biginteger(d.ecprvhex, 16) , c = ecpointfp.decodefromhex(c.ecparams.curve, d.ecpubhex); this.p2 = a.multiply(b); this.reset(); return c }, encryptblock: function (a) { this.sm3c3.blockupdate(a, 0, a.length); for (var b = this.kdf(a.length), c = 0; c < a.length; c++) a[c] ^= b[c] }, initdecipher: function (a, b) { this.p2 = b.multiply(a); this.p2.getx().tobiginteger().toradix(16); this.p2.gety().tobiginteger().toradix(16); this.reset() }, decryptblock: function (a) { for (var b = this.kdf(a.length), c = 0, d = "", c = 0; c < b.length; c++) d += b[c].tostring(16); for (c = 0; c < a.length; c++) a[c] ^= b[c]; this.sm3c3.blockupdate(a, 0, a.length) }, dofinal: function (a) { for (var b = this.p2.gety().tobiginteger().toradix(16); 64 > b.length;) b = "0" + b; b = this.getwords(b); this.sm3c3.blockupdate(b, 0, b.length); this.sm3c3.dofinal(a, 0); this.reset() }, encrypt: function (a, b) { var c = array(b.length); array.copy(b, 0, c, 0, b.length); var d = this.initencipher(a); this.encryptblock(c); var e = array(32); this.dofinal(e); for (var f = d.getx().tobiginteger().toradix(16), d = d.gety().tobiginteger().toradix(16); 64 > f.length;) f = "0" + f; for (; 64 > d.length;) d = "0" + d; f += d; c = this.gethex(c).tostring(); 0 != c.length % 2 && (c = "0" + c); e = this.gethex(e).tostring(); d = f + c + e; this.ciphermode == sm2ciphermode.c1c3c2 && (d = f + e + c); return d }, getwords: function (a) { for (var b = [], c = a.length, d = 0; d < c; d += 2) b[b.length] = parseint(a.substr(d, 2), 16); return b }, gethex: function (a) { for (var b = [], c = 0, d = 0; d < 2 * a.length; d += 2) b[d >>> 3] |= parseint(a[c]) << 24 - d % 8 * 4, c++; return new cryptojs.lib.wordarray.init(b, a.length) }, decrypt: function (a, b) { var c = b.substr(0, 64) , d = b.substr(0 + c.length, 64) , e = b.substr(c.length + d.length, b.length - c.length - d.length - 64) , f = b.substr(b.length - 64); this.ciphermode == sm2ciphermode.c1c3c2 && (f = b.substr(c.length + d.length, 64), e = b.substr(c.length + d.length + 64)); e = this.getwords(e); c = this.createpoint(c, d); this.initdecipher(a, c); this.decryptblock(e); c = array(32); this.dofinal(c); return this.gethex(c).tostring() == f ? (f = this.gethex(e), cryptojs.enc.utf8.stringify(f)) : "" }, createpoint: function (a, b) { var c = new kjur.crypto.ecdsa({ curve: "sm2" }); return ecpointfp.decodefromhex(c.ecparams.curve, "04" + a + b) } }; /*-------------下面修改----------*/ var sm2key = function (key) { this.setkey(key); }; function sm2setkey(key) { if (key && typeof key === 'object') { this.eccx = key.eccx; this.eccy = key.eccy; } else { this.eccx = "f1342adb38855e1f8c37d1181378de446e52788389f7db3dea022a1fc4d4d856"; this.eccy = "66fc6de253c822f1e52914d9e0b80c5d825759ce696cf039a8449f98017510b7"; } } /* * 加密数据 */ function sm2encrypt(text) { var ciphermode = sm2ciphermode.c1c3c2, cipher = new sm2cipher(ciphermode), textdata = cryptojs.enc.utf8.parse(text); var cipher = new sm2cipher(ciphermode); var userkey = cipher.createpoint(this.eccx, this.eccy); var msgdata = cipher.getwords(textdata.tostring()); return cipher.encrypt(userkey, msgdata); } sm2key.prototype.setkey = sm2setkey; sm2key.prototype.encrypt = sm2encrypt; // export default sm2key; // global.sm2 = { // sm2ciphermode:sm2ciphermode, // sm2cipher:sm2cipher, // cryptojs:cryptojs // } var c = cryptojs; var c_lib = c.lib; var wordarray = c_lib.wordarray; var hasher = c_lib.hasher; var c_algo = c.algo; var w = [ ]; var sm3 = c_algo.sm3 = hasher.extend({ _doreset: function () { this._hash = new wordarray.init([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]) }, _doprocessblock: function (m, offset) { var h = this._hash.words; var a = h[0]; var b = h[1]; var c = h[2]; var d = h[3]; var e = h[4]; for (var i = 0; i < 80; i++) { if (i < 16) { w[i] = m[offset + i] | 0 } else { var n = w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]; w[i] = (n << 1) | (n >>> 31) } var t = ((a << 5) | (a >>> 27)) + e + w[i]; if (i < 20) { t += ((b & c) | (~b & d)) + 1518500249 } else if (i < 40) { t += (b ^ c ^ d) + 1859775393 } else if (i < 60) { t += ((b & c) | (b & d) | (c & d)) - 1894007588 } else { t += (b ^ c ^ d) - 899497514 } e = d; d = c; c = (b << 30) | (b >>> 2); b = a; a = t } h[0] = (h[0] + a) | 0; h[1] = (h[1] + b) | 0; h[2] = (h[2] + c) | 0; h[3] = (h[3] + d) | 0; h[4] = (h[4] + e) | 0 }, _dofinalize: function () { var data = this._data; var datawords = data.words; var nbitstotal = this._ndatabytes * 8; var nbitsleft = data.sigbytes * 8; datawords[nbitsleft >>> 5] |= 128 << (24 - nbitsleft % 32); datawords[(((nbitsleft + 64) >>> 9) << 4) + 14] = math.floor(nbitstotal / 4294967296); datawords[(((nbitsleft + 64) >>> 9) << 4) + 15] = nbitstotal; data.sigbytes = datawords.length * 4; this._process(); return this._hash }, clone: function () { var clone = hasher.clone.call(this); clone._hash = this._hash.clone(); return clone } }); c.sm3 = hasher._createhelper(sm3); c.hmacsm3 = hasher._createhmachelper(sm3) function sm3digest() { this.byte_length = 64; this.xbuf = new array(); this.xbufoff = 0; this.bytecount = 0; this.digest_length = 32; this.v0 = [ 1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214 ]; this.v0 = [ 1937774191, 1226093241, 388252375, - 628488704, - 1452330820, 372324522, - 477237683, - 1325724082 ]; this.v = new array(8); this.v_ = new array(8); this.x0 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; this.x = new array(68); this.xoff = 0; this.t_00_15 = 2043430169; this.t_16_63 = 2055708042; if (arguments.length > 0) { this.initdigest(arguments[0]) } else { this.init() } } sm3digest.prototype = { init: function () { this.xbuf = new array(4); this.reset() }, initdigest: function (t) { this.xbuf = new array(t.xbuf.length); array.copy(t.xbuf, 0, this.xbuf, 0, t.xbuf.length); this.xbufoff = t.xbufoff; this.bytecount = t.bytecount; array.copy(t.x, 0, this.x, 0, t.x.length); this.xoff = t.xoff; array.copy(t.v, 0, this.v, 0, t.v.length) }, getdigestsize: function () { return this.digest_length }, reset: function () { this.bytecount = 0; this.xbufoff = 0; array.clear(this.xbuf, 0, this.xbuf.length); array.copy(this.v0, 0, this.v, 0, this.v0.length); this.xoff = 0; array.copy(this.x0, 0, this.x, 0, this.x0.length) }, getbytelength: function () { return this.byte_length }, processblock: function () { var i; var ww = this.x; var ww_ = new array(64); for (i = 16; i < 68; i++) { ww[i] = this.p1(ww[i - 16] ^ ww[i - 9] ^ (this.rotate(ww[i - 3], 15))) ^ (this.rotate(ww[i - 13], 7)) ^ ww[i - 6] } for (i = 0; i < 64; i++) { ww_[i] = ww[i] ^ ww[i + 4] } var vv = this.v; var vv_ = this.v_; array.copy(vv, 0, vv_, 0, this.v0.length); var ss1, ss2, tt1, tt2, aaa; for (i = 0; i < 16; i++) { aaa = this.rotate(vv_[0], 12); ss1 = int32.parse(int32.parse(aaa + vv_[4]) + this.rotate(this.t_00_15, i)); ss1 = this.rotate(ss1, 7); ss2 = ss1 ^ aaa; tt1 = int32.parse(int32.parse(this.ff_00_15(vv_[0], vv_[1], vv_[2]) + vv_[3]) + ss2) + ww_[i]; tt2 = int32.parse(int32.parse(this.gg_00_15(vv_[4], vv_[5], vv_[6]) + vv_[7]) + ss1) + ww[i]; vv_[3] = vv_[2]; vv_[2] = this.rotate(vv_[1], 9); vv_[1] = vv_[0]; vv_[0] = tt1; vv_[7] = vv_[6]; vv_[6] = this.rotate(vv_[5], 19); vv_[5] = vv_[4]; vv_[4] = this.p0(tt2) } for (i = 16; i < 64; i++) { aaa = this.rotate(vv_[0], 12); ss1 = int32.parse(int32.parse(aaa + vv_[4]) + this.rotate(this.t_16_63, i)); ss1 = this.rotate(ss1, 7); ss2 = ss1 ^ aaa; tt1 = int32.parse(int32.parse(this.ff_16_63(vv_[0], vv_[1], vv_[2]) + vv_[3]) + ss2) + ww_[i]; tt2 = int32.parse(int32.parse(this.gg_16_63(vv_[4], vv_[5], vv_[6]) + vv_[7]) + ss1) + ww[i]; vv_[3] = vv_[2]; vv_[2] = this.rotate(vv_[1], 9); vv_[1] = vv_[0]; vv_[0] = tt1; vv_[7] = vv_[6]; vv_[6] = this.rotate(vv_[5], 19); vv_[5] = vv_[4]; vv_[4] = this.p0(tt2) } for (i = 0; i < 8; i++) { vv[i] ^= int32.parse(vv_[i]) } this.xoff = 0; array.copy(this.x0, 0, this.x, 0, this.x0.length) }, processword: function (in_renamed, inoff) { var n = in_renamed[inoff] << 24; n |= (in_renamed[++inoff] & 255) << 16; n |= (in_renamed[++inoff] & 255) << 8; n |= (in_renamed[++inoff] & 255); this.x[this.xoff] = n; if (++this.xoff == 16) { this.processblock() } }, processlength: function (bitlength) { if (this.xoff > 14) { this.processblock() } this.x[14] = (this.urshiftlong(bitlength, 32)); this.x[15] = (bitlength & (4294967295)) }, inttobigendian: function (n, bs, off) { bs[off] = int32.parsebyte(this.urshift(n, 24)); bs[++off] = int32.parsebyte(this.urshift(n, 16)); bs[++off] = int32.parsebyte(this.urshift(n, 8)); bs[++off] = int32.parsebyte(n) }, dofinal: function (out_renamed, outoff) { this.finish(); for (var i = 0; i < 8; i++) { this.inttobigendian(this.v[i], out_renamed, outoff + i * 4) } this.reset(); return this.digest_length }, update: function (input) { this.xbuf[this.xbufoff++] = input; if (this.xbufoff == this.xbuf.length) { this.processword(this.xbuf, 0); this.xbufoff = 0 } this.bytecount++ }, blockupdate: function (input, inoff, length) { while ((this.xbufoff != 0) && (length > 0)) { this.update(input[inoff]); inoff++; length-- } while (length > this.xbuf.length) { this.processword(input, inoff); inoff += this.xbuf.length; length -= this.xbuf.length; this.bytecount += this.xbuf.length } while (length > 0) { this.update(input[inoff]); inoff++; length-- } }, finish: function () { var bitlength = (this.bytecount << 3); this.update((128)); while (this.xbufoff != 0) this.update((0)); this.processlength(bitlength); this.processblock() }, rotate: function (x, n) { return (x << n) | (this.urshift(x, (32 - n))) }, p0: function (x) { return ((x) ^ this.rotate((x), 9) ^ this.rotate((x), 17)) }, p1: function (x) { return ((x) ^ this.rotate((x), 15) ^ this.rotate((x), 23)) }, ff_00_15: function (x, y, z) { return (x ^ y ^ z) }, ff_16_63: function (x, y, z) { return ((x & y) | (x & z) | (y & z)) }, gg_00_15: function (x, y, z) { return (x ^ y ^ z) }, gg_16_63: function (x, y, z) { return ((x & y) | (~x & z)) }, urshift: function (number, bits) { if (number > int32.maxvalue || number < int32.minvalue) { number = int32.parse(number) } if (number >= 0) { return number >> bits } else { return (number >> bits) + (2 << ~bits) } }, urshiftlong: function (number, bits) { var returnv; var big = new biginteger(); big.fromint(number); if (big.signum() >= 0) { returnv = big.shiftright(bits).intvalue() } else { var bigadd = new biginteger(); bigadd.fromint(2); var shiftleftbits = ~bits; var shiftleftnumber = ''; if (shiftleftbits < 0) { var shiftrightbits = 64 + shiftleftbits; for (var i = 0; i < shiftrightbits; i++) { shiftleftnumber += '0' } var shiftleftnumberbigadd = new biginteger(); shiftleftnumberbigadd.fromint(number >> bits); var shiftleftnumberbig = new biginteger('10' + shiftleftnumber, 2); shiftleftnumber = shiftleftnumberbig.toradix(10); var r = shiftleftnumberbig.add(shiftleftnumberbigadd); returnv = r.toradix(10) } else { shiftleftnumber = bigadd.shiftleft((~bits)).intvalue(); returnv = (number >> bits) + shiftleftnumber } } return returnv }, getz: function (g, pubkeyhex) { var userid = cryptojs.enc.utf8.parse('1234567812345678'); var len = userid.words.length * 4 * 8; this.update((len >> 8 & 255)); this.update((len & 255)); var useridwords = this.getwords(userid.tostring()); this.blockupdate(useridwords, 0, useridwords.length); var awords = this.getwords(g.curve.a.tobiginteger().toradix(16)); var bwords = this.getwords(g.curve.b.tobiginteger().toradix(16)); var gxwords = this.getwords(g.getx().tobiginteger().toradix(16)); var gywords = this.getwords(g.gety().tobiginteger().toradix(16)); var pxwords = this.getwords(pubkeyhex.substr(0, 64)); var pywords = this.getwords(pubkeyhex.substr(64, 64)); this.blockupdate(awords, 0, awords.length); this.blockupdate(bwords, 0, bwords.length); this.blockupdate(gxwords, 0, gxwords.length); this.blockupdate(gywords, 0, gywords.length); this.blockupdate(pxwords, 0, pxwords.length); this.blockupdate(pywords, 0, pywords.length); var md = new array(this.getdigestsize()); this.dofinal(md, 0); return md }, getwords: function (hexstr) { var words = [ ]; var hexstrlength = hexstr.length; for (var i = 0; i < hexstrlength; i += 2) { words[words.length] = parseint(hexstr.substr(i, 2), 16) } return words }, gethex: function (arr) { var words = [ ]; var j = 0; for (var i = 0; i < arr.length * 2; i += 2) { words[i >>> 3] |= parseint(arr[j]) << (24 - (i % 8) * 4); j++ } var wordarray = new cryptojs.lib.wordarray.init(words, arr.length); return wordarray } }; array.clear = function (destinationarray, destinationindex, length) { for (elm in destinationarray) { destinationarray[elm] = null } }; array.copy = function (sourcearray, sourceindex, destinationarray, destinationindex, length) { var clonearray = sourcearray.slice(sourceindex, sourceindex + length); for (var i = 0; i < clonearray.length; i++) { destinationarray[destinationindex] = clonearray[i]; destinationindex++ } }; window.int32 = { minvalue: - parseint('10000000000000000000000000000000', 2), maxvalue: parseint('1111111111111111111111111111111', 2), parse: function (n) { if (n < this.minvalue) { var biginteger = new number( - n); var bigintegerradix = biginteger.tostring(2); var subbigintegerradix = bigintegerradix.substr(bigintegerradix.length - 31, 31); var rebigintegerradix = ''; for (var i = 0; i < subbigintegerradix.length; i++) { var subbigintegerradixitem = subbigintegerradix.substr(i, 1); rebigintegerradix += subbigintegerradixitem == '0' ? '1' : '0' } var result = parseint(rebigintegerradix, 2); return (result + 1) } else if (n > this.maxvalue) { var biginteger = number(n); var bigintegerradix = biginteger.tostring(2); var subbigintegerradix = bigintegerradix.substr(bigintegerradix.length - 31, 31); var rebigintegerradix = ''; for (var i = 0; i < subbigintegerradix.length; i++) { var subbigintegerradixitem = subbigintegerradix.substr(i, 1); rebigintegerradix += subbigintegerradixitem == '0' ? '1' : '0' } var result = parseint(rebigintegerradix, 2); return - (result + 1) } else { return n } }, parsebyte: function (n) { if (n < 0) { var biginteger = new number( - n); var bigintegerradix = biginteger.tostring(2); var subbigintegerradix = bigintegerradix.substr(bigintegerradix.length - 8, 8); var rebigintegerradix = ''; for (var i = 0; i < subbigintegerradix.length; i++) { var subbigintegerradixitem = subbigintegerradix.substr(i, 1); rebigintegerradix += subbigintegerradixitem == '0' ? '1' : '0' } var result = parseint(rebigintegerradix, 2); return (result + 1) } else if (n > 255) { var biginteger = number(n); var bigintegerradix = biginteger.tostring(2); return parseint(bigintegerradix.substr(bigintegerradix.length - 8, 8), 2) } else { return n } } }; function smutil() { this.sm2encrypt = function(data, publickey){ var msgdata = cryptojs.enc.utf8.parse(data); var pubkeyhex = publickey; if (pubkeyhex.length > 64 * 2) { pubkeyhex = pubkeyhex.substr(pubkeyhex.length - 64 * 2); } var xhex = pubkeyhex.substr(0, 64); var yhex = pubkeyhex.substr(64); var cipher = new sm2cipher("0"); var userkey = cipher.createpoint(xhex, yhex); msgdata = cipher.getwords(msgdata.tostring()); var encryptdata = cipher.encrypt(userkey, msgdata); return '04' + encryptdata; } this.sm3encrypt = function(str){ var sm3 = new window.sm3digest(); str = new sm2cipher().getwords(cryptojs.enc.utf8.parse(str).tostring()); sm3.blockupdate(str,0,str.length); var md = new array(32); sm3.dofinal(md, 0); var words = [ ]; var j = 0; for (var i = 0; i < md.length * 2; i += 2) { words[i >>> 3] |= parseint(md[j]) << (24 - (i % 8) * 4); j++; } var encryptdata = new cryptojs.lib.wordarray.init(words, md.length).tostring(); return encryptdata; } this.sm2decrypt = function(privatekey,encrypted) { encrypted = encrypted.substr(2); // privatekey = b64tohex(privatekey); var privkey = new biginteger(privatekey, 16); var cipher = new sm2cipher("0"); var decryptdata = cipher.decrypt(privkey, encrypted); return decryptdata; } };