tt-uploader 1.2.0 → 1.2.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- !function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ImagexEncrypt=e():t.ImagexEncrypt=e()}("undefined"!=typeof self?self:this,()=>(()=>{var n={166:(p,d)=>{var y={userAgent:!1},t={},C=C||function(u){var t={},e=t.lib={},n=e.Base=function(){function n(){}return{extend:function(t){n.prototype=this;var e=new n;return t&&e.mixIn(t),e.hasOwnProperty("init")||(e.init=function(){e.$super.init.apply(this,arguments)}),(e.init.prototype=e).$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),c=e.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||i).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,i=t.sigBytes;if(this.clamp(),r%4)for(var s=0;s<i;s++){var a=n[s>>>2]>>>24-s%4*8&255;e[r+s>>>2]|=a<<24-(r+s)%4*8}else for(s=0;s<i;s+=4)e[r+s>>>2]=n[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=u.ceil(e/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(4294967296*u.random()|0);return new c.init(e,t)}}),r=t.enc={},i=r.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],i=0;i<n;i++){var s=e[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new c.init(n,e/2)}},s=r.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],i=0;i<n;i++){var s=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new c.init(n,e)}},a=r.Utf8={stringify:function(t){try{return decodeURIComponent(escape(s.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return s.parse(unescape(encodeURIComponent(t)))}},o=e.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=a.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,n=e.words,r=e.sigBytes,i=this.blockSize,s=r/(4*i),a=(s=t?u.ceil(s):u.max((0|s)-this._minBufferSize,0))*i,t=u.min(4*a,r);if(a){for(var o=0;o<a;o+=i)this._doProcessBlock(n,o);var h=n.splice(0,a);e.sigBytes-=t}return new c.init(h,t)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(e.Hasher=o.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){o.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(t,e){return new n.init(e).finalize(t)}},_createHmacHelper:function(n){return function(t,e){return new h.HMAC.init(n,e).finalize(t)}}}),t.algo={});return t}(Math),o=(!function(){var t=C,e=t.lib,i=e.Base,s=e.WordArray;(t=t.x64={}).Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r<e;r++){var i=t[r];n.push(i.high),n.push(i.low)}return s.create(n,this.sigBytes)},clone:function(){for(var t=i.clone.call(this),e=t.words=this.words.slice(0),n=e.length,r=0;r<n;r++)e[r]=e[r].clone();return t}})}(),C.lib.Cipher||function(){function bb(t,e,n){var r=this._iv;r?this._iv=void 0:r=this._prevBlock;for(var i=0;i<n;i++)t[e+i]^=r[i]}var t=(l=C).lib,e=t.Base,a=t.WordArray,n=t.BufferedBlockAlgorithm,r=l.enc.Base64,i=l.algo.EvpKDF,s=t.Cipher=n.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,n){this.cfg=this.cfg.extend(n),this._xformMode=t,this._key=e,this.reset()},reset:function(){n.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(r){return{encrypt:function(t,e,n){return("string"==typeof e?f:c).encrypt(r,t,e,n)},decrypt:function(t,e,n){return("string"==typeof e?f:c).decrypt(r,t,e,n)}}}}),o=(t.StreamCipher=s.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),l.mode={}),h=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend(),u=(h.Encryptor=h.extend({processBlock:function(t,e){var n=this._cipher,r=n.blockSize;bb.call(this,t,e,r),n.encryptBlock(t,e),this._prevBlock=t.slice(e,e+r)}}),h.Decryptor=h.extend({processBlock:function(t,e){var n=this._cipher,r=n.blockSize,i=t.slice(e,e+r);n.decryptBlock(t,e),bb.call(this,t,e,r),this._prevBlock=i}}),o=o.CBC=h,h=(l.pad={}).Pkcs7={pad:function(t,e){for(var n=4*e,r=(n=n-t.sigBytes%n)<<24|n<<16|n<<8|n,i=[],s=0;s<n;s+=4)i.push(r);n=a.create(i,n),t.concat(n)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:o,padding:h}),reset:function(){s.reset.call(this);var t,e=(n=this.cfg).iv,n=n.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode=t.call(n,this,e&&e.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),o=(l.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?a.create([1398893684,1701076831]).concat(t).concat(e):e).toString(r)},parse:function(t){var e,n=(t=r.parse(t)).words;return 1398893684==n[0]&&1701076831==n[1]&&(e=a.create(n.slice(2,4)),n.splice(0,4),t.sigBytes-=16),u.create({ciphertext:t,salt:e})}},c=t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var i=t.createEncryptor(n,r);return e=i.finalize(e),i=i.cfg,u.create({ciphertext:e,key:n,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),t.createDecryptor(n,r).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),l=(l.kdf={}).OpenSSL={execute:function(t,e,n,r){return r=r||a.random(8),t=i.create({keySize:e+n}).compute(t,r),n=a.create(t.words.slice(e),4*n),t.sigBytes=4*e,u.create({key:t,iv:n,salt:r})}},f=t.PasswordBasedCipher=c.extend({cfg:c.cfg.extend({kdf:l}),encrypt:function(t,e,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,t.keySize,t.ivSize),r.iv=n.iv,(t=c.encrypt.call(this,t,e,n.key,r)).mixIn(n),t},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),n=r.kdf.execute(n,t.keySize,t.ivSize,e.salt),r.iv=n.iv,c.decrypt.call(this,t,e,n.key,r)}})}(),!function(){for(var t=C,e=t.lib.BlockCipher,n=t.algo,a=[],r=[],i=[],s=[],o=[],h=[],u=[],c=[],l=[],f=[],g=[],p=0;p<256;p++)g[p]=p<128?p<<1:p<<1^283;for(var d=0,m=0,p=0;p<256;p++){var y=m^m<<1^m<<2^m<<3^m<<4,x=g[r[a[d]=y=y>>>8^255&y^99]=d],v=g[x],S=g[v],E=257*g[y]^16843008*y;i[d]=E<<24|E>>>8,s[d]=E<<16|E>>>16,o[d]=E<<8|E>>>24,h[d]=E,u[y]=(E=16843009*S^65537*v^257*x^16843008*d)<<24|E>>>8,c[y]=E<<16|E>>>16,l[y]=E<<8|E>>>24,f[y]=E,d?(d=x^g[g[g[S^x]]],m^=g[g[m]]):d=m=1}var b=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=e.extend({_doReset:function(){for(var t,e=(r=this._key).words,n=r.sigBytes/4,r=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],s=0;s<r;s++)s<n?i[s]=e[s]:(t=i[s-1],s%n?6<n&&4==s%n&&(t=a[t>>>24]<<24|a[t>>>16&255]<<16|a[t>>>8&255]<<8|a[255&t]):(t=a[(t=t<<8|t>>>24)>>>24]<<24|a[t>>>16&255]<<16|a[t>>>8&255]<<8|a[255&t],t^=b[s/n|0]<<24),i[s]=i[s-n]^t);for(e=this._invKeySchedule=[],n=0;n<r;n++)s=r-n,t=n%4?i[s]:i[s-4],e[n]=n<4||s<=4?t:u[a[t>>>24]]^c[a[t>>>16&255]]^l[a[t>>>8&255]]^f[a[255&t]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,i,s,o,h,a)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),n=t[e+1],t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,i,s,a,o){for(var h=this._nRounds,u=t[e]^n[0],c=t[e+1]^n[1],l=t[e+2]^n[2],f=t[e+3]^n[3],g=4,p=1;p<h;p++)var d=r[u>>>24]^i[c>>>16&255]^s[l>>>8&255]^a[255&f]^n[g++],m=r[c>>>24]^i[l>>>16&255]^s[f>>>8&255]^a[255&u]^n[g++],y=r[l>>>24]^i[f>>>16&255]^s[u>>>8&255]^a[255&c]^n[g++],f=r[f>>>24]^i[u>>>16&255]^s[c>>>8&255]^a[255&l]^n[g++],u=d,c=m,l=y;d=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^n[g++],m=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&u])^n[g++],y=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^n[g++],f=(o[f>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^n[g++],t[e]=d,t[e+1]=m,t[e+2]=y,t[e+3]=f},keySize:8});t.AES=e._createHelper(n)}(),!function(){function j(t,e){e=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=e,this._lBlock^=e<<t}function l(t,e){e=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=e,this._rBlock^=e<<t}var t=C,e=(n=t.lib).WordArray,n=n.BlockCipher,r=t.algo,a=[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],o=[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],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{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}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],i=r.DES=n.extend({_doReset:function(){for(var t=this._key.words,e=[],n=0;n<56;n++){var r=a[n]-1;e[n]=t[r>>>5]>>>31-r%32&1}for(t=this._subKeys=[],r=0;r<16;r++){for(var i=t[r]=[],s=h[r],n=0;n<24;n++)i[n/6|0]|=e[(o[n]-1+s)%28]<<31-n%6,i[4+(n/6|0)]|=e[28+(o[n+24]-1+s)%28]<<31-n%6;for(i[0]=i[0]<<1|i[0]>>>31,n=1;n<7;n++)i[n]>>>=4*(n-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],n=0;n<16;n++)e[n]=t[15-n]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,n){this._lBlock=t[e],this._rBlock=t[e+1],j.call(this,4,252645135),j.call(this,16,65535),l.call(this,2,858993459),l.call(this,8,16711935),j.call(this,1,1431655765);for(var r=0;r<16;r++){for(var i=n[r],s=this._lBlock,a=this._rBlock,o=0,h=0;h<8;h++)o|=u[h][((a^i[h])&c[h])>>>0];this._lBlock=a,this._rBlock=s^o}n=this._lBlock,this._lBlock=this._rBlock,this._rBlock=n,j.call(this,1,1431655765),l.call(this,8,16711935),l.call(this,2,858993459),j.call(this,16,65535),j.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});t.DES=n._createHelper(i),r=r.TripleDES=n.extend({_doReset:function(){var t=this._key.words;this._des1=i.createEncryptor(e.create(t.slice(0,2))),this._des2=i.createEncryptor(e.create(t.slice(2,4))),this._des3=i.createEncryptor(e.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),t.TripleDES=n._createHelper(r)}(),!function(){var t=C,h=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp(),t=[];for(var i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)t.push(r.charAt(s>>>6*(3-a)&63));if(e=r.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var e=t.length,n=this._map;(s=n.charAt(64))&&-1!=(s=t.indexOf(s))&&(e=s);for(var r,i,s=[],a=0,o=0;o<e;o++)o%4&&(r=n.indexOf(t.charAt(o-1))<<o%4*2,i=n.indexOf(t.charAt(o))>>>6-o%4*2,s[a>>>2]|=(r|i)<<24-a%4*8,a++);return h.create(s,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),!function(s){function h(t,e,n,r,i,s,a){return((t=t+(e&n|~e&r)+i+a)<<s|t>>>32-s)+e}function k(t,e,n,r,i,s,a){return((t=t+(e&r|n&~r)+i+a)<<s|t>>>32-s)+e}function l(t,e,n,r,i,s,a){return((t=t+(e^n^r)+i+a)<<s|t>>>32-s)+e}function n(t,e,n,r,i,s,a){return((t=t+(n^(e|~r))+i+a)<<s|t>>>32-s)+e}for(var t=C,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,I=[],a=0;a<64;a++)I[a]=4294967296*s.abs(s.sin(a+1))|0;i=i.MD5=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=t[s=e+r];t[s]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r=this._hash.words,s=t[e+0],i=t[e+1],a=t[e+2],o=t[e+3],u=t[e+4],c=t[e+5],f=t[e+6],g=t[e+7],p=t[e+8],d=t[e+9],m=t[e+10],y=t[e+11],x=t[e+12],v=t[e+13],S=t[e+14],E=t[e+15],b=h(r[0],A=r[1],w=r[2],F=r[3],s,7,I[0]),F=h(F,b,A,w,i,12,I[1]),w=h(w,F,b,A,a,17,I[2]),A=h(A,w,F,b,o,22,I[3]),b=h(b,A,w,F,u,7,I[4]),F=h(F,b,A,w,c,12,I[5]),w=h(w,F,b,A,f,17,I[6]),A=h(A,w,F,b,g,22,I[7]),b=h(b,A,w,F,p,7,I[8]),F=h(F,b,A,w,d,12,I[9]),w=h(w,F,b,A,m,17,I[10]),A=h(A,w,F,b,y,22,I[11]),b=h(b,A,w,F,x,7,I[12]),F=h(F,b,A,w,v,12,I[13]),w=h(w,F,b,A,S,17,I[14]),b=k(b,A=h(A,w,F,b,E,22,I[15]),w,F,i,5,I[16]),F=k(F,b,A,w,f,9,I[17]),w=k(w,F,b,A,y,14,I[18]),A=k(A,w,F,b,s,20,I[19]),b=k(b,A,w,F,c,5,I[20]),F=k(F,b,A,w,m,9,I[21]),w=k(w,F,b,A,E,14,I[22]),A=k(A,w,F,b,u,20,I[23]),b=k(b,A,w,F,d,5,I[24]),F=k(F,b,A,w,S,9,I[25]),w=k(w,F,b,A,o,14,I[26]),A=k(A,w,F,b,p,20,I[27]),b=k(b,A,w,F,v,5,I[28]),F=k(F,b,A,w,a,9,I[29]),w=k(w,F,b,A,g,14,I[30]),b=l(b,A=k(A,w,F,b,x,20,I[31]),w,F,c,4,I[32]),F=l(F,b,A,w,p,11,I[33]),w=l(w,F,b,A,y,16,I[34]),A=l(A,w,F,b,S,23,I[35]),b=l(b,A,w,F,i,4,I[36]),F=l(F,b,A,w,u,11,I[37]),w=l(w,F,b,A,g,16,I[38]),A=l(A,w,F,b,m,23,I[39]),b=l(b,A,w,F,v,4,I[40]),F=l(F,b,A,w,s,11,I[41]),w=l(w,F,b,A,o,16,I[42]),A=l(A,w,F,b,f,23,I[43]),b=l(b,A,w,F,d,4,I[44]),F=l(F,b,A,w,x,11,I[45]),w=l(w,F,b,A,E,16,I[46]),b=n(b,A=l(A,w,F,b,a,23,I[47]),w,F,s,6,I[48]),F=n(F,b,A,w,g,10,I[49]),w=n(w,F,b,A,S,15,I[50]),A=n(A,w,F,b,c,21,I[51]),b=n(b,A,w,F,x,6,I[52]),F=n(F,b,A,w,o,10,I[53]),w=n(w,F,b,A,m,15,I[54]),A=n(A,w,F,b,i,21,I[55]),b=n(b,A,w,F,p,6,I[56]),F=n(F,b,A,w,E,10,I[57]),w=n(w,F,b,A,f,15,I[58]),A=n(A,w,F,b,v,21,I[59]),b=n(b,A,w,F,u,6,I[60]),F=n(F,b,A,w,y,10,I[61]),w=n(w,F,b,A,a,15,I[62]),A=n(A,w,F,b,d,21,I[63]);r[0]=r[0]+b|0,r[1]=r[1]+A|0,r[2]=r[2]+w|0,r[3]=r[3]+F|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes,i=(e[r>>>5]|=128<<24-r%32,s.floor(n/4294967296));for(e[15+(64+r>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e[14+(64+r>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,n=0;n<4;n++)r=e[n],e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.MD5=r._createHelper(i),t.HmacMD5=r._createHmacHelper(i)}(Math),!function(){var t=C,e=(r=t.lib).WordArray,n=r.Hasher,c=[],r=t.algo.SHA1=n.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n,r=this._hash.words,i=r[0],s=r[1],a=r[2],o=r[3],h=r[4],u=0;u<80;u++)c[u]=u<16?0|t[e+u]:(n=c[u-3]^c[u-8]^c[u-14]^c[u-16])<<1|n>>>31,n=(i<<5|i>>>27)+h+c[u],n=u<20?n+(1518500249+(s&a|~s&o)):u<40?n+(1859775393+(s^a^o)):u<60?n+((s&a|s&o|a&o)-1894007588):n+((s^a^o)-899497514),h=o,o=a,a=s<<30|s>>>2,s=i,i=n;r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(64+r>>>9<<4)]=Math.floor(n/4294967296),e[15+(64+r>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=n._createHelper(r),t.HmacSHA1=n._createHmacHelper(r)}(),!function(i){function q3(t){return 4294967296*(t-(0|t))|0}for(var t=C,e=(r=t.lib).WordArray,n=r.Hasher,r=t.algo,s=[],p=[],a=2,o=0;o<64;){t:{for(var h=a,u=i.sqrt(h),c=2;c<=u;c++)if(!(h%c)){h=!1;break t}h=!0}h&&(o<8&&(s[o]=q3(i.pow(a,.5))),p[o]=q3(i.pow(a,1/3)),o++),a++}var d=[],r=r.SHA256=n.extend({_doReset:function(){this._hash=new e.init(s.slice(0))},_doProcessBlock:function(t,e){for(var n,r,i=this._hash.words,s=i[0],a=i[1],o=i[2],h=i[3],u=i[4],c=i[5],l=i[6],f=i[7],g=0;g<64;g++)d[g]=g<16?0|t[e+g]:(((n=d[g-15])<<25|n>>>7)^(n<<14|n>>>18)^n>>>3)+d[g-7]+(((r=d[g-2])<<15|r>>>17)^(r<<13|r>>>19)^r>>>10)+d[g-16],n=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+p[g]+d[g],r=((s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22))+(s&a^s&o^a&o),f=l,l=c,c=u,u=h+n|0,h=o,o=a,a=s,s=n+r|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+o|0,i[3]=i[3]+h|0,i[4]=i[4]+u|0,i[5]=i[5]+c|0,i[6]=i[6]+l|0,i[7]=i[7]+f|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(64+r>>>9<<4)]=i.floor(n/4294967296),e[15+(64+r>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA256=n._createHelper(r),t.HmacSHA256=n._createHmacHelper(r)}(Math),!function(){var t=C,e=t.lib.WordArray,n=(r=t.algo).SHA256,r=r.SHA224=n.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=n._createHelper(r),t.HmacSHA224=n._createHmacHelper(r)}(),!function(){function a(){return n.create.apply(n,arguments)}for(var t=C,e=t.lib.Hasher,n=(i=t.x64).Word,r=i.WordArray,i=t.algo,tt=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],et=[],s=0;s<80;s++)et[s]=a();i=i.SHA512=e.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(j,V){for(var t=(o=this._hash.words)[0],e=o[1],n=o[2],r=o[3],i=o[4],s=o[5],a=o[6],o=o[7],K=t.high,h=t.low,k=e.high,u=e.low,L=n.high,c=n.low,_=r.high,l=r.low,q=i.high,f=i.low,M=s.high,g=s.low,U=a.high,p=a.low,G=o.high,d=o.low,m=K,y=h,x=k,v=u,S=L,E=c,z=_,b=l,F=q,w=f,X=M,A=g,W=U,I=p,J=G,$=d,C=0;C<80;C++)var D,B=et[C],Y=(C<16?(D=B.high=0|j[V+2*C],O=B.low=0|j[V+2*C+1]):(D=((O=(D=et[C-15]).high)>>>1|(R=D.low)<<31)^(O>>>8|R<<24)^O>>>7,R=(R>>>1|O<<31)^(R>>>8|O<<24)^(R>>>7|O<<25),T=((O=(T=et[C-2]).high)>>>19|(N=T.low)<<13)^(O<<3|N>>>29)^O>>>6,N=(N>>>19|O<<13)^(N<<3|O>>>29)^(N>>>6|O<<26),Y=(O=et[C-7]).high,H=(P=et[C-16]).high,P=P.low,D=(D=(D=D+Y+((O=R+O.low)>>>0<R>>>0?1:0))+T+((O=O+N)>>>0<N>>>0?1:0))+H+((O=O+P)>>>0<P>>>0?1:0),B.high=D,B.low=O),F&X^~F&W),P=w&A^~w&I,B=m&x^m&S^x&S,R=(m>>>28|y<<4)^(m<<30|y>>>2)^(m<<25|y>>>7),T=(y>>>28|m<<4)^(y<<30|m>>>2)^(y<<25|m>>>7),N=tt[C],Z=N.high,Q=N.low,H=(H=(H=(H=J+((F>>>14|w<<18)^(F>>>18|w<<14)^(F<<23|w>>>9))+((N=$+((w>>>14|F<<18)^(w>>>18|F<<14)^(w<<23|F>>>9)))>>>0<$>>>0?1:0))+Y+((N=N+P)>>>0<P>>>0?1:0))+Z+((N=N+Q)>>>0<Q>>>0?1:0))+D+((N=N+O)>>>0<O>>>0?1:0),O=T+(y&v^y&E^v&E),J=W,$=I,W=X,I=A,X=F,A=w,F=z+H+((w=b+N|0)>>>0<b>>>0?1:0)|0,z=S,b=E,S=x,E=v,x=m,v=y,m=H+(B=R+B+(O>>>0<T>>>0?1:0))+((y=N+O|0)>>>0<N>>>0?1:0)|0;h=t.low=h+y,t.high=K+m+(h>>>0<y>>>0?1:0),u=e.low=u+v,e.high=k+x+(u>>>0<v>>>0?1:0),c=n.low=c+E,n.high=L+S+(c>>>0<E>>>0?1:0),l=r.low=l+b,r.high=_+z+(l>>>0<b>>>0?1:0),f=i.low=f+w,i.high=q+F+(f>>>0<w>>>0?1:0),g=s.low=g+A,s.high=M+X+(g>>>0<A>>>0?1:0),p=a.low=p+I,a.high=U+W+(p>>>0<I>>>0?1:0),d=o.low=d+$,o.high=G+J+(d>>>0<$>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[30+(128+r>>>10<<5)]=Math.floor(n/4294967296),e[31+(128+r>>>10<<5)]=n,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=e.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),t.SHA512=e._createHelper(i),t.HmacSHA512=e._createHmacHelper(i)}(),!function(){var t=C,e=(i=t.x64).Word,n=i.WordArray,r=(i=t.algo).SHA512,i=i.SHA384=r.extend({_doReset:function(){this._hash=new n.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=r._createHelper(i),t.HmacSHA384=r._createHmacHelper(i)}(),!function(){var t=C,e=(r=t.lib).WordArray,n=r.Hasher,r=t.algo,E=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),b=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),F=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),w=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),A=e.create([0,1518500249,1859775393,2400959708,2840853838]),I=e.create([1352829926,1548603684,1836072691,2053994217,0]),r=r.RIPEMD160=n.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=0;n<16;n++){var r=t[c=e+n];t[c]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}for(var i,s,a,o,h,u,c=this._hash.words,r=A.words,l=I.words,f=E.words,g=b.words,p=F.words,d=w.words,m=i=c[0],y=s=c[1],x=a=c[2],v=o=c[3],S=h=c[4],n=0;n<80;n+=1)u=i+t[e+f[n]]|0,u=n<16?u+((s^a^o)+r[0]):n<32?u+((s&a|~s&o)+r[1]):n<48?u+(((s|~a)^o)+r[2]):n<64?u+((s&o|a&~o)+r[3]):u+((s^(a|~o))+r[4]),u=(u=(u|=0)<<p[n]|u>>>32-p[n])+h|0,i=h,h=o,o=a<<10|a>>>22,a=s,s=u,u=m+t[e+g[n]]|0,u=n<16?u+((y^(x|~v))+l[0]):n<32?u+((y&v|x&~v)+l[1]):n<48?u+(((y|~x)^v)+l[2]):n<64?u+((y&x|~y&v)+l[3]):u+((y^x^v)+l[4]),u=(u=(u|=0)<<d[n]|u>>>32-d[n])+S|0,m=S,S=v,v=x<<10|x>>>22,x=y,y=u;u=c[1]+a+v|0,c[1]=c[2]+o+S|0,c[2]=c[3]+h+m|0,c[3]=c[4]+i+y|0,c[4]=c[0]+s+x|0,c[0]=u},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;for(e[r>>>5]|=128<<24-r%32,e[14+(64+r>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,n=0;n<5;n++)r=e[n],e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=n._createHelper(r),t.HmacRIPEMD160=n._createHmacHelper(r)}(Math),!function(){var t=C,o=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=o.parse(e));var n=t.blockSize,r=4*n;(e=e.sigBytes>r?t.finalize(e):e).clamp();for(var t=this._oKey=e.clone(),e=this._iKey=e.clone(),i=t.words,s=e.words,a=0;a<n;a++)i[a]^=1549556828,s[a]^=909522486;t.sigBytes=e.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),!function(){var t=C,e=t.lib,n=e.Base,m=e.WordArray,y=(e=t.algo).HMAC,r=e.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:e.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=y.create(n.hasher,t),i=m.create(),s=m.create([1]),a=i.words,o=s.words,h=n.keySize,n=n.iterations;a.length<h;){var u=r.update(e).finalize(s);r.reset();for(var c=u.words,l=c.length,f=u,g=1;g<n;g++){f=r.finalize(f),r.reset();for(var p=f.words,d=0;d<l;d++)c[d]^=p[d]}i.concat(u),o[0]++}return i.sigBytes=4*h,i}});t.PBKDF2=function(t,e,n){return r.create(n).compute(t,e)}}(),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),v="=";function hex2b64(t){for(var e,n="",r=0;r+3<=t.length;r+=3)e=parseInt(t.substring(r,r+3),16),n+=o.charAt(e>>6)+o.charAt(63&e);if(r+1==t.length?(e=parseInt(t.substring(r,r+1),16),n+=o.charAt(e<<2)):r+2==t.length&&(e=parseInt(t.substring(r,r+2),16),n+=o.charAt(e>>2)+o.charAt((3&e)<<4)),v)for(;0<(3&n.length);)n+=v;return n}function b64tohex(t){for(var e,n,r="",i=0,s=0;s<t.length&&t.charAt(s)!=v;++s)(n=o.indexOf(t.charAt(s)))<0||(i=0==i?(r+=int2char(n>>2),e=3&n,1):1==i?(r+=int2char(e<<2|n>>4),e=15&n,2):2==i?(r=(r+=int2char(e))+int2char(n>>2),e=3&n,3):(r=(r+=int2char(e<<2|n>>4))+int2char(15&n),0));return 1==i&&(r+=int2char(e<<2)),r}function BigInteger(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function nbi(){return new BigInteger(null)}c="Microsoft Internet Explorer"==y.appName?(BigInteger.prototype.am=function am2(t,e,n,r,i,s){for(var a=32767&e,o=e>>15;0<=--s;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;i=((h=a*h+((32767&c)<<15)+n[r]+(1073741823&i))>>>30)+(c>>>15)+o*u+(i>>>30),n[r++]=1073741823&h}return i},30):"Netscape"!=y.appName?(BigInteger.prototype.am=function am1(t,e,n,r,i,s){for(;0<=--s;){var a=e*this[t++]+n[r]+i;i=Math.floor(a/67108864),n[r++]=67108863&a}return i},26):(BigInteger.prototype.am=function am3(t,e,n,r,i,s){for(var a=16383&e,o=e>>14;0<=--s;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;i=((h=a*h+((16383&c)<<14)+n[r]+i)>>28)+(c>>14)+o*u,n[r++]=268435455&h}return i},28),BigInteger.prototype.DB=c,BigInteger.prototype.DM=(1<<c)-1,BigInteger.prototype.DV=1<<c;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-c,BigInteger.prototype.F2=2*c-52;for(var S="0123456789abcdefghijklmnopqrstuvwxyz",F=new Array,w="0".charCodeAt(0),r=0;r<=9;++r)F[w++]=r;for(w="a".charCodeAt(0),r=10;r<36;++r)F[w++]=r;for(w="A".charCodeAt(0),r=10;r<36;++r)F[w++]=r;function int2char(t){return S.charAt(t)}function intAt(t,e){t=F[t.charCodeAt(e)];return null==t?-1:t}function nbv(t){var e=nbi();return e.fromInt(t),e}function nbits(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}function Classic(t){this.m=t}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function op_and(t,e){return t&e}function op_or(t,e){return t|e}function op_xor(t,e){return t^e}function op_andnot(t,e){return t&~e}function NullExp(){}function nNop(t){return t}function Barrett(t){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}Classic.prototype.convert=function cConvert(t){return t.s<0||0<=t.compareTo(this.m)?t.mod(this.m):t},Classic.prototype.revert=function cRevert(t){return t},Classic.prototype.reduce=function cReduce(t){t.divRemTo(this.m,null,t)},Classic.prototype.mulTo=function cMulTo(t,e,n){t.multiplyTo(e,n),this.reduce(n)},Classic.prototype.sqrTo=function cSqrTo(t,e){t.squareTo(e),this.reduce(e)},Montgomery.prototype.convert=function montConvert(t){var e=nbi();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&0<e.compareTo(BigInteger.ZERO)&&this.m.subTo(e,e),e},Montgomery.prototype.revert=function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e},Montgomery.prototype.reduce=function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},Montgomery.prototype.mulTo=function montMulTo(t,e,n){t.multiplyTo(e,n),this.reduce(n)},Montgomery.prototype.sqrTo=function montSqrTo(t,e){t.squareTo(e),this.reduce(e)},BigInteger.prototype.copyTo=function bnpCopyTo(t){for(var e=this.t-1;0<=e;--e)t[e]=this[e];t.t=this.t,t.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(t){this.t=1,this.s=t<0?-1:0,0<t?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var r=t.length,i=!1,s=0;0<=--r;){var a=8==n?255&t[r]:intAt(t,r);a<0?"-"==t.charAt(r)&&(i=!0):(i=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,0<s)&&(this[this.t-1]|=(1<<this.DB-s)-1<<s),this.clamp(),i&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var t=this.s&this.DM;0<this.t&&this[this.t-1]==t;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(t,e){for(var n=this.t-1;0<=n;--n)e[n+t]=this[n];for(n=t-1;0<=n;--n)e[n]=0;e.t=this.t+t,e.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(t,e){for(var n=t%this.DB,r=this.DB-n,i=(1<<r)-1,s=Math.floor(t/this.DB),a=this.s<<n&this.DM,o=this.t-1;0<=o;--o)e[o+s+1]=this[o]>>r|a,a=(this[o]&i)<<n;for(o=s-1;0<=o;--o)e[o]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,i=this.DB-r,s=(1<<r)-1;e[0]=this[n]>>r;for(var a=n+1;a<this.t;++a)e[a-n-1]|=(this[a]&s)<<i,e[a-n]=this[a]>>r;0<r&&(e[this.t-n-1]|=(this.s&s)<<i),e.t=this.t-n,e.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:0<r&&(e[n++]=r),e.t=n,e.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(t,e){var n=this.abs(),r=t.abs(),i=n.t;for(e.t=i+r.t;0<=--i;)e[i]=0;for(i=0;i<r.t;++i)e[i+n.t]=n.am(0,r[i],e,i,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&BigInteger.ZERO.subTo(e,e)},BigInteger.prototype.squareTo=function bnpSquareTo(t){for(var e=this.abs(),n=t.t=2*e.t;0<=--n;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}0<t.t&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(t,e,n){var r=t.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t)null!=e&&e.fromInt(0),null!=n&&this.copyTo(n);else{null==n&&(n=nbi());var s=nbi(),a=this.s,t=t.s,o=this.DB-nbits(r[r.t-1]),h=(0<o?(r.lShiftTo(o,s),i.lShiftTo(o,n)):(r.copyTo(s),i.copyTo(n)),s.t),u=s[h-1];if(0!=u){var r=u*(1<<this.F1)+(1<h?s[h-2]>>this.F2:0),c=this.FV/r,l=(1<<this.F1)/r,f=1<<this.F2,g=n.t,p=g-h,d=null==e?nbi():e;for(s.dlShiftTo(p,d),0<=n.compareTo(d)&&(n[n.t++]=1,n.subTo(d,n)),BigInteger.ONE.dlShiftTo(h,d),d.subTo(s,s);s.t<h;)s[s.t++]=0;for(;0<=--p;){var m=n[--g]==u?this.DM:Math.floor(n[g]*c+(n[g-1]+f)*l);if((n[g]+=s.am(0,m,n,p,0,h))<m)for(s.dlShiftTo(p,d),n.subTo(d,n);n[g]<--m;)n.subTo(d,n)}null!=e&&(n.drShiftTo(h,e),a!=t)&&BigInteger.ZERO.subTo(e,e),n.t=h,n.clamp(),0<o&&n.rShiftTo(o,n),a<0&&BigInteger.ZERO.subTo(n,n)}}}},BigInteger.prototype.invDigit=function bnpInvDigit(){var t,e;return this.t<1||0==(1&(t=this[0]))?0:0<(e=(e=(e=(e=(e=3&t)*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)?this.DV-e:-e},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(0<this.t?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(t,e){if(4294967295<t||t<1)return BigInteger.ONE;var n,r=nbi(),i=nbi(),s=e.convert(this),a=nbits(t)-1;for(s.copyTo(r);0<=--a;)e.sqrTo(r,i),0<(t&1<<a)?e.mulTo(i,s,r):(n=r,r=i,i=n);return e.revert(r)},BigInteger.prototype.toString=function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var n,r=(1<<e)-1,i=!1,s="",a=this.t,o=this.DB-a*this.DB%e;if(0<a--)for(o<this.DB&&0<(n=this[a]>>o)&&(i=!0,s=int2char(n));0<=a;)o<e?(n=(this[a]&(1<<o)-1)<<e-o,n|=this[--a]>>(o+=this.DB-e)):(n=this[a]>>(o-=e)&r,o<=0&&(o+=this.DB,--a)),(i=0<n?!0:i)&&(s+=int2char(n));return i?s:"0"},BigInteger.prototype.negate=function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;0<=--n;)if(0!=(e=this[n]-t[n]))return e;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&0<e.compareTo(BigInteger.ZERO)&&t.subTo(e,e),e},BigInteger.prototype.modPowInt=function bnModPowInt(t,e){return e=new(t<256||e.isEven()?Classic:Montgomery)(e),this.exp(t,e)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(t,e,n){t.multiplyTo(e,n)},NullExp.prototype.sqrTo=function nSqrTo(t,e){t.squareTo(e)},Barrett.prototype.convert=function barrettConvert(t){var e;return t.s<0||t.t>2*this.m.t?t.mod(this.m):t.compareTo(this.m)<0?t:(e=nbi(),t.copyTo(e),this.reduce(e),e)},Barrett.prototype.revert=function barrettRevert(t){return t},Barrett.prototype.reduce=function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},Barrett.prototype.mulTo=function barrettMulTo(t,e,n){t.multiplyTo(e,n),this.reduce(n)},Barrett.prototype.sqrTo=function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)};var u=[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],I=(1<<26)/u[u.length-1];
1
+ !function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ImagexEncrypt=e():t.ImagexEncrypt=e()}("undefined"!=typeof self?self:this,()=>(()=>{var r={166:(p,d)=>{var y={userAgent:!1},t={},I=I||function(u){var t={},e=t.lib={},r=e.Base=function(){function n(){}return{extend:function(t){n.prototype=this;var e=new n;return t&&e.mixIn(t),e.hasOwnProperty("init")||(e.init=function(){e.$super.init.apply(this,arguments)}),(e.init.prototype=e).$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),c=e.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||i).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var a=r[s>>>2]>>>24-s%4*8&255;e[n+s>>>2]|=a<<24-(n+s)%4*8}else for(s=0;s<i;s+=4)e[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=u.ceil(e/4)},clone:function(){var t=r.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r<t;r+=4)e.push(4294967296*u.random()|0);return new c.init(e,t)}}),n=t.enc={},i=n.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i<r;i++){var s=e[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new c.init(r,e/2)}},s=n.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i<r;i++){var s=e[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new c.init(r,e)}},a=n.Utf8={stringify:function(t){try{return decodeURIComponent(escape(s.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return s.parse(unescape(encodeURIComponent(t)))}},o=e.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=a.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,r=e.words,n=e.sigBytes,i=this.blockSize,s=n/(4*i),a=(s=t?u.ceil(s):u.max((0|s)-this._minBufferSize,0))*i,t=u.min(4*a,n);if(a){for(var o=0;o<a;o+=i)this._doProcessBlock(r,o);var h=r.splice(0,a);e.sigBytes-=t}return new c.init(h,t)},clone:function(){var t=r.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(e.Hasher=o.extend({cfg:r.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){o.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(r){return function(t,e){return new r.init(e).finalize(t)}},_createHmacHelper:function(r){return function(t,e){return new h.HMAC.init(r,e).finalize(t)}}}),t.algo={});return t}(Math),o=(!function(){var t=I,e=t.lib,i=e.Base,s=e.WordArray;(t=t.x64={}).Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],n=0;n<e;n++){var i=t[n];r.push(i.high),r.push(i.low)}return s.create(r,this.sigBytes)},clone:function(){for(var t=i.clone.call(this),e=t.words=this.words.slice(0),r=e.length,n=0;n<r;n++)e[n]=e[n].clone();return t}})}(),I.lib.Cipher||function(){function ab(t,e,r){var n=this._iv;n?this._iv=void 0:n=this._prevBlock;for(var i=0;i<r;i++)t[e+i]^=n[i]}var t=(l=I).lib,e=t.Base,a=t.WordArray,r=t.BufferedBlockAlgorithm,n=l.enc.Base64,i=l.algo.EvpKDF,s=t.Cipher=r.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){r.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(n){return{encrypt:function(t,e,r){return("string"==typeof e?f:c).encrypt(n,t,e,r)},decrypt:function(t,e,r){return("string"==typeof e?f:c).decrypt(n,t,e,r)}}}}),o=(t.StreamCipher=s.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),l.mode={}),h=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend(),u=(h.Encryptor=h.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize;ab.call(this,t,e,n),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+n)}}),h.Decryptor=h.extend({processBlock:function(t,e){var r=this._cipher,n=r.blockSize,i=t.slice(e,e+n);r.decryptBlock(t,e),ab.call(this,t,e,n),this._prevBlock=i}}),o=o.CBC=h,h=(l.pad={}).Pkcs7={pad:function(t,e){for(var r=4*e,n=(r=r-t.sigBytes%r)<<24|r<<16|r<<8|r,i=[],s=0;s<r;s+=4)i.push(n);r=a.create(i,r),t.concat(r)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:o,padding:h}),reset:function(){s.reset.call(this);var t,e=(r=this.cfg).iv,r=r.mode;this._xformMode==this._ENC_XFORM_MODE?t=r.createEncryptor:(t=r.createDecryptor,this._minBufferSize=1),this._mode=t.call(r,this,e&&e.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),o=(l.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?a.create([1398893684,1701076831]).concat(t).concat(e):e).toString(n)},parse:function(t){var e,r=(t=n.parse(t)).words;return 1398893684==r[0]&&1701076831==r[1]&&(e=a.create(r.slice(2,4)),r.splice(0,4),t.sigBytes-=16),u.create({ciphertext:t,salt:e})}},c=t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n);return e=i.finalize(e),i=i.cfg,u.create({ciphertext:e,key:r,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),l=(l.kdf={}).OpenSSL={execute:function(t,e,r,n){return n=n||a.random(8),t=i.create({keySize:e+r}).compute(t,n),r=a.create(t.words.slice(e),4*r),t.sigBytes=4*e,u.create({key:t,iv:r,salt:n})}},f=t.PasswordBasedCipher=c.extend({cfg:c.cfg.extend({kdf:l}),encrypt:function(t,e,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize),n.iv=r.iv,(t=c.encrypt.call(this,t,e,r.key,n)).mixIn(r),t},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),r=n.kdf.execute(r,t.keySize,t.ivSize,e.salt),n.iv=r.iv,c.decrypt.call(this,t,e,r.key,n)}})}(),!function(){for(var t=I,e=t.lib.BlockCipher,r=t.algo,a=[],n=[],i=[],s=[],o=[],h=[],u=[],c=[],l=[],f=[],g=[],p=0;p<256;p++)g[p]=p<128?p<<1:p<<1^283;for(var d=0,m=0,p=0;p<256;p++){var y=m^m<<1^m<<2^m<<3^m<<4,x=g[n[a[d]=y=y>>>8^255&y^99]=d],v=g[x],S=g[v],E=257*g[y]^16843008*y;i[d]=E<<24|E>>>8,s[d]=E<<16|E>>>16,o[d]=E<<8|E>>>24,h[d]=E,u[y]=(E=16843009*S^65537*v^257*x^16843008*d)<<24|E>>>8,c[y]=E<<16|E>>>16,l[y]=E<<8|E>>>24,f[y]=E,d?(d=x^g[g[g[S^x]]],m^=g[g[m]]):d=m=1}var b=[0,1,2,4,8,16,32,64,128,27,54],r=r.AES=e.extend({_doReset:function(){for(var t,e=(n=this._key).words,r=n.sigBytes/4,n=4*((this._nRounds=r+6)+1),i=this._keySchedule=[],s=0;s<n;s++)s<r?i[s]=e[s]:(t=i[s-1],s%r?6<r&&4==s%r&&(t=a[t>>>24]<<24|a[t>>>16&255]<<16|a[t>>>8&255]<<8|a[255&t]):(t=a[(t=t<<8|t>>>24)>>>24]<<24|a[t>>>16&255]<<16|a[t>>>8&255]<<8|a[255&t],t^=b[s/r|0]<<24),i[s]=i[s-r]^t);for(e=this._invKeySchedule=[],r=0;r<n;r++)s=n-r,t=r%4?i[s]:i[s-4],e[r]=r<4||s<=4?t:u[a[t>>>24]]^c[a[t>>>16&255]]^l[a[t>>>8&255]]^f[a[255&t]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,i,s,o,h,a)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,n),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,s,a,o){for(var h=this._nRounds,u=t[e]^r[0],c=t[e+1]^r[1],l=t[e+2]^r[2],f=t[e+3]^r[3],g=4,p=1;p<h;p++)var d=n[u>>>24]^i[c>>>16&255]^s[l>>>8&255]^a[255&f]^r[g++],m=n[c>>>24]^i[l>>>16&255]^s[f>>>8&255]^a[255&u]^r[g++],y=n[l>>>24]^i[f>>>16&255]^s[u>>>8&255]^a[255&c]^r[g++],f=n[f>>>24]^i[u>>>16&255]^s[c>>>8&255]^a[255&l]^r[g++],u=d,c=m,l=y;d=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^r[g++],m=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&u])^r[g++],y=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^r[g++],f=(o[f>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[g++],t[e]=d,t[e+1]=m,t[e+2]=y,t[e+3]=f},keySize:8});t.AES=e._createHelper(r)}(),!function(){function j(t,e){e=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=e,this._lBlock^=e<<t}function l(t,e){e=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=e,this._rBlock^=e<<t}var t=I,e=(r=t.lib).WordArray,r=r.BlockCipher,n=t.algo,a=[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],o=[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],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{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}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],i=n.DES=r.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=a[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;n<16;n++){for(var i=t[n]=[],s=h[n],r=0;r<24;r++)i[r/6|0]|=e[(o[r]-1+s)%28]<<31-r%6,i[4+(r/6|0)]|=e[28+(o[r+24]-1+s)%28]<<31-r%6;for(i[0]=i[0]<<1|i[0]>>>31,r=1;r<7;r++)i[r]>>>=4*(r-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],r=0;r<16;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],j.call(this,4,252645135),j.call(this,16,65535),l.call(this,2,858993459),l.call(this,8,16711935),j.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],s=this._lBlock,a=this._rBlock,o=0,h=0;h<8;h++)o|=u[h][((a^i[h])&c[h])>>>0];this._lBlock=a,this._rBlock=s^o}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,j.call(this,1,1431655765),l.call(this,8,16711935),l.call(this,2,858993459),j.call(this,16,65535),j.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});t.DES=r._createHelper(i),n=n.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=i.createEncryptor(e.create(t.slice(0,2))),this._des2=i.createEncryptor(e.create(t.slice(2,4))),this._des3=i.createEncryptor(e.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),t.TripleDES=r._createHelper(n)}(),!function(){var t=I,h=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp(),t=[];for(var i=0;i<r;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<r;a++)t.push(n.charAt(s>>>6*(3-a)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var e=t.length,r=this._map;(s=r.charAt(64))&&-1!=(s=t.indexOf(s))&&(e=s);for(var n,i,s=[],a=0,o=0;o<e;o++)o%4&&(n=r.indexOf(t.charAt(o-1))<<o%4*2,i=r.indexOf(t.charAt(o))>>>6-o%4*2,s[a>>>2]|=(n|i)<<24-a%4*8,a++);return h.create(s,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),!function(s){function h(t,e,r,n,i,s,a){return((t=t+(e&r|~e&n)+i+a)<<s|t>>>32-s)+e}function k(t,e,r,n,i,s,a){return((t=t+(e&n|r&~n)+i+a)<<s|t>>>32-s)+e}function l(t,e,r,n,i,s,a){return((t=t+(e^r^n)+i+a)<<s|t>>>32-s)+e}function n(t,e,r,n,i,s,a){return((t=t+(r^(e|~n))+i+a)<<s|t>>>32-s)+e}for(var t=I,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,C=[],a=0;a<64;a++)C[a]=4294967296*s.abs(s.sin(a+1))|0;i=i.MD5=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=t[s=e+r];t[s]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r=this._hash.words,s=t[e+0],i=t[e+1],a=t[e+2],o=t[e+3],u=t[e+4],c=t[e+5],f=t[e+6],g=t[e+7],p=t[e+8],d=t[e+9],m=t[e+10],y=t[e+11],x=t[e+12],v=t[e+13],S=t[e+14],E=t[e+15],b=h(r[0],A=r[1],F=r[2],w=r[3],s,7,C[0]),w=h(w,b,A,F,i,12,C[1]),F=h(F,w,b,A,a,17,C[2]),A=h(A,F,w,b,o,22,C[3]),b=h(b,A,F,w,u,7,C[4]),w=h(w,b,A,F,c,12,C[5]),F=h(F,w,b,A,f,17,C[6]),A=h(A,F,w,b,g,22,C[7]),b=h(b,A,F,w,p,7,C[8]),w=h(w,b,A,F,d,12,C[9]),F=h(F,w,b,A,m,17,C[10]),A=h(A,F,w,b,y,22,C[11]),b=h(b,A,F,w,x,7,C[12]),w=h(w,b,A,F,v,12,C[13]),F=h(F,w,b,A,S,17,C[14]),b=k(b,A=h(A,F,w,b,E,22,C[15]),F,w,i,5,C[16]),w=k(w,b,A,F,f,9,C[17]),F=k(F,w,b,A,y,14,C[18]),A=k(A,F,w,b,s,20,C[19]),b=k(b,A,F,w,c,5,C[20]),w=k(w,b,A,F,m,9,C[21]),F=k(F,w,b,A,E,14,C[22]),A=k(A,F,w,b,u,20,C[23]),b=k(b,A,F,w,d,5,C[24]),w=k(w,b,A,F,S,9,C[25]),F=k(F,w,b,A,o,14,C[26]),A=k(A,F,w,b,p,20,C[27]),b=k(b,A,F,w,v,5,C[28]),w=k(w,b,A,F,a,9,C[29]),F=k(F,w,b,A,g,14,C[30]),b=l(b,A=k(A,F,w,b,x,20,C[31]),F,w,c,4,C[32]),w=l(w,b,A,F,p,11,C[33]),F=l(F,w,b,A,y,16,C[34]),A=l(A,F,w,b,S,23,C[35]),b=l(b,A,F,w,i,4,C[36]),w=l(w,b,A,F,u,11,C[37]),F=l(F,w,b,A,g,16,C[38]),A=l(A,F,w,b,m,23,C[39]),b=l(b,A,F,w,v,4,C[40]),w=l(w,b,A,F,s,11,C[41]),F=l(F,w,b,A,o,16,C[42]),A=l(A,F,w,b,f,23,C[43]),b=l(b,A,F,w,d,4,C[44]),w=l(w,b,A,F,x,11,C[45]),F=l(F,w,b,A,E,16,C[46]),b=n(b,A=l(A,F,w,b,a,23,C[47]),F,w,s,6,C[48]),w=n(w,b,A,F,g,10,C[49]),F=n(F,w,b,A,S,15,C[50]),A=n(A,F,w,b,c,21,C[51]),b=n(b,A,F,w,x,6,C[52]),w=n(w,b,A,F,o,10,C[53]),F=n(F,w,b,A,m,15,C[54]),A=n(A,F,w,b,i,21,C[55]),b=n(b,A,F,w,p,6,C[56]),w=n(w,b,A,F,E,10,C[57]),F=n(F,w,b,A,f,15,C[58]),A=n(A,F,w,b,v,21,C[59]),b=n(b,A,F,w,u,6,C[60]),w=n(w,b,A,F,y,10,C[61]),F=n(F,w,b,A,a,15,C[62]),A=n(A,F,w,b,d,21,C[63]);r[0]=r[0]+b|0,r[1]=r[1]+A|0,r[2]=r[2]+F|0,r[3]=r[3]+w|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes,i=(e[n>>>5]|=128<<24-n%32,s.floor(r/4294967296));for(e[15+(64+n>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e[14+(64+n>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;r<4;r++)n=e[r],e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.MD5=r._createHelper(i),t.HmacMD5=r._createHmacHelper(i)}(Math),!function(){var t=I,e=(n=t.lib).WordArray,r=n.Hasher,c=[],n=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r,n=this._hash.words,i=n[0],s=n[1],a=n[2],o=n[3],h=n[4],u=0;u<80;u++)c[u]=u<16?0|t[e+u]:(r=c[u-3]^c[u-8]^c[u-14]^c[u-16])<<1|r>>>31,r=(i<<5|i>>>27)+h+c[u],r=u<20?r+(1518500249+(s&a|~s&o)):u<40?r+(1859775393+(s^a^o)):u<60?r+((s&a|s&o|a&o)-1894007588):r+((s^a^o)-899497514),h=o,o=a,a=s<<30|s>>>2,s=i,i=r;n[0]=n[0]+i|0,n[1]=n[1]+s|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(64+n>>>9<<4)]=Math.floor(r/4294967296),e[15+(64+n>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(n),t.HmacSHA1=r._createHmacHelper(n)}(),!function(i){function p3(t){return 4294967296*(t-(0|t))|0}for(var t=I,e=(n=t.lib).WordArray,r=n.Hasher,n=t.algo,s=[],p=[],a=2,o=0;o<64;){t:{for(var h=a,u=i.sqrt(h),c=2;c<=u;c++)if(!(h%c)){h=!1;break t}h=!0}h&&(o<8&&(s[o]=p3(i.pow(a,.5))),p[o]=p3(i.pow(a,1/3)),o++),a++}var d=[],n=n.SHA256=r.extend({_doReset:function(){this._hash=new e.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r,n,i=this._hash.words,s=i[0],a=i[1],o=i[2],h=i[3],u=i[4],c=i[5],l=i[6],f=i[7],g=0;g<64;g++)d[g]=g<16?0|t[e+g]:(((r=d[g-15])<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+d[g-7]+(((n=d[g-2])<<15|n>>>17)^(n<<13|n>>>19)^n>>>10)+d[g-16],r=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+p[g]+d[g],n=((s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22))+(s&a^s&o^a&o),f=l,l=c,c=u,u=h+r|0,h=o,o=a,a=s,s=r+n|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+o|0,i[3]=i[3]+h|0,i[4]=i[4]+u|0,i[5]=i[5]+c|0,i[6]=i[6]+l|0,i[7]=i[7]+f|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(64+n>>>9<<4)]=i.floor(r/4294967296),e[15+(64+n>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA256=r._createHelper(n),t.HmacSHA256=r._createHmacHelper(n)}(Math),!function(){var t=I,e=t.lib.WordArray,r=(n=t.algo).SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(n),t.HmacSHA224=r._createHmacHelper(n)}(),!function(){function a(){return r.create.apply(r,arguments)}for(var t=I,e=t.lib.Hasher,r=(i=t.x64).Word,n=i.WordArray,i=t.algo,tt=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],et=[],s=0;s<80;s++)et[s]=a();i=i.SHA512=e.extend({_doReset:function(){this._hash=new n.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(j,V){for(var t=(o=this._hash.words)[0],e=o[1],r=o[2],n=o[3],i=o[4],s=o[5],a=o[6],o=o[7],K=t.high,h=t.low,k=e.high,u=e.low,L=r.high,c=r.low,q=n.high,l=n.low,_=i.high,f=i.low,M=s.high,g=s.low,U=a.high,p=a.low,G=o.high,d=o.low,m=K,y=h,x=k,v=u,S=L,E=c,z=q,b=l,w=_,F=f,X=M,A=g,W=U,C=p,J=G,$=d,I=0;I<80;I++)var P,B=et[I],Y=(I<16?(P=B.high=0|j[V+2*I],O=B.low=0|j[V+2*I+1]):(P=((O=(P=et[I-15]).high)>>>1|(R=P.low)<<31)^(O>>>8|R<<24)^O>>>7,R=(R>>>1|O<<31)^(R>>>8|O<<24)^(R>>>7|O<<25),T=((O=(T=et[I-2]).high)>>>19|(N=T.low)<<13)^(O<<3|N>>>29)^O>>>6,N=(N>>>19|O<<13)^(N<<3|O>>>29)^(N>>>6|O<<26),Y=(O=et[I-7]).high,H=(D=et[I-16]).high,D=D.low,P=(P=(P=P+Y+((O=R+O.low)>>>0<R>>>0?1:0))+T+((O=O+N)>>>0<N>>>0?1:0))+H+((O=O+D)>>>0<D>>>0?1:0),B.high=P,B.low=O),w&X^~w&W),D=F&A^~F&C,B=m&x^m&S^x&S,R=(m>>>28|y<<4)^(m<<30|y>>>2)^(m<<25|y>>>7),T=(y>>>28|m<<4)^(y<<30|m>>>2)^(y<<25|m>>>7),N=tt[I],Z=N.high,Q=N.low,H=(H=(H=(H=J+((w>>>14|F<<18)^(w>>>18|F<<14)^(w<<23|F>>>9))+((N=$+((F>>>14|w<<18)^(F>>>18|w<<14)^(F<<23|w>>>9)))>>>0<$>>>0?1:0))+Y+((N=N+D)>>>0<D>>>0?1:0))+Z+((N=N+Q)>>>0<Q>>>0?1:0))+P+((N=N+O)>>>0<O>>>0?1:0),O=T+(y&v^y&E^v&E),J=W,$=C,W=X,C=A,X=w,A=F,w=z+H+((F=b+N|0)>>>0<b>>>0?1:0)|0,z=S,b=E,S=x,E=v,x=m,v=y,m=H+(B=R+B+(O>>>0<T>>>0?1:0))+((y=N+O|0)>>>0<N>>>0?1:0)|0;h=t.low=h+y,t.high=K+m+(h>>>0<y>>>0?1:0),u=e.low=u+v,e.high=k+x+(u>>>0<v>>>0?1:0),c=r.low=c+E,r.high=L+S+(c>>>0<E>>>0?1:0),l=n.low=l+b,n.high=q+z+(l>>>0<b>>>0?1:0),f=i.low=f+F,i.high=_+w+(f>>>0<F>>>0?1:0),g=s.low=g+A,s.high=M+X+(g>>>0<A>>>0?1:0),p=a.low=p+C,a.high=U+W+(p>>>0<C>>>0?1:0),d=o.low=d+$,o.high=G+J+(d>>>0<$>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(128+n>>>10<<5)]=Math.floor(r/4294967296),e[31+(128+n>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=e.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),t.SHA512=e._createHelper(i),t.HmacSHA512=e._createHmacHelper(i)}(),!function(){var t=I,e=(i=t.x64).Word,r=i.WordArray,n=(i=t.algo).SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(i),t.HmacSHA384=n._createHmacHelper(i)}(),!function(){var t=I,e=(n=t.lib).WordArray,r=n.Hasher,n=t.algo,E=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),b=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),w=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),F=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),A=e.create([0,1518500249,1859775393,2400959708,2840853838]),C=e.create([1352829926,1548603684,1836072691,2053994217,0]),n=n.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=t[c=e+r];t[c]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}for(var i,s,a,o,h,u,c=this._hash.words,n=A.words,l=C.words,f=E.words,g=b.words,p=w.words,d=F.words,m=i=c[0],y=s=c[1],x=a=c[2],v=o=c[3],S=h=c[4],r=0;r<80;r+=1)u=i+t[e+f[r]]|0,u=r<16?u+((s^a^o)+n[0]):r<32?u+((s&a|~s&o)+n[1]):r<48?u+(((s|~a)^o)+n[2]):r<64?u+((s&o|a&~o)+n[3]):u+((s^(a|~o))+n[4]),u=(u=(u|=0)<<p[r]|u>>>32-p[r])+h|0,i=h,h=o,o=a<<10|a>>>22,a=s,s=u,u=m+t[e+g[r]]|0,u=r<16?u+((y^(x|~v))+l[0]):r<32?u+((y&v|x&~v)+l[1]):r<48?u+(((y|~x)^v)+l[2]):r<64?u+((y&x|~y&v)+l[3]):u+((y^x^v)+l[4]),u=(u=(u|=0)<<d[r]|u>>>32-d[r])+S|0,m=S,S=v,v=x<<10|x>>>22,x=y,y=u;u=c[1]+a+v|0,c[1]=c[2]+o+S|0,c[2]=c[3]+h+m|0,c[3]=c[4]+i+y|0,c[4]=c[0]+s+x|0,c[0]=u},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(64+n>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;r<5;r++)n=e[r],e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=r._createHelper(n),t.HmacRIPEMD160=r._createHmacHelper(n)}(Math),!function(){var t=I,o=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=o.parse(e));var r=t.blockSize,n=4*r;(e=e.sigBytes>n?t.finalize(e):e).clamp();for(var t=this._oKey=e.clone(),e=this._iKey=e.clone(),i=t.words,s=e.words,a=0;a<r;a++)i[a]^=1549556828,s[a]^=909522486;t.sigBytes=e.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),!function(){var t=I,e=t.lib,r=e.Base,m=e.WordArray,y=(e=t.algo).HMAC,n=e.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:e.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=y.create(r.hasher,t),i=m.create(),s=m.create([1]),a=i.words,o=s.words,h=r.keySize,r=r.iterations;a.length<h;){var u=n.update(e).finalize(s);n.reset();for(var c=u.words,l=c.length,f=u,g=1;g<r;g++){f=n.finalize(f),n.reset();for(var p=f.words,d=0;d<l;d++)c[d]^=p[d]}i.concat(u),o[0]++}return i.sigBytes=4*h,i}});t.PBKDF2=function(t,e,r){return n.create(r).compute(t,e)}}(),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),x="=";function hex2b64(t){for(var e,r="",n=0;n+3<=t.length;n+=3)e=parseInt(t.substring(n,n+3),16),r+=o.charAt(e>>6)+o.charAt(63&e);if(n+1==t.length?(e=parseInt(t.substring(n,n+1),16),r+=o.charAt(e<<2)):n+2==t.length&&(e=parseInt(t.substring(n,n+2),16),r+=o.charAt(e>>2)+o.charAt((3&e)<<4)),x)for(;0<(3&r.length);)r+=x;return r}function b64tohex(t){for(var e,r,n="",i=0,s=0;s<t.length&&t.charAt(s)!=x;++s)(r=o.indexOf(t.charAt(s)))<0||(i=0==i?(n+=int2char(r>>2),e=3&r,1):1==i?(n+=int2char(e<<2|r>>4),e=15&r,2):2==i?(n=(n+=int2char(e))+int2char(r>>2),e=3&r,3):(n=(n+=int2char(e<<2|r>>4))+int2char(15&r),0));return 1==i&&(n+=int2char(e<<2)),n}function BigInteger(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function nbi(){return new BigInteger(null)}c="Microsoft Internet Explorer"==y.appName?(BigInteger.prototype.am=function am2(t,e,r,n,i,s){for(var a=32767&e,o=e>>15;0<=--s;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;i=((h=a*h+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+o*u+(i>>>30),r[n++]=1073741823&h}return i},30):"Netscape"!=y.appName?(BigInteger.prototype.am=function am1(t,e,r,n,i,s){for(;0<=--s;){var a=e*this[t++]+r[n]+i;i=Math.floor(a/67108864),r[n++]=67108863&a}return i},26):(BigInteger.prototype.am=function am3(t,e,r,n,i,s){for(var a=16383&e,o=e>>14;0<=--s;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;i=((h=a*h+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+o*u,r[n++]=268435455&h}return i},28),BigInteger.prototype.DB=c,BigInteger.prototype.DM=(1<<c)-1,BigInteger.prototype.DV=1<<c;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-c,BigInteger.prototype.F2=2*c-52;for(var v="0123456789abcdefghijklmnopqrstuvwxyz",S=new Array,F="0".charCodeAt(0),r=0;r<=9;++r)S[F++]=r;for(F="a".charCodeAt(0),r=10;r<36;++r)S[F++]=r;for(F="A".charCodeAt(0),r=10;r<36;++r)S[F++]=r;function int2char(t){return v.charAt(t)}function intAt(t,e){t=S[t.charCodeAt(e)];return null==t?-1:t}function nbv(t){var e=nbi();return e.fromInt(t),e}function nbits(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function Classic(t){this.m=t}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function op_and(t,e){return t&e}function op_or(t,e){return t|e}function op_xor(t,e){return t^e}function op_andnot(t,e){return t&~e}function NullExp(){}function nNop(t){return t}function Barrett(t){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}Classic.prototype.convert=function cConvert(t){return t.s<0||0<=t.compareTo(this.m)?t.mod(this.m):t},Classic.prototype.revert=function cRevert(t){return t},Classic.prototype.reduce=function cReduce(t){t.divRemTo(this.m,null,t)},Classic.prototype.mulTo=function cMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)},Classic.prototype.sqrTo=function cSqrTo(t,e){t.squareTo(e),this.reduce(e)},Montgomery.prototype.convert=function montConvert(t){var e=nbi();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&0<e.compareTo(BigInteger.ZERO)&&this.m.subTo(e,e),e},Montgomery.prototype.revert=function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e},Montgomery.prototype.reduce=function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},Montgomery.prototype.mulTo=function montMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)},Montgomery.prototype.sqrTo=function montSqrTo(t,e){t.squareTo(e),this.reduce(e)},BigInteger.prototype.copyTo=function bnpCopyTo(t){for(var e=this.t-1;0<=e;--e)t[e]=this[e];t.t=this.t,t.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(t){this.t=1,this.s=t<0?-1:0,0<t?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;0<=--n;){var a=8==r?255&t[n]:intAt(t,n);a<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,0<s)&&(this[this.t-1]|=(1<<this.DB-s)-1<<s),this.clamp(),i&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var t=this.s&this.DM;0<this.t&&this[this.t-1]==t;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(t,e){for(var r=this.t-1;0<=r;--r)e[r+t]=this[r];for(r=t-1;0<=r;--r)e[r]=0;e.t=this.t+t,e.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),a=this.s<<r&this.DM,o=this.t-1;0<=o;--o)e[o+s+1]=this[o]>>n|a,a=(this[o]&i)<<r;for(o=s-1;0<=o;--o)e[o]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var a=r+1;a<this.t;++a)e[a-r-1]|=(this[a]&s)<<i,e[a-r]=this[a]>>n;0<n&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:0<n&&(e[r++]=n),e.t=r,e.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;0<=--i;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&BigInteger.ZERO.subTo(e,e)},BigInteger.prototype.squareTo=function bnpSquareTo(t){for(var e=this.abs(),r=t.t=2*e.t;0<=--r;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}0<t.t&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)null!=e&&e.fromInt(0),null!=r&&this.copyTo(r);else{null==r&&(r=nbi());var s=nbi(),a=this.s,t=t.s,o=this.DB-nbits(n[n.t-1]),h=(0<o?(n.lShiftTo(o,s),i.lShiftTo(o,r)):(n.copyTo(s),i.copyTo(r)),s.t),u=s[h-1];if(0!=u){var n=u*(1<<this.F1)+(1<h?s[h-2]>>this.F2:0),c=this.FV/n,l=(1<<this.F1)/n,f=1<<this.F2,g=r.t,p=g-h,d=null==e?nbi():e;for(s.dlShiftTo(p,d),0<=r.compareTo(d)&&(r[r.t++]=1,r.subTo(d,r)),BigInteger.ONE.dlShiftTo(h,d),d.subTo(s,s);s.t<h;)s[s.t++]=0;for(;0<=--p;){var m=r[--g]==u?this.DM:Math.floor(r[g]*c+(r[g-1]+f)*l);if((r[g]+=s.am(0,m,r,p,0,h))<m)for(s.dlShiftTo(p,d),r.subTo(d,r);r[g]<--m;)r.subTo(d,r)}null!=e&&(r.drShiftTo(h,e),a!=t)&&BigInteger.ZERO.subTo(e,e),r.t=h,r.clamp(),0<o&&r.rShiftTo(o,r),a<0&&BigInteger.ZERO.subTo(r,r)}}}},BigInteger.prototype.invDigit=function bnpInvDigit(){var t,e;return this.t<1||0==(1&(t=this[0]))?0:0<(e=(e=(e=(e=(e=3&t)*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)?this.DV-e:-e},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(0<this.t?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(t,e){if(4294967295<t||t<1)return BigInteger.ONE;var r,n=nbi(),i=nbi(),s=e.convert(this),a=nbits(t)-1;for(s.copyTo(n);0<=--a;)e.sqrTo(n,i),0<(t&1<<a)?e.mulTo(i,s,n):(r=n,n=i,i=r);return e.revert(n)},BigInteger.prototype.toString=function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,s="",a=this.t,o=this.DB-a*this.DB%e;if(0<a--)for(o<this.DB&&0<(r=this[a]>>o)&&(i=!0,s=int2char(r));0<=a;)o<e?(r=(this[a]&(1<<o)-1)<<e-o,r|=this[--a]>>(o+=this.DB-e)):(r=this[a]>>(o-=e)&n,o<=0&&(o+=this.DB,--a)),(i=0<r?!0:i)&&(s+=int2char(r));return i?s:"0"},BigInteger.prototype.negate=function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;0<=--r;)if(0!=(e=this[r]-t[r]))return e;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&0<e.compareTo(BigInteger.ZERO)&&t.subTo(e,e),e},BigInteger.prototype.modPowInt=function bnModPowInt(t,e){return e=new(t<256||e.isEven()?Classic:Montgomery)(e),this.exp(t,e)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(t,e,r){t.multiplyTo(e,r)},NullExp.prototype.sqrTo=function nSqrTo(t,e){t.squareTo(e)},Barrett.prototype.convert=function barrettConvert(t){var e;return t.s<0||t.t>2*this.m.t?t.mod(this.m):t.compareTo(this.m)<0?t:(e=nbi(),t.copyTo(e),this.reduce(e),e)},Barrett.prototype.revert=function barrettRevert(t){return t},Barrett.prototype.reduce=function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},Barrett.prototype.mulTo=function barrettMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)},Barrett.prototype.sqrTo=function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)};var u=[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],C=(1<<26)/u[u.length-1];
2
2
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
3
3
  */
4
- function Arcfour(){this.i=0,this.j=0,this.S=new Array}BigInteger.prototype.chunkSize=function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},BigInteger.prototype.toRadix=function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||36<t)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=nbv(n),i=nbi(),s=nbi(),a="";for(this.divRemTo(r,i,s);0<i.signum();)a=(n+s.intValue()).toString(t).substr(1)+a,i.divRemTo(r,i,s);return s.intValue().toString(t)+a},BigInteger.prototype.fromRadix=function bnpFromRadix(t,e){this.fromInt(0);for(var n=this.chunkSize(e=null==e?10:e),r=Math.pow(e,n),i=!1,s=0,a=0,o=0;o<t.length;++o){var h=intAt(t,o);h<0?"-"==t.charAt(o)&&0==this.signum()&&(i=!0):(a=e*a+h,++s>=n&&(this.dMultiply(r),this.dAddOffset(a,0),a=s=0))}0<s&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),i&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),0<r?n[0]&=(1<<r)-1:n[0]=0,this.fromString(n,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(t,e,n){for(var r,i=Math.min(t.t,this.t),s=0;s<i;++s)n[s]=e(this[s],t[s]);if(t.t<this.t){for(r=t.s&this.DM,s=i;s<this.t;++s)n[s]=e(this[s],r);n.t=this.t}else{for(r=this.s&this.DM,s=i;s<t.t;++s)n[s]=e(r,t[s]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(t,e){return t=BigInteger.ONE.shiftLeft(t),this.bitwiseTo(t,e,t),t},BigInteger.prototype.addTo=function bnpAddTo(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,0<r?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(t,e,n){var r,i=Math.min(this.t+t.t,e);for(n.s=0,n.t=i;0<i;)n[--i]=0;for(r=n.t-this.t;i<r;++i)n[i+this.t]=this.am(0,t[i],n,i,0,this.t);for(r=Math.min(t.t,e);i<r;++i)this.am(0,t[i],n,i,0,e-i);n.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(t,e,n){var r=n.t=this.t+t.t- --e;for(n.s=0;0<=--r;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)},BigInteger.prototype.modInt=function bnpModInt(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(0<this.t)if(0==e)n=this[0]%t;else for(var r=this.t-1;0<=r;--r)n=(e*n+this[r])%t;return n},BigInteger.prototype.millerRabin=function bnpMillerRabin(t){var e=this.subtract(BigInteger.ONE),n=e.getLowestSetBit();if(n<=0)return!1;for(var r=e.shiftRight(n),i=(u.length<(t=t+1>>1)&&(t=u.length),nbi()),s=0;s<t;++s){i.fromInt(u[Math.floor(Math.random()*u.length)]);var a=i.modPow(r,this);if(0!=a.compareTo(BigInteger.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<n&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},BigInteger.prototype.clone=
4
+ function Arcfour(){this.i=0,this.j=0,this.S=new Array}BigInteger.prototype.chunkSize=function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},BigInteger.prototype.toRadix=function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||36<t)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=nbv(r),i=nbi(),s=nbi(),a="";for(this.divRemTo(n,i,s);0<i.signum();)a=(r+s.intValue()).toString(t).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(t)+a},BigInteger.prototype.fromRadix=function bnpFromRadix(t,e){this.fromInt(0);for(var r=this.chunkSize(e=null==e?10:e),n=Math.pow(e,r),i=!1,s=0,a=0,o=0;o<t.length;++o){var h=intAt(t,o);h<0?"-"==t.charAt(o)&&0==this.signum()&&(i=!0):(a=e*a+h,++s>=r&&(this.dMultiply(n),this.dAddOffset(a,0),a=s=0))}0<s&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),i&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var r=new Array,n=7&t;r.length=1+(t>>3),e.nextBytes(r),0<n?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(t,e,r){for(var n,i=Math.min(t.t,this.t),s=0;s<i;++s)r[s]=e(this[s],t[s]);if(t.t<this.t){for(n=t.s&this.DM,s=i;s<this.t;++s)r[s]=e(this[s],n);r.t=this.t}else{for(n=this.s&this.DM,s=i;s<t.t;++s)r[s]=e(n,t[s]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(t,e){return t=BigInteger.ONE.shiftLeft(t),this.bitwiseTo(t,e,t),t},BigInteger.prototype.addTo=function bnpAddTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,0<n?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;0<i;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(t,e,r){var n=r.t=this.t+t.t- --e;for(r.s=0;0<=--n;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},BigInteger.prototype.modInt=function bnpModInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(0<this.t)if(0==e)r=this[0]%t;else for(var n=this.t-1;0<=n;--n)r=(e*r+this[n])%t;return r},BigInteger.prototype.millerRabin=function bnpMillerRabin(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=(u.length<(t=t+1>>1)&&(t=u.length),nbi()),s=0;s<t;++s){i.fromInt(u[Math.floor(Math.random()*u.length)]);var a=i.modPow(n,this);if(0!=a.compareTo(BigInteger.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<r&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},BigInteger.prototype.clone=
5
5
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
6
6
  */
7
- function bnClone(){var t=nbi();return this.copyTo(t),t},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){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]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var t,e=this.t,n=new Array,r=(n[0]=this.s,this.DB-e*this.DB%8),i=0;if(0<e--)for(r<this.DB&&(t=this[e]>>r)!=(this.s&this.DM)>>r&&(n[i++]=t|this.s<<this.DB-r);0<=e;)r<8?(t=(this[e]&(1<<r)-1)<<8-r,t|=this[--e]>>(r+=this.DB-8)):(t=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),0!=(128&t)&&(t|=-256),0==i&&(128&this.s)!=(128&t)&&++i,(0<i||t!=this.s)&&(n[i++]=t);return n},BigInteger.prototype.equals=function bnEquals(t){return 0==this.compareTo(t)},BigInteger.prototype.min=function bnMin(t){return this.compareTo(t)<0?this:t},BigInteger.prototype.max=function bnMax(t){return 0<this.compareTo(t)?this:t},BigInteger.prototype.and=function bnAnd(t){var e=nbi();return this.bitwiseTo(t,op_and,e),e},BigInteger.prototype.or=function bnOr(t){var e=nbi();return this.bitwiseTo(t,op_or,e),e},BigInteger.prototype.xor=function bnXor(t){var e=nbi();return this.bitwiseTo(t,op_xor,e),e},BigInteger.prototype.andNot=function bnAndNot(t){var e=nbi();return this.bitwiseTo(t,op_andnot,e),e},BigInteger.prototype.not=function bnNot(){for(var t=nbi(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},BigInteger.prototype.shiftLeft=function bnShiftLeft(t){var e=nbi();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},BigInteger.prototype.shiftRight=function bnShiftRight(t){var e=nbi();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+function lbit(t){var e;return 0==t?-1:((e=0)==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e)}(this[t]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=function cbit(t){for(var e=0;0!=t;)t&=t-1,++e;return e}(this[n]^e);return t},BigInteger.prototype.testBit=function bnTestBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},BigInteger.prototype.setBit=function bnSetBit(t){return this.changeBit(t,op_or)},BigInteger.prototype.clearBit=function bnClearBit(t){return this.changeBit(t,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(t){return this.changeBit(t,op_xor)},BigInteger.prototype.add=function bnAdd(t){var e=nbi();return this.addTo(t,e),e},BigInteger.prototype.subtract=function bnSubtract(t){var e=nbi();return this.subTo(t,e),e},BigInteger.prototype.multiply=function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e},BigInteger.prototype.divide=function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e},BigInteger.prototype.remainder=function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(t){var e=nbi(),n=nbi();return this.divRemTo(t,e,n),new Array(e,n)},BigInteger.prototype.modPow=function bnModPow(t,e){var n=t.bitLength(),r=nbv(1);if(n<=0)return r;var i=n<18?1:n<48?3:n<144?4:n<768?5:6,s=new(n<8?Classic:e.isEven()?Barrett:Montgomery)(e),a=new Array,o=3,h=i-1,u=(1<<i)-1;if(a[1]=s.convert(this),1<i){var c=nbi();for(s.sqrTo(a[1],c);o<=u;)a[o]=nbi(),s.mulTo(c,a[o-2],a[o]),o+=2}for(var l,f,g=t.t-1,p=!0,d=nbi(),n=nbits(t[g])-1;0<=g;){for(h<=n?l=t[g]>>n-h&u:(l=(t[g]&(1<<n+1)-1)<<h-n,0<g&&(l|=t[g-1]>>this.DB+n-h)),o=i;0==(1&l);)l>>=1,--o;if((n-=o)<0&&(n+=this.DB,--g),p)a[l].copyTo(r),p=!1;else{for(;1<o;)s.sqrTo(r,d),s.sqrTo(d,r),o-=2;0<o?s.sqrTo(r,d):(f=r,r=d,d=f),s.mulTo(d,a[l],r)}for(;0<=g&&0==(t[g]&1<<n);)s.sqrTo(r,d),f=r,r=d,d=f,--n<0&&(n=this.DB-1,--g)}return s.revert(r)},BigInteger.prototype.modInverse=function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var n=t.clone(),r=this.clone(),i=nbv(1),s=nbv(0),a=nbv(0),o=nbv(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(i.isEven()&&s.isEven()||(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),e?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(t,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);0<=n.compareTo(r)?(n.subTo(r,n),e&&i.subTo(a,i),s.subTo(o,s)):(r.subTo(n,r),e&&a.subTo(i,a),o.subTo(s,o))}return 0!=r.compareTo(BigInteger.ONE)?BigInteger.ZERO:0<=o.compareTo(t)?o.subtract(t):o.signum()<0&&(o.addTo(t,o),o.signum()<0)?o.add(t):o},BigInteger.prototype.pow=function bnPow(t){return this.exp(t,new NullExp)},BigInteger.prototype.gcd=function bnGCD(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone(),r=(e.compareTo(n)<0&&(t=e,e=n,n=t),e.getLowestSetBit());if((t=n.getLowestSetBit())<0)return e;for(0<(t=r<t?r:t)&&(e.rShiftTo(t,e),n.rShiftTo(t,n));0<e.signum();)0<(r=e.getLowestSetBit())&&e.rShiftTo(r,e),0<(r=n.getLowestSetBit())&&n.rShiftTo(r,n),0<=e.compareTo(n)?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return 0<t&&n.lShiftTo(t,n),n},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(t){var e,n=this.abs();if(1==n.t&&n[0]<=u[u.length-1]){for(e=0;e<u.length;++e)if(n[0]==u[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<u.length;){for(var r=u[e],i=e+1;i<u.length&&r<I;)r*=u[i++];for(r=n.modInt(r);e<i;)if(r%u[e++]==0)return!1}return n.millerRabin(t)},BigInteger.prototype.square=function bnSquare(){var t=nbi();return this.squareTo(t),t},Arcfour.prototype.init=function ARC4init(t){for(var e,n,r=0;r<256;++r)this.S[r]=r;for(r=e=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,n=this.S[r],this.S[r]=this.S[e],this.S[e]=n;this.i=0,this.j=0},Arcfour.prototype.next=function ARC4next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var P,R=256;
7
+ function bnClone(){var t=nbi();return this.copyTo(t),t},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){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]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var t,e=this.t,r=new Array,n=(r[0]=this.s,this.DB-e*this.DB%8),i=0;if(0<e--)for(n<this.DB&&(t=this[e]>>n)!=(this.s&this.DM)>>n&&(r[i++]=t|this.s<<this.DB-n);0<=e;)n<8?(t=(this[e]&(1<<n)-1)<<8-n,t|=this[--e]>>(n+=this.DB-8)):(t=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&t)&&(t|=-256),0==i&&(128&this.s)!=(128&t)&&++i,(0<i||t!=this.s)&&(r[i++]=t);return r},BigInteger.prototype.equals=function bnEquals(t){return 0==this.compareTo(t)},BigInteger.prototype.min=function bnMin(t){return this.compareTo(t)<0?this:t},BigInteger.prototype.max=function bnMax(t){return 0<this.compareTo(t)?this:t},BigInteger.prototype.and=function bnAnd(t){var e=nbi();return this.bitwiseTo(t,op_and,e),e},BigInteger.prototype.or=function bnOr(t){var e=nbi();return this.bitwiseTo(t,op_or,e),e},BigInteger.prototype.xor=function bnXor(t){var e=nbi();return this.bitwiseTo(t,op_xor,e),e},BigInteger.prototype.andNot=function bnAndNot(t){var e=nbi();return this.bitwiseTo(t,op_andnot,e),e},BigInteger.prototype.not=function bnNot(){for(var t=nbi(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},BigInteger.prototype.shiftLeft=function bnShiftLeft(t){var e=nbi();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},BigInteger.prototype.shiftRight=function bnShiftRight(t){var e=nbi();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+function lbit(t){var e;return 0==t?-1:((e=0)==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e)}(this[t]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=function cbit(t){for(var e=0;0!=t;)t&=t-1,++e;return e}(this[r]^e);return t},BigInteger.prototype.testBit=function bnTestBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},BigInteger.prototype.setBit=function bnSetBit(t){return this.changeBit(t,op_or)},BigInteger.prototype.clearBit=function bnClearBit(t){return this.changeBit(t,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(t){return this.changeBit(t,op_xor)},BigInteger.prototype.add=function bnAdd(t){var e=nbi();return this.addTo(t,e),e},BigInteger.prototype.subtract=function bnSubtract(t){var e=nbi();return this.subTo(t,e),e},BigInteger.prototype.multiply=function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e},BigInteger.prototype.divide=function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e},BigInteger.prototype.remainder=function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(t){var e=nbi(),r=nbi();return this.divRemTo(t,e,r),new Array(e,r)},BigInteger.prototype.modPow=function bnModPow(t,e){var r=t.bitLength(),n=nbv(1);if(r<=0)return n;var i=r<18?1:r<48?3:r<144?4:r<768?5:6,s=new(r<8?Classic:e.isEven()?Barrett:Montgomery)(e),a=new Array,o=3,h=i-1,u=(1<<i)-1;if(a[1]=s.convert(this),1<i){var c=nbi();for(s.sqrTo(a[1],c);o<=u;)a[o]=nbi(),s.mulTo(c,a[o-2],a[o]),o+=2}for(var l,f,g=t.t-1,p=!0,d=nbi(),r=nbits(t[g])-1;0<=g;){for(h<=r?l=t[g]>>r-h&u:(l=(t[g]&(1<<r+1)-1)<<h-r,0<g&&(l|=t[g-1]>>this.DB+r-h)),o=i;0==(1&l);)l>>=1,--o;if((r-=o)<0&&(r+=this.DB,--g),p)a[l].copyTo(n),p=!1;else{for(;1<o;)s.sqrTo(n,d),s.sqrTo(d,n),o-=2;0<o?s.sqrTo(n,d):(f=n,n=d,d=f),s.mulTo(d,a[l],n)}for(;0<=g&&0==(t[g]&1<<r);)s.sqrTo(n,d),f=n,n=d,d=f,--r<0&&(r=this.DB-1,--g)}return s.revert(n)},BigInteger.prototype.modInverse=function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var r=t.clone(),n=this.clone(),i=nbv(1),s=nbv(0),a=nbv(0),o=nbv(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&s.isEven()||(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(t,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);0<=r.compareTo(n)?(r.subTo(n,r),e&&i.subTo(a,i),s.subTo(o,s)):(n.subTo(r,n),e&&a.subTo(i,a),o.subTo(s,o))}return 0!=n.compareTo(BigInteger.ONE)?BigInteger.ZERO:0<=o.compareTo(t)?o.subtract(t):o.signum()<0&&(o.addTo(t,o),o.signum()<0)?o.add(t):o},BigInteger.prototype.pow=function bnPow(t){return this.exp(t,new NullExp)},BigInteger.prototype.gcd=function bnGCD(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone(),n=(e.compareTo(r)<0&&(t=e,e=r,r=t),e.getLowestSetBit());if((t=r.getLowestSetBit())<0)return e;for(0<(t=n<t?n:t)&&(e.rShiftTo(t,e),r.rShiftTo(t,r));0<e.signum();)0<(n=e.getLowestSetBit())&&e.rShiftTo(n,e),0<(n=r.getLowestSetBit())&&r.rShiftTo(n,r),0<=e.compareTo(r)?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return 0<t&&r.lShiftTo(t,r),r},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=u[u.length-1]){for(e=0;e<u.length;++e)if(r[0]==u[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<u.length;){for(var n=u[e],i=e+1;i<u.length&&n<C;)n*=u[i++];for(n=r.modInt(n);e<i;)if(n%u[e++]==0)return!1}return r.millerRabin(t)},BigInteger.prototype.square=function bnSquare(){var t=nbi();return this.squareTo(t),t},Arcfour.prototype.init=function ARC4init(t){for(var e,r,n=0;n<256;++n)this.S[n]=n;for(n=e=0;n<256;++n)e=e+this.S[n]+t[n%t.length]&255,r=this.S[n],this.S[n]=this.S[e],this.S[e]=r;this.i=0,this.j=0},Arcfour.prototype.next=function ARC4next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var B,D=256;
8
8
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
9
- */function rng_seed_time(){!function rng_seed_int(t){i[s++]^=255&t,i[s++]^=t>>8&255,i[s++]^=t>>16&255,i[s++]^=t>>24&255,R<=s&&(s-=R)}((new Date).getTime())}if(null==i){var i=new Array,s=0;if(void 0!==t&&(void 0!==t.crypto||void 0!==t.msCrypto)){var c=t.crypto||t.msCrypto;if(c.getRandomValues){var T=new Uint8Array(32);for(c.getRandomValues(T),f=0;f<32;++f)i[s++]=T[f]}else if("Netscape"==y.appName&&y.appVersion<"5")for(var N=t.crypto.random(32),f=0;f<N.length;++f)i[s++]=255&N.charCodeAt(f)}for(;s<R;)f=Math.floor(65536*Math.random()),i[s++]=f>>>8,i[s++]=255&f;s=0,rng_seed_time()}function rng_get_byte(){if(null==P){for(rng_seed_time(),(P=function prng_newstate(){return new Arcfour}()).init(i),s=0;s<i.length;++s)i[s]=0;s=0}return P.next()}function SecureRandom(){}
9
+ */function rng_seed_time(){!function rng_seed_int(t){i[s++]^=255&t,i[s++]^=t>>8&255,i[s++]^=t>>16&255,i[s++]^=t>>24&255,D<=s&&(s-=D)}((new Date).getTime())}if(null==i){var i=new Array,s=0;if(void 0!==t&&(void 0!==t.crypto||void 0!==t.msCrypto)){var c=t.crypto||t.msCrypto;if(c.getRandomValues){var R=new Uint8Array(32);for(c.getRandomValues(R),f=0;f<32;++f)i[s++]=R[f]}else if("Netscape"==y.appName&&y.appVersion<"5")for(var T=t.crypto.random(32),f=0;f<T.length;++f)i[s++]=255&T.charCodeAt(f)}for(;s<D;)f=Math.floor(65536*Math.random()),i[s++]=f>>>8,i[s++]=255&f;s=0,rng_seed_time()}function rng_get_byte(){if(null==B){for(rng_seed_time(),(B=function prng_newstate(){return new Arcfour}()).init(i),s=0;s<i.length;++s)i[s]=0;s=0}return B.next()}function SecureRandom(){}
10
10
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
11
11
  */
12
- function parseBigInt(t,e){return new BigInteger(t,e)}function oaep_mgf1_arr(t,e,n){for(var r="",i=0;r.length<e;)r+=n(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return r}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function oaep_mgf1_str(t,e,n){for(var r="",i=0;r.length<e;)r+=n(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return r}
12
+ function parseBigInt(t,e){return new BigInteger(t,e)}function oaep_mgf1_arr(t,e,r){for(var n="",i=0;n.length<e;)n+=r(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function oaep_mgf1_str(t,e,r){for(var n="",i=0;n.length<e;)n+=r(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return n}
13
13
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
14
14
  */
15
- function ECFieldElementFp(t,e){this.x=e,this.q=t}function ECPointFp(t,e,n,r){this.curve=t,this.x=e,this.y=n,this.z=null==r?BigInteger.ONE:r,this.zinv=null}function ECCurveFp(t,e,n){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(n),this.infinity=new ECPointFp(this,null,null)}SecureRandom.prototype.nextBytes=function rng_get_bytes(t){for(var e=0;e<t.length;++e)t[e]=rng_get_byte()},RSAKey.prototype.doPublic=function RSADoPublic(t){return t.modPowInt(this.e,this.n)},RSAKey.prototype.setPublic=function RSASetPublic(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA public key";this.n=parseBigInt(t,16),this.e=parseInt(e,16)}},RSAKey.prototype.encrypt=function RSAEncrypt(t){return null==(t=function pkcs1pad2(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var n=new Array,r=t.length-1;0<=r&&0<e;){var i=t.charCodeAt(r--);i<128?n[--e]=i:127<i&&i<2048?(n[--e]=63&i|128,n[--e]=i>>6|192):(n[--e]=63&i|128,n[--e]=i>>6&63|128,n[--e]=i>>12|224)}n[--e]=0;for(var s=new SecureRandom,a=new Array;2<e;){for(a[0]=0;0==a[0];)s.nextBytes(a);n[--e]=a[0]}return n[--e]=2,n[--e]=0,new BigInteger(n)}(t,this.n.bitLength()+7>>3))||null==(t=this.doPublic(t))?null:0==(1&(t=t.toString(16)).length)?t:"0"+t},RSAKey.prototype.encryptOAEP=function RSAEncryptOAEP(t,e,n){var r=this.n.bitLength()+7>>3;if(null==(t=function oaep_pad(t,e,n,r){var i,s=D.crypto.MessageDigest,a=D.crypto.Util;if("string"==typeof(n=n||"sha1")&&(i=s.getCanonicalAlgName(n),r=s.getHashLength(i),n=function(t){return hextorstr(a.hashHex(rstrtohex(t),i))}),t.length+2*r+2>e)throw"Message too long for RSA";for(var o="",h=0;h<e-t.length-2*r-2;h+=1)o+="\0";var u=n("")+o+""+t,c=new Array(r),l=((new SecureRandom).nextBytes(c),oaep_mgf1_arr(c,u.length,n)),f=[];for(h=0;h<u.length;h+=1)f[h]=u.charCodeAt(h)^l.charCodeAt(h);var g=oaep_mgf1_arr(f,c.length,n),p=[0];for(h=0;h<c.length;h+=1)p[h+1]=c[h]^g.charCodeAt(h);return new BigInteger(p.concat(f))}(t,r,e,n)))return null;if(null==(e=this.doPublic(t)))return null;for(var i=e.toString(16);i.length<2*r;)i="0"+i;return i},RSAKey.prototype.type="RSA",RSAKey.prototype.doPrivate=function RSADoPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},RSAKey.prototype.setPrivate=function RSASetPrivate(t,e,n){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=n;else{if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA private key";this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(n,16)}},RSAKey.prototype.setPrivateEx=function RSASetPrivateEx(t,e,n,r,i,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA private key in RSASetPrivateEx";this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(n,16),this.p=parseBigInt(r,16),this.q=parseBigInt(i,16),this.dmp1=parseBigInt(s,16),this.dmq1=parseBigInt(a,16),this.coeff=parseBigInt(o,16)},RSAKey.prototype.generate=function RSAGenerate(t,e){for(var n=new SecureRandom,r=t>>1,i=(this.e=parseInt(e,16),new BigInteger(e,16)),s=t/2-100,a=BigInteger.ONE.shiftLeft(s);;){for(;this.p=new BigInteger(t-r,1,n),0!=this.p.subtract(BigInteger.ONE).gcd(i).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(r,1,n),0!=this.q.subtract(BigInteger.ONE).gcd(i).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(o=this.p,this.p=this.q,this.q=o);var o=this.q.subtract(this.p).abs();if(!(o.bitLength()<s||o.compareTo(a)<=0)){var h=this.p.subtract(BigInteger.ONE),u=this.q.subtract(BigInteger.ONE),c=h.multiply(u);if(0==c.gcd(i).compareTo(BigInteger.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=i.modInverse(c),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(u),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},RSAKey.prototype.decrypt=function RSADecrypt(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");return t=parseBigInt(t,16),null==(t=this.doPrivate(t))?null:
15
+ function ECFieldElementFp(t,e){this.x=e,this.q=t}function ECPointFp(t,e,r,n){this.curve=t,this.x=e,this.y=r,this.z=null==n?BigInteger.ONE:n,this.zinv=null}function ECCurveFp(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new ECPointFp(this,null,null)}SecureRandom.prototype.nextBytes=function rng_get_bytes(t){for(var e=0;e<t.length;++e)t[e]=rng_get_byte()},RSAKey.prototype.doPublic=function RSADoPublic(t){return t.modPowInt(this.e,this.n)},RSAKey.prototype.setPublic=function RSASetPublic(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA public key";this.n=parseBigInt(t,16),this.e=parseInt(e,16)}},RSAKey.prototype.encrypt=function RSAEncrypt(t){return null==(t=function pkcs1pad2(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var r=new Array,n=t.length-1;0<=n&&0<e;){var i=t.charCodeAt(n--);i<128?r[--e]=i:127<i&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new SecureRandom,a=new Array;2<e;){for(a[0]=0;0==a[0];)s.nextBytes(a);r[--e]=a[0]}return r[--e]=2,r[--e]=0,new BigInteger(r)}(t,this.n.bitLength()+7>>3))||null==(t=this.doPublic(t))?null:0==(1&(t=t.toString(16)).length)?t:"0"+t},RSAKey.prototype.encryptOAEP=function RSAEncryptOAEP(t,e,r){var n=this.n.bitLength()+7>>3;if(null==(t=function oaep_pad(t,e,r,n){var i,s=P.crypto.MessageDigest,a=P.crypto.Util;if("string"==typeof(r=r||"sha1")&&(i=s.getCanonicalAlgName(r),n=s.getHashLength(i),r=function(t){return hextorstr(a.hashHex(rstrtohex(t),i))}),t.length+2*n+2>e)throw"Message too long for RSA";for(var o="",h=0;h<e-t.length-2*n-2;h+=1)o+="\0";var u=r("")+o+""+t,c=new Array(n),l=((new SecureRandom).nextBytes(c),oaep_mgf1_arr(c,u.length,r)),f=[];for(h=0;h<u.length;h+=1)f[h]=u.charCodeAt(h)^l.charCodeAt(h);var g=oaep_mgf1_arr(f,c.length,r),p=[0];for(h=0;h<c.length;h+=1)p[h+1]=c[h]^g.charCodeAt(h);return new BigInteger(p.concat(f))}(t,n,e,r)))return null;if(null==(e=this.doPublic(t)))return null;for(var i=e.toString(16);i.length<2*n;)i="0"+i;return i},RSAKey.prototype.type="RSA",RSAKey.prototype.doPrivate=function RSADoPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},RSAKey.prototype.setPrivate=function RSASetPrivate(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA private key";this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(r,16)}},RSAKey.prototype.setPrivateEx=function RSASetPrivateEx(t,e,r,n,i,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&0<t.length&&0<e.length))throw"Invalid RSA private key in RSASetPrivateEx";this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(r,16),this.p=parseBigInt(n,16),this.q=parseBigInt(i,16),this.dmp1=parseBigInt(s,16),this.dmq1=parseBigInt(a,16),this.coeff=parseBigInt(o,16)},RSAKey.prototype.generate=function RSAGenerate(t,e){for(var r=new SecureRandom,n=t>>1,i=(this.e=parseInt(e,16),new BigInteger(e,16)),s=t/2-100,a=BigInteger.ONE.shiftLeft(s);;){for(;this.p=new BigInteger(t-n,1,r),0!=this.p.subtract(BigInteger.ONE).gcd(i).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(n,1,r),0!=this.q.subtract(BigInteger.ONE).gcd(i).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(o=this.p,this.p=this.q,this.q=o);var o=this.q.subtract(this.p).abs();if(!(o.bitLength()<s||o.compareTo(a)<=0)){var h=this.p.subtract(BigInteger.ONE),u=this.q.subtract(BigInteger.ONE),c=h.multiply(u);if(0==c.gcd(i).compareTo(BigInteger.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=i.modInverse(c),this.dmp1=this.d.mod(h),this.dmq1=this.d.mod(u),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},RSAKey.prototype.decrypt=function RSADecrypt(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");return t=parseBigInt(t,16),null==(t=this.doPrivate(t))?null:
16
16
  /*! (c) Tom Wu, Kenji Urushima | http://www-cs-students.stanford.edu/~tjw/jsbn/
17
17
  */
18
- function pkcs1unpad2(t,e){for(var n=t.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=e-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var i="";++r<n.length;){var s=255&n[r];s<128?i+=String.fromCharCode(s):191<s&&s<224?(i+=String.fromCharCode((31&s)<<6|63&n[r+1]),++r):(i+=String.fromCharCode((15&s)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return i}(t,this.n.bitLength()+7>>3)},RSAKey.prototype.decryptOAEP=function RSADecryptOAEP(t,e,n){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");return t=parseBigInt(t,16),null==(t=this.doPrivate(t))?null:function oaep_unpad(t,e,n,r){var i,s=D.crypto.MessageDigest,a=D.crypto.Util;for("string"==typeof(n=n||"sha1")&&(i=s.getCanonicalAlgName(n),r=s.getHashLength(i),n=function(t){return hextorstr(a.hashHex(rstrtohex(t),i))}),t=t.toByteArray(),o=0;o<t.length;o+=1)t[o]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*r+2)throw"Cipher too short";var o,h=t.substr(1,r),u=t.substr(r+1),c=oaep_mgf1_str(u,r,n),l=[];for(o=0;o<h.length;o+=1)l[o]=h.charCodeAt(o)^c.charCodeAt(o);var f=oaep_mgf1_str(String.fromCharCode.apply(String,l),t.length-r,n),g=[];for(o=0;o<u.length;o+=1)g[o]=u.charCodeAt(o)^f.charCodeAt(o);if((g=String.fromCharCode.apply(String,g)).substr(0,r)!==n(""))throw"Hash mismatch";if((-1!=(s=(g=g.substr(r)).indexOf(""))?g.substr(0,s).lastIndexOf("\0"):-1)+1!=s)throw"Malformed data";return g.substr(s+1)}(t,this.n.bitLength()+7>>3,e,n)},ECFieldElementFp.prototype.equals=function feFpEquals(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ECFieldElementFp.prototype.toBigInteger=function feFpToBigInteger(){return this.x},ECFieldElementFp.prototype.negate=function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))},ECFieldElementFp.prototype.add=function feFpAdd(t){return new ECFieldElementFp(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.subtract=function feFpSubtract(t){return new ECFieldElementFp(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.multiply=function feFpMultiply(t){return new ECFieldElementFp(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.square=function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))},ECFieldElementFp.prototype.divide=function feFpDivide(t){return new ECFieldElementFp(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ECFieldElementFp.prototype.sqrt=function(){return new ECFieldElementFp(this.q,this.x.sqrt().mod(this.q))},ECPointFp.prototype.getX=function pointFpGetX(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.getY=function pointFpGetY(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.equals=function pointFpEquals(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(BigInteger.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(BigInteger.ZERO))},ECPointFp.prototype.isInfinity=function pointFpIsInfinity(){return null==this.x&&null==this.y||this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)},ECPointFp.prototype.negate=function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)},ECPointFp.prototype.add=function pointFpAdd(t){var e,n,r,i,s,a,o;return this.isInfinity()?t:t.isInfinity()?this:(e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),s=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q),BigInteger.ZERO.equals(s)?BigInteger.ZERO.equals(e)?this.twice():this.curve.getInfinity():(o=new BigInteger("3"),a=this.x.toBigInteger(),n=this.y.toBigInteger(),t.x.toBigInteger(),t.y.toBigInteger(),r=(i=s.square()).multiply(s),a=a.multiply(i),s=(i=e.square().multiply(this.z)).subtract(a.shiftLeft(1)).multiply(t.z).subtract(r).multiply(s).mod(this.curve.q),a=a.multiply(o).multiply(e).subtract(n.multiply(r)).subtract(i.multiply(e)).multiply(t.z).add(e.multiply(r)).mod(this.curve.q),o=r.multiply(this.z).multiply(t.z).mod(this.curve.q),new ECPointFp(this.curve,this.curve.fromBigInteger(s),this.curve.fromBigInteger(a),o)))},ECPointFp.prototype.twice=function pointFpTwice(){var t,e,n,r,i,s;return this.isInfinity()?this:0==this.y.toBigInteger().signum()?this.curve.getInfinity():(i=new BigInteger("3"),s=this.x.toBigInteger(),e=(t=(e=this.y.toBigInteger()).multiply(this.z)).multiply(e).mod(this.curve.q),r=this.curve.a.toBigInteger(),n=s.square().multiply(i),r=(n=(n=BigInteger.ZERO.equals(r)?n:n.add(this.z.square().multiply(r))).mod(this.curve.q)).square().subtract(s.shiftLeft(3).multiply(e)).shiftLeft(1).multiply(t).mod(this.curve.q),i=n.multiply(i).multiply(s).subtract(e.shiftLeft(1)).shiftLeft(2).multiply(e).subtract(n.square().multiply(n)).mod(this.curve.q),s=t.square().multiply(t).shiftLeft(3).mod(this.curve.q),new ECPointFp(this.curve,this.curve.fromBigInteger(r),this.curve.fromBigInteger(i),s))},ECPointFp.prototype.multiply=function pointFpMultiply(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();for(var e=t,n=e.multiply(new BigInteger("3")),r=this.negate(),i=this,s=this.curve.q.subtract(t),a=s.multiply(new BigInteger("3")),o=(c=new ECPointFp(this.curve,this.x,this.y)).negate(),h=n.bitLength()-2;0<h;--h){var i=i.twice(),u=n.testBit(h);u!=e.testBit(h)&&(i=i.add(u?this:r))}for(h=a.bitLength()-2;0<h;--h){var c=c.twice(),l=a.testBit(h);l!=s.testBit(h)&&(c=c.add(l?c:o))}return i},ECPointFp.prototype.multiplyTwo=function pointFpMultiplyTwo(t,e,n){for(var r=t.bitLength()>n.bitLength()?t.bitLength()-1:n.bitLength()-1,i=this.curve.getInfinity(),s=this.add(e);0<=r;)i=i.twice(),t.testBit(r)?i=n.testBit(r)?i.add(s):i.add(this):n.testBit(r)&&(i=i.add(e)),--r;return i},ECCurveFp.prototype.getQ=function curveFpGetQ(){return this.q},ECCurveFp.prototype.getA=function curveFpGetA(){return this.a},ECCurveFp.prototype.getB=function curveFpGetB(){return this.b},ECCurveFp.prototype.equals=function curveFpEquals(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ECCurveFp.prototype.getInfinity=function curveFpGetInfinity(){return this.infinity},ECCurveFp.prototype.fromBigInteger=function curveFpFromBigInteger(t){return new ECFieldElementFp(this.q,t)},ECCurveFp.prototype.decodePointHex=function curveFpDecodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),n=(t.substr(2),this.fromBigInteger(new BigInteger(s,16))),r=this.getA(),i=this.getB(),r=n.square().add(r).multiply(n).add(i).sqrt();return new ECPointFp(this,n,r="03"==e?r.negate():r);case 4:case 6:case 7:var i=(t.length-2)/2,s=t.substr(2,i),n=t.substr(2+i,i);return new ECPointFp(this,this.fromBigInteger(new BigInteger(s,16)),this.fromBigInteger(new BigInteger(n,16)));default:return null}},
18
+ function pkcs1unpad2(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):191<s&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(t,this.n.bitLength()+7>>3)},RSAKey.prototype.decryptOAEP=function RSADecryptOAEP(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");return t=parseBigInt(t,16),null==(t=this.doPrivate(t))?null:function oaep_unpad(t,e,r,n){var i,s=P.crypto.MessageDigest,a=P.crypto.Util;for("string"==typeof(r=r||"sha1")&&(i=s.getCanonicalAlgName(r),n=s.getHashLength(i),r=function(t){return hextorstr(a.hashHex(rstrtohex(t),i))}),t=t.toByteArray(),o=0;o<t.length;o+=1)t[o]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*n+2)throw"Cipher too short";var o,h=t.substr(1,n),u=t.substr(n+1),c=oaep_mgf1_str(u,n,r),l=[];for(o=0;o<h.length;o+=1)l[o]=h.charCodeAt(o)^c.charCodeAt(o);var f=oaep_mgf1_str(String.fromCharCode.apply(String,l),t.length-n,r),g=[];for(o=0;o<u.length;o+=1)g[o]=u.charCodeAt(o)^f.charCodeAt(o);if((g=String.fromCharCode.apply(String,g)).substr(0,n)!==r(""))throw"Hash mismatch";if((-1!=(s=(g=g.substr(n)).indexOf(""))?g.substr(0,s).lastIndexOf("\0"):-1)+1!=s)throw"Malformed data";return g.substr(s+1)}(t,this.n.bitLength()+7>>3,e,r)},ECFieldElementFp.prototype.equals=function feFpEquals(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ECFieldElementFp.prototype.toBigInteger=function feFpToBigInteger(){return this.x},ECFieldElementFp.prototype.negate=function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))},ECFieldElementFp.prototype.add=function feFpAdd(t){return new ECFieldElementFp(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.subtract=function feFpSubtract(t){return new ECFieldElementFp(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.multiply=function feFpMultiply(t){return new ECFieldElementFp(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.square=function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))},ECFieldElementFp.prototype.divide=function feFpDivide(t){return new ECFieldElementFp(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ECFieldElementFp.prototype.sqrt=function(){return new ECFieldElementFp(this.q,this.x.sqrt().mod(this.q))},ECPointFp.prototype.getX=function pointFpGetX(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.getY=function pointFpGetY(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.equals=function pointFpEquals(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(BigInteger.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(BigInteger.ZERO))},ECPointFp.prototype.isInfinity=function pointFpIsInfinity(){return null==this.x&&null==this.y||this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)},ECPointFp.prototype.negate=function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)},ECPointFp.prototype.add=function pointFpAdd(t){var e,r,n,i,s,a,o;return this.isInfinity()?t:t.isInfinity()?this:(e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),s=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q),BigInteger.ZERO.equals(s)?BigInteger.ZERO.equals(e)?this.twice():this.curve.getInfinity():(o=new BigInteger("3"),a=this.x.toBigInteger(),r=this.y.toBigInteger(),t.x.toBigInteger(),t.y.toBigInteger(),n=(i=s.square()).multiply(s),a=a.multiply(i),s=(i=e.square().multiply(this.z)).subtract(a.shiftLeft(1)).multiply(t.z).subtract(n).multiply(s).mod(this.curve.q),a=a.multiply(o).multiply(e).subtract(r.multiply(n)).subtract(i.multiply(e)).multiply(t.z).add(e.multiply(n)).mod(this.curve.q),o=n.multiply(this.z).multiply(t.z).mod(this.curve.q),new ECPointFp(this.curve,this.curve.fromBigInteger(s),this.curve.fromBigInteger(a),o)))},ECPointFp.prototype.twice=function pointFpTwice(){var t,e,r,n,i,s;return this.isInfinity()?this:0==this.y.toBigInteger().signum()?this.curve.getInfinity():(i=new BigInteger("3"),s=this.x.toBigInteger(),e=(t=(e=this.y.toBigInteger()).multiply(this.z)).multiply(e).mod(this.curve.q),n=this.curve.a.toBigInteger(),r=s.square().multiply(i),n=(r=(r=BigInteger.ZERO.equals(n)?r:r.add(this.z.square().multiply(n))).mod(this.curve.q)).square().subtract(s.shiftLeft(3).multiply(e)).shiftLeft(1).multiply(t).mod(this.curve.q),i=r.multiply(i).multiply(s).subtract(e.shiftLeft(1)).shiftLeft(2).multiply(e).subtract(r.square().multiply(r)).mod(this.curve.q),s=t.square().multiply(t).shiftLeft(3).mod(this.curve.q),new ECPointFp(this.curve,this.curve.fromBigInteger(n),this.curve.fromBigInteger(i),s))},ECPointFp.prototype.multiply=function pointFpMultiply(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();for(var e=t,r=e.multiply(new BigInteger("3")),n=this.negate(),i=this,s=this.curve.q.subtract(t),a=s.multiply(new BigInteger("3")),o=(c=new ECPointFp(this.curve,this.x,this.y)).negate(),h=r.bitLength()-2;0<h;--h){var i=i.twice(),u=r.testBit(h);u!=e.testBit(h)&&(i=i.add(u?this:n))}for(h=a.bitLength()-2;0<h;--h){var c=c.twice(),l=a.testBit(h);l!=s.testBit(h)&&(c=c.add(l?c:o))}return i},ECPointFp.prototype.multiplyTwo=function pointFpMultiplyTwo(t,e,r){for(var n=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1,i=this.curve.getInfinity(),s=this.add(e);0<=n;)i=i.twice(),t.testBit(n)?i=r.testBit(n)?i.add(s):i.add(this):r.testBit(n)&&(i=i.add(e)),--n;return i},ECCurveFp.prototype.getQ=function curveFpGetQ(){return this.q},ECCurveFp.prototype.getA=function curveFpGetA(){return this.a},ECCurveFp.prototype.getB=function curveFpGetB(){return this.b},ECCurveFp.prototype.equals=function curveFpEquals(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ECCurveFp.prototype.getInfinity=function curveFpGetInfinity(){return this.infinity},ECCurveFp.prototype.fromBigInteger=function curveFpFromBigInteger(t){return new ECFieldElementFp(this.q,t)},ECCurveFp.prototype.decodePointHex=function curveFpDecodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new BigInteger(s,16))),n=this.getA(),i=this.getB(),n=r.square().add(n).multiply(r).add(i).sqrt();return new ECPointFp(this,r,n="03"==e?n.negate():n);case 4:case 6:case 7:var i=(t.length-2)/2,s=t.substr(2,i),r=t.substr(2+i,i);return new ECPointFp(this,this.fromBigInteger(new BigInteger(s,16)),this.fromBigInteger(new BigInteger(r,16)));default:return null}},
19
19
  /*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib
20
20
  */
21
- ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(t){function Gk(t,e){var n=t.toByteArrayUnsigned();if(e<n.length)n=n.slice(n.length-e);else for(;e>n.length;)n.unshift(0);return n}var e=this.getX().toBigInteger(),n=this.getY().toBigInteger(),e=Gk(e,32);return t?n.isEven()?e.unshift(2):e.unshift(3):(e.unshift(4),e=e.concat(Gk(n,32))),e},ECPointFp.decodeFrom=function(t,e){e[0];var n=e.length-1,r=e.slice(1,1+n/2),e=e.slice(1+n/2,1+n),n=(r.unshift(0),e.unshift(0),new BigInteger(r)),r=new BigInteger(e);return new ECPointFp(t,t.fromBigInteger(n),t.fromBigInteger(r))},ECPointFp.decodeFromHex=function(t,e){e.substr(0,2);var n=e.length-2,r=e.substr(2,n/2),e=e.substr(2+n/2,n/2),n=new BigInteger(r,16),r=new BigInteger(e,16);return new ECPointFp(t,t.fromBigInteger(n),t.fromBigInteger(r))},ECPointFp.prototype.add2D=function(t){var e;return this.isInfinity()?t:t.isInfinity()?this:this.x.equals(t.x)?this.y.equals(t.y)?this.twice():this.curve.getInfinity():(e=t.x.subtract(this.x),t=(e=t.y.subtract(this.y).divide(e)).square().subtract(this.x).subtract(t.x),e=e.multiply(this.x.subtract(t)).subtract(this.y),new ECPointFp(this.curve,t,e))},ECPointFp.prototype.twice2D=function(){var t,e;return this.isInfinity()?this:0==this.y.toBigInteger().signum()?this.curve.getInfinity():(t=this.curve.fromBigInteger(BigInteger.valueOf(2)),e=this.curve.fromBigInteger(BigInteger.valueOf(3)),t=(e=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t))).square().subtract(this.x.multiply(t)),e=e.multiply(this.x.subtract(t)).subtract(this.y),new ECPointFp(this.curve,t,e))},ECPointFp.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();for(var e=t,n=e.multiply(new BigInteger("3")),r=this.negate(),i=this,s=n.bitLength()-2;0<s;--s){var i=i.twice(),a=n.testBit(s);a!=e.testBit(s)&&(i=i.add2D(a?this:r))}return i},ECPointFp.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),n=this.curve.getA().toBigInteger(),r=this.curve.getB().toBigInteger(),i=this.curve.getQ(),e=e.multiply(e).mod(i),n=t.multiply(t).multiply(t).add(n.multiply(t)).add(r).mod(i);return e.equals(n)},ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ECPointFp.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),n=this.getY().toBigInteger();if(e.compareTo(BigInteger.ONE)<0||0<e.compareTo(t.subtract(BigInteger.ONE)))throw new Error("x coordinate out of bounds");if(n.compareTo(BigInteger.ONE)<0||0<n.compareTo(t.subtract(BigInteger.ONE)))throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};
21
+ ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(t){function Fk(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r}var e=this.getX().toBigInteger(),r=this.getY().toBigInteger(),e=Fk(e,32);return t?r.isEven()?e.unshift(2):e.unshift(3):(e.unshift(4),e=e.concat(Fk(r,32))),e},ECPointFp.decodeFrom=function(t,e){e[0];var r=e.length-1,n=e.slice(1,1+r/2),e=e.slice(1+r/2,1+r),r=(n.unshift(0),e.unshift(0),new BigInteger(n)),n=new BigInteger(e);return new ECPointFp(t,t.fromBigInteger(r),t.fromBigInteger(n))},ECPointFp.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,n=e.substr(2,r/2),e=e.substr(2+r/2,r/2),r=new BigInteger(n,16),n=new BigInteger(e,16);return new ECPointFp(t,t.fromBigInteger(r),t.fromBigInteger(n))},ECPointFp.prototype.add2D=function(t){var e;return this.isInfinity()?t:t.isInfinity()?this:this.x.equals(t.x)?this.y.equals(t.y)?this.twice():this.curve.getInfinity():(e=t.x.subtract(this.x),t=(e=t.y.subtract(this.y).divide(e)).square().subtract(this.x).subtract(t.x),e=e.multiply(this.x.subtract(t)).subtract(this.y),new ECPointFp(this.curve,t,e))},ECPointFp.prototype.twice2D=function(){var t,e;return this.isInfinity()?this:0==this.y.toBigInteger().signum()?this.curve.getInfinity():(t=this.curve.fromBigInteger(BigInteger.valueOf(2)),e=this.curve.fromBigInteger(BigInteger.valueOf(3)),t=(e=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t))).square().subtract(this.x.multiply(t)),e=e.multiply(this.x.subtract(t)).subtract(this.y),new ECPointFp(this.curve,t,e))},ECPointFp.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();for(var e=t,r=e.multiply(new BigInteger("3")),n=this.negate(),i=this,s=r.bitLength()-2;0<s;--s){var i=i.twice(),a=r.testBit(s);a!=e.testBit(s)&&(i=i.add2D(a?this:n))}return i},ECPointFp.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),e=e.multiply(e).mod(i),r=t.multiply(t).multiply(t).add(r.multiply(t)).add(n).mod(i);return e.equals(r)},ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ECPointFp.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(BigInteger.ONE)<0||0<e.compareTo(t.subtract(BigInteger.ONE)))throw new Error("x coordinate out of bounds");if(r.compareTo(BigInteger.ONE)<0||0<r.compareTo(t.subtract(BigInteger.ONE)))throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};
22
22
  /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval
23
23
  */
24
- var D,H,g,O=function(){var f=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),g=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(t,e,n){return e?r[e]:String.fromCharCode(parseInt(n,16))}var p=new String(""),d=(Object,Array,Object.hasOwnProperty);return function(t,o){for(var e,n,u,r,i=t.match(f),s=i[0],t=!1,a=("{"===s?r={}:"["===s?r=[]:(r=[],t=!0),[r]),c=1-t,l=i.length;c<l;++c)switch((s=i[c]).charCodeAt(0)){default:(n=a[0])[e||n.length]=+s,e=void 0;break;case 34:if(-1!==(s=s.substring(1,s.length-1)).indexOf("\\")&&(s=s.replace(g,h)),n=a[0],!e){if(!(n instanceof Array)){e=s||p;break}e=n.length}n[e]=s,e=void 0;break;case 91:n=a[0],a.unshift(n[e||n.length]=[]),e=void 0;break;case 93:a.shift();break;case 102:(n=a[0])[e||n.length]=!1,e=void 0;break;case 110:(n=a[0])[e||n.length]=null,e=void 0;break;case 116:(n=a[0])[e||n.length]=!0,e=void 0;break;case 123:n=a[0],a.unshift(n[e||n.length]={}),e=void 0;break;case 125:a.shift()}if(t){if(1!==a.length)throw new Error;r=r[0]}else if(a.length)throw new Error;return r=o?(u=function(t,e){var n=t[e];if(n&&"object"==typeof n){var r,i,s=null;for(r in n)d.call(n,r)&&n!==t&&(void 0!==(i=u(n,r))?n[r]=i:(s=s||[]).push(r));if(s)for(var a=s.length;0<=--a;)delete n[s[a]]}return o.call(t,e,n)})({"":r},""):r}}(),E=(void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),D.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){t=t.toString(16);return t=t.length%2==1?"0"+t:t},this.bigIntToMinTwosComplementsHex=function(t){if("-"!=(i=t.toString(16)).substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{for(var e=i.substr(1).length,n=(e%2==1?e+=1:i.match(/^[0-7]/)||(e+=2),""),r=0;r<e;r++)n+="f";var i=new BigInteger(n,16).xor(t).add(BigInteger.ONE).toString(16).replace(/^-/,"")}return i},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=D.asn1,n=e.ASN1Object,r=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,g=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,x=e.DERBMPString,v=e.DERSequence,S=e.DERSet,E=e.DERTaggedObject,b=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;e=Object.keys(t);if(1!=e.length)throw new Error("key of param shall be only one.");e=e[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+e+":"))throw new Error("undefined key: "+e);if("bool"==e)return new r(t[e]);if("int"==e)return new i(t[e]);if("bitstr"==e)return new s(t[e]);if("octstr"==e)return new a(t[e]);if("null"==e)return new o(t[e]);if("oid"==e)return new h(t[e]);if("enum"==e)return new u(t[e]);if("utf8str"==e)return new c(t[e]);if("numstr"==e)return new l(t[e]);if("prnstr"==e)return new f(t[e]);if("telstr"==e)return new g(t[e]);if("ia5str"==e)return new p(t[e]);if("utctime"==e)return new d(t[e]);if("gentime"==e)return new m(t[e]);if("visstr"==e)return new y(t[e]);if("bmpstr"==e)return new x(t[e]);if("asn1"==e)return new n(t[e]);if("seq"==e){for(var F=t[e],w=[],A=0;A<F.length;A++){var I=b(F[A]);w.push(I)}return new v({array:w})}if("set"!=e)return"tag"==e?(r=t[e],"[object Array]"===Object.prototype.toString.call(r)&&3==r.length?(i=b(r[2]),new E({tag:r[0],explicit:r[1],obj:i})):new E(r)):void 0;for(F=t[e],w=[],A=0;A<F.length;A++){I=b(F[A]);w.push(I)}return new S({array:w})},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},D.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),e=Math.floor(n/40)+"."+n%40,r="",i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);r+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new BigInteger(r,2).toString(10),r="")}return e},D.asn1.ASN1Util.oidIntToHex=function(t){function mn(t){return t=1==(t=t.toString(16)).length?"0"+t:t}if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",n=t.split("."),t=40*parseInt(n[0])+parseInt(n[1]);e+=mn(t),n.splice(0,2);for(var r=0;r<n.length;r++)e+=function(t){for(var e="",n=7-(s=new BigInteger(t,10).toString(2)).length%7,r=(7==n&&(n=0),""),i=0;i<n;i++)r+="0";for(var s=r+s,i=0;i<s.length-1;i+=7){var a=s.substr(i,7);i!=s.length-7&&(a="1"+a),e+=mn(parseInt(a,2))}return e}(n[r]);return e},D.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var n=e.length/2;if(15<n)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+n).toString(16)+e},this.tohex=function(){return null!=this.hTLV&&!this.isModified||(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},D.asn1.DERAbstractString=function(t){D.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=utf8tohex(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},extendClass(D.asn1.DERAbstractString,D.asn1.ASN1Object),D.asn1.DERAbstractTime=function(t){D.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){t=t.getTime()+6e4*t.getTimezoneOffset();return new Date(t)},this.formatDate=function(t,e,n){var r=this.zeroPadding,t=this.localDateToUTC(t),i=String(t.getFullYear()),e=("utc"==e&&(i=i.substr(2,2)),r(String(t.getMonth()+1),2)),i=i+e+r(String(t.getDate()),2)+r(String(t.getHours()),2)+r(String(t.getMinutes()),2)+r(String(t.getSeconds()),2);return(i=!0===n&&0!=(e=t.getMilliseconds())?i+"."+r(String(e),3).replace(/[0]+$/,""):i)+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,n,r,i,s){t=new Date(Date.UTC(t,e-1,n,r,i,s,0));this.setByDate(t)},this.getFreshValueHex=function(){return this.hV}},extendClass(D.asn1.DERAbstractTime,D.asn1.ASN1Object),D.asn1.DERAbstractStructured=function(t){D.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},extendClass(D.asn1.DERAbstractStructured,D.asn1.ASN1Object),D.asn1.DERBoolean=function(t){D.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},extendClass(D.asn1.DERBoolean,D.asn1.ASN1Object),D.asn1.DERInteger=function(t){D.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var n=D.asn1.ASN1Util.bigIntToMinTwosComplementsHex;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,e=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)this.hV=t.hex;else{if("number"==typeof t)e=new BigInteger(String(t),10);else if(null!=t.int)e=new BigInteger(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");e=t.bigint}this.hV=n(e)}return this.hV},null!=t&&(this.params=t)},extendClass(D.asn1.DERInteger,D.asn1.ASN1Object),D.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=D.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.tohex()),D.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;t="0"+t;this.hTLV=null,this.isModified=!0,this.hV=t+e},this.setByBinaryString=function(t){for(var e=8-(t=t.replace(/0+$/,"")).length%8,n=(t+="0000000".substr(0,e=8==e?0:e),""),r=0;r<t.length-1;r+=8){var i=t.substr(r,8),i=parseInt(i,2).toString(16);n+=i=1==i.length?"0"+i:i}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},extendClass(D.asn1.DERBitString,D.asn1.ASN1Object),D.asn1.DEROctetString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=D.asn1.ASN1Util.newObject(t.obj),t.hex=e.tohex()),D.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},extendClass(D.asn1.DEROctetString,D.asn1.DERAbstractString),D.asn1.DERNull=function(){D.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},extendClass(D.asn1.DERNull,D.asn1.ASN1Object),D.asn1.DERObjectIdentifier=function(t){D.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=oidtohex(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=D.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.DERObjectIdentifier,D.asn1.ASN1Object),D.asn1.DEREnumerated=function(t){D.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=D.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){t=new BigInteger(String(t),10);this.setByBigInteger(t)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},extendClass(D.asn1.DEREnumerated,D.asn1.ASN1Object),D.asn1.DERUTF8String=function(t){D.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},extendClass(D.asn1.DERUTF8String,D.asn1.DERAbstractString),D.asn1.DERNumericString=function(t){D.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},extendClass(D.asn1.DERNumericString,D.asn1.DERAbstractString),D.asn1.DERPrintableString=function(t){D.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},extendClass(D.asn1.DERPrintableString,D.asn1.DERAbstractString),D.asn1.DERTeletexString=function(t){D.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},extendClass(D.asn1.DERTeletexString,D.asn1.DERAbstractString),D.asn1.DERIA5String=function(t){D.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},extendClass(D.asn1.DERIA5String,D.asn1.DERAbstractString),D.asn1.DERVisibleString=function(t){D.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},extendClass(D.asn1.DERVisibleString,D.asn1.DERAbstractString),D.asn1.DERBMPString=function(t){D.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},extendClass(D.asn1.DERBMPString,D.asn1.DERAbstractString),D.asn1.DERUTCTime=function(t){D.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t,e=this.params;if("string"==typeof(e=null==this.params?{date:new Date}:e)){if(!e.match(/^[0-9]{12}Z$/)&&!e.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+e);this.hV=stohex(e)}else null!=e.str?this.hV=stohex(e.str):null==e.date&&1==e.millis?(t=new Date,this.hV=stohex(this.formatDate(t,"utc",!0))):null!=e.date&&e.date instanceof Date?(t=!0===e.millis,this.hV=stohex(this.formatDate(e.date,"utc",t))):e instanceof Date&&(this.hV=stohex(this.formatDate(e,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},extendClass(D.asn1.DERUTCTime,D.asn1.DERAbstractTime),D.asn1.DERGeneralizedTime=function(t){D.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t,e=this.params;if("string"==typeof(e=null==this.params?{date:new Date}:e)){if(!e.match(/^[0-9]{14}Z$/)&&!e.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+e);this.hV=stohex(e)}else null!=e.str?this.hV=stohex(e.str):null==e.date&&1==e.millis?(t=new Date,this.hV=stohex(this.formatDate(t,"gen",!0))):null!=e.date&&e.date instanceof Date?(t=!0===e.millis,this.hV=stohex(this.formatDate(e.date,"gen",t))):e instanceof Date&&(this.hV=stohex(this.formatDate(e,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},extendClass(D.asn1.DERGeneralizedTime,D.asn1.DERAbstractTime),D.asn1.DERSequence=function(t){D.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].tohex();return this.hV=t,this.hV}},extendClass(D.asn1.DERSequence,D.asn1.DERAbstractStructured),D.asn1.DERSet=function(t){D.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.tohex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},extendClass(D.asn1.DERSet,D.asn1.DERAbstractStructured),D.asn1.DERTaggedObject=function(t){D.asn1.DERTaggedObject.superclass.constructor.call(this);var n=D.asn1,r=E.getV,i=(E.isASN1HEX,n.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,n){this.params={tag:e,explicit:t,obj:n}},this.getFreshValueHex=function(){var t,e=this.params;if(null==e.explicit&&(e.explicit=!0),null!=e.tage&&(e.tag=e.tage,e.explicit=!0),null!=e.tagi&&(e.tag=e.tagi,e.explicit=!1),null!=e.str)this.hV=utf8tohex(e.str);else if(null!=e.hex)this.hV=e.hex;else{if(null==e.obj)throw new Error("str, hex nor obj not specified");e.obj instanceof n.ASN1Object?t=e.obj.tohex():"object"==typeof e.obj&&(t=i(e.obj).tohex()),e.explicit?this.hV=t:this.hV=r(t,0)}return null==e.tag&&(e.tag="a0"),this.hT=e.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.DERTaggedObject,D.asn1.ASN1Object),new function(){});function stoBA(t){for(var e=new Array,n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function BAtohex(t){for(var e="",n=0;n<t.length;n++){var r=t[n].toString(16);e+=r=1==r.length?"0"+r:r}return e}function stohex(t){return BAtohex(stoBA(t))}function b64tob64u(t){return t=(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function b64utob64(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function hextob64u(t){return b64tob64u(hex2b64(t=t.length%2==1?"0"+t:t))}function b64utohex(t){return b64tohex(b64utob64(t))}function utf8tohex(t){return uricmptohex(encodeURIComponentAll(t)).toLowerCase()}function hextoutf8(t){try{return decodeURIComponent(hextouricmp(t))}catch(t){return null}}function iso88591hextoutf8(t){return hextoutf8(function iso88591hextoutf8hex(t){for(var e=t.match(/.{1,2}/g),n=[],r=0;r<e.length;r++){var i=parseInt(e[r],16);161<=i&&i<=191?(n.push("c2"),n.push(e[r])):192<=i&&i<=255?(n.push("c3"),n.push((i-64).toString(16))):n.push(e[r])}return n.join("")}(t))}function hextorstr(t){for(var e="",n=0;n<t.length-1;n+=2)e+=String.fromCharCode(parseInt(t.substr(n,2),16));return e}function rstrtohex(t){for(var e="",n=0;n<t.length;n++)e+=("0"+t.charCodeAt(n).toString(16)).slice(-2);return e}function hextob64(t){return hex2b64(t)}function foldnl(t,e){return t=(t=t.replace(new RegExp("(.{"+e+"})","g"),"$1\r\n")).replace(/\s+$/,"")}function b64nltohex(t){return b64tohex(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}function hextopem(t,e){return"-----BEGIN "+e+"-----\r\n"+foldnl(hextob64(t),64)+"\r\n-----END "+e+"-----\r\n"}function pemtohex(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return b64nltohex(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function zulutomsec(t){var e,n,r,i,s,a,o,h;if(h=(t=timetogen(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(h[1]),n=parseInt(h[2])-1,r=parseInt(h[3]),i=parseInt(h[4]),s=parseInt(h[5]),a=parseInt(h[6]),o=0,""!==(h=h[7])&&(h=(h.substr(1)+"00").substr(0,3),o=parseInt(h)),Date.UTC(e,n,r,i,s,a,o);throw new Error("unsupported zulu format: "+t)}function zulutosec(t){return Math.round(zulutomsec(t)/1e3)}function timetogen(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}function uricmptohex(t){return t.replace(/%/g,"")}function hextouricmp(t){return t.replace(/(..)/g,"%$1")}function ipv6tohex(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var n=(t=t.toLowerCase()).split(":").length-1;if(n<2)throw e;var n=":".repeat(7-n+2),r=(t=t.replace("::",n)).split(":");if(8!=r.length)throw e;for(var i=0;i<8;i++)r[i]=("0000"+r[i]).slice(-4);return r.join("")}function hextoipv6(t){var e;if(t.match(/^[0-9A-Fa-f]{32}$/))return null==(e=(t=":"+(t=t.toLowerCase()).match(/.{1,4}/g).map(function(t){return t.replace(/^0+/,"")}).map(function(t){return""==t?"0":t}).join(":")+":").match(/:(0:){2,}/g))?t.slice(1,-1):(e=e.sort().slice(-1)[0],"::"!=(t="::"!=(t=t.replace(e.substr(0,e.length-1),":")).substr(0,2)?t.substr(1):t).substr(-2,2)?t.substr(0,t.length-1):t);throw new Error("malformed IPv6 address: "+t)}function hextoip(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}else if(16==t.length)try{return hextoip(t.substr(0,8))+"/"+ipprefixlen(t.substr(8))}catch(t){throw e}else{if(32==t.length)return hextoipv6(t);if(64!=t.length)return t;try{return hextoipv6(t.substr(0,32))+"/"+ipprefixlen(t.substr(32))}catch(t){throw e}}}function ipprefixlen(t){var e,n=new Error("malformed mask");try{e=new BigInteger(t,16).toString(2)}catch(t){throw n}if(e.match(/^1*0*$/))return e.replace(/0+$/,"").length;throw n}function iptohex(t){var e,n=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw n;if(!t.match(/^[0-9.]+$/)){if(t.match(/^[0-9.]+\/[0-9]+$/))return iptohex((e=t.split("/"))[0])+ipnetmask(parseInt(e[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return ipv6tohex(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return ipv6tohex((e=t.split("/"))[0])+ipnetmask(parseInt(e[1]),128);throw n}var r=t.split(".");if(4!==r.length)throw n;var i="";try{for(var s=0;s<4;s++)i+=("0"+parseInt(r[s]).toString(16)).slice(-2);return i}catch(t){throw n}}function ipnetmask(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new BigInteger(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function ucs2hextoutf8(t){return t.match(/.{4}/g).map(function e(t){var n,r=parseInt(t.substr(0,2),16),t=parseInt(t.substr(2),16);return 0==r&t<128?String.fromCharCode(t):r<8?(n=128|63&t,hextoutf8((192|(7&r)<<3|(192&t)>>6).toString(16)+n.toString(16))):(n=128|(15&r)<<2|(192&t)>>6,t=128|63&t,hextoutf8((224|(240&r)>>4).toString(16)+n.toString(16)+t.toString(16)))}).join("")}function encodeURIComponentAll(t){for(var e=encodeURIComponent(t),n="",r=0;r<e.length;r++)"%"==e[r]?(n+=e.substr(r,3),r+=2):n=n+"%"+stohex(e[r]);return n}function ishex(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function isBase64URLDot(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function hextoposhex(t){return t.length%2==1?"0"+t:"7"<t.substr(0,1)?"00"+t:t}E.getLblen=function(t,e){return"8"!=t.substr(e+2,1)?1:0==(t=parseInt(t.substr(e+3,1)))?-1:0<t&&t<10?t+1:-2},E.getL=function(t,e){var n=E.getLblen(t,e);return n<1?"":t.substr(e+2,2*n)},E.getVblen=function(t,e){t=E.getL(t,e);return""==t?-1:("8"===t.substr(0,1)?new BigInteger(t.substr(2),16):new BigInteger(t,16)).intValue()},E.getVidx=function(t,e){t=E.getLblen(t,e);return t<0?t:e+2*(t+1)},E.getV=function(t,e){var n=E.getVidx(t,e),e=E.getVblen(t,e);return t.substr(n,2*e)},E.getTLV=function(t,e){return t.substr(e,2)+E.getL(t,e)+E.getV(t,e)},E.getTLVblen=function(t,e){return 2+2*E.getLblen(t,e)+2*E.getVblen(t,e)},E.getNextSiblingIdx=function(t,e){return E.getVidx(t,e)+2*E.getVblen(t,e)},E.getChildIdx=function(t,e){var n=E,r=[],i=n.getVidx(t,e),s=2*n.getVblen(t,e);"03"==t.substr(e,2)&&(i+=2,s-=2);for(var a=0,o=i;a<=s;){var h=n.getTLVblen(t,o);if((a+=h)<=s&&r.push(o),o+=h,s<=a)break}return r},E.getNthChildIdx=function(t,e,n){return E.getChildIdx(t,e)[n]},E.getIdxbyList=function(t,e,n,r){var i,s=E;return 0==n.length?void 0!==r&&t.substr(e,2)!==r?-1:e:(i=n.shift())>=(e=s.getChildIdx(t,e)).length?-1:s.getIdxbyList(t,e[i],n,r)},E.getIdxbyListEx=function(t,e,n,r){var i=E;if(0==n.length)return void 0!==r&&t.substr(e,2)!==r?-1:e;for(var s=n.shift(),a=i.getChildIdx(t,e),o=0,h=0;h<a.length;h++){var u=t.substr(a[h],2);if("number"==typeof s&&!i.isContextTag(u)&&o==s||"string"==typeof s&&i.isContextTag(u,s))return i.getIdxbyListEx(t,a[h],n,r);i.isContextTag(u)||o++}return-1},E.getTLVbyList=function(t,e,n,r){var i=E,e=i.getIdxbyList(t,e,n,r);return-1==e||e>=t.length?null:i.getTLV(t,e)},E.getTLVbyListEx=function(t,e,n,r){var i=E,e=i.getIdxbyListEx(t,e,n,r);return-1==e?null:i.getTLV(t,e)},E.getVbyList=function(t,e,n,r,i){var s=E,e=s.getIdxbyList(t,e,n,r);return-1==e||e>=t.length?null:(n=s.getV(t,e),!0===i?n.substr(2):n)},E.getVbyListEx=function(t,e,n,r,i){var s=E,e=s.getIdxbyListEx(t,e,n,r);return-1==e?null:(n=s.getV(t,e),"03"==t.substr(e,2)&&!1!==i?n.substr(2):n)},E.getInt=function(t,e,n){null==n&&(n=-1);try{var r,i=t.substr(e,2);return"02"!=i&&"03"!=i?n:(r=E.getV(t,e),"02"==i?parseInt(r,16):bitstrtoint(r))}catch(t){return n}},E.getOID=function(t,e,n){null==n&&(n=null);try{return"06"!=t.substr(e,2)?n:hextooid(E.getV(t,e))}catch(t){return n}},E.getOIDName=function(t,e,n){null==n&&(n=null);try{var r,i=E.getOID(t,e,n);return i==n?n:""==(r=D.asn1.x509.OID.oid2name(i))?i:r}catch(t){return n}},E.getString=function(t,e,n){null==n&&(n=null);try{return hextorstr(E.getV(t,e))}catch(t){return n}},E.hextooidstr=function(t){function Wr(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}for(var e=[],n=t.substr(0,2),n=parseInt(n,16),r=(e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40),t.substr(2)),i=[],s=0;s<r.length/2;s++)i.push(parseInt(r.substr(2*s,2),16));for(var a=[],o="",s=0;s<i.length;s++)128&i[s]?o+=Wr((127&i[s]).toString(2),7):(o+=Wr((127&i[s]).toString(2),7),a.push(new String(parseInt(o,2))),o="");n=e.join(".");return n=0<a.length?n+"."+a.join("."):n},E.dump=function(t,e,n,r){function ps(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)}var i=E,s=i.getV,a=i.dump,o=i.getChildIdx,h=t,t=(t instanceof D.asn1.ASN1Object&&(h=t.tohex()),void 0===r&&(r=""),(e=void 0===e?{ommit_long_octet:32}:e).ommit_long_octet),u=h.substr(n=void 0===n?0:n,2);if("01"==u)return"00"==(d=s(h,n))?r+"BOOLEAN FALSE\n":r+"BOOLEAN TRUE\n";if("02"==u)return r+"INTEGER "+ps(d=s(h,n),t)+"\n";if("03"==u)return d=s(h,n),i.isASN1HEX(d.substr(2))?(l=r+"BITSTRING, encapsulates\n")+a(d.substr(2),e,0,r+" "):r+"BITSTRING "+ps(d,t)+"\n";if("04"==u)return d=s(h,n),i.isASN1HEX(d)?(l=r+"OCTETSTRING, encapsulates\n")+a(d,e,0,r+" "):r+"OCTETSTRING "+ps(d,t)+"\n";if("05"==u)return r+"NULL\n";if("06"==u)return t=s(h,n),t=D.asn1.ASN1Util.oidHexToInt(t),c=D.asn1.x509.OID.oid2name(t),t=t.replace(/\./g," "),""!=c?r+"ObjectIdentifier "+c+" ("+t+")\n":r+"ObjectIdentifier ("+t+")\n";if("0a"==u)return r+"ENUMERATED "+parseInt(s(h,n))+"\n";if("0c"==u)return r+"UTF8String '"+hextoutf8(s(h,n))+"'\n";if("13"==u)return r+"PrintableString '"+hextoutf8(s(h,n))+"'\n";if("14"==u)return r+"TeletexString '"+hextoutf8(s(h,n))+"'\n";if("16"==u)return r+"IA5String '"+hextoutf8(s(h,n))+"'\n";if("17"==u)return r+"UTCTime "+hextoutf8(s(h,n))+"\n";if("18"==u)return r+"GeneralizedTime "+hextoutf8(s(h,n))+"\n";if("1a"==u)return r+"VisualString '"+hextoutf8(s(h,n))+"'\n";if("1e"==u)return r+"BMPString '"+ucs2hextoutf8(s(h,n))+"'\n";if("30"==u){if("3000"==h.substr(n,4))return r+"SEQUENCE {}\n";var c,l=r+"SEQUENCE\n",f=e;2!=(p=o(h,n)).length&&3!=p.length||"06"!=h.substr(p[0],2)||"04"!=h.substr(p[p.length-1],2)||(c=i.oidname(s(h,p[0])),(t=JSON.parse(JSON.stringify(e))).x509ExtName=c,f=t);for(var g=0;g<p.length;g++)l+=a(h,f,p[g],r+" ")}else if("31"==u)for(var l=r+"SET\n",p=o(h,n),g=0;g<p.length;g++)l+=a(h,e,p[g],r+" ");else{if(0==(128&(u=parseInt(u,16))))return r+"UNKNOWN("+u+") "+s(h,n)+"\n";var d,i=31&u;if(0==(32&u))return d=s(h,n),E.isASN1HEX(d)?(l=r+"["+i+"]\n")+a(d,e,0,r+" "):r+"["+i+"] "+(d="68747470"==d.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==i?hextoutf8(d):d)+"\n";for(var l=r+"["+i+"]\n",p=o(h,n),g=0;g<p.length;g++)l+=a(h,e,p[g],r+" ")}return l},E.parse=function(t){var e,s=E.parse,n=E.isASN1HEX,r=E.getV,a=E.getTLV,o=E.getChildIdx,i=D.asn1,h=i.ASN1Util.oidHexToInt,i=i.x509.OID.oid2name,u=hextoutf8,c=ucs2hextoutf8,l=iso88591hextoutf8,f={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},g=t.substr(0,2),p={},r=r(t,0);if("01"==g)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==g)return{int:{hex:r}};if("03"==g)try{if("00"==r.substr(0,2)){var d=r.substr(2);if(n(d))return{bitstr:{obj:s(d)}}}throw"not encap"}catch(t){var d=null;return null==(d=r.length<=10?bitstrtobinstr(r):d)?{bitstr:{hex:r}}:{bitstr:{bin:d}}}else if("04"==g)try{if(n(r))return{octstr:{obj:s(r)}};throw"not encap"}catch(t){return{octstr:{hex:r}}}else{if("05"==g)return{null:""};if("06"==g)return""==(i=i(d=h(r)))?{oid:d}:{oid:i};if("0a"==g)return 4<r.length?{enum:{hex:r}}:{enum:parseInt(r,16)};if("30"==g||"31"==g)return p[f[g]]=function(t){for(var e=[],n=o(t,0),r=0;r<n.length;r++){var i=n[r],i=a(t,i),i=s(i);e.push(i)}return e}(t),p;if("14"==g)return e=l(r),p[f[g]]={str:e},p;if("1e"==g)return e=c(r),p[f[g]]={str:e},p;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(g))return e=u(r),p[f[g]]={str:e},p;if(g.match(/^8[0-9]$/))return null==(e=u(r))|""==e||null!=e.match(/[\x00-\x1F\x7F-\x9F]/)||null!=e.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:g,explicit:!1,hex:r}}:{tag:{tag:g,explicit:!1,str:e}};if(!g.match(/^a[0-9]$/))return(h=new D.asn1.ASN1Object).hV=r,{asn1:{tlv:g+h.getLengthHexFromValue()+r}};try{if(n(r))return{tag:{tag:g,explicit:!0,obj:s(r)}};throw new Error("not encap")}catch(t){return{tag:{tag:g,explicit:!0,hex:r}}}}},E.isContextTag=function(t,e){var n,r;t=t.toLowerCase();try{n=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&n);try{return null==e.match(/^\[[0-9]+\]$/)?!1:!(31<(r=parseInt(e.substr(1,e.length-1),10)))&&128==(192&n)&&(31&n)==r}catch(t){return!1}},E.isASN1HEX=function(t){var e,n,r=E;return t.length%2!=1&&(e=r.getVblen(t,0),n=t.substr(0,2),r=r.getL(t,0),t.length-n.length-r.length==2*e)},E.checkStrictDER=function(t,e,n,r,i){var s=E;if(void 0===n){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!D.lang.String.isHex(t))throw new Error("not hex string");n=t.length,i=(r=t.length/2)<128?1:Math.ceil(r.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(r<a)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),h=o.length-2-s.getL(t,e).length;if(h!=2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);h=t.substr(e,2);if("02"===h){a=s.getVidx(t,e);if("00"==t.substr(a,2)&&t.charCodeAt(a+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var o=s.getVblen(t,e),u=0,c=s.getChildIdx(t,e),l=0;l<c.length;l++)u+=s.getTLV(t,c[l]).length,s.checkStrictDER(t,c[l],n,r,i);if(2*o!=u)throw new Error("sum of children's TLV length and L unmatch: "+2*o+"!="+u)}},E.oidname=function(t){var e=D.asn1,e=(D.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t)),e.x509.OID.oid2name(t));return e=""===e?t:e},void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),void 0!==D.asn1.x509&&D.asn1.x509||(D.asn1.x509={}),D.asn1.x509.Certificate=function(t){D.asn1.x509.Certificate.superclass.constructor.call(this);var e=D.asn1,n=e.DERBitString,r=e.DERSequence,e=e.x509,i=e.TBSCertificate,s=e.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg,n=(null!=t.sigalg.name&&(e=t.sigalg.name),t.tbsobj.tohex()),e=new D.crypto.Signature({alg:e});e.init(t.cakey),e.updateHex(n),t.sighex=e.sign()},this.getPEM=function(){return hextopem(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new i(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},extendClass(D.asn1.x509.Certificate,D.asn1.ASN1Object),D.asn1.x509.TBSCertificate=function(t){D.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=D.asn1,n=e.x509,r=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,a=n.AlgorithmIdentifier,o=n.Time,h=n.X500Name,u=n.Extensions,c=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e=[],n=this.params;return null==n.version&&1==n.version||(t=2,null!=n.version&&(t=n.version-1),t=new r({obj:new i({int:t})}),e.push(t)),e.push(new i(n.serial)),e.push(new a({name:n.sigalg})),e.push(new h(n.issuer)),e.push(new s({array:[new o(n.notbefore),new o(n.notafter)]})),e.push(new h(n.subject)),e.push(new c(b.getKey(n.sbjpubkey))),void 0!==n.ext&&0<n.ext.length&&e.push(new r({tag:"a3",obj:new u(n.ext)})),new D.asn1.DERSequence({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.TBSCertificate,D.asn1.ASN1Object),D.asn1.x509.Extensions=function(t){D.asn1.x509.Extensions.superclass.constructor.call(this);var e=D.asn1,s=e.DERSequence,a=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var n=this.aParam[e],r=n.extname,i=null;if(null!=n.extn)i=new a.PrivateExtension(n);else if("subjectKeyIdentifier"==r)i=new a.SubjectKeyIdentifier(n);else if("keyUsage"==r)i=new a.KeyUsage(n);else if("subjectAltName"==r)i=new a.SubjectAltName(n);else if("issuerAltName"==r)i=new a.IssuerAltName(n);else if("basicConstraints"==r)i=new a.BasicConstraints(n);else if("nameConstraints"==r)i=new a.NameConstraints(n);else if("cRLDistributionPoints"==r)i=new a.CRLDistributionPoints(n);else if("certificatePolicies"==r)i=new a.CertificatePolicies(n);else if("policyMappings"==r)i=new a.PolicyMappings(n);else if("policyConstraints"==r)i=new a.PolicyConstraints(n);else if("inhibitAnyPolicy"==r)i=new a.InhibitAnyPolicy(n);else if("authorityKeyIdentifier"==r)i=new a.AuthorityKeyIdentifier(n);else if("extKeyUsage"==r)i=new a.ExtKeyUsage(n);else if("authorityInfoAccess"==r)i=new a.AuthorityInfoAccess(n);else if("cRLNumber"==r)i=new a.CRLNumber(n);else if("cRLReason"==r)i=new a.CRLReason(n);else if("ocspNonce"==r)i=new a.OCSPNonce(n);else if("ocspNoCheck"==r)i=new a.OCSPNoCheck(n);else if("adobeTimeStamp"==r)i=new a.AdobeTimeStamp(n);else{if("subjectDirectoryAttributes"!=r)throw new Error("extension not supported:"+JSON.stringify(n));i=new a.SubjectDirectoryAttributes(n)}null!=i&&t.push(i)}return new s({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.x509.Extensions,D.asn1.ASN1Object),D.asn1.x509.Extension=function(t){D.asn1.x509.Extension.superclass.constructor.call(this);var e=D.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),a=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),n=new Array;return n.push(t),this.critical&&n.push(new s),n.push(e),new a({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},extendClass(D.asn1.x509.Extension,D.asn1.ASN1Object),D.asn1.x509.KeyUsage=function(t){D.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,n={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new D.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return namearraytobinstr(t.names,n);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.KeyUsage,D.asn1.x509.Extension),D.asn1.x509.BasicConstraints=function(t){D.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=D.asn1,n=e.DERBoolean,r=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array,t=(this.cA&&t.push(new n),-1<this.pathLen&&t.push(new r({int:this.pathLen})),new i({array:t}));return this.asn1ExtnValue=t,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen)&&(this.pathLen=t.pathLen)},extendClass(D.asn1.x509.BasicConstraints,D.asn1.x509.Extension),D.asn1.x509.CRLDistributionPoints=function(t){D.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var i=D.asn1,s=i.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var e,n=[],r=0;r<t.length;r++)t[r]instanceof D.asn1.ASN1Object?n.push(t[r]):(e=new s.DistributionPoint(t[r]),n.push(e));this.asn1ExtnValue=new i.DERSequence({array:n})},this.setByOneURI=function(t){t=new s.DistributionPoint({fulluri:t});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},extendClass(D.asn1.x509.CRLDistributionPoints,D.asn1.x509.Extension),D.asn1.x509.DistributionPoint=function(t){D.asn1.x509.DistributionPoint.superclass.constructor.call(this);var n=D.asn1,e=n.x509.DistributionPointName;this.tohex=function(){var t,e=new n.DERSequence;return null!=this.asn1DP&&(t=new n.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP}),e.appendASN1Object(t)),this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new e(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new e({full:[{uri:t.fulluri}]})))},extendClass(D.asn1.x509.DistributionPoint,D.asn1.ASN1Object),D.asn1.x509.DistributionPointName=function(t){D.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=D.asn1,n=e.DERTaggedObject;if(this.tohex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new n({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},extendClass(D.asn1.x509.DistributionPointName,D.asn1.ASN1Object),D.asn1.x509.CertificatePolicies=function(t){D.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=D.asn1,n=e.x509,r=e.DERSequence,i=n.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var n=new r({array:t});return this.asn1ExtnValue=n,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.CertificatePolicies,D.asn1.x509.Extension),D.asn1.x509.PolicyInformation=function(t){D.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=D.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],n=0;n<this.params.array.length;n++)e.push(new s(this.params.array[n]));0<e.length&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.PolicyInformation,D.asn1.ASN1Object),D.asn1.x509.PolicyQualifierInfo=function(t){D.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=D.asn1,n=e.DERSequence,r=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new n({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new r({str:this.params.cps})]}).tohex():null!=this.params.unotice?new n({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.PolicyQualifierInfo,D.asn1.ASN1Object),D.asn1.x509.UserNotice=function(t){D.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=D.asn1.DERSequence,n=(D.asn1.DERInteger,D.asn1.x509.DisplayText),r=D.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new r(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new n(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.UserNotice,D.asn1.ASN1Object),D.asn1.x509.NoticeReference=function(t){D.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var i=D.asn1.DERSequence,s=D.asn1.DERInteger,a=D.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new a(this.params.org)),void 0!==this.params.noticenum){for(var e=[],n=this.params.noticenum,r=0;r<n.length;r++)e.push(new s(n[r]));t.push(new i({array:e}))}if(0==t.length)throw new Error("parameter is empty");return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.NoticeReference,D.asn1.ASN1Object),D.asn1.x509.DisplayText=function(t){D.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},extendClass(D.asn1.x509.DisplayText,D.asn1.DERAbstractString),D.asn1.x509.PolicyMappings=function(t){D.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=D.asn1,i=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],n=0;n<t.array.length;n++){var r=t.array[n];e.push({seq:[{oid:r[0]},{oid:r[1]}]})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.PolicyMappings,D.asn1.x509.Extension),D.asn1.x509.PolicyConstraints=function(t){D.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=D.asn1,n=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=n({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.PolicyConstraints,D.asn1.x509.Extension),D.asn1.x509.InhibitAnyPolicy=function(t){D.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=D.asn1,n=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=n({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.InhibitAnyPolicy,D.asn1.x509.Extension),D.asn1.x509.NameConstraints=function(t){D.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=D.asn1,n=e.x509,s=e.ASN1Util.newObject,a=n.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var n=[],r=0;r<t.permit.length;r++)n.push(new a(t.permit[r]));e.push({tag:{tagi:"a0",obj:{seq:n}}})}if(null!=t.exclude&&null!=t.exclude.length){for(var i=[],r=0;r<t.exclude.length;r++)i.push(new a(t.exclude[r]));e.push({tag:{tagi:"a1",obj:{seq:i}}})}return this.asn1ExtnValue=s({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.NameConstraints,D.asn1.x509.Extension),D.asn1.x509.GeneralSubtree=function(t){D.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=D.asn1,n=e.x509.GeneralName,r=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new n(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.GeneralSubtree,D.asn1.ASN1Object),D.asn1.x509.ExtKeyUsage=function(t){D.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var r=D.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new r.DERSequence;for(var e=0;e<t.length;e++){var n=new r.DERObjectIdentifier(t[e]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},extendClass(D.asn1.x509.ExtKeyUsage,D.asn1.x509.Extension),D.asn1.x509.AuthorityKeyIdentifier=function(t){D.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=D,n=e.asn1,r=n.DERTaggedObject,i=n.x509.GeneralNames;e.crypto.Util.isKey;this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array,t=(this.asn1KID&&t.push(new r({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new r({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new r({explicit:!1,tag:"82",obj:this.asn1CertSN})),new n.DERSequence({array:t}));return this.asn1ExtnValue=t,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){var e;void 0!==t.str||void 0!==t.hex?this.asn1KID=new D.asn1.DEROctetString(t):("object"==typeof t&&D.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN "))&&("string"==typeof(e=t)&&(e=b.getKey(t)),t=b.getKeyID(e),this.asn1KID=new D.asn1.DEROctetString({hex:t}))},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new D.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new D.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){var e;void 0!==t.str||void 0!==t.bigint||void 0!==t.hex?this.asn1CertSN=new D.asn1.DERInteger(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")&&((e=new X509).readCertPEM(t),t=e.getSerialNumberHex(),this.asn1CertSN=new D.asn1.DERInteger({hex:t}))},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn)&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn))},extendClass(D.asn1.x509.AuthorityKeyIdentifier,D.asn1.x509.Extension),D.asn1.x509.SubjectKeyIdentifier=function(t){D.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var n=D.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){var e;void 0!==t.str||void 0!==t.hex?this.asn1KID=new n(t):("object"==typeof t&&D.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN"))&&("string"==typeof(e=t)&&(e=b.getKey(t)),t=b.getKeyID(e),this.asn1KID=new D.asn1.DEROctetString({hex:t}))},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},extendClass(D.asn1.x509.SubjectKeyIdentifier,D.asn1.x509.Extension),D.asn1.x509.AuthorityInfoAccess=function(t){D.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,n=D.asn1,r=n.DERSequence,i=n.DERObjectIdentifier,s=n.x509.GeneralName,a=0;a<t.length;a++){var o,h=t[a];if(void 0!==h.ocsp)o=new r({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));o=new r({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:h.caissuer})]})}e.push(o)}this.asn1ExtnValue=new r({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},extendClass(D.asn1.x509.AuthorityInfoAccess,D.asn1.x509.Extension),D.asn1.x509.SubjectAltName=function(t){D.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new D.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},extendClass(D.asn1.x509.SubjectAltName,D.asn1.x509.Extension),D.asn1.x509.IssuerAltName=function(t){D.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new D.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},extendClass(D.asn1.x509.IssuerAltName,D.asn1.x509.Extension),D.asn1.x509.SubjectDirectoryAttributes=function(t){D.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=D.asn1,s=e.DERSequence,a=e.ASN1Util.newObject,o=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var n=this.params.array[e];if(null!=n.attr&&null!=n.array){var r={seq:[{oid:n.attr},{set:n.array}]};t.push(a(r))}else{r={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==n.attr)r.seq[0].oid=o(n.attr),r.seq[1].set[0]={gentime:n.str};else if("placeOfBirth"==n.attr)r.seq[0].oid=o(n.attr),r.seq[1].set[0]={utf8str:n.str};else{if("gender"!=n.attr&&"countryOfCitizenship"!=n.attr&&"countryOfResidence"!=n.attr)throw new Error("unsupported attribute: "+n.attr);r.seq[0].oid=o(n.attr),r.seq[1].set[0]={prnstr:n.str}}t.push(new a(r))}}var i=new s({array:t});return this.asn1ExtnValue=i,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},extendClass(D.asn1.x509.SubjectDirectoryAttributes,D.asn1.x509.Extension),D.asn1.x509.PrivateExtension=function(t){D.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=D,n=e.lang.String.isHex,e=e.asn1,r=e.x509.OID.name2oid,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=r(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&n(t))return t;if("object"==typeof t)try{return i(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},extendClass(D.asn1.x509.PrivateExtension,D.asn1.x509.Extension),D.asn1.x509.CRL=function(t){D.asn1.x509.CRL.superclass.constructor.call(this);var e=D.asn1,n=e.DERSequence,r=e.DERBitString,e=e.x509,i=e.AlgorithmIdentifier,s=e.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new D.crypto.Signature({alg:this.params.sigalg}),t=(e.init(this.params.cakey),e.updateHex(t),e.sign());this.params.sighex=t},this.getPEM=function(){return hextopem(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new i({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},extendClass(D.asn1.x509.CRL,D.asn1.ASN1Object),D.asn1.x509.TBSCertList=function(t){D.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=D.asn1,i=e.DERInteger,s=e.DERSequence,r=e.DERTaggedObject,e=(e.DERObjectIdentifier,e.x509),a=e.AlgorithmIdentifier,o=e.Time,h=e.Extensions,u=e.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,n=0;n<e.length;n++){var r=[new i(e[n].sn),new o(e[n].date)];null!=e[n].ext&&r.push(new h(e[n].ext)),t.push(new s({array:r}))}return new s({array:t})},this.tohex=function(){var t,e=[],n=this.params;return null!=n.version&&(t=n.version-1,t=new i({int:t}),e.push(t)),e.push(new a({name:n.sigalg})),e.push(new u(n.issuer)),e.push(new o(n.thisupdate)),null!=n.nextupdate&&e.push(new o(n.nextupdate)),null!=n.revcert&&e.push(this.getRevCertSequence()),null!=n.ext&&(t=new h(n.ext),e.push(new r({tag:"a0",explicit:!0,obj:t}))),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.TBSCertList,D.asn1.ASN1Object),D.asn1.x509.CRLEntry=function(t){D.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=D.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn)&&this.setCertSerial(t.sn)},extendClass(D.asn1.x509.CRLEntry,D.asn1.ASN1Object),D.asn1.x509.CRLNumber=function(t){D.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new D.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},extendClass(D.asn1.x509.CRLNumber,D.asn1.x509.Extension),D.asn1.x509.CRLReason=function(t){D.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new D.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},extendClass(D.asn1.x509.CRLReason,D.asn1.x509.Extension),D.asn1.x509.OCSPNonce=function(t){D.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new D.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},extendClass(D.asn1.x509.OCSPNonce,D.asn1.x509.Extension),D.asn1.x509.OCSPNoCheck=function(t){D.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new D.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},extendClass(D.asn1.x509.OCSPNoCheck,D.asn1.x509.Extension),D.asn1.x509.AdobeTimeStamp=function(t){D.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=D.asn1,n=e.DERInteger,r=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new n(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new r(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.AdobeTimeStamp,D.asn1.x509.Extension),D.asn1.x509.X500Name=function(t){D.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var r=D.asn1,n=r.x509,a=n.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);for(var n,r=t.split("/"),i=(r.shift(),[]),s=0;s<r.length;s++)r[s].match(/^[^=]+=.+$/)?i.push(r[s]):i[n=i.length-1]=i[n]+"/"+r[s];for(s=0;s<i.length;s++)this.asn1Array.push(new a({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);t=n.X500Name.ldapToCompat(t);this.setByString(t,e)},this.setByObject=function(t,e){for(var n in void 0!==e&&(this.sRule=e),t)t.hasOwnProperty(n)&&(n=new a({str:n+"="+t[n],rule:this.sRule}),this.asn1Array?this.asn1Array.push(n):this.asn1Array=[n])},this.setByParam=function(t){var e;void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new X509).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new X509).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=function(){if("string"!=typeof this.hTLV){if(0==this.asn1Array.length&&0<this.paramArray.length)for(var t=0;t<this.paramArray.length;t++){var e={array:this.paramArray[t]},e=("utf8"!=this.sRule&&(e.rule=this.sRule),new a(e));this.asn1Array.push(e)}var n=new r.DERSequence({array:this.asn1Array});this.hTLV=n.tohex()}return this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.X500Name,D.asn1.ASN1Object),D.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";t=(t=t.substr(1)).split("/");return t.reverse(),(t=t.map(function(t){return t.replace(/,/,"\\,")})).join(",")},D.asn1.x509.X500Name.onelineToLDAP=function(t){return D.asn1.x509.X500Name.compatToLDAP(t)},D.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),n=!1,r=[];0<e.length;){var i,s=e.shift();!0===n?(i=(r.pop()+","+s).replace(/\\,/g,","),r.push(i),n=!1):r.push(s),"\\"===s.substr(-1,1)&&(n=!0)}return(r=r.map(function(t){return t.replace("/","\\/")})).reverse(),"/"+r.join("/")},D.asn1.x509.X500Name.ldapToOneline=function(t){return D.asn1.x509.X500Name.ldapToCompat(t)},D.asn1.x509.RDN=function(t){D.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var r=D.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new D.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=D.asn1.x509.RDN.parseString(t),n=0;n<e.length;n++)this.addByString(e[n])},this.tohex=function(){if(0==this.asn1Array.length&&0<this.paramArray.length)for(var t=0;t<this.paramArray.length;t++){var e=this.paramArray[t],e=(void 0!==e.rule&&"utf8"!=this.sRule&&(e.rule=this.sRule),new r(e));this.asn1Array.push(e)}var n=new D.asn1.DERSet({array:this.asn1Array});return this.TLV=n.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.RDN,D.asn1.ASN1Object),D.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),n=!1,r=[];0<e.length;){var i=e.shift();!0===n?(h=(r.pop()+"+"+i).replace(/\\\+/g,"+"),r.push(h),n=!1):r.push(i),"\\"===i.substr(-1,1)&&(n=!0)}for(var s=!1,a=[];0<r.length;){var o,h,i=r.shift();!0===s?(o=a.pop(),i.match(/"$/)?(h=(o+"+"+i).replace(/^([^=]+)="(.*)"$/,"$1=$2"),a.push(h),s=!1):a.push(o+"+"+i)):a.push(i),i.match(/^[^=]+="/)&&(s=!0)}return a},D.asn1.x509.AttributeTypeAndValue=function(t){D.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=D,n=e.asn1,r=n.DERSequence,i=n.DERUTF8String,s=n.DERPrintableString,a=n.DERTeletexString,o=n.DERIA5String,h=n.DERVisibleString,u=n.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);e=t.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(e[1],e[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,n=this.sRule;return"prn"===n?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===n?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,n){void 0!==n&&(this.sRule=n),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=D.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),t=new r({array:[t,e]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.AttributeTypeAndValue,D.asn1.ASN1Object),D.asn1.x509.SubjectPublicKeyInfo=function(t){D.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=D,n=e.asn1,i=n.DERInteger,s=n.DERBitString,a=n.DERObjectIdentifier,r=n.DERSequence,o=n.ASN1Util.newObject,h=n.x509.AlgorithmIdentifier,n=e.crypto;n.ECDSA,n.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new r({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{var e;t instanceof RSAKey&&(e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex(),this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e}))}catch(t){}try{t instanceof D.crypto.ECDSA&&(n=new a({name:t.curveName}),this.asn1AlgId=new h({name:"ecPublicKey",asn1params:n}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex}))}catch(t){}try{var n,r;t instanceof D.crypto.DSA&&(n=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new h({name:"dsa",asn1params:n}),r=new i({bigint:t.y}),this.asn1SubjPKey=new s({hex:"00"+r.tohex()}))}catch(t){}},void 0!==t&&this.setPubKey(t)},extendClass(D.asn1.x509.SubjectPublicKeyInfo,D.asn1.ASN1Object),D.asn1.x509.Time=function(t){D.asn1.x509.Time.superclass.constructor.call(this);var e=D.asn1,n=e.DERUTCTime,r=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if(null==(t="string"==typeof t?{str:t}:t)||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new n(t.str)),"gen"==t.type&&(e=new r(t.str))):e=new("gen"==this.type?r:n),null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},D.asn1.x509.Time_bak=function(t){D.asn1.x509.Time_bak.superclass.constructor.call(this);var e=D.asn1,n=e.DERUTCTime,r=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null,t=null!=this.timeParams?new("utc"==this.type?n:r)(this.timeParams):new("utc"==this.type?n:r);return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/))&&(this.type="gen"),this.timeParams=t)},extendClass(D.asn1.x509.Time,D.asn1.ASN1Object),D.asn1.x509.AlgorithmIdentifier=function(t){D.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var r=D.asn1,i=r.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t,e=null;for(t in i)t===this.nameAlg&&(e=i[t]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var n=[this.asn1Alg],n=(null!==this.asn1Params&&n.push(this.asn1Params),new r.DERSequence({array:n}));return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty)&&(this.paramEmpty=t.paramempty),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg&&(void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name),"withdsa"!==(t=this.nameAlg.toLowerCase()).substr(-7,7))&&"withecdsa"!==t.substr(-9,9)&&(this.asn1Params=new r.DERNull)},extendClass(D.asn1.x509.AlgorithmIdentifier,D.asn1.ASN1Object),D.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},D.asn1.x509.GeneralName=function(t){D.asn1.x509.GeneralName.superclass.constructor.call(this);var e=D.asn1,n=e.x509,u=n.X500Name,c=n.OtherName,l=e.DERIA5String,f=(e.DERPrintableString,e.DEROctetString),g=e.DERTaggedObject,p=e.ASN1Object,d=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e=this.params,n=!1;if(void 0!==e.other)r="a0",t=new c(e.other);else if(void 0!==e.rfc822)r="81",t=new l({str:e.rfc822});else if(void 0!==e.dns)r="82",t=new l({str:e.dns});else if(void 0!==e.dn)r="a4",n=!0,t="string"==typeof e.dn?new u({str:e.dn}):e.dn instanceof D.asn1.x509.X500Name?e.dn:new u(e.dn);else if(void 0!==e.ldapdn)r="a4",n=!0,t=new u({ldapstr:e.ldapdn});else if(void 0!==e.certissuer||void 0!==e.certsubj){var r="a4",i=(n=!0,null);if((s=void 0!==e.certsubj?(o=!1,e.certsubj):(o=!0,e.certissuer)).match(/^[0-9A-Fa-f]+$/),null==(i=-1!=s.indexOf("-----BEGIN ")?pemtohex(s):i))throw new Error("certsubj/certissuer not cert");var s=new X509;s.hex=i,i=o?s.getIssuerHex():s.getSubjectHex(),(t=new p).hTLV=i}else if(void 0!==e.uri)r="86",t=new l({str:e.uri});else{if(void 0===e.ip)throw new d("improper params");r="87";var a,o=e.ip;try{if(o.match(/^[0-9a-f]+$/)){var h=o.length;if(8!=h&&16!=h&&32!=h&&64!=h)throw"err";a=o}else a=iptohex(o)}catch(t){throw new d("malformed IP address: "+e.ip+":"+t.message)}t=new f({hex:a})}return new g({tag:r,explicit:n,obj:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.GeneralName,D.asn1.ASN1Object),D.asn1.x509.GeneralNames=function(t){D.asn1.x509.GeneralNames.superclass.constructor.call(this);var r=D.asn1;this.setByParamArray=function(t){for(var e=0;e<t.length;e++){var n=new r.x509.GeneralName(t[e]);this.asn1Array.push(n)}},this.tohex=function(){return new r.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},extendClass(D.asn1.x509.GeneralNames,D.asn1.ASN1Object),D.asn1.x509.OtherName=function(t){D.asn1.x509.OtherName.superclass.constructor.call(this);var e=D.asn1,n=e.DERObjectIdentifier,r=e.DERSequence,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new n({oid:t.oid}),t=i({tag:{tag:"a0",explicit:!0,obj:t.value}});return new r({array:[e,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.x509.OtherName,D.asn1.ASN1Object),D.asn1.x509.OID=new function(){var n=D.asn1.DERObjectIdentifier;this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",secp521r1:"1.3.132.0.35",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",GN:"2.5.4.42",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.objCache={},this.name2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],e=new n({oid:e});return this.objCache[t]=e},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw new Error("AttributeType name undefined: "+t);e=this.name2oidList[t]}var e=new n({oid:e});return this.objCache[t]=e},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0==e.length?!1:(e.map(function(t,e,n){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},D.asn1.x509.OID.oid2name=function(t){var e,n=D.asn1.x509.OID.name2oidList;for(e in n)if(n[e]==t)return e;return""},D.asn1.x509.OID.oid2atype=function(t){var e,n=D.asn1.x509.OID.atype2oidList;for(e in n)if(n[e]==t)return e;return t},D.asn1.x509.OID.name2oid=function(t){var e;return t.match(/^[0-9.]+$/)?t:void 0===(e=D.asn1.x509.OID.name2oidList)[t]?"":e[t]},D.asn1.x509.X509Util={},D.asn1.x509.X509Util.newCertPEM=function(t){var e=D.asn1.x509;e.TBSCertificate;return new e.Certificate(t).getPEM()},void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),void 0!==D.asn1.cms&&D.asn1.cms||(D.asn1.cms={}),D.asn1.cms.Attribute=function(t){var e=Error,n=D.asn1,r=n.DERSequence,i=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new s({oid:this.typeOid}),e=new i({array:this.getValueArray()});return new r({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},extendClass(D.asn1.cms.Attribute,D.asn1.ASN1Object),D.asn1.cms.ContentType=function(t){var e=D.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.ContentType,D.asn1.cms.Attribute),D.asn1.cms.MessageDigest=function(t){var e=D.asn1,n=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new n(this.params)]},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.MessageDigest,D.asn1.cms.Attribute),D.asn1.cms.SigningTime=function(t){var e=D.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.SigningTime,D.asn1.cms.Attribute),D.asn1.cms.SigningCertificate=function(s){var a=Error,t=D,e=t.asn1,o=e.DERSequence,e=e.cms,h=e.ESSCertID;t.crypto;e.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new a("parameter 'array' not specified");for(var t=this.params.array,e=[],n=0;n<t.length;n++){var r=t[n];0!=(r=0!=s.hasis||"string"!=typeof r||-1==r.indexOf("-----BEGIN")&&!E.isASN1HEX(r)?r:{cert:r}).hasis&&0==s.hasis&&(r.hasis=!1),e.push(new h(r))}var i=new o({array:e});return[new o({array:[i]})]},null!=s&&this.setByParam(s)},extendClass(D.asn1.cms.SigningCertificate,D.asn1.cms.Attribute),D.asn1.cms.ESSCertID=function(t){D.asn1.cms.ESSCertID.superclass.constructor.call(this);var i=Error,s=D,e=s.asn1,r=e.DEROctetString,a=e.DERSequence,o=e.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,e){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!E.isASN1HEX(t))return t;var n,r;if("string"==typeof t)n=t;else{if(null==t.cert)throw new i("hash nor cert unspecified");n=t.cert}if(n=-1!=n.indexOf("-----BEGIN")?pemtohex(n):n,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?n=pemtohex(t):E.isASN1HEX(t)&&(n=t)),null!=t.alg)r=t.alg;else{if(null==e)throw new i("hash alg unspecified");r=e}return s.crypto.Util.hashHex(n,r)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),n=[];return n.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&n.push(new o(t)),new a({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.ESSCertID,D.asn1.ASN1Object),D.asn1.cms.SigningCertificateV2=function(s){var a=Error,t=D,e=t.asn1,o=e.DERSequence,e=(e.x509,e.cms),h=e.ESSCertIDv2;t.crypto;e.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new a("parameter 'array' not specified");for(var t=this.params.array,e=[],n=0;n<t.length;n++){var r=t[n];null==(r=null==s.alg&&0!=s.hasis||"string"!=typeof r||-1==r.indexOf("-----BEGIN")&&!E.isASN1HEX(r)?r:{cert:r}).alg&&null!=s.alg&&(r.alg=s.alg),0!=r.hasis&&0==s.hasis&&(r.hasis=!1),e.push(new h(r))}var i=new o({array:e});return[new o({array:[i]})]},null!=s&&this.setByParam(s)},extendClass(D.asn1.cms.SigningCertificateV2,D.asn1.cms.Attribute),D.asn1.cms.ESSCertIDv2=function(t){D.asn1.cms.ESSCertIDv2.superclass.constructor.call(this);Error;var e=D.asn1,r=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,a=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),n=[];return null!=t.alg&&"sha256"!=t.alg&&n.push(new a({name:t.alg})),n.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&n.push(new s(t)),new i({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.ESSCertIDv2,D.asn1.cms.ESSCertID),D.asn1.cms.IssuerSerial=function(t){var r=Error,e=D.asn1,i=e.DERInteger,s=e.DERSequence,n=e.cms,a=e.x509.GeneralNames,o=X509;n.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert){var e=null!=t.cert?t.cert:t,n=new o;n.readCertPEM(e),e=n.getIssuer(),n={hex:n.getSerialNumberHex()}}else{if(null==t.issuer||!t.serial)throw new r("cert or issuer and serial parameter not specified");e=t.issuer,n=t.serial}t=new a([{dn:e}]),e=new i(n);return new s({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.IssuerSerial,D.asn1.ASN1Object),D.asn1.cms.SignerIdentifier=function(t){var e=D.asn1,n=(e.DERInteger,e.DERSequence,e.cms),r=n.IssuerAndSerialNumber,i=n.SubjectKeyIdentifier;e.x509.X500Name,Error;n.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new r(t).tohex();if("skid"==t.type)return new i(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.SignerIdentifier,D.asn1.ASN1Object),D.asn1.cms.IssuerAndSerialNumber=function(t){var e=D.asn1,r=e.DERInteger,i=e.DERSequence,n=e.cms,s=e.x509.X500Name,a=X509,o=Error;n.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert){var e=null!=t.cert?t.cert:t,n=new a;n.readCertPEM(e),e=n.getIssuer(),n={hex:n.getSerialNumberHex()}}else{if(null==t.issuer||!t.serial)throw new o("cert or issuer and serial parameter not specified");e=t.issuer,n=t.serial}t=new s(e),e=new r(n);return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.IssuerAndSerialNumber,D.asn1.ASN1Object),D.asn1.cms.SubjectKeyIdentifier=function(t){var e=D.asn1,n=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),r=e.cms,i=(r.IssuerAndSerialName,r.SubjectKeyIdentifier,e.x509.X500Name,X509),s=Error;r.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");return null!=e.cert?t=new i(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),n({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.SubjectKeyIdentifier,D.asn1.ASN1Object),D.asn1.cms.AttributeList=function(t){var o=Error,e=D.asn1,h=e.DERSet,u=e.cms;u.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==this.hTLV){for(var e=!0,n=(null!=t.sortflag&&(e=t.sortflag),t.array),r=[],i=0;i<n.length;i++){var s=n[i],a=s.attr;if("contentType"==a)r.push(new u.ContentType(s));else if("messageDigest"==a)r.push(new u.MessageDigest(s));else if("signingTime"==a)r.push(new u.SigningTime(s));else if("signingCertificate"==a)r.push(new u.SigningCertificate(s));else if("signingCertificateV2"==a)r.push(new u.SigningCertificateV2(s));else if("signaturePolicyIdentifier"==a)r.push(new D.asn1.cades.SignaturePolicyIdentifier(s));else{if("signatureTimeStamp"!=a&&"timeStampToken"!=a)throw new o("unknown attr: "+a);r.push(new D.asn1.cades.SignatureTimeStamp(s))}}t=new h({array:r,sortflag:e});this.hTLV=t.tohex()}return this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.AttributeList,D.asn1.ASN1Object),D.asn1.cms.SignerInfo=function(t){var r=Error,e=D,n=e.asn1,i=n.DERInteger,s=n.DEROctetString,a=n.DERSequence,o=n.DERTaggedObject,h=n.cms,u=h.SignerIdentifier,c=h.AttributeList,l=(h.ContentType,h.EncapsulatedContentInfo,h.MessageDigest,h.SignedData,n.x509.AlgorithmIdentifier),f=e.crypto,g=b;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,n=new c(t.sattrs).tohex(),r=g.getKey(t.signkey),e=new f.Signature({alg:e}),r=(e.init(r),e.updateHex(n),e.sign());t.sighex=r},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:t.version})),e.push(new u(t.id)),e.push(new l({name:t.hashalg})),null!=t.sattrs){var n=new c(t.sattrs);try{e.push(new o({tag:"a0",explicit:!1,obj:n}))}catch(t){throw new r("si sattr error: "+t)}}if(null!=t.sigalgfield?e.push(new l({name:t.sigalgfield})):e.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),e.push(new s({hex:t.sighex})),null!=t.uattrs){n=new c(t.uattrs);try{e.push(new o({tag:"a1",explicit:!1,obj:n}))}catch(t){throw new r("si uattr error: "+t)}}return new a({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.SignerInfo,D.asn1.ASN1Object),D.asn1.cms.EncapsulatedContentInfo=function(t){var e=D.asn1,n=e.DERTaggedObject,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.type)),null==t.content||null==t.content.hex&&null==t.content.str||1==t.isDetached||(t=new s(t.content),t=new n({tag:"a0",explicit:!0,obj:t}),e.push(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.EncapsulatedContentInfo,D.asn1.ASN1Object),D.asn1.cms.ContentInfo=function(t){var e=D.asn1,n=e.DERTaggedObject,r=e.DERSequence,i=e.DERObjectIdentifier;e.x509.OID.name2obj;D.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[],t=(e.push(new i(t.type)),new n({tag:"a0",explicit:!0,obj:t.obj}));return e.push(t),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.ContentInfo,D.asn1.ASN1Object),D.asn1.cms.SignedData=function(t){Error;var e=D.asn1,o=(e.ASN1Object,e.DERInteger),h=e.DERSet,u=e.DERSequence,n=(e.DERTaggedObject,e.cms),c=n.EncapsulatedContentInfo,l=n.SignerInfo,r=n.ContentInfo,f=n.CertificateSet,g=n.RevocationInfoChoices,p=e.x509.AlgorithmIdentifier;D.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},n=t.sinfos,r=0;r<n.length;r++)e[n[r].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,n=t.sinfos,r=0;r<n.length;r++){var i=n[r];this._getAttrParamByName(i,"contentType").type=e}},this._setMessageDigestByEContent=function(t){for(var e=t.econtent,n=(t.econtent.type,e.content.hex),r=(null==n&&"data"==e.type&&null!=e.content.str&&(n=rstrtohex(e.content.str)),t.sinfos),i=0;i<r.length;i++){var s=r[i],a=s.hashalg,s=this._getAttrParamByName(s,"messageDigest"),a=D.crypto.Util.hashHex(n,a);s.hex=a}},this._getAttrParamByName=function(t,e){for(var n=t.sattrs.array,r=0;r<n.length;r++)if(n[r].attr==e)return n[r]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,n=0;n<e.length;n++){var r=e[n],i=1;"skid"==r.id.type&&(i=3),r.version=i}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,n=0;n<e.length;n++)if(null!=e[n].ocsp)return 5;for(var r=t.sinfos,n=0;n<r.length;n++)if(3==t.sinfos[n].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){for(var t=this.params,e=(null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam(),[]),n=(e.push(new o({int:t.version})),[]),r=0;r<t.hashalgs.length;r++){var i=t.hashalgs[r];n.push(new p({name:i}))}e.push(new h({array:n})),e.push(new c(t.econtent)),null!=t.certs&&e.push(new f(t.certs)),null!=t.revinfos&&e.push(new g(t.revinfos));for(var s=[],r=0;r<t.sinfos.length;r++){var a=t.sinfos[r];s.push(new l(a))}return e.push(new h({array:s})),new u({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new r({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.SignedData,D.asn1.ASN1Object),D.asn1.cms.CertificateSet=function(t){D.asn1.cms.CertificateSet.superclass.constructor.call(this);var o=Error,e=D.asn1,h=e.DERTaggedObject,u=e.DERSet,c=e.ASN1Object;this.params=null,this.tohex=function(){var t,e=this.params,n=[];if(e instanceof Array)t=e;else{if(null==e.array)throw new o("cert array not specified");t=e.array}for(var r=0;r<t.length;r++){var i=pemtohex(t[r]),s=new c;s.hTLV=i,n.push(s)}var a={array:n},e=(0==e.sortflag&&(a.sortflag=!1),new u(a));return new h({tag:"a0",explicit:!1,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.CertificateSet,D.asn1.ASN1Object),D.asn1.cms.RevocationInfoChoices=function(t){D.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],n=0;n<t.length;n++)e.push(new D.asn1.cms.RevocationInfoChoice(t[n]));return D.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.RevocationInfoChoices,D.asn1.ASN1Object),D.asn1.cms.RevocationInfoChoice=function(t){D.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params;if(null!=e.crl&&"string"==typeof e.crl)return t=e.crl,-1!=e.crl.indexOf("-----BEGIN")?pemtohex(e.crl):t;if(null!=e.ocsp)return D.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new D.asn1.cms.OtherRevocationFormat(e)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.RevocationInfoChoice,D.asn1.ASN1Object),D.asn1.cms.OtherRevocationFormat=function(t){D.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,n=D,r=n.asn1.ASN1Util.newObject,i=n.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(i(t.ocsp)&&E.isASN1HEX(t.ocsp))return r({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex();throw new e("ocsp value not ASN.1 hex string")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cms.OtherRevocationFormat,D.asn1.ASN1Object),D.asn1.cms.CMSUtil=new function(){},D.asn1.cms.CMSUtil.newSignedData=function(t){return new D.asn1.cms.SignedData(t)},D.asn1.cms.CMSUtil.verifySignedData=function(t){var e=D,n=e.asn1,r=n.cms,r=(r.SignerInfo,r.SignedData,r.SigningTime,r.SigningCertificate,r.SigningCertificateV2,n.cades.SignaturePolicyIdentifier,e.lang.String.isHex),h=E.getVbyList,i=E.getTLVbyList,s=E.getIdxbyList,f=E.getChildIdx,g=E.getTLV,a=E.oidname,p=e.crypto.Util.hashHex,n=(void 0===t.cms&&r(t.cms),t.cms),o=function(t,e){var n=e.idx,r=(e.signerid_issuer1=i(t,n,[1,0],"30"),e.signerid_serial1=h(t,n,[1,1],"02"),e.hashalg=a(h(t,n,[2,0],"06")),s(t,n,[3],"a0"));e.idxSignedAttrs=r,function(t,e,n){var r=f(t,n);e.signedAttrIdxList=r;for(var i=0,s;i<r.length;i++){var a=r[i];var o=h(t,a,[0],"06");if(o==="2a864886f70d010905"){s=hextoutf8(h(t,a,[1,0]));e.saSigningTime=s}else if(o==="2a864886f70d010904"){s=h(t,a,[1,0],"04");e.saMessageDigest=s}}}(t,e,r);r=f(t,n).length;if(r<6)throw"malformed SignerInfo";e.sigalg=a(h(t,n,[r-2,0],"06")),e.sigval=h(t,n,[r-1],"04")},d=function(t,e,n,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var a=f(t,s),o=0;o<a.length;o++){var h=g(t,a[o]),u=new X509;u.readCertHex(h),i[o]=u,e.certkeys[o]=u.getPublicKey()}e.certs=i}else i=e.certs;e.cccc=i.length,e.cccci=a.length;for(o=0;o<i.length;o++){var c=u.getIssuerHex(),l=u.getSerialNumberHex();n.signerid_issuer1===c&&n.signerid_serial1===l&&(n.certkey_idx=o)}},e={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==h(t,0,[0],"06"))return;e.cmsType="signedData",e.econtent=h(t,0,[1,0,2,1,0]),function(t,e){for(var n,r,i=3;i<6;i++)void 0!==(r=s(t,0,[1,0,i]))&&("a0"===(n=t.substr(r,2))&&(e.certsIdx=r),"a1"===n&&(e.revinfosIdx=r),"31"===n)&&(e.signerinfosIdx=r)}(t,e),e.signerInfos=[],function(t,e){var n=e.signerinfosIdx;if(void 0!==n){var r=f(t,n);e.signerInfoIdxList=r;for(var i=0;i<r.length;i++){var s={idx:r[i]};o(t,s),e.signerInfos.push(s)}}}(t,e)}(n,e.parse),function(t,e){for(var n=e.parse.signerInfos,r=n.length,i=!0,s=0;s<r;s++){var a=n[s];!function(t,e,n,r){n.verifyDetail={};var i=n.verifyDetail,s=e.parse.econtent,a=n.hashalg,o=n.saMessageDigest;if(i.validMessageDigest=false,p(s,a)===o)i.validMessageDigest=true;d(t,e,n,r),i.validSignatureValue=false;var h=n.sigalg,u="31"+g(t,n.idxSignedAttrs).substr(2),c=(n.signedattrshex=u,e.certs[n.certkey_idx].getPublicKey()),l=new D.crypto.Signature({alg:h}),f=(l.init(c),l.updateHex(u),l.verify(n.sigval));if((i.validSignatureValue_isValid=f)===true)i.validSignatureValue=true;if(n.isValid=false,i.validMessageDigest&&i.validSignatureValue)n.isValid=true}(t,e,a,s),a.isValid||(i=!1)}e.isValid=i}(n,e),e},D.asn1.cms.CMSParser=function(){var s=Error,a=X509,o=new a,h=E,u=h.getV,c=h.getTLV,e=(h.getIdxbyList,h.getTLVbyList),i=h.getTLVbyListEx,r=h.getVbyList,l=h.getVbyListEx,f=h.getChildIdx;this.getCMSSignedData=function(t){t=e(t,0,[1,0]);return this.getSignedData(t)},this.getSignedData=function(t){var e=f(t,0),n={},r=u(t,e[0]),r=parseInt(r,16),r=(n.version=r,c(t,e[1])),r=(n.hashalgs=this.getHashAlgArray(r),c(t,e[2])),e=(n.econtent=this.getEContent(r),i(t,0,["[0]"])),r=(null!=e&&(n.certs=this.getCertificateSet(e)),i(t,0,["[1]"]),i(t,0,[3]));return n.sinfos=this.getSignerInfos(r),n},this.getHashAlgArray=function(t){for(var e=f(t,0),n=new a,r=[],i=0;i<e.length;i++){var s=c(t,e[i]),s=n.getAlgorithmIdentifierName(s);r.push(s)}return r},this.getEContent=function(t){var e={},n=r(t,0,[0]),t=r(t,0,[1,0]);return e.type=D.asn1.x509.OID.oid2name(E.hextooidstr(n)),e.content={hex:t},e},this.getSignerInfos=function(t){for(var e=[],n=f(t,0),r=0;r<n.length;r++){var i=c(t,n[r]),i=this.getSignerInfo(i);e.push(i)}return e},this.getSignerInfo=function(t){var e={},n=f(t,0),r=h.getInt(t,n[0],-1),r=(-1!=r&&(e.version=r),c(t,n[1])),r=this.getIssuerAndSerialNumber(r),r=(e.id=r,c(t,n[2])),n=o.getAlgorithmIdentifierName(r),r=(e.hashalg=n,i(t,0,["[0]"])),r=(null!=r&&(n=this.getAttributeList(r),e.sattrs=n),i(t,0,[3])),n=o.getAlgorithmIdentifierName(r),r=(e.sigalg=n,l(t,0,[4])),n=(e.sighex=r,i(t,0,["[1]"]));return null!=n&&(r=this.getAttributeList(n),e.uattrs=r),e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},n=f(t,0),r=c(t,n[0]),r=(e.issuer=o.getX500Name(r),u(t,n[1]));return e.serial={hex:r},e},this.getAttributeList=function(t){for(var e=[],n=f(t,0),r=0;r<n.length;r++){var i=c(t,n[r]),i=this.getAttribute(i);e.push(i)}return{array:e}},this.getAttribute=function(t){var e={},n=f(t,0),r=h.getOID(t,n[0]),r=D.asn1.x509.OID.oid2name(r),i=(e.attr=r,c(t,n[1])),s=f(i,0);if(1==s.length)e.valhex=c(i,s[0]);else{for(var a=[],o=0;o<s.length;o++)a.push(c(i,s[o]));e.valhex=a}return"contentType"==r?this.setContentType(e):"messageDigest"==r?this.setMessageDigest(e):"signingTime"==r?this.setSigningTime(e):"signingCertificate"==r?this.setSigningCertificate(e):"signingCertificateV2"==r?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==r&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=h.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=hextoutf8(u(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=u(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=f(t.valhex,0);if(0<e.length){for(var n=c(t.valhex,e[0]),r=f(n,0),i=[],s=0;s<r.length;s++){var a=c(n,r[s]),a=this.getESSCertID(a);i.push(a)}t.array=i}1<e.length&&(e=c(t.valhex,e[1]),t.polhex=e),delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var e,n,r=f(t.valhex,0);0<r.length&&(e=h.getOID(t.valhex,r[0]),t.oid=e),1<r.length&&(e=new a,r=f(t.valhex,r[1]),n=c(t.valhex,r[0]),e=e.getAlgorithmIdentifierName(n),t.alg=e,n=u(t.valhex,r[1]),t.hash=n),delete t.valhex},this.setSigningCertificateV2=function(t){var e=f(t.valhex,0);if(0<e.length){for(var n=c(t.valhex,e[0]),r=f(n,0),i=[],s=0;s<r.length;s++){var a=c(n,r[s]),a=this.getESSCertIDv2(a);i.push(a)}t.array=i}1<e.length&&(e=c(t.valhex,e[1]),t.polhex=e),delete t.valhex},this.getESSCertID=function(t){var e,n={},r=f(t,0);return 0<r.length&&(e=u(t,r[0]),n.hash=e),1<r.length&&(e=c(t,r[1]),null!=(t=this.getIssuerSerial(e)).serial&&(n.serial=t.serial),null!=t.issuer)&&(n.issuer=t.issuer),n},this.getESSCertIDv2=function(t){var e={},n=f(t,0);if(n.length<1||3<n.length)throw new s("wrong number of elements");var r=0,i=("30"==t.substr(n[0],2)?(i=c(t,n[0]),e.alg=o.getAlgorithmIdentifierName(i),r++):e.alg="sha256",u(t,n[r]));return e.hash=i,n.length>r+1&&(i=c(t,n[r+1]),t=this.getIssuerSerial(i),e.issuer=t.issuer,e.serial=t.serial),e},this.getIssuerSerial=function(t){var e={},n=f(t,0),r=c(t,n[0]),r=o.getGeneralNames(r)[0].dn,r=(e.issuer=r,u(t,n[1]));return e.serial={hex:r},e},this.getCertificateSet=function(t){for(var e=f(t,0),n=[],r=0;r<e.length;r++){var i=c(t,e[r]);"30"==i.substr(0,2)&&(i=hextopem(i,"CERTIFICATE"),n.push(i))}return{array:n,sortflag:!1}}},void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),void 0!==D.asn1.tsp&&D.asn1.tsp||(D.asn1.tsp={}),D.asn1.tsp.TimeStampToken=function(t){var e=D.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.TimeStampToken,D.asn1.cms.SignedData),D.asn1.tsp.TSTInfo=function(t){Error;var e=D.asn1,n=e.DERSequence,r=e.DERInteger,i=e.DERBoolean,s=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,h=e.tsp,u=h.MessageImprint,c=h.Accuracy,e=(e.x509.X500Name,e.x509.GeneralName);if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new r({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);t=new n({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new r(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new i),void 0!==t.nonce&&(this.dNonce=new r(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new e({dn:t.tsa})}))}},extendClass(D.asn1.tsp.TSTInfo,D.asn1.ASN1Object),D.asn1.tsp.Accuracy=function(t){var e=D.asn1,n=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),n({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.Accuracy,D.asn1.ASN1Object),D.asn1.tsp.MessageImprint=function(t){var e=D.asn1,n=e.DERSequence,r=e.DEROctetString,i=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new i({name:t.alg}),t=new r({hex:t.hash});return new n({array:[e,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.tsp.MessageImprint,D.asn1.ASN1Object),D.asn1.tsp.TimeStampReq=function(t){var e=D.asn1,n=e.DERSequence,r=e.DERInteger,i=e.DERBoolean,s=(e.ASN1Object,e.DERObjectIdentifier),e=e.tsp,a=e.MessageImprint;e.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new r({int:1})),t.messageImprint instanceof D.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new r(t.nonce)),1==t.certreq&&e.push(new i),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.TimeStampReq,D.asn1.ASN1Object),D.asn1.tsp.TimeStampResp=function(t){var n=D.asn1,r=n.DERSequence,i=(n.ASN1Object,n.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?e.push(new s(t.statusinfo)):e.push(new s("granted")),null!=t.econtent)e.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof n.ASN1Object))throw new Error("improper member tst value");e.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");e.push(new s(t.statusinfo))}return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.TimeStampResp,D.asn1.ASN1Object),D.asn1.tsp.PKIStatusInfo=function(t){var n=Error,e=D.asn1,r=e.DERSequence,e=e.tsp,i=e.PKIStatus,s=e.PKIFreeText,a=e.PKIFailureInfo;e.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if("string"==typeof t)e.push(new i(t));else{if(null==t.status)throw new n("property 'status' unspecified");e.push(new i(t.status)),null!=t.statusstr&&e.push(new s(t.statusstr)),null!=t.failinfo&&e.push(new a(t.failinfo))}return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.PKIStatusInfo,D.asn1.ASN1Object),D.asn1.tsp.PKIStatus=function(t){var n=Error,e=D.asn1,r=e.DERInteger,i=(e.tsp.PKIStatus.superclass.constructor.call(this),{granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5});this.params=null,this.tohex=function(){var t,e=this.params;if("string"==typeof e)try{t=i[e]}catch(t){throw new n("undefined name: "+e)}else{if("number"!=typeof e)throw new n("unsupported params");t=e}return new r({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.PKIStatus,D.asn1.ASN1Object),D.asn1.tsp.PKIFreeText=function(t){var r=Error,e=D.asn1,i=e.DERSequence,s=e.DERUTF8String;e.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new r("wrong params: not array");for(var e=[],n=0;n<t.length;n++)e.push(new s({str:t[n]}));return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.PKIFreeText,D.asn1.ASN1Object),D.asn1.tsp.PKIFailureInfo=function(t){var s=Error,e=D.asn1,n=e.DERBitString,e=e.tsp.PKIFailureInfo,a={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};e.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,e=0;if("number"==typeof t&&0<=t&&t<=25){for(var n=(e|=1<<t).toString(2),r="",i=n.length-1;0<=i;i--)r+=n[i];return r}if("string"==typeof t&&null!=a[t])return namearraytobinstr([t],a);if("object"==typeof t&&null!=t.length)return namearraytobinstr(t,a);throw new s("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new n({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.tsp.PKIFailureInfo,D.asn1.ASN1Object),D.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},D.asn1.tsp.SimpleTSAAdapter=function(t){var e=D,n=e.asn1.tsp,r=e.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){t=r(t,e),this.params.econtent.content.messageImprint={alg:e,hash:t},this.params.econtent.content.serial={int:this.serial++},e=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:e},new n.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.tsp.SimpleTSAAdapter,D.asn1.tsp.AbstractTSAAdapter),D.asn1.tsp.FixedTSAAdapter=function(t){var e=D,n=e.asn1.tsp,r=e.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){t=r(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:t},new n.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},extendClass(D.asn1.tsp.FixedTSAAdapter,D.asn1.tsp.AbstractTSAAdapter),D.asn1.tsp.TSPUtil=new function(){},D.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new D.asn1.tsp.TimeStampToken(t)},D.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new D.asn1.tsp.TSPParser).getTimeStampReq(t)},D.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new D.asn1.tsp.TSPParser).getMessageImprint(t)},D.asn1.tsp.TSPParser=function(){Error;var s=new X509,h=E,u=h.getV,c=h.getTLV,i=h.getIdxbyList,l=(h.getTLVbyListEx,h.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],e={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e,n=l(t,0);return 1==n.length?this.getPKIStatusInfo(c(t,n[0])):1<n.length?(e=this.getPKIStatusInfo(c(t,n[0])),t=c(t,n[1]),(n=this.getToken(t)).statusinfo=e,n):void 0},this.getToken=function(t){t=(new D.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(t),t},this.setTSTInfo=function(t){var e,t=t.econtent;"tstinfo"==t.type&&(e=t.content.hex,e=this.getTSTInfo(e),t.content=e)},this.getTSTInfo=function(t){var e,n={},r=l(t,0),i=u(t,r[1]),i=(n.policy=hextooid(i),c(t,r[2])),i=(n.messageImprint=this.getMessageImprint(i),u(t,r[3])),i=(n.serial={hex:i},u(t,r[4])),i=(n.genTime={str:hextoutf8(i)},0);return 5<r.length&&"30"==t.substr(r[5],2)&&(e=c(t,r[5]),n.accuracy=this.getAccuracy(e),i++),r.length>5+i&&"01"==t.substr(r[5+i],2)&&("ff"==u(t,r[5+i])&&(n.ordering=!0),i++),r.length>5+i&&"02"==t.substr(r[5+i],2)&&(e=u(t,r[5+i]),n.nonce={hex:e},i++),r.length>5+i&&"a0"==t.substr(r[5+i],2)&&(e="30"+(e=c(t,r[5+i])).substr(2),e=(pGeneralNames=s.getGeneralNames(e))[0].dn,n.tsa=e,i++),r.length>5+i&&"a1"==t.substr(r[5+i],2)&&(e="30"+(e=c(t,r[5+i])).substr(2),t=s.getExtParamArray(e),n.ext=t,i++),n},this.getAccuracy=function(t){for(var e={},n=l(t,0),r=0;r<n.length;r++){var i=t.substr(n[r],2),s=u(t,n[r]),s=parseInt(s,16);"02"==i?e.seconds=s:"80"==i?e.millis=s:"81"==i&&(e.micros=s)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var e={},n=(l(t,0),i(t,0,[0,0])),n=u(t,n),n=h.hextooidstr(n),r=D.asn1.x509.OID.oid2name(n);if(""==r)throw new Error("hashAlg name undefined: "+n);n=r,r=i(t,0,[1]);return e.alg=n,e.hash=u(t,r),e},this.getPKIStatusInfo=function(t){var e={},n=l(t,0),r=0;try{var i=u(t,n[0]),s=parseInt(i,16);e.status=a[s]}catch(t){}return 1<n.length&&"30"==t.substr(n[1],2)&&(i=c(t,n[1]),e.statusstr=this.getPKIFreeText(i),r++),n.length>r&&"03"==t.substr(n[1+r],2)&&(s=c(t,n[1+r]),e.failinfo=this.getPKIFailureInfo(s)),e},this.getPKIFreeText=function(t){for(var e=[],n=l(t,0),r=0;r<n.length;r++)e.push(h.getString(t,n[r]));return e},this.getPKIFailureInfo=function(t){t=h.getInt(t,0);return null!=e[t]?e[t]:t},this.getTimeStampReq=function(t){var e={certreq:!1},n=l(t,0);if(n.length<2)throw new Error("TimeStampReq must have at least 2 items");var r=c(t,n[1]);e.messageImprint=D.asn1.tsp.TSPUtil.parseMessageImprint(r);for(var i=2;i<n.length;i++){var s,a=n[i],o=t.substr(a,2);"06"==o&&(s=u(t,a),e.policy=h.hextooidstr(s)),"02"==o&&(e.nonce=u(t,a)),"01"==o&&(e.certreq=!0)}return e}},void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),void 0!==D.asn1.cades&&D.asn1.cades||(D.asn1.cades={}),D.asn1.cades.SignaturePolicyIdentifier=function(t){var e=D.asn1.cades,n=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new n(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.SignaturePolicyIdentifier,D.asn1.cms.Attribute),D.asn1.cades.SignaturePolicyId=function(t){var e=D.asn1,n=e.DERSequence,r=e.DERObjectIdentifier,e=(e.x509.AlgorithmIdentifier,e.cades),i=e.SignaturePolicyId,s=e.OtherHashAlgAndValue;i.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new r(t.oid)),e.push(new s(t)),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.SignaturePolicyId,D.asn1.ASN1Object),D.asn1.cades.OtherHashAlgAndValue=function(t){var r=Error,e=D.asn1,i=e.DERSequence,s=e.DEROctetString,a=e.x509.AlgorithmIdentifier;e.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new r("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new r("property 'hash' nor 'cert' not specified");var e=null;if(null!=t.hash)e=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new r("cert not string");var n=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(n=pemtohex(t.cert)),e=D.crypto.Util.hashHex(n,t.alg)}n=[];return n.push(new a({name:t.alg})),n.push(new s({hex:e})),new i({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.OtherHashAlgAndValue,D.asn1.ASN1Object),D.asn1.cades.OtherHashValue=function(t){D.asn1.cades.OtherHashValue.superclass.constructor.call(this);var r=Error,e=D,i=(e.lang.String.isHex,e.asn1.DEROctetString);e.crypto.Util.hashHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new r("hash or cert not specified");var e=null;if(null!=t.hash)e=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new r("cert not string");var n=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(n=pemtohex(t.cert)),e=D.crypto.Util.hashHex(n,"sha1")}return new i({hex:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.OtherHashValue,D.asn1.ASN1Object),D.asn1.cades.SignatureTimeStamp=function(t){var r=Error,e=D,i=e.lang.String.isHex,e=e.asn1,s=e.ASN1Object;e.x509;e.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(e=new s).hTLV=t.tst,[e];if(t.tst instanceof s)return[t.tst];throw new r("params.tst has wrong value")}if(null!=t.res){var e,n=t.res;if("string"==typeof(n=n instanceof s?n.tohex():n)&&i(n))return E.getTLVbyList(n,0,[1]),(e=new s).hTLV=t.tst,[e];throw new r("params.res has wrong value")}},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.SignatureTimeStamp,D.asn1.cms.Attribute),D.asn1.cades.CompleteCertificateRefs=function(t){var i=Error,e=D,n=e.asn1,s=n.DERSequence,n=n.cades,a=n.OtherCertID,o=e.lang.String.isHex;n.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,e=[],n=0;n<t.array.length;n++){var r=t.array[n];if("string"==typeof r)if(-1!=r.indexOf("-----BEGIN"))r={cert:r};else{if(!o(r))throw new i("unsupported value: "+r);r={hash:r}}null!=t.alg&&null==r.alg&&(r.alg=t.alg),null!=t.hasis&&null==r.hasis&&(r.hasis=t.hasis);r=new a(r);e.push(r)}return[new s({array:e})]},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.CompleteCertificateRefs,D.asn1.cms.Attribute),D.asn1.cades.OtherCertID=function(t){var e=D.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,e=e.cades,s=e.OtherHashValue,a=e.OtherHashAlgAndValue;e.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params,e=("string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t})),[]),n=null,n=new(null!=t.alg?a:s)(t);return e.push(n),(null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial)&&(n=new i(t),e.push(n)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.OtherCertID,D.asn1.ASN1Object),D.asn1.cades.OtherHash=function(t){Error;var e=D,n=e.asn1,n=(n.cms,n.cades),r=n.OtherHashAlgAndValue,i=n.OtherHashValue,s=(e.crypto.Util.hashHex,e.lang.String.isHex);n.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:s(t)&&(t={hash:t}));return new(null!=t.alg?r:i)(t).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.cades.OtherHash,D.asn1.ASN1Object),D.asn1.cades.CAdESUtil=new function(){},D.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new D.asn1.cms.CMSParser).getCMSSignedData(t)},D.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,n){var r=E.getChildIdx,i=E.getTLV,s=E.getV,a=D.asn1,o=a.ASN1Object,a=a.cms,h=a.AttributeList,a=a.SignerInfo,u={},r=r(t,e);if(6!=r.length)throw"not supported items for SignerInfo (!=6)";e=r.shift(),u.version=i(t,e),e=r.shift(),u.si=i(t,e),e=r.shift(),u.digalg=i(t,e),e=r.shift(),u.sattrs=i(t,e),e=r.shift(),u.sigalg=i(t,e),e=r.shift(),u.sig=i(t,e),u.sigval=s(t,e),r=null;return u.obj=new a,(r=new o).hTLV=u.version,u.obj.dCMSVersion=r,(r=new o).hTLV=u.si,u.obj.dSignerIdentifier=r,(r=new o).hTLV=u.digalg,u.obj.dDigestAlgorithm=r,(r=new o).hTLV=u.sattrs,u.obj.dSignedAttrs=r,(r=new o).hTLV=u.sigalg,u.obj.dSigAlg=r,(r=new o).hTLV=u.sig,u.obj.dSig=r,u.obj.dUnsignedAttrs=new h,u},void 0!==D.asn1.csr&&D.asn1.csr||(D.asn1.csr={}),D.asn1.csr.CertificationRequest=function(t){var e=D.asn1,r=e.DERBitString,i=e.DERSequence,n=e.csr,s=(e.x509,n.CertificationRequestInfo);n.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new D.crypto.Signature({alg:this.params.sigalg}),t=(e.init(this.params.sbjprvkey),e.updateHex(t),e.sign());this.params.sighex=t},this.getPEM=function(){return hextopem(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new D.asn1.csr.CertificationRequestInfo(this.params),n=new D.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");t=new r({hex:"00"+t.sighex});return new i({array:[e,n,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.csr.CertificationRequest,D.asn1.ASN1Object),D.asn1.csr.CertificationRequestInfo=function(t){var e=D.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,a=e.DERTaggedObject,o=e.ASN1Util.newObject,n=e.csr,e=e.x509,h=e.X500Name,u=e.Extensions,c=e.SubjectPublicKeyInfo;n.AttributeList;n.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t,e=this.params,n=[];return n.push(new i({int:0})),n.push(new h(e.subject)),n.push(new c(b.getKey(e.sbjpubkey))),null!=e.attrs?(t=function m(t){for(var e=Error,n=D.asn1.x509.Extensions,r=[],i=0;i<t.length;i++){var s=t[i],a=s.attr;if("extensionRequest"==a)var o={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new n(s.ext)]}]};else if("unstructuredName"==a)o={seq:[{oid:"1.2.840.113549.1.9.2"},{set:s.names}]};else{if("challengePassword"!=a)throw new e("unknown CSR attribute");o={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:s.password}]}]}}r.push(o)}return{set:r}}(e.attrs),t=o({tag:{tage:"a0",obj:t}}),n.push(t)):null!=e.extreq?(e=new u(e.extreq),t=o({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[e]}]}}}),n.push(t)):n.push(new a({tag:"a0",explicit:!1,obj:new s({str:""})})),new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(D.asn1.csr.CertificationRequestInfo,D.asn1.ASN1Object),D.asn1.csr.AttributeList=function(t){},extendClass(D.asn1.csr.AttributeList,D.asn1.ASN1Object),D.asn1.csr.CSRUtil=new function(){},D.asn1.csr.CSRUtil.newCSRPEM=function(t){return new D.asn1.csr.CertificationRequest(t).getPEM()},D.asn1.csr.CSRUtil.getParam=function(t,e){var n=E.getV,r=E.getIdxbyList,i=E.getTLVbyList,s=E.getTLVbyListEx,a=E.getVbyListEx,o={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");t=pemtohex(t,"CERTIFICATE REQUEST");e&&(o.tbs=i(t,0,[0]));try{var h=s(t,0,[0,1]);"3000"==h?o.subject={}:(u=new X509,o.subject=u.getX500Name(h))}catch(t){}var e=s(t,0,[0,2]),h=b.getKey(e,null,"pkcs8pub"),e=(o.sbjpubkey=b.getPEM(h,"PKCS8PUB"),function(t){var e=r(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=n(t,e)?null:i(t,0,[0,3,0,1,0],"30")}(t)),u=new X509;null!=e&&(o.extreq=u.getExtParamArray(e));try{var c=s(t,0,[1],"30"),u=new X509;o.sigalg=u.getAlgorithmIdentifierName(c)}catch(t){}try{var l=a(t,0,[2]);o.sighex=l}catch(t){}return o},D.asn1.csr.CSRUtil.verifySignature=function(t){try{var e,n=null;return("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?n=D.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(n=t),null==n)?!1:((e=new D.crypto.Signature({alg:n.sigalg})).init(n.sbjpubkey),e.updateHex(n.tbs),e.verify(n.sighex))}catch(t){return alert(t),!1}},void 0!==(D=void 0!==D&&D?D:{}).asn1&&D.asn1||(D.asn1={}),void 0!==D.asn1.ocsp&&D.asn1.ocsp||(D.asn1.ocsp={}),D.asn1.ocsp.DEFAULT_HASH="sha1",D.asn1.ocsp.OCSPResponse=function(t){D.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);D.asn1.DEREnumerated;var n=D.asn1.ASN1Util.newObject,r=D.asn1.ocsp.ResponseBytes,e=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:e.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=this._getStatusCode();if(-1==e)throw new Error("responseStatus not supported: "+t.resstatus);return(0!=e?n({seq:[{enum:{int:e}}]}):(e=new r(t),n({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:e}}]}))).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.OCSPResponse,D.asn1.ASN1Object),D.asn1.ocsp.ResponseBytes=function(t){D.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=D.asn1,n=e.DERSequence,r=e.DERObjectIdentifier,i=e.DEROctetString,s=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var t=new s(t),e=[];return e.push(new r({name:"ocspBasic"})),e.push(new i({hex:t.tohex()})),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.ResponseBytes,D.asn1.ASN1Object),D.asn1.ocsp.BasicOCSPResponse=function(t){D.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var o=Error,e=D.asn1,h=e.ASN1Object,u=e.DERSequence,c=(e.DERGeneralizedTime,e.DERTaggedObject),l=e.DERBitString,f=(e.x509.Extensions,e.x509.AlgorithmIdentifier),e=e.ocsp;e.ResponderID;_SingleResponseList=e.SingleResponseList,_ResponseData=e.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),n=new D.crypto.Signature({alg:t.sigalg});n.init(t.reskey),n.updateHex(e),t.sighex=n.sign()},this.tohex=function(){var t=this.params,e=(null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign(),[]);if(e.push(t.tbsresp),e.push(new f({name:t.sigalg})),e.push(new l({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var n=[],r=0;r<t.certs.length;r++){var i=t.certs[r],s=null;if(E.isASN1HEX(i))s=i;else{if(!i.match(/-----BEGIN/))throw new o("certs["+r+"] not hex or PEM");s=pemtohex(i)}n.push(new h({tlv:s}))}var a=new u({array:n});e.push(new c({tag:"a0",explicit:!0,obj:a}))}return new u({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.BasicOCSPResponse,D.asn1.ASN1Object),D.asn1.ocsp.ResponseData=function(t){D.asn1.ocsp.ResponseData.superclass.constructor.call(this);var n=Error,e=D.asn1,r=e.DERSequence,i=e.DERGeneralizedTime,s=e.DERTaggedObject,a=e.x509.Extensions,e=e.ocsp,o=e.ResponderID;_SingleResponseList=e.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params,e=(null!=t.respid&&new n("respid not specified"),null!=t.prodat&&new n("prodat not specified"),null!=t.array&&new n("array not specified"),[]);return e.push(new o(t.respid)),e.push(new i(t.prodat)),e.push(new _SingleResponseList(t.array)),null!=t.ext&&(t=new a(t.ext),e.push(new s({tag:"a1",explicit:!0,obj:t}))),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.ResponseData,D.asn1.ASN1Object),D.asn1.ocsp.ResponderID=function(t){D.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=D,n=e.asn1,r=n.ASN1Util.newObject,i=n.x509.X500Name,s=e.lang.String.isHex,a=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e=null;if("string"==typeof t.key?(s(t.key)&&(e=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(n=new X509(t.key).getExtSubjectKeyIdentifier())&&(e=n.kid.hex)):t.key instanceof X509&&null!=(n=t.key.getExtSubjectKeyIdentifier())&&(e=n.kid.hex),null==e)throw new a("wrong key member value");return r({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:e}}}}).tohex()}if(null==t.name)throw new a("key or name not specified");var n=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?n=new X509(t.name).getSubject():t.name instanceof X509?n=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(n=t.name),null==n)throw new a("wrong name member value");return r({tag:{tag:"a1",explicit:!0,obj:new i(n)}}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.ResponderID,D.asn1.ASN1Object),D.asn1.ocsp.SingleResponseList=function(t){D.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=D.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],n=0;n<t.length;n++)e.push(new i(t[n]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.SingleResponseList,D.asn1.ASN1Object),D.asn1.ocsp.SingleResponse=function(t){var r=Error,e=D.asn1,i=e.DERSequence,s=e.DERGeneralizedTime,a=e.DERTaggedObject,n=e.ocsp,o=n.CertID,h=n.CertStatus,u=e.x509.Extensions;n.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params,n=[];if(null==e.certid)throw new r("certid unspecified");if(null==e.status)throw new r("status unspecified");if(null==e.thisupdate)throw new r("thisupdate unspecified");return n.push(new o(e.certid)),n.push(new h(e.status)),n.push(new s(e.thisupdate)),null!=e.nextupdate&&(t=new s(e.nextupdate),n.push(new a({tag:"a0",explicit:!0,obj:t}))),null!=e.ext&&(t=new u(e.ext),n.push(new a({tag:"a1",explicit:!0,obj:t}))),new i({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.SingleResponse,D.asn1.ASN1Object),D.asn1.ocsp.CertID=function(t){var e=D,n=e.asn1,s=n.DEROctetString,a=n.DERInteger,o=n.DERSequence,h=n.x509.AlgorithmIdentifier,n=n.ocsp,i=(n.DEFAULT_HASH,e.crypto.Util.hashHex),u=X509,c=E.getVbyList;n.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,n,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issname:t,isskey:e,sbjsn:n}},this.setByCert=function(t,e,n){null==n&&(n=this.DEFAULT_HASH),this.params={alg:n,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,n){null==n&&(n=this.DEFAULT_HASH);var t=new u(t),e=new u(e),r=i(t.getSubjectHex(),n),t=t.getPublicKeyHex();return{alg:n,issname:r,isskey:i(c(t,0,[1],"03",!0),n),sbjsn:e.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t=this.params,e=null==t.alg?this.DEFAULT_HASH:t.alg;if(null!=t.issuerCert&&null!=t.subjectCert)var n=this.getParamByCerts(t.issuerCert,t.subjectCert,e),r=n.issname,i=n.isskey,n=n.sbjsn;else{if(null==t.issname||null==t.isskey||null==t.sbjsn)throw new Error("required param members not defined");r=t.issname,i=t.isskey,n=t.sbjsn}t=new h({name:e}),e=new s({hex:r}),r=new s({hex:i}),i=new a({hex:n}),n=new o({array:[t,e,r,i]});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.CertID,D.asn1.ASN1Object),D.asn1.ocsp.CertStatus=function(t){D.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params;if("good"==e.status)return"8000";if("unknown"==e.status)return"8200";if("revoked"==e.status)return t=[{gentime:{str:e.time}}],null!=e.reason&&t.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:e.reason}}}}),D.asn1.ASN1Util.newObject({tag:{tag:"a1",explicit:!1,obj:{seq:t}}}).tohex();throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(D.asn1.ocsp.CertStatus,D.asn1.ASN1Object),D.asn1.ocsp.Request=function(t){var e=D.asn1,n=e.DERSequence,e=e.ocsp;e.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);t=new n({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(e=new e.CertID(t),this.dReqCert=e)},extendClass(D.asn1.ocsp.Request,D.asn1.ASN1Object),D.asn1.ocsp.TBSRequest=function(t){var e=D.asn1,n=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],n=0;n<t.length;n++){var r=new i.Request(t[0]);e.push(r)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new n({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";e=new n({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},extendClass(D.asn1.ocsp.TBSRequest,D.asn1.ASN1Object),D.asn1.ocsp.OCSPRequest=function(t){var e=D.asn1,n=e.DERSequence,e=e.ocsp;e.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";t=new n({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&(e=new e.TBSRequest(t),this.dTbsRequest=e)},extendClass(D.asn1.ocsp.OCSPRequest,D.asn1.ASN1Object),D.asn1.ocsp.OCSPUtil={},D.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,n){var r=D.asn1.ocsp,n={alg:n=void 0===n?r.DEFAULT_HASH:n,issuerCert:t,subjectCert:e};return new r.OCSPRequest({reqList:[n]}).tohex()},D.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=E.getVbyList,n=E.getVbyListEx,r=E.getIdxbyList,i=(E.getIdxbyListEx,E.getV),s={};try{var a=n(t,0,[0],"0a");s.responseStatus=parseInt(a,16)}catch(t){}if(0===s.responseStatus){try{var o=r(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(o,2)?s.certStatus="good":"a1"===t.substr(o,2)?(s.certStatus="revoked",s.revocationTime=hextoutf8(e(t,o,[0]))):"82"===t.substr(o,2)&&(s.certStatus="unknown")}catch(t){}try{var h=r(t,0,[1,0,1,0,0,2,0,2]);s.thisUpdate=hextoutf8(i(t,h))}catch(t){}try{var u=r(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(u,2)&&(s.nextUpdate=hextoutf8(e(t,u,[0])))}catch(t){}}return s},D.asn1.ocsp.OCSPParser=function(){var i=Error,s=X509,r=new s,u=E.getV,c=E.getTLV,a=E.getIdxbyList,o=E.getVbyList,h=E.getTLVbyList,l=E.getVbyListEx,f=E.getTLVbyListEx,g=E.getChildIdx;this.getOCSPRequest=function(t){var e=g(t,0);if(1!=e.length&&2!=e.length)throw new i("wrong number elements: "+e.length);return this.getTBSRequest(c(t,e[0]))},this.getTBSRequest=function(t){var e={},n=f(t,0,[0],"30"),n=(e.array=this.getRequestList(n),f(t,0,["[2]",0],"30"));return null!=n&&(e.ext=r.getExtParamArray(n)),e},this.getRequestList=function(t){for(var e=[],n=g(t,0),r=0;r<n.length;r++){t=c(t,n[r]);e.push(this.getRequest(t))}return e},this.getRequest=function(t){var e=g(t,0);if(1!=e.length&&2!=e.length)throw new i("wrong number elements: "+e.length);var n=this.getCertID(c(t,e[0]));return 2==e.length&&(e=a(t,0,[1,0]),n.ext=r.getExtParamArray(c(t,e))),n},this.getCertID=function(t){var e=g(t,0);if(4!=e.length)throw new i("wrong number elements: "+e.length);var n=new s,r={};return r.alg=n.getAlgorithmIdentifierName(c(t,e[0])),r.issname=u(t,e[1]),r.isskey=u(t,e[2]),r.sbjsn=u(t,e[3]),r},this.getOCSPResponse=function(t){var e=g(t,0),n=u(t,e[0]),n=parseInt(n);return 1==e.length?{resstatus:n}:(e=h(t,0,[1,0]),(t=this.getResponseBytes(e)).resstatus=n,t)},this.getResponseBytes=function(t){var e=g(t,0),n=h(t,0,[1,0]),n=this.getBasicOCSPResponse(n),t=u(t,e[0]);return n.restype=D.asn1.x509.OID.oid2name(hextooid(t)),n},this.getBasicOCSPResponse=function(t){var e=g(t,0),n=this.getResponseData(c(t,e[0])),r=new X509,r=(n.alg=r.getAlgorithmIdentifierName(c(t,e[1])),u(t,e[2])),i=(n.sighex=r.substr(2),l(t,0,["[0]"]));if(null!=i){for(var s=g(i,0),a=[],o=0;o<s.length;o++){var h=c(i,s[o]);a.push(h)}n.certs=a}return n},this.getResponseData=function(t){var e=g(t,0),n=e.length,r={},i=0,s=("a0"==t.substr(e[0],2)&&i++,r.respid=this.getResponderID(c(t,e[i++])),u(t,e[i++]));return r.prodat=hextoutf8(s),r.array=this.getSingleResponseList(c(t,e[i++])),"a1"==t.substr(e[n-1],2)&&(s=h(t,e[n-1],[0]),i=new X509,r.ext=i.getExtParamArray(s)),r},this.getResponderID=function(t){var e,n={};return"a2"==t.substr(0,2)&&(e=o(t,0,[0]),n.key=e),"a1"==t.substr(0,2)&&(e=h(t,0,[0]),t=new X509,n.name=t.getX500Name(e)),n},this.getSingleResponseList=function(t){for(var e=g(t,0),n=[],r=0;r<e.length;r++){var i=this.getSingleResponse(c(t,e[r]));n.push(i)}return n},this.getSingleResponse=function(t){var e=g(t,0),n={},r=this.getCertID(c(t,e[0])),r=(n.certid=r,this.getCertStatus(c(t,e[1])));n.status=r,"18"==t.substr(e[2],2)&&(r=u(t,e[2]),n.thisupdate=hextoutf8(r));for(var i,s,a=3;a<e.length;a++)"a0"==t.substr(e[a],2)&&(i=o(t,e[a],[0],"18"),n.nextupdate=hextoutf8(i)),"a1"==t.substr(e[a],2)&&(i=new X509,s=h(t,0,[a,0]),n.ext=i.getExtParamArray(s));return n},this.getCertStatus=function(t){var e={};return"8000"==t?{status:"good"}:"8200"==t?{status:"unknown"}:("a1"==t.substr(0,2)&&(e.status="revoked",t=hextoutf8(o(t,0,[0])),e.time=t),e)}},void 0!==(D=void 0!==D&&D?D:{}).lang&&D.lang||(D.lang={}),D.lang.String=function(){},g="function"==typeof Buffer?(H=function(t){return b64tob64u(Buffer.from(t,"utf8").toString("base64"))},function(t){return Buffer.from(b64utob64(t),"base64").toString("utf8")}):(H=function(t){return hextob64u(uricmptohex(encodeURIComponentAll(t)))},function(t){return decodeURIComponent(hextouricmp(b64utohex(t)))}),D.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},D.lang.String.isHex=function(t){return ishex(t)},D.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},D.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=b64utob64(t),D.lang.String.isBase64(t))},D.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},D.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},D.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},D.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};function oidtohex(t){function fba(t){return t=1==(t=t.toString(16)).length?"0"+t:t}try{if(!t.match(/^[0-9.]+$/))return null;var e="",n=t.split("."),r=40*parseInt(n[0],10)+parseInt(n[1],10);e+=fba(r),n.splice(0,2);for(var i=0;i<n.length;i++)e+=function(t){for(var e="",n=7-(s=parseInt(t,10).toString(2)).length%7,r=(7==n&&(n=0),""),i=0;i<n;i++)r+="0";for(var s=r+s,i=0;i<s.length-1;i+=7){var a=s.substr(i,7);i!=s.length-7&&(a="1"+a),e+=fba(parseInt(a,2))}return e}(n[i]);return e}catch(t){return null}}function hextooid(t){if(!ishex(t))return null;try{for(var e=[],n=t.substr(0,2),r=parseInt(n,16),i=(e[0]=new String(Math.floor(r/40)),e[1]=new String(r%40),t.substr(2)),s=[],a=0;a<i.length/2;a++)s.push(parseInt(i.substr(2*a,2),16));for(var o=[],h="",a=0;a<s.length;a++)128&s[a]?h+=V((127&s[a]).toString(2),7):(h+=V((127&s[a]).toString(2),7),o.push(new String(parseInt(h,2))),h="");var u=e.join(".");return u=0<o.length?u+"."+o.join("."):u}catch(t){return null}}var V=function(t,e,n){return null==n&&(n="0"),t.length>=e?t:new Array(e-t.length+1).join(n)+t};function bitstrtoint(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e,n,r,i,s=t.substr(0,2);return"00"==s?parseInt(t.substr(2),16):7<(e=parseInt(s,16))||(n=t.substr(2),r=(r="0"==(r=parseInt(n,16).toString(2))?"00000000":r).slice(0,0-e),NaN==(i=parseInt(r,2)))?-1:i}catch(t){return-1}}function bitstrtobinstr(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var n=t.substr(2),r="",i=0;i<n.length;i+=2){var s=n.substr(i,2);r+=("0000000"+parseInt(s,16).toString(2)).slice(-8)}return r.substr(0,r.length-e)}catch(t){return null}}function namearraytobinstr(t,e){for(var n=0,r=0;r<t.length;r++)n|=1<<e[t[r]];for(var i=n.toString(2),s="",r=i.length-1;0<=r;r--)s+=i[r];return s}function aryval(t,e,n){if("object"==typeof t){for(var e=String(e).split("."),r=0;r<e.length&&t;r++){var i=e[r];t=t[i=i.match(/^[0-9]+$/)?parseInt(i):i]}return t||!1===t?t:n}}function extendClass(t,e){function s1a(){}s1a.prototype=e.prototype,t.prototype=new s1a,(t.prototype.constructor=t).superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==(D=void 0!==D&&D?D:{}).crypto&&D.crypto||(D.crypto={}),D.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",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",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:C.algo.MD5,sha1:C.algo.SHA1,sha224:C.algo.SHA224,sha256:C.algo.SHA256,sha384:C.algo.SHA384,sha512:C.algo.SHA512,ripemd160:C.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,n){var t=this.getDigestInfoHex(t,e),r=n/4;if(t.length+22>r)throw"key is too short for SigAlg: keylen="+n+","+e;for(var n="00"+t,i="",s=r-"0001".length-n.length,a=0;a<s;a+=2)i+="ff";return"0001"+i+n},this.hashString=function(t,e){return new D.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new D.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof RSAKey||t instanceof D.crypto.DSA||t instanceof D.crypto.ECDSA}},D.crypto.Util.md5=function(t){return new D.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},D.crypto.Util.ripemd160=function(t){return new D.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},D.crypto.Util.SECURERANDOMGEN=new SecureRandom,D.crypto.Util.getRandomHexOfNbytes=function(t){t=new Array(t);return D.crypto.Util.SECURERANDOMGEN.nextBytes(t),BAtohex(t)},D.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new BigInteger(D.crypto.Util.getRandomHexOfNbytes(t),16)},D.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,t=new Array(1+(t-e)/8);return D.crypto.Util.SECURERANDOMGEN.nextBytes(t),t[0]=(255<<e&255^255)&t[0],BAtohex(t)},D.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new BigInteger(D.crypto.Util.getRandomHexOfNbits(t),16)},D.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var n=D.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(n))return n}},D.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var n=t.compareTo(e);if(1==n)throw"biMin is greater than biMax";return 0==n?t:(n=e.subtract(t),D.crypto.Util.getRandomBigIntegerZeroToMax(n).add(t))},D.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(e,t){if(null!==(e=D.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=D.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=D.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){t=C.enc.Hex.parse(t);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(C.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){t=sjcl.codec.hex.toBits(t);this.md.update(t)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=D.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},D.crypto.MessageDigest.getCanonicalAlgName=function(t){return t="string"==typeof t?(t=t.toLowerCase()).replace(/-/,""):t},D.crypto.MessageDigest.getHashLength=function(t){var e=D.crypto.MessageDigest,n=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[n])throw"not supported algorithm: "+t;return e.HASHLENGTH[n]},D.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},D.crypto.Mac=function(t){this.setAlgAndProvider=function(e,t){if("hmac"!=(e=(e=null==(e=e.toLowerCase())?"hmacsha1":e).toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=D.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;e=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{var n=D.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e];this.mac=C.algo.HMAC.create(n,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+e+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){t=C.enc.Hex.parse(t);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(C.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t)(e=t).length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=rstrtohex(t));else{if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;var e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=utf8tohex(t.utf8)),void 0!==t.rstr&&(e=rstrtohex(t.rstr)),void 0!==t.b64&&(e=b64tohex(t.b64)),null==(e=void 0!==t.b64u?b64utohex(t.b64u):e))throw"KJUR.crypto.Mac unsupported password type: "+t}this.pass=C.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg)&&(this.algName=t.alg,void 0===t.prov&&(this.provName=D.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},D.crypto.Signature=function(t){if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName)&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1")},this._zeroPaddingOfSignature=function(t,e){for(var n="",r=e/4-t.length,i=0;i<r;i++)n+="0";return n+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new D.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var n=null;try{n=void 0===e?b.getKey(t):b.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===n.isPrivate)this.prvKey=n,this.state="SIGN";else{if(!0!==n.isPublic)throw"init failed.:"+n;this.pubKey=n,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==D.crypto.ECDSA&&(this.prvKey=new D.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else{if(!(this.prvKey instanceof D.crypto.ECDSA||this.prvKey instanceof D.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==D.crypto.ECDSA&&(this.pubKey=new D.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==D.crypto.ECDSA&&this.pubKey instanceof D.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==D.crypto.DSA&&this.pubKey instanceof D.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},void 0!==(this.initParams=t)&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=D.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{var e=b.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},D.crypto.Cipher=function(t){},D.crypto.Cipher.encrypt=function(t,e,n){if(e instanceof RSAKey&&e.isPublic){var r=D.crypto.Cipher.getAlgByKeyAndName(e,n);if("RSA"===r)return e.encrypt(t);if("RSAOAEP"===r)return e.encryptOAEP(t,"sha1");r=r.match(/^RSAOAEP(\d+)$/);if(null!==r)return e.encryptOAEP(t,"sha"+r[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+n}throw"Cipher.encrypt: unsupported key or algorithm"},D.crypto.Cipher.decrypt=function(t,e,n){if(e instanceof RSAKey&&e.isPrivate){var r=D.crypto.Cipher.getAlgByKeyAndName(e,n);if("RSA"===r)return e.decrypt(t);if("RSAOAEP"===r)return e.decryptOAEP(t,"sha1");r=r.match(/^RSAOAEP(\d+)$/);if(null!==r)return e.decryptOAEP(t,"sha"+r[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+n}throw"Cipher.decrypt: unsupported key or algorithm"},D.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof RSAKey){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},D.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==(D=void 0!==D&&D?D:{}).crypto&&D.crypto||(D.crypto={}),D.crypto.ECDSA=function(t){var i=Error,h=BigInteger,u=ECPointFp,c=D.crypto.ECDSA,e=D.crypto.ECParameterDB,s=c.getName,a=E.getVbyListEx,o=E.isASN1HEX,n=new SecureRandom;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new h(t.bitLength(),n).mod(t.subtract(h.ONE)).add(h.ONE)},this.setNamedCurve=function(t){this.ecparams=e.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var n={};return n.x=t.substr(2,e),n.y=t.substr(2+e),n},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,t=this.getBigRandom(t),e=this.ecparams.keycharlen,t=("0000000000"+t.toString(16)).slice(-e);return this.setPrivateKeyHex(t),{ecprvhex:t,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new h(this.prvKeyHex,16),t=this.ecparams.G.multiply(t),e=t.getX().toBigInteger(),t=t.getY().toBigInteger(),n=this.ecparams.keycharlen,e="04"+("0000000000"+e.toString(16)).slice(-n)+("0000000000"+t.toString(16)).slice(-n);return this.setPublicKeyHex(e),e},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var e=new h(e,16),n=this.ecparams.n,t=new h(t.substring(0,this.ecparams.keycharlen),16);do{var r=this.getBigRandom(n),i=this.ecparams.G.multiply(r).getX().toBigInteger().mod(n)}while(i.compareTo(h.ZERO)<=0);t=r.modInverse(n).multiply(t.add(e.multiply(i))).mod(n);return c.biRSSigToASN1Sig(i,t)},this.sign=function(t,e){var n=this.ecparams.n,t=h.fromByteArrayUnsigned(t);do{var r=this.getBigRandom(n),i=this.ecparams.G.multiply(r).getX().toBigInteger().mod(n)}while(i.compareTo(BigInteger.ZERO)<=0);t=r.modInverse(n).multiply(t.add(e.multiply(i))).mod(n);return this.serializeSig(i,t)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,n){try{var r=c.parseSigHex(e),i=r.r,s=r.s,a=u.decodeFromHex(this.ecparams.curve,n),o=new h(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(o,i,s,a)}catch(t){return!1}},this.verify=function(t,e,n){var r;if(Bitcoin.Util.isArray(e))var i=this.parseSig(e),s=i.r,i=i.s;else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,i=e.s}if(n instanceof ECPointFp)r=n;else{if(!Bitcoin.Util.isArray(n))throw"Invalid format for pubkey value, must be byte array or ECPointFp";r=u.decodeFrom(this.ecparams.curve,n)}e=h.fromByteArrayUnsigned(t);return this.verifyRaw(e,s,i,r)},this.verifyRaw=function(t,e,n,r){var i=this.ecparams.n,s=this.ecparams.G;return!(e.compareTo(h.ONE)<0||0<=e.compareTo(i)||n.compareTo(h.ONE)<0||0<=n.compareTo(i))&&(n=n.modInverse(i),t=t.multiply(n).mod(i),n=e.multiply(n).mod(i),s.multiply(t).add(r.multiply(n)).getX().toBigInteger().mod(i).equals(e))},this.serializeSig=function(t,e){var t=t.toByteArraySigned(),e=e.toByteArraySigned(),n=[];return n.push(2),n.push(t.length),(n=n.concat(t)).push(2),n.push(e.length),(n=n.concat(e)).unshift(n.length),n.unshift(48),n},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if((e=2)!=t[2])throw new Error("First element in signature must be a DERInteger");var n=t.slice(4,4+t[3]);if(2!=t[e+=2+t[3]])throw new Error("Second element in signature must be a DERInteger");var r=t.slice(e+2,e+2+t[e+1]);return t[e+1],{r:h.fromByteArrayUnsigned(n),s:h.fromByteArrayUnsigned(r)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||7<e)throw"Invalid signature type";var n=this.ecparams.n;return{r:h.fromByteArrayUnsigned(t.slice(1,33)).mod(n),s:h.fromByteArrayUnsigned(t.slice(33,65)).mod(n),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===o(t))throw new Error("not ASN.1 hex string");var e,n,r;try{e=a(t,0,["[0]",0],"06"),n=a(t,0,[1],"04");try{r=a(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(r),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===o(t))throw new i("not ASN.1 hex string");var e,n,r;try{a(t,0,[1,0],"06"),e=a(t,0,[1,1],"06"),n=a(t,0,[2,0,1],"04");try{r=a(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new i("malformed PKCS#8 plain ECC private key")}if(this.curveName=s(e),void 0===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(r),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===o(t))throw new i("not ASN.1 hex string");var e,n;try{a(t,0,[0,0],"06"),e=a(t,0,[0,1],"06"),n=a(t,0,[1],"03")}catch(t){throw new i("malformed PKCS#8 ECC public key")}if(this.curveName=s(e),null===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},this.readCertPubKeyHex=function(t,e){if(!1===o(t))throw new i("not ASN.1 hex string");var n,r;try{n=a(t,0,[0,5,0,1],"06"),r=a(t,0,[0,5,1],"03")}catch(t){throw new i("malformed X.509 certificate ECC public key")}if(this.curveName=s(n),null===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(r)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub)&&this.setPublicKeyHex(t.pub)},D.crypto.ECDSA.parseSigHex=function(t){t=D.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new BigInteger(t.r,16),s:new BigInteger(t.s,16)}},D.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=E,n=e.getChildIdx,r=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");e=n(t,0);if(2!=e.length)throw new Error("signature shall have two elements");n=e[0],e=e[1];if("02"!=t.substr(n,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(e,2))throw new Error("2nd item not ASN.1 integer");return{r:r(t,n),s:r(t,e)}},D.crypto.ECDSA.asn1SigToConcatSig=function(t){var t=D.crypto.ECDSA.parseSigHexInHexRS(t),e=t.r,t=t.s;if(130<=e.length&&e.length<=134){if(e.length%2!=0)throw Error("unknown ECDSA sig r length error");if(t.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==e.substr(0,2)&&(e=e.substr(2)),"00"==t.substr(0,2)&&(t=t.substr(2));var n=Math.max(e.length,t.length);return(e=("000000"+e).slice(-n))+(t=("000000"+t).slice(-n))}if("00"==e.substr(0,2)&&e.length%32==2&&(e=e.substr(2)),"00"==t.substr(0,2)&&t.length%32==2&&(t=t.substr(2)),e.length%32==30&&(e="00"+e),t.length%32==30&&(t="00"+t),e.length%32!=0)throw Error("unknown ECDSA sig r length error");if(t.length%32!=0)throw Error("unknown ECDSA sig s length error");return e+t},D.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),t=t.substr(t.length/2);return D.crypto.ECDSA.hexRSSigToASN1Sig(e,t)},D.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){t=new BigInteger(t,16),e=new BigInteger(e,16);return D.crypto.ECDSA.biRSSigToASN1Sig(t,e)},D.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var n=D.asn1,t=new n.DERInteger({bigint:t}),e=new n.DERInteger({bigint:e});return new n.DERSequence({array:[t,e]}).tohex()},D.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==(D=void 0!==D&&D?D:{}).crypto&&D.crypto||(D.crypto={}),D.crypto.ECParameterDB=new function(){var p={},d={};function a(t){return new BigInteger(t,16)}this.getByName=function(t){var e=t;if(void 0!==d[e]&&(e=d[t]),void 0!==p[e])return p[e];throw"unregistered EC curve name: "+e},this.regist=function(t,e,n,r,i,s,o,h,u,c,l,f){p[t]={};n=a(n),r=a(r),i=a(i),s=a(s),o=a(o),n=new ECCurveFp(n,r,i),r=n.decodePointHex("04"+h+u);p[t].name=t,p[t].keylen=e,p[t].keycharlen=2*Math.ceil(e/8),p[t].curve=n,p[t].G=r,p[t].n=s,p[t].h=o,p[t].oid=l,p[t].info=f;for(var g=0;g<c.length;g++)d[c[g]]=t}},D.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),D.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),D.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),D.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),D.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),D.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),D.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),D.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),D.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),D.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==(D=void 0!==D&&D?D:{}).crypto&&D.crypto||(D.crypto={}),D.crypto.DSA=function(){E.getVbyList;var a=E.getVbyListEx,o=E.isASN1HEX,e=BigInteger;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,n,r,i){this.isPrivate=!0,this.p=t,this.q=e,this.g=n,this.y=r,this.x=i},this.setPrivateHex=function(t,e,n,r,i){t=new BigInteger(t,16),e=new BigInteger(e,16),n=new BigInteger(n,16),r="string"==typeof r&&1<r.length?new BigInteger(r,16):null,i=new BigInteger(i,16);this.setPrivate(t,e,n,r,i)},this.setPublic=function(t,e,n,r){this.isPublic=!0,this.p=t,this.q=e,this.g=n,this.y=r,this.x=null},this.setPublicHex=function(t,e,n,r){t=new BigInteger(t,16),e=new BigInteger(e,16),n=new BigInteger(n,16),r=new BigInteger(r,16);this.setPublic(t,e,n,r)},this.signWithMessageHash=function(t){var e=this.p,n=this.q,r=this.g,i=(this.y,this.x),s=D.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),n.subtract(BigInteger.ONE)),t=new BigInteger(t.substr(0,n.bitLength()/4),16),r=r.modPow(s,e).mod(n),e=s.modInverse(n).multiply(t.add(i.multiply(r))).mod(n);return D.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:e}}]})},this.verifyWithMessageHash=function(t,e){var n=this.p,r=this.q,i=this.g,s=this.y,e=this.parseASN1Signature(e),a=e[0],e=e[1],t=new BigInteger(t.substr(0,r.bitLength()/4),16);if(0<BigInteger.ZERO.compareTo(a)||0<a.compareTo(r))throw"invalid DSA signature";if(0<=BigInteger.ZERO.compareTo(e)||0<e.compareTo(r))throw"invalid DSA signature";e=e.modInverse(r),t=t.multiply(e).mod(r),e=a.multiply(e).mod(r);return 0==i.modPow(t,n).multiply(s.modPow(e,n)).mod(n).mod(r).compareTo(a)},this.parseASN1Signature=function(t){try{return[new e(a(t,0,[0],"02"),16),new e(a(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var e,n,r,i,s;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[1],"02"),n=a(t,0,[2],"02"),r=a(t,0,[3],"02"),i=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(e,n,r,i,s)},this.readPKCS8PrvKeyHex=function(t){var e,n,r,i;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[1,1,0],"02"),n=a(t,0,[1,1,1],"02"),r=a(t,0,[1,1,2],"02"),i=a(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(e,n,r,null,i)},this.readPKCS8PubKeyHex=function(t){var e,n,r,i;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[0,1,0],"02"),n=a(t,0,[0,1,1],"02"),r=a(t,0,[0,1,2],"02"),i=a(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(e,n,r,i)},this.readCertPubKeyHex=function(t,e){var n,r,i,s;if(!1===o(t))throw new Error("not ASN.1 hex string");try{n=a(t,0,[0,5,0,1,0],"02"),r=a(t,0,[0,5,0,1,1],"02"),i=a(t,0,[0,5,0,1,2],"02"),s=a(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(n,r,i,s)}};var b=function(){function u5a(t,e,n){return x5a(C.AES,t,e,n)}function x5a(t,e,n,r){var e=C.enc.Hex.parse(e),n=C.enc.Hex.parse(n),r=C.enc.Hex.parse(r),i={},e=(i.key=n,i.iv=r,i.ciphertext=e,t.decrypt(i,n,{iv:r}));return C.enc.Hex.stringify(e)}function y5a(t,e,n){return B5a(C.AES,t,e,n)}function B5a(t,e,n,r){return e=C.enc.Hex.parse(e),n=C.enc.Hex.parse(n),r=C.enc.Hex.parse(r),t=t.encrypt(e,n,{iv:r}),e=C.enc.Hex.parse(t.toString()),C.enc.Base64.stringify(e)}function F5a(t){var e={};(n=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m")))&&(e.cipher=n[1],e.ivsalt=n[2]);(n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----")))&&(e.type=n[1]);var n=-1,r=0,i=(-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),r=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),r=1),t.indexOf("-----END"));return-1!=n&&-1!=i&&(t=(t=t.substring(n+2*r,i-r)).replace(/\s+/g,""),e.data=t),e}function G5a(t,e,n){for(var n=n.substring(0,16),r=C.enc.Hex.parse(n),i=C.enc.Utf8.parse(e),s=u[t].keylen+u[t].ivlen,a="",o=null;;){var h=C.algo.MD5.create();if(null!=o&&h.update(o),h.update(i),h.update(r),o=h.finalize(),(a+=C.enc.Hex.stringify(o)).length>=2*s)break}return(n={}).keyhex=a.substr(0,2*u[t].keylen),n.ivhex=a.substr(2*u[t].keylen,2*u[t].ivlen),n}function H5a(t,e,n,r){return t=C.enc.Base64.parse(t),t=C.enc.Hex.stringify(t),(0,u[e].proc)(t,n,r)}var u={"AES-256-CBC":{proc:u5a,eproc:y5a,keylen:32,ivlen:16},"AES-192-CBC":{proc:u5a,eproc:y5a,keylen:24,ivlen:16},"AES-128-CBC":{proc:u5a,eproc:y5a,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,n){return x5a(C.TripleDES,t,e,n)},eproc:function(t,e,n){return B5a(C.TripleDES,t,e,n)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,n){return x5a(C.DES,t,e,n)},eproc:function(t,e,n){return B5a(C.DES,t,e,n)},keylen:8,ivlen:8}};return{version:"1.0.0",parsePKCS5PEM:function(t){return F5a(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,n){return G5a(t,e,n)},decryptKeyB64:function(t,e,n,r){return H5a(t,e,n,r)},getDecryptedKeyHex:function(t,e){var t=F5a(t),n=(t.type,t.cipher),r=t.ivsalt,t=t.data,e=G5a(n,e,r).keyhex;return H5a(t,n,e,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,n,r,i){if(void 0===u[r=void 0!==r&&null!=r?r:"AES-256-CBC"])throw new Error("KEYUTIL unsupported algorithm: "+r);var s="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return(s+="Proc-Type: 4,ENCRYPTED\r\n")+("DEK-Info: "+r+","+(i=void 0!==i&&null!=i?i:function(t){t=C.lib.WordArray.random(t);return C.enc.Hex.stringify(t)}(u[r].ivlen).toUpperCase())+"\r\n")+"\r\n"+function(t,e,n,r){return(0,u[e].eproc)(t,n,r)}(e,r,G5a(r,n,i).keyhex,i).replace(/(.{64})/g,"$1\r\n")+("\r\n-----END "+t+" PRIVATE KEY-----\r\n")},parseHexOfEncryptedPKCS8:function(t){var e=E.getChildIdx,n=E.getV,r={},i=e(t,0);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+i.length);r.ciphertext=n(t,i[1]);i=e(t,i[0]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+i.length);if("2a864886f70d01050d"!=n(t,i[0]))throw new Error("this only supports pkcs5PBES2");var s=e(t,i[1]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+s.length);i=e(t,s[1]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+i.length);if("2a864886f70d0307"!=n(t,i[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,i[1]);i=e(t,s[0]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+i.length);if("2a864886f70d01050c"!=n(t,i[0]))throw new Error("this only supports pkcs5PBKDF2");s=e(t,i[1]);if(s.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+s.length);r.pbkdf2Salt=n(t,s[0]);e=n(t,s[1]);try{r.pbkdf2Iter=parseInt(e,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+e)}return r},getPBKDF2KeyHexFromParam:function(t,e){var n=C.enc.Hex.parse(t.pbkdf2Salt),t=t.pbkdf2Iter,e=C.PBKDF2(e,n,{keySize:6,iterations:t});return C.enc.Hex.stringify(e)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var t=pemtohex(t,"ENCRYPTED PRIVATE KEY"),t=this.parseHexOfEncryptedPKCS8(t),e=b.getPBKDF2KeyHexFromParam(t,e),n={},e=(n.ciphertext=C.enc.Hex.parse(t.ciphertext),C.enc.Hex.parse(e)),t=C.enc.Hex.parse(t.encryptionSchemeIV),n=C.TripleDES.decrypt(n,e,{iv:t});return C.enc.Hex.stringify(n)},getKeyFromEncryptedPKCS8PEM:function(t,e){t=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(t)},parsePlainPrivatePKCS8Hex:function(t){var e=E,n=e.getChildIdx,r=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=n(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");n=n(t,s[1]);if(2!=n.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(n[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=r(t,n[0]),"06"==t.substr(n[1],2)&&(i.algparam=r(t,n[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){t=pemtohex(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,n=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==n.algoid)e=new RSAKey;else if("2a8648ce380401"==n.algoid)e=new D.crypto.DSA;else{if("2a8648ce3d0201"!=n.algoid)throw new Error("unsupported private key algorithm");e=new D.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,n=E.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===n)e=new RSAKey;else if("2a8648ce380401"===n)e=new D.crypto.DSA;else{if("2a8648ce3d0201"!==n)throw new Error("unsupported PKCS#8 public key hex");e=new D.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=E.getChildIdx,n=E.getV,r={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");e=e(t,0);if(2!=e.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(e[0],2))throw new Error("malformed RSA key(code:003)");if(r.n=n(t,e[0]),"02"!=t.substr(e[1],2))throw new Error("malformed RSA key(code:004)");return r.e=n(t,e[1]),r},parsePublicPKCS8Hex:function(t){var e=E,n=e.getChildIdx,r=e.getV,i={algparam:null},s=n(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var a=s[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");n=n(t,a);if(2!=n.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(n[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=r(t,n[0]),"06"==t.substr(n[1],2)?i.algparam=r(t,n[1]):"30"==t.substr(n[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,n[1],[0],"02"),i.algparam.q=e.getVbyList(t,n[1],[1],"02"),i.algparam.g=e.getVbyList(t,n[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=r(t,s[1]).substr(2),i}}}();b.getKey=function(t,e,n){var r,i,s,a,o,h,u=E.getChildIdx,c=(E.getV,E.getVbyList),l=D.crypto,f=l.ECDSA,l=l.DSA,g=RSAKey,p=pemtohex,d=b;if(void 0!==g&&t instanceof g)return t;if(void 0!==f&&t instanceof f)return t;if(void 0!==l&&t instanceof l)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new f({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new f({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(S=new g).setPublic(t.n,t.e),S;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(S=new g).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),S;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(S=new g).setPrivate(t.n,t.e,t.d),S;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(S=new l).setPublic(t.p,t.q,t.g,t.y),S;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(S=new l).setPrivate(t.p,t.q,t.g,t.y,t.x),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(S=new g).setPublic(b64utohex(t.n),b64utohex(t.e)),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(S=new g).setPrivateEx(b64utohex(t.n),b64utohex(t.e),b64utohex(t.d),b64utohex(t.p),b64utohex(t.q),b64utohex(t.dp),b64utohex(t.dq),b64utohex(t.qi)),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(S=new g).setPrivate(b64utohex(t.n),b64utohex(t.e),b64utohex(t.d)),S;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d)return y=(v=new f({curve:t.crv})).ecparams.keycharlen,m="04"+("0000000000"+b64utohex(t.x)).slice(-y)+("0000000000"+b64utohex(t.y)).slice(-y),v.setPublicKeyHex(m),v;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d)return y=(v=new f({curve:t.crv})).ecparams.keycharlen,m="04"+("0000000000"+b64utohex(t.x)).slice(-y)+("0000000000"+b64utohex(t.y)).slice(-y),y=("0000000000"+b64utohex(t.d)).slice(-y),v.setPublicKeyHex(m),v.setPrivateKeyHex(y),v;if("pkcs5prv"===n){var m=t,y=u(m,0);if(9===y.length)(S=new g).readPKCS5PrvKeyHex(m);else if(6===y.length)(S=new l).readPKCS5PrvKeyHex(m);else{if(!(2<y.length&&"04"===m.substr(y[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(S=new f).readPKCS5PrvKeyHex(m)}return S}if("pkcs8prv"===n)return S=d.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===n)return d._getKeyFromPublicPKCS8Hex(t);if("x509pub"===n)return X509.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return X509.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-"))return u=pemtohex(t,"PUBLIC KEY"),d._getKeyFromPublicPKCS8Hex(u);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return r=p(t,"RSA PRIVATE KEY"),d.getKey(r,null,"pkcs5prv");if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return i=c(x=p(t,"DSA PRIVATE KEY"),0,[1],"02"),s=c(x,0,[2],"02"),a=c(x,0,[3],"02"),o=c(x,0,[4],"02"),h=c(x,0,[5],"02"),(S=new l).setPrivate(new BigInteger(i,16),new BigInteger(s,16),new BigInteger(a,16),new BigInteger(o,16),new BigInteger(h,16)),S;if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return r=p(t,"EC PRIVATE KEY"),d.getKey(r,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return d.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return g=d.getDecryptedKeyHex(t,e),(y=new RSAKey).readPKCS5PrvKeyHex(g),y;if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var x,v,S=c(x=d.getDecryptedKeyHex(t,e),0,[1],"04"),m=c(x,0,[2,0],"06"),n=c(x,0,[3,0],"03").substr(2);if(void 0===D.crypto.OID.oidhex2name[m])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+m);return(v=new f({curve:D.crypto.OID.oidhex2name[m]})).setPublicKeyHex(n),v.setPrivateKeyHex(S),v.isPublic=!1,v}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return i=c(x=d.getDecryptedKeyHex(t,e),0,[1],"02"),s=c(x,0,[2],"02"),a=c(x,0,[3],"02"),o=c(x,0,[4],"02"),h=c(x,0,[5],"02"),(S=new l).setPrivate(new BigInteger(i,16),new BigInteger(s,16),new BigInteger(a,16),new BigInteger(o,16),new BigInteger(h,16)),S;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return d.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},b.generateKeypair=function(t,e){var n,r,i,s;if("RSA"==t)return i=e,(r=new RSAKey).generate(i,"10001"),r.isPrivate=!0,r.isPublic=!0,i=new RSAKey,s=r.n.toString(16),n=r.e.toString(16),i.setPublic(s,n),i.isPrivate=!1,i.isPublic=!0,(s={}).prvKeyObj=r,s.pubKeyObj=i,s;if("EC"==t)return e=new D.crypto.ECDSA({curve:n=e}).generateKeyPairHex(),(r=new D.crypto.ECDSA({curve:n})).setPublicKeyHex(e.ecpubhex),r.setPrivateKeyHex(e.ecprvhex),r.isPrivate=!0,r.isPublic=!1,(i=new D.crypto.ECDSA({curve:n})).setPublicKeyHex(e.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(s={}).prvKeyObj=r,s.pubKeyObj=i,s;throw new Error("unknown algorithm: "+t)},b.getPEM=function(t,e,n,r,i,s){var a=D,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,o=o.x509.SubjectPublicKeyInfo,a=a.crypto,l=a.DSA,a=a.ECDSA,f=RSAKey;function A(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function B(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function x(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((t instanceof f||void 0!==l&&t instanceof l||void 0!==a&&t instanceof a)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return hextopem(p=new o(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&t instanceof f&&(void 0===n||null==n)&&1==t.isPrivate)return hextopem(p=A(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==a&&t instanceof a&&(void 0===n||null==n)&&1==t.isPrivate)return o=new h({name:t.curveName}).tohex(),d=B(t).tohex(),h="",(h+=hextopem(o,"EC PARAMETERS"))+hextopem(d,"EC PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==l&&t instanceof l&&(void 0===n||null==n)&&1==t.isPrivate)return hextopem(p=x(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&t instanceof f&&void 0!==n&&null!=n&&1==t.isPrivate)return p=A(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",p,n,r=void 0===r?"DES-EDE3-CBC":r,s);if("PKCS5PRV"==e&&void 0!==a&&t instanceof a&&void 0!==n&&null!=n&&1==t.isPrivate)return p=B(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",p,n,r=void 0===r?"DES-EDE3-CBC":r,s);if("PKCS5PRV"==e&&void 0!==l&&t instanceof l&&void 0!==n&&null!=n&&1==t.isPrivate)return p=x(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",p,n,r=void 0===r?"DES-EDE3-CBC":r,s);function cia(t,e){return t=m(t,e),new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:t.pbkdf2Salt}},{int:t.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:t.encryptionSchemeIV}}]}]}]},{octstr:{hex:t.ciphertext}}]}).tohex()}var g,p,d,m=function(t,e){var n=C.lib.WordArray.random(8),r=C.lib.WordArray.random(8),e=C.PBKDF2(e,n,{keySize:6,iterations:100}),t=C.enc.Hex.parse(t),t=C.TripleDES.encrypt(t,e,{iv:r})+"",e={};return e.ciphertext=t,e.pbkdf2Salt=C.enc.Hex.stringify(n),e.pbkdf2Iter=100,e.encryptionSchemeAlg="DES-EDE3-CBC",e.encryptionSchemeIV=C.enc.Hex.stringify(r),e};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate)return g=A(t).tohex(),p=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:g}}]}).tohex(),void 0===n||null==n?hextopem(p,"PRIVATE KEY"):hextopem(d=cia(p,n),"ENCRYPTED PRIVATE KEY");if("PKCS8PRV"==e&&void 0!==a&&t instanceof a&&1==t.isPrivate)return o={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]},"string"==typeof t.pubKeyHex&&o.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),g=new c(o).tohex(),p=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:g}}]}).tohex(),void 0===n||null==n?hextopem(p,"PRIVATE KEY"):hextopem(d=cia(p,n),"ENCRYPTED PRIVATE KEY");if("PKCS8PRV"==e&&void 0!==l&&t instanceof l&&1==t.isPrivate)return g=new u({bigint:t.x}).tohex(),p=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:g}}]}).tohex(),void 0===n||null==n?hextopem(p,"PRIVATE KEY"):hextopem(d=cia(p,n),"ENCRYPTED PRIVATE KEY");throw new Error("unsupported object nor format")},b.getKeyFromCSRPEM=function(t){t=pemtohex(t,"CERTIFICATE REQUEST");return b.getKeyFromCSRHex(t)},b.getKeyFromCSRHex=function(t){t=b.parseCSRHex(t);return b.getKey(t.p8pubkeyhex,null,"pkcs8pub")},b.parseCSRHex=function(t){var e=E.getChildIdx,n=E.getTLV,r={};if("30"!=t.substr(0,2))throw new Error("malformed CSR(code:001)");var i=e(t,0);if(i.length<1)throw new Error("malformed CSR(code:002)");if("30"!=t.substr(i[0],2))throw new Error("malformed CSR(code:003)");e=e(t,i[0]);if(e.length<3)throw new Error("malformed CSR(code:004)");return r.p8pubkeyhex=n(t,e[2]),r},b.getKeyID=function(t){var e=b,n=E,e=("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t)),pemtohex(e.getPEM(t))),t=n.getIdxbyList(e,0,[1]),n=n.getV(e,t).substring(2);return D.crypto.Util.hashHex(n,"sha1")},b.getJWK=function(t,e,n,r,i){var s,a,o,h={},u=D.crypto.Util.hashHex;if("string"==typeof t)s=b.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=pemtohex(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof X509?(s=t.getPublicKey(),a=t.hex):s=t}if(s instanceof RSAKey&&s.isPrivate)h.kty="RSA",h.n=hextob64u(s.n.toString(16)),h.e=hextob64u(s.e.toString(16)),h.d=hextob64u(s.d.toString(16)),h.p=hextob64u(s.p.toString(16)),h.q=hextob64u(s.q.toString(16)),h.dp=hextob64u(s.dmp1.toString(16)),h.dq=hextob64u(s.dmq1.toString(16)),h.qi=hextob64u(s.coeff.toString(16));else if(s instanceof RSAKey&&s.isPublic)h.kty="RSA",h.n=hextob64u(s.n.toString(16)),h.e=hextob64u(s.e.toString(16));else if(s instanceof D.crypto.ECDSA&&s.isPrivate){if("P-256"!==(o=s.getShortNISTPCurveName())&&"P-384"!==o&&"P-521"!==o)throw new Error("unsupported curve name for JWT: "+o);var c=s.getPublicKeyXYHex();h.kty="EC",h.crv=o,h.x=hextob64u(c.x),h.y=hextob64u(c.y),h.d=hextob64u(s.prvKeyHex)}else if(s instanceof D.crypto.ECDSA&&s.isPublic){if("P-256"!==(o=s.getShortNISTPCurveName())&&"P-384"!==o&&"P-521"!==o)throw new Error("unsupported curve name for JWT: "+o);c=s.getPublicKeyXYHex();h.kty="EC",h.crv=o,h.x=hextob64u(c.x),h.y=hextob64u(c.y)}if(null==h.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(h.kid=D.jws.JWS.getJWKthumbprint(h)),null!=a&&1!=n&&(h.x5c=[hex2b64(a)]),null!=a&&1!=r&&(h.x5t=b64tob64u(hex2b64(u(a,"sha1")))),null!=a&&1!=i&&(h["x5t#S256"]=b64tob64u(hex2b64(u(a,"sha256")))),h},b.getJWKFromKey=function(t){return b.getJWK(t,!0,!0,!0,!0)},RSAKey.getPosArrayOfChildrenFromHex=function(t){return E.getChildIdx(t,0)},RSAKey.getHexValueArrayOfChildrenFromHex=function(t){var e=E.getV,n=RSAKey.getPosArrayOfChildrenFromHex(t),r=e(t,n[0]),i=e(t,n[1]),s=e(t,n[2]),a=e(t,n[3]),o=e(t,n[4]),h=e(t,n[5]),u=e(t,n[6]),c=e(t,n[7]),e=e(t,n[8]);return(n=new Array).push(r,i,s,a,o,h,u,c,e),n},RSAKey.prototype.readPrivateKeyFromPEMString=function(t){t=pemtohex(t),t=RSAKey.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},RSAKey.prototype.readPKCS5PrvKeyHex=function(t){t=RSAKey.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},RSAKey.prototype.readPKCS8PrvKeyHex=function(t){var e,n,r,i,s,a,o,h,u=E,c=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),n=c(t,0,[2,0,2],"02"),r=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,n,r,i,s,a,o,h)},RSAKey.prototype.readPKCS5PubKeyHex=function(t){var e=E,n=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");e=e.getChildIdx(t,0);if(2!==e.length||"02"!==t.substr(e[0],2)||"02"!==t.substr(e[1],2))throw new Error("wrong hex for PKCS#5 public key");var r=n(t,e[0]),n=n(t,e[1]);this.setPublic(r,n)},RSAKey.prototype.readPKCS8PubKeyHex=function(t){var e=E;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");e=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(e)},RSAKey.prototype.readCertPubKeyHex=function(t,e){var n=new X509;n.readCertHex(t),t=n.getPublicKeyHex(),this.readPKCS8PubKeyHex(t)};function _zeroPaddingOfSignature(t,e){for(var n="",r=e/4-t.length,i=0;i<r;i++)n+="0";return n+t}function pss_mgf1_str(t,e,n){for(var r="",i=0;r.length<e;)r+=hextorstr(n(rstrtohex(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return r}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(t){for(var e in D.crypto.Util.DIGESTINFOHEAD){var n=D.crypto.Util.DIGESTINFOHEAD[e],r=n.length;if(t.substring(0,r)==n)return[e,t.substring(r)]}return[]}function X509(t){var n,o=E,l=o.getChildIdx,h=o.getV,u=(o.dump,o.parse),f=o.getTLV,c=o.getVbyList,g=o.getVbyListEx,i=o.getTLVbyList,s=o.getTLVbyListEx,p=o.getIdxbyList,a=o.getIdxbyListEx,d=o.getVidx,r=o.getInt,m=o.oidname,y=o.hextooidstr,e=pemtohex,x=Error;try{n=D.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null!==this.hex&&0===this.version){var t=i(this.hex,0,[0,0]);if("a0"!=t.substr(0,2))return this.version=1,this.foffset=-1,1;t=i(t,0,[0]),t=r(t,0);if(t<0||2<t)throw new Error("malformed version field");this.version=t+1}return this.version},this.getSerialNumberHex=function(){return g(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=s(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var e in n)if(t===n[e])return e;return m(g(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return i(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},this.getSubjectHex=function(){return i(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=(t=c(this.hex,0,[0,4+this.foffset,0])).replace(/(..)/g,"%$1");return t=decodeURIComponent(t)},this.getNotAfter=function(){var t=(t=c(this.hex,0,[0,4+this.foffset,1])).replace(/(..)/g,"%$1");return t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return i(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:c(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return p(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return p(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return b.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=i(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return c(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),n=this.getSignatureValueHex(),r=i(this.hex,0,[0],"30"),e=new D.crypto.Signature({alg:e});return e.init(t),e.updateHex(r),e.verify(n)},this.parseExt=function(t){var e,n;if(void 0===t){if(r=this.hex,3!==this.version)return-1;e=p(r,0,[0,7,0],"30"),n=l(r,e)}else{var r=pemtohex(t),t=p(r,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=h(r,t))return void(this.aExtInfo=new Array);e=p(r,0,[0,3,0,1,0],"30"),n=l(r,e),this.hex=r}this.aExtInfo=new Array;for(var i=0;i<n.length;i++){var s={critical:!1},a=0,a=(3===l(r,n[i]).length&&(s.critical=!0,a=1),s.oid=o.hextooidstr(c(r,n[i],[0],"06")),p(r,n[i],[1+a]));s.vidx=d(r,a),this.aExtInfo.push(s)}},this.getExtInfo=function(t){var e=this.aExtInfo,n=t;if(""!==(n=t.match(/^[0-9.]+$/)?n:D.asn1.x509.OID.name2oid(t)))for(var r=0;r<e.length;r++)if(e[r].oid===n)return e[r]},this.getCriticalExtV=function(t,e,n){return null!=e?[e,n]:null==(e=this.getExtInfo(t))?[null,null]:[f(this.hex,e.vidx),e.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("basicConstraints");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}n={extname:"basicConstraints"};if(e&&(n.critical=!0),"3000"===t)return n;if("30030101ff"===t)return n.cA=!0,n;if("30060101ff02"===t.substr(0,12))return e=h(t,10),e=parseInt(e,16),n.cA=!0,n.pathLen=e,n;throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var n=this.getCriticalExtV("nameConstraints",t,e);if(t=n[0],e=n[1],null!=t){for(var r={extname:"nameConstraints"},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++){for(var a=[],o=l(t,i[s]),h=0;h<o.length;h++){var u=f(t,o[h]),u=this.getGeneralSubtree(u);a.push(u)}var c=t.substr(i[s],2);"a0"==c?r.permit=a:"a1"==c&&(r.exclude=a)}return r}},this.getGeneralSubtree=function(t){var e=l(t,0),n=e.length;if(n<1||2<n)throw new Error("wrong num elements");for(var r=this.getGeneralName(f(t,e[0])),i=1;i<n;i++){var s=t.substr(e[i],2),a=h(t,e[i]),a=parseInt(a,16);"80"==s&&(r.min=a),"81"==s&&(r.max=a)}return r},this.getExtKeyUsage=function(t,e){var n=this.getCriticalExtV("keyUsage",t,e);if(t=n[0],e=n[1],null!=t)return n={extname:"keyUsage"},e&&(n.critical=!0),n.names=this.getExtKeyUsageString(t).split(","),n},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=f(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);e="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(e=e.slice(-8)),e=""==(e=(e=10==t.length?e.slice(-16):e).replace(/0+$/,""))?"0":e},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),n=new Array,r=0;r<e.length;r++)"1"==e.substr(r,1)&&n.push(X509.KEYUSAGE_NAME[r]);return n.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("subjectKeyIdentifier");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}n={extname:"subjectKeyIdentifier"},e&&(n.critical=!0),e=h(t,0);return n.kid={hex:e},n},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("authorityKeyIdentifier");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}for(var r={extname:"authorityKeyIdentifier"},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++){var a,o=t.substr(i[s],2);"80"===o&&(r.kid={hex:h(t,i[s])}),"a1"===o&&(a=f(t,i[s]),a=this.getGeneralNames(a),r.issuer=a[0].dn),"82"===o&&(r.sn={hex:h(t,i[s])})}return r},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("extKeyUsage");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}for(var r={extname:"extKeyUsage",array:[]},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++)r.array.push(m(h(t,i[s])));return r},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,n=f(this.hex,t.vidx);if(""!==n)for(var r=l(n,0),i=0;i<r.length;i++)e.push(m(h(n,r[i])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("subjectAltName");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}n={extname:"subjectAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("issuerAltName");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}n={extname:"issuerAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getGeneralNames=function(t){for(var e=l(t,0),n=[],r=0;r<e.length;r++){var i=this.getGeneralName(f(t,e[r]));void 0!==i&&n.push(i)}return n},this.getGeneralName=function(t){var e=t.substr(0,2),n=h(t,0),r=hextorstr(n);return"81"==e?{rfc822:r}:"82"==e?{dns:r}:"86"==e?{uri:r}:"87"==e?{ip:hextoip(n)}:"a4"==e?{dn:this.getX500Name(n)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,n,r=this.getExtInfo("subjectAltName");if(void 0===r)return r;for(var i=new Array,s=f(this.hex,r.vidx),a=l(s,0),o=0;o<a.length;o++)n=s.substr(a[o],2),t=h(s,a[o]),"81"===n&&(e=hextoutf8(t),i.push(["MAIL",e])),"82"===n&&(e=hextoutf8(t),i.push(["DNS",e])),"84"===n&&(e=X509.hex2dn(t,0),i.push(["DN",e])),"86"===n&&(e=hextoutf8(t),i.push(["URI",e])),"87"===n&&(e=hextoip(t),i.push(["IP",e]));return i},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("cRLDistributionPoints");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}for(var r={extname:"cRLDistributionPoints",array:[]},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=f(t,i[s]);r.array.push(this.getDistributionPoint(a))}return r},this.getDistributionPoint=function(t){for(var e={},n=l(t,0),r=0;r<n.length;r++){var i=t.substr(n[r],2),s=f(t,n[r]);"a0"==i&&(e.dpname=this.getDistributionPointName(s))}return e},this.getDistributionPointName=function(t){for(var e={},n=l(t,0),r=0;r<n.length;r++){var i=t.substr(n[r],2),s=f(t,n[r]);"a0"==i&&(e.full=this.getGeneralNames(s))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,n=[],r=0;r<e.length;r++)try{null!=e[r].dpname.full[0].uri&&n.push(e[r].dpname.full[0].uri)}catch(t){}return n},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},n=l(this.hex,t.vidx),r=0;r<n.length;r++){var i=c(this.hex,n[r],[0],"06"),s=c(this.hex,n[r],[1],"86");"2b06010505073001"===i&&e.ocsp.push(hextoutf8(s)),"2b06010505073002"===i&&e.caissuer.push(hextoutf8(s))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("authorityInfoAccess");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}for(var r={extname:"authorityInfoAccess",array:[]},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=g(t,i[s],[0],"06"),o=hextoutf8(c(t,i[s],[1],"86"));if("2b06010505073001"==a)r.array.push({ocsp:o});else{if("2b06010505073002"!=a)throw new Error("unknown method: "+a);r.array.push({caissuer:o})}}return r},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("certificatePolicies");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}for(var r={extname:"certificatePolicies",array:[]},i=(e&&(r.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=f(t,i[s]),a=this.getPolicyInformation(a);r.array.push(a)}return r},this.getPolicyInformation=function(t){var e={},n=c(t,0,[0],"06"),n=(e.policyoid=m(n),a(t,0,[1],"30"));if(-1!=n){e.array=[];for(var r=l(t,n),i=0;i<r.length;i++){var s=f(t,r[i]),s=this.getPolicyQualifierInfo(s);e.array.push(s)}}return e},this.getOtherName=function(t){var e={},n=l(t,0),r=c(t,n[0],[],"06"),t=c(t,n[1],[]);return e.oid=m(r),e.value=u(t),e},this.getPolicyQualifierInfo=function(t){var e,n={},r=c(t,0,[0],"06");return"2b06010505070201"===r?(e=g(t,0,[1],"16"),n.cps=hextorstr(e)):"2b06010505070202"===r&&(e=i(t,0,[1],"30"),n.unotice=this.getUserNotice(e)),n},this.getUserNotice=function(t){try{var e=o.parse(t);return this._asn1ToUnotice(e)}catch(t){}},this._asn1ToUnotice=function(t){try{for(var e={},n=aryval(t,"seq"),r=0;r<n.length;r++){var i=this._asn1ToNoticeRef(n[r]),s=(null!=i&&(e.noticeref=i),this.asn1ToDisplayText(n[r]));null!=s&&(e.exptext=s)}if(0<Object.keys(e).length)return e}catch(t){}},this._asn1ToNoticeRef=function(t){try{for(var e={},n=aryval(t,"seq"),r=0;r<n.length;r++){var i=this._asn1ToNoticeNum(n[r]),s=(null!=i&&(e.noticenum=i),this.asn1ToDisplayText(n[r]));null!=s&&(e.org=s)}if(0<Object.keys(e).length)return e}catch(t){}},this._asn1ToNoticeNum=function(t){try{for(var e=aryval(t,"seq"),n=[],r=0;r<e.length;r++){var i=e[r];n.push(parseInt(aryval(i,"int.hex"),16))}return n}catch(t){}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=hextorstr(h(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var n=this.getCriticalExtV("policyMappings",t,e);if(t=n[0],e=n[1],null!=t){n={extname:"policyMappings"};e&&(n.critical=!0);try{for(var r=u(t).seq,i=[],s=0;s<r.length;s++){var a=r[s].seq;i.push([a[0].oid,a[1].oid])}n.array=i}catch(t){throw new x("malformed policyMappings")}return n}},this.getExtPolicyConstraints=function(t,e){var n=this.getCriticalExtV("policyConstraints",t,e);if(t=n[0],e=n[1],null!=t){var r={extname:"policyConstraints"},n=(e&&(r.critical=!0),u(t));try{for(var i=n.seq,s=0;s<i.length;s++){var a=i[s].tag;0==a.explicit&&("80"==a.tag&&(r.reqexp=parseInt(a.hex,16)),"81"==a.tag)&&(r.inhibit=parseInt(a.hex,16))}}catch(t){return new x("malformed policyConstraints value")}return r}},this.getExtInhibitAnyPolicy=function(t,e){var n=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=n[0],e=n[1],null!=t)return n={extname:"inhibitAnyPolicy"},e&&(n.critical=!0),-1==(e=r(t,0))?new x("wrong value"):(n.skip=e,n)},this.getExtCRLNumber=function(t,e){var n={extname:"cRLNumber"};if(e&&(n.critical=!0),"02"==t.substr(0,2))return n.num={hex:h(t,0)},n;throw new x("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var n={extname:"cRLReason"};if(e&&(n.critical=!0),"0a"==t.substr(0,2))return n.code=parseInt(h(t,0),16),n;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var n={extname:"ocspNonce"},e=(e&&(n.critical=!0),h(t,0));return n.hex=e,n},this.getExtOcspNoCheck=function(t,e){var n={extname:"ocspNoCheck"};return e&&(n.critical=!0),n},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("adobeTimeStamp");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}var r,n={extname:"adobeTimeStamp"},e=(e&&(n.critical=!0),l(t,0));return 1<e.length&&(r=f(t,e[1]),null!=(r=this.getGeneralName(r)).uri)&&(n.uri=r.uri),2<e.length&&("0101ff"==(r=f(t,e[2]))&&(n.reqauth=!0),"010100"==r)&&(n.reqauth=!1),n},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("subjectDirectoryAttributes");if(void 0===n)return;t=f(this.hex,n.vidx),e=n.critical}n={extname:"subjectDirectoryAttributes"};e&&(n.critical=!0);try{for(var r=u(t),i=[],s=0;s<r.seq.length;s++){var a=r.seq[s],o=aryval(a,"seq.0.oid"),h=aryval(a,"seq.1.set");if(null==o||null==h)throw"error";i.push({attr:o,array:h})}return n.array=i,n}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};function uka(t){var e={};try{var n=t.seq[0].oid,r=D.asn1.x509.OID.name2oid(n),i=(e.type=D.asn1.x509.OID.oid2atype(r),t.seq[1]);if(null!=i.utf8str)e.ds="utf8",e.value=i.utf8str.str;else if(null!=i.numstr)e.ds="num",e.value=i.numstr.str;else if(null!=i.telstr)e.ds="tel",e.value=i.telstr.str;else if(null!=i.prnstr)e.ds="prn",e.value=i.prnstr.str;else if(null!=i.ia5str)e.ds="ia5",e.value=i.ia5str.str;else if(null!=i.visstr)e.ds="vis",e.value=i.visstr.str;else{if(null==i.bmpstr)throw"error";e.ds="bmp",e.value=i.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}}function vka(t){try{return t.set.map(function(t){return uka(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}}this.getX500NameRule=function(t){for(var e=null,n=[],r=0;r<t.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(i[s]);for(r=0;r<n.length;r++){var a=n[r],o=a.ds,h=a.value,a=a.type;if("prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"==a&&D.lang.String.isMail(h))continue;return"mixed"}if("C"==a){if("prn"==o)continue;return"mixed"}if(null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){t=u(t);return uka(t)},this.getRDN=function(t){t=u(t);return vka(t)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return vka(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(u(t))},this.getX500Name=function(t,e,n){var r=this.getX500NameArray(t),i={str:this.dnarraytostr(r)};return i.array=r,1==n&&(i.hex=t),1==e&&(i.canon=this.c14nRDNArray(r)),i},this.readCertPEM=function(t){this.readCertHex(e(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{p(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=hextopem(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&0<this.aExtInfo.length&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=i(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=a(this.hex,0,[0,"[3]"])&&(t=s(this.hex,0,[0,"[3]",0],"30"));for(var e=[],n=l(t,0),r=0;r<n.length;r++){var i=f(t,n[r]),i=this.getExtParam(i);null!=i&&e.push(i)}return e},this.getExtParam=function(t){var e=l(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var n=y(c(t,0,[0],"06")),r=!1,t=(3==e&&"0101ff"==i(t,0,[1])&&(r=!0),i(t,0,[e-1,0])),e=void 0;if("2.5.29.14"==n?e=this.getExtSubjectKeyIdentifier(t,r):"2.5.29.15"==n?e=this.getExtKeyUsage(t,r):"2.5.29.17"==n?e=this.getExtSubjectAltName(t,r):"2.5.29.18"==n?e=this.getExtIssuerAltName(t,r):"2.5.29.19"==n?e=this.getExtBasicConstraints(t,r):"2.5.29.30"==n?e=this.getExtNameConstraints(t,r):"2.5.29.31"==n?e=this.getExtCRLDistributionPoints(t,r):"2.5.29.32"==n?e=this.getExtCertificatePolicies(t,r):"2.5.29.33"==n?e=this.getExtPolicyMappings(t,r):"2.5.29.35"==n?e=this.getExtAuthorityKeyIdentifier(t,r):"2.5.29.36"==n?e=this.getExtPolicyConstraints(t,r):"2.5.29.37"==n?e=this.getExtExtKeyUsage(t,r):"2.5.29.54"==n?e=this.getExtInhibitAnyPolicy(t,r):"1.3.6.1.5.5.7.1.1"==n?e=this.getExtAuthorityInfoAccess(t,r):"2.5.29.20"==n?e=this.getExtCRLNumber(t,r):"2.5.29.21"==n?e=this.getExtCRLReason(t,r):"2.5.29.9"==n?e=this.getExtSubjectDirectoryAttributes(t,r):"1.3.6.1.5.5.7.48.1.2"==n?e=this.getExtOcspNonce(t,r):"1.3.6.1.5.5.7.48.1.5"==n?e=this.getExtOcspNoCheck(t,r):"1.2.840.113583.1.1.9.1"==n?e=this.getExtAdobeTimeStamp(t,r):null!=X509.EXT_PARSER[n]&&(e=X509.EXT_PARSER[n](n,r,t)),null!=e)return e;e={extname:n,extn:t};try{e.extn=u(t)}catch(t){}return r&&(e.critical=!0),e},this.findExt=function(t,e){for(var n=0;n<t.length;n++)if(t[n].extname==e)return t[n];return null},this.updateExtCDPFullURI=function(t,e){t=this.findExt(t,"cRLDistributionPoints");if(null!=t&&null!=t.array)for(var n=t.array,r=0;r<n.length;r++)if(null!=n[r].dpname&&null!=n[r].dpname.full)for(var i=n[r].dpname.full,s=0;s<i.length;s++){var a=i[r];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){t=this.findExt(t,"authorityInfoAccess");if(null!=t&&null!=t.array)for(var n=t.array,r=0;r<n.length;r++)null!=n[r].ocsp&&(n[r].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){t=this.findExt(t,"authorityInfoAccess");if(null!=t&&null!=t.array)for(var n=t.array,r=0;r<n.length;r++)null!=n[r].caissuer&&(n[r].caissuer=e)},this.dnarraytostr=function(t){function z(t){return t.map(function(t){return function A(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")}).join("+")}return"/"+t.map(function(t){return z(t).replace(/\//,"\\/")}).join("/")},this.setCanonicalizedDN=function(t){var e;e=null!=t.str&&null==t.array?(e=new D.asn1.x509.X500Name({str:t.str}).tohex(),this.getX500NameArray(e)):t.array,null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],n=0;n<t.length;n++){for(var r=t[n],i=[],s=0;s<r.length;s++){var a=r[s],o=a.value;o=(o=(o=(o=o.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),i.push(a.type.toLowerCase()+"="+o)}e.push(i.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,n="Basic Fields\n";if(n=(n=(n=(n=(n=(n=(n+=" serial number: "+this.getSerialNumberHex()+"\n")+(" signature algorithm: "+this.getSignatureAlgorithmField()+"\n"))+(" issuer: "+this.getIssuerString()+"\n"))+(" notBefore: "+this.getNotBefore()+"\n"))+(" notAfter: "+this.getNotAfter()+"\n"))+(" subject: "+this.getSubjectString()+"\n")+" subject public key info: \n")+(" key algorithm: "+(t=this.getPublicKey()).type+"\n"),"RSA"===t.type&&(n=(n+=" n="+hextoposhex(t.n.toString(16)).substr(0,16)+"...\n")+" e="+hextoposhex(t.e.toString(16))+"\n"),null!=(e=this.aExtInfo)){n+="X509v3 Extensions:\n";for(var r=0;r<e.length;r++){var i,s=e[r],a=D.asn1.x509.OID.oid2name(s.oid),o="";n+=" "+(a=""===a?s.oid:a)+" "+(o=!0===s.critical?"CRITICAL":o)+":\n","basicConstraints"===a?void 0===(s=this.getExtBasicConstraints()).cA?n+=" {}\n":(n+=" cA=true",void 0!==s.pathLen&&(n+=", pathLen="+s.pathLen),n+="\n"):"policyMappings"==a?n+=" "+this.getExtPolicyMappings().array.map(function(t){return t[0]+":"+t[1]}).join(", ")+"\n":"policyConstraints"==a?(n+=" ",null!=(i=this.getExtPolicyConstraints()).reqexp&&(n+=" reqexp="+i.reqexp),null!=i.inhibit&&(n+=" inhibit="+i.inhibit),n+="\n"):"inhibitAnyPolicy"==a?n+=" skip="+(i=this.getExtInhibitAnyPolicy()).skip+"\n":"keyUsage"==a?n+=" "+this.getExtKeyUsageString()+"\n":"subjectKeyIdentifier"==a?n+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n":"authorityKeyIdentifier"==a?void 0!==(o=this.getExtAuthorityKeyIdentifier()).kid&&(n+=" kid="+o.kid.hex+"\n"):"extKeyUsage"==a?n+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==a?n+=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];null!=i.dn&&(e+=" dn: "+i.dn.str+"\n"),null!=i.ip&&(e+=" ip: "+i.ip+"\n"),null!=i.rfc822&&(e+=" rfc822: "+i.rfc822+"\n"),null!=i.dns&&(e+=" dns: "+i.dns+"\n"),null!=i.uri&&(e+=" uri: "+i.uri+"\n"),null!=i.other&&(e+=" other: "+i.other.oid+"="+JSON.stringify(i.other.value).replace(/\"/g,"")+"\n")}return e=e.replace(/\n$/,"")}(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==a?n+=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+X509.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e}(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==a?n+=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e}(this.getExtAuthorityInfoAccess()):"certificatePolicies"==a&&(n+=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var a=i.array[s];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e}(this.getExtCertificatePolicies()))}}return n=(n+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+("signature: "+this.getSignatureValueHex().substr(0,16)+"...\n")},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):D.lang.String.isHex(t)&&this.readCertHex(t))}RSAKey.prototype.sign=function(t,e){t=function(t){return D.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(t,e)},RSAKey.prototype.signWithMessageHash=function(t,e){t=parseBigInt(D.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return _zeroPaddingOfSignature(this.doPrivate(t).toString(16),this.n.bitLength())},RSAKey.prototype.signPSS=function(t,e,n){t=function(t){return D.crypto.Util.hashHex(t,e)}(rstrtohex(t));return this.signWithMessageHashPSS(t,e,n=void 0===n?-1:n)},RSAKey.prototype.signWithMessageHashPSS=function(t,e,n){function Kja(t){return D.crypto.Util.hashHex(t,e)}var t=hextorstr(t),r=t.length,i=this.n.bitLength()-1,s=Math.ceil(i/8);if(-1===n||void 0===n)n=r;else if(-2===n)n=s-r-2;else if(n<-2)throw new Error("invalid salt length");if(s<r+n+2)throw new Error("data too long");for(var a="",o=(0<n&&(a=new Array(n),(new SecureRandom).nextBytes(a),a=String.fromCharCode.apply(String,a)),hextorstr(Kja(rstrtohex("\0\0\0\0\0\0\0\0"+t+a)))),h=[],u=0;u<s-n-r-2;u+=1)h[u]=0;var c=String.fromCharCode.apply(String,h)+""+a,l=pss_mgf1_str(o,c.length,Kja),f=[];for(u=0;u<c.length;u+=1)f[u]=c.charCodeAt(u)^l.charCodeAt(u);for(f[0]&=~(65280>>8*s-i&255),u=0;u<r;u++)f.push(o.charCodeAt(u));return f.push(188),_zeroPaddingOfSignature(this.doPrivate(new BigInteger(f)).toString(16),this.n.bitLength())},RSAKey.prototype.verify=function(t,e){var n,r;return null!=(e=e.toLowerCase()).match(/^[0-9a-f]+$/)&&(e=parseBigInt(e,16),n=this.n.bitLength(),!(e.bitLength()>n))&&(e=this.doPublic(e).toString(16)).length+3==n/4&&0!=(n=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e.replace(/^1f+00/,""))).length&&(r=n[0],n[1]==function(t){return D.crypto.Util.hashString(t,r)}(t))},RSAKey.prototype.verifyWithMessageHash=function(t,e){return e.length==Math.ceil(this.n.bitLength()/4)&&((e=parseBigInt(e,16)).bitLength()>this.n.bitLength()?0:0!=(e=_rsasign_getAlgNameAndHashFromHexDisgestInfo(this.doPublic(e).toString(16).replace(/^1f+00/,""))).length&&(e[0],e[1]==t))},RSAKey.prototype.verifyPSS=function(t,e,n,r){t=function(t){return D.crypto.Util.hashHex(t,n)}(rstrtohex(t));return this.verifyWithMessageHashPSS(t,e,n,r=void 0===r?-1:r)},RSAKey.prototype.verifyWithMessageHashPSS=function(t,e,n,r){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;function N9a(t){return D.crypto.Util.hashHex(t,n)}var e=new BigInteger(e,16),t=hextorstr(t),i=t.length,s=this.n.bitLength()-1,a=Math.ceil(s/8);if(-1===r||void 0===r)r=i;else if(-2===r)r=a-i-2;else if(r<-2)throw new Error("invalid salt length");if(a<i+r+2)throw new Error("data too long");for(var o=this.doPublic(e).toByteArray(),h=0;h<o.length;h+=1)o[h]&=255;for(;o.length<a;)o.unshift(0);if(188!==o[a-1])throw new Error("encoded message does not end in 0xbc");var u=(o=String.fromCharCode.apply(String,o)).substr(0,a-i-1),e=o.substr(u.length,i),s=65280>>8*a-s&255;if(0!=(u.charCodeAt(0)&s))throw new Error("bits beyond keysize not zero");var c=pss_mgf1_str(e,u.length,N9a),l=[];for(h=0;h<u.length;h+=1)l[h]=u.charCodeAt(h)^c.charCodeAt(h);l[0]&=~s;var f=a-i-r-2;for(h=0;h<f;h+=1)if(0!==l[h])throw new Error("leftmost octets not zero");if(1!==l[f])throw new Error("0x01 marker not found");return e===hextorstr(N9a(rstrtohex("\0\0\0\0\0\0\0\0"+t+String.fromCharCode.apply(String,l.slice(-r)))))},RSAKey.SALT_LEN_HLEN=-1,RSAKey.SALT_LEN_MAX=-2,RSAKey.SALT_LEN_RECOVER=-2,X509.EXT_PARSER={},X509.registExtParser=function(t,e){X509.EXT_PARSER[t]=e},X509.hex2dn=function(t,e){void 0===e&&(e=0);var n=new X509;E.getTLV(t,e);return n.getX500Name(t).str},X509.hex2rdn=function(t,e){if("31"!==t.substr(e=void 0===e?0:e,2))throw new Error("malformed RDN");for(var n=new Array,r=E.getChildIdx(t,e),i=0;i<r.length;i++)n.push(X509.hex2attrTypeValue(t,r[i]));return(n=n.map(function(t){return t.replace("+","\\+")})).join("+")},X509.hex2attrTypeValue=function(t,e){var n=E,r=n.getV;if("30"!==t.substr(e=void 0===e?0:e,2))throw new Error("malformed attribute type and value");n=n.getChildIdx(t,e),2===n.length&&t.substr(n[0],2),e=r(t,n[0]),e=D.asn1.ASN1Util.oidHexToInt(e);return D.asn1.x509.OID.oid2atype(e)+"="+hextorstr(r(t,n[1]))},X509.getPublicKeyFromCertHex=function(t){var e=new X509;return e.readCertHex(t),e.getPublicKey()},X509.getPublicKeyFromCertPEM=function(t){var e=new X509;return e.readCertPEM(t),e.getPublicKey()},X509.getPublicKeyInfoPropOfCertPEM=function(t){var e=E.getVbyList,n={algparam:null},r=new X509;return r.readCertPEM(t),t=r.getPublicKeyHex(),n.keyhex=e(t,0,[1],"03").substr(2),n.algoid=e(t,0,[0,0],"06"),"2a8648ce3d0201"===n.algoid&&(n.algparam=e(t,0,[0,1],"06")),n},X509.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];void 0!==(D=void 0!==D&&D?D:{}).jws&&D.jws||(D.jws={}),D.jws.JWS=function(){var s=D.jws.JWS.isSafeJSONString;this.parseJWS=function(t,e){if(void 0===this.parsedJWS||!e&&void 0===this.parsedJWS.sigvalH){t=t.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var n=t[1],r=t[2],t=t[3],i=n+"."+r,t=(this.parsedJWS={},this.parsedJWS.headB64U=n,this.parsedJWS.payloadB64U=r,this.parsedJWS.sigvalB64U=t,this.parsedJWS.si=i,e||(e=parseBigInt(i=b64utohex(t),16),this.parsedJWS.sigvalH=i,this.parsedJWS.sigvalBI=e),g(n)),i=g(r);if(this.parsedJWS.headS=t,this.parsedJWS.payloadS=i,!s(t,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+t}}},D.jws.JWS.sign=function(t,e,n,r,i){var s,a=D,o=a.jws.JWS,h=o.readSafeJSONString,u=o.isSafeJSONString,a=a.crypto,c=(a.ECDSA,a.Mac),a=a.Signature,l=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(s=l.stringify(f=e)),"string"==typeof e){if(!u(s=e))throw"JWS Head is not safe JSON string: "+s;f=h(s)}if("object"==typeof(u=n)&&(u=l.stringify(n)),""!=(t=""!=t&&null!=t||void 0===f.alg?t:f.alg)&&null!=t&&void 0===f.alg&&(f.alg=t,s=l.stringify(f)),t!==f.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+f.alg;e=null;if(void 0===o.jwsalg2sigalg[t])throw"unsupported alg name: "+t;var f,g,e=o.jwsalg2sigalg[t],h=H(s)+"."+H(u),n="";if("Hmac"==e.substr(0,4)){if(void 0===r)throw"mac key shall be specified for HS* alg";l=new c({alg:e,prov:"cryptojs",pass:r});l.updateString(h),n=l.doFinal()}else-1!=e.indexOf("withECDSA")?((g=new a({alg:e})).init(r,i),g.updateString(h),f=g.sign(),n=D.crypto.ECDSA.asn1SigToConcatSig(f)):"none"!=e&&((g=new a({alg:e})).init(r,i),g.updateString(h),n=g.sign());return h+"."+hextob64u(n)},D.jws.JWS.verify=function(t,e,n){var r=D,i=r.jws.JWS,s=i.readSafeJSONString,r=r.crypto,a=r.ECDSA,o=r.Mac,r=r.Signature,h=RSAKey;if(!isBase64URLDot(t))return!1;t=t.split(".");if(3!==t.length)return!1;var u=t[0]+"."+t[1],c=b64utohex(t[2]),s=s(g(t[0])),t=null,l=null;if(void 0===s.alg)throw"algorithm not specified in header";if((l=(t=s.alg).substr(0,2),null!=n&&"[object Array]"===Object.prototype.toString.call(n)&&0<n.length)&&-1==(":"+n.join(":")+":").indexOf(":"+t+":"))throw"algorithm '"+t+"' not accepted in the list";if("none"!=t&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=b.getKey(e)),!("RS"!=l&&"PS"!=l||e instanceof h))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==l&&!(e instanceof a))throw"key shall be a ECDSA obj for ES* algs";n=null;if(void 0===i.jwsalg2sigalg[s.alg])throw"unsupported alg name: "+t;if("none"==(n=i.jwsalg2sigalg[t]))throw"not supported";if("Hmac"==n.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";h=new o({alg:n,pass:e});return h.updateString(u),c==h.doFinal()}if(-1==n.indexOf("withECDSA"))return(f=new r({alg:n})).init(e),f.updateString(u),f.verify(c);var f,l=null;try{l=a.concatSigToASN1Sig(c)}catch(t){return!1}return(f=new r({alg:n})).init(e),f.updateString(u),f.verify(l)},D.jws.JWS.parse=function(t){var e,n,r,t=t.split("."),i={};if(2!=t.length&&3!=t.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=t[0],n=t[1],3==t.length&&(r=t[2]),i.headerObj=D.jws.JWS.readSafeJSONString(g(e)),i.payloadObj=D.jws.JWS.readSafeJSONString(g(n)),i.headerPP=JSON.stringify(i.headerObj,null," "),i.payloadPP=null==i.payloadObj?g(n):JSON.stringify(i.payloadObj,null," "),void 0!==r&&(i.sigHex=b64utohex(r)),i},D.jws.JWS.verifyJWT=function(t,e,n){var r=D.jws,i=r.JWS,s=i.readSafeJSONString,a=i.inArray,o=i.includedArray;if(!isBase64URLDot(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1],h=(b64utohex(h[2]),s(g(u))),u=s(g(c));if(void 0===h.alg)return!1;if(void 0===n.alg)throw"acceptField.alg shall be specified";if(!a(h.alg,n.alg))return!1;if(void 0!==u.iss&&"object"==typeof n.iss&&!a(u.iss,n.iss))return!1;if(void 0!==u.sub&&"object"==typeof n.sub&&!a(u.sub,n.sub))return!1;if(void 0!==u.aud&&"object"==typeof n.aud)if("string"==typeof u.aud){if(!a(u.aud,n.aud))return!1}else if("object"==typeof u.aud&&!o(u.aud,n.aud))return!1;s=r.IntDate.getNow();return void 0!==n.verifyAt&&"number"==typeof n.verifyAt&&(s=n.verifyAt),void 0!==n.gracePeriod&&"number"==typeof n.gracePeriod||(n.gracePeriod=0),!(void 0!==u.exp&&"number"==typeof u.exp&&u.exp+n.gracePeriod<s||void 0!==u.nbf&&"number"==typeof u.nbf&&s<u.nbf-n.gracePeriod||void 0!==u.iat&&"number"==typeof u.iat&&s<u.iat-n.gracePeriod||void 0!==u.jti&&void 0!==n.jti&&u.jti!==n.jti||!i.verify(t,e,n.alg))},D.jws.JWS.includedArray=function(t,e){var n=D.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var r=0;r<t.length;r++)if(!n(t[r],e))return!1;return!0},D.jws.JWS.inArray=function(t,e){if(null!==e&&"object"==typeof e&&"number"==typeof e.length)for(var n=0;n<e.length;n++)if(e[n]==t)return!0;return!1},D.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},D.jws.JWS.isSafeJSONString=function(t,e,n){var r;try{return"object"!=typeof(r=O(t))?0:r.constructor===Array?0:(e&&(e[n]=r),1)}catch(t){return 0}},D.jws.JWS.readSafeJSONString=function(t){var e;try{return"object"!=typeof(e=O(t))?null:e.constructor===Array?null:e}catch(t){return null}},D.jws.JWS.getEncodedSignatureValueFromJWS=function(t){t=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return t[1]},D.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e=(e=(e+='"e":"'+t.e+'",')+('"kty":"'+t.kty+'",'))+('"n":"'+t.n+'"}')}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e=(e=(e=(e+='"crv":"'+t.crv+'",')+('"kty":"'+t.kty+'",'))+('"x":"'+t.x+'",'))+('"y":"'+t.y+'"}')}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e=(e+='"kty":"'+t.kty+'",')+('"k":"'+t.k+'"}')}t=rstrtohex(e);return hextob64u(D.crypto.Util.hashHex(t,"sha256"))},D.jws.IntDate={},D.jws.IntDate.get=function(t){var e=D.jws.IntDate,n=e.getNow,e=e.getZulu;if("now"==t)return n();if("now + 1hour"==t)return n()+3600;if("now + 1day"==t)return n()+86400;if("now + 1month"==t)return n()+2592e3;if("now + 1year"==t)return n()+31536e3;if(t.match(/Z$/))return e(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},D.jws.IntDate.getZulu=function(t){return zulutosec(t)},D.jws.IntDate.getNow=function(){return~~(new Date/1e3)},D.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},D.jws.IntDate.intDate2Zulu=function(t){t=new Date(1e3*t);return("0000"+t.getUTCFullYear()).slice(-4)+("00"+(t.getUTCMonth()+1)).slice(-2)+("00"+t.getUTCDate()).slice(-2)+("00"+t.getUTCHours()).slice(-2)+("00"+t.getUTCMinutes()).slice(-2)+("00"+t.getUTCSeconds()).slice(-2)+"Z"},void 0!==(D=void 0!==D&&D?D:{}).jws&&D.jws||(D.jws={}),D.jws.JWSJS=function(){var i=D.jws.JWS,n=i.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();t=t.split(".");if(3!=t.length)throw"malformed input JWS";this.aHeader.push(t[0]),this.sPayload=t[1],this.aSignature.push(t[2])},this.addSignature=function(t,e,n,r){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var i=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=D.jws.JWS.sign(t,e,this.sPayload,n,r).split(".");s[0],s[2];this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>i&&this.aHeader.pop(),this.aSignature.length>i&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var n=t[e];if(2!==n.length)return!1;if(!1===this.verifyNth(e,n[0],n[1]))return!1}return!0},this.verifyNth=function(t,e,n){if(this.aHeader.length<=t||this.aSignature.length<=t)return!1;var r=this.aHeader[t],t=this.aSignature[t],r=r+"."+this.sPayload+"."+t,t=!1;try{t=i.verify(r,e,n)}catch(t){return!1}return t},this.readJWSJS=function(t){if("string"==typeof t){var e=n(t);if(null==e)throw"argument is not safe JSON object string";this.aHeader=e.headers,this.sPayload=e.payload,this.aSignature=e.signatures}else try{if(!(0<t.headers.length))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(0<t.signatures.length))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},D.crypto.ECDSA,D.crypto.DSA,D.crypto.Signature,D.crypto.MessageDigest,D.crypto.Mac,D.crypto.Cipher,d.KZ=b,d.eL=D.crypto,D.asn1,D.jws,D.lang}},r={};function __webpack_require__(t){var e=r[t];return void 0!==e||(e=r[t]={exports:{}},n[t](e,e.exports,__webpack_require__)),e.exports}__webpack_require__.d=(t,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var e={};return(()=>{"use strict";__webpack_require__.d(e,{default:()=>t});var h=__webpack_require__(166);function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,function _toPropertyKey(t){t=function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===_typeof(t)?t:String(t)}(r.key),r)}}var t=function(){function _default(){!function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,_default),this._identifier="imagex-encrypt-plugin",this.stage=1005}return function _createClass(t,e,n){e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),Object.defineProperty(t,"prototype",{writable:!1})}(_default,[{key:"apply",value:function apply(t,e,n){var r=this,i=t.isImageBatchUpload,s=t.imagexPublicKey,a=t.imagexEncryptKey,o=h.KZ.getKey(s);return i?t.crc32Array.map(function(){var t=h.eL.Cipher.encrypt(a,o,"RSAOAEP256");return r._hexToBase64(t)}):(s=h.eL.Cipher.encrypt(a,o,"RSAOAEP256"),[this._hexToBase64(s)])}},{key:"_hexToBase64",value:function _hexToBase64(t){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",r=0,i=0,s=0;s<t.length;++s)r=r<<4|("A"<=t[s]&&t[s]<="Z"?t.charCodeAt(s)-55:"a"<=t[s]&&t[s]<="z"?t.charCodeAt(s)-87:t.charCodeAt(s)-48),6<=(i+=4)&&(n+=e[r>>>(i-=6)],r&=~(-1<<i));0<i&&(n+=e[r<<=6-i]);var a=n.length%4;if(0<a)for(var o=0;o<4-a;++o)n+="=";return n}}]),_default}()})(),e.default})());
24
+ var P,N,g,H=function(){var f=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),g=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),n={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(t,e,r){return e?n[e]:String.fromCharCode(parseInt(r,16))}var p=new String(""),d=(Object,Array,Object.hasOwnProperty);return function(t,o){for(var e,r,u,n,i=t.match(f),s=i[0],t=!1,a=("{"===s?n={}:"["===s?n=[]:(n=[],t=!0),[n]),c=1-t,l=i.length;c<l;++c)switch((s=i[c]).charCodeAt(0)){default:(r=a[0])[e||r.length]=+s,e=void 0;break;case 34:if(-1!==(s=s.substring(1,s.length-1)).indexOf("\\")&&(s=s.replace(g,h)),r=a[0],!e){if(!(r instanceof Array)){e=s||p;break}e=r.length}r[e]=s,e=void 0;break;case 91:r=a[0],a.unshift(r[e||r.length]=[]),e=void 0;break;case 93:a.shift();break;case 102:(r=a[0])[e||r.length]=!1,e=void 0;break;case 110:(r=a[0])[e||r.length]=null,e=void 0;break;case 116:(r=a[0])[e||r.length]=!0,e=void 0;break;case 123:r=a[0],a.unshift(r[e||r.length]={}),e=void 0;break;case 125:a.shift()}if(t){if(1!==a.length)throw new Error;n=n[0]}else if(a.length)throw new Error;return n=o?(u=function(t,e){var r=t[e];if(r&&"object"==typeof r){var n,i,s=null;for(n in r)d.call(r,n)&&r!==t&&(void 0!==(i=u(r,n))?r[n]=i:(s=s||[]).push(n));if(s)for(var a=s.length;0<=--a;)delete r[s[a]]}return o.call(t,e,r)})({"":n},""):n}}(),E=(void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),P.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){t=t.toString(16);return t=t.length%2==1?"0"+t:t},this.bigIntToMinTwosComplementsHex=function(t){return twoscompl(t)},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=P.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,g=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,m=e.DERGeneralizedTime,y=e.DERVisibleString,x=e.DERBMPString,v=e.DERSequence,S=e.DERSet,E=e.DERTaggedObject,b=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;e=Object.keys(t);if(1!=e.length)throw new Error("key of param shall be only one.");e=e[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+e+":"))throw new Error("undefined key: "+e);if("bool"==e)return new n(t[e]);if("int"==e)return new i(t[e]);if("bitstr"==e)return new s(t[e]);if("octstr"==e)return new a(t[e]);if("null"==e)return new o(t[e]);if("oid"==e)return new h(t[e]);if("enum"==e)return new u(t[e]);if("utf8str"==e)return new c(t[e]);if("numstr"==e)return new l(t[e]);if("prnstr"==e)return new f(t[e]);if("telstr"==e)return new g(t[e]);if("ia5str"==e)return new p(t[e]);if("utctime"==e)return new d(t[e]);if("gentime"==e)return new m(t[e]);if("visstr"==e)return new y(t[e]);if("bmpstr"==e)return new x(t[e]);if("asn1"==e)return new r(t[e]);if("seq"==e){for(var w=t[e],F=[],A=0;A<w.length;A++){var C=b(w[A]);F.push(C)}return new v({array:F})}if("set"!=e)return"tag"==e?(n=t[e],"[object Array]"===Object.prototype.toString.call(n)&&3==n.length?(i=b(n[2]),new E({tag:n[0],explicit:n[1],obj:i})):new E(n)):void 0;for(w=t[e],F=[],A=0;A<w.length;A++){C=b(w[A]);F.push(C)}return new S({array:F})},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},P.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),e=Math.floor(r/40)+"."+r%40,n="",i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new BigInteger(n,2).toString(10),n="")}return e},P.asn1.ASN1Util.oidIntToHex=function(t){function dn(t){return t=1==(t=t.toString(16)).length?"0"+t:t}if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",r=t.split("."),t=40*parseInt(r[0])+parseInt(r[1]);e+=dn(t),r.splice(0,2);for(var n=0;n<r.length;n++)e+=function(t){for(var e="",r=7-(s=new BigInteger(t,10).toString(2)).length%7,n=(7==r&&(r=0),""),i=0;i<r;i++)n+="0";for(var s=n+s,i=0;i<s.length-1;i+=7){var a=s.substr(i,7);i!=s.length-7&&(a="1"+a),e+=dn(parseInt(a,2))}return e}(r[n]);return e},P.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(15<r)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return null!=this.hTLV&&!this.isModified||(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},P.asn1.DERAbstractString=function(t){P.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=utf8tohex(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},extendClass(P.asn1.DERAbstractString,P.asn1.ASN1Object),P.asn1.DERAbstractTime=function(t){P.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){t=t.getTime()+6e4*t.getTimezoneOffset();return new Date(t)},this.formatDate=function(t,e,r){var n=this.zeroPadding,t=this.localDateToUTC(t),i=String(t.getFullYear()),e=("utc"==e&&(i=i.substr(2,2)),n(String(t.getMonth()+1),2)),i=i+e+n(String(t.getDate()),2)+n(String(t.getHours()),2)+n(String(t.getMinutes()),2)+n(String(t.getSeconds()),2);return(i=!0===r&&0!=(e=t.getMilliseconds())?i+"."+n(String(e),3).replace(/[0]+$/,""):i)+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,n,i,s){t=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(t)},this.getFreshValueHex=function(){return this.hV}},extendClass(P.asn1.DERAbstractTime,P.asn1.ASN1Object),P.asn1.DERAbstractStructured=function(t){P.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},extendClass(P.asn1.DERAbstractStructured,P.asn1.ASN1Object),P.asn1.DERBoolean=function(t){P.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},extendClass(P.asn1.DERBoolean,P.asn1.ASN1Object),P.asn1.DERInteger=function(t){P.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var r=twoscompl;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,e=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)this.hV=t.hex;else{if("number"==typeof t)e=new BigInteger(String(t),10);else if(null!=t.int)e=new BigInteger(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");e=t.bigint}this.hV=r(e)}return this.hV},null!=t&&(this.params=t)},extendClass(P.asn1.DERInteger,P.asn1.ASN1Object),P.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=P.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.tohex()),P.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;t="0"+t;this.hTLV=null,this.isModified=!0,this.hV=t+e},this.setByBinaryString=function(t){for(var e=8-(t=t.replace(/0+$/,"")).length%8,r=(t+="0000000".substr(0,e=8==e?0:e),""),n=0;n<t.length-1;n+=8){var i=t.substr(n,8),i=parseInt(i,2).toString(16);r+=i=1==i.length?"0"+i:i}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},extendClass(P.asn1.DERBitString,P.asn1.ASN1Object),P.asn1.DEROctetString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=P.asn1.ASN1Util.newObject(t.obj),t.hex=e.tohex()),P.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},extendClass(P.asn1.DEROctetString,P.asn1.DERAbstractString),P.asn1.DERNull=function(){P.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},extendClass(P.asn1.DERNull,P.asn1.ASN1Object),P.asn1.DERObjectIdentifier=function(t){P.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=oidtohex(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=P.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.DERObjectIdentifier,P.asn1.ASN1Object),P.asn1.DEREnumerated=function(t){P.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=twoscompl(t)},this.setByInteger=function(t){t=new BigInteger(String(t),10);this.setByBigInteger(t)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},extendClass(P.asn1.DEREnumerated,P.asn1.ASN1Object),P.asn1.DERUTF8String=function(t){P.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},extendClass(P.asn1.DERUTF8String,P.asn1.DERAbstractString),P.asn1.DERNumericString=function(t){P.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},extendClass(P.asn1.DERNumericString,P.asn1.DERAbstractString),P.asn1.DERPrintableString=function(t){P.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},extendClass(P.asn1.DERPrintableString,P.asn1.DERAbstractString),P.asn1.DERTeletexString=function(t){P.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},extendClass(P.asn1.DERTeletexString,P.asn1.DERAbstractString),P.asn1.DERIA5String=function(t){P.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},extendClass(P.asn1.DERIA5String,P.asn1.DERAbstractString),P.asn1.DERVisibleString=function(t){P.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},extendClass(P.asn1.DERVisibleString,P.asn1.DERAbstractString),P.asn1.DERBMPString=function(t){P.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},extendClass(P.asn1.DERBMPString,P.asn1.DERAbstractString),P.asn1.DERUTCTime=function(t){P.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t,e=this.params;if("string"==typeof(e=null==this.params?{date:new Date}:e)){if(!e.match(/^[0-9]{12}Z$/)&&!e.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+e);this.hV=stohex(e)}else null!=e.str?this.hV=stohex(e.str):null==e.date&&1==e.millis?(t=new Date,this.hV=stohex(this.formatDate(t,"utc",!0))):null!=e.date&&e.date instanceof Date?(t=!0===e.millis,this.hV=stohex(this.formatDate(e.date,"utc",t))):e instanceof Date&&(this.hV=stohex(this.formatDate(e,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},extendClass(P.asn1.DERUTCTime,P.asn1.DERAbstractTime),P.asn1.DERGeneralizedTime=function(t){P.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t,e=this.params;if("string"==typeof(e=null==this.params?{date:new Date}:e)){if(!e.match(/^[0-9]{14}Z$/)&&!e.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+e);this.hV=stohex(e)}else null!=e.str?this.hV=stohex(e.str):null==e.date&&1==e.millis?(t=new Date,this.hV=stohex(this.formatDate(t,"gen",!0))):null!=e.date&&e.date instanceof Date?(t=!0===e.millis,this.hV=stohex(this.formatDate(e.date,"gen",t))):e instanceof Date&&(this.hV=stohex(this.formatDate(e,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},extendClass(P.asn1.DERGeneralizedTime,P.asn1.DERAbstractTime),P.asn1.DERSequence=function(t){P.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].tohex();return this.hV=t,this.hV}},extendClass(P.asn1.DERSequence,P.asn1.DERAbstractStructured),P.asn1.DERSet=function(t){P.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.tohex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},extendClass(P.asn1.DERSet,P.asn1.DERAbstractStructured),P.asn1.DERTaggedObject=function(t){P.asn1.DERTaggedObject.superclass.constructor.call(this);var r=P.asn1,n=E.getV,i=(E.isASN1HEX,r.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t,e=this.params;if(null==e.explicit&&(e.explicit=!0),null!=e.tage&&(e.tag=e.tage,e.explicit=!0),null!=e.tagi&&(e.tag=e.tagi,e.explicit=!1),null!=e.str)this.hV=utf8tohex(e.str);else if(null!=e.hex)this.hV=e.hex;else{if(null==e.obj)throw new Error("str, hex nor obj not specified");e.obj instanceof r.ASN1Object?t=e.obj.tohex():"object"==typeof e.obj&&(t=i(e.obj).tohex()),e.explicit?this.hV=t:this.hV=n(t,0)}return null==e.tag&&(e.tag="a0"),this.hT=e.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.DERTaggedObject,P.asn1.ASN1Object),new function(){});function stoBA(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}function BAtohex(t){for(var e="",r=0;r<t.length;r++){var n=t[r].toString(16);e+=n=1==n.length?"0"+n:n}return e}function stohex(t){return BAtohex(stoBA(t))}function b64tob64u(t){return t=(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function b64utob64(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function hextob64u(t){return b64tob64u(hex2b64(t=t.length%2==1?"0"+t:t))}function b64utohex(t){return b64tohex(b64utob64(t))}function utf8tohex(t){return uricmptohex(encodeURIComponentAll(t)).toLowerCase()}function hextoutf8(t){try{return decodeURIComponent(hextouricmp(t))}catch(t){return null}}function iso88591hextoutf8(t){return hextoutf8(function iso88591hextoutf8hex(t){for(var e=t.match(/.{1,2}/g),r=[],n=0;n<e.length;n++){var i=parseInt(e[n],16);161<=i&&i<=191?(r.push("c2"),r.push(e[n])):192<=i&&i<=255?(r.push("c3"),r.push((i-64).toString(16))):r.push(e[n])}return r.join("")}(t))}function hextorstr(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function rstrtohex(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function hextob64(t){return hex2b64(t)}function foldnl(t,e){return t=(t=t.replace(new RegExp("(.{"+e+"})","g"),"$1\r\n")).replace(/\s+$/,"")}function b64nltohex(t){return b64tohex(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}function hextopem(t,e){return"-----BEGIN "+e+"-----\r\n"+foldnl(hextob64(t),64)+"\r\n-----END "+e+"-----\r\n"}function pemtohex(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return b64nltohex(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function zulutomsec(t){var e,r,n,i,s,a,o,h;if(h=(t=timetogen(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(h[1]),r=parseInt(h[2])-1,n=parseInt(h[3]),i=parseInt(h[4]),s=parseInt(h[5]),a=parseInt(h[6]),o=0,""!==(h=h[7])&&(h=(h.substr(1)+"00").substr(0,3),o=parseInt(h)),Date.UTC(e,r,n,i,s,a,o);throw new Error("unsupported zulu format: "+t)}function zulutosec(t){return Math.round(zulutomsec(t)/1e3)}function timetogen(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}function uricmptohex(t){return t.replace(/%/g,"")}function hextouricmp(t){return t.replace(/(..)/g,"%$1")}function ipv6tohex(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var r=":".repeat(7-r+2),n=(t=t.replace("::",r)).split(":");if(8!=n.length)throw e;for(var i=0;i<8;i++)n[i]=("0000"+n[i]).slice(-4);return n.join("")}function hextoipv6(t){var e;if(t.match(/^[0-9A-Fa-f]{32}$/))return null==(e=(t=":"+(t=t.toLowerCase()).match(/.{1,4}/g).map(function(t){return t.replace(/^0+/,"")}).map(function(t){return""==t?"0":t}).join(":")+":").match(/:(0:){2,}/g))?t.slice(1,-1):(e=e.sort().slice(-1)[0],"::"!=(t="::"!=(t=t.replace(e.substr(0,e.length-1),":")).substr(0,2)?t.substr(1):t).substr(-2,2)?t.substr(0,t.length-1):t);throw new Error("malformed IPv6 address: "+t)}function hextoip(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}else if(16==t.length)try{return hextoip(t.substr(0,8))+"/"+ipprefixlen(t.substr(8))}catch(t){throw e}else{if(32==t.length)return hextoipv6(t);if(64!=t.length)return t;try{return hextoipv6(t.substr(0,32))+"/"+ipprefixlen(t.substr(32))}catch(t){throw e}}}function ipprefixlen(t){var e,r=new Error("malformed mask");try{e=new BigInteger(t,16).toString(2)}catch(t){throw r}if(e.match(/^1*0*$/))return e.replace(/0+$/,"").length;throw r}function iptohex(t){var e,r=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw r;if(!t.match(/^[0-9.]+$/)){if(t.match(/^[0-9.]+\/[0-9]+$/))return iptohex((e=t.split("/"))[0])+ipnetmask(parseInt(e[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return ipv6tohex(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return ipv6tohex((e=t.split("/"))[0])+ipnetmask(parseInt(e[1]),128);throw r}var n=t.split(".");if(4!==n.length)throw r;var i="";try{for(var s=0;s<4;s++)i+=("0"+parseInt(n[s]).toString(16)).slice(-2);return i}catch(t){throw r}}function ipnetmask(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new BigInteger(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function ucs2hextoutf8(t){return t.match(/.{4}/g).map(function e(t){var r,n=parseInt(t.substr(0,2),16),t=parseInt(t.substr(2),16);return 0==n&t<128?String.fromCharCode(t):n<8?(r=128|63&t,hextoutf8((192|(7&n)<<3|(192&t)>>6).toString(16)+r.toString(16))):(r=128|(15&n)<<2|(192&t)>>6,t=128|63&t,hextoutf8((224|(240&n)>>4).toString(16)+r.toString(16)+t.toString(16)))}).join("")}function encodeURIComponentAll(t){for(var e=encodeURIComponent(t),r="",n=0;n<e.length;n++)"%"==e[n]?(r+=e.substr(n,3),n+=2):r=r+"%"+stohex(e[n]);return r}function ishex(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function isBase64URLDot(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function hextoposhex(t){return t.length%2==1?"0"+t:"7"<t.substr(0,1)?"00"+t:t}E.getLblen=function(t,e){return"8"!=t.substr(e+2,1)?1:0==(t=parseInt(t.substr(e+3,1)))?-1:0<t&&t<10?t+1:-2},E.getL=function(t,e){var r=E.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},E.getVblen=function(t,e){t=E.getL(t,e);return""==t?-1:("8"===t.substr(0,1)?new BigInteger(t.substr(2),16):new BigInteger(t,16)).intValue()},E.getVidx=function(t,e){t=E.getLblen(t,e);return t<0?t:e+2*(t+1)},E.getV=function(t,e){var r=E.getVidx(t,e),e=E.getVblen(t,e);return t.substr(r,2*e)},E.getTLV=function(t,e){return t.substr(e,2)+E.getL(t,e)+E.getV(t,e)},E.getTLVblen=function(t,e){return 2+2*E.getLblen(t,e)+2*E.getVblen(t,e)},E.getNextSiblingIdx=function(t,e){return E.getVidx(t,e)+2*E.getVblen(t,e)},E.getChildIdx=function(t,e){var r=E,n=[],i=r.getVidx(t,e),s=2*r.getVblen(t,e);"03"==t.substr(e,2)&&(i+=2,s-=2);for(var a=0,o=i;a<=s;){var h=r.getTLVblen(t,o);if((a+=h)<=s&&n.push(o),o+=h,s<=a)break}return n},E.getNthChildIdx=function(t,e,r){return E.getChildIdx(t,e)[r]},E.getIdxbyList=function(t,e,r,n){var i,s=E;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(e=s.getChildIdx(t,e)).length?-1:s.getIdxbyList(t,e[i],r,n)},E.getIdxbyListEx=function(t,e,r,n){var i=E;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;for(var s=r.shift(),a=i.getChildIdx(t,e),o=0,h=0;h<a.length;h++){var u=t.substr(a[h],2);if("number"==typeof s&&!i.isContextTag(u)&&o==s||"string"==typeof s&&i.isContextTag(u,s))return i.getIdxbyListEx(t,a[h],r,n);i.isContextTag(u)||o++}return-1},E.getTLVbyList=function(t,e,r,n){var i=E,e=i.getIdxbyList(t,e,r,n);return-1==e||e>=t.length?null:i.getTLV(t,e)},E.getTLVbyListEx=function(t,e,r,n){var i=E,e=i.getIdxbyListEx(t,e,r,n);return-1==e?null:i.getTLV(t,e)},E.getVbyList=function(t,e,r,n,i){var s=E,e=s.getIdxbyList(t,e,r,n);return-1==e||e>=t.length?null:(r=s.getV(t,e),!0===i?r.substr(2):r)},E.getVbyListEx=function(t,e,r,n,i){var s=E,e=s.getIdxbyListEx(t,e,r,n);return-1==e?null:(r=s.getV(t,e),"03"==t.substr(e,2)&&!1!==i?r.substr(2):r)},E.getInt=function(t,e,r){null==r&&(r=-1);try{var n,i=t.substr(e,2);return"02"!=i&&"03"!=i?r:(n=E.getV(t,e),"02"==i?parseInt(n,16):bitstrtoint(n))}catch(t){return r}},E.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:hextooid(E.getV(t,e))}catch(t){return r}},E.getOIDName=function(t,e,r){null==r&&(r=null);try{var n,i=E.getOID(t,e,r);return i==r?r:""==(n=P.asn1.x509.OID.oid2name(i))?i:n}catch(t){return r}},E.getString=function(t,e,r){null==r&&(r=null);try{return hextorstr(E.getV(t,e))}catch(t){return r}},E.hextooidstr=function(t){function Or(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}for(var e=[],r=t.substr(0,2),r=parseInt(r,16),n=(e[0]=new String(Math.floor(r/40)),e[1]=new String(r%40),t.substr(2)),i=[],s=0;s<n.length/2;s++)i.push(parseInt(n.substr(2*s,2),16));for(var a=[],o="",s=0;s<i.length;s++)128&i[s]?o+=Or((127&i[s]).toString(2),7):(o+=Or((127&i[s]).toString(2),7),a.push(new String(parseInt(o,2))),o="");r=e.join(".");return r=0<a.length?r+"."+a.join("."):r},E.dump=function(t,e,r,n){function hs(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)}var i=E,s=i.getV,a=i.dump,o=i.getChildIdx,h=t,t=(t instanceof P.asn1.ASN1Object&&(h=t.tohex()),void 0===n&&(n=""),(e=void 0===e?{ommit_long_octet:32}:e).ommit_long_octet),u=h.substr(r=void 0===r?0:r,2);if("01"==u)return"00"==(d=s(h,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==u)return n+"INTEGER "+hs(d=s(h,r),t)+"\n";if("03"==u)return d=s(h,r),i.isASN1HEX(d.substr(2))?(l=n+"BITSTRING, encapsulates\n")+a(d.substr(2),e,0,n+" "):n+"BITSTRING "+hs(d,t)+"\n";if("04"==u)return d=s(h,r),i.isASN1HEX(d)?(l=n+"OCTETSTRING, encapsulates\n")+a(d,e,0,n+" "):n+"OCTETSTRING "+hs(d,t)+"\n";if("05"==u)return n+"NULL\n";if("06"==u)return t=s(h,r),t=P.asn1.ASN1Util.oidHexToInt(t),c=P.asn1.x509.OID.oid2name(t),t=t.replace(/\./g," "),""!=c?n+"ObjectIdentifier "+c+" ("+t+")\n":n+"ObjectIdentifier ("+t+")\n";if("0a"==u)return n+"ENUMERATED "+parseInt(s(h,r))+"\n";if("0c"==u)return n+"UTF8String '"+hextoutf8(s(h,r))+"'\n";if("13"==u)return n+"PrintableString '"+hextoutf8(s(h,r))+"'\n";if("14"==u)return n+"TeletexString '"+hextoutf8(s(h,r))+"'\n";if("16"==u)return n+"IA5String '"+hextoutf8(s(h,r))+"'\n";if("17"==u)return n+"UTCTime "+hextoutf8(s(h,r))+"\n";if("18"==u)return n+"GeneralizedTime "+hextoutf8(s(h,r))+"\n";if("1a"==u)return n+"VisualString '"+hextoutf8(s(h,r))+"'\n";if("1e"==u)return n+"BMPString '"+ucs2hextoutf8(s(h,r))+"'\n";if("30"==u){if("3000"==h.substr(r,4))return n+"SEQUENCE {}\n";var c,l=n+"SEQUENCE\n",f=e;2!=(p=o(h,r)).length&&3!=p.length||"06"!=h.substr(p[0],2)||"04"!=h.substr(p[p.length-1],2)||(c=i.oidname(s(h,p[0])),(t=JSON.parse(JSON.stringify(e))).x509ExtName=c,f=t);for(var g=0;g<p.length;g++)l+=a(h,f,p[g],n+" ")}else if("31"==u)for(var l=n+"SET\n",p=o(h,r),g=0;g<p.length;g++)l+=a(h,e,p[g],n+" ");else{if(0==(128&(u=parseInt(u,16))))return n+"UNKNOWN("+u+") "+s(h,r)+"\n";var d,i=31&u;if(0==(32&u))return d=s(h,r),E.isASN1HEX(d)?(l=n+"["+i+"]\n")+a(d,e,0,n+" "):n+"["+i+"] "+(d="68747470"==d.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==i?hextoutf8(d):d)+"\n";for(var l=n+"["+i+"]\n",p=o(h,r),g=0;g<p.length;g++)l+=a(h,e,p[g],n+" ")}return l},E.parse=function(t){var e,s=E.parse,r=E.isASN1HEX,n=E.getV,a=E.getTLV,o=E.getChildIdx,i=P.asn1,h=i.ASN1Util.oidHexToInt,i=i.x509.OID.oid2name,u=hextoutf8,c=ucs2hextoutf8,l=iso88591hextoutf8,f={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},g=t.substr(0,2),p={},n=n(t,0);if("01"==g)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==g)return{int:{hex:n}};if("03"==g)try{if("00"==n.substr(0,2)){var d=n.substr(2);if(r(d))return{bitstr:{obj:s(d)}}}throw"not encap"}catch(t){var d=null;return null==(d=n.length<=10?bitstrtobinstr(n):d)?{bitstr:{hex:n}}:{bitstr:{bin:d}}}else if("04"==g)try{if(r(n))return{octstr:{obj:s(n)}};throw"not encap"}catch(t){return{octstr:{hex:n}}}else{if("05"==g)return{null:""};if("06"==g)return""==(i=i(d=h(n)))?{oid:d}:{oid:i};if("0a"==g)return 4<n.length?{enum:{hex:n}}:{enum:parseInt(n,16)};if("30"==g||"31"==g)return p[f[g]]=function(t){for(var e=[],r=o(t,0),n=0;n<r.length;n++){var i=r[n],i=a(t,i),i=s(i);e.push(i)}return e}(t),p;if("14"==g)return e=l(n),p[f[g]]={str:e},p;if("1e"==g)return e=c(n),p[f[g]]={str:e},p;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(g))return e=u(n),p[f[g]]={str:e},p;if(g.match(/^8[0-9]$/))return null==(e=u(n))|""==e||null!=e.match(/[\x00-\x1F\x7F-\x9F]/)||null!=e.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:g,explicit:!1,hex:n}}:{tag:{tag:g,explicit:!1,str:e}};if(!g.match(/^a[0-9]$/))return(h=new P.asn1.ASN1Object).hV=n,{asn1:{tlv:g+h.getLengthHexFromValue()+n}};try{if(r(n))return{tag:{tag:g,explicit:!0,obj:s(n)}};throw new Error("not encap")}catch(t){return{tag:{tag:g,explicit:!0,hex:n}}}}},E.isContextTag=function(t,e){var r,n;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null==e.match(/^\[[0-9]+\]$/)?!1:!(31<(n=parseInt(e.substr(1,e.length-1),10)))&&128==(192&r)&&(31&r)==n}catch(t){return!1}},E.isASN1HEX=function(t){var e,r,n=E;return t.length%2!=1&&(e=n.getVblen(t,0),r=t.substr(0,2),n=n.getL(t,0),t.length-r.length-n.length==2*e)},E.checkStrictDER=function(t,e,r,n,i){var s=E;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!P.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(n<a)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),h=o.length-2-s.getL(t,e).length;if(h!=2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);h=t.substr(e,2);if("02"===h){a=s.getVidx(t,e);if("00"==t.substr(a,2)&&t.charCodeAt(a+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var o=s.getVblen(t,e),u=0,c=s.getChildIdx(t,e),l=0;l<c.length;l++)u+=s.getTLV(t,c[l]).length,s.checkStrictDER(t,c[l],r,n,i);if(2*o!=u)throw new Error("sum of children's TLV length and L unmatch: "+2*o+"!="+u)}},E.oidname=function(t){var e=P.asn1,e=(P.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t)),e.x509.OID.oid2name(t));return e=""===e?t:e},void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),void 0!==P.asn1.x509&&P.asn1.x509||(P.asn1.x509={}),P.asn1.x509.Certificate=function(t){P.asn1.x509.Certificate.superclass.constructor.call(this);var e=P.asn1,r=e.DERBitString,n=e.DERSequence,e=e.x509,i=e.TBSCertificate,s=e.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg,r=(null!=t.sigalg.name&&(e=t.sigalg.name),t.tbsobj.tohex()),e=new P.crypto.Signature({alg:e});e.init(t.cakey),e.updateHex(r),t.sighex=e.sign()},this.getPEM=function(){return hextopem(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new i(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},extendClass(P.asn1.x509.Certificate,P.asn1.ASN1Object),P.asn1.x509.TBSCertificate=function(t){P.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=P.asn1,r=e.x509,n=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,a=r.AlgorithmIdentifier,o=r.Time,h=r.X500Name,u=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e=[],r=this.params;return null==r.version&&1==r.version||(t=2,null!=r.version&&(t=r.version-1),t=new n({obj:new i({int:t})}),e.push(t)),e.push(new i(r.serial)),e.push(new a({name:r.sigalg})),e.push(new h(r.issuer)),e.push(new s({array:[new o(r.notbefore),new o(r.notafter)]})),e.push(new h(r.subject)),e.push(new c(b.getKey(r.sbjpubkey))),void 0!==r.ext&&0<r.ext.length&&e.push(new n({tag:"a3",obj:new u(r.ext)})),new P.asn1.DERSequence({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.TBSCertificate,P.asn1.ASN1Object),P.asn1.x509.Extensions=function(t){P.asn1.x509.Extensions.superclass.constructor.call(this);var e=P.asn1,s=e.DERSequence,a=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var r=this.aParam[e],n=r.extname,i=null;if(null!=r.extn)i=new a.PrivateExtension(r);else if("subjectKeyIdentifier"==n)i=new a.SubjectKeyIdentifier(r);else if("keyUsage"==n)i=new a.KeyUsage(r);else if("subjectAltName"==n)i=new a.SubjectAltName(r);else if("issuerAltName"==n)i=new a.IssuerAltName(r);else if("basicConstraints"==n)i=new a.BasicConstraints(r);else if("nameConstraints"==n)i=new a.NameConstraints(r);else if("cRLDistributionPoints"==n)i=new a.CRLDistributionPoints(r);else if("certificatePolicies"==n)i=new a.CertificatePolicies(r);else if("policyMappings"==n)i=new a.PolicyMappings(r);else if("policyConstraints"==n)i=new a.PolicyConstraints(r);else if("inhibitAnyPolicy"==n)i=new a.InhibitAnyPolicy(r);else if("authorityKeyIdentifier"==n)i=new a.AuthorityKeyIdentifier(r);else if("extKeyUsage"==n)i=new a.ExtKeyUsage(r);else if("authorityInfoAccess"==n)i=new a.AuthorityInfoAccess(r);else if("cRLNumber"==n)i=new a.CRLNumber(r);else if("cRLReason"==n)i=new a.CRLReason(r);else if("ocspNonce"==n)i=new a.OCSPNonce(r);else if("ocspNoCheck"==n)i=new a.OCSPNoCheck(r);else if("adobeTimeStamp"==n)i=new a.AdobeTimeStamp(r);else{if("subjectDirectoryAttributes"!=n)throw new Error("extension not supported:"+JSON.stringify(r));i=new a.SubjectDirectoryAttributes(r)}null!=i&&t.push(i)}return new s({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.x509.Extensions,P.asn1.ASN1Object),P.asn1.x509.Extension=function(t){P.asn1.x509.Extension.superclass.constructor.call(this);var e=P.asn1,n=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),a=e.DERSequence;this.tohex=function(){var t=new n({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),r=new Array;return r.push(t),this.critical&&r.push(new s),r.push(e),new a({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},extendClass(P.asn1.x509.Extension,P.asn1.ASN1Object),P.asn1.x509.KeyUsage=function(t){P.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new P.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return namearraytobinstr(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.KeyUsage,P.asn1.x509.Extension),P.asn1.x509.BasicConstraints=function(t){P.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=P.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array,t=(this.cA&&t.push(new r),-1<this.pathLen&&t.push(new n({int:this.pathLen})),new i({array:t}));return this.asn1ExtnValue=t,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen)&&(this.pathLen=t.pathLen)},extendClass(P.asn1.x509.BasicConstraints,P.asn1.x509.Extension),P.asn1.x509.CRLDistributionPoints=function(t){P.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var i=P.asn1,s=i.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var e,r=[],n=0;n<t.length;n++)t[n]instanceof P.asn1.ASN1Object?r.push(t[n]):(e=new s.DistributionPoint(t[n]),r.push(e));this.asn1ExtnValue=new i.DERSequence({array:r})},this.setByOneURI=function(t){t=new s.DistributionPoint({fulluri:t});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},extendClass(P.asn1.x509.CRLDistributionPoints,P.asn1.x509.Extension),P.asn1.x509.DistributionPoint=function(t){P.asn1.x509.DistributionPoint.superclass.constructor.call(this);var r=P.asn1,e=r.x509.DistributionPointName;this.tohex=function(){var t,e=new r.DERSequence;return null!=this.asn1DP&&(t=new r.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP}),e.appendASN1Object(t)),this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new e(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new e({full:[{uri:t.fulluri}]})))},extendClass(P.asn1.x509.DistributionPoint,P.asn1.ASN1Object),P.asn1.x509.DistributionPointName=function(t){P.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=P.asn1,r=e.DERTaggedObject;if(this.tohex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},extendClass(P.asn1.x509.DistributionPointName,P.asn1.ASN1Object),P.asn1.x509.CertificatePolicies=function(t){P.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=P.asn1,r=e.x509,n=e.DERSequence,i=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var r=new n({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.CertificatePolicies,P.asn1.x509.Extension),P.asn1.x509.PolicyInformation=function(t){P.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=P.asn1,n=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],r=0;r<this.params.array.length;r++)e.push(new s(this.params.array[r]));0<e.length&&t.push(new n({array:e}))}return new n({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.PolicyInformation,P.asn1.ASN1Object),P.asn1.x509.PolicyQualifierInfo=function(t){P.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=P.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.PolicyQualifierInfo,P.asn1.ASN1Object),P.asn1.x509.UserNotice=function(t){P.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=P.asn1.DERSequence,r=(P.asn1.DERInteger,P.asn1.x509.DisplayText),n=P.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.UserNotice,P.asn1.ASN1Object),P.asn1.x509.NoticeReference=function(t){P.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var i=P.asn1.DERSequence,s=P.asn1.DERInteger,a=P.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new a(this.params.org)),void 0!==this.params.noticenum){for(var e=[],r=this.params.noticenum,n=0;n<r.length;n++)e.push(new s(r[n]));t.push(new i({array:e}))}if(0==t.length)throw new Error("parameter is empty");return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.NoticeReference,P.asn1.ASN1Object),P.asn1.x509.DisplayText=function(t){P.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},extendClass(P.asn1.x509.DisplayText,P.asn1.DERAbstractString),P.asn1.x509.PolicyMappings=function(t){P.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=P.asn1,i=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],r=0;r<t.array.length;r++){var n=t.array[r];e.push({seq:[{oid:n[0]},{oid:n[1]}]})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.PolicyMappings,P.asn1.x509.Extension),P.asn1.x509.PolicyConstraints=function(t){P.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=P.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.PolicyConstraints,P.asn1.x509.Extension),P.asn1.x509.InhibitAnyPolicy=function(t){P.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=P.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=r({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.InhibitAnyPolicy,P.asn1.x509.Extension),P.asn1.x509.NameConstraints=function(t){P.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=P.asn1,r=e.x509,s=e.ASN1Util.newObject,a=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],n=0;n<t.permit.length;n++)r.push(new a(t.permit[n]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){for(var i=[],n=0;n<t.exclude.length;n++)i.push(new a(t.exclude[n]));e.push({tag:{tagi:"a1",obj:{seq:i}}})}return this.asn1ExtnValue=s({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.NameConstraints,P.asn1.x509.Extension),P.asn1.x509.GeneralSubtree=function(t){P.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=P.asn1,r=e.x509.GeneralName,n=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),n({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.GeneralSubtree,P.asn1.ASN1Object),P.asn1.x509.ExtKeyUsage=function(t){P.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var n=P.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new n.DERSequence;for(var e=0;e<t.length;e++){var r=new n.DERObjectIdentifier(t[e]);this.asn1ExtnValue.appendASN1Object(r)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},extendClass(P.asn1.x509.ExtKeyUsage,P.asn1.x509.Extension),P.asn1.x509.AuthorityKeyIdentifier=function(t){P.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=P,r=e.asn1,n=r.DERTaggedObject,i=r.x509.GeneralNames;e.crypto.Util.isKey;this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array,t=(this.asn1KID&&t.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new n({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN})),new r.DERSequence({array:t}));return this.asn1ExtnValue=t,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){var e;void 0!==t.str||void 0!==t.hex?this.asn1KID=new P.asn1.DEROctetString(t):("object"==typeof t&&P.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN "))&&("string"==typeof(e=t)&&(e=b.getKey(t)),t=b.getKeyID(e),this.asn1KID=new P.asn1.DEROctetString({hex:t}))},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new P.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new P.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){var e;void 0!==t.str||void 0!==t.bigint||void 0!==t.hex?this.asn1CertSN=new P.asn1.DERInteger(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")&&((e=new X509).readCertPEM(t),t=e.getSerialNumberHex(),this.asn1CertSN=new P.asn1.DERInteger({hex:t}))},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn)&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn))},extendClass(P.asn1.x509.AuthorityKeyIdentifier,P.asn1.x509.Extension),P.asn1.x509.SubjectKeyIdentifier=function(t){P.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var r=P.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){var e;void 0!==t.str||void 0!==t.hex?this.asn1KID=new r(t):("object"==typeof t&&P.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN"))&&("string"==typeof(e=t)&&(e=b.getKey(t)),t=b.getKeyID(e),this.asn1KID=new P.asn1.DEROctetString({hex:t}))},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},extendClass(P.asn1.x509.SubjectKeyIdentifier,P.asn1.x509.Extension),P.asn1.x509.AuthorityInfoAccess=function(t){P.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=P.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,s=r.x509.GeneralName,a=0;a<t.length;a++){var o,h=t[a];if(void 0!==h.ocsp)o=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));o=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:h.caissuer})]})}e.push(o)}this.asn1ExtnValue=new n({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},extendClass(P.asn1.x509.AuthorityInfoAccess,P.asn1.x509.Extension),P.asn1.x509.SubjectAltName=function(t){P.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new P.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},extendClass(P.asn1.x509.SubjectAltName,P.asn1.x509.Extension),P.asn1.x509.IssuerAltName=function(t){P.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new P.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},extendClass(P.asn1.x509.IssuerAltName,P.asn1.x509.Extension),P.asn1.x509.SubjectDirectoryAttributes=function(t){P.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=P.asn1,s=e.DERSequence,a=e.ASN1Util.newObject,o=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var r=this.params.array[e];if(null!=r.attr&&null!=r.array){var n={seq:[{oid:r.attr},{set:r.array}]};t.push(a(n))}else{n={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==r.attr)n.seq[0].oid=o(r.attr),n.seq[1].set[0]={gentime:r.str};else if("placeOfBirth"==r.attr)n.seq[0].oid=o(r.attr),n.seq[1].set[0]={utf8str:r.str};else{if("gender"!=r.attr&&"countryOfCitizenship"!=r.attr&&"countryOfResidence"!=r.attr)throw new Error("unsupported attribute: "+r.attr);n.seq[0].oid=o(r.attr),n.seq[1].set[0]={prnstr:r.str}}t.push(new a(n))}}var i=new s({array:t});return this.asn1ExtnValue=i,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},extendClass(P.asn1.x509.SubjectDirectoryAttributes,P.asn1.x509.Extension),P.asn1.x509.PrivateExtension=function(t){P.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=P,r=e.lang.String.isHex,e=e.asn1,n=e.x509.OID.name2oid,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=n(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return i(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},extendClass(P.asn1.x509.PrivateExtension,P.asn1.x509.Extension),P.asn1.x509.CRL=function(t){P.asn1.x509.CRL.superclass.constructor.call(this);var e=P.asn1,r=e.DERSequence,n=e.DERBitString,e=e.x509,i=e.AlgorithmIdentifier,s=e.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new P.crypto.Signature({alg:this.params.sigalg}),t=(e.init(this.params.cakey),e.updateHex(t),e.sign());this.params.sighex=t},this.getPEM=function(){return hextopem(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new i({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},extendClass(P.asn1.x509.CRL,P.asn1.ASN1Object),P.asn1.x509.TBSCertList=function(t){P.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=P.asn1,i=e.DERInteger,s=e.DERSequence,n=e.DERTaggedObject,e=(e.DERObjectIdentifier,e.x509),a=e.AlgorithmIdentifier,o=e.Time,h=e.Extensions,u=e.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,r=0;r<e.length;r++){var n=[new i(e[r].sn),new o(e[r].date)];null!=e[r].ext&&n.push(new h(e[r].ext)),t.push(new s({array:n}))}return new s({array:t})},this.tohex=function(){var t,e=[],r=this.params;return null!=r.version&&(t=r.version-1,t=new i({int:t}),e.push(t)),e.push(new a({name:r.sigalg})),e.push(new u(r.issuer)),e.push(new o(r.thisupdate)),null!=r.nextupdate&&e.push(new o(r.nextupdate)),null!=r.revcert&&e.push(this.getRevCertSequence()),null!=r.ext&&(t=new h(r.ext),e.push(new n({tag:"a0",explicit:!0,obj:t}))),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.TBSCertList,P.asn1.ASN1Object),P.asn1.x509.CRLEntry=function(t){P.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=P.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn)&&this.setCertSerial(t.sn)},extendClass(P.asn1.x509.CRLEntry,P.asn1.ASN1Object),P.asn1.x509.CRLNumber=function(t){P.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new P.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},extendClass(P.asn1.x509.CRLNumber,P.asn1.x509.Extension),P.asn1.x509.CRLReason=function(t){P.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new P.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},extendClass(P.asn1.x509.CRLReason,P.asn1.x509.Extension),P.asn1.x509.OCSPNonce=function(t){P.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new P.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},extendClass(P.asn1.x509.OCSPNonce,P.asn1.x509.Extension),P.asn1.x509.OCSPNoCheck=function(t){P.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new P.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},extendClass(P.asn1.x509.OCSPNoCheck,P.asn1.x509.Extension),P.asn1.x509.AdobeTimeStamp=function(t){P.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=P.asn1,r=e.DERInteger,n=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new n(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.AdobeTimeStamp,P.asn1.x509.Extension),P.asn1.x509.X500Name=function(t){P.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var n=P.asn1,r=n.x509,a=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);for(var r,n=t.split("/"),i=(n.shift(),[]),s=0;s<n.length;s++)n[s].match(/^[^=]+=.+$/)?i.push(n[s]):i[r=i.length-1]=i[r]+"/"+n[s];for(s=0;s<i.length;s++)this.asn1Array.push(new a({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);t=r.X500Name.ldapToCompat(t);this.setByString(t,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)t.hasOwnProperty(r)&&(r=new a({str:r+"="+t[r],rule:this.sRule}),this.asn1Array?this.asn1Array.push(r):this.asn1Array=[r])},this.setByParam=function(t){var e;void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new X509).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new X509).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=function(){if("string"!=typeof this.hTLV){if(0==this.asn1Array.length&&0<this.paramArray.length)for(var t=0;t<this.paramArray.length;t++){var e={array:this.paramArray[t]},e=("utf8"!=this.sRule&&(e.rule=this.sRule),new a(e));this.asn1Array.push(e)}var r=new n.DERSequence({array:this.asn1Array});this.hTLV=r.tohex()}return this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.X500Name,P.asn1.ASN1Object),P.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";t=(t=t.substr(1)).split("/");return t.reverse(),(t=t.map(function(t){return t.replace(/,/,"\\,")})).join(",")},P.asn1.x509.X500Name.onelineToLDAP=function(t){return P.asn1.x509.X500Name.compatToLDAP(t)},P.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,n=[];0<e.length;){var i,s=e.shift();!0===r?(i=(n.pop()+","+s).replace(/\\,/g,","),n.push(i),r=!1):n.push(s),"\\"===s.substr(-1,1)&&(r=!0)}return(n=n.map(function(t){return t.replace("/","\\/")})).reverse(),"/"+n.join("/")},P.asn1.x509.X500Name.ldapToOneline=function(t){return P.asn1.x509.X500Name.ldapToCompat(t)},P.asn1.x509.RDN=function(t){P.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var n=P.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new P.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=P.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=function(){if(0==this.asn1Array.length&&0<this.paramArray.length)for(var t=0;t<this.paramArray.length;t++){var e=this.paramArray[t],e=(void 0!==e.rule&&"utf8"!=this.sRule&&(e.rule=this.sRule),new n(e));this.asn1Array.push(e)}var r=new P.asn1.DERSet({array:this.asn1Array});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.RDN,P.asn1.ASN1Object),P.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,n=[];0<e.length;){var i=e.shift();!0===r?(h=(n.pop()+"+"+i).replace(/\\\+/g,"+"),n.push(h),r=!1):n.push(i),"\\"===i.substr(-1,1)&&(r=!0)}for(var s=!1,a=[];0<n.length;){var o,h,i=n.shift();!0===s?(o=a.pop(),i.match(/"$/)?(h=(o+"+"+i).replace(/^([^=]+)="(.*)"$/,"$1=$2"),a.push(h),s=!1):a.push(o+"+"+i)):a.push(i),i.match(/^[^=]+="/)&&(s=!0)}return a},P.asn1.x509.AttributeTypeAndValue=function(t){P.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=P,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,h=r.DERVisibleString,u=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);e=t.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(e[1],e[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=P.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),t=new n({array:[t,e]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.AttributeTypeAndValue,P.asn1.ASN1Object),P.asn1.x509.SubjectPublicKeyInfo=function(t){P.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=P,r=e.asn1,i=r.DERInteger,s=r.DERBitString,a=r.DERObjectIdentifier,n=r.DERSequence,o=r.ASN1Util.newObject,h=r.x509.AlgorithmIdentifier,r=e.crypto;r.ECDSA,r.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new n({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{var e;t instanceof RSAKey&&(e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex(),this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e}))}catch(t){}try{t instanceof P.crypto.ECDSA&&(r=new a({name:t.curveName}),this.asn1AlgId=new h({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex}))}catch(t){}try{var r,n;t instanceof P.crypto.DSA&&(r=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new h({name:"dsa",asn1params:r}),n=new i({bigint:t.y}),this.asn1SubjPKey=new s({hex:"00"+n.tohex()}))}catch(t){}},void 0!==t&&this.setPubKey(t)},extendClass(P.asn1.x509.SubjectPublicKeyInfo,P.asn1.ASN1Object),P.asn1.x509.Time=function(t){P.asn1.x509.Time.superclass.constructor.call(this);var e=P.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if(null==(t="string"==typeof t?{str:t}:t)||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new n(t.str))):e=new("gen"==this.type?n:r),null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},P.asn1.x509.Time_bak=function(t){P.asn1.x509.Time_bak.superclass.constructor.call(this);var e=P.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null,t=null!=this.timeParams?new("utc"==this.type?r:n)(this.timeParams):new("utc"==this.type?r:n);return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/))&&(this.type="gen"),this.timeParams=t)},extendClass(P.asn1.x509.Time,P.asn1.ASN1Object),P.asn1.x509.AlgorithmIdentifier=function(t){P.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var n=P.asn1,i=n.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t,e=null;for(t in i)t===this.nameAlg&&(e=i[t]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=n.x509.OID.name2obj(this.nameAlg));var r=[this.asn1Alg],r=(null!==this.asn1Params&&r.push(this.asn1Params),new n.DERSequence({array:r}));return this.hTLV=r.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty)&&(this.paramEmpty=t.paramempty),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg&&(void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name),"withdsa"!==(t=this.nameAlg.toLowerCase()).substr(-7,7))&&"withecdsa"!==t.substr(-9,9)&&(this.asn1Params=new n.DERNull)},extendClass(P.asn1.x509.AlgorithmIdentifier,P.asn1.ASN1Object),P.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},P.asn1.x509.GeneralName=function(t){P.asn1.x509.GeneralName.superclass.constructor.call(this);var e=P.asn1,r=e.x509,u=r.X500Name,c=r.OtherName,l=e.DERIA5String,f=(e.DERPrintableString,e.DEROctetString),g=e.DERTaggedObject,p=e.ASN1Object,d=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e=this.params,r=!1;if(void 0!==e.other)n="a0",t=new c(e.other);else if(void 0!==e.rfc822)n="81",t=new l({str:e.rfc822});else if(void 0!==e.dns)n="82",t=new l({str:e.dns});else if(void 0!==e.dn)n="a4",r=!0,t="string"==typeof e.dn?new u({str:e.dn}):e.dn instanceof P.asn1.x509.X500Name?e.dn:new u(e.dn);else if(void 0!==e.ldapdn)n="a4",r=!0,t=new u({ldapstr:e.ldapdn});else if(void 0!==e.certissuer||void 0!==e.certsubj){var n="a4",i=(r=!0,null);if((s=void 0!==e.certsubj?(o=!1,e.certsubj):(o=!0,e.certissuer)).match(/^[0-9A-Fa-f]+$/),null==(i=-1!=s.indexOf("-----BEGIN ")?pemtohex(s):i))throw new Error("certsubj/certissuer not cert");var s=new X509;s.hex=i,i=o?s.getIssuerHex():s.getSubjectHex(),(t=new p).hTLV=i}else if(void 0!==e.uri)n="86",t=new l({str:e.uri});else{if(void 0===e.ip)throw new d("improper params");n="87";var a,o=e.ip;try{if(o.match(/^[0-9a-f]+$/)){var h=o.length;if(8!=h&&16!=h&&32!=h&&64!=h)throw"err";a=o}else a=iptohex(o)}catch(t){throw new d("malformed IP address: "+e.ip+":"+t.message)}t=new f({hex:a})}return new g({tag:n,explicit:r,obj:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.GeneralName,P.asn1.ASN1Object),P.asn1.x509.GeneralNames=function(t){P.asn1.x509.GeneralNames.superclass.constructor.call(this);var n=P.asn1;this.setByParamArray=function(t){for(var e=0;e<t.length;e++){var r=new n.x509.GeneralName(t[e]);this.asn1Array.push(r)}},this.tohex=function(){return new n.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},extendClass(P.asn1.x509.GeneralNames,P.asn1.ASN1Object),P.asn1.x509.OtherName=function(t){P.asn1.x509.OtherName.superclass.constructor.call(this);var e=P.asn1,r=e.DERObjectIdentifier,n=e.DERSequence,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),t=i({tag:{tag:"a0",explicit:!0,obj:t.value}});return new n({array:[e,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.x509.OtherName,P.asn1.ASN1Object),P.asn1.x509.OID=new function(){var r=P.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",secp521r1:"1.3.132.0.35",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",GN:"2.5.4.42",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.objCache={},this.name2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],e=new r({oid:e});return this.objCache[t]=e},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw new Error("AttributeType name undefined: "+t);e=this.name2oidList[t]}var e=new r({oid:e});return this.objCache[t]=e},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0==e.length?!1:(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},P.asn1.x509.OID.oid2name=function(t){var e,r=P.asn1.x509.OID.name2oidList;for(e in r)if(r[e]==t)return e;return""},P.asn1.x509.OID.oid2atype=function(t){var e,r=P.asn1.x509.OID.atype2oidList;for(e in r)if(r[e]==t)return e;return t},P.asn1.x509.OID.name2oid=function(t){var e;return t.match(/^[0-9.]+$/)?t:void 0===(e=P.asn1.x509.OID.name2oidList)[t]?"":e[t]},P.asn1.x509.X509Util={},P.asn1.x509.X509Util.newCertPEM=function(t){var e=P.asn1.x509;e.TBSCertificate;return new e.Certificate(t).getPEM()},void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),void 0!==P.asn1.cms&&P.asn1.cms||(P.asn1.cms={}),P.asn1.cms.Attribute=function(t){var e=Error,r=P.asn1,n=r.DERSequence,i=r.DERSet,s=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new s({oid:this.typeOid}),e=new i({array:this.getValueArray()});return new n({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},extendClass(P.asn1.cms.Attribute,P.asn1.ASN1Object),P.asn1.cms.ContentType=function(t){var e=P.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.ContentType,P.asn1.cms.Attribute),P.asn1.cms.MessageDigest=function(t){var e=P.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.MessageDigest,P.asn1.cms.Attribute),P.asn1.cms.SigningTime=function(t){var e=P.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.SigningTime,P.asn1.cms.Attribute),P.asn1.cms.SigningCertificate=function(s){var a=Error,t=P,e=t.asn1,o=e.DERSequence,e=e.cms,h=e.ESSCertID;t.crypto;e.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new a("parameter 'array' not specified");for(var t=this.params.array,e=[],r=0;r<t.length;r++){var n=t[r];0!=(n=0!=s.hasis||"string"!=typeof n||-1==n.indexOf("-----BEGIN")&&!E.isASN1HEX(n)?n:{cert:n}).hasis&&0==s.hasis&&(n.hasis=!1),e.push(new h(n))}var i=new o({array:e});return[new o({array:[i]})]},null!=s&&this.setByParam(s)},extendClass(P.asn1.cms.SigningCertificate,P.asn1.cms.Attribute),P.asn1.cms.ESSCertID=function(t){P.asn1.cms.ESSCertID.superclass.constructor.call(this);var i=Error,s=P,e=s.asn1,n=e.DEROctetString,a=e.DERSequence,o=e.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,e){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!E.isASN1HEX(t))return t;var r,n;if("string"==typeof t)r=t;else{if(null==t.cert)throw new i("hash nor cert unspecified");r=t.cert}if(r=-1!=r.indexOf("-----BEGIN")?pemtohex(r):r,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?r=pemtohex(t):E.isASN1HEX(t)&&(r=t)),null!=t.alg)n=t.alg;else{if(null==e)throw new i("hash alg unspecified");n=e}return s.crypto.Util.hashHex(r,n)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new n({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new o(t)),new a({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.ESSCertID,P.asn1.ASN1Object),P.asn1.cms.SigningCertificateV2=function(s){var a=Error,t=P,e=t.asn1,o=e.DERSequence,e=(e.x509,e.cms),h=e.ESSCertIDv2;t.crypto;e.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new a("parameter 'array' not specified");for(var t=this.params.array,e=[],r=0;r<t.length;r++){var n=t[r];null==(n=null==s.alg&&0!=s.hasis||"string"!=typeof n||-1==n.indexOf("-----BEGIN")&&!E.isASN1HEX(n)?n:{cert:n}).alg&&null!=s.alg&&(n.alg=s.alg),0!=n.hasis&&0==s.hasis&&(n.hasis=!1),e.push(new h(n))}var i=new o({array:e});return[new o({array:[i]})]},null!=s&&this.setByParam(s)},extendClass(P.asn1.cms.SigningCertificateV2,P.asn1.cms.Attribute),P.asn1.cms.ESSCertIDv2=function(t){P.asn1.cms.ESSCertIDv2.superclass.constructor.call(this);Error;var e=P.asn1,n=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,a=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),r=[];return null!=t.alg&&"sha256"!=t.alg&&r.push(new a({name:t.alg})),r.push(new n({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new s(t)),new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.ESSCertIDv2,P.asn1.cms.ESSCertID),P.asn1.cms.IssuerSerial=function(t){var n=Error,e=P.asn1,i=e.DERInteger,s=e.DERSequence,r=e.cms,a=e.x509.GeneralNames,o=X509;r.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert){var e=null!=t.cert?t.cert:t,r=new o;r.readCertPEM(e),e=r.getIssuer(),r={hex:r.getSerialNumberHex()}}else{if(null==t.issuer||!t.serial)throw new n("cert or issuer and serial parameter not specified");e=t.issuer,r=t.serial}t=new a([{dn:e}]),e=new i(r);return new s({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.IssuerSerial,P.asn1.ASN1Object),P.asn1.cms.SignerIdentifier=function(t){var e=P.asn1,r=(e.DERInteger,e.DERSequence,e.cms),n=r.IssuerAndSerialNumber,i=r.SubjectKeyIdentifier;e.x509.X500Name,Error;r.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new n(t).tohex();if("skid"==t.type)return new i(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.SignerIdentifier,P.asn1.ASN1Object),P.asn1.cms.IssuerAndSerialNumber=function(t){var e=P.asn1,n=e.DERInteger,i=e.DERSequence,r=e.cms,s=e.x509.X500Name,a=X509,o=Error;r.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert){var e=null!=t.cert?t.cert:t,r=new a;r.readCertPEM(e),e=r.getIssuer(),r={hex:r.getSerialNumberHex()}}else{if(null==t.issuer||!t.serial)throw new o("cert or issuer and serial parameter not specified");e=t.issuer,r=t.serial}t=new s(e),e=new n(r);return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.IssuerAndSerialNumber,P.asn1.ASN1Object),P.asn1.cms.SubjectKeyIdentifier=function(t){var e=P.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),n=e.cms,i=(n.IssuerAndSerialName,n.SubjectKeyIdentifier,e.x509.X500Name,X509),s=Error;n.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");return null!=e.cert?t=new i(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.SubjectKeyIdentifier,P.asn1.ASN1Object),P.asn1.cms.AttributeList=function(t){var o=Error,e=P.asn1,h=e.DERSet,u=e.cms;u.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==this.hTLV){for(var e=!0,r=(null!=t.sortflag&&(e=t.sortflag),t.array),n=[],i=0;i<r.length;i++){var s=r[i],a=s.attr;if("contentType"==a)n.push(new u.ContentType(s));else if("messageDigest"==a)n.push(new u.MessageDigest(s));else if("signingTime"==a)n.push(new u.SigningTime(s));else if("signingCertificate"==a)n.push(new u.SigningCertificate(s));else if("signingCertificateV2"==a)n.push(new u.SigningCertificateV2(s));else if("signaturePolicyIdentifier"==a)n.push(new P.asn1.cades.SignaturePolicyIdentifier(s));else{if("signatureTimeStamp"!=a&&"timeStampToken"!=a)throw new o("unknown attr: "+a);n.push(new P.asn1.cades.SignatureTimeStamp(s))}}t=new h({array:n,sortflag:e});this.hTLV=t.tohex()}return this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.AttributeList,P.asn1.ASN1Object),P.asn1.cms.SignerInfo=function(t){var n=Error,e=P,r=e.asn1,i=r.DERInteger,s=r.DEROctetString,a=r.DERSequence,o=r.DERTaggedObject,h=r.cms,u=h.SignerIdentifier,c=h.AttributeList,l=(h.ContentType,h.EncapsulatedContentInfo,h.MessageDigest,h.SignedData,r.x509.AlgorithmIdentifier),f=e.crypto,g=b;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new c(t.sattrs).tohex(),n=g.getKey(t.signkey),e=new f.Signature({alg:e}),n=(e.init(n),e.updateHex(r),e.sign());t.sighex=n},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:t.version})),e.push(new u(t.id)),e.push(new l({name:t.hashalg})),null!=t.sattrs){var r=new c(t.sattrs);try{e.push(new o({tag:"a0",explicit:!1,obj:r}))}catch(t){throw new n("si sattr error: "+t)}}if(null!=t.sigalgfield?e.push(new l({name:t.sigalgfield})):e.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),e.push(new s({hex:t.sighex})),null!=t.uattrs){r=new c(t.uattrs);try{e.push(new o({tag:"a1",explicit:!1,obj:r}))}catch(t){throw new n("si uattr error: "+t)}}return new a({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.SignerInfo,P.asn1.ASN1Object),P.asn1.cms.EncapsulatedContentInfo=function(t){var e=P.asn1,r=e.DERTaggedObject,n=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.type)),null==t.content||null==t.content.hex&&null==t.content.str||1==t.isDetached||(t=new s(t.content),t=new r({tag:"a0",explicit:!0,obj:t}),e.push(t)),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.EncapsulatedContentInfo,P.asn1.ASN1Object),P.asn1.cms.ContentInfo=function(t){var e=P.asn1,r=e.DERTaggedObject,n=e.DERSequence,i=e.DERObjectIdentifier;e.x509.OID.name2obj;P.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[],t=(e.push(new i(t.type)),new r({tag:"a0",explicit:!0,obj:t.obj}));return e.push(t),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.ContentInfo,P.asn1.ASN1Object),P.asn1.cms.SignedData=function(t){Error;var e=P.asn1,o=(e.ASN1Object,e.DERInteger),h=e.DERSet,u=e.DERSequence,r=(e.DERTaggedObject,e.cms),c=r.EncapsulatedContentInfo,l=r.SignerInfo,n=r.ContentInfo,f=r.CertificateSet,g=r.RevocationInfoChoices,p=e.x509.AlgorithmIdentifier;P.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,n=0;n<r.length;n++)e[r[n].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,n=0;n<r.length;n++){var i=r[n];this._getAttrParamByName(i,"contentType").type=e}},this._setMessageDigestByEContent=function(t){for(var e=t.econtent,r=(t.econtent.type,e.content.hex),n=(null==r&&"data"==e.type&&null!=e.content.str&&(r=rstrtohex(e.content.str)),t.sinfos),i=0;i<n.length;i++){var s=n[i],a=s.hashalg,s=this._getAttrParamByName(s,"messageDigest"),a=P.crypto.Util.hashHex(r,a);s.hex=a}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,n=0;n<r.length;n++)if(r[n].attr==e)return r[n]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var n=e[r],i=1;"skid"==n.id.type&&(i=3),n.version=i}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++)if(null!=e[r].ocsp)return 5;for(var n=t.sinfos,r=0;r<n.length;r++)if(3==t.sinfos[r].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){for(var t=this.params,e=(null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam(),[]),r=(e.push(new o({int:t.version})),[]),n=0;n<t.hashalgs.length;n++){var i=t.hashalgs[n];r.push(new p({name:i}))}e.push(new h({array:r})),e.push(new c(t.econtent)),null!=t.certs&&e.push(new f(t.certs)),null!=t.revinfos&&e.push(new g(t.revinfos));for(var s=[],n=0;n<t.sinfos.length;n++){var a=t.sinfos[n];s.push(new l(a))}return e.push(new h({array:s})),new u({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new n({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.SignedData,P.asn1.ASN1Object),P.asn1.cms.CertificateSet=function(t){P.asn1.cms.CertificateSet.superclass.constructor.call(this);var o=Error,e=P.asn1,h=e.DERTaggedObject,u=e.DERSet,c=e.ASN1Object;this.params=null,this.tohex=function(){var t,e=this.params,r=[];if(e instanceof Array)t=e;else{if(null==e.array)throw new o("cert array not specified");t=e.array}for(var n=0;n<t.length;n++){var i=pemtohex(t[n]),s=new c;s.hTLV=i,r.push(s)}var a={array:r},e=(0==e.sortflag&&(a.sortflag=!1),new u(a));return new h({tag:"a0",explicit:!1,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.CertificateSet,P.asn1.ASN1Object),P.asn1.cms.RevocationInfoChoices=function(t){P.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new P.asn1.cms.RevocationInfoChoice(t[r]));return P.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.RevocationInfoChoices,P.asn1.ASN1Object),P.asn1.cms.RevocationInfoChoice=function(t){P.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params;if(null!=e.crl&&"string"==typeof e.crl)return t=e.crl,-1!=e.crl.indexOf("-----BEGIN")?pemtohex(e.crl):t;if(null!=e.ocsp)return P.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new P.asn1.cms.OtherRevocationFormat(e)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.RevocationInfoChoice,P.asn1.ASN1Object),P.asn1.cms.OtherRevocationFormat=function(t){P.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=P,n=r.asn1.ASN1Util.newObject,i=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(i(t.ocsp)&&E.isASN1HEX(t.ocsp))return n({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex();throw new e("ocsp value not ASN.1 hex string")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cms.OtherRevocationFormat,P.asn1.ASN1Object),P.asn1.cms.CMSUtil=new function(){},P.asn1.cms.CMSUtil.newSignedData=function(t){return new P.asn1.cms.SignedData(t)},P.asn1.cms.CMSUtil.verifySignedData=function(t){var e=P,r=e.asn1,n=r.cms,n=(n.SignerInfo,n.SignedData,n.SigningTime,n.SigningCertificate,n.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),h=E.getVbyList,i=E.getTLVbyList,s=E.getIdxbyList,f=E.getChildIdx,g=E.getTLV,a=E.oidname,p=e.crypto.Util.hashHex,r=(void 0===t.cms&&n(t.cms),t.cms),o=function(t,e){var r=e.idx,n=(e.signerid_issuer1=i(t,r,[1,0],"30"),e.signerid_serial1=h(t,r,[1,1],"02"),e.hashalg=a(h(t,r,[2,0],"06")),s(t,r,[3],"a0"));e.idxSignedAttrs=n,function(t,e,r){var n=f(t,r);e.signedAttrIdxList=n;for(var i=0,s;i<n.length;i++){var a=n[i];var o=h(t,a,[0],"06");if(o==="2a864886f70d010905"){s=hextoutf8(h(t,a,[1,0]));e.saSigningTime=s}else if(o==="2a864886f70d010904"){s=h(t,a,[1,0],"04");e.saMessageDigest=s}}}(t,e,n);n=f(t,r).length;if(n<6)throw"malformed SignerInfo";e.sigalg=a(h(t,r,[n-2,0],"06")),e.sigval=h(t,r,[n-1],"04")},d=function(t,e,r,n){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var a=f(t,s),o=0;o<a.length;o++){var h=g(t,a[o]),u=new X509;u.readCertHex(h),i[o]=u,e.certkeys[o]=u.getPublicKey()}e.certs=i}else i=e.certs;e.cccc=i.length,e.cccci=a.length;for(o=0;o<i.length;o++){var c=u.getIssuerHex(),l=u.getSerialNumberHex();r.signerid_issuer1===c&&r.signerid_serial1===l&&(r.certkey_idx=o)}},e={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==h(t,0,[0],"06"))return;e.cmsType="signedData",e.econtent=h(t,0,[1,0,2,1,0]),function(t,e){for(var r,n,i=3;i<6;i++)void 0!==(n=s(t,0,[1,0,i]))&&("a0"===(r=t.substr(n,2))&&(e.certsIdx=n),"a1"===r&&(e.revinfosIdx=n),"31"===r)&&(e.signerinfosIdx=n)}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var n=f(t,r);e.signerInfoIdxList=n;for(var i=0;i<n.length;i++){var s={idx:n[i]};o(t,s),e.signerInfos.push(s)}}}(t,e)}(r,e.parse),function(t,e){for(var r=e.parse.signerInfos,n=r.length,i=!0,s=0;s<n;s++){var a=r[s];!function(t,e,r,n){r.verifyDetail={};var i=r.verifyDetail,s=e.parse.econtent,a=r.hashalg,o=r.saMessageDigest;if(i.validMessageDigest=false,p(s,a)===o)i.validMessageDigest=true;d(t,e,r,n),i.validSignatureValue=false;var h=r.sigalg,u="31"+g(t,r.idxSignedAttrs).substr(2),c=(r.signedattrshex=u,e.certs[r.certkey_idx].getPublicKey()),l=new P.crypto.Signature({alg:h}),f=(l.init(c),l.updateHex(u),l.verify(r.sigval));if((i.validSignatureValue_isValid=f)===true)i.validSignatureValue=true;if(r.isValid=false,i.validMessageDigest&&i.validSignatureValue)r.isValid=true}(t,e,a,s),a.isValid||(i=!1)}e.isValid=i}(r,e),e},P.asn1.cms.CMSParser=function(){var s=Error,a=X509,o=new a,h=E,u=h.getV,c=h.getTLV,e=(h.getIdxbyList,h.getTLVbyList),i=h.getTLVbyListEx,n=h.getVbyList,l=h.getVbyListEx,f=h.getChildIdx;this.getCMSSignedData=function(t){t=e(t,0,[1,0]);return this.getSignedData(t)},this.getSignedData=function(t){var e=f(t,0),r={},n=u(t,e[0]),n=parseInt(n,16),n=(r.version=n,c(t,e[1])),n=(r.hashalgs=this.getHashAlgArray(n),c(t,e[2])),e=(r.econtent=this.getEContent(n),i(t,0,["[0]"])),n=(null!=e&&(r.certs=this.getCertificateSet(e)),i(t,0,["[1]"]),i(t,0,[3]));return r.sinfos=this.getSignerInfos(n),r},this.getHashAlgArray=function(t){for(var e=f(t,0),r=new a,n=[],i=0;i<e.length;i++){var s=c(t,e[i]),s=r.getAlgorithmIdentifierName(s);n.push(s)}return n},this.getEContent=function(t){var e={},r=n(t,0,[0]),t=n(t,0,[1,0]);return e.type=P.asn1.x509.OID.oid2name(E.hextooidstr(r)),e.content={hex:t},e},this.getSignerInfos=function(t){for(var e=[],r=f(t,0),n=0;n<r.length;n++){var i=c(t,r[n]),i=this.getSignerInfo(i);e.push(i)}return e},this.getSignerInfo=function(t){var e={},r=f(t,0),n=h.getInt(t,r[0],-1),n=(-1!=n&&(e.version=n),c(t,r[1])),n=this.getIssuerAndSerialNumber(n),n=(e.id=n,c(t,r[2])),r=o.getAlgorithmIdentifierName(n),n=(e.hashalg=r,i(t,0,["[0]"])),n=(null!=n&&(r=this.getAttributeList(n),e.sattrs=r),i(t,0,[3])),r=o.getAlgorithmIdentifierName(n),n=(e.sigalg=r,l(t,0,[4])),r=(e.sighex=n,i(t,0,["[1]"]));return null!=r&&(n=this.getAttributeList(r),e.uattrs=n),e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},r=f(t,0),n=c(t,r[0]),n=(e.issuer=o.getX500Name(n),u(t,r[1]));return e.serial={hex:n},e},this.getAttributeList=function(t){for(var e=[],r=f(t,0),n=0;n<r.length;n++){var i=c(t,r[n]),i=this.getAttribute(i);e.push(i)}return{array:e}},this.getAttribute=function(t){var e={},r=f(t,0),n=h.getOID(t,r[0]),n=P.asn1.x509.OID.oid2name(n),i=(e.attr=n,c(t,r[1])),s=f(i,0);if(1==s.length)e.valhex=c(i,s[0]);else{for(var a=[],o=0;o<s.length;o++)a.push(c(i,s[o]));e.valhex=a}return"contentType"==n?this.setContentType(e):"messageDigest"==n?this.setMessageDigest(e):"signingTime"==n?this.setSigningTime(e):"signingCertificate"==n?this.setSigningCertificate(e):"signingCertificateV2"==n?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==n&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=h.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=hextoutf8(u(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=u(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=f(t.valhex,0);if(0<e.length){for(var r=c(t.valhex,e[0]),n=f(r,0),i=[],s=0;s<n.length;s++){var a=c(r,n[s]),a=this.getESSCertID(a);i.push(a)}t.array=i}1<e.length&&(e=c(t.valhex,e[1]),t.polhex=e),delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var e,r,n=f(t.valhex,0);0<n.length&&(e=h.getOID(t.valhex,n[0]),t.oid=e),1<n.length&&(e=new a,n=f(t.valhex,n[1]),r=c(t.valhex,n[0]),e=e.getAlgorithmIdentifierName(r),t.alg=e,r=u(t.valhex,n[1]),t.hash=r),delete t.valhex},this.setSigningCertificateV2=function(t){var e=f(t.valhex,0);if(0<e.length){for(var r=c(t.valhex,e[0]),n=f(r,0),i=[],s=0;s<n.length;s++){var a=c(r,n[s]),a=this.getESSCertIDv2(a);i.push(a)}t.array=i}1<e.length&&(e=c(t.valhex,e[1]),t.polhex=e),delete t.valhex},this.getESSCertID=function(t){var e,r={},n=f(t,0);return 0<n.length&&(e=u(t,n[0]),r.hash=e),1<n.length&&(e=c(t,n[1]),null!=(t=this.getIssuerSerial(e)).serial&&(r.serial=t.serial),null!=t.issuer)&&(r.issuer=t.issuer),r},this.getESSCertIDv2=function(t){var e={},r=f(t,0);if(r.length<1||3<r.length)throw new s("wrong number of elements");var n=0,i=("30"==t.substr(r[0],2)?(i=c(t,r[0]),e.alg=o.getAlgorithmIdentifierName(i),n++):e.alg="sha256",u(t,r[n]));return e.hash=i,r.length>n+1&&(i=c(t,r[n+1]),t=this.getIssuerSerial(i),e.issuer=t.issuer,e.serial=t.serial),e},this.getIssuerSerial=function(t){var e={},r=f(t,0),n=c(t,r[0]),n=o.getGeneralNames(n)[0].dn,n=(e.issuer=n,u(t,r[1]));return e.serial={hex:n},e},this.getCertificateSet=function(t){for(var e=f(t,0),r=[],n=0;n<e.length;n++){var i=c(t,e[n]);"30"==i.substr(0,2)&&(i=hextopem(i,"CERTIFICATE"),r.push(i))}return{array:r,sortflag:!1}}},void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),void 0!==P.asn1.tsp&&P.asn1.tsp||(P.asn1.tsp={}),P.asn1.tsp.TimeStampToken=function(t){var e=P.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.TimeStampToken,P.asn1.cms.SignedData),P.asn1.tsp.TSTInfo=function(t){Error;var e=P.asn1,r=e.DERSequence,n=e.DERInteger,i=e.DERBoolean,s=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,h=e.tsp,u=h.MessageImprint,c=h.Accuracy,e=(e.x509.X500Name,e.x509.GeneralName);if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new n({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);t=new r({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new n(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new i),void 0!==t.nonce&&(this.dNonce=new n(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new e({dn:t.tsa})}))}},extendClass(P.asn1.tsp.TSTInfo,P.asn1.ASN1Object),P.asn1.tsp.Accuracy=function(t){var e=P.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.Accuracy,P.asn1.ASN1Object),P.asn1.tsp.MessageImprint=function(t){var e=P.asn1,r=e.DERSequence,n=e.DEROctetString,i=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new i({name:t.alg}),t=new n({hex:t.hash});return new r({array:[e,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.tsp.MessageImprint,P.asn1.ASN1Object),P.asn1.tsp.TimeStampReq=function(t){var e=P.asn1,r=e.DERSequence,n=e.DERInteger,i=e.DERBoolean,s=(e.ASN1Object,e.DERObjectIdentifier),e=e.tsp,a=e.MessageImprint;e.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new n({int:1})),t.messageImprint instanceof P.asn1.ASN1Object?e.push(t.messageImprint):e.push(new a(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new n(t.nonce)),1==t.certreq&&e.push(new i),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.TimeStampReq,P.asn1.ASN1Object),P.asn1.tsp.TimeStampResp=function(t){var r=P.asn1,n=r.DERSequence,i=(r.ASN1Object,r.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?e.push(new s(t.statusinfo)):e.push(new s("granted")),null!=t.econtent)e.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof r.ASN1Object))throw new Error("improper member tst value");e.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");e.push(new s(t.statusinfo))}return new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.TimeStampResp,P.asn1.ASN1Object),P.asn1.tsp.PKIStatusInfo=function(t){var r=Error,e=P.asn1,n=e.DERSequence,e=e.tsp,i=e.PKIStatus,s=e.PKIFreeText,a=e.PKIFailureInfo;e.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if("string"==typeof t)e.push(new i(t));else{if(null==t.status)throw new r("property 'status' unspecified");e.push(new i(t.status)),null!=t.statusstr&&e.push(new s(t.statusstr)),null!=t.failinfo&&e.push(new a(t.failinfo))}return new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.PKIStatusInfo,P.asn1.ASN1Object),P.asn1.tsp.PKIStatus=function(t){var r=Error,e=P.asn1,n=e.DERInteger,i=(e.tsp.PKIStatus.superclass.constructor.call(this),{granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5});this.params=null,this.tohex=function(){var t,e=this.params;if("string"==typeof e)try{t=i[e]}catch(t){throw new r("undefined name: "+e)}else{if("number"!=typeof e)throw new r("unsupported params");t=e}return new n({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.PKIStatus,P.asn1.ASN1Object),P.asn1.tsp.PKIFreeText=function(t){var n=Error,e=P.asn1,i=e.DERSequence,s=e.DERUTF8String;e.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new n("wrong params: not array");for(var e=[],r=0;r<t.length;r++)e.push(new s({str:t[r]}));return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.PKIFreeText,P.asn1.ASN1Object),P.asn1.tsp.PKIFailureInfo=function(t){var s=Error,e=P.asn1,r=e.DERBitString,e=e.tsp.PKIFailureInfo,a={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};e.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,e=0;if("number"==typeof t&&0<=t&&t<=25){for(var r=(e|=1<<t).toString(2),n="",i=r.length-1;0<=i;i--)n+=r[i];return n}if("string"==typeof t&&null!=a[t])return namearraytobinstr([t],a);if("object"==typeof t&&null!=t.length)return namearraytobinstr(t,a);throw new s("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new r({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.tsp.PKIFailureInfo,P.asn1.ASN1Object),P.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},P.asn1.tsp.SimpleTSAAdapter=function(t){var e=P,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){t=n(t,e),this.params.econtent.content.messageImprint={alg:e,hash:t},this.params.econtent.content.serial={int:this.serial++},e=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:e},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.tsp.SimpleTSAAdapter,P.asn1.tsp.AbstractTSAAdapter),P.asn1.tsp.FixedTSAAdapter=function(t){var e=P,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){t=n(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:t},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},extendClass(P.asn1.tsp.FixedTSAAdapter,P.asn1.tsp.AbstractTSAAdapter),P.asn1.tsp.TSPUtil=new function(){},P.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new P.asn1.tsp.TimeStampToken(t)},P.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new P.asn1.tsp.TSPParser).getTimeStampReq(t)},P.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new P.asn1.tsp.TSPParser).getMessageImprint(t)},P.asn1.tsp.TSPParser=function(){Error;var s=new X509,h=E,u=h.getV,c=h.getTLV,i=h.getIdxbyList,l=(h.getTLVbyListEx,h.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],e={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e,r=l(t,0);return 1==r.length?this.getPKIStatusInfo(c(t,r[0])):1<r.length?(e=this.getPKIStatusInfo(c(t,r[0])),t=c(t,r[1]),(r=this.getToken(t)).statusinfo=e,r):void 0},this.getToken=function(t){t=(new P.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(t),t},this.setTSTInfo=function(t){var e,t=t.econtent;"tstinfo"==t.type&&(e=t.content.hex,e=this.getTSTInfo(e),t.content=e)},this.getTSTInfo=function(t){var e,r={},n=l(t,0),i=u(t,n[1]),i=(r.policy=hextooid(i),c(t,n[2])),i=(r.messageImprint=this.getMessageImprint(i),u(t,n[3])),i=(r.serial={hex:i},u(t,n[4])),i=(r.genTime={str:hextoutf8(i)},0);return 5<n.length&&"30"==t.substr(n[5],2)&&(e=c(t,n[5]),r.accuracy=this.getAccuracy(e),i++),n.length>5+i&&"01"==t.substr(n[5+i],2)&&("ff"==u(t,n[5+i])&&(r.ordering=!0),i++),n.length>5+i&&"02"==t.substr(n[5+i],2)&&(e=u(t,n[5+i]),r.nonce={hex:e},i++),n.length>5+i&&"a0"==t.substr(n[5+i],2)&&(e="30"+(e=c(t,n[5+i])).substr(2),e=(pGeneralNames=s.getGeneralNames(e))[0].dn,r.tsa=e,i++),n.length>5+i&&"a1"==t.substr(n[5+i],2)&&(e="30"+(e=c(t,n[5+i])).substr(2),t=s.getExtParamArray(e),r.ext=t,i++),r},this.getAccuracy=function(t){for(var e={},r=l(t,0),n=0;n<r.length;n++){var i=t.substr(r[n],2),s=u(t,r[n]),s=parseInt(s,16);"02"==i?e.seconds=s:"80"==i?e.millis=s:"81"==i&&(e.micros=s)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var e={},r=(l(t,0),i(t,0,[0,0])),r=u(t,r),r=h.hextooidstr(r),n=P.asn1.x509.OID.oid2name(r);if(""==n)throw new Error("hashAlg name undefined: "+r);r=n,n=i(t,0,[1]);return e.alg=r,e.hash=u(t,n),e},this.getPKIStatusInfo=function(t){var e={},r=l(t,0),n=0;try{var i=u(t,r[0]),s=parseInt(i,16);e.status=a[s]}catch(t){}return 1<r.length&&"30"==t.substr(r[1],2)&&(i=c(t,r[1]),e.statusstr=this.getPKIFreeText(i),n++),r.length>n&&"03"==t.substr(r[1+n],2)&&(s=c(t,r[1+n]),e.failinfo=this.getPKIFailureInfo(s)),e},this.getPKIFreeText=function(t){for(var e=[],r=l(t,0),n=0;n<r.length;n++)e.push(h.getString(t,r[n]));return e},this.getPKIFailureInfo=function(t){t=h.getInt(t,0);return null!=e[t]?e[t]:t},this.getTimeStampReq=function(t){var e={certreq:!1},r=l(t,0);if(r.length<2)throw new Error("TimeStampReq must have at least 2 items");var n=c(t,r[1]);e.messageImprint=P.asn1.tsp.TSPUtil.parseMessageImprint(n);for(var i=2;i<r.length;i++){var s,a=r[i],o=t.substr(a,2);"06"==o&&(s=u(t,a),e.policy=h.hextooidstr(s)),"02"==o&&(e.nonce=u(t,a)),"01"==o&&(e.certreq=!0)}return e}},void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),void 0!==P.asn1.cades&&P.asn1.cades||(P.asn1.cades={}),P.asn1.cades.SignaturePolicyIdentifier=function(t){var e=P.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.SignaturePolicyIdentifier,P.asn1.cms.Attribute),P.asn1.cades.SignaturePolicyId=function(t){var e=P.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,e=(e.x509.AlgorithmIdentifier,e.cades),i=e.SignaturePolicyId,s=e.OtherHashAlgAndValue;i.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new n(t.oid)),e.push(new s(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.SignaturePolicyId,P.asn1.ASN1Object),P.asn1.cades.OtherHashAlgAndValue=function(t){var n=Error,e=P.asn1,i=e.DERSequence,s=e.DEROctetString,a=e.x509.AlgorithmIdentifier;e.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new n("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new n("property 'hash' nor 'cert' not specified");var e=null;if(null!=t.hash)e=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new n("cert not string");var r=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(r=pemtohex(t.cert)),e=P.crypto.Util.hashHex(r,t.alg)}r=[];return r.push(new a({name:t.alg})),r.push(new s({hex:e})),new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.OtherHashAlgAndValue,P.asn1.ASN1Object),P.asn1.cades.OtherHashValue=function(t){P.asn1.cades.OtherHashValue.superclass.constructor.call(this);var n=Error,e=P,i=(e.lang.String.isHex,e.asn1.DEROctetString);e.crypto.Util.hashHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new n("hash or cert not specified");var e=null;if(null!=t.hash)e=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new n("cert not string");var r=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(r=pemtohex(t.cert)),e=P.crypto.Util.hashHex(r,"sha1")}return new i({hex:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.OtherHashValue,P.asn1.ASN1Object),P.asn1.cades.SignatureTimeStamp=function(t){var n=Error,e=P,i=e.lang.String.isHex,e=e.asn1,s=e.ASN1Object;e.x509;e.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(e=new s).hTLV=t.tst,[e];if(t.tst instanceof s)return[t.tst];throw new n("params.tst has wrong value")}if(null!=t.res){var e,r=t.res;if("string"==typeof(r=r instanceof s?r.tohex():r)&&i(r))return E.getTLVbyList(r,0,[1]),(e=new s).hTLV=t.tst,[e];throw new n("params.res has wrong value")}},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.SignatureTimeStamp,P.asn1.cms.Attribute),P.asn1.cades.CompleteCertificateRefs=function(t){var i=Error,e=P,r=e.asn1,s=r.DERSequence,r=r.cades,a=r.OtherCertID,o=e.lang.String.isHex;r.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,e=[],r=0;r<t.array.length;r++){var n=t.array[r];if("string"==typeof n)if(-1!=n.indexOf("-----BEGIN"))n={cert:n};else{if(!o(n))throw new i("unsupported value: "+n);n={hash:n}}null!=t.alg&&null==n.alg&&(n.alg=t.alg),null!=t.hasis&&null==n.hasis&&(n.hasis=t.hasis);n=new a(n);e.push(n)}return[new s({array:e})]},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.CompleteCertificateRefs,P.asn1.cms.Attribute),P.asn1.cades.OtherCertID=function(t){var e=P.asn1,n=e.DERSequence,i=e.cms.IssuerSerial,e=e.cades,s=e.OtherHashValue,a=e.OtherHashAlgAndValue;e.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params,e=("string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t})),[]),r=null,r=new(null!=t.alg?a:s)(t);return e.push(r),(null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial)&&(r=new i(t),e.push(r)),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.OtherCertID,P.asn1.ASN1Object),P.asn1.cades.OtherHash=function(t){Error;var e=P,r=e.asn1,r=(r.cms,r.cades),n=r.OtherHashAlgAndValue,i=r.OtherHashValue,s=(e.crypto.Util.hashHex,e.lang.String.isHex);r.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:s(t)&&(t={hash:t}));return new(null!=t.alg?n:i)(t).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.cades.OtherHash,P.asn1.ASN1Object),P.asn1.cades.CAdESUtil=new function(){},P.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new P.asn1.cms.CMSParser).getCMSSignedData(t)},P.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var n=E.getChildIdx,i=E.getTLV,s=E.getV,a=P.asn1,o=a.ASN1Object,a=a.cms,h=a.AttributeList,a=a.SignerInfo,u={},n=n(t,e);if(6!=n.length)throw"not supported items for SignerInfo (!=6)";e=n.shift(),u.version=i(t,e),e=n.shift(),u.si=i(t,e),e=n.shift(),u.digalg=i(t,e),e=n.shift(),u.sattrs=i(t,e),e=n.shift(),u.sigalg=i(t,e),e=n.shift(),u.sig=i(t,e),u.sigval=s(t,e),n=null;return u.obj=new a,(n=new o).hTLV=u.version,u.obj.dCMSVersion=n,(n=new o).hTLV=u.si,u.obj.dSignerIdentifier=n,(n=new o).hTLV=u.digalg,u.obj.dDigestAlgorithm=n,(n=new o).hTLV=u.sattrs,u.obj.dSignedAttrs=n,(n=new o).hTLV=u.sigalg,u.obj.dSigAlg=n,(n=new o).hTLV=u.sig,u.obj.dSig=n,u.obj.dUnsignedAttrs=new h,u},void 0!==P.asn1.csr&&P.asn1.csr||(P.asn1.csr={}),P.asn1.csr.CertificationRequest=function(t){var e=P.asn1,n=e.DERBitString,i=e.DERSequence,r=e.csr,s=(e.x509,r.CertificationRequestInfo);r.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new P.crypto.Signature({alg:this.params.sigalg}),t=(e.init(this.params.sbjprvkey),e.updateHex(t),e.sign());this.params.sighex=t},this.getPEM=function(){return hextopem(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new P.asn1.csr.CertificationRequestInfo(this.params),r=new P.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");t=new n({hex:"00"+t.sighex});return new i({array:[e,r,t]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.csr.CertificationRequest,P.asn1.ASN1Object),P.asn1.csr.CertificationRequestInfo=function(t){var e=P.asn1,n=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,a=e.DERTaggedObject,o=e.ASN1Util.newObject,r=e.csr,e=e.x509,h=e.X500Name,u=e.Extensions,c=e.SubjectPublicKeyInfo;r.AttributeList;r.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t,e=this.params,r=[];return r.push(new i({int:0})),r.push(new h(e.subject)),r.push(new c(b.getKey(e.sbjpubkey))),null!=e.attrs?(t=function m(t){for(var e=Error,r=P.asn1.x509.Extensions,n=[],i=0;i<t.length;i++){var s=t[i],a=s.attr;if("extensionRequest"==a)var o={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(s.ext)]}]};else if("unstructuredName"==a)o={seq:[{oid:"1.2.840.113549.1.9.2"},{set:s.names}]};else{if("challengePassword"!=a)throw new e("unknown CSR attribute");o={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:s.password}]}]}}n.push(o)}return{set:n}}(e.attrs),t=o({tag:{tage:"a0",obj:t}}),r.push(t)):null!=e.extreq?(e=new u(e.extreq),t=o({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[e]}]}}}),r.push(t)):r.push(new a({tag:"a0",explicit:!1,obj:new s({str:""})})),new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},extendClass(P.asn1.csr.CertificationRequestInfo,P.asn1.ASN1Object),P.asn1.csr.AttributeList=function(t){},extendClass(P.asn1.csr.AttributeList,P.asn1.ASN1Object),P.asn1.csr.CSRUtil=new function(){},P.asn1.csr.CSRUtil.newCSRPEM=function(t){return new P.asn1.csr.CertificationRequest(t).getPEM()},P.asn1.csr.CSRUtil.getParam=function(t,e){var r=E.getV,n=E.getIdxbyList,i=E.getTLVbyList,s=E.getTLVbyListEx,a=E.getVbyListEx,o={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");t=pemtohex(t,"CERTIFICATE REQUEST");e&&(o.tbs=i(t,0,[0]));try{var h=s(t,0,[0,1]);"3000"==h?o.subject={}:(u=new X509,o.subject=u.getX500Name(h))}catch(t){}var e=s(t,0,[0,2]),h=b.getKey(e,null,"pkcs8pub"),e=(o.sbjpubkey=b.getPEM(h,"PKCS8PUB"),function(t){var e=n(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=r(t,e)?null:i(t,0,[0,3,0,1,0],"30")}(t)),u=new X509;null!=e&&(o.extreq=u.getExtParamArray(e));try{var c=s(t,0,[1],"30"),u=new X509;o.sigalg=u.getAlgorithmIdentifierName(c)}catch(t){}try{var l=a(t,0,[2]);o.sighex=l}catch(t){}return o},P.asn1.csr.CSRUtil.verifySignature=function(t){try{var e,r=null;return("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?r=P.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(r=t),null==r)?!1:((e=new P.crypto.Signature({alg:r.sigalg})).init(r.sbjpubkey),e.updateHex(r.tbs),e.verify(r.sighex))}catch(t){return alert(t),!1}},void 0!==(P=void 0!==P&&P?P:{}).asn1&&P.asn1||(P.asn1={}),void 0!==P.asn1.ocsp&&P.asn1.ocsp||(P.asn1.ocsp={}),P.asn1.ocsp.DEFAULT_HASH="sha1",P.asn1.ocsp.OCSPResponse=function(t){P.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);P.asn1.DEREnumerated;var r=P.asn1.ASN1Util.newObject,n=P.asn1.ocsp.ResponseBytes,e=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:e.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=this._getStatusCode();if(-1==e)throw new Error("responseStatus not supported: "+t.resstatus);return(0!=e?r({seq:[{enum:{int:e}}]}):(e=new n(t),r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:e}}]}))).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.OCSPResponse,P.asn1.ASN1Object),P.asn1.ocsp.ResponseBytes=function(t){P.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=P.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,i=e.DEROctetString,s=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var t=new s(t),e=[];return e.push(new n({name:"ocspBasic"})),e.push(new i({hex:t.tohex()})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.ResponseBytes,P.asn1.ASN1Object),P.asn1.ocsp.BasicOCSPResponse=function(t){P.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var o=Error,e=P.asn1,h=e.ASN1Object,u=e.DERSequence,c=(e.DERGeneralizedTime,e.DERTaggedObject),l=e.DERBitString,f=(e.x509.Extensions,e.x509.AlgorithmIdentifier),e=e.ocsp;e.ResponderID;_SingleResponseList=e.SingleResponseList,_ResponseData=e.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new P.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params,e=(null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign(),[]);if(e.push(t.tbsresp),e.push(new f({name:t.sigalg})),e.push(new l({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var r=[],n=0;n<t.certs.length;n++){var i=t.certs[n],s=null;if(E.isASN1HEX(i))s=i;else{if(!i.match(/-----BEGIN/))throw new o("certs["+n+"] not hex or PEM");s=pemtohex(i)}r.push(new h({tlv:s}))}var a=new u({array:r});e.push(new c({tag:"a0",explicit:!0,obj:a}))}return new u({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.BasicOCSPResponse,P.asn1.ASN1Object),P.asn1.ocsp.ResponseData=function(t){P.asn1.ocsp.ResponseData.superclass.constructor.call(this);var r=Error,e=P.asn1,n=e.DERSequence,i=e.DERGeneralizedTime,s=e.DERTaggedObject,a=e.x509.Extensions,e=e.ocsp,o=e.ResponderID;_SingleResponseList=e.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params,e=(null!=t.respid&&new r("respid not specified"),null!=t.prodat&&new r("prodat not specified"),null!=t.array&&new r("array not specified"),[]);return e.push(new o(t.respid)),e.push(new i(t.prodat)),e.push(new _SingleResponseList(t.array)),null!=t.ext&&(t=new a(t.ext),e.push(new s({tag:"a1",explicit:!0,obj:t}))),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.ResponseData,P.asn1.ASN1Object),P.asn1.ocsp.ResponderID=function(t){P.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=P,r=e.asn1,n=r.ASN1Util.newObject,i=r.x509.X500Name,s=e.lang.String.isHex,a=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e=null;if("string"==typeof t.key?(s(t.key)&&(e=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(r=new X509(t.key).getExtSubjectKeyIdentifier())&&(e=r.kid.hex)):t.key instanceof X509&&null!=(r=t.key.getExtSubjectKeyIdentifier())&&(e=r.kid.hex),null==e)throw new a("wrong key member value");return n({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:e}}}}).tohex()}if(null==t.name)throw new a("key or name not specified");var r=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?r=new X509(t.name).getSubject():t.name instanceof X509?r=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(r=t.name),null==r)throw new a("wrong name member value");return n({tag:{tag:"a1",explicit:!0,obj:new i(r)}}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.ResponderID,P.asn1.ASN1Object),P.asn1.ocsp.SingleResponseList=function(t){P.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=P.asn1,n=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],r=0;r<t.length;r++)e.push(new i(t[r]));return new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.SingleResponseList,P.asn1.ASN1Object),P.asn1.ocsp.SingleResponse=function(t){var n=Error,e=P.asn1,i=e.DERSequence,s=e.DERGeneralizedTime,a=e.DERTaggedObject,r=e.ocsp,o=r.CertID,h=r.CertStatus,u=e.x509.Extensions;r.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params,r=[];if(null==e.certid)throw new n("certid unspecified");if(null==e.status)throw new n("status unspecified");if(null==e.thisupdate)throw new n("thisupdate unspecified");return r.push(new o(e.certid)),r.push(new h(e.status)),r.push(new s(e.thisupdate)),null!=e.nextupdate&&(t=new s(e.nextupdate),r.push(new a({tag:"a0",explicit:!0,obj:t}))),null!=e.ext&&(t=new u(e.ext),r.push(new a({tag:"a1",explicit:!0,obj:t}))),new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.SingleResponse,P.asn1.ASN1Object),P.asn1.ocsp.CertID=function(t){var e=P,r=e.asn1,s=r.DEROctetString,a=r.DERInteger,o=r.DERSequence,h=r.x509.AlgorithmIdentifier,r=r.ocsp,i=(r.DEFAULT_HASH,e.crypto.Util.hashHex),u=X509,c=E.getVbyList;r.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,n){null==n&&(n=this.DEFAULT_HASH),this.params={alg:n,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var t=new u(t),e=new u(e),n=i(t.getSubjectHex(),r),t=t.getPublicKeyHex();return{alg:r,issname:n,isskey:i(c(t,0,[1],"03",!0),r),sbjsn:e.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t=this.params,e=null==t.alg?this.DEFAULT_HASH:t.alg;if(null!=t.issuerCert&&null!=t.subjectCert)var r=this.getParamByCerts(t.issuerCert,t.subjectCert,e),n=r.issname,i=r.isskey,r=r.sbjsn;else{if(null==t.issname||null==t.isskey||null==t.sbjsn)throw new Error("required param members not defined");n=t.issname,i=t.isskey,r=t.sbjsn}t=new h({name:e}),e=new s({hex:n}),n=new s({hex:i}),i=new a({hex:r}),r=new o({array:[t,e,n,i]});return this.hTLV=r.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.CertID,P.asn1.ASN1Object),P.asn1.ocsp.CertStatus=function(t){P.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e=this.params;if("good"==e.status)return"8000";if("unknown"==e.status)return"8200";if("revoked"==e.status)return t=[{gentime:{str:e.time}}],null!=e.reason&&t.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:e.reason}}}}),P.asn1.ASN1Util.newObject({tag:{tag:"a1",explicit:!1,obj:{seq:t}}}).tohex();throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},extendClass(P.asn1.ocsp.CertStatus,P.asn1.ASN1Object),P.asn1.ocsp.Request=function(t){var e=P.asn1,r=e.DERSequence,e=e.ocsp;e.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);t=new r({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(e=new e.CertID(t),this.dReqCert=e)},extendClass(P.asn1.ocsp.Request,P.asn1.ASN1Object),P.asn1.ocsp.TBSRequest=function(t){var e=P.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var n=new i.Request(t[0]);e.push(n)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},extendClass(P.asn1.ocsp.TBSRequest,P.asn1.ASN1Object),P.asn1.ocsp.OCSPRequest=function(t){var e=P.asn1,r=e.DERSequence,e=e.ocsp;e.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";t=new r({array:t});return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&(e=new e.TBSRequest(t),this.dTbsRequest=e)},extendClass(P.asn1.ocsp.OCSPRequest,P.asn1.ASN1Object),P.asn1.ocsp.OCSPUtil={},P.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var n=P.asn1.ocsp,r={alg:r=void 0===r?n.DEFAULT_HASH:r,issuerCert:t,subjectCert:e};return new n.OCSPRequest({reqList:[r]}).tohex()},P.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=E.getVbyList,r=E.getVbyListEx,n=E.getIdxbyList,i=(E.getIdxbyListEx,E.getV),s={};try{var a=r(t,0,[0],"0a");s.responseStatus=parseInt(a,16)}catch(t){}if(0===s.responseStatus){try{var o=n(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(o,2)?s.certStatus="good":"a1"===t.substr(o,2)?(s.certStatus="revoked",s.revocationTime=hextoutf8(e(t,o,[0]))):"82"===t.substr(o,2)&&(s.certStatus="unknown")}catch(t){}try{var h=n(t,0,[1,0,1,0,0,2,0,2]);s.thisUpdate=hextoutf8(i(t,h))}catch(t){}try{var u=n(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(u,2)&&(s.nextUpdate=hextoutf8(e(t,u,[0])))}catch(t){}}return s},P.asn1.ocsp.OCSPParser=function(){var i=Error,s=X509,n=new s,u=E.getV,c=E.getTLV,a=E.getIdxbyList,o=E.getVbyList,h=E.getTLVbyList,l=E.getVbyListEx,f=E.getTLVbyListEx,g=E.getChildIdx;this.getOCSPRequest=function(t){var e=g(t,0);if(1!=e.length&&2!=e.length)throw new i("wrong number elements: "+e.length);return this.getTBSRequest(c(t,e[0]))},this.getTBSRequest=function(t){var e={},r=f(t,0,[0],"30"),r=(e.array=this.getRequestList(r),f(t,0,["[2]",0],"30"));return null!=r&&(e.ext=n.getExtParamArray(r)),e},this.getRequestList=function(t){for(var e=[],r=g(t,0),n=0;n<r.length;n++){t=c(t,r[n]);e.push(this.getRequest(t))}return e},this.getRequest=function(t){var e=g(t,0);if(1!=e.length&&2!=e.length)throw new i("wrong number elements: "+e.length);var r=this.getCertID(c(t,e[0]));return 2==e.length&&(e=a(t,0,[1,0]),r.ext=n.getExtParamArray(c(t,e))),r},this.getCertID=function(t){var e=g(t,0);if(4!=e.length)throw new i("wrong number elements: "+e.length);var r=new s,n={};return n.alg=r.getAlgorithmIdentifierName(c(t,e[0])),n.issname=u(t,e[1]),n.isskey=u(t,e[2]),n.sbjsn=u(t,e[3]),n},this.getOCSPResponse=function(t){var e=g(t,0),r=u(t,e[0]),r=parseInt(r);return 1==e.length?{resstatus:r}:(e=h(t,0,[1,0]),(t=this.getResponseBytes(e)).resstatus=r,t)},this.getResponseBytes=function(t){var e=g(t,0),r=h(t,0,[1,0]),r=this.getBasicOCSPResponse(r),t=u(t,e[0]);return r.restype=P.asn1.x509.OID.oid2name(hextooid(t)),r},this.getBasicOCSPResponse=function(t){var e=g(t,0),r=this.getResponseData(c(t,e[0])),n=new X509,n=(r.alg=n.getAlgorithmIdentifierName(c(t,e[1])),u(t,e[2])),i=(r.sighex=n.substr(2),l(t,0,["[0]"]));if(null!=i){for(var s=g(i,0),a=[],o=0;o<s.length;o++){var h=c(i,s[o]);a.push(h)}r.certs=a}return r},this.getResponseData=function(t){var e=g(t,0),r=e.length,n={},i=0,s=("a0"==t.substr(e[0],2)&&i++,n.respid=this.getResponderID(c(t,e[i++])),u(t,e[i++]));return n.prodat=hextoutf8(s),n.array=this.getSingleResponseList(c(t,e[i++])),"a1"==t.substr(e[r-1],2)&&(s=h(t,e[r-1],[0]),i=new X509,n.ext=i.getExtParamArray(s)),n},this.getResponderID=function(t){var e,r={};return"a2"==t.substr(0,2)&&(e=o(t,0,[0]),r.key=e),"a1"==t.substr(0,2)&&(e=h(t,0,[0]),t=new X509,r.name=t.getX500Name(e)),r},this.getSingleResponseList=function(t){for(var e=g(t,0),r=[],n=0;n<e.length;n++){var i=this.getSingleResponse(c(t,e[n]));r.push(i)}return r},this.getSingleResponse=function(t){var e=g(t,0),r={},n=this.getCertID(c(t,e[0])),n=(r.certid=n,this.getCertStatus(c(t,e[1])));r.status=n,"18"==t.substr(e[2],2)&&(n=u(t,e[2]),r.thisupdate=hextoutf8(n));for(var i,s,a=3;a<e.length;a++)"a0"==t.substr(e[a],2)&&(i=o(t,e[a],[0],"18"),r.nextupdate=hextoutf8(i)),"a1"==t.substr(e[a],2)&&(i=new X509,s=h(t,0,[a,0]),r.ext=i.getExtParamArray(s));return r},this.getCertStatus=function(t){var e={};return"8000"==t?{status:"good"}:"8200"==t?{status:"unknown"}:("a1"==t.substr(0,2)&&(e.status="revoked",t=hextoutf8(o(t,0,[0])),e.time=t),e)}},void 0!==(P=void 0!==P&&P?P:{}).lang&&P.lang||(P.lang={}),P.lang.String=function(){},g="function"==typeof Buffer?(N=function(t){return b64tob64u(Buffer.from(t,"utf8").toString("base64"))},function(t){return Buffer.from(b64utob64(t),"base64").toString("utf8")}):(N=function(t){return hextob64u(uricmptohex(encodeURIComponentAll(t)))},function(t){return decodeURIComponent(hextouricmp(b64utohex(t)))}),P.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},P.lang.String.isHex=function(t){return ishex(t)},P.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},P.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=b64utob64(t),P.lang.String.isBase64(t))},P.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},P.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},P.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},P.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};function oidtohex(t){function Z0a(t){return t=1==(t=t.toString(16)).length?"0"+t:t}try{if(!t.match(/^[0-9.]+$/))return null;var e="",r=t.split("."),n=40*parseInt(r[0],10)+parseInt(r[1],10);e+=Z0a(n),r.splice(0,2);for(var i=0;i<r.length;i++)e+=function(t){for(var e="",r=7-(s=parseInt(t,10).toString(2)).length%7,n=(7==r&&(r=0),""),i=0;i<r;i++)n+="0";for(var s=n+s,i=0;i<s.length-1;i+=7){var a=s.substr(i,7);i!=s.length-7&&(a="1"+a),e+=Z0a(parseInt(a,2))}return e}(r[i]);return e}catch(t){return null}}function hextooid(t){if(!ishex(t))return null;try{for(var e=[],r=t.substr(0,2),n=parseInt(r,16),i=(e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40),t.substr(2)),s=[],a=0;a<i.length/2;a++)s.push(parseInt(i.substr(2*a,2),16));for(var o=[],h="",a=0;a<s.length;a++)128&s[a]?h+=O((127&s[a]).toString(2),7):(h+=O((127&s[a]).toString(2),7),o.push(new String(parseInt(h,2))),h="");var u=e.join(".");return u=0<o.length?u+"."+o.join("."):u}catch(t){return null}}function inttohex(t){return twoscompl(new BigInteger(String(t),10))}function twoscompl(t){if("-"!=(i=t.toString(16)).substr(0,1))i.length%2==1?i="0"+i:i.match(/^[0-7]/)||(i="00"+i);else{for(var e=i.substr(1).length,r=(e%2==1?e+=1:i.match(/^[0-7]/)||(e+=2),""),n=0;n<e;n++)r+="f";var i=new BigInteger(r,16).xor(t).add(BigInteger.ONE).toString(16).replace(/^-/,"")}return i}var O=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function bitstrtoint(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e,r,n,i,s=t.substr(0,2);return"00"==s?parseInt(t.substr(2),16):7<(e=parseInt(s,16))||(r=t.substr(2),n=(n="0"==(n=parseInt(r,16).toString(2))?"00000000":n).slice(0,0-e),NaN==(i=parseInt(n,2)))?-1:i}catch(t){return-1}}function bitstrtobinstr(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),n="",i=0;i<r.length;i+=2){var s=r.substr(i,2);n+=("0000000"+parseInt(s,16).toString(2)).slice(-8)}return n.substr(0,n.length-e)}catch(t){return null}}function namearraytobinstr(t,e){for(var r=0,n=0;n<t.length;n++)r|=1<<e[t[n]];for(var i=r.toString(2),s="",n=i.length-1;0<=n;n--)s+=i[n];return s}function aryval(t,e,r){if("object"==typeof t){for(var e=String(e).split("."),n=0;n<e.length&&t;n++){var i=e[n];t=t[i=i.match(/^[0-9]+$/)?parseInt(i):i]}return t||!1===t?t:r}}function extendClass(t,e){function u1a(){}u1a.prototype=e.prototype,t.prototype=new u1a,(t.prototype.constructor=t).superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==(P=void 0!==P&&P?P:{}).crypto&&P.crypto||(P.crypto={}),P.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",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",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:I.algo.MD5,sha1:I.algo.SHA1,sha224:I.algo.SHA224,sha256:I.algo.SHA256,sha384:I.algo.SHA384,sha512:I.algo.SHA512,ripemd160:I.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var t=this.getDigestInfoHex(t,e),n=r/4;if(t.length+22>n)throw"key is too short for SigAlg: keylen="+r+","+e;for(var r="00"+t,i="",s=n-"0001".length-r.length,a=0;a<s;a+=2)i+="ff";return"0001"+i+r},this.hashString=function(t,e){return new P.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new P.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof RSAKey||t instanceof P.crypto.DSA||t instanceof P.crypto.ECDSA}},P.crypto.Util.md5=function(t){return new P.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},P.crypto.Util.ripemd160=function(t){return new P.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},P.crypto.Util.SECURERANDOMGEN=new SecureRandom,P.crypto.Util.getRandomHexOfNbytes=function(t){t=new Array(t);return P.crypto.Util.SECURERANDOMGEN.nextBytes(t),BAtohex(t)},P.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new BigInteger(P.crypto.Util.getRandomHexOfNbytes(t),16)},P.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,t=new Array(1+(t-e)/8);return P.crypto.Util.SECURERANDOMGEN.nextBytes(t),t[0]=(255<<e&255^255)&t[0],BAtohex(t)},P.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new BigInteger(P.crypto.Util.getRandomHexOfNbits(t),16)},P.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=P.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},P.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";return 0==r?t:(r=e.subtract(t),P.crypto.Util.getRandomBigIntegerZeroToMax(r).add(t))},P.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(e,t){if(null!==(e=P.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=P.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=P.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){t=I.enc.Hex.parse(t);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(I.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){t=sjcl.codec.hex.toBits(t);this.md.update(t)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=P.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},P.crypto.MessageDigest.getCanonicalAlgName=function(t){return t="string"==typeof t?(t=t.toLowerCase()).replace(/-/,""):t},P.crypto.MessageDigest.getHashLength=function(t){var e=P.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},P.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},P.crypto.Mac=function(t){this.setAlgAndProvider=function(e,t){if("hmac"!=(e=(e=null==(e=e.toLowerCase())?"hmacsha1":e).toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=P.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;e=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{var r=P.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e];this.mac=I.algo.HMAC.create(r,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+e+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){t=I.enc.Hex.parse(t);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(I.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t)(e=t).length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=rstrtohex(t));else{if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;var e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=utf8tohex(t.utf8)),void 0!==t.rstr&&(e=rstrtohex(t.rstr)),void 0!==t.b64&&(e=b64tohex(t.b64)),null==(e=void 0!==t.b64u?b64utohex(t.b64u):e))throw"KJUR.crypto.Mac unsupported password type: "+t}this.pass=I.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg)&&(this.algName=t.alg,void 0===t.prov&&(this.provName=P.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},P.crypto.Signature=function(t){if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName)&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1")},this._zeroPaddingOfSignature=function(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new P.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?b.getKey(t):b.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==P.crypto.ECDSA&&(this.prvKey=new P.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else{if(!(this.prvKey instanceof P.crypto.ECDSA||this.prvKey instanceof P.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==P.crypto.ECDSA&&(this.pubKey=new P.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof RSAKey&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof RSAKey&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==P.crypto.ECDSA&&this.pubKey instanceof P.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==P.crypto.DSA&&this.pubKey instanceof P.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},void 0!==(this.initParams=t)&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=P.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{var e=b.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},P.crypto.Cipher=function(t){},P.crypto.Cipher.encrypt=function(t,e,r,n){if("string"==typeof(r=null!=aryval(n,"enclag")?n.encalg:r)&&"-CBC"==r.substr(-4)){var i,s=e,a=t,s=(null!=aryval(n,"key")&&(s=n.key),null!=aryval(n,"enc")&&(hEnc=n.enc),I.enc.Hex.parse(s)),a=I.enc.Hex.parse(a),n=I.enc.Hex.parse(n.iv);if("des-EDE3-CBC"==r)i=I.TripleDES.encrypt(a,s,{iv:n});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);i=I.AES.encrypt(a,s,{iv:n})}return i+""}if(e instanceof RSAKey&&e.isPublic){a=P.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===a)return e.encrypt(t);if("RSAOAEP"===a)return e.encryptOAEP(t,"sha1");s=a.match(/^RSAOAEP(\d+)$/);if(null!==s)return e.encryptOAEP(t,"sha"+s[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},P.crypto.Cipher.decrypt=function(t,e,r,n){if("string"==typeof(r=null!=aryval(n,"enclag")?n.encalg:r)&&"-CBC"==r.substr(-4)){var i,s=e,a=t,s=(null!=aryval(n,"key")&&(s=n.key),null!=aryval(n,"enc")&&(a=n.enc),I.enc.Hex.parse(s)),a=I.enc.Hex.parse(a),n=I.enc.Hex.parse(n.iv);if("des-EDE3-CBC"==r)i=I.TripleDES.decrypt({ciphertext:a},s,{iv:n});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);i=I.AES.decrypt({ciphertext:a},s,{iv:n})}return I.enc.Hex.stringify(i)}if(e instanceof RSAKey&&e.isPrivate){a=P.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===a)return e.decrypt(t);if("RSAOAEP"===a)return e.decryptOAEP(t,"sha1");s=a.match(/^RSAOAEP(\d+)$/);if(null!==s)return e.decryptOAEP(t,"sha"+s[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},P.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof RSAKey){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},P.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==(P=void 0!==P&&P?P:{}).crypto&&P.crypto||(P.crypto={}),P.crypto.ECDSA=function(t){var i=Error,h=BigInteger,u=ECPointFp,c=P.crypto.ECDSA,e=P.crypto.ECParameterDB,s=c.getName,a=E.getVbyListEx,o=E.isASN1HEX,r=new SecureRandom;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new h(t.bitLength(),r).mod(t.subtract(h.ONE)).add(h.ONE)},this.setNamedCurve=function(t){this.ecparams=e.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,t=this.getBigRandom(t),e=this.ecparams.keycharlen,t=("0000000000"+t.toString(16)).slice(-e);return this.setPrivateKeyHex(t),{ecprvhex:t,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new h(this.prvKeyHex,16),t=this.ecparams.G.multiply(t),e=t.getX().toBigInteger(),t=t.getY().toBigInteger(),r=this.ecparams.keycharlen,e="04"+("0000000000"+e.toString(16)).slice(-r)+("0000000000"+t.toString(16)).slice(-r);return this.setPublicKeyHex(e),e},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var e=new h(e,16),r=this.ecparams.n,t=new h(t.substring(0,this.ecparams.keycharlen),16);do{var n=this.getBigRandom(r),i=this.ecparams.G.multiply(n).getX().toBigInteger().mod(r)}while(i.compareTo(h.ZERO)<=0);t=n.modInverse(r).multiply(t.add(e.multiply(i))).mod(r);return c.biRSSigToASN1Sig(i,t)},this.sign=function(t,e){var r=this.ecparams.n,t=h.fromByteArrayUnsigned(t);do{var n=this.getBigRandom(r),i=this.ecparams.G.multiply(n).getX().toBigInteger().mod(r)}while(i.compareTo(BigInteger.ZERO)<=0);t=n.modInverse(r).multiply(t.add(e.multiply(i))).mod(r);return this.serializeSig(i,t)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,r){try{var n=c.parseSigHex(e),i=n.r,s=n.s,a=u.decodeFromHex(this.ecparams.curve,r),o=new h(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(o,i,s,a)}catch(t){return!1}},this.verify=function(t,e,r){var n;if(Bitcoin.Util.isArray(e))var i=this.parseSig(e),s=i.r,i=i.s;else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,i=e.s}if(r instanceof ECPointFp)n=r;else{if(!Bitcoin.Util.isArray(r))throw"Invalid format for pubkey value, must be byte array or ECPointFp";n=u.decodeFrom(this.ecparams.curve,r)}e=h.fromByteArrayUnsigned(t);return this.verifyRaw(e,s,i,n)},this.verifyRaw=function(t,e,r,n){var i=this.ecparams.n,s=this.ecparams.G;return!(e.compareTo(h.ONE)<0||0<=e.compareTo(i)||r.compareTo(h.ONE)<0||0<=r.compareTo(i))&&(r=r.modInverse(i),t=t.multiply(r).mod(i),r=e.multiply(r).mod(i),s.multiply(t).add(n.multiply(r)).getX().toBigInteger().mod(i).equals(e))},this.serializeSig=function(t,e){var t=t.toByteArraySigned(),e=e.toByteArraySigned(),r=[];return r.push(2),r.push(t.length),(r=r.concat(t)).push(2),r.push(e.length),(r=r.concat(e)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if((e=2)!=t[2])throw new Error("First element in signature must be a DERInteger");var r=t.slice(4,4+t[3]);if(2!=t[e+=2+t[3]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return t[e+1],{r:h.fromByteArrayUnsigned(r),s:h.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||7<e)throw"Invalid signature type";var r=this.ecparams.n;return{r:h.fromByteArrayUnsigned(t.slice(1,33)).mod(r),s:h.fromByteArrayUnsigned(t.slice(33,65)).mod(r),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===o(t))throw new Error("not ASN.1 hex string");var e,r,n;try{e=a(t,0,["[0]",0],"06"),r=a(t,0,[1],"04");try{n=a(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===o(t))throw new i("not ASN.1 hex string");var e,r,n;try{a(t,0,[1,0],"06"),e=a(t,0,[1,1],"06"),r=a(t,0,[2,0,1],"04");try{n=a(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new i("malformed PKCS#8 plain ECC private key")}if(this.curveName=s(e),void 0===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===o(t))throw new i("not ASN.1 hex string");var e,r;try{a(t,0,[0,0],"06"),e=a(t,0,[0,1],"06"),r=a(t,0,[1],"03")}catch(t){throw new i("malformed PKCS#8 ECC public key")}if(this.curveName=s(e),null===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(r)},this.readCertPubKeyHex=function(t,e){if(!1===o(t))throw new i("not ASN.1 hex string");var r,n;try{r=a(t,0,[0,5,0,1],"06"),n=a(t,0,[0,5,1],"03")}catch(t){throw new i("malformed X.509 certificate ECC public key")}if(this.curveName=s(r),null===this.curveName)throw new i("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub)&&this.setPublicKeyHex(t.pub)},P.crypto.ECDSA.parseSigHex=function(t){t=P.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new BigInteger(t.r,16),s:new BigInteger(t.s,16)}},P.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=E,r=e.getChildIdx,n=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");e=r(t,0);if(2!=e.length)throw new Error("signature shall have two elements");r=e[0],e=e[1];if("02"!=t.substr(r,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(e,2))throw new Error("2nd item not ASN.1 integer");return{r:n(t,r),s:n(t,e)}},P.crypto.ECDSA.asn1SigToConcatSig=function(t){var t=P.crypto.ECDSA.parseSigHexInHexRS(t),e=t.r,t=t.s;if(130<=e.length&&e.length<=134){if(e.length%2!=0)throw Error("unknown ECDSA sig r length error");if(t.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==e.substr(0,2)&&(e=e.substr(2)),"00"==t.substr(0,2)&&(t=t.substr(2));var r=Math.max(e.length,t.length);return(e=("000000"+e).slice(-r))+(t=("000000"+t).slice(-r))}if("00"==e.substr(0,2)&&e.length%32==2&&(e=e.substr(2)),"00"==t.substr(0,2)&&t.length%32==2&&(t=t.substr(2)),e.length%32==30&&(e="00"+e),t.length%32==30&&(t="00"+t),e.length%32!=0)throw Error("unknown ECDSA sig r length error");if(t.length%32!=0)throw Error("unknown ECDSA sig s length error");return e+t},P.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),t=t.substr(t.length/2);return P.crypto.ECDSA.hexRSSigToASN1Sig(e,t)},P.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){t=new BigInteger(t,16),e=new BigInteger(e,16);return P.crypto.ECDSA.biRSSigToASN1Sig(t,e)},P.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=P.asn1,t=new r.DERInteger({bigint:t}),e=new r.DERInteger({bigint:e});return new r.DERSequence({array:[t,e]}).tohex()},P.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==(P=void 0!==P&&P?P:{}).crypto&&P.crypto||(P.crypto={}),P.crypto.ECParameterDB=new function(){var p={},d={};function a(t){return new BigInteger(t,16)}this.getByName=function(t){var e=t;if(void 0!==d[e]&&(e=d[t]),void 0!==p[e])return p[e];throw"unregistered EC curve name: "+e},this.regist=function(t,e,r,n,i,s,o,h,u,c,l,f){p[t]={};r=a(r),n=a(n),i=a(i),s=a(s),o=a(o),r=new ECCurveFp(r,n,i),n=r.decodePointHex("04"+h+u);p[t].name=t,p[t].keylen=e,p[t].keycharlen=2*Math.ceil(e/8),p[t].curve=r,p[t].G=n,p[t].n=s,p[t].h=o,p[t].oid=l,p[t].info=f;for(var g=0;g<c.length;g++)d[c[g]]=t}},P.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),P.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),P.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),P.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),P.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),P.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),P.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),P.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),P.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),P.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==(P=void 0!==P&&P?P:{}).crypto&&P.crypto||(P.crypto={}),P.crypto.DSA=function(){E.getVbyList;var a=E.getVbyListEx,o=E.isASN1HEX,e=BigInteger;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,n,i){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=n,this.x=i},this.setPrivateHex=function(t,e,r,n,i){t=new BigInteger(t,16),e=new BigInteger(e,16),r=new BigInteger(r,16),n="string"==typeof n&&1<n.length?new BigInteger(n,16):null,i=new BigInteger(i,16);this.setPrivate(t,e,r,n,i)},this.setPublic=function(t,e,r,n){this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=n,this.x=null},this.setPublicHex=function(t,e,r,n){t=new BigInteger(t,16),e=new BigInteger(e,16),r=new BigInteger(r,16),n=new BigInteger(n,16);this.setPublic(t,e,r,n)},this.signWithMessageHash=function(t){var e=this.p,r=this.q,n=this.g,i=(this.y,this.x),s=P.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),r.subtract(BigInteger.ONE)),t=new BigInteger(t.substr(0,r.bitLength()/4),16),n=n.modPow(s,e).mod(r),e=s.modInverse(r).multiply(t.add(i.multiply(n))).mod(r);return P.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:n}},{int:{bigint:e}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,n=this.q,i=this.g,s=this.y,e=this.parseASN1Signature(e),a=e[0],e=e[1],t=new BigInteger(t.substr(0,n.bitLength()/4),16);if(0<BigInteger.ZERO.compareTo(a)||0<a.compareTo(n))throw"invalid DSA signature";if(0<=BigInteger.ZERO.compareTo(e)||0<e.compareTo(n))throw"invalid DSA signature";e=e.modInverse(n),t=t.multiply(e).mod(n),e=a.multiply(e).mod(n);return 0==i.modPow(t,r).multiply(s.modPow(e,r)).mod(r).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new e(a(t,0,[0],"02"),16),new e(a(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var e,r,n,i,s;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[1],"02"),r=a(t,0,[2],"02"),n=a(t,0,[3],"02"),i=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(e,r,n,i,s)},this.readPKCS8PrvKeyHex=function(t){var e,r,n,i;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[1,1,0],"02"),r=a(t,0,[1,1,1],"02"),n=a(t,0,[1,1,2],"02"),i=a(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(e,r,n,null,i)},this.readPKCS8PubKeyHex=function(t){var e,r,n,i;if(!1===o(t))throw new Error("not ASN.1 hex string");try{e=a(t,0,[0,1,0],"02"),r=a(t,0,[0,1,1],"02"),n=a(t,0,[0,1,2],"02"),i=a(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(e,r,n,i)},this.readCertPubKeyHex=function(t,e){var r,n,i,s;if(!1===o(t))throw new Error("not ASN.1 hex string");try{r=a(t,0,[0,5,0,1,0],"02"),n=a(t,0,[0,5,0,1,1],"02"),i=a(t,0,[0,5,0,1,2],"02"),s=a(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(r,n,i,s)}};var b=function(){function K5a(t,e,r){return N5a(I.AES,t,e,r)}function N5a(t,e,r,n){var e=I.enc.Hex.parse(e),r=I.enc.Hex.parse(r),n=I.enc.Hex.parse(n),i={},e=(i.key=r,i.iv=n,i.ciphertext=e,t.decrypt(i,r,{iv:n}));return I.enc.Hex.stringify(e)}function O5a(t,e,r){return R5a(I.AES,t,e,r)}function R5a(t,e,r,n){return e=I.enc.Hex.parse(e),r=I.enc.Hex.parse(r),n=I.enc.Hex.parse(n),t=t.encrypt(e,r,{iv:n}),e=I.enc.Hex.parse(t.toString()),I.enc.Base64.stringify(e)}function V5a(t){var e={};(r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m")))&&(e.cipher=r[1],e.ivsalt=r[2]);(r=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----")))&&(e.type=r[1]);var r=-1,n=0,i=(-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),n=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),n=1),t.indexOf("-----END"));return-1!=r&&-1!=i&&(t=(t=t.substring(r+2*n,i-n)).replace(/\s+/g,""),e.data=t),e}function W5a(t,e,r){for(var r=r.substring(0,16),n=I.enc.Hex.parse(r),i=I.enc.Utf8.parse(e),s=u[t].keylen+u[t].ivlen,a="",o=null;;){var h=I.algo.MD5.create();if(null!=o&&h.update(o),h.update(i),h.update(n),o=h.finalize(),(a+=I.enc.Hex.stringify(o)).length>=2*s)break}return(r={}).keyhex=a.substr(0,2*u[t].keylen),r.ivhex=a.substr(2*u[t].keylen,2*u[t].ivlen),r}function X5a(t,e,r,n){return t=I.enc.Base64.parse(t),t=I.enc.Hex.stringify(t),(0,u[e].proc)(t,r,n)}var u={"AES-256-CBC":{proc:K5a,eproc:O5a,keylen:32,ivlen:16},"AES-192-CBC":{proc:K5a,eproc:O5a,keylen:24,ivlen:16},"AES-128-CBC":{proc:K5a,eproc:O5a,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,r){return N5a(I.TripleDES,t,e,r)},eproc:function(t,e,r){return R5a(I.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,r){return N5a(I.DES,t,e,r)},eproc:function(t,e,r){return R5a(I.DES,t,e,r)},keylen:8,ivlen:8}};return{version:"1.0.0",parsePKCS5PEM:function(t){return V5a(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return W5a(t,e,r)},decryptKeyB64:function(t,e,r,n){return X5a(t,e,r,n)},getDecryptedKeyHex:function(t,e){var t=V5a(t),r=(t.type,t.cipher),n=t.ivsalt,t=t.data,e=W5a(r,e,n).keyhex;return X5a(t,r,e,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,i){if(void 0===u[n=void 0!==n&&null!=n?n:"AES-256-CBC"])throw new Error("KEYUTIL unsupported algorithm: "+n);var s="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return(s+="Proc-Type: 4,ENCRYPTED\r\n")+("DEK-Info: "+n+","+(i=void 0!==i&&null!=i?i:function(t){t=I.lib.WordArray.random(t);return I.enc.Hex.stringify(t)}(u[n].ivlen).toUpperCase())+"\r\n")+"\r\n"+function(t,e,r,n){return(0,u[e].eproc)(t,r,n)}(e,n,W5a(n,r,i).keyhex,i).replace(/(.{64})/g,"$1\r\n")+("\r\n-----END "+t+" PRIVATE KEY-----\r\n")},getEncryptedPKCS8PEM:function(t,e,r){return hextopem(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){r=null==r?{}:JSON.parse(JSON.stringify(r)),r.plain=t,this.initPBES2Param(r),this.encryptPBES2Param(r,e),t=this.generatePBES2ASN1Param(r);return P.asn1.ASN1Util.newObject(t).tohex()},initPBES2Param:function(t){var e;null==aryval(t,"encalg")&&(t.encalg="aes256-CBC"),null==aryval(t,"iter")&&(t.iter=2048),null==aryval(t,"prf")&&(t.prf="hmacWithSHA256"),null==aryval(t,"salt")&&(t.salt=I.enc.Hex.stringify(I.lib.WordArray.random(8))),null==aryval(t,"enciv")&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=I.enc.Hex.stringify(I.lib.WordArray.random(e)))},encryptPBES2Param:function(e,r){r=b.getDKFromPBES2Param(e,r);try{var t=P.crypto.Cipher.encrypt(e.plain,r,e.encalg,{iv:e.enciv})}catch(t){throw new Error("encrypt error: "+e.plain+" "+r+" "+e.encalg+" "+e.enciv)}e.enc=t},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:inttohex(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=E.getChildIdx,r=E.getV,n={},i=e(t,0);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+i.length);n.ciphertext=r(t,i[1]);i=e(t,i[0]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+i.length);if("2a864886f70d01050d"!=r(t,i[0]))throw new Error("this only supports pkcs5PBES2");var s=e(t,i[1]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+s.length);i=e(t,s[1]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+i.length);if("2a864886f70d0307"!=r(t,i[0]))throw"this only supports TripleDES";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=r(t,i[1]);i=e(t,s[0]);if(2!=i.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+i.length);if("2a864886f70d01050c"!=r(t,i[0]))throw new Error("this only supports pkcs5PBKDF2");s=e(t,i[1]);if(s.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+s.length);n.pbkdf2Salt=r(t,s[0]);e=r(t,s[1]);try{n.pbkdf2Iter=parseInt(e,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+e)}return n},getPBKDF2KeyHexFromParam:function(t,e){var r=I.enc.Hex.parse(t.pbkdf2Salt),t=t.pbkdf2Iter,e=I.PBKDF2(e,r,{keySize:6,iterations:t});return I.enc.Hex.stringify(e)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var t=pemtohex(t,"ENCRYPTED PRIVATE KEY"),t=this.parseHexOfEncryptedPKCS8(t),e=b.getPBKDF2KeyHexFromParam(t,e),r={},e=(r.ciphertext=I.enc.Hex.parse(t.ciphertext),I.enc.Hex.parse(e)),t=I.enc.Hex.parse(t.encryptionSchemeIV),r=I.TripleDES.decrypt(r,e,{iv:t});return I.enc.Hex.stringify(r)},parsePBES2:function(t){t=E.parse(t);if("pkcs5PBES2"!=aryval(t,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=aryval(t,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var e=aryval(t,"seq.0.seq.1.seq.0.seq.1.seq");if(null==e)throw new Error("PBKDF2 parameter not found");var r=aryval(e,"0.octstr.hex"),n=aryval(e,"1.int.hex"),e=aryval(e,"2.seq.0.oid","hmacWithSHA1"),i=-1;try{i=parseInt(n,16)}catch(t){throw new Error("iter not proper value")}var n=aryval(t,"seq.0.seq.1.seq.1.seq.0.oid"),s=aryval(t,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),t=aryval(t,"seq.1.octstr.hex");if(null==n||null==s||null==t)throw new Error("encalg, enciv or enc is undefined");return{salt:r,iter:i,prf:e,encalg:n,enciv:s,enc:t}},getDKFromPBES2Param:function(e,r){var t={hmacWithSHA1:I.algo.SHA1,hmacWithSHA224:I.algo.SHA224,hmacWithSHA256:I.algo.SHA256,hmacWithSHA384:I.algo.SHA384,hmacWithSHA512:I.algo.SHA512}[e.prf];if(null==t)throw new Error("unsupported prf");var n={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[e.encalg];if(null==n)throw new Error("unsupported encalg");var i=I.enc.Hex.parse(e.salt),s=e.iter;try{var a=I.PBKDF2(r,i,{keySize:n,iterations:s,hasher:t});return I.enc.Hex.stringify(a)}catch(t){throw new Error("PBKDF2 error: "+t+" "+JSON.stringify(e)+" "+r)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,t=pemtohex(t);try{r=b.parsePBES2(t)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}t=b.getDKFromPBES2Param(r,e);return P.crypto.Cipher.decrypt(r.enc,t,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){t=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(t)},parsePlainPrivatePKCS8Hex:function(t){var e=E,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");r=r(t,s[1]);if(2!=r.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(r[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,r[0]),"06"==t.substr(r[1],2)&&(i.algparam=n(t,r[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){t=pemtohex(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new RSAKey;else if("2a8648ce380401"==r.algoid)e=new P.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new P.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=E.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new RSAKey;else if("2a8648ce380401"===r)e=new P.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new P.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=E.getChildIdx,r=E.getV,n={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");e=e(t,0);if(2!=e.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(e[0],2))throw new Error("malformed RSA key(code:003)");if(n.n=r(t,e[0]),"02"!=t.substr(e[1],2))throw new Error("malformed RSA key(code:004)");return n.e=r(t,e[1]),n},parsePublicPKCS8Hex:function(t){var e=E,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var a=s[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");r=r(t,a);if(2!=r.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(r[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=n(t,r[0]),"06"==t.substr(r[1],2)?i.algparam=n(t,r[1]):"30"==t.substr(r[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,r[1],[0],"02"),i.algparam.q=e.getVbyList(t,r[1],[1],"02"),i.algparam.g=e.getVbyList(t,r[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=n(t,s[1]).substr(2),i}}}();b.getKey=function(t,e,r){var n,i,s,a,o,h,u=E.getChildIdx,c=(E.getV,E.getVbyList),l=P.crypto,f=l.ECDSA,l=l.DSA,g=RSAKey,p=pemtohex,d=b;if(void 0!==g&&t instanceof g)return t;if(void 0!==f&&t instanceof f)return t;if(void 0!==l&&t instanceof l)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new f({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new f({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(S=new g).setPublic(t.n,t.e),S;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(S=new g).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),S;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(S=new g).setPrivate(t.n,t.e,t.d),S;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(S=new l).setPublic(t.p,t.q,t.g,t.y),S;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(S=new l).setPrivate(t.p,t.q,t.g,t.y,t.x),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(S=new g).setPublic(b64utohex(t.n),b64utohex(t.e)),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(S=new g).setPrivateEx(b64utohex(t.n),b64utohex(t.e),b64utohex(t.d),b64utohex(t.p),b64utohex(t.q),b64utohex(t.dp),b64utohex(t.dq),b64utohex(t.qi)),S;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(S=new g).setPrivate(b64utohex(t.n),b64utohex(t.e),b64utohex(t.d)),S;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d)return y=(v=new f({curve:t.crv})).ecparams.keycharlen,m="04"+("0000000000"+b64utohex(t.x)).slice(-y)+("0000000000"+b64utohex(t.y)).slice(-y),v.setPublicKeyHex(m),v;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d)return y=(v=new f({curve:t.crv})).ecparams.keycharlen,m="04"+("0000000000"+b64utohex(t.x)).slice(-y)+("0000000000"+b64utohex(t.y)).slice(-y),y=("0000000000"+b64utohex(t.d)).slice(-y),v.setPublicKeyHex(m),v.setPrivateKeyHex(y),v;if("pkcs5prv"===r){var m=t,y=u(m,0);if(9===y.length)(S=new g).readPKCS5PrvKeyHex(m);else if(6===y.length)(S=new l).readPKCS5PrvKeyHex(m);else{if(!(2<y.length&&"04"===m.substr(y[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(S=new f).readPKCS5PrvKeyHex(m)}return S}if("pkcs8prv"===r)return S=d.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return d._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return X509.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return X509.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-"))return u=pemtohex(t,"PUBLIC KEY"),d._getKeyFromPublicPKCS8Hex(u);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return n=p(t,"RSA PRIVATE KEY"),d.getKey(n,null,"pkcs5prv");if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return i=c(x=p(t,"DSA PRIVATE KEY"),0,[1],"02"),s=c(x,0,[2],"02"),a=c(x,0,[3],"02"),o=c(x,0,[4],"02"),h=c(x,0,[5],"02"),(S=new l).setPrivate(new BigInteger(i,16),new BigInteger(s,16),new BigInteger(a,16),new BigInteger(o,16),new BigInteger(h,16)),S;if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return n=p(t,"EC PRIVATE KEY"),d.getKey(n,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return d.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return g=d.getDecryptedKeyHex(t,e),(y=new RSAKey).readPKCS5PrvKeyHex(g),y;if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var x,v,S=c(x=d.getDecryptedKeyHex(t,e),0,[1],"04"),m=c(x,0,[2,0],"06"),r=c(x,0,[3,0],"03").substr(2);if(void 0===P.crypto.OID.oidhex2name[m])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+m);return(v=new f({curve:P.crypto.OID.oidhex2name[m]})).setPublicKeyHex(r),v.setPrivateKeyHex(S),v.isPublic=!1,v}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return i=c(x=d.getDecryptedKeyHex(t,e),0,[1],"02"),s=c(x,0,[2],"02"),a=c(x,0,[3],"02"),o=c(x,0,[4],"02"),h=c(x,0,[5],"02"),(S=new l).setPrivate(new BigInteger(i,16),new BigInteger(s,16),new BigInteger(a,16),new BigInteger(o,16),new BigInteger(h,16)),S;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return d.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},b.generateKeypair=function(t,e){var r,n,i,s;if("RSA"==t)return i=e,(n=new RSAKey).generate(i,"10001"),n.isPrivate=!0,n.isPublic=!0,i=new RSAKey,s=n.n.toString(16),r=n.e.toString(16),i.setPublic(s,r),i.isPrivate=!1,i.isPublic=!0,(s={}).prvKeyObj=n,s.pubKeyObj=i,s;if("EC"==t)return e=new P.crypto.ECDSA({curve:r=e}).generateKeyPairHex(),(n=new P.crypto.ECDSA({curve:r})).setPublicKeyHex(e.ecpubhex),n.setPrivateKeyHex(e.ecprvhex),n.isPrivate=!0,n.isPublic=!1,(i=new P.crypto.ECDSA({curve:r})).setPublicKeyHex(e.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(s={}).prvKeyObj=n,s.pubKeyObj=i,s;throw new Error("unknown algorithm: "+t)},b.getPEM=function(t,e,r,n,i,s){var a,o=P,h=o.asn1,u=h.DERObjectIdentifier,c=h.DERInteger,l=h.ASN1Util.newObject,h=h.x509.SubjectPublicKeyInfo,o=o.crypto,f=o.DSA,o=o.ECDSA,g=RSAKey;function z(t){return l({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function A(t){return l({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function w(t){return l({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((t instanceof g||void 0!==f&&t instanceof f||void 0!==o&&t instanceof o)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return hextopem(d=new h(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate)return hextopem(d=z(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==o&&t instanceof o&&(void 0===r||null==r)&&1==t.isPrivate)return h=new u({name:t.curveName}).tohex(),u=A(t).tohex(),a="",(a+=hextopem(h,"EC PARAMETERS"))+hextopem(u,"EC PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==f&&t instanceof f&&(void 0===r||null==r)&&1==t.isPrivate)return hextopem(d=w(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return d=z(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",d,r,n=void 0===n?"DES-EDE3-CBC":n,s);if("PKCS5PRV"==e&&void 0!==o&&t instanceof o&&void 0!==r&&null!=r&&1==t.isPrivate)return d=A(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",d,r,n=void 0===n?"DES-EDE3-CBC":n,s);if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate)return d=w(t).tohex(),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",d,r,n=void 0===n?"DES-EDE3-CBC":n,s);function k8a(t,e){var r;return"string"==typeof e?b.getEncryptedPKCS8PEM(t,e):"object"==typeof e&&null!=aryval(e,"passcode")?(r=(e=JSON.parse(JSON.stringify(e))).passcode,delete e.passcode,b.getEncryptedPKCS8PEM(t,r,e)):void 0}var p,d;if("PKCS8PRV"==e&&null!=g&&t instanceof g&&1==t.isPrivate)return p=z(t).tohex(),d=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:p}}]}).tohex(),void 0===r||null==r?hextopem(d,"PRIVATE KEY"):k8a(d,r);if("PKCS8PRV"==e&&void 0!==o&&t instanceof o&&1==t.isPrivate)return h={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]},"string"==typeof t.pubKeyHex&&h.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),p=new l(h).tohex(),d=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:p}}]}).tohex(),void 0===r||null==r?hextopem(d,"PRIVATE KEY"):k8a(d,r);if("PKCS8PRV"==e&&void 0!==f&&t instanceof f&&1==t.isPrivate)return p=new c({bigint:t.x}).tohex(),d=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:p}}]}).tohex(),void 0===r||null==r?hextopem(d,"PRIVATE KEY"):k8a(d,r);throw new Error("unsupported object nor format")},b.getKeyFromCSRPEM=function(t){t=pemtohex(t,"CERTIFICATE REQUEST");return b.getKeyFromCSRHex(t)},b.getKeyFromCSRHex=function(t){t=b.parseCSRHex(t);return b.getKey(t.p8pubkeyhex,null,"pkcs8pub")},b.parseCSRHex=function(t){var e=E.getChildIdx,r=E.getTLV,n={};if("30"!=t.substr(0,2))throw new Error("malformed CSR(code:001)");var i=e(t,0);if(i.length<1)throw new Error("malformed CSR(code:002)");if("30"!=t.substr(i[0],2))throw new Error("malformed CSR(code:003)");e=e(t,i[0]);if(e.length<3)throw new Error("malformed CSR(code:004)");return n.p8pubkeyhex=r(t,e[2]),n},b.getKeyID=function(t){var e=b,r=E,e=("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t)),pemtohex(e.getPEM(t))),t=r.getIdxbyList(e,0,[1]),r=r.getV(e,t).substring(2);return P.crypto.Util.hashHex(r,"sha1")},b.getJWK=function(t,e,r,n,i){var s,a,o,h={},u=P.crypto.Util.hashHex;if("string"==typeof t)s=b.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=pemtohex(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof X509?(s=t.getPublicKey(),a=t.hex):s=t}if(s instanceof RSAKey&&s.isPrivate)h.kty="RSA",h.n=hextob64u(s.n.toString(16)),h.e=hextob64u(s.e.toString(16)),h.d=hextob64u(s.d.toString(16)),h.p=hextob64u(s.p.toString(16)),h.q=hextob64u(s.q.toString(16)),h.dp=hextob64u(s.dmp1.toString(16)),h.dq=hextob64u(s.dmq1.toString(16)),h.qi=hextob64u(s.coeff.toString(16));else if(s instanceof RSAKey&&s.isPublic)h.kty="RSA",h.n=hextob64u(s.n.toString(16)),h.e=hextob64u(s.e.toString(16));else if(s instanceof P.crypto.ECDSA&&s.isPrivate){if("P-256"!==(o=s.getShortNISTPCurveName())&&"P-384"!==o&&"P-521"!==o)throw new Error("unsupported curve name for JWT: "+o);var c=s.getPublicKeyXYHex();h.kty="EC",h.crv=o,h.x=hextob64u(c.x),h.y=hextob64u(c.y),h.d=hextob64u(s.prvKeyHex)}else if(s instanceof P.crypto.ECDSA&&s.isPublic){if("P-256"!==(o=s.getShortNISTPCurveName())&&"P-384"!==o&&"P-521"!==o)throw new Error("unsupported curve name for JWT: "+o);c=s.getPublicKeyXYHex();h.kty="EC",h.crv=o,h.x=hextob64u(c.x),h.y=hextob64u(c.y)}if(null==h.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(h.kid=P.jws.JWS.getJWKthumbprint(h)),null!=a&&1!=r&&(h.x5c=[hex2b64(a)]),null!=a&&1!=n&&(h.x5t=b64tob64u(hex2b64(u(a,"sha1")))),null!=a&&1!=i&&(h["x5t#S256"]=b64tob64u(hex2b64(u(a,"sha256")))),h},b.getJWKFromKey=function(t){return b.getJWK(t,!0,!0,!0,!0)},RSAKey.getPosArrayOfChildrenFromHex=function(t){return E.getChildIdx(t,0)},RSAKey.getHexValueArrayOfChildrenFromHex=function(t){var e=E.getV,r=RSAKey.getPosArrayOfChildrenFromHex(t),n=e(t,r[0]),i=e(t,r[1]),s=e(t,r[2]),a=e(t,r[3]),o=e(t,r[4]),h=e(t,r[5]),u=e(t,r[6]),c=e(t,r[7]),e=e(t,r[8]);return(r=new Array).push(n,i,s,a,o,h,u,c,e),r},RSAKey.prototype.readPrivateKeyFromPEMString=function(t){t=pemtohex(t),t=RSAKey.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},RSAKey.prototype.readPKCS5PrvKeyHex=function(t){t=RSAKey.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},RSAKey.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,a,o,h,u=E,c=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,a,o,h)},RSAKey.prototype.readPKCS5PubKeyHex=function(t){var e=E,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");e=e.getChildIdx(t,0);if(2!==e.length||"02"!==t.substr(e[0],2)||"02"!==t.substr(e[1],2))throw new Error("wrong hex for PKCS#5 public key");var n=r(t,e[0]),r=r(t,e[1]);this.setPublic(n,r)},RSAKey.prototype.readPKCS8PubKeyHex=function(t){var e=E;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");e=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(e)},RSAKey.prototype.readCertPubKeyHex=function(t,e){var r=new X509;r.readCertHex(t),t=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(t)};function _zeroPaddingOfSignature(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t}function pss_mgf1_str(t,e,r){for(var n="",i=0;n.length<e;)n+=hextorstr(r(rstrtohex(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(t){for(var e in P.crypto.Util.DIGESTINFOHEAD){var r=P.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function X509(t){var r,o=E,l=o.getChildIdx,h=o.getV,u=(o.dump,o.parse),f=o.getTLV,c=o.getVbyList,g=o.getVbyListEx,i=o.getTLVbyList,s=o.getTLVbyListEx,p=o.getIdxbyList,a=o.getIdxbyListEx,d=o.getVidx,n=o.getInt,m=o.oidname,y=o.hextooidstr,e=pemtohex,x=Error;try{r=P.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null!==this.hex&&0===this.version){var t=i(this.hex,0,[0,0]);if("a0"!=t.substr(0,2))return this.version=1,this.foffset=-1,1;t=i(t,0,[0]),t=n(t,0);if(t<0||2<t)throw new Error("malformed version field");this.version=t+1}return this.version},this.getSerialNumberHex=function(){return g(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=s(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var e in r)if(t===r[e])return e;return m(g(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return i(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},this.getSubjectHex=function(){return i(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=(t=c(this.hex,0,[0,4+this.foffset,0])).replace(/(..)/g,"%$1");return t=decodeURIComponent(t)},this.getNotAfter=function(){var t=(t=c(this.hex,0,[0,4+this.foffset,1])).replace(/(..)/g,"%$1");return t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return i(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:c(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return p(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return p(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return b.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=i(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return c(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=i(this.hex,0,[0],"30"),e=new P.crypto.Signature({alg:e});return e.init(t),e.updateHex(n),e.verify(r)},this.parseExt=function(t){var e,r;if(void 0===t){if(n=this.hex,3!==this.version)return-1;e=p(n,0,[0,7,0],"30"),r=l(n,e)}else{var n=pemtohex(t),t=p(n,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=h(n,t))return void(this.aExtInfo=new Array);e=p(n,0,[0,3,0,1,0],"30"),r=l(n,e),this.hex=n}this.aExtInfo=new Array;for(var i=0;i<r.length;i++){var s={critical:!1},a=0,a=(3===l(n,r[i]).length&&(s.critical=!0,a=1),s.oid=o.hextooidstr(c(n,r[i],[0],"06")),p(n,r[i],[1+a]));s.vidx=d(n,a),this.aExtInfo.push(s)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(""!==(r=t.match(/^[0-9.]+$/)?r:P.asn1.x509.OID.name2oid(t)))for(var n=0;n<e.length;n++)if(e[n].oid===r)return e[n]},this.getCriticalExtV=function(t,e,r){return null!=e?[e,r]:null==(e=this.getExtInfo(t))?[null,null]:[f(this.hex,e.vidx),e.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}r={extname:"basicConstraints"};if(e&&(r.critical=!0),"3000"===t)return r;if("30030101ff"===t)return r.cA=!0,r;if("30060101ff02"===t.substr(0,12))return e=h(t,10),e=parseInt(e,16),r.cA=!0,r.pathLen=e,r;throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){for(var n={extname:"nameConstraints"},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++){for(var a=[],o=l(t,i[s]),h=0;h<o.length;h++){var u=f(t,o[h]),u=this.getGeneralSubtree(u);a.push(u)}var c=t.substr(i[s],2);"a0"==c?n.permit=a:"a1"==c&&(n.exclude=a)}return n}},this.getGeneralSubtree=function(t){var e=l(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var n=this.getGeneralName(f(t,e[0])),i=1;i<r;i++){var s=t.substr(e[i],2),a=h(t,e[i]),a=parseInt(a,16);"80"==s&&(n.min=a),"81"==s&&(n.max=a)}return n},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t)return r={extname:"keyUsage"},e&&(r.critical=!0),r.names=this.getExtKeyUsageString(t).split(","),r},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=f(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);e="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(e=e.slice(-8)),e=""==(e=(e=10==t.length?e.slice(-16):e).replace(/0+$/,""))?"0":e},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,n=0;n<e.length;n++)"1"==e.substr(n,1)&&r.push(X509.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}r={extname:"subjectKeyIdentifier"},e&&(r.critical=!0),e=h(t,0);return r.kid={hex:e},r},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}for(var n={extname:"authorityKeyIdentifier"},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++){var a,o=t.substr(i[s],2);"80"===o&&(n.kid={hex:h(t,i[s])}),"a1"===o&&(a=f(t,i[s]),a=this.getGeneralNames(a),n.issuer=a[0].dn),"82"===o&&(n.sn={hex:h(t,i[s])})}return n},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}for(var n={extname:"extKeyUsage",array:[]},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++)n.array.push(m(h(t,i[s])));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=f(this.hex,t.vidx);if(""!==r)for(var n=l(r,0),i=0;i<n.length;i++)e.push(m(h(r,n[i])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}r={extname:"subjectAltName",array:[]};return e&&(r.critical=!0),r.array=this.getGeneralNames(t),r},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}r={extname:"issuerAltName",array:[]};return e&&(r.critical=!0),r.array=this.getGeneralNames(t),r},this.getGeneralNames=function(t){for(var e=l(t,0),r=[],n=0;n<e.length;n++){var i=this.getGeneralName(f(t,e[n]));void 0!==i&&r.push(i)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=h(t,0),n=hextorstr(r);return"81"==e?{rfc822:n}:"82"==e?{dns:n}:"86"==e?{uri:n}:"87"==e?{ip:hextoip(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,n=this.getExtInfo("subjectAltName");if(void 0===n)return n;for(var i=new Array,s=f(this.hex,n.vidx),a=l(s,0),o=0;o<a.length;o++)r=s.substr(a[o],2),t=h(s,a[o]),"81"===r&&(e=hextoutf8(t),i.push(["MAIL",e])),"82"===r&&(e=hextoutf8(t),i.push(["DNS",e])),"84"===r&&(e=X509.hex2dn(t,0),i.push(["DN",e])),"86"===r&&(e=hextoutf8(t),i.push(["URI",e])),"87"===r&&(e=hextoip(t),i.push(["IP",e]));return i},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}for(var n={extname:"cRLDistributionPoints",array:[]},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=f(t,i[s]);n.array.push(this.getDistributionPoint(a))}return n},this.getDistributionPoint=function(t){for(var e={},r=l(t,0),n=0;n<r.length;n++){var i=t.substr(r[n],2),s=f(t,r[n]);"a0"==i&&(e.dpname=this.getDistributionPointName(s))}return e},this.getDistributionPointName=function(t){for(var e={},r=l(t,0),n=0;n<r.length;n++){var i=t.substr(r[n],2),s=f(t,r[n]);"a0"==i&&(e.full=this.getGeneralNames(s))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],n=0;n<e.length;n++)try{null!=e[n].dpname.full[0].uri&&r.push(e[n].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=l(this.hex,t.vidx),n=0;n<r.length;n++){var i=c(this.hex,r[n],[0],"06"),s=c(this.hex,r[n],[1],"86");"2b06010505073001"===i&&e.ocsp.push(hextoutf8(s)),"2b06010505073002"===i&&e.caissuer.push(hextoutf8(s))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}for(var n={extname:"authorityInfoAccess",array:[]},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=g(t,i[s],[0],"06"),o=hextoutf8(c(t,i[s],[1],"86"));if("2b06010505073001"==a)n.array.push({ocsp:o});else{if("2b06010505073002"!=a)throw new Error("unknown method: "+a);n.array.push({caissuer:o})}}return n},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}for(var n={extname:"certificatePolicies",array:[]},i=(e&&(n.critical=!0),l(t,0)),s=0;s<i.length;s++){var a=f(t,i[s]),a=this.getPolicyInformation(a);n.array.push(a)}return n},this.getPolicyInformation=function(t){var e={},r=c(t,0,[0],"06"),r=(e.policyoid=m(r),a(t,0,[1],"30"));if(-1!=r){e.array=[];for(var n=l(t,r),i=0;i<n.length;i++){var s=f(t,n[i]),s=this.getPolicyQualifierInfo(s);e.array.push(s)}}return e},this.getOtherName=function(t){var e={},r=l(t,0),n=c(t,r[0],[],"06"),t=c(t,r[1],[]);return e.oid=m(n),e.value=u(t),e},this.getPolicyQualifierInfo=function(t){var e,r={},n=c(t,0,[0],"06");return"2b06010505070201"===n?(e=g(t,0,[1],"16"),r.cps=hextorstr(e)):"2b06010505070202"===n&&(e=i(t,0,[1],"30"),r.unotice=this.getUserNotice(e)),r},this.getUserNotice=function(t){try{var e=o.parse(t);return this._asn1ToUnotice(e)}catch(t){}},this._asn1ToUnotice=function(t){try{for(var e={},r=aryval(t,"seq"),n=0;n<r.length;n++){var i=this._asn1ToNoticeRef(r[n]),s=(null!=i&&(e.noticeref=i),this.asn1ToDisplayText(r[n]));null!=s&&(e.exptext=s)}if(0<Object.keys(e).length)return e}catch(t){}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=aryval(t,"seq"),n=0;n<r.length;n++){var i=this._asn1ToNoticeNum(r[n]),s=(null!=i&&(e.noticenum=i),this.asn1ToDisplayText(r[n]));null!=s&&(e.org=s)}if(0<Object.keys(e).length)return e}catch(t){}},this._asn1ToNoticeNum=function(t){try{for(var e=aryval(t,"seq"),r=[],n=0;n<e.length;n++){var i=e[n];r.push(parseInt(aryval(i,"int.hex"),16))}return r}catch(t){}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=hextorstr(h(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){r={extname:"policyMappings"};e&&(r.critical=!0);try{for(var n=u(t).seq,i=[],s=0;s<n.length;s++){var a=n[s].seq;i.push([a[0].oid,a[1].oid])}r.array=i}catch(t){throw new x("malformed policyMappings")}return r}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var n={extname:"policyConstraints"},r=(e&&(n.critical=!0),u(t));try{for(var i=r.seq,s=0;s<i.length;s++){var a=i[s].tag;0==a.explicit&&("80"==a.tag&&(n.reqexp=parseInt(a.hex,16)),"81"==a.tag)&&(n.inhibit=parseInt(a.hex,16))}}catch(t){return new x("malformed policyConstraints value")}return n}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t)return r={extname:"inhibitAnyPolicy"},e&&(r.critical=!0),-1==(e=n(t,0))?new x("wrong value"):(r.skip=e,r)},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:h(t,0)},r;throw new x("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(h(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"},e=(e&&(r.critical=!0),h(t,0));return r.hex=e,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}var n,r={extname:"adobeTimeStamp"},e=(e&&(r.critical=!0),l(t,0));return 1<e.length&&(n=f(t,e[1]),null!=(n=this.getGeneralName(n)).uri)&&(r.uri=n.uri),2<e.length&&("0101ff"==(n=f(t,e[2]))&&(r.reqauth=!0),"010100"==n)&&(r.reqauth=!1),r},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=f(this.hex,r.vidx),e=r.critical}r={extname:"subjectDirectoryAttributes"};e&&(r.critical=!0);try{for(var n=u(t),i=[],s=0;s<n.seq.length;s++){var a=n.seq[s],o=aryval(a,"seq.0.oid"),h=aryval(a,"seq.1.set");if(null==o||null==h)throw"error";i.push({attr:o,array:h})}return r.array=i,r}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};function rla(t){var e={};try{var r=t.seq[0].oid,n=P.asn1.x509.OID.name2oid(r),i=(e.type=P.asn1.x509.OID.oid2atype(n),t.seq[1]);if(null!=i.utf8str)e.ds="utf8",e.value=i.utf8str.str;else if(null!=i.numstr)e.ds="num",e.value=i.numstr.str;else if(null!=i.telstr)e.ds="tel",e.value=i.telstr.str;else if(null!=i.prnstr)e.ds="prn",e.value=i.prnstr.str;else if(null!=i.ia5str)e.ds="ia5",e.value=i.ia5str.str;else if(null!=i.visstr)e.ds="vis",e.value=i.visstr.str;else{if(null==i.bmpstr)throw"error";e.ds="bmp",e.value=i.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}}function sla(t){try{return t.set.map(function(t){return rla(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}}this.getX500NameRule=function(t){for(var e=null,r=[],n=0;n<t.length;n++)for(var i=t[n],s=0;s<i.length;s++)r.push(i[s]);for(n=0;n<r.length;n++){var a=r[n],o=a.ds,h=a.value,a=a.type;if("prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"==a&&P.lang.String.isMail(h))continue;return"mixed"}if("C"==a){if("prn"==o)continue;return"mixed"}if(null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){t=u(t);return rla(t)},this.getRDN=function(t){t=u(t);return sla(t)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return sla(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(u(t))},this.getX500Name=function(t,e,r){var n=this.getX500NameArray(t),i={str:this.dnarraytostr(n)};return i.array=n,1==r&&(i.hex=t),1==e&&(i.canon=this.c14nRDNArray(n)),i},this.readCertPEM=function(t){this.readCertHex(e(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{p(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=hextopem(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&0<this.aExtInfo.length&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=i(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=a(this.hex,0,[0,"[3]"])&&(t=s(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=l(t,0),n=0;n<r.length;n++){var i=f(t,r[n]),i=this.getExtParam(i);null!=i&&e.push(i)}return e},this.getExtParam=function(t){var e=l(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=y(c(t,0,[0],"06")),n=!1,t=(3==e&&"0101ff"==i(t,0,[1])&&(n=!0),i(t,0,[e-1,0])),e=void 0;if("2.5.29.14"==r?e=this.getExtSubjectKeyIdentifier(t,n):"2.5.29.15"==r?e=this.getExtKeyUsage(t,n):"2.5.29.17"==r?e=this.getExtSubjectAltName(t,n):"2.5.29.18"==r?e=this.getExtIssuerAltName(t,n):"2.5.29.19"==r?e=this.getExtBasicConstraints(t,n):"2.5.29.30"==r?e=this.getExtNameConstraints(t,n):"2.5.29.31"==r?e=this.getExtCRLDistributionPoints(t,n):"2.5.29.32"==r?e=this.getExtCertificatePolicies(t,n):"2.5.29.33"==r?e=this.getExtPolicyMappings(t,n):"2.5.29.35"==r?e=this.getExtAuthorityKeyIdentifier(t,n):"2.5.29.36"==r?e=this.getExtPolicyConstraints(t,n):"2.5.29.37"==r?e=this.getExtExtKeyUsage(t,n):"2.5.29.54"==r?e=this.getExtInhibitAnyPolicy(t,n):"1.3.6.1.5.5.7.1.1"==r?e=this.getExtAuthorityInfoAccess(t,n):"2.5.29.20"==r?e=this.getExtCRLNumber(t,n):"2.5.29.21"==r?e=this.getExtCRLReason(t,n):"2.5.29.9"==r?e=this.getExtSubjectDirectoryAttributes(t,n):"1.3.6.1.5.5.7.48.1.2"==r?e=this.getExtOcspNonce(t,n):"1.3.6.1.5.5.7.48.1.5"==r?e=this.getExtOcspNoCheck(t,n):"1.2.840.113583.1.1.9.1"==r?e=this.getExtAdobeTimeStamp(t,n):null!=X509.EXT_PARSER[r]&&(e=X509.EXT_PARSER[r](r,n,t)),null!=e)return e;e={extname:r,extn:t};try{e.extn=u(t)}catch(t){}return n&&(e.critical=!0),e},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){t=this.findExt(t,"cRLDistributionPoints");if(null!=t&&null!=t.array)for(var r=t.array,n=0;n<r.length;n++)if(null!=r[n].dpname&&null!=r[n].dpname.full)for(var i=r[n].dpname.full,s=0;s<i.length;s++){var a=i[n];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){t=this.findExt(t,"authorityInfoAccess");if(null!=t&&null!=t.array)for(var r=t.array,n=0;n<r.length;n++)null!=r[n].ocsp&&(r[n].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){t=this.findExt(t,"authorityInfoAccess");if(null!=t&&null!=t.array)for(var r=t.array,n=0;n<r.length;n++)null!=r[n].caissuer&&(r[n].caissuer=e)},this.dnarraytostr=function(t){function z(t){return t.map(function(t){return function A(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")}).join("+")}return"/"+t.map(function(t){return z(t).replace(/\//,"\\/")}).join("/")},this.setCanonicalizedDN=function(t){var e;e=null!=t.str&&null==t.array?(e=new P.asn1.x509.X500Name({str:t.str}).tohex(),this.getX500NameArray(e)):t.array,null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var n=t[r],i=[],s=0;s<n.length;s++){var a=n[s],o=a.value;o=(o=(o=(o=o.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),i.push(a.type.toLowerCase()+"="+o)}e.push(i.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r="Basic Fields\n";if(r=(r=(r=(r=(r=(r=(r+=" serial number: "+this.getSerialNumberHex()+"\n")+(" signature algorithm: "+this.getSignatureAlgorithmField()+"\n"))+(" issuer: "+this.getIssuerString()+"\n"))+(" notBefore: "+this.getNotBefore()+"\n"))+(" notAfter: "+this.getNotAfter()+"\n"))+(" subject: "+this.getSubjectString()+"\n")+" subject public key info: \n")+(" key algorithm: "+(t=this.getPublicKey()).type+"\n"),"RSA"===t.type&&(r=(r+=" n="+hextoposhex(t.n.toString(16)).substr(0,16)+"...\n")+" e="+hextoposhex(t.e.toString(16))+"\n"),null!=(e=this.aExtInfo)){r+="X509v3 Extensions:\n";for(var n=0;n<e.length;n++){var i,s=e[n],a=P.asn1.x509.OID.oid2name(s.oid),o="";r+=" "+(a=""===a?s.oid:a)+" "+(o=!0===s.critical?"CRITICAL":o)+":\n","basicConstraints"===a?void 0===(s=this.getExtBasicConstraints()).cA?r+=" {}\n":(r+=" cA=true",void 0!==s.pathLen&&(r+=", pathLen="+s.pathLen),r+="\n"):"policyMappings"==a?r+=" "+this.getExtPolicyMappings().array.map(function(t){return t[0]+":"+t[1]}).join(", ")+"\n":"policyConstraints"==a?(r+=" ",null!=(i=this.getExtPolicyConstraints()).reqexp&&(r+=" reqexp="+i.reqexp),null!=i.inhibit&&(r+=" inhibit="+i.inhibit),r+="\n"):"inhibitAnyPolicy"==a?r+=" skip="+(i=this.getExtInhibitAnyPolicy()).skip+"\n":"keyUsage"==a?r+=" "+this.getExtKeyUsageString()+"\n":"subjectKeyIdentifier"==a?r+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n":"authorityKeyIdentifier"==a?void 0!==(o=this.getExtAuthorityKeyIdentifier()).kid&&(r+=" kid="+o.kid.hex+"\n"):"extKeyUsage"==a?r+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==a?r+=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];null!=i.dn&&(e+=" dn: "+i.dn.str+"\n"),null!=i.ip&&(e+=" ip: "+i.ip+"\n"),null!=i.rfc822&&(e+=" rfc822: "+i.rfc822+"\n"),null!=i.dns&&(e+=" dns: "+i.dns+"\n"),null!=i.uri&&(e+=" uri: "+i.uri+"\n"),null!=i.other&&(e+=" other: "+i.other.oid+"="+JSON.stringify(i.other.value).replace(/\"/g,"")+"\n")}return e=e.replace(/\n$/,"")}(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==a?r+=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+X509.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e}(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==a?r+=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e}(this.getExtAuthorityInfoAccess()):"certificatePolicies"==a&&(r+=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var a=i.array[s];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e}(this.getExtCertificatePolicies()))}}return r=(r+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+("signature: "+this.getSignatureValueHex().substr(0,16)+"...\n")},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):P.lang.String.isHex(t)&&this.readCertHex(t))}RSAKey.prototype.sign=function(t,e){t=function(t){return P.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(t,e)},RSAKey.prototype.signWithMessageHash=function(t,e){t=parseBigInt(P.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return _zeroPaddingOfSignature(this.doPrivate(t).toString(16),this.n.bitLength())},RSAKey.prototype.signPSS=function(t,e,r){t=function(t){return P.crypto.Util.hashHex(t,e)}(rstrtohex(t));return this.signWithMessageHashPSS(t,e,r=void 0===r?-1:r)},RSAKey.prototype.signWithMessageHashPSS=function(t,e,r){function H9a(t){return P.crypto.Util.hashHex(t,e)}var t=hextorstr(t),n=t.length,i=this.n.bitLength()-1,s=Math.ceil(i/8);if(-1===r||void 0===r)r=n;else if(-2===r)r=s-n-2;else if(r<-2)throw new Error("invalid salt length");if(s<n+r+2)throw new Error("data too long");for(var a="",o=(0<r&&(a=new Array(r),(new SecureRandom).nextBytes(a),a=String.fromCharCode.apply(String,a)),hextorstr(H9a(rstrtohex("\0\0\0\0\0\0\0\0"+t+a)))),h=[],u=0;u<s-r-n-2;u+=1)h[u]=0;var c=String.fromCharCode.apply(String,h)+""+a,l=pss_mgf1_str(o,c.length,H9a),f=[];for(u=0;u<c.length;u+=1)f[u]=c.charCodeAt(u)^l.charCodeAt(u);for(f[0]&=~(65280>>8*s-i&255),u=0;u<n;u++)f.push(o.charCodeAt(u));return f.push(188),_zeroPaddingOfSignature(this.doPrivate(new BigInteger(f)).toString(16),this.n.bitLength())},RSAKey.prototype.verify=function(t,e){var r,n;return null!=(e=e.toLowerCase()).match(/^[0-9a-f]+$/)&&(e=parseBigInt(e,16),r=this.n.bitLength(),!(e.bitLength()>r))&&(e=this.doPublic(e).toString(16)).length+3==r/4&&0!=(r=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e.replace(/^1f+00/,""))).length&&(n=r[0],r[1]==function(t){return P.crypto.Util.hashString(t,n)}(t))},RSAKey.prototype.verifyWithMessageHash=function(t,e){return e.length==Math.ceil(this.n.bitLength()/4)&&((e=parseBigInt(e,16)).bitLength()>this.n.bitLength()?0:0!=(e=_rsasign_getAlgNameAndHashFromHexDisgestInfo(this.doPublic(e).toString(16).replace(/^1f+00/,""))).length&&(e[0],e[1]==t))},RSAKey.prototype.verifyPSS=function(t,e,r,n){t=function(t){return P.crypto.Util.hashHex(t,r)}(rstrtohex(t));return this.verifyWithMessageHashPSS(t,e,r,n=void 0===n?-1:n)},RSAKey.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;function Kka(t){return P.crypto.Util.hashHex(t,r)}var e=new BigInteger(e,16),t=hextorstr(t),i=t.length,s=this.n.bitLength()-1,a=Math.ceil(s/8);if(-1===n||void 0===n)n=i;else if(-2===n)n=a-i-2;else if(n<-2)throw new Error("invalid salt length");if(a<i+n+2)throw new Error("data too long");for(var o=this.doPublic(e).toByteArray(),h=0;h<o.length;h+=1)o[h]&=255;for(;o.length<a;)o.unshift(0);if(188!==o[a-1])throw new Error("encoded message does not end in 0xbc");var u=(o=String.fromCharCode.apply(String,o)).substr(0,a-i-1),e=o.substr(u.length,i),s=65280>>8*a-s&255;if(0!=(u.charCodeAt(0)&s))throw new Error("bits beyond keysize not zero");var c=pss_mgf1_str(e,u.length,Kka),l=[];for(h=0;h<u.length;h+=1)l[h]=u.charCodeAt(h)^c.charCodeAt(h);l[0]&=~s;var f=a-i-n-2;for(h=0;h<f;h+=1)if(0!==l[h])throw new Error("leftmost octets not zero");if(1!==l[f])throw new Error("0x01 marker not found");return e===hextorstr(Kka(rstrtohex("\0\0\0\0\0\0\0\0"+t+String.fromCharCode.apply(String,l.slice(-n)))))},RSAKey.SALT_LEN_HLEN=-1,RSAKey.SALT_LEN_MAX=-2,RSAKey.SALT_LEN_RECOVER=-2,X509.EXT_PARSER={},X509.registExtParser=function(t,e){X509.EXT_PARSER[t]=e},X509.hex2dn=function(t,e){void 0===e&&(e=0);var r=new X509;E.getTLV(t,e);return r.getX500Name(t).str},X509.hex2rdn=function(t,e){if("31"!==t.substr(e=void 0===e?0:e,2))throw new Error("malformed RDN");for(var r=new Array,n=E.getChildIdx(t,e),i=0;i<n.length;i++)r.push(X509.hex2attrTypeValue(t,n[i]));return(r=r.map(function(t){return t.replace("+","\\+")})).join("+")},X509.hex2attrTypeValue=function(t,e){var r=E,n=r.getV;if("30"!==t.substr(e=void 0===e?0:e,2))throw new Error("malformed attribute type and value");r=r.getChildIdx(t,e),2===r.length&&t.substr(r[0],2),e=n(t,r[0]),e=P.asn1.ASN1Util.oidHexToInt(e);return P.asn1.x509.OID.oid2atype(e)+"="+hextorstr(n(t,r[1]))},X509.getPublicKeyFromCertHex=function(t){var e=new X509;return e.readCertHex(t),e.getPublicKey()},X509.getPublicKeyFromCertPEM=function(t){var e=new X509;return e.readCertPEM(t),e.getPublicKey()},X509.getPublicKeyInfoPropOfCertPEM=function(t){var e=E.getVbyList,r={algparam:null},n=new X509;return n.readCertPEM(t),t=n.getPublicKeyHex(),r.keyhex=e(t,0,[1],"03").substr(2),r.algoid=e(t,0,[0,0],"06"),"2a8648ce3d0201"===r.algoid&&(r.algparam=e(t,0,[0,1],"06")),r},X509.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];void 0!==(P=void 0!==P&&P?P:{}).jws&&P.jws||(P.jws={}),P.jws.JWS=function(){var s=P.jws.JWS.isSafeJSONString;this.parseJWS=function(t,e){if(void 0===this.parsedJWS||!e&&void 0===this.parsedJWS.sigvalH){t=t.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var r=t[1],n=t[2],t=t[3],i=r+"."+n,t=(this.parsedJWS={},this.parsedJWS.headB64U=r,this.parsedJWS.payloadB64U=n,this.parsedJWS.sigvalB64U=t,this.parsedJWS.si=i,e||(e=parseBigInt(i=b64utohex(t),16),this.parsedJWS.sigvalH=i,this.parsedJWS.sigvalBI=e),g(r)),i=g(n);if(this.parsedJWS.headS=t,this.parsedJWS.payloadS=i,!s(t,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+t}}},P.jws.JWS.sign=function(t,e,r,n,i){var s,a=P,o=a.jws.JWS,h=o.readSafeJSONString,u=o.isSafeJSONString,a=a.crypto,c=(a.ECDSA,a.Mac),a=a.Signature,l=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(s=l.stringify(f=e)),"string"==typeof e){if(!u(s=e))throw"JWS Head is not safe JSON string: "+s;f=h(s)}if("object"==typeof(u=r)&&(u=l.stringify(r)),""!=(t=""!=t&&null!=t||void 0===f.alg?t:f.alg)&&null!=t&&void 0===f.alg&&(f.alg=t,s=l.stringify(f)),t!==f.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+f.alg;e=null;if(void 0===o.jwsalg2sigalg[t])throw"unsupported alg name: "+t;var f,g,e=o.jwsalg2sigalg[t],h=N(s)+"."+N(u),r="";if("Hmac"==e.substr(0,4)){if(void 0===n)throw"mac key shall be specified for HS* alg";l=new c({alg:e,prov:"cryptojs",pass:n});l.updateString(h),r=l.doFinal()}else-1!=e.indexOf("withECDSA")?((g=new a({alg:e})).init(n,i),g.updateString(h),f=g.sign(),r=P.crypto.ECDSA.asn1SigToConcatSig(f)):"none"!=e&&((g=new a({alg:e})).init(n,i),g.updateString(h),r=g.sign());return h+"."+hextob64u(r)},P.jws.JWS.verify=function(t,e,r){var n=P,i=n.jws.JWS,s=i.readSafeJSONString,n=n.crypto,a=n.ECDSA,o=n.Mac,n=n.Signature,h=RSAKey;if(!isBase64URLDot(t))return!1;t=t.split(".");if(3!==t.length)return!1;var u=t[0]+"."+t[1],c=b64utohex(t[2]),s=s(g(t[0])),t=null,l=null;if(void 0===s.alg)throw"algorithm not specified in header";if((l=(t=s.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&0<r.length)&&-1==(":"+r.join(":")+":").indexOf(":"+t+":"))throw"algorithm '"+t+"' not accepted in the list";if("none"!=t&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=b.getKey(e)),!("RS"!=l&&"PS"!=l||e instanceof h))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==l&&!(e instanceof a))throw"key shall be a ECDSA obj for ES* algs";r=null;if(void 0===i.jwsalg2sigalg[s.alg])throw"unsupported alg name: "+t;if("none"==(r=i.jwsalg2sigalg[t]))throw"not supported";if("Hmac"==r.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";h=new o({alg:r,pass:e});return h.updateString(u),c==h.doFinal()}if(-1==r.indexOf("withECDSA"))return(f=new n({alg:r})).init(e),f.updateString(u),f.verify(c);var f,l=null;try{l=a.concatSigToASN1Sig(c)}catch(t){return!1}return(f=new n({alg:r})).init(e),f.updateString(u),f.verify(l)},P.jws.JWS.parse=function(t){var e,r,n,t=t.split("."),i={};if(2!=t.length&&3!=t.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=t[0],r=t[1],3==t.length&&(n=t[2]),i.headerObj=P.jws.JWS.readSafeJSONString(g(e)),i.payloadObj=P.jws.JWS.readSafeJSONString(g(r)),i.headerPP=JSON.stringify(i.headerObj,null," "),i.payloadPP=null==i.payloadObj?g(r):JSON.stringify(i.payloadObj,null," "),void 0!==n&&(i.sigHex=b64utohex(n)),i},P.jws.JWS.verifyJWT=function(t,e,r){var n=P.jws,i=n.JWS,s=i.readSafeJSONString,a=i.inArray,o=i.includedArray;if(!isBase64URLDot(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1],h=(b64utohex(h[2]),s(g(u))),u=s(g(c));if(void 0===h.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(h.alg,r.alg))return!1;if(void 0!==u.iss&&"object"==typeof r.iss&&!a(u.iss,r.iss))return!1;if(void 0!==u.sub&&"object"==typeof r.sub&&!a(u.sub,r.sub))return!1;if(void 0!==u.aud&&"object"==typeof r.aud)if("string"==typeof u.aud){if(!a(u.aud,r.aud))return!1}else if("object"==typeof u.aud&&!o(u.aud,r.aud))return!1;s=n.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(s=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==u.exp&&"number"==typeof u.exp&&u.exp+r.gracePeriod<s||void 0!==u.nbf&&"number"==typeof u.nbf&&s<u.nbf-r.gracePeriod||void 0!==u.iat&&"number"==typeof u.iat&&s<u.iat-r.gracePeriod||void 0!==u.jti&&void 0!==r.jti&&u.jti!==r.jti||!i.verify(t,e,r.alg))},P.jws.JWS.includedArray=function(t,e){var r=P.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var n=0;n<t.length;n++)if(!r(t[n],e))return!1;return!0},P.jws.JWS.inArray=function(t,e){if(null!==e&&"object"==typeof e&&"number"==typeof e.length)for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},P.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},P.jws.JWS.isSafeJSONString=function(t,e,r){var n;try{return"object"!=typeof(n=H(t))?0:n.constructor===Array?0:(e&&(e[r]=n),1)}catch(t){return 0}},P.jws.JWS.readSafeJSONString=function(t){var e;try{return"object"!=typeof(e=H(t))?null:e.constructor===Array?null:e}catch(t){return null}},P.jws.JWS.getEncodedSignatureValueFromJWS=function(t){t=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return t[1]},P.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e=(e=(e+='"e":"'+t.e+'",')+('"kty":"'+t.kty+'",'))+('"n":"'+t.n+'"}')}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e=(e=(e=(e+='"crv":"'+t.crv+'",')+('"kty":"'+t.kty+'",'))+('"x":"'+t.x+'",'))+('"y":"'+t.y+'"}')}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e=(e+='"kty":"'+t.kty+'",')+('"k":"'+t.k+'"}')}t=rstrtohex(e);return hextob64u(P.crypto.Util.hashHex(t,"sha256"))},P.jws.IntDate={},P.jws.IntDate.get=function(t){var e=P.jws.IntDate,r=e.getNow,e=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return e(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},P.jws.IntDate.getZulu=function(t){return zulutosec(t)},P.jws.IntDate.getNow=function(){return~~(new Date/1e3)},P.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},P.jws.IntDate.intDate2Zulu=function(t){t=new Date(1e3*t);return("0000"+t.getUTCFullYear()).slice(-4)+("00"+(t.getUTCMonth()+1)).slice(-2)+("00"+t.getUTCDate()).slice(-2)+("00"+t.getUTCHours()).slice(-2)+("00"+t.getUTCMinutes()).slice(-2)+("00"+t.getUTCSeconds()).slice(-2)+"Z"},void 0!==(P=void 0!==P&&P?P:{}).jws&&P.jws||(P.jws={}),P.jws.JWSJS=function(){var i=P.jws.JWS,r=i.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();t=t.split(".");if(3!=t.length)throw"malformed input JWS";this.aHeader.push(t[0]),this.sPayload=t[1],this.aSignature.push(t[2])},this.addSignature=function(t,e,r,n){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var i=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=P.jws.JWS.sign(t,e,this.sPayload,r,n).split(".");s[0],s[2];this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>i&&this.aHeader.pop(),this.aSignature.length>i&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(t,e,r){if(this.aHeader.length<=t||this.aSignature.length<=t)return!1;var n=this.aHeader[t],t=this.aSignature[t],n=n+"."+this.sPayload+"."+t,t=!1;try{t=i.verify(n,e,r)}catch(t){return!1}return t},this.readJWSJS=function(t){if("string"==typeof t){var e=r(t);if(null==e)throw"argument is not safe JSON object string";this.aHeader=e.headers,this.sPayload=e.payload,this.aSignature=e.signatures}else try{if(!(0<t.headers.length))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(0<t.signatures.length))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},P.crypto.ECDSA,P.crypto.DSA,P.crypto.Signature,P.crypto.MessageDigest,P.crypto.Mac,P.crypto.Cipher,d.KZ=b,d.eL=P.crypto,P.asn1,P.jws,P.lang}},n={};function __webpack_require__(t){var e=n[t];return void 0!==e||(e=n[t]={exports:{}},r[t](e,e.exports,__webpack_require__)),e.exports}__webpack_require__.d=(t,e)=>{for(var r in e)__webpack_require__.o(e,r)&&!__webpack_require__.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var e={};return(()=>{"use strict";__webpack_require__.d(e,{default:()=>t});var h=__webpack_require__(166);function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,function _toPropertyKey(t){t=function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==_typeof(t)?t:String(t)}(n.key),n)}}var t=function(){function _default(){!function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,_default),this._identifier="imagex-encrypt-plugin",this.stage=1005}return function _createClass(t,e,r){e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1})}(_default,[{key:"apply",value:function apply(t,e,r){var n=this,i=t.isImageBatchUpload,s=t.imagexPublicKey,a=t.imagexEncryptKey,o=h.KZ.getKey(s);return i?t.crc32Array.map(function(){var t=h.eL.Cipher.encrypt(a,o,"RSAOAEP256");return n._hexToBase64(t)}):(s=h.eL.Cipher.encrypt(a,o,"RSAOAEP256"),[this._hexToBase64(s)])}},{key:"_hexToBase64",value:function _hexToBase64(t){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="",n=0,i=0,s=0;s<t.length;++s)n=n<<4|("A"<=t[s]&&t[s]<="Z"?t.charCodeAt(s)-55:"a"<=t[s]&&t[s]<="z"?t.charCodeAt(s)-87:t.charCodeAt(s)-48),6<=(i+=4)&&(r+=e[n>>>(i-=6)],n&=~(-1<<i));0<i&&(r+=e[n<<=6-i]);var a=r.length%4;if(0<a)for(var o=0;o<4-a;++o)r+="=";return r}}]),_default}()})(),e.default})());