/*! For license information please see jitsi.js.LICENSE.txt */ !function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=33)}([,,function(t,e){t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},function(t,e,i){"use strict";function r(t){return t.slice(0,t.length)}function n(t,e){if(t.length===e.length){for(let i=0;i!t.includes(e))||!!t.some(t=>!e.includes(t)))}function a(t,e){return{added:e.filter(e=>!t.includes(e)),removed:t.filter(t=>!e.includes(t))}}function o(t,e){return t.filter(t=>e.includes(t))}function h(...t){return Array.from(t.reduce((t,e)=>(e.forEach(e=>t.add(e)),t),new Set))}i.d(e,"c",(function(){return r})),i.d(e,"e",(function(){return n})),i.d(e,"d",(function(){return s})),i.d(e,"b",(function(){return a})),i.d(e,"g",(function(){return o})),i.d(e,"f",(function(){return h})),i.d(e,"a",(function(){return u}));class u{constructor(t){this.a=t}get value(){return this.a}groupBy(t){const e=this.a.reduce((e,i)=>{const r=t(i);return e.has(r)||e.set(r,[]),e.get(r).push(i),e},new Map);return new c(e)}}class c{constructor(t){this.val=t}orderBy(t){const e=[];for(const i of t)this.val.has(i)&&e.push(...this.val.get(i));return new u(e)}}},function(t,e,i){"use strict";e.decode=e.parse=i(8),e.encode=e.stringify=i(9)},,function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.d(e,"a",(function(){return h})),i.d(e,"b",(function(){return u})),i.d(e,"c",(function(){return l}));var r=i(2),n=i.n(r),s=i(13),a=i(10),o=i(11);let h,u,c;!function(t){t.Screenshot="m.capability.screenshot",t.Sticker="m.sticker",t.AlwaysOnScreen="m.always_on_screen",t.ReceiveTerminate="im.vector.receive_terminate"}(h||(h={})),function(t){t.GetSupportedApiVersions="supported_api_versions",t.TakeScreenshot="screenshot",t.GetCapabilities="capabilities",t.SendEvent="send_event",t.UpdateVisibility="visibility",t.GetOpenIDCredentials="get_openid",t.ReceiveOpenIDCredentials="openid_credentials",t.SetAlwaysOnScreen="set_always_on_screen",t.ClientReady="im.vector.ready",t.Terminate="im.vector.terminate"}(u||(u={})),function(t){t.ToWidget="toWidget",t.FromWidget="fromWidget"}(c||(c={}));class l extends a.EventEmitter{constructor(t,e,i){super(),this.widgetId=e,this.requestedCapabilities=i,n()(this,"origin",void 0),n()(this,"inFlightRequests",{}),n()(this,"readyPromise",void 0),n()(this,"readyPromiseResolve",void 0),n()(this,"openIDCredentialsCallback",void 0),n()(this,"openIDCredentials",void 0),n()(this,"expectingExplicitReady",!1),this.origin=new URL(t).origin,this.readyPromise=new Promise(t=>this.readyPromiseResolve=t),window.addEventListener("message",t=>{if(t.origin!==this.origin)return;if(!t.data)return;if(t.data.widgetId!==this.widgetId)return;const e=t.data;if(e.api===c.ToWidget&&e.action)if(console.log("[WidgetAPI] Got request: "+JSON.stringify(e)),e.action===u.GetCapabilities)this.onCapabilitiesRequest(e),this.expectingExplicitReady||this.readyPromiseResolve();else if(e.action===u.ClientReady)this.readyPromiseResolve(),this.replyToRequest(e,{});else if(e.action===u.Terminate){let t=Promise.resolve();const i=e=>{t=t.then(()=>e)};this.emit("terminate",i),Promise.resolve(t).then(()=>{this.replyToRequest(e,{})})}else e.action===u.ReceiveOpenIDCredentials?(this.setOpenIDCredentials(e),this.replyToRequest(e,{})):console.warn("[WidgetAPI] Got unexpected action: "+e.action);else if(e.api===c.FromWidget&&this.inFlightRequests[e.requestId]){console.log("[WidgetAPI] Got reply: "+JSON.stringify(e));const t=this.inFlightRequests[e.requestId];delete this.inFlightRequests[e.requestId],t(e)}else console.warn("[WidgetAPI] Unhandled payload: "+JSON.stringify(e))})}setOpenIDCredentials(t){const e=t.data;"allowed"===e.state?this.openIDCredentials={accessToken:e.access_token,tokenType:e.token_type,matrixServerName:e.matrix_server_name,expiresIn:e.expires_in}:"blocked"===e.state&&(this.openIDCredentials=null),["allowed","blocked"].includes(e.state)&&this.openIDCredentialsCallback&&this.openIDCredentialsCallback()}requestOpenIDCredentials(t){this.openIDCredentialsCallback=t,this.callAction(u.GetOpenIDCredentials,{},this.setOpenIDCredentials)}waitReady(){return this.readyPromise}replyToRequest(t,e){if(!window.parent)return;const i=Object(o.a)(t);i.response=e,window.parent.postMessage(i,this.origin)}onCapabilitiesRequest(t){return this.replyToRequest(t,{capabilities:this.requestedCapabilities})}callAction(t,e,i){if(!window.parent)return;const r={api:c.FromWidget,widgetId:this.widgetId,action:t,requestId:Object(s.a)(160),data:e,response:{}};i&&(this.inFlightRequests[r.requestId]=i),console.log("[WidgetAPI] Sending request: ",r),window.parent.postMessage(r,"*")}setAlwaysOnScreen(t){return new Promise(e=>{this.callAction(u.SetAlwaysOnScreen,{value:t},null),e()})}}},function(t,e,i){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,i,s){e=e||"&",i=i||"=";var a={};if("string"!=typeof t||0===t.length)return a;var o=/\+/g;t=t.split(e);var h=1e3;s&&"number"==typeof s.maxKeys&&(h=s.maxKeys);var u=t.length;h>0&&u>h&&(u=h);for(var c=0;c=0?(l=p.substr(0,v),f=p.substr(v+1)):(l=p,f=""),d=decodeURIComponent(l),g=decodeURIComponent(f),r(a,d)?n(a[d])?a[d].push(g):a[d]=[a[d],g]:a[d]=g}return a};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,i){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,i,o){return e=e||"&",i=i||"=",null===t&&(t=void 0),"object"==typeof t?s(a(t),(function(a){var o=encodeURIComponent(r(a))+i;return n(t[a])?s(t[a],(function(t){return o+encodeURIComponent(r(t))})).join(e):o+encodeURIComponent(r(t[a]))})).join(e):o?encodeURIComponent(r(o))+i+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e){if(t.map)return t.map(e);for(var i=[],r=0;r0&&a.length>n&&!a.warned){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=a.length,o=h,console&&console.warn&&console.warn(o)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=f.bind(r);return n.listener=i,r.wrapFn=n,n}function g(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var h=n[t];if(void 0===h)return!1;if("function"==typeof h)s(h,this,e);else{var u=h.length,c=v(h,u);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){a=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return g(this,t,!0)},o.prototype.rawListeners=function(t){return g(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,i){"use strict";i.d(e,"b",(function(){return n})),i.d(e,"f",(function(){return s})),i.d(e,"e",(function(){return a})),i.d(e,"c",(function(){return o})),i.d(e,"d",(function(){return h})),i.d(e,"a",(function(){return u}));var r=i(3);function n(t,e){const i=new Map(Object.entries(t));for(const t of e)i.delete(t);return Array.from(i.entries()).reduce((t,[e,i])=>(t[e]=i,t),{})}function s(t,e){const i=Object.keys(t),s=Object(r.b)(i,e);return 0===s.removed.length?a(t):n(t,s.removed)}function a(t,e){const i={};for(const[r,n]of Object.entries(t))i[r]=n,e&&(i[r]=e(r,n));return i}function o(t,e){const i=Object.keys(t),n=Object.keys(e);if(Object(r.d)(i,n))return!0;return Object(r.g)(i,n).some(i=>t[i]!==e[i])}function h(t,e){const i=function(t,e){const i=Object.keys(t),n=Object.keys(e),s=Object(r.b)(i,n);return{changed:Object(r.g)(i,n).filter(i=>t[i]!==e[i]),added:s.added,removed:s.removed}}(t,e);return Object(r.f)(i.removed,i.added,i.changed)}function u(t){return JSON.parse(JSON.stringify(t))}},,function(t,e,i){"use strict";function r(t){let e="";const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let r=0;r>>2]>>>24-s%4*8&255;e[r+s>>>2]|=a<<24-(r+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-n%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,i=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,r=[],n=0;n>>2]>>>24-n%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(t){for(var e=t.length,i=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=o.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,r=e.sigBytes,n=this.blockSize,a=r/(4*n),o=(a=t?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*n,h=s.min(4*o,r);if(o){for(var c=0;c>>2]}},e.BlockCipher=o.extend({cfg:o.cfg.extend({mode:h,padding:c}),reset:function(){o.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,r){r=this.cfg.extend(r);var n=t.createEncryptor(i,r);return e=n.finalize(e),n=n.cfg,l.create({ciphertext:e,key:i,iv:n.iv,algorithm:t,mode:n.mode,padding:n.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,i,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),t.createDecryptor(i,r).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,n){return n||(n=r.random(8)),t=a.create({keySize:e+i}).compute(t,n),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:n})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,r){return i=(r=this.cfg.extend(r)).kdf.execute(i,t.keySize,t.ivSize),r.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,r)).mixIn(i),t},decrypt:function(t,e,i,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),i=r.kdf.execute(i,t.keySize,t.ivSize,e.salt),r.iv=i.iv,f.decrypt.call(this,t,e,i.key,r)}})}(),function(){for(var t=v,e=t.lib.BlockCipher,i=t.algo,r=[],n=[],s=[],a=[],o=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,y=0;for(g=0;256>g;g++){var m=(m=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&m^99;r[p]=m,n[m]=p;var x=d[p],S=d[x],E=d[S],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,a[p]=w<<16|w>>>16,o[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*S^257*x^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=x^d[d[d[E^x]]],y^=d[d[y]]):p=y=1}var F=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),n=this._keySchedule=[],s=0;s>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=F[s/e|0]<<24),n[s]=n[s-e]^a}for(t=this._invKeySchedule=[],e=0;ee||4>=s?a:u[r[a>>>24]]^c[r[a>>>16&255]]^l[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,o,h,r)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,n),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,r,n,s,a,o){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^n[c>>>16&255]^s[l>>>8&255]^a[255&f]^i[d++],v=r[c>>>24]^n[l>>>16&255]^s[f>>>8&255]^a[255&u]^i[d++],y=r[l>>>24]^n[f>>>16&255]^s[u>>>8&255]^a[255&c]^i[d++];f=r[f>>>24]^n[u>>>16&255]^s[c>>>8&255]^a[255&l]^i[d++],u=p,c=v,l=y}p=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^i[d++],v=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&u])^i[d++],y=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^i[d++],f=(o[f>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^i[d++],t[e]=p,t[e+1]=v,t[e+2]=y,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var r=a[i]-1;e[i]=t[r>>>5]>>>31-r%32&1}for(t=this._subKeys=[],r=0;16>r;r++){var n=t[r]=[],s=h[r];for(i=0;24>i;i++)n[i/6|0]|=e[(o[i]-1+s)%28]<<31-i%6,n[4+(i/6|0)]|=e[28+(o[i+24]-1+s)%28]<<31-i%6;for(n[0]=n[0]<<1|n[0]>>>31,i=1;7>i;i++)n[i]>>>=4*(i-1)+3;n[7]=n[7]<<5|n[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,r,n){this._lBlock=i[r],this._rBlock=i[r+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var a=n[s],o=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^a[f])&c[f])>>>0];this._lBlock=h,this._rBlock=o^l}n=this._lBlock,this._lBlock=this._rBlock,this._rBlock=n,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[r]=this._lBlock,i[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=n._createHelper(l),s=s.TripleDES=n.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(r.create(t.slice(0,2))),this._des2=l.createEncryptor(r.create(t.slice(2,4))),this._des3=l.createEncryptor(r.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}),i.TripleDES=n._createHelper(s)}(),function(){var t=v,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,r=this._map;t.clamp(),t=[];for(var n=0;n>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,a=0;4>a&&n+.75*a>>6*(3-a)&63));if(e=r.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,r=this._map;(n=r.charAt(64))&&(-1!=(n=t.indexOf(n))&&(i=n));for(var n=[],s=0,a=0;a>>6-a%4*2;n[s>>>2]|=(o|h)<<24-s%4*8,s++}return e.create(n,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,r,n,s,a){return((t=t+(e&i|~e&r)+n+a)<>>32-s)+e}function i(t,e,i,r,n,s,a){return((t=t+(e&r|i&~r)+n+a)<>>32-s)+e}function r(t,e,i,r,n,s,a){return((t=t+(e^i^r)+n+a)<>>32-s)+e}function n(t,e,i,r,n,s,a){return((t=t+(i^(e|~r))+n+a)<>>32-s)+e}for(var s=v,a=(h=s.lib).WordArray,o=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var a=0;16>a;a++){var o=t[h=s+a];t[h]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var h=t[s+0],c=(o=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],v=t[s+8],y=t[s+9],m=t[s+10],x=t[s+11],S=t[s+12],E=t[s+13],w=t[s+14],F=t[s+15],b=e(b=a[0],I=a[1],C=a[2],A=a[3],h,7,u[0]),A=e(A,b,I,C,o,12,u[1]),C=e(C,A,b,I,c,17,u[2]),I=e(I,C,A,b,l,22,u[3]);b=e(b,I,C,A,f,7,u[4]),A=e(A,b,I,C,d,12,u[5]),C=e(C,A,b,I,g,17,u[6]),I=e(I,C,A,b,p,22,u[7]),b=e(b,I,C,A,v,7,u[8]),A=e(A,b,I,C,y,12,u[9]),C=e(C,A,b,I,m,17,u[10]),I=e(I,C,A,b,x,22,u[11]),b=e(b,I,C,A,S,7,u[12]),A=e(A,b,I,C,E,12,u[13]),C=e(C,A,b,I,w,17,u[14]),b=i(b,I=e(I,C,A,b,F,22,u[15]),C,A,o,5,u[16]),A=i(A,b,I,C,g,9,u[17]),C=i(C,A,b,I,x,14,u[18]),I=i(I,C,A,b,h,20,u[19]),b=i(b,I,C,A,d,5,u[20]),A=i(A,b,I,C,m,9,u[21]),C=i(C,A,b,I,F,14,u[22]),I=i(I,C,A,b,f,20,u[23]),b=i(b,I,C,A,y,5,u[24]),A=i(A,b,I,C,w,9,u[25]),C=i(C,A,b,I,l,14,u[26]),I=i(I,C,A,b,v,20,u[27]),b=i(b,I,C,A,E,5,u[28]),A=i(A,b,I,C,c,9,u[29]),C=i(C,A,b,I,p,14,u[30]),b=r(b,I=i(I,C,A,b,S,20,u[31]),C,A,d,4,u[32]),A=r(A,b,I,C,v,11,u[33]),C=r(C,A,b,I,x,16,u[34]),I=r(I,C,A,b,w,23,u[35]),b=r(b,I,C,A,o,4,u[36]),A=r(A,b,I,C,f,11,u[37]),C=r(C,A,b,I,p,16,u[38]),I=r(I,C,A,b,m,23,u[39]),b=r(b,I,C,A,E,4,u[40]),A=r(A,b,I,C,h,11,u[41]),C=r(C,A,b,I,l,16,u[42]),I=r(I,C,A,b,g,23,u[43]),b=r(b,I,C,A,y,4,u[44]),A=r(A,b,I,C,S,11,u[45]),C=r(C,A,b,I,F,16,u[46]),b=n(b,I=r(I,C,A,b,c,23,u[47]),C,A,h,6,u[48]),A=n(A,b,I,C,p,10,u[49]),C=n(C,A,b,I,w,15,u[50]),I=n(I,C,A,b,d,21,u[51]),b=n(b,I,C,A,S,6,u[52]),A=n(A,b,I,C,l,10,u[53]),C=n(C,A,b,I,m,15,u[54]),I=n(I,C,A,b,o,21,u[55]),b=n(b,I,C,A,v,6,u[56]),A=n(A,b,I,C,F,10,u[57]),C=n(C,A,b,I,g,15,u[58]),I=n(I,C,A,b,E,21,u[59]),b=n(b,I,C,A,f,6,u[60]),A=n(A,b,I,C,x,10,u[61]),C=n(C,A,b,I,c,15,u[62]),I=n(I,C,A,b,y,21,u[63]);a[0]=a[0]+b|0,a[1]=a[1]+I|0,a[2]=a[2]+C|0,a[3]=a[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;i[n>>>5]|=128<<24-n%32;var s=t.floor(r/4294967296);for(i[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,r=0;4>r;r++)n=i[r],i[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=o._createHelper(h),s.HmacMD5=o._createHmacHelper(h)}(Math),function(){var t=v,e=(n=t.lib).WordArray,i=n.Hasher,r=[],n=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],s=i[1],a=i[2],o=i[3],h=i[4],u=0;80>u;u++){if(16>u)r[u]=0|t[e+u];else{var c=r[u-3]^r[u-8]^r[u-14]^r[u-16];r[u]=c<<1|c>>>31}c=(n<<5|n>>>27)+h+r[u],c=20>u?c+(1518500249+(s&a|~s&o)):40>u?c+(1859775393+(s^a^o)):60>u?c+((s&a|s&o|a&o)-1894007588):c+((s^a^o)-899497514),h=o,o=a,a=s<<30|s>>>2,s=n,n=c}i[0]=i[0]+n|0,i[1]=i[1]+s|0,i[2]=i[2]+a|0,i[3]=i[3]+o|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(r+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(n),t.HmacSHA1=i._createHmacHelper(n)}(),function(t){for(var e=v,i=(n=e.lib).WordArray,r=n.Hasher,n=e.algo,s=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=o(t.pow(h,.5))),a[u]=o(t.pow(h,1/3)),u++),h++}var d=[];n=n.SHA256=r.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],n=i[1],s=i[2],o=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+a[f]+d[f],p=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&n^r&s^n&s),l=c,c=u,u=h,h=o+g|0,o=s,s=n,n=r,r=g+p|0}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return i[n>>>5]|=128<<24-n%32,i[14+(n+64>>>9<<4)]=t.floor(r/4294967296),i[15+(n+64>>>9<<4)]=r,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=r._createHelper(n),e.HmacSHA256=r._createHmacHelper(n)}(Math),function(){var t=v,e=t.lib.WordArray,i=(r=t.algo).SHA256,r=r.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(r),t.HmacSHA224=i._createHmacHelper(r)}(),function(){function t(){return r.create.apply(r,arguments)}for(var e=v,i=e.lib.Hasher,r=(s=e.x64).Word,n=s.WordArray,s=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],h=0;80>h;h++)o[h]=t();s=s.SHA512=i.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(t,e){for(var i=(l=this._hash.words)[0],r=l[1],n=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=r.high,p=r.low,v=n.high,y=n.low,m=s.high,x=s.low,S=h.high,E=h.low,w=u.high,F=u.low,b=c.high,A=c.low,C=l.high,I=l.low,D=f,T=d,P=g,R=p,H=v,B=y,N=m,O=x,j=S,L=E,V=w,K=F,_=b,M=A,k=C,U=I,q=0;80>q;q++){var z=o[q];if(16>q)var G=z.high=0|t[e+2*q],W=z.low=0|t[e+2*q+1];else{G=((W=(G=o[q-15]).high)>>>1|(Y=G.low)<<31)^(W>>>8|Y<<24)^W>>>7;var Y=(Y>>>1|W<<31)^(Y>>>8|W<<24)^(Y>>>7|W<<25),J=((W=(J=o[q-2]).high)>>>19|(X=J.low)<<13)^(W<<3|X>>>29)^W>>>6,X=(X>>>19|W<<13)^(X<<3|W>>>29)^(X>>>6|W<<26),$=(W=o[q-7]).high,Z=(Q=o[q-16]).high,Q=Q.low;G=(G=(G=G+$+((W=Y+W.low)>>>0>>0?1:0))+J+((W=W+X)>>>0>>0?1:0))+Z+((W=W+Q)>>>0>>0?1:0);z.high=G,z.low=W}$=j&V^~j&_,Q=L&K^~L&M,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(Y=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),J=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=a[q]).high),it=X.low;Z=k+((j>>>14|L<<18)^(j>>>18|L<<14)^(j<<23|L>>>9))+((X=U+((L>>>14|j<<18)^(L>>>18|j<<14)^(L<<23|j>>>9)))>>>0>>0?1:0),k=_,U=M,_=V,M=K,V=j,K=L,j=N+(Z=(Z=(Z=Z+$+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+W)>>>0>>0?1:0))+((L=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=Z+(z=Y+z+((W=J+tt)>>>0>>0?1:0))+((T=X+W|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=r.low=p+R,r.high=g+P+(p>>>0>>0?1:0),y=n.low=y+B,n.high=v+H+(y>>>0>>0?1:0),x=s.low=x+O,s.high=m+N+(x>>>0>>0?1:0),E=h.low=E+L,h.high=S+j+(E>>>0>>0?1:0),F=u.low=F+K,u.high=w+V+(F>>>0>>0?1:0),A=c.low=A+M,c.high=b+_+(A>>>0>>0?1:0),I=l.low=I+U,l.high=C+k+(I>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(r+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=v,e=(n=t.x64).Word,i=n.WordArray,r=(n=t.algo).SHA512,n=n.SHA384=r.extend({_doReset:function(){this._hash=new i.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(n),t.HmacSHA384=r._createHmacHelper(n)}(),function(){var t=v,e=(r=t.lib).WordArray,i=r.Hasher,r=t.algo,n=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]),s=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]),a=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]),o=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]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);r=r.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var r=t[S=e+i];t[S]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var c,l,f,d,g,p,v,y,m,x,S=this._hash.words,E=(r=h.words,u.words),w=n.words,F=s.words,b=a.words,A=o.words;p=c=S[0],v=l=S[1],y=f=S[2],m=d=S[3],x=g=S[4];var C;for(i=0;80>i;i+=1)C=c+t[e+w[i]]|0,C=16>i?C+((l^f^d)+r[0]):32>i?C+((l&f|~l&d)+r[1]):48>i?C+(((l|~f)^d)+r[2]):64>i?C+((l&d|f&~d)+r[3]):C+((l^(f|~d))+r[4]),C=(C=(C|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=C,C=p+t[e+F[i]]|0,C=16>i?C+((v^(y|~m))+E[0]):32>i?C+((v&m|y&~m)+E[1]):48>i?C+(((v|~y)^m)+E[2]):64>i?C+((v&y|~v&m)+E[3]):C+((v^y^m)+E[4]),C=(C=(C|=0)<>>32-A[i])+x|0,p=x,x=m,m=y<<10|y>>>22,y=v,v=C;C=S[1]+f+m|0,S[1]=S[2]+d+x|0,S[2]=S[3]+g+p|0,S[3]=S[4]+c+v|0,S[4]=S[0]+l+y|0,S[0]=C},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,r=8*t.sigBytes;for(e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)r=e[i],e[i]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(r),t.HmacRIPEMD160=i._createHmacHelper(r)}(Math),function(){var t=v,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var r=t.blockSize,n=4*r;i.sigBytes>n&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),a=this._iKey=i.clone(),o=s.words,h=a.words,u=0;u>6)+m.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=m.charAt(i>>2)+m.charAt((3&i)<<4)),"=";(3&r.length)>0;)r+="=";return r}function S(t){var e,i,r,n="",s=0;for(e=0;e>2),i=3&r,s=1):1==s?(n+=I(i<<2|r>>4),i=15&r,s=2):2==s?(n+=I(i),n+=I(r>>2),i=3&r,s=3):(n+=I(i<<2|r>>4),n+=I(15&r),s=0));return 1==s&&(n+=I(i<<2)),n}function E(t){var e,i=S(t),r=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;n=((h=a*h+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+o*u+(n>>>30),i[r++]=1073741823&h}return n},y=30):"Netscape"!=i.appName?(w.prototype.am=function(t,e,i,r,n,s){for(;--s>=0;){var a=e*this[t++]+i[r]+n;n=Math.floor(a/67108864),i[r++]=67108863&a}return n},y=26):(w.prototype.am=function(t,e,i,r,n,s){for(var a=16383&e,o=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;n=((h=a*h+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+o*u,i[r++]=268435455&h}return n},y=28),w.prototype.DB=y,w.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function R(t){this.m=t}function H(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=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}function V(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function K(){}function _(t){return t}function M(t){this.r2=F(),this.q3=F(),w.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}R.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},R.prototype.revert=function(t){return t},R.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},R.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},R.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},H.prototype.convert=function(t){var e=F();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(w.ZERO)>0&&this.m.subTo(e,e),e},H.prototype.revert=function(t){var e=F();return t.copyTo(e),this.reduce(e),e},H.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},H.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},H.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},w.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},w.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},w.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,s=0;--r>=0;){var a=8==i?255&t[r]:D(t,r);a<0?"-"==t.charAt(r)&&(n=!0):(n=!1,0==s?this[this.t++]=a:s+i>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},w.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},w.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+a+1]=this[i]>>n|o,o=(this[i]&s)<=0;--i)e[i]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},w.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<>r;for(var a=i+1;a>r;r>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()},w.prototype.multiplyTo=function(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;--n>=0;)e[n]=0;for(n=0;n=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},w.prototype.divRemTo=function(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t0?(r.lShiftTo(h,s),n.lShiftTo(h,i)):(r.copyTo(s),n.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(y,i)),w.ONE.dlShiftTo(u,y),y.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,v,0,u))0&&i.rShiftTo(h,i),a<0&&w.ZERO.subTo(i,i)}}},w.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},w.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},w.prototype.exp=function(t,e){if(t>4294967295||t<1)return w.ONE;var i=F(),r=F(),n=e.convert(this),s=P(t)-1;for(n.copyTo(i);--s>=0;)if(e.sqrTo(i,r),(t&1<0)e.mulTo(r,n,i);else{var a=i;i=r,r=a}return e.revert(i)},w.prototype.toString=function(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 i,r=(1<0)for(o>o)>0&&(n=!0,s=I(i));a>=0;)o>(o+=this.DB-e)):(i=this[a]>>(o-=e)&r,o<=0&&(o+=this.DB,--a)),i>0&&(n=!0),n&&(s+=I(i));return n?s:"0"},w.prototype.negate=function(){var t=F();return w.ZERO.subTo(this,t),t},w.prototype.abs=function(){return this.s<0?this.negate():this},w.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},w.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)},w.prototype.mod=function(t){var e=F();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(w.ZERO)>0&&t.subTo(e,e),e},w.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new R(e):new H(e),this.exp(t,i)},w.ZERO=T(0),w.ONE=T(1),K.prototype.convert=_,K.prototype.revert=_,K.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},K.prototype.sqrTo=function(t,e){t.squareTo(e)},M.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=F();return t.copyTo(e),this.reduce(e),e},M.prototype.revert=function(t){return t},M.prototype.reduce=function(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);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},M.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},M.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[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],U=(1<<26)/k[k.length-1];function q(){this.i=0,this.j=0,this.S=new Array}w.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},w.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=T(i),n=F(),s=F(),a="";for(this.divRemTo(r,n,s);n.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,n.divRemTo(r,n,s);return s.intValue().toString(t)+a},w.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,s=0,a=0,o=0;o=i&&(this.dMultiply(r),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),n&&w.ZERO.subTo(this,this)},w.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(w.ONE.shiftLeft(t-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(w.ONE.shiftLeft(t-1),this);else{var r=new Array,n=7&t;r.length=1+(t>>3),e.nextBytes(r),n>0?r[0]&=(1<>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()},w.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},w.prototype.dAddOffset=function(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]}},w.prototype.multiplyLowerTo=function(t,e,i){var r,n=Math.min(this.t+t.t,e);for(i.s=0,i.t=n;n>0;)i[--n]=0;for(r=i.t-this.t;n=0;)i[r]=0;for(r=Math.max(e-this.t,0);r0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i},w.prototype.millerRabin=function(t){var e=this.subtract(w.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var r=e.shiftRight(i);(t=t+1>>1)>k.length&&(t=k.length);for(var n=F(),s=0;s>24},w.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},w.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},w.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,r=this.DB-t*this.DB%8,n=0;if(t-- >0)for(r>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<=0;)r<8?(i=(this[t]&(1<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=i);return e},w.prototype.equals=function(t){return 0==this.compareTo(t)},w.prototype.min=function(t){return this.compareTo(t)<0?this:t},w.prototype.max=function(t){return this.compareTo(t)>0?this:t},w.prototype.and=function(t){var e=F();return this.bitwiseTo(t,B,e),e},w.prototype.or=function(t){var e=F();return this.bitwiseTo(t,N,e),e},w.prototype.xor=function(t){var e=F();return this.bitwiseTo(t,O,e),e},w.prototype.andNot=function(t){var e=F();return this.bitwiseTo(t,j,e),e},w.prototype.not=function(){for(var t=F(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=F();for(r.sqrTo(a[1],c);o<=u;)a[o]=F(),r.mulTo(c,a[o-2],a[o]),o+=2}var l,f,d=t.t-1,g=!0,p=F();for(n=P(t[d])-1;d>=0;){for(n>=h?l=t[d]>>n-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+n-h)),o=i;0==(1&l);)l>>=1,--o;if((n-=o)<0&&(n+=this.DB,--d),g)a[l].copyTo(s),g=!1;else{for(;o>1;)r.sqrTo(s,p),r.sqrTo(p,s),o-=2;o>0?r.sqrTo(s,p):(f=s,s=p,p=f),r.mulTo(p,a[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(r,i),e&&n.subTo(a,n),s.subTo(o,s)):(r.subTo(i,r),e&&a.subTo(n,a),o.subTo(s,o))}return 0!=r.compareTo(w.ONE)?w.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},w.prototype.pow=function(t){return this.exp(t,new K)},w.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var n=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(n0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},w.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=k[k.length-1]){for(e=0;e>8&255,G[W++]^=t>>16&255,G[W++]^=t>>24&255,W>=256&&(W-=256)}((new Date).getTime())}if(null==G){var J;if(G=new Array,W=0,void 0!==r&&(void 0!==r.crypto||void 0!==r.msCrypto)){var X=r.crypto||r.msCrypto;if(X.getRandomValues){var $=new Uint8Array(32);for(X.getRandomValues($),J=0;J<32;++J)G[W++]=$[J]}else if("Netscape"==i.appName&&i.appVersion<"5"){var Z=r.crypto.random(32);for(J=0;J>>8,G[W++]=255&J;W=0,Y()}function Q(){if(null==z){for(Y(),(z=new q).init(G),W=0;W>24,(16711680&n)>>16,(65280&n)>>8,255&n]))),n+=1;return r}function rt(){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 nt(t,e,i){for(var r="",n=0;r.length>24,(16711680&n)>>16,(65280&n)>>8,255&n])),n+=1;return r}function st(t,e){this.x=e,this.q=t}function at(t,e,i,r){this.curve=t,this.x=e,this.y=i,this.z=null==r?w.ONE:r,this.zinv=null}function ot(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new at(this,null,null)}tt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=et(t,16),this.e=parseInt(e,16)}},rt.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var n=t.charCodeAt(r--);n<128?i[--e]=n:n>127&&n<2048?(i[--e]=63&n|128,i[--e]=n>>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new tt,a=new Array;e>2;){for(a[0]=0;0==a[0];)s.nextBytes(a);i[--e]=a[0]}return i[--e]=2,i[--e]=0,new w(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r},rt.prototype.encryptOAEP=function(t,e,i){var r=function(t,e,i,r){var n=ut.crypto.MessageDigest,s=ut.crypto.Util,a=null;if(i||(i="sha1"),"string"==typeof i&&(a=n.getCanonicalAlgName(i),r=n.getHashLength(a),i=function(t){return Ft(s.hashHex(bt(t),a))}),t.length+2*r+2>e)throw"Message too long for RSA";var o,h="";for(o=0;o>3,e,i);if(null==r)return null;var n=this.doPublic(r);if(null==n)return null;var s=n.toString(16);return 0==(1&s.length)?s:"0"+s},rt.prototype.type="RSA",rt.prototype.doPrivate=function(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),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},rt.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(i,16)}},rt.prototype.setPrivateEx=function(t,e,i,r,n,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&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(i,16),this.p=et(r,16),this.q=et(n,16),this.dmp1=et(s,16),this.dmq1=et(a,16),this.coeff=et(o,16)},rt.prototype.generate=function(t,e){var i=new tt,r=t>>1;this.e=parseInt(e,16);for(var n=new w(e,16);;){for(;this.p=new w(t-r,1,i),0!=this.p.subtract(w.ONE).gcd(n).compareTo(w.ONE)||!this.p.isProbablePrime(10););for(;this.q=new w(r,1,i),0!=this.q.subtract(w.ONE).gcd(n).compareTo(w.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var a=this.p.subtract(w.ONE),o=this.q.subtract(w.ONE),h=a.multiply(o);if(0==h.gcd(n).compareTo(w.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=n.modInverse(h),this.dmp1=this.d.mod(a),this.dmq1=this.d.mod(o),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},rt.prototype.decrypt=function(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var e=et(t,16),i=this.doPrivate(e);return null==i?null:function(t,e){for(var i=t.toByteArray(),r=0;r=i.length)return null;for(var n="";++r191&&s<224?(n+=String.fromCharCode((31&s)<<6|63&i[r+1]),++r):(n+=String.fromCharCode((15&s)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return n}(i,this.n.bitLength()+7>>3)},rt.prototype.decryptOAEP=function(t,e,i){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var r=et(t,16),n=this.doPrivate(r);return null==n?null:function(t,e,i,r){var n=ut.crypto.MessageDigest,s=ut.crypto.Util,a=null;for(i||(i="sha1"),"string"==typeof i&&(a=n.getCanonicalAlgName(i),r=n.getHashLength(a),i=function(t){return Ft(s.hashHex(bt(t),a))}),t=t.toByteArray(),o=0;o>3,e,i)},st.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},st.prototype.toBigInteger=function(){return this.x},st.prototype.negate=function(){return new st(this.q,this.x.negate().mod(this.q))},st.prototype.add=function(t){return new st(this.q,this.x.add(t.toBigInteger()).mod(this.q))},st.prototype.subtract=function(t){return new st(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},st.prototype.multiply=function(t){return new st(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},st.prototype.square=function(){return new st(this.q,this.x.square().mod(this.q))},st.prototype.divide=function(t){return new st(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},at.prototype.getX=function(){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))},at.prototype.getY=function(){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))},at.prototype.equals=function(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(w.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(w.ZERO))},at.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(w.ZERO)&&!this.y.toBigInteger().equals(w.ZERO)},at.prototype.negate=function(){return new at(this.curve,this.x,this.y.negate(),this.z)},at.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(w.ZERO.equals(i))return w.ZERO.equals(e)?this.twice():this.curve.getInfinity();var r=new w("3"),n=this.x.toBigInteger(),s=this.y.toBigInteger(),a=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),o=a.multiply(i),h=n.multiply(a),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(o).multiply(i).mod(this.curve.q),l=h.multiply(r).multiply(e).subtract(s.multiply(o)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),f=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new at(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},at.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new w("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),r=i.multiply(this.z),n=r.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),a=e.square().multiply(t);w.ZERO.equals(s)||(a=a.add(this.z.square().multiply(s)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.q),h=a.multiply(t).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(a.square().multiply(a)).mod(this.curve.q),u=r.square().multiply(r).shiftLeft(3).mod(this.curve.q);return new at(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(h),u)},at.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,r=i.multiply(new w("3")),n=this.negate(),s=this,a=this.curve.q.subtract(t),o=a.multiply(new w("3")),h=new at(this.curve,this.x,this.y),u=h.negate();for(e=r.bitLength()-2;e>0;--e){s=s.twice();var c=r.testBit(e);c!=i.testBit(e)&&(s=s.add(c?this:n))}for(e=o.bitLength()-2;e>0;--e){h=h.twice();var l=o.testBit(e);l!=a.testBit(e)&&(h=h.add(l?h:u))}return s},at.prototype.multiplyTwo=function(t,e,i){var r;r=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var n=this.curve.getInfinity(),s=this.add(e);r>=0;)n=n.twice(),t.testBit(r)?n=i.testBit(r)?n.add(s):n.add(this):i.testBit(r)&&(n=n.add(e)),--r;return n},ot.prototype.getQ=function(){return this.q},ot.prototype.getA=function(){return this.a},ot.prototype.getB=function(){return this.b},ot.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ot.prototype.getInfinity=function(){return this.infinity},ot.prototype.fromBigInteger=function(t){return new st(this.q,t)},ot.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),r=t.substr(e+2,e);return new at(this,this.fromBigInteger(new w(i,16)),this.fromBigInteger(new w(r,16)));default:return null}},st.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},at.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),r=this.getY().toBigInteger(),n=e(i,32);return t?r.isEven()?n.unshift(2):n.unshift(3):(n.unshift(4),n=n.concat(e(r,32))),n},at.decodeFrom=function(t,e){e[0];var i=e.length-1,r=e.slice(1,1+i/2),n=e.slice(1+i/2,1+i);r.unshift(0),n.unshift(0);var s=new w(r),a=new w(n);return new at(t,t.fromBigInteger(s),t.fromBigInteger(a))},at.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,r=e.substr(2,i/2),n=e.substr(2+i/2,i/2),s=new w(r,16),a=new w(n,16);return new at(t,t.fromBigInteger(s),t.fromBigInteger(a))},at.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),r=i.square().subtract(this.x).subtract(t.x),n=i.multiply(this.x.subtract(r)).subtract(this.y);return new at(this.curve,r,n)},at.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(w.valueOf(2)),e=this.curve.fromBigInteger(w.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),r=i.square().subtract(this.x.multiply(t)),n=i.multiply(this.x.subtract(r)).subtract(this.y);return new at(this.curve,r,n)},at.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,r=i.multiply(new w("3")),n=this.negate(),s=this;for(e=r.bitLength()-2;e>0;--e){s=s.twice();var a=r.testBit(e);a!=i.testBit(e)&&(s=s.add2D(a?this:n))}return s},at.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),r=this.curve.getB().toBigInteger(),n=this.curve.getQ(),s=e.multiply(e).mod(n),a=t.multiply(t).multiply(t).add(i.multiply(t)).add(r).mod(n);return s.equals(a)},at.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},at.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(w.ONE)<0||e.compareTo(t.subtract(w.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(w.ONE)<0||i.compareTo(t.subtract(w.ONE))>0)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};var ht=function(){var t=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"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function r(t,e,r){return e?i[e]:String.fromCharCode(parseInt(r,16))}var n=new String(""),s=Object.hasOwnProperty;return function(i,a){var o,h,u=i.match(t),c=u[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var f=[o],d=1-l,g=u.length;d=0;)delete i[r[h]]}return a.call(t,e,i)};o=v({"":o},"")}return o}}();void 0!==ut&&ut||(ut={}),void 0!==ut.asn1&&ut.asn1||(ut.asn1={}),ut.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var r="",n=0;n15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=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.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ut.asn1.DERAbstractString=function(t){ut.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=Et(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))},n.lang.extend(ut.asn1.DERAbstractString,ut.asn1.ASN1Object),ut.asn1.DERAbstractTime=function(t){ut.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,i){var r=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var a=s+r(String(n.getMonth()+1),2)+r(String(n.getDate()),2)+r(String(n.getHours()),2)+r(String(n.getMinutes()),2)+r(String(n.getSeconds()),2);if(!0===i){var o=n.getMilliseconds();if(0!=o){var h=r(String(o),3);a=a+"."+(h=h.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=vt(t)},this.setByDateValue=function(t,e,i,r,n,s){var a=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},n.lang.extend(ut.asn1.DERAbstractTime,ut.asn1.ASN1Object),ut.asn1.DERAbstractStructured=function(t){ut.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)},n.lang.extend(ut.asn1.DERAbstractStructured,ut.asn1.ASN1Object),ut.asn1.DERBoolean=function(){ut.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},n.lang.extend(ut.asn1.DERBoolean,ut.asn1.ASN1Object),ut.asn1.DERInteger=function(t){ut.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ut.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new w(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},n.lang.extend(ut.asn1.DERInteger,ut.asn1.ASN1Object),ut.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ut.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ut.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||7n.length&&(n=r[i]);return(t=t.replace(n,"::")).slice(1,-1)}function jt(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Ot(t):t;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}}function Lt(t){for(var e=encodeURIComponent(t),i="",r=0;r"7"?"00"+t:t}function Kt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var r=parseInt(t);if(r<0||255=r)break}return a},ft.getNthChildIdx=function(t,e,i){return ft.getChildIdx(t,e)[i]},ft.getIdxbyList=function(t,e,i,r){var n,s,a=ft;return 0==i.length?void 0!==r&&t.substr(e,2)!==r?-1:e:(n=i.shift())>=(s=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,s[n],i,r)},ft.getIdxbyListEx=function(t,e,i,r){var n,s,a=ft;if(0==i.length)return void 0!==r&&t.substr(e,2)!==r?-1:e;n=i.shift(),s=a.getChildIdx(t,e);for(var o=0,h=0;h=t.length?null:n.getTLV(t,s)},ft.getTLVbyListEx=function(t,e,i,r){var n=ft,s=n.getIdxbyListEx(t,e,i,r);return-1==s?null:n.getTLV(t,s)},ft.getVbyList=function(t,e,i,r,n){var s,a,o=ft;return-1==(s=o.getIdxbyList(t,e,i,r))||s>=t.length?null:(a=o.getV(t,s),!0===n&&(a=a.substr(2)),a)},ft.getVbyListEx=function(t,e,i,r,n){var s,a,o=ft;return-1==(s=o.getIdxbyListEx(t,e,i,r))?null:(a=o.getV(t,s),"03"==t.substr(s,2)&&!1!==n&&(a=a.substr(2)),a)},ft.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],r=t.substr(0,2),n=parseInt(r,16);i[0]=new String(Math.floor(n/40)),i[1]=new String(n%40);for(var s=t.substr(2),a=[],o=0;o0&&(c=c+"."+h.join(".")),c},ft.dump=function(t,e,i,r){var n=ft,s=n.getV,a=n.dump,o=n.getChildIdx,h=t;t instanceof ut.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===r&&(r="");var c,l=e.ommit_long_octet;if("01"==(c=h.substr(i,2)))return"00"==(f=s(h,i))?r+"BOOLEAN FALSE\n":r+"BOOLEAN TRUE\n";if("02"==c)return r+"INTEGER "+u(f=s(h,i),l)+"\n";if("03"==c){var f=s(h,i);if(n.isASN1HEX(f.substr(2))){var d=r+"BITSTRING, encapsulates\n";return d+=a(f.substr(2),e,0,r+" ")}return r+"BITSTRING "+u(f,l)+"\n"}if("04"==c){f=s(h,i);if(n.isASN1HEX(f)){d=r+"OCTETSTRING, encapsulates\n";return d+=a(f,e,0,r+" ")}return r+"OCTETSTRING "+u(f,l)+"\n"}if("05"==c)return r+"NULL\n";if("06"==c){var g=s(h,i),p=ut.asn1.ASN1Util.oidHexToInt(g),v=ut.asn1.x509.OID.oid2name(p),y=p.replace(/\./g," ");return""!=v?r+"ObjectIdentifier "+v+" ("+y+")\n":r+"ObjectIdentifier ("+y+")\n"}if("0a"==c)return r+"ENUMERATED "+parseInt(s(h,i))+"\n";if("0c"==c)return r+"UTF8String '"+wt(s(h,i))+"'\n";if("13"==c)return r+"PrintableString '"+wt(s(h,i))+"'\n";if("14"==c)return r+"TeletexString '"+wt(s(h,i))+"'\n";if("16"==c)return r+"IA5String '"+wt(s(h,i))+"'\n";if("17"==c)return r+"UTCTime "+wt(s(h,i))+"\n";if("18"==c)return r+"GeneralizedTime "+wt(s(h,i))+"\n";if("1a"==c)return r+"VisualString '"+wt(s(h,i))+"'\n";if("1e"==c)return r+"BMPString '"+wt(s(h,i))+"'\n";if("30"==c){if("3000"==h.substr(i,4))return r+"SEQUENCE {}\n";d=r+"SEQUENCE\n";var m=e;if((2==(E=o(h,i)).length||3==E.length)&&"06"==h.substr(E[0],2)&&"04"==h.substr(E[E.length-1],2)){v=n.oidname(s(h,E[0]));var x=JSON.parse(JSON.stringify(e));x.x509ExtName=v,m=x}for(var S=0;S31)&&(128==(192&i)&&(31&i)==r))}catch(t){return!1}},ft.isASN1HEX=function(t){var e=ft;if(t.length%2==1)return!1;var i=e.getVblen(t,0),r=t.substr(0,2),n=e.getL(t,0);return t.length-r.length-n.length==2*i},ft.checkStrictDER=function(t,e,i,r,n){var s=ft;if(void 0===i){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!ut.lang.String.isHex(t))throw new Error("not hex string");i=t.length,n=(r=t.length/2)<128?1:Math.ceil(r.toString(16))+1}if(s.getL(t,e).length>2*n)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(a>r)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);var u=t.substr(e,2);if("02"===u){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var l=s.getVblen(t,e),f=0,d=s.getChildIdx(t,e),g=0;g0&&t.push(new r({tag:"a3",obj:new u(e.ext)})),new ut.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},n.lang.extend(ut.asn1.x509.TBSCertificate,ut.asn1.ASN1Object),ut.asn1.x509.Extensions=function(t){ut.asn1.x509.Extensions.superclass.constructor.call(this);var e=ut.asn1,i=e.DERSequence,r=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e-1&&t.push(new r({int:this.pathLen}));var e=new n({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},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))},n.lang.extend(ut.asn1.x509.BasicConstraints,ut.asn1.x509.Extension),ut.asn1.x509.CRLDistributionPoints=function(t){ut.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ut.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var r=[],n=0;n0&&t.push(new i({array:e}))}return new i({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},n.lang.extend(ut.asn1.x509.PolicyInformation,ut.asn1.ASN1Object),ut.asn1.x509.PolicyQualifierInfo=function(t){ut.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=ut.asn1,i=e.DERSequence,r=e.DERIA5String,n=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new i({array:[new n({oid:"1.3.6.1.5.5.7.2.1"}),new r({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new i({array:[new n({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},n.lang.extend(ut.asn1.x509.PolicyQualifierInfo,ut.asn1.ASN1Object),ut.asn1.x509.UserNotice=function(t){ut.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=ut.asn1.DERSequence,i=(ut.asn1.DERInteger,ut.asn1.x509.DisplayText),r=ut.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new r(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new i(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},n.lang.extend(ut.asn1.x509.UserNotice,ut.asn1.ASN1Object),ut.asn1.x509.NoticeReference=function(t){ut.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=ut.asn1.DERSequence,i=ut.asn1.DERInteger,r=ut.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new r(this.params.org)),void 0!==this.params.noticenum){for(var n=[],s=this.params.noticenum,a=0;a0)for(var t=0;t0;n++){var s=e.shift();if(!0===i){var a=(r.pop()+","+s).replace(/\\,/g,",");r.push(a),i=!1}else r.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(r=r.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+r.join("/")},ut.asn1.x509.X500Name.ldapToOneline=function(t){return ut.asn1.x509.X500Name.ldapToCompat(t)},ut.asn1.x509.RDN=function(t){ut.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ut.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 ut.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=ut.asn1.x509.RDN.parseString(t),i=0;i0)for(var t=0;t0;n++){var s=e.shift();if(!0===i){var a=(r.pop()+"+"+s).replace(/\\\+/g,"+");r.push(a),i=!1}else r.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var o=!1,h=[];for(n=0;r.length>0;n++){s=r.shift();if(!0===o){var u=h.pop();if(s.match(/"$/)){a=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(a),o=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(o=!0)}return h},ut.asn1.x509.AttributeTypeAndValue=function(t){ut.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=ut,i=e.asn1,r=i.DERSequence,n=i.DERUTF8String,s=i.DERPrintableString,a=i.DERTeletexString,o=i.DERIA5String,h=i.DERVisibleString,u=i.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);var i=t.match(/^([^=]+)=(.+)$/);if(!i)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(i[1],i[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,i=this.sRule;return"prn"===i?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===i?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,i){void 0!==i&&(this.sRule=i),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new n({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.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=ut.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),i=new r({array:[t,e]});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},n.lang.extend(ut.asn1.x509.AttributeTypeAndValue,ut.asn1.ASN1Object),ut.asn1.x509.SubjectPublicKeyInfo=function(t){ut.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ut,i=e.asn1,r=i.DERInteger,n=i.DERBitString,s=i.DERObjectIdentifier,a=i.DERSequence,o=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof rt){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new n({hex:"00"+e})}}catch(t){}try{if(t instanceof ut.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new n({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ut.crypto.DSA){i=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var a=new r({bigint:t.y});this.asn1SubjPKey=new n({hex:"00"+a.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},n.lang.extend(ut.asn1.x509.SubjectPublicKeyInfo,ut.asn1.ASN1Object),ut.asn1.x509.Time=function(t){ut.asn1.x509.Time.superclass.constructor.call(this);var e=ut.asn1,i=e.DERUTCTime,r=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new r(this.timeParams):"utc"==this.type?new i:new r,this.TLV=t.getEncodedHex(),this.TLV},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)},n.lang.extend(ut.asn1.x509.Time,ut.asn1.ASN1Object),ut.asn1.x509.AlgorithmIdentifier=function(t){ut.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ut.asn1,i=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var r in i)r===this.nameAlg&&(t=i[r]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var n=[this.asn1Alg];null!==this.asn1Params&&n.push(this.asn1Params);var s=new e.DERSequence({array:n});return this.hTLV=s.getEncodedHex(),this.hTLV},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);var r=this.nameAlg.toLowerCase();"withdsa"!==r.substr(-7,7)&&"withecdsa"!==r.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},n.lang.extend(ut.asn1.x509.AlgorithmIdentifier,ut.asn1.ASN1Object),ut.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},ut.asn1.x509.GeneralName=function(t){ut.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ut.asn1,r=(i.DERSequence,i.DEROctetString),n=i.DERIA5String,s=i.DERTaggedObject,a=i.ASN1Object,o=i.x509.X500Name,h=Tt;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new n({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new n({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new n({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i="string"==typeof t.dn?new o({str:t.dn}):t.dn instanceof ut.asn1.x509.X500Name?t.dn:new o(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new o({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new zt).hex=u;var c=f.getIssuerHex();(i=new a).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new zt).hex=u;c=f.getSubjectHex();(i=new a).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Kt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Nt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new r({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},n.lang.extend(ut.asn1.x509.GeneralName,ut.asn1.ASN1Object),ut.asn1.x509.GeneralNames=function(t){ut.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ut.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new r({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var n=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&n.push(e);var a=new i.DERSequence({array:n});return this.hTLV=a.getEncodedHex(),this.hTLV}},n.lang.extend(ut.asn1.cms.SignerInfo,ut.asn1.ASN1Object),ut.asn1.cms.EncapsulatedContentInfo=function(t){var e=ut.asn1,i=e.DERTaggedObject,r=e.DERSequence,n=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new n({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new n({oid:t}):this.dEContentType=new n({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=Et(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=Et(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var n=new r({array:e});return this.hTLV=n.getEncodedHex(),this.hTLV}},n.lang.extend(ut.asn1.cms.EncapsulatedContentInfo,ut.asn1.ASN1Object),ut.asn1.cms.ContentInfo=function(t){var e=ut.asn1,i=e.DERTaggedObject,r=e.DERSequence,n=e.x509;ut.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=n.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new r({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},n.lang.extend(ut.asn1.cms.ContentInfo,ut.asn1.ASN1Object),ut.asn1.cms.SignedData=function(t){var e=ut.asn1,i=e.ASN1Object,r=e.DERInteger,n=e.DERSet,s=e.DERSequence,a=e.DERTaggedObject,o=e.cms,h=o.EncapsulatedContentInfo,u=o.SignerInfo,c=o.ContentInfo,l=e.x509.AlgorithmIdentifier;ut.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new r({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Tt(t),r=new i;r.hTLV=e,this.certificateList.push(r)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new n({array:this.certificateList});this.dCerts=new a({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&o.push(this.dCerts);var u=new n({array:this.signerInfoList});o.push(u);var c=new s({array:o});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Dt(this.getContentInfoEncodedHex(),"CMS")}},n.lang.extend(ut.asn1.cms.SignedData,ut.asn1.ASN1Object),ut.asn1.cms.CMSUtil=new function(){},ut.asn1.cms.CMSUtil.newSignedData=function(t){var e=ut.asn1,i=e.cms,r=i.SignerInfo,n=i.SignedData,s=i.SigningTime,a=i.SigningCertificate,o=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new n;if(u.dEncapContentInfo.setContentValue(t.content),"boolean"==typeof t.detached&&(u.dEncapContentInfo.isDetached=t.detached),"object"==typeof t.certs)for(var c=0;cn)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",a="00"+r,o="",h=n-s.length-a.length,u=0;u=0)return!1;if(r.compareTo(i.ONE)<0||r.compareTo(s)>=0)return!1;var o=r.modInverse(s),h=t.multiply(o).mod(s),u=e.multiply(o).mod(s);return a.multiply(h).add(n.multiply(u)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),r=e.toByteArraySigned(),n=[];return n.push(2),n.push(i.length),(n=n.concat(i)).push(2),n.push(r.length),(n=n.concat(r)).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(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var r=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:i.fromByteArrayUnsigned(r),s:i.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var r=this.ecparams.n;return{r:i.fromByteArrayUnsigned(t.slice(1,33)).mod(r),s:i.fromByteArrayUnsigned(t.slice(33,65)).mod(r),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===u(t))throw new Error("not ASN.1 hex string");var e,i,r;try{e=h(t,0,["[0]",0],"06"),i=h(t,0,[1],"04");try{r=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(r),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var i,r,n;try{h(t,0,[1,0],"06"),i=h(t,0,[1,1],"06"),r=h(t,0,[2,0,1],"04");try{n=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(i),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var i,r;try{h(t,0,[0,0],"06"),i=h(t,0,[0,1],"06"),r=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(r)},this.readCertPubKeyHex=function(t,i){if(!1===u(t))throw new e("not ASN.1 hex string");var r,n;try{r=h(t,0,[0,5,0,1],"06"),n=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("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))},ut.crypto.ECDSA.parseSigHex=function(t){var e=ut.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new w(e.r,16),s:new w(e.s,16)}},ut.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ft,i=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");var n=i(t,0);if(2!=n.length)throw new Error("signature shall have two elements");var s=n[0],a=n[1];if("02"!=t.substr(s,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:r(t,s),s:r(t,a)}},ut.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ut.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,r=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),i.length%32==30&&(i="00"+i),r.length%32==30&&(r="00"+r),i.length%32!=0)throw"unknown ECDSA sig r length error";if(r.length%32!=0)throw"unknown ECDSA sig s length error";return i+r},ut.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ut.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ut.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new w(t,16),r=new w(e,16);return ut.crypto.ECDSA.biRSSigToASN1Sig(i,r)},ut.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ut.asn1,r=new i.DERInteger({bigint:t}),n=new i.DERInteger({bigint:e});return new i.DERSequence({array:[r,n]}).getEncodedHex()},ut.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":-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":null},void 0!==ut&&ut||(ut={}),void 0!==ut.crypto&&ut.crypto||(ut.crypto={}),ut.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new w(t,16)}this.getByName=function(i){var r=i;if(void 0!==e[r]&&(r=e[i]),void 0!==t[r])return t[r];throw"unregistered EC curve name: "+r},this.regist=function(r,n,s,a,o,h,u,c,l,f,d,g){t[r]={};var p=i(s),v=i(a),y=i(o),m=i(h),x=i(u),S=new ot(p,v,y),E=S.decodePointHex("04"+c+l);t[r].name=r,t[r].keylen=n,t[r].curve=S,t[r].G=E,t[r].n=m,t[r].h=x,t[r].oid=d,t[r].info=g;for(var w=0;w1?new w(r,16):null,u=new w(n,16),this.setPrivate(s,a,o,h,u)},this.setPublic=function(t,e,i,r){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=r,this.x=null},this.setPublicHex=function(t,e,i,r){var n,s,a,o;n=new w(t,16),s=new w(e,16),a=new w(i,16),o=new w(r,16),this.setPublic(n,s,a,o)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,r=this.g,n=(this.y,this.x),s=ut.crypto.Util.getRandomBigIntegerMinToMax(w.ONE.add(w.ONE),i.subtract(w.ONE)),a=new w(t.substr(0,i.bitLength()/4),16),o=r.modPow(s,e).mod(i),h=s.modInverse(i).multiply(a.add(n.multiply(o))).mod(i);return ut.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,r=this.q,n=this.g,s=this.y,a=this.parseASN1Signature(e),o=a[0],h=a[1],u=new w(t.substr(0,r.bitLength()/4),16);if(w.ZERO.compareTo(o)>0||o.compareTo(r)>0)throw"invalid DSA signature";if(w.ZERO.compareTo(h)>=0||h.compareTo(r)>0)throw"invalid DSA signature";var c=h.modInverse(r),l=u.multiply(c).mod(r),f=o.multiply(c).mod(r);return 0==n.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(r).compareTo(o)},this.parseASN1Signature=function(t){try{return[new r(e(t,0,[0],"02"),16),new r(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var r,n,s,a,o;if(!1===i(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[1],"02"),n=e(t,0,[2],"02"),s=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(r,n,s,a,o)},this.readPKCS8PrvKeyHex=function(t){var r,n,s,a;if(!1===i(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[1,1,0],"02"),n=e(t,0,[1,1,1],"02"),s=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(r,n,s,null,a)},this.readPKCS8PubKeyHex=function(t){var r,n,s,a;if(!1===i(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[0,1,0],"02"),n=e(t,0,[0,1,1],"02"),s=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(r,n,s,a)},this.readCertPubKeyHex=function(t,r){var n,s,a,o;if(!1===i(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,5,0,1,0],"02"),s=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(n,s,a,o)}};var _t=function(){var t=function(t,i,r){return e(v.AES,t,i,r)},e=function(t,e,i,r){var n=v.enc.Hex.parse(e),s=v.enc.Hex.parse(i),a=v.enc.Hex.parse(r),o={};o.key=s,o.iv=a,o.ciphertext=n;var h=t.decrypt(o,s,{iv:a});return v.enc.Hex.stringify(h)},i=function(t,e,i){return r(v.AES,t,e,i)},r=function(t,e,i,r){var n=v.enc.Hex.parse(e),s=v.enc.Hex.parse(i),a=v.enc.Hex.parse(r),o=t.encrypt(n,s,{iv:a}),h=v.enc.Hex.parse(o.toString());return v.enc.Base64.stringify(h)},n={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,r){return e(v.TripleDES,t,i,r)},eproc:function(t,e,i){return r(v.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,r){return e(v.DES,t,i,r)},eproc:function(t,e,i){return r(v.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var r=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));r&&(e.type=r[1]);var n=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),s=1);var a=t.indexOf("-----END");if(-1!=n&&-1!=a){var o=t.substring(n+2*s,a-s);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,i){for(var r=i.substring(0,16),s=v.enc.Hex.parse(r),a=v.enc.Utf8.parse(e),o=n[t].keylen+n[t].ivlen,h="",u=null;;){var c=v.algo.MD5.create();if(null!=u&&c.update(u),c.update(a),c.update(s),u=c.finalize(),(h+=v.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=h.substr(0,2*n[t].keylen),l.ivhex=h.substr(2*n[t].keylen,2*n[t].ivlen),l},o=function(t,e,i,r){var s=v.enc.Base64.parse(t),a=v.enc.Hex.stringify(s);return(0,n[e].proc)(a,i,r)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return a(t,e,i)},decryptKeyB64:function(t,e,i,r){return o(t,e,i,r)},getDecryptedKeyHex:function(t,e){var i=s(t),r=(i.type,i.cipher),n=i.ivsalt,h=i.data,u=a(r,e,n).keyhex;return o(h,r,u,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,r,s){var o="";if(void 0!==r&&null!=r||(r="AES-256-CBC"),void 0===n[r])throw"KEYUTIL unsupported algorithm: "+r;void 0!==s&&null!=s||(s=function(t){var e=v.lib.WordArray.random(t);return v.enc.Hex.stringify(e)}(n[r].ivlen).toUpperCase());var h=function(t,e,i,r){return(0,n[e].eproc)(t,i,r)}(e,r,a(r,i,s).keyhex,s);o="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+r+","+s+"\r\n",o+="\r\n",o+=h.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=ft,i=e.getChildIdx,r=e.getV,n={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;n.ciphertext=r(t,s[1]);var a=i(t,s[0]);if(2!=a.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+a.length;if("2a864886f70d01050d"!=r(t,a[0]))throw"this only supports pkcs5PBES2";var o=i(t,a[1]);if(2!=a.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+o.length;var h=i(t,o[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=r(t,h[0]))throw"this only supports TripleDES";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=r(t,h[1]);var u=i(t,o[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=r(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;n.pbkdf2Salt=r(t,c[0]);var l=r(t,c[1]);try{n.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return n},getPBKDF2KeyHexFromParam:function(t,e){var i=v.enc.Hex.parse(t.pbkdf2Salt),r=t.pbkdf2Iter,n=v.PBKDF2(e,i,{keySize:6,iterations:r});return v.enc.Hex.stringify(n)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Tt(t,"ENCRYPTED PRIVATE KEY"),r=this.parseHexOfEncryptedPKCS8(i),n=_t.getPBKDF2KeyHexFromParam(r,e),s={};s.ciphertext=v.enc.Hex.parse(r.ciphertext);var a=v.enc.Hex.parse(n),o=v.enc.Hex.parse(r.encryptionSchemeIV),h=v.TripleDES.decrypt(s,a,{iv:o});return v.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=ft,i=e.getChildIdx,r=e.getV,n={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var a=i(t,s[1]);if(2!=a.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 private key(code:005)";if(n.algoid=r(t,a[0]),"06"==t.substr(a[1],2)&&(n.algparam=r(t,a[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return n.keyidx=e.getVidx(t,s[2]),n},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Tt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new rt;else if("2a8648ce380401"==i.algoid)e=new ut.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ut.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=ft.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new rt;else if("2a8648ce380401"===i)e=new ut.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ut.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ft,i=e.getChildIdx,r=e.getV,n={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(n.n=r(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return n.e=r(t,s[1]),n},parsePublicPKCS8Hex:function(t){var e=ft,i=e.getChildIdx,r=e.getV,n={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var a=s[0];if("30"!=t.substr(a,2))throw"malformed PKCS8 public key(code:001)";var o=i(t,a);if(2!=o.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 public key(code:003)";if(n.algoid=r(t,o[0]),"06"==t.substr(o[1],2)?n.algparam=r(t,o[1]):"30"==t.substr(o[1],2)&&(n.algparam={},n.algparam.p=e.getVbyList(t,o[1],[0],"02"),n.algparam.q=e.getVbyList(t,o[1],[1],"02"),n.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return n.key=r(t,s[1]).substr(2),n}}}();_t.getKey=function(t,e,i){var r=(v=ft).getChildIdx,n=(v.getV,v.getVbyList),s=ut.crypto,a=s.ECDSA,o=s.DSA,h=rt,u=Tt,c=_t;if(void 0!==h&&t instanceof h)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;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(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new o).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new o).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(St(t.n),St(t.e)),D;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(D=new h).setPrivateEx(St(t.n),St(t.e),St(t.d),St(t.p),St(t.q),St(t.dp),St(t.dq),St(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(St(t.n),St(t.e),St(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(I=new a({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+St(t.x)).slice(-l)+("0000000000"+St(t.y)).slice(-l);return I.setPublicKeyHex(f),I}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(I=new a({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+St(t.x)).slice(-l)+("0000000000"+St(t.y)).slice(-l);var d=("0000000000"+St(t.d)).slice(-l);return I.setPublicKeyHex(f),I.setPrivateKeyHex(d),I}if("pkcs5prv"===i){var g,p=t,v=ft;if(9===(g=r(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new o).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new a).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return zt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return zt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var y=Tt(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(y)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=n(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),S=n(R,0,[2],"02"),E=n(R,0,[3],"02"),F=n(R,0,[4],"02"),b=n(R,0,[5],"02");return(D=new o).setPrivate(new w(x,16),new w(S,16),new w(E,16),new w(F,16),new w(b,16)),D}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){m=u(t,"EC PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),C=new rt;return C.readPKCS5PrvKeyHex(A),C}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I,D=n(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=n(R,0,[2,0],"06"),P=n(R,0,[3,0],"03").substr(2);if(void 0===ut.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(I=new a({curve:ut.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),I.setPrivateKeyHex(D),I.isPublic=!1,I}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;x=n(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),S=n(R,0,[2],"02"),E=n(R,0,[3],"02"),F=n(R,0,[4],"02"),b=n(R,0,[5],"02");return(D=new o).setPrivate(new w(x,16),new w(S,16),new w(E,16),new w(F,16),new w(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},_t.generateKeypair=function(t,e){if("RSA"==t){var i=e;(a=new rt).generate(i,"10001"),a.isPrivate=!0,a.isPublic=!0;var r=new rt,n=a.n.toString(16),s=a.e.toString(16);return r.setPublic(n,s),r.isPrivate=!1,r.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=r,o}if("EC"==t){var a,o,h=e,u=new ut.crypto.ECDSA({curve:h}).generateKeyPairHex();return(a=new ut.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),a.setPrivateKeyHex(u.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(r=new ut.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),r.isPrivate=!1,r.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=r,o}throw"unknown algorithm: "+t},_t.getPEM=function(t,e,i,r,n,s){var a=ut,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,f=a.crypto,d=f.DSA,g=f.ECDSA,p=rt;function y(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 m(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((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Dt(F=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Dt(F=y(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var S=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Dt(S,"EC PARAMETERS"),w+=Dt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Dt(F=x(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var F=y(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",F,i,r,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){F=m(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",F,i,r,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){F=x(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",F,i,r,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=v.lib.WordArray.random(8),r=v.lib.WordArray.random(8),n=v.PBKDF2(e,i,{keySize:6,iterations:100}),s=v.enc.Hex.parse(t),a=v.TripleDES.encrypt(s,n,{iv:r})+"",o={};return o.ciphertext=a,o.pbkdf2Salt=v.enc.Hex.stringify(i),o.pbkdf2Iter=100,o.encryptionSchemeAlg="DES-EDE3-CBC",o.encryptionSchemeIV=v.enc.Hex.stringify(r),o};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var C=y(t).getEncodedHex();F=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===i||null==i?Dt(F,"PRIVATE KEY"):Dt(E=b(F,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){C=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),F=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===i||null==i?Dt(F,"PRIVATE KEY"):Dt(E=b(F,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){C=new u({bigint:t.x}).getEncodedHex(),F=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===i||null==i?Dt(F,"PRIVATE KEY"):Dt(E=b(F,i),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},_t.getKeyFromCSRPEM=function(t){var e=Tt(t,"CERTIFICATE REQUEST");return _t.getKeyFromCSRHex(e)},_t.getKeyFromCSRHex=function(t){var e=_t.parseCSRHex(t);return _t.getKey(e.p8pubkeyhex,null,"pkcs8pub")},_t.parseCSRHex=function(t){var e=ft,i=e.getChildIdx,r=e.getTLV,n={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var a=i(s,0);if(a.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(a[0],2))throw"malformed CSR(code:003)";var o=i(s,a[0]);if(o.length<3)throw"malformed CSR(code:004)";return n.p8pubkeyhex=r(s,o[2]),n},_t.getKeyID=function(t){var e=_t,i=ft;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var r=Tt(e.getPEM(t)),n=i.getIdxbyList(r,0,[1]),s=i.getV(r,n).substring(2);return ut.crypto.Util.hashHex(s,"sha1")},_t.getJWKFromKey=function(t){var e={};if(t instanceof rt&&t.isPrivate)return e.kty="RSA",e.n=xt(t.n.toString(16)),e.e=xt(t.e.toString(16)),e.d=xt(t.d.toString(16)),e.p=xt(t.p.toString(16)),e.q=xt(t.q.toString(16)),e.dp=xt(t.dmp1.toString(16)),e.dq=xt(t.dmq1.toString(16)),e.qi=xt(t.coeff.toString(16)),e;if(t instanceof rt&&t.isPublic)return e.kty="RSA",e.n=xt(t.n.toString(16)),e.e=xt(t.e.toString(16)),e;if(t instanceof ut.crypto.ECDSA&&t.isPrivate){if("P-256"!==(r=t.getShortNISTPCurveName())&&"P-384"!==r)throw"unsupported curve name for JWT: "+r;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=r,e.x=xt(i.x),e.y=xt(i.y),e.d=xt(t.prvKeyHex),e}if(t instanceof ut.crypto.ECDSA&&t.isPublic){var r;if("P-256"!==(r=t.getShortNISTPCurveName())&&"P-384"!==r)throw"unsupported curve name for JWT: "+r;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=r,e.x=xt(i.x),e.y=xt(i.y),e}throw"not supported key object"},rt.getPosArrayOfChildrenFromHex=function(t){return ft.getChildIdx(t,0)},rt.getHexValueArrayOfChildrenFromHex=function(t){var e,i=ft.getV,r=i(t,(e=rt.getPosArrayOfChildrenFromHex(t))[0]),n=i(t,e[1]),s=i(t,e[2]),a=i(t,e[3]),o=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(r,n,s,a,o,h,u,c,l),e},rt.prototype.readPrivateKeyFromPEMString=function(t){var e=Tt(t),i=rt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},rt.prototype.readPKCS5PrvKeyHex=function(t){var e=rt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},rt.prototype.readPKCS8PrvKeyHex=function(t){var e,i,r,n,s,a,o,h,u=ft,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"),i=c(t,0,[2,0,2],"02"),r=c(t,0,[2,0,3],"02"),n=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,i,r,n,s,a,o,h)},rt.prototype.readPKCS5PubKeyHex=function(t){var e=ft,i=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var r=e.getChildIdx(t,0);if(2!==r.length||"02"!==t.substr(r[0],2)||"02"!==t.substr(r[1],2))throw new Error("wrong hex for PKCS#5 public key");var n=i(t,r[0]),s=i(t,r[1]);this.setPublic(n,s)},rt.prototype.readPKCS8PubKeyHex=function(t){var e=ft;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");var i=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},rt.prototype.readCertPubKeyHex=function(t,e){var i,r;(i=new zt).readCertHex(t),r=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(r)};var Mt=new RegExp("[^0-9a-f]","gi");function kt(t,e){for(var i="",r=e/4-t.length,n=0;n>24,(16711680&n)>>16,(65280&n)>>8,255&n])))),n+=1;return r}function qt(t){for(var e in ut.crypto.Util.DIGESTINFOHEAD){var i=ut.crypto.Util.DIGESTINFOHEAD[e],r=i.length;if(t.substring(0,r)==i)return[e,t.substring(r)]}return[]}function zt(){var t,e=ft,i=e.getChildIdx,r=e.getV,n=e.getTLV,s=e.getVbyList,a=e.getVbyListEx,o=e.getTLVbyList,h=e.getTLVbyListEx,u=e.getIdxbyList,c=e.getIdxbyListEx,l=e.getVidx,f=e.oidname,d=e.hextooidstr,g=zt,p=Tt;try{t=ut.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(){return null===this.hex||0!==this.version?this.version:"a003020102"!==o(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(e){for(var i in t)if(e===t[i])return i;return f(a(e,0,[0],"06"))},this.getIssuer=function(){var t={};return t.array=this.getX500Name(this.getIssuerHex()),t.str=this.getIssuerString(),t},this.getIssuerHex=function(){return o(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return g.hex2dn(this.getIssuerHex())},this.getSubject=function(){var t={};return t.array=this.getX500Name(this.getSubjectHex()),t.str=this.getSubjectString(),t},this.getSubjectHex=function(){return o(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return g.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=s(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=s(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return e.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return u(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return u(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return _t.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=o(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),i=this.getSignatureValueHex(),r=o(this.hex,0,[0],"30"),n=new ut.crypto.Signature({alg:e});return n.init(t),n.updateHex(r),n.verify(i)},this.parseExt=function(t){var n,a,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;n=u(o,0,[0,7,0],"30"),a=i(o,n)}else{o=Tt(t);var h=u(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=r(o,h))return void(this.aExtInfo=new Array);n=u(o,0,[0,3,0,1,0],"30"),a=i(o,n),this.hex=o}this.aExtInfo=new Array;for(var c=0;c0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=c(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=i(t,0),s=0;s0&&(u=new Array(i),(new tt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=Ft(h(bt("\0\0\0\0\0\0\0\0"+n+u))),l=[];for(r=0;r>8*o-a&255;for(g[0]&=~p,r=0;rthis.n.bitLength())return 0;var r=qt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==r.length)return!1;var n=r[0];return r[1]==function(t){return ut.crypto.Util.hashString(t,n)}(t)},rt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=et(e,16);if(i.bitLength()>this.n.bitLength())return 0;var r=qt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==r.length)return!1;r[0];return r[1]==t},rt.prototype.verifyPSS=function(t,e,i,r){var n,s=(n=bt(t),ut.crypto.Util.hashHex(n,i));return void 0===r&&(r=-1),this.verifyWithMessageHashPSS(s,e,i,r)},rt.prototype.verifyWithMessageHashPSS=function(t,e,i,r){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var n,s=new w(e,16),a=function(t){return ut.crypto.Util.hashHex(t,i)},o=Ft(t),h=o.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===r||void 0===r)r=h;else if(-2===r)r=c-h-2;else if(r<-2)throw new Error("invalid salt length");if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var p=Ut(d,f.length,a),v=[];for(n=0;n0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=_t.getKey(e)),!("RS"!=v&&"PS"!=v||e instanceof r))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==v&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var y=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(y=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:y,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=y.indexOf("withECDSA")){var x,S=null;try{S=h.concatSigToASN1Sig(d)}catch(t){return!1}return(x=new c({alg:y})).init(e),x.updateString(f),x.verify(S)}return(x=new c({alg:y})).init(e),x.updateString(f),x.verify(d)},ut.jws.JWS.parse=function(t){var e,i,r,n=t.split("."),s={};if(2!=n.length&&3!=n.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=n[0],i=n[1],3==n.length&&(r=n[2]),s.headerObj=ut.jws.JWS.readSafeJSONString(lt(e)),s.payloadObj=ut.jws.JWS.readSafeJSONString(lt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=lt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==r&&(s.sigHex=St(r)),s},ut.jws.JWS.verifyJWT=function(t,e,i){var r=ut.jws,n=r.JWS,s=n.readSafeJSONString,a=n.inArray,o=n.includedArray,h=t.split("."),u=h[0],c=h[1],l=(St(h[2]),s(lt(u))),f=s(lt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!a(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!a(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!a(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!o(f.aud,i.aud))return!1;var d=r.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodn&&this.aHeader.pop(),this.aSignature.length>n&&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;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))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}},e.SecureRandom=tt,e.rng_seed_time=Y,e.BigInteger=w,e.RSAKey=rt,e.ECDSA=ut.crypto.ECDSA,e.DSA=ut.crypto.DSA,e.Signature=ut.crypto.Signature,e.MessageDigest=ut.crypto.MessageDigest,e.Mac=ut.crypto.Mac,e.Cipher=ut.crypto.Cipher,e.KEYUTIL=_t,e.ASN1HEX=ft,e.X509=zt,e.X509CRL=function(t){var e=ut.lang.String.isHex,i=ft,r=i.getV,n=i.getTLV,s=i.getVbyList,a=i.getTLVbyList,o=i.getTLVbyListEx,h=i.getIdxbyList,u=i.getIdxbyListEx,c=i.getChildIdx,l=new zt;this.hex=null,this.posSigAlg=null,this.posRevCert=null,this._setPos=function(){var t=h(this.hex,0,[0,0]),e=this.hex.substr(t,2);if("02"==e)this.posSigAlg=1;else{if("30"!=e)throw new Error("malformed 1st item of TBSCertList: "+e);this.posSigAlg=0}var i,r=h(this.hex,0,[0,this.posSigAlg+3]),n=this.hex.substr(r,2);if("17"==n||"18"==n)i=h(this.hex,0,[0,this.posSigAlg+4]),this.posRevCert=null,-1!=i&&"30"==this.hex.substr(i,2)&&(this.posRevCert=this.posSigAlg+4);else if("30"==n)this.posRevCert=this.posSigAlg+3;else{if("a0"!=n)throw new Error("malformed nextUpdate or revCert tag: "+n);this.posRevCert=null}},this.getVersion=function(){return 0==this.posSigAlg?null:parseInt(s(this.hex,0,[0,0],"02"),16)+1},this.getSignatureAlgorithmField=function(){var t=a(this.hex,0,[0,this.posSigAlg],"30");return l.getAlgorithmIdentifierName(t)},this.getIssuer=function(){var t=a(this.hex,0,[0,this.posSigAlg+1],"30"),e={};return e.array=l.getX500Name(t),e},this.getThisUpdate=function(){var t=s(this.hex,0,[0,this.posSigAlg+2]);return result=Ft(t)},this.getNextUpdate=function(){var t=h(this.hex,0,[0,this.posSigAlg+3]),e=this.hex.substr(t,2);return"17"!=e&&"18"!=e?null:Ft(r(this.hex,t))},this.getRevCertArray=function(){if(null==this.posRevCert)return null;for(var t=[],e=h(this.hex,0,[0,this.posRevCert]),i=c(this.hex,e),r=0;re.length&&(i=e.length);for(var r=0;r=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return _(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(r)return _(t).length;e=(""+e).toLowerCase(),r=!0}}function p(t,e,i){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,i);case"utf8":case"utf-8":return C(this,e,i);case"ascii":return I(this,e,i);case"latin1":case"binary":return D(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function y(t,e,i,r,n){if(0===t.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(n)return-1;i=t.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof e&&(e=h.from(e,r)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,r,n);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,r,n);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,r,n){var s,a=1,o=t.length,h=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,o/=2,h/=2,i/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){var c=-1;for(s=i;so&&(i=o-h),s=i;s>=0;s--){for(var l=!0,f=0;fn&&(r=n):r=n;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function A(t,e,i){return 0===e&&i===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,i))}function C(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n239?4:u>223?3:u>191?2:1;if(n+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[n+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[n+1],a=t[n+2],128==(192&s)&&128==(192&a)&&(h=(15&u)<<12|(63&s)<<6|63&a)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[n+1],a=t[n+2],o=t[n+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(h=(15&u)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),n+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",r=0;for(;r0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,r,n){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),e<0||i>t.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&e>=i)return 0;if(r>=n)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(n>>>=0)-(r>>>=0),a=(i>>>=0)-(e>>>=0),o=Math.min(s,a),u=this.slice(r,n),c=t.slice(e,i),l=0;ln)&&(i=n),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return x(this,t,e,i);case"utf8":case"utf-8":return S(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return F(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(t,e,i){var r="";i=Math.min(t.length,i);for(var n=e;nr)&&(i=r);for(var n="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function H(t,e,i,r,n,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError("Index out of range")}function B(t,e,i,r){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(t.length-i,2);n>>8*(r?n:1-n)}function N(t,e,i,r){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(t.length-i,4);n>>8*(r?n:3-n)&255}function O(t,e,i,r,n,s){if(i+r>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function j(t,e,i,r,s){return s||O(t,0,i,4),n.write(t,e,i,r,23,4),i+4}function L(t,e,i,r,s){return s||O(t,0,i,8),n.write(t,e,i,r,52,8),i+8}h.prototype.slice=function(t,e){var i,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(n*=256);)r+=this[t+--e]*n;return r},h.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s=(n*=128)&&(r-=Math.pow(2,8*e)),r},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||R(t,e,this.length);for(var r=e,n=1,s=this[t+--r];r>0&&(n*=256);)s+=this[t+--r]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,r){(t=+t,e|=0,i|=0,r)||H(this,t,e,i,Math.pow(2,8*i)-1,0);var n=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+n]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,r){if(t=+t,e|=0,!r){var n=Math.pow(2,8*i-1);H(this,t,e,i,n-1,-n)}var s=0,a=1,o=0;for(this[e]=255&t;++s>0)-o&255;return e+i},h.prototype.writeIntBE=function(t,e,i,r){if(t=+t,e|=0,!r){var n=Math.pow(2,8*i-1);H(this,t,e,i,n-1,-n)}var s=i-1,a=1,o=0;for(this[e+s]=255&t;--s>=0&&(a*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||H(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return j(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return j(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,r){if(i||(i=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--n)t[n+e]=this[n+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(n=0;n>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!n){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function k(t,e,i,r){for(var n=0;n=e.length||n>=t.length);++n)e[n+i]=t[n];return n}}).call(this,i(6))},,function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],r=e[1];return 3*(i+r)/4-r},e.toByteArray=function(t){var e,i,r=u(t),a=r[0],o=r[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,a,o)),c=0,l=o>0?a-4:a;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===o&&(e=n[t.charCodeAt(i)]<<2|n[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===o&&(e=n[t.charCodeAt(i)]<<10|n[t.charCodeAt(i+1)]<<4|n[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],a=0,o=i-n;ao?o:a+16383));1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return s.join("")};for(var r=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,h=a.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var n,s,a=[],o=e;o>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,r,n){var s,a,o=8*n-r-1,h=(1<>1,c=-7,l=i?n-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=o;c>0;s=256*s+t[e+l],l+=f,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=r;c>0;a=256*a+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),s-=u}return(d?-1:1)*a*Math.pow(2,s-r)},e.write=function(t,e,i,r,n,s){var a,o,h,u=8*s-n-1,c=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,g=r?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),(e+=a+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(a++,h/=2),a+l>=c?(o=0,a=c):a+l>=1?(o=(e*h-1)*Math.pow(2,n),a+=l):(o=e*Math.pow(2,l-1)*Math.pow(2,n),a=0));n>=8;t[i+d]=255&o,d+=g,o/=256,n-=8);for(a=a<0;t[i+d]=255&a,d+=g,a/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},,,,,,,function(t,e,i){"use strict";i.r(e);var r=i(4),n=i(7),s=i(20);i(34);let a,o,h,u,c,l,f,d,g=!1;function p(){d.openIDCredentials?(console.info("Successfully got OpenID credentials."),v()):(console.warn("OpenID credentials request was blocked by user."),document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget")}function v(){document.getElementById("joinButton").onclick=()=>function(){let t;if("openidtoken-jwt"===l){if(!d.openIDCredentials||!d.openIDCredentials.accessToken)return console.warn("Expected to have an OpenID credential, cannot initialize widget."),void(document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget");t=function(){const t={iss:a,sub:a,aud:"https://"+a,room:"*",context:{matrix:{token:d.openIDCredentials.accessToken,room_id:f},user:{avatar:u,name:h}}};return s.KJUR.jws.JWS.sign("HS256",JSON.stringify({alg:"HS256",typ:"JWT"}),JSON.stringify(t),"notused")}()}y(),d&&d.setAlwaysOnScreen(!0);console.warn("[Jitsi Widget] The next few errors about failing to parse URL parameters are fine if they mention 'external_api' or 'jitsi' in the stack. They're just Jitsi Meet trying to parse our fragment values and not recognizing the options.");const e={width:"100%",height:"100%",parentNode:document.querySelector("#jitsiContainer"),roomName:o,interfaceConfigOverwrite:{SHOW_JITSI_WATERMARK:!1,SHOW_WATERMARK_FOR_GUESTS:!1,MAIN_TOOLBAR_BUTTONS:[],VIDEO_LAYOUT_FIT:"height"},jwt:t},i=new JitsiMeetExternalAPI(a,e);h&&i.executeCommand("displayName",h);u&&i.executeCommand("avatarUrl",u);c&&i.executeCommand("email",c);i.on("readyToClose",()=>{y(),d&&d.setAlwaysOnScreen(!1),document.getElementById("jitsiContainer").innerHTML=""})}()}function y(){g=!g,document.getElementById("jitsiContainer").style.visibility=g?"unset":"hidden",document.getElementById("joinButtonContainer").style.visibility=g?"hidden":"unset"}!async function(){try{const t=r.parse(window.location.hash.substring(1)),e=Object.assign({},r.parse(window.location.search.substring(1)),t),i=(t,i=!1)=>{if(!(i||e[t]&&"string"==typeof e[t]))throw new Error(`Expected singular ${t} in query string`);return e[t]},s=i("parentUrl",!0),g=i("widgetId",!0);s&&g&&(d=new n.c(i("parentUrl"),i("widgetId"),[n.a.AlwaysOnScreen]),d.expectingExplicitReady=!0),a=i("conferenceDomain"),o=i("conferenceId"),h=i("displayName",!0),u=i("avatarUrl",!0),c=i("userId"),l=i("auth",!0),f=i("roomId",!0),d?(await d.waitReady(),await d.setAlwaysOnScreen(!1),"openidtoken-jwt"===l?d.requestOpenIDCredentials(p):v()):v()}catch(t){console.error("Error setting up Jitsi widget",t),document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget"}}()},function(t,e,i){}]); //# sourceMappingURL=jitsi.js.map