@tsocial/tvweb-sdk.msb 5.7.12 → 5.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -64,4 +64,4 @@ function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=a.create([0,1,2,
|
|
|
64
64
|
|
|
65
65
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
66
66
|
and limitations under the License.
|
|
67
|
-
***************************************************************************** */function a(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,r,n){return new(r||(r=Promise))((function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var u=function(){function e(e){this.httpClient=e}return e.prototype.uploadImage=function(e){return this.httpClient.postFormData("/v1/images",e)},e.prototype.request=function(e){var t="application/pdf"===e.file.type;return this.httpClient.postFormData(t?"/v1/files":"/v1/images",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/images",e,t)},e.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/images/"+e)];case 1:return t=r.sent(),[4,URL.createObjectURL(t)];case 2:return[2,r.sent()]}}))}))},e.prototype.updateMetadata=function(e,t){return this.httpClient.patch("/v1/images/"+e,t)},e}(),l=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/files",e,t)},e.prototype.uploadFile=function(e){return this.httpClient.postFormData("/v1/files",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/files",e,t)},e}(),f=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/compare_faces_sync",e,t)},e}(),d=function(){function e(e){this.httpClient=e}return e.prototype.getClientSettings=function(){return this.httpClient.get("/v1/client_settings")},e.prototype.request=function(){return this.httpClient.get("/v1/client_settings")},e}(),p=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_face_liveness_sync",e,t)},e}(),h=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_id_card_sanity_sync",e,t)},e}(),g=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_portrait_sanity_sync",e,t)},e}(),m=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e.prototype.requestWithAuthHeaders=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e}(),y=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/search_faces_sync",e,t)},e.prototype.indexFaces=function(e,t){return this.httpClient.post("/v1/index_faces_sync",e,t)},e.prototype.deleteFaces=function(e,t){return this.httpClient.post("/v1/delete_faces",e,t)},e.prototype.downloadFaceImage=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/face_images/"+e)];case 1:return t=r.sent(),[2,URL.createObjectURL(t)]}}))}))},e}(),v=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.postFormData("/v1/convert_pdf_sync",e,t)},e}(),b=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/ekyc_pdf",e,t)},e}(),C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:{};function E(e,t){return e(t={exports:{}},t.exports),t.exports}var w=E((function(e){var t,r;t=C,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var a=e[n];if("string"!=typeof a)throw new TypeError("Url must be a string. Received "+a);""!==a&&(n>0&&(a=a.replace(/^[\/]+/,"")),a=n<e.length-1?a.replace(/[\/]+$/,""):a.replace(/[\/]+$/,"/"),t.push(a))}var i=t.join("/"),o=(i=i.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o.shift()+(o.length>0?"?":"")+o.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()}));function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var S=function(e,t,r,n){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var i=/\+/g;e=e.split(t);var o=1e3;n&&"number"==typeof n.maxKeys&&(o=n.maxKeys);var s=e.length;o>0&&s>o&&(s=o);for(var c=0;c<s;++c){var u,l,f,d,p=e[c].replace(i,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),f=decodeURIComponent(u),d=decodeURIComponent(l),k(a,f)?Array.isArray(a[f])?a[f].push(d):a[f]=[a[f],d]:a[f]=d}return a},B=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},A=function(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){var a=encodeURIComponent(B(n))+r;return Array.isArray(e[n])?e[n].map((function(e){return a+encodeURIComponent(B(e))})).join(t):a+encodeURIComponent(B(e[n]))})).join(t):n?encodeURIComponent(B(n))+r+encodeURIComponent(B(e)):""},T=E((function(e,t){t.decode=t.parse=S,t.encode=t.stringify=A})),I=(T.decode,T.parse,T.encode,T.stringify),_=function(){function e(e){this.authorizer=e.authorizer,this.domain=e.domain,this.onError=e.onError,this.configHeaders=e.headers}return e.prototype.get=function(e,t,r){var n=new URL(this.resolveUrl(e));return t&&(n.search=I(t)),this.request(n.toString(),{requestPath:e,method:"GET",headers:r})},e.prototype.post=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"POST",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.postFormData=function(e,t,r){var n,a=t instanceof FormData?t:(n=t,Object.entries(n).reduce((function(e,t){var r=t[0],n=t[1];return Array.isArray(n)?n.forEach((function(t,a){return e.append(r+"["+a+"]",n)})):!(n instanceof Object)||n instanceof File||n instanceof Date||n instanceof Blob?e.append(r,n):Object.entries(n).forEach((function(t,a){return e.append(r+"["+a+"]",n[a])})),e}),new FormData)),i=this.resolveUrl(e);return this.request(i,{requestPath:e,method:"POST",body:a,headers:r})},e.prototype.patch=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"PATCH",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.delete=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"DELETE",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.downloadFile=function(e){var t=this.resolveUrl(e);return this.request(t,{requestPath:e,method:"GET"},"blob")},e.prototype.request=function(e,t,r){return void 0===r&&(r="json"),s(this,void 0,void 0,(function(){var a,i,o,s;return c(this,(function(c){switch(c.label){case 0:return a={},i={},this.authorizer&&(a=this.authorizer.getHeaders(t)),this.configHeaders&&(i=this.configHeaders),t.headers=n(n(n({},t.headers),a),i),[4,fetch(e,t)];case 1:return o=c.sent(),[4,"blob"===r?o.blob():o.json()];case 2:if((s=c.sent()).errors&&this.onError)throw this.onError(s.errors),s;return[2,s]}}))}))},e.prototype.resolveUrl=function(e){return w(this.domain,e)},e}(),x=function(){function e(e){this.mocks=e}return e.prototype.get=function(e,t){return this.findInMocks(e,t)},e.prototype.post=function(e,t){return this.findInMocks(e)},e.prototype.postFormData=function(e,t){return this.findInMocks(e)},e.prototype.patch=function(e,t){return this.findInMocks(e)},e.prototype.delete=function(e,t){return this.findInMocks(e)},e.prototype.downloadFile=function(e){return this.findInMocks(e)},e.prototype.resolveUrl=function(e){return this.mocks.resolveUrl?this.mocks.resolveUrl(e):e},e.prototype.findInMocks=function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this.mocks[e]?"function"==typeof this.mocks[e]?[2,Promise.resolve(this.mocks[e](t))]:[2,Promise.resolve(this.mocks[e])]:[2,Promise.reject(new Error(e+" is not presented in mocks"))]}))}))},e}(),P=E((function(e,t){var r;e.exports=r=r||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},a=n.lib={},i=a.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=a.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,a=e.sigBytes;if(this.clamp(),n%4)for(var i=0;i<a;i++){var o=r[i>>>2]>>>24-i%4*8&255;t[n+i>>>2]|=o<<24-(n+i)%4*8}else for(i=0;i<a;i+=4)t[n+i>>>2]=r[i>>>2];return this.sigBytes+=a,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],a=function(t){t=t;var r=987654321,n=4294967295;return function(){var a=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return a/=4294967296,(a+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var s=a(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new o.init(n,t)}}),s=n.enc={},c=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var i=t[a>>>2]>>>24-a%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},u=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var i=t[a>>>2]>>>24-a%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=a.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,a=r.sigBytes,i=this.blockSize,s=a/(4*i),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,u=e.min(4*c,a);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(n,l);var f=n.splice(0,c);r.sigBytes-=u}return new o.init(f,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(a.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new d.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),R=E((function(e,t){var r,n,a;e.exports=(n=(r=a=P).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var a=[],i=0;i<r;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)a.push(n.charAt(o>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;a.length%4;)a.push(c);return a.join("")},parse:function(e){var t=e.length,r=this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var i=0;i<r.length;i++)a[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var s=e.indexOf(o);-1!==s&&(t=s)}return function(e,t,r){for(var a=[],i=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2,c=r[e.charCodeAt(o)]>>>6-o%4*2;a[i>>>2]|=(s|c)<<24-i%4*8,i++}return n.create(a,i)}(e,t,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},a.enc.Base64)})),N=(E((function(e,t){var r;e.exports=(r=P,function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,a=0;a<64;)t(n)&&(a<8&&(s[a]=r(e.pow(n,.5))),c[a]=r(e.pow(n,1/3)),a++),n++}();var u=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new a.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],a=r[1],i=r[2],o=r[3],s=r[4],l=r[5],f=r[6],d=r[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var h=u[p-15],g=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=g+u[p-7]+y+u[p-16]}var v=n&a^n&i^a&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=d+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&f)+c[p]+u[p];d=f,f=l,l=s,s=o+C|0,o=i,i=a,a=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+a|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+f|0,r[7]=r[7]+d|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,a=8*t.sigBytes;return r[a>>>5]|=128<<24-a%32,r[14+(a+64>>>9<<4)]=e.floor(n/4294967296),r[15+(a+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l)}(Math),r.SHA256)})),E((function(e,t){var r,n,a;e.exports=(n=(r=P).lib.Base,a=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,c=o.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))})),E((function(e,t){e.exports=P.HmacSHA256}))),L=function(){function e(e,t){this.accessKey=e,this.keySecret=t}return e.prototype.getHeaders=function(e){var t=function(e){function t(e){return e<10?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+(0===(r=e.getTimezoneOffset())?"Z":(n=r>0?"-":"+",r=Math.abs(r),n+t(Math.floor(r/60))+":"+t(r%60)));var r,n}(new Date);return{Authorization:this.generateAuthorization(e.requestPath,e.method,t),"X-TV-Timestamp":t}},e.prototype.generateAuthorization=function(e,t,r){var n=this.computeStringToSign(e,t,r),a=R.stringify(this.computeSignature(n));return this.formatAuthToken("TV",a)},e.prototype.formatAuthToken=function(e,t){return e+" "+this.accessKey+":"+t},e.prototype.computeStringToSign=function(e,t,r){return t+"\n"+e+"\n"+r},e.prototype.computeSignature=function(e){return N(e,this.keySecret)},e}();function O(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":return"https://vn-vision.trustingsocial.com/api";default:return e}}function D(e,t,r,n){void 0===r&&(r="production");var a=(void 0===n?{}:n).headers,i=new L(e,t),o=O(r);return new _({authorizer:i,domain:o,headers:a})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:O(e)});this.imagesService=new u(t),this.detectIDTamperingService=new m(t)}return e.prototype.uploadImage=function(e,t){return this.imagesService.requestWithHeaders(e,t)},e.prototype.detectTampering=function(e,t){return this.detectIDTamperingService.requestWithAuthHeaders(e,t)},e}();function M(e){var t=e.headerIndex;return function(e,r,a){var i=a.value,o=n({},a);return o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,a,o,s;return c(this,(function(c){switch(c.label){case 0:return this.transactionEnabled?[4,this.transactionManager.begin()]:[3,4];case 1:return r=c.sent(),a=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),a=0;for(t=0;t<r;t++)for(var i=arguments[t],o=0,s=i.length;o<s;o++,a++)n[a]=i[o];return n}(e),(o=n({},a[t]))["X-TV-Transaction"]=r,a[t]=o,[4,i.apply(this,a)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,i.apply(this,e)];case 5:return[2,c.sent()]}}))}))},o}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,a){var i=a.value,o=n({},a);return o.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n;return c(this,(function(a){switch(a.label){case 0:return[4,i.apply(this,t)];case 1:return r=a.sent(),this.encryptionEnabled&&"string"==typeof r[e.encryptedField]?(n=this.encryptionService.decrypt(r[e.encryptedField],{transactionID:this.transactionManager.currentTransactionID}),[2,JSON.parse(n)]):[2,r]}}))}))},o}}var F=function(){function e(e){this.httpClient=e,this.transactionID="",this.totalTransactions=0,this.currentTransaction=0}return Object.defineProperty(e.prototype,"currentTransactionID",{get:function(){return this.transactionID},enumerable:!0,configurable:!0}),e.prototype.begin=function(){return s(this,void 0,void 0,(function(){var e,t,r=this;return c(this,(function(n){switch(n.label){case 0:return e=this.totalTransactions++,[4,new Promise((function(t,n){var a=window.performance.now(),i=setInterval((function(){e===r.currentTransaction&&(clearInterval(i),t(!0)),window.performance.now()-a>=3e3&&(clearInterval(i),n(new Error("Transaction timeout")))}),100)}))];case 1:return n.sent(),[4,this.httpClient.post("/v1/transactions",{})];case 2:return t=n.sent().data,this.transactionID=t.id,[2,t.id]}}))}))},e.prototype.end=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return[4,this.httpClient.post("/v1/transactions/"+this.transactionID+"/finish")];case 1:return e=t.sent(),this.transactionID="",this.currentTransaction++,[2,e]}}))}))},e}(),j={options:{usePureJavaScript:!1}},K={},z=K,q={};K.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var a=0,i=t.length,o=t.charAt(0),s=[0];for(a=0;a<e.length;++a){for(var c=0,u=e[a];c<s.length;++c)u+=s[c]<<8,s[c]=u%i,u=u/i|0;for(;u>0;)s.push(u%i),u=u/i|0}for(a=0;0===e[a]&&a<e.length-1;++a)n+=o;for(a=s.length-1;a>=0;--a)n+=t[s[a]]}else n=function(e,t){var r=0,n=t.length,a=t.charAt(0),i=[0];for(r=0;r<e.length();++r){for(var o=0,s=e.at(r);o<i.length;++o)s+=i[o]<<8,i[o]=s%n,s=s/n|0;for(;s>0;)i.push(s%n),s=s/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=a;for(r=i.length-1;r>=0;--r)c+=t[i[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},K.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=q[t];if(!r){r=q[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var a=t.length,i=t.charAt(0),o=[0];for(n=0;n<e.length;n++){var s=r[e.charCodeAt(n)];if(void 0===s)return;for(var c=0,u=s;c<o.length;++c)u+=o[c]*a,o[c]=255&u,u>>=8;for(;u>0;)o.push(255&u),u>>=8}for(var l=0;e[l]===i&&l<e.length-1;++l)o.push(0);return"undefined"!=typeof Buffer?Buffer.from(o.reverse()):new Uint8Array(o.reverse())},E((function(e){var t=e.exports=j.util=j.util||{};function r(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function n(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(t.isArrayBuffer(e)||t.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var r=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,r)}catch(e){for(var a=0;a<r.length;++a)this.putByte(r[a])}}else(e instanceof n||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return t.nextTick=process.nextTick,void("function"==typeof setImmediate?t.setImmediate=setImmediate:t.setImmediate=t.nextTick);if("function"==typeof setImmediate)return t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(t.nextTick=function(e){return setImmediate(e)});if(t.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",r=[];t.setImmediate=function(t){r.push(t),1===r.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(t){if(t.source===window&&t.data===e){t.stopPropagation();var n=r.slice();r.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!=typeof MutationObserver){var n=Date.now(),a=!0,i=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var o=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),o(e)):(r.push(e),1===r.length&&i.setAttribute("a",a=!a))}}t.nextTick=t.setImmediate}(),t.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,t.globalScope=t.isNodejs?C:"undefined"==typeof self?window:self,t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},t.isArrayBufferView=function(e){return e&&t.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},t.ByteBuffer=n,t.ByteStringBuffer=n,t.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},t.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},t.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},t.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(t.encodeUtf8(e))},t.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},t.ByteStringBuffer.prototype.putInt=function(e,t){r(t);var n="";do{t-=8,n+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(n)},t.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},t.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},t.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},t.ByteStringBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},t.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.DataBuffer=function(e,r){r=r||{},this.read=r.readOffset||0,this.growSize=r.growSize||1024;var n=t.isArrayBuffer(e),a=t.isArrayBufferView(e);if(n||a)return this.data=n?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in r?r.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in r&&(this.write=r.writeOffset)},t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},t.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},t.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},t.DataBuffer.prototype.putBytes=function(e,r){if(t.isArrayBufferView(e)){var n=(a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-a.byteOffset;return this.accommodate(n),new Uint8Array(this.data.buffer,this.write).set(a),this.write+=n,this}if(t.isArrayBuffer(e)){var a=new Uint8Array(e);return this.accommodate(a.byteLength),new Uint8Array(this.data.buffer).set(a,this.write),this.write+=a.byteLength,this}if(e instanceof t.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&t.isArrayBufferView(e.data))return a=new Uint8Array(e.data.byteLength,e.read,e.length()),this.accommodate(a.byteLength),new Uint8Array(e.data.byteLength,this.write).set(a),this.write+=a.byteLength,this;if(e instanceof t.ByteStringBuffer&&(e=e.data,r="binary"),r=r||"binary","string"==typeof e){var i;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,i,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,i,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(i),this;if("utf16"===r)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+r)}throw Error("Invalid parameter: "+e)},t.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},t.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},t.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(e,t){r(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},t.DataBuffer.prototype.putSignedInt=function(e,t){return r(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},t.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},t.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},t.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},t.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},t.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},t.DataBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},t.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},t.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.DataBuffer.prototype.toString=function(e){var r=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return t.binary.raw.encode(r);if("hex"===e)return t.binary.hex.encode(r);if("base64"===e)return t.binary.base64.encode(r);if("utf8"===e)return t.text.utf8.decode(r);if("utf16"===e)return t.text.utf16.decode(r);throw new Error("Invalid encoding: "+e)},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var n="",a="",i="",o=0,s=0;r>0;--r,++o)a=e.charCodeAt(o)^t.charCodeAt(o),s>=10&&(n+=i,i="",s=0),i+=String.fromCharCode(a),++s;return n+i},t.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},t.bytesToHex=function(e){return t.createBuffer(e).toHex()},t.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,i,o="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),i=e.charCodeAt(c++),o+=a.charAt(r>>2),o+=a.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=a.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":a.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,a,o="",s=0;s<e.length;)t=i[e.charCodeAt(s++)-43],r=i[e.charCodeAt(s++)-43],n=i[e.charCodeAt(s++)-43],a=i[e.charCodeAt(s++)-43],o+=String.fromCharCode(t<<2|r>>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==a&&(o+=String.fromCharCode((3&n)<<6|a)));return o},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:z.encode,decode:z.decode}},t.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},t.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var a=r=r||0,i=0;i<e.length;++i)n[a++]=e.charCodeAt(i);return t?a-r:n},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var a=0,i=r=r||0;for(1&e.length&&(a=1,n[i++]=parseInt(e[0],16));a<e.length;a+=2)n[i++]=parseInt(e.substr(a,2),16);return t?i-r:n},t.binary.base64.encode=function(e,t){for(var r,n,i,o="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],i=e[c++],o+=a.charAt(r>>2),o+=a.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=a.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":a.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.binary.base64.decode=function(e,t,r){var n,a,o,s,c=t;c||(c=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u<e.length;)n=i[e.charCodeAt(u++)-43],a=i[e.charCodeAt(u++)-43],o=i[e.charCodeAt(u++)-43],s=i[e.charCodeAt(u++)-43],c[l++]=n<<2|a>>4,64!==o&&(c[l++]=(15&a)<<4|o>>2,64!==s&&(c[l++]=(3&o)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,o,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,o,r)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(e,r,n){e=t.encodeUtf8(e);var a=r;a||(a=new Uint8Array(e.length));for(var i=n=n||0,o=0;o<e.length;++o)a[i++]=e.charCodeAt(o);return r?i-n:a},t.text.utf8.decode=function(e){return t.decodeUtf8(String.fromCharCode.apply(null,e))},t.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var a=new Uint16Array(n.buffer),i=r=r||0,o=r,s=0;s<e.length;++s)a[o++]=e.charCodeAt(s),i+=2;return t?i-r:n},t.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},t.deflate=function(e,r,n){if(r=t.decode64(e.deflate(t.encode64(r)).rval),n){var a=2;32&r.charCodeAt(1)&&(a=6),r=r.substring(a,r.length-4)}return r},t.inflate=function(e,r,n){var a=e.inflate(t.encode64(r)).rval;return null===a?null:t.decode64(a)};var s=function(e,r,n){if(!e)throw new Error("WebStorage not available.");var a;if(null===n?a=e.removeItem(r):(n=t.encode64(JSON.stringify(n)),a=e.setItem(r,n)),void 0!==a&&!0!==a.rval){var i=new Error(a.error.message);throw i.id=a.error.id,i.name=a.error.name,i}},c=function(e,r){if(!e)throw new Error("WebStorage not available.");var n=e.getItem(r);if(e.init)if(null===n.rval){if(n.error){var a=new Error(n.error.message);throw a.id=n.error.id,a.name=n.error.name,a}n=null}else n=n.rval;return null!==n&&(n=JSON.parse(t.decode64(n))),n},u=function(e,t,r,n){var a=c(e,t);null===a&&(a={}),a[r]=n,s(e,t,a)},l=function(e,t,r){var n=c(e,t);return null!==n&&(n=r in n?n[r]:null),n},f=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var a=!0;for(var i in n){a=!1;break}a&&(n=null),s(e,t,n)}},d=function(e,t){s(e,t,null)},p=function(e,t,r){var n,a=null;void 0===r&&(r=["web","flash"]);var i=!1,o=null;for(var s in r){n=r[s];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");a=e.apply(this,t),i="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,a=e.apply(this,t),i=!0)}catch(e){o=e}if(i)break}if(!i)throw o;return a};t.setItem=function(e,t,r,n,a){p(u,arguments,a)},t.getItem=function(e,t,r,n){return p(l,arguments,n)},t.removeItem=function(e,t,r,n){p(f,arguments,n)},t.clearItems=function(e,t,r){p(d,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var h=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var a,i,o=r[n].indexOf("=");o>0?(a=r[n].substring(0,o),i=r[n].substring(o+1)):(a=r[n],i=null),a in t||(t[a]=[]),a in Object.prototype||null===i||t[a].push(unescape(i))}return t};return void 0===e?(null===h&&(h="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=h):t=r(e),t},t.parseFragment=function(e){var r=e,n="",a=e.indexOf("?");a>0&&(r=e.substring(0,a),n=e.substring(a+1));var i=r.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:r,queryString:n,path:i,query:""===n?{}:t.getQueryVariables(n)}},t.makeRequest=function(e){var r=t.parseFragment(e),n={path:r.pathString,query:r.queryString,getPath:function(e){return void 0===e?r.path:r.path[e]},getQuery:function(e,t){var n;return void 0===e?n=r.query:(n=r.query[e])&&void 0!==t&&(n=n[t]),n},getQueryLast:function(e,t){var r=n.getQuery(e);return r?r[r.length-1]:t}};return n},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,a=t.length;n<a;){var i=t[n++];if(n==a)e[i]=r;else{var o=i in e;(!o||o&&"object"!=typeof e[i]||o&&null===e[i])&&(e[i]={}),e=e[i]}}},t.getPath=function(e,t,r){for(var n=0,a=t.length,i=!0;i&&n<a&&"object"==typeof e&&null!==e;){var o=t[n++];(i=o in e)&&(e=e[o])}return i?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,n=t.length;r<n;){var a=t[r++];if(r==n)delete e[a];else{if(!(a in e)||"object"!=typeof e[a]||null===e[a])break;e=e[a]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,n=/%./g,a=0,i=[],o=0;t=n.exec(e);){(r=e.substring(o,n.lastIndex-2)).length>0&&i.push(r),o=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":a<arguments.length?i.push(arguments[1+a++]):i.push("<?>");break;case"%":i.push("%");break;default:i.push("<%"+s+"?>")}}return i.push(e.substring(o)),i.join("")},t.formatNumber=function(e,t,r,n){var a=e,i=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,s=void 0===n?".":n,c=a<0?"-":"",u=parseInt(a=Math.abs(+a||0).toFixed(i),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+s:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+s)+(i?o+Math.abs(a-u).toFixed(i).slice(2):"")},t.formatSize=function(e){return e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var r=t.createBuffer(),n=0;n<e.length;++n){var a=parseInt(e[n],10);if(isNaN(a))return null;r.putByte(a)}return r.getBytes()},t.bytesFromIPv6=function(e){for(var r=0,n=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++r,!0}))).length+r),a=t.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var o=t.hexToBytes(e[i]);o.length<2&&a.putByte(0),a.putBytes(o)}else a.fillWithByte(0,n),n=0;return a.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},t.bytesToIPv6=function(e){if(16!==e.length)return null;for(var r=[],n=[],a=0,i=0;i<e.length;i+=2){for(var o=t.bytesToHex(e[i]+e[i+1]);"0"===o[0]&&"0"!==o;)o=o.substr(1);if("0"===o){var s=n[n.length-1],c=r.length;s&&c===s.end+1?(s.end=c,s.end-s.start>n[a].end-n[a].start&&(a=n.length-1)):n.push({start:c,end:c})}r.push(o)}if(n.length>0){var u=n[a];u.end-u.start>0&&(r.splice(u.start,u.end-u.start+1,""),0===u.start&&r.unshift(""),7===u.end&&r.push(""))}return r.join(":")},t.estimateCores=function(e,r){if("function"==typeof e&&(r=e,e={}),e=e||{},"cores"in t&&!e.update)return r(null,t.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,r(null,t.cores);if("undefined"==typeof Worker)return t.cores=1,r(null,t.cores);if("undefined"==typeof Blob)return t.cores=2,r(null,t.cores);var n=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(a,i,o){if(0===i){var s=Math.floor(a.reduce((function(e,t){return e+t}),0)/a.length);return t.cores=Math.max(1,s),URL.revokeObjectURL(n),r(null,t.cores)}!function(e,t){for(var r=[],a=[],i=0;i<e;++i){var o=new Worker(n);o.addEventListener("message",(function(n){if(a.push(n.data),a.length===e){for(var i=0;i<e;++i)r[i].terminate();t(null,a)}})),r.push(o)}for(i=0;i<e;++i)r[i].postMessage(i)}(o,(function(t,r){a.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var a=t[n],i=r[n]=[],o=0;o<e;++o)if(n!==o){var s=t[o];(a.st>s.st&&a.st<s.et||s.st>a.st&&s.st<a.et)&&i.push(o)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(o,r)),e(a,i-1,o)}))}([],5,16)}})),j.cipher=j.cipher||{},j.cipher.algorithms=j.cipher.algorithms||{},j.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=j.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new j.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},j.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=j.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new j.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},j.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),j.cipher.algorithms[e]=t},j.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in j.cipher.algorithms?j.cipher.algorithms[e]:null};var H=j.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};function G(e,t){j.cipher.registerAlgorithm(e,(function(){return new j.aes.Algorithm(e,t)}))}H.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=j.util.createBuffer(),this.output=e.output||j.util.createBuffer(),this.mode.start(t)},H.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},H.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))},E((function(e){j.cipher=j.cipher||{};var t=e.exports=j.cipher.modes=j.cipher.modes||{};function r(e,t){if("string"==typeof e&&(e=j.util.createBuffer(e)),j.util.isArray(e)&&e.length>4){var r=e;e=j.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!j.util.isArray(e)){var a=[],i=t/4;for(n=0;n<i;++n)a.push(e.getInt32());e=a}return e}function n(e){e[e.length-1]=e[e.length-1]+1&4294967295}function a(e){return[e/4294967296|0,4294967295&e]}t.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.ecb.prototype.start=function(e){},t.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},t.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},t.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},t.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32()^this._outBlock[a],t.putInt32(this._inBlock[a]);else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32()^this._outBlock[a],this._partialOutput.putInt32(this._partialBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32(),t.putInt32(this._inBlock[a]^this._outBlock[a]);else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[a]^this._outBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]),this._inBlock[a]=this._outBlock[a];else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._outBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb.prototype.decrypt=t.ofb.prototype.encrypt,t.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ctr.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var o=(this.blockSize-a)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},t.ctr.prototype.decrypt=t.ctr.prototype.encrypt,t.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0,this._R=3774873600},t.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=j.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?j.util.createBuffer(e.additionalData):j.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=j.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=j.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},t.gcm.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-a)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o<=0||r){if(r){var s=a%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},t.gcm.prototype.decrypt=function(e,t,r){var a=e.length();if(a<this.blockSize&&!(r&&a>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);a<this.blockSize?this._cipherLength+=a%this.blockSize:this._cipherLength+=this.blockSize},t.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=j.util.createBuffer();var n=this._aDataLength.concat(a(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^i[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},t.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),a=0;a<128;++a)e[a/32|0]&1<<31-a%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n);return r},t.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},t.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,a=this._m[r][n];t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3]}return t},t.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},t.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,a=16*r,i=new Array(a),o=0;o<a;++o){var s=[0,0,0,0],c=(n-1-o%n)*t;s[o/n|0]=1<<t-1<<c,i[o]=this.generateSubHashTable(this.multiply(s,e),t)}return i},t.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,a=new Array(r);a[n]=e.slice(0);for(var i=n>>>1;i>0;)this.pow(a[2*i],a[i]=[]),i>>=1;for(i=2;i<n;){for(var o=1;o<i;++o){var s=a[i],c=a[o];a[i+o]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}i*=2}for(a[0]=[0,0,0,0],i=n+1;i<r;++i){var u=a[i^n];a[i]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return a}})),j.aes=j.aes||{},j.aes.startEncrypting=function(e,t,r,n){var a=ne({key:e,output:r,decrypt:!1,mode:n});return a.start(t),a},j.aes.createEncryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!1,mode:t})},j.aes.startDecrypting=function(e,t,r,n){var a=ne({key:e,output:r,decrypt:!0,mode:n});return a.start(t),a},j.aes.createDecryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!0,mode:t})},j.aes.Algorithm=function(e,t){Z||ee();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return re(r._w,e,t,!1)},decrypt:function(e,t){return re(r._w,e,t,!0)}}}),r._init=!1},j.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(j.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=j.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=j.util.createBuffer(r);if(!j.util.isArray(r)){t=r,r=[];var a=t.length();if(16===a||24===a||32===a)for(a>>>=2,n=0;n<a;++n)r.push(t.getInt32())}if(!j.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var i=this.mode.name,o=-1!==["CFB","OFB","CTR","GCM"].indexOf(i);this._w=te(r,e.decrypt&&!o),this._init=!0}},j.aes._expandKey=function(e,t){return Z||ee(),te(e,t)},j.aes._updateBlock=re,G("AES-ECB",j.cipher.modes.ecb),G("AES-CBC",j.cipher.modes.cbc),G("AES-CFB",j.cipher.modes.cfb),G("AES-OFB",j.cipher.modes.ofb),G("AES-CTR",j.cipher.modes.ctr),G("AES-GCM",j.cipher.modes.gcm);var Q,W,X,Y,$,Z=!1,J=4;function ee(){Z=!0,X=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;for(Q=new Array(256),W=new Array(256),Y=new Array(4),$=new Array(4),t=0;t<4;++t)Y[t]=new Array(256),$[t]=new Array(256);var r,n,a,i,o,s,c,u=0,l=0;for(t=0;t<256;++t){i=(i=l^l<<1^l<<2^l<<3^l<<4)>>8^255&i^99,Q[u]=i,W[i]=u,s=(o=e[i])<<24^i<<16^i<<8^i^o,c=((r=e[u])^(n=e[r])^(a=e[n]))<<24^(u^a)<<16^(u^n^a)<<8^u^r^a;for(var f=0;f<4;++f)Y[f][u]=s,$[f][i]=c,s=s<<24|s>>>8,c=c<<24|c>>>8;0===u?u=l=1:(u=r^e[e[e[r^a]]],l^=e[e[l]])}}function te(e,t){for(var r,n=e.slice(0),a=1,i=n.length,o=J*(i+6+1),s=i;s<o;++s)r=n[s-1],s%i==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[a]<<24,a++):i>6&&s%i==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-i]^r;if(t){for(var c,u=$[0],l=$[1],f=$[2],d=$[3],p=n.slice(0),h=(s=0,(o=n.length)-J);s<o;s+=J,h-=J)if(0===s||s===o-J)p[s]=n[h],p[s+1]=n[h+3],p[s+2]=n[h+2],p[s+3]=n[h+1];else for(var g=0;g<J;++g)c=n[h+g],p[s+(3&-g)]=u[Q[c>>>24]]^l[Q[c>>>16&255]]^f[Q[c>>>8&255]]^d[Q[255&c]];n=p}return n}function re(e,t,r,n){var a,i,o,s,c,u,l,f,d,p,h,g,m=e.length/4-1;n?(a=$[0],i=$[1],o=$[2],s=$[3],c=W):(a=Y[0],i=Y[1],o=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],f=t[2]^e[2],d=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=a[u>>>24]^i[l>>>16&255]^o[f>>>8&255]^s[255&d]^e[++y],h=a[l>>>24]^i[f>>>16&255]^o[d>>>8&255]^s[255&u]^e[++y],g=a[f>>>24]^i[d>>>16&255]^o[u>>>8&255]^s[255&l]^e[++y],d=a[d>>>24]^i[u>>>16&255]^o[l>>>8&255]^s[255&f]^e[++y],u=p,l=h,f=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[f>>>8&255]<<8^c[255&d]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[f>>>16&255]<<16^c[d>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[f>>>24]<<24^c[d>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[d>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&f]^e[++y]}function ne(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?j.cipher.createDecipher(r,e.key):j.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var a=null;r instanceof j.util.ByteBuffer&&(a=r,r={}),(r=r||{}).output=a,r.iv=e,n.call(t,r)},t}function ae(e,t){j.cipher.registerAlgorithm(e,(function(){return new j.des.Algorithm(e,t)}))}E((function(e){j.pki=j.pki||{};var t=e.exports=j.pki.oids=j.oids=j.oids||{};function r(e,r){t[e]=r,t[r]=e}function n(e,r){t[e]=r}r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.5","serialName"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),n("2.5.29.1","authorityKeyIdentifier"),n("2.5.29.2","keyAttributes"),n("2.5.29.3","certificatePolicies"),n("2.5.29.4","keyUsageRestriction"),n("2.5.29.5","policyMapping"),n("2.5.29.6","subtreesConstraint"),n("2.5.29.7","subjectAltName"),n("2.5.29.8","issuerAltName"),n("2.5.29.9","subjectDirectoryAttributes"),n("2.5.29.10","basicConstraints"),n("2.5.29.11","nameConstraints"),n("2.5.29.12","policyConstraints"),n("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),n("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),n("2.5.29.20","cRLNumber"),n("2.5.29.21","cRLReason"),n("2.5.29.22","expirationDate"),n("2.5.29.23","instructionCode"),n("2.5.29.24","invalidityDate"),n("2.5.29.25","cRLDistributionPoints"),n("2.5.29.26","issuingDistributionPoint"),n("2.5.29.27","deltaCRLIndicator"),n("2.5.29.28","issuingDistributionPoint"),n("2.5.29.29","certificateIssuer"),n("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),n("2.5.29.33","policyMappings"),n("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),n("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),n("2.5.29.46","freshestCRL"),n("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping")})),E((function(e){var t=e.exports=j.asn1=j.asn1||{};function r(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,r,n,a,i){if(j.util.isArray(a)){for(var o=[],s=0;s<a.length;++s)void 0!==a[s]&&o.push(a[s]);a=o}var c={tagClass:e,type:r,constructed:n,composed:n||j.util.isArray(a),value:a};return i&&"bitStringContents"in i&&(c.bitStringContents=i.bitStringContents,c.original=t.copy(c)),c},t.copy=function(e,r){var n;if(j.util.isArray(e)){n=[];for(var a=0;a<e.length;++a)n.push(t.copy(e[a],r));return n}return"string"==typeof e?e:(n={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:t.copy(e.value,r)},r&&!r.excludeBitStringContents&&(n.bitStringContents=e.bitStringContents),n)},t.equals=function(e,r,n){if(j.util.isArray(e)){if(!j.util.isArray(r))return!1;if(e.length!==r.length)return!1;for(var a=0;a<e.length;++a)if(!t.equals(e[a],r[a]))return!1;return!0}if(typeof e!=typeof r)return!1;if("string"==typeof e)return e===r;var i=e.tagClass===r.tagClass&&e.type===r.type&&e.constructed===r.constructed&&e.composed===r.composed&&t.equals(e.value,r.value);return n&&n.includeBitStringContents&&(i=i&&e.bitStringContents===r.bitStringContents),i},t.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};var n=function(e,t){var n=e.getByte();if(t--,128!==n){var a;if(128&n){var i=127&n;r(e,t,i),a=e.getInt(i<<3)}else a=n;if(a<0)throw new Error("Negative length: "+a);return a}};t.fromDer=function(e,a){return void 0===a&&(a={strict:!0,decodeBitStrings:!0}),"boolean"==typeof a&&(a={strict:a,decodeBitStrings:!0}),"strict"in a||(a.strict=!0),"decodeBitStrings"in a||(a.decodeBitStrings=!0),"string"==typeof e&&(e=j.util.createBuffer(e)),function e(a,i,o,s){var c;r(a,i,2);var u=a.getByte();i--;var l=192&u,f=31&u;c=a.length();var d,p,h=n(a,i);if(i-=c-a.length(),void 0!==h&&h>i){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=a.length(),g.remaining=i,g.requested=h,g}h=i}var m=32==(32&u);if(m)if(d=[],void 0===h)for(;;){if(r(a,i,2),a.bytes(2)===String.fromCharCode(0,0)){a.getBytes(2),i-=2;break}c=a.length(),d.push(e(a,i,o+1,s)),i-=c-a.length()}else for(;h>0;)c=a.length(),d.push(e(a,h,o+1,s)),i-=c-a.length(),h-=c-a.length();if(void 0===d&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&(p=a.bytes(h)),void 0===d&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&h>1){var y=a.read,v=i,b=0;if(f===t.Type.BITSTRING&&(r(a,i,1),b=a.getByte(),i--),0===b)try{c=a.length();var C=e(a,i,o+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),E=c-a.length();i-=E,f==t.Type.BITSTRING&&E++;var w=C.tagClass;E!==h||w!==t.Class.UNIVERSAL&&w!==t.Class.CONTEXT_SPECIFIC||(d=[C])}catch(e){}void 0===d&&(a.read=y,i=v)}if(void 0===d){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=i}if(f===t.Type.BMPSTRING)for(d="";h>0;h-=2)r(a,i,2),d+=String.fromCharCode(a.getInt16()),i-=2;else d=a.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,f,m,d,k)}(e,e.length(),0,a)},t.toDer=function(e){var r=j.util.createBuffer(),n=e.tagClass|e.type,a=j.util.createBuffer(),i=!1;if("bitStringContents"in e&&(i=!0,e.original&&(i=t.equals(e,e.original))),i)a.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:a.putByte(0);for(var o=0;o<e.value.length;++o)void 0!==e.value[o]&&a.putBuffer(t.toDer(e.value[o]))}else if(e.type===t.Type.BMPSTRING)for(o=0;o<e.value.length;++o)a.putInt16(e.value.charCodeAt(o));else e.type===t.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?a.putBytes(e.value.substr(1)):a.putBytes(e.value);if(r.putByte(n),a.length()<=127)r.putByte(127&a.length());else{var s=a.length(),c="";do{c+=String.fromCharCode(255&s),s>>>=8}while(s>0);for(r.putByte(128|c.length),o=c.length-1;o>=0;--o)r.putByte(c.charCodeAt(o))}return r.putBuffer(a),r},t.oidToDer=function(e){var t,r,n,a,i=e.split("."),o=j.util.createBuffer();o.putByte(40*parseInt(i[0],10)+parseInt(i[1],10));for(var s=2;s<i.length;++s){t=!0,r=[],n=parseInt(i[s],10);do{a=127&n,n>>>=7,t||(a|=128),r.push(a),t=!1}while(n>0);for(var c=r.length-1;c>=0;--c)o.putByte(r[c])}return o},t.derToOid=function(e){var t;"string"==typeof e&&(e=j.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,a=parseInt(e.substr(4,2),10),i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(s=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,a),t.setUTCHours(i,o,s,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,a=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var f=e.length-5,d=e.charAt(f);return"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,a),t.setUTCHours(i,o,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,a),t.setHours(i,o,s,c)),t},t.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.integerToDer=function(e){var t=j.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},t.derToInteger=function(e){"string"==typeof e&&(e=j.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},t.validate=function(e,r,n,a){var i=!1;if(e.tagClass!==r.tagClass&&void 0!==r.tagClass||e.type!==r.type&&void 0!==r.type)a&&(e.tagClass!==r.tagClass&&a.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+e.tagClass+'"'),e.type!==r.type&&a.push("["+r.name+'] Expected type "'+r.type+'", got "'+e.type+'"'));else if(e.constructed===r.constructed||void 0===r.constructed){if(i=!0,r.value&&j.util.isArray(r.value))for(var o=0,s=0;i&&s<r.value.length;++s)i=r.value[s].optional||!1,e.value[o]&&((i=t.validate(e.value[o],r.value[s],n,a))?++o:r.value[s].optional&&(i=!0)),!i&&a&&a.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(i&&n&&(r.capture&&(n[r.capture]=e.value),r.captureAsn1&&(n[r.captureAsn1]=e),r.captureBitStringContents&&"bitStringContents"in e&&(n[r.captureBitStringContents]=e.bitStringContents),r.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)n[r.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");n[r.captureBitStringValue]=e.bitStringContents.slice(1)}}else a&&a.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+e.constructed+'"');return i};var a=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var i="";n=n||2,(r=r||0)>0&&(i+="\n");for(var o="",s=0;s<r*n;++s)o+=" ";switch(i+=o+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:i+="Universal:";break;case t.Class.APPLICATION:i+="Application:";break;case t.Class.CONTEXT_SPECIFIC:i+="Context-Specific:";break;case t.Class.PRIVATE:i+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(i+=e.type,e.type){case t.Type.NONE:i+=" (None)";break;case t.Type.BOOLEAN:i+=" (Boolean)";break;case t.Type.INTEGER:i+=" (Integer)";break;case t.Type.BITSTRING:i+=" (Bit string)";break;case t.Type.OCTETSTRING:i+=" (Octet string)";break;case t.Type.NULL:i+=" (Null)";break;case t.Type.OID:i+=" (Object Identifier)";break;case t.Type.ODESC:i+=" (Object Descriptor)";break;case t.Type.EXTERNAL:i+=" (External or Instance of)";break;case t.Type.REAL:i+=" (Real)";break;case t.Type.ENUMERATED:i+=" (Enumerated)";break;case t.Type.EMBEDDED:i+=" (Embedded PDV)";break;case t.Type.UTF8:i+=" (UTF8)";break;case t.Type.ROID:i+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:i+=" (Sequence)";break;case t.Type.SET:i+=" (Set)";break;case t.Type.PRINTABLESTRING:i+=" (Printable String)";break;case t.Type.IA5String:i+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:i+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:i+=" (Generalized time)";break;case t.Type.BMPSTRING:i+=" (BMP String)"}else i+=e.type;if(i+="\n",i+=o+"Constructed: "+e.constructed+"\n",e.composed){var c=0,u="";for(s=0;s<e.value.length;++s)void 0!==e.value[s]&&(c+=1,u+=t.prettyPrint(e.value[s],r+1,n),s+1<e.value.length&&(u+=","));i+=o+"Sub values: "+c+u}else{if(i+=o+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);i+=l,j.pki&&j.pki.oids&&l in j.pki.oids&&(i+=" ("+j.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{i+=t.derToInteger(e.value)}catch(t){i+="0x"+j.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?i+="0x"+j.util.bytesToHex(e.value.slice(1)):i+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?i+=" (1 unused bit shown)":f>1&&(i+=" ("+f+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(a.test(e.value)||(i+="("+e.value+") "),i+="0x"+j.util.bytesToHex(e.value)):e.type===t.Type.UTF8?i+=j.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?i+=e.value:a.test(e.value)?i+="0x"+j.util.bytesToHex(e.value):0===e.value.length?i+="[null]":i+=e.value}return i}})),j.md=j.md||{},j.md.algorithms=j.md.algorithms||{},E((function(e){(e.exports=j.hmac=j.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,a={start:function(a,i){if(null!==a)if("string"==typeof a){if(!((a=a.toLowerCase())in j.md.algorithms))throw new Error('Unknown hash algorithm "'+a+'"');t=j.md.algorithms[a].create()}else t=a;if(null===i)i=e;else{if("string"==typeof i)i=j.util.createBuffer(i);else if(j.util.isArray(i)){var o=i;i=j.util.createBuffer();for(var s=0;s<o.length;++s)i.putByte(o[s])}var c=i.length();for(c>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),r=j.util.createBuffer(),n=j.util.createBuffer(),c=i.length(),s=0;s<c;++s)o=i.at(s),r.putByte(54^o),n.putByte(92^o);if(c<t.blockLength)for(o=t.blockLength-c,s=0;s<o;++s)r.putByte(54),n.putByte(92);e=i,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return a.digest=a.getMac,a}})),E((function(e){var t=e.exports=j.md5=j.md5||{};j.md.md5=j.md.algorithms.md5=t,t.create=function(){o||function(){r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),n=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],a=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],i=new Array(64);for(var e=0;e<64;++e)i[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));o=!0}();var e=null,t=j.util.createBuffer(),c=new Array(16),u={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){u.messageLength=0,u.fullMessageLength=u.messageLength64=[];for(var r=u.messageLengthSize/4,n=0;n<r;++n)u.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},u}};return u.start(),u.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var a=r.length;u.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var i=u.fullMessageLength.length-1;i>=0;--i)u.fullMessageLength[i]+=a[1],a[1]=a[0]+(u.fullMessageLength[i]/4294967296>>>0),u.fullMessageLength[i]=u.fullMessageLength[i]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(r),s(e,c,t),(t.read>2048||0===t.length())&&t.compact(),u},u.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var a=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize&u.blockLength-1;n.putBytes(r.substr(0,u.blockLength-a));for(var i,o=0,l=u.fullMessageLength.length-1;l>=0;--l)o=(i=8*u.fullMessageLength[l]+o)/4294967296>>>0,n.putInt32Le(i>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(f,c,n);var d=j.util.createBuffer();return d.putInt32Le(f.h0),d.putInt32Le(f.h1),d.putInt32Le(f.h2),d.putInt32Le(f.h3),d},u};var r=null,n=null,a=null,i=null,o=!1;function s(e,t,r){for(var o,s,c,u,l,f,d,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,d=0;d<16;++d)t[d]=r.getInt32Le(),o=s+(l^c&(u^l))+i[d]+t[d],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<32;++d)o=s+(u^l&(c^u))+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<48;++d)o=s+(c^u^l)+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<64;++d)o=s+(u^(c|~l))+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;e.h0=e.h0+s|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,p-=64}}})),E((function(e){var t=e.exports=j.pem=j.pem||{};function r(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},a=0;a<e.values.length;++a)r.push(e.values[a].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var i=0,o=-1;for(a=0;a<t.length;++a,++i)if(i>65&&-1!==o){var s=t[o];","===s?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+s+t.substr(o+1),i=a-o-1,o=-1,++a}else" "!==t[a]&&"\t"!==t[a]&&","!==t[a]||(o=a);return t}function n(e){return e.replace(/^\s+/,"")}t.encode=function(e,t){t=t||{};var n,a="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(a+=r(n={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(a+=r(n={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(n={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&n.values.push(e.dekInfo.parameters),a+=r(n)),e.headers)for(var i=0;i<e.headers.length;++i)a+=r(e.headers[i]);return e.procType&&(a+="\r\n"),(a+=j.util.encode64(e.body,t.maxline||64)+"\r\n")+"-----END "+e.type+"-----\r\n"},t.decode=function(e){for(var t,r=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;t=a.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:j.util.decode64(t[3])};if(r.push(s),t[2]){for(var c=t[2].split(o),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var d=c[f];if(!/\s/.test(d[0]))break;l+=d,u=f}if(t=l.match(i)){for(var p={name:t[1],values:[]},h=t[2].split(","),g=0;g<h.length;++g)p.values.push(n(h[g]));if(s.procType)if(s.contentDomain||"Content-Domain"!==p.name)if(s.dekInfo||"DEK-Info"!==p.name)s.headers.push(p);else{if(0===p.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:h[0],parameters:h[1]||null}}else s.contentDomain=h[0]||"";else{if("Proc-Type"!==p.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==p.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:h[0],type:h[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}})),j.des=j.des||{},j.des.startEncrypting=function(e,t,r,n){var a=he({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return a.start(t),a},j.des.createEncryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!1,mode:t})},j.des.startDecrypting=function(e,t,r,n){var a=he({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return a.start(t),a},j.des.createDecryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!0,mode:t})},j.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return pe(r._keys,e,t,!1)},decrypt:function(e,t){return pe(r._keys,e,t,!0)}}}),r._init=!1},j.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=j.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],a=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],h=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],m=e.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,C=0;C<m;C++){var E=e.getInt32(),w=e.getInt32();E^=(t=252645135&(E>>>4^w))<<4,E^=t=65535&((w^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(w^=t<<-16)))<<2,E^=t=65535&((w^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(w^=t<<-16)))<<1,E^=t=16711935&((w^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(w^=t<<8)))<<1)<<8|(w^=t)>>>20&240,E=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=t;for(var k=0;k<v.length;++k){v[k]?(E=E<<2|E>>>26,w=w<<2|w>>>26):(E=E<<1|E>>>27,w=w<<1|w>>>27);var S=r[(E&=-15)>>>28]|n[E>>>24&15]|a[E>>>20&15]|i[E>>>16&15]|o[E>>>12&15]|s[E>>>8&15]|c[E>>>4&15],B=u[(w&=-15)>>>28]|l[w>>>24&15]|f[w>>>20&15]|d[w>>>16&15]|p[w>>>12&15]|h[w>>>8&15]|g[w>>>4&15];t=65535&(B>>>16^S),y[b++]=S^t,y[b++]=B^t<<16}}return y}(t),this._init=!0}},ae("DES-ECB",j.cipher.modes.ecb),ae("DES-CBC",j.cipher.modes.cbc),ae("DES-CFB",j.cipher.modes.cfb),ae("DES-OFB",j.cipher.modes.ofb),ae("DES-CTR",j.cipher.modes.ctr),ae("3DES-ECB",j.cipher.modes.ecb),ae("3DES-CBC",j.cipher.modes.cbc),ae("3DES-CFB",j.cipher.modes.cfb),ae("3DES-OFB",j.cipher.modes.ofb),ae("3DES-CTR",j.cipher.modes.ctr);var ie=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],oe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],se=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],ce=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],ue=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],le=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],fe=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],de=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function pe(e,t,r,n){var a,i,o=32===e.length?3:9;a=3===o?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s=t[0],c=t[1];s^=(i=252645135&(s>>>4^c))<<4,s^=(i=65535&(s>>>16^(c^=i)))<<16,s^=i=858993459&((c^=i)>>>2^s),s^=i=16711935&((c^=i<<2)>>>8^s),s=(s^=(i=1431655765&(s>>>1^(c^=i<<8)))<<1)<<1|s>>>31,c=(c^=i)<<1|c>>>31;for(var u=0;u<o;u+=3){for(var l=a[u+1],f=a[u+2],d=a[u];d!=l;d+=f){var p=c^e[d],h=(c>>>4|c<<28)^e[d+1];i=s,s=c,c=i^(oe[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|de[63&p]|ie[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|fe[63&h])}i=s,s=c,c=i}c=c>>>1|c<<31,c^=i=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(i=16711935&(c>>>8^(s^=i<<1)))<<8,c^=(i=858993459&(c>>>2^(s^=i)))<<2,c^=i=65535&((s^=i)>>>16^c),c^=i=252645135&((s^=i<<16)>>>4^c),s^=i<<4,r[0]=s,r[1]=c}function he(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?j.cipher.createDecipher(r,e.key):j.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var a=null;r instanceof j.util.ByteBuffer&&(a=r,r={}),(r=r||{}).output=a,r.iv=e,n.call(t,r)},t}var ge,me=j.pkcs5=j.pkcs5||{};j.util.isNodejs&&!j.options.usePureJavaScript&&(ge=t),j.pbkdf2=me.pbkdf2=function(e,t,r,n,a,i){if("function"==typeof a&&(i=a,a=null),j.util.isNodejs&&!j.options.usePureJavaScript&&ge.pbkdf2&&(null===a||"object"!=typeof a)&&(ge.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),i?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return i(e);i(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,a,(function(e,t){if(e)return i(e);i(null,t.toString("binary"))})):4===ge.pbkdf2Sync.length?ge.pbkdf2Sync(e,t,r,n).toString("binary"):ge.pbkdf2Sync(e,t,r,n,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in j.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=j.md[a].create()}var o=a.digestLength;if(n>4294967295*o){var s=new Error("Derived key is too long.");if(i)return i(s);throw s}var c=Math.ceil(n/o),u=n-(c-1)*o,l=j.hmac.create();l.start(a,e);var f,d,p,h="";if(!i){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(j.util.int32ToBytes(g)),f=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),d=l.digest().getBytes(),f=j.util.xorBytes(f,d,o),p=d;h+=g<c?f:f.substr(0,u)}return h}function y(){if(g>c)return i(null,h);l.start(null,null),l.update(t),l.update(j.util.int32ToBytes(g)),f=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),f=j.util.xorBytes(f,d,o),p=d,++m,j.util.setImmediate(v);h+=g<c?f:f.substr(0,u),++g,y()}g=1,y()},E((function(e){var t=e.exports=j.sha256=j.sha256||{};j.md.sha256=j.md.algorithms.sha256=t,t.create=function(){n||(r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=!0);var e=null,t=j.util.createBuffer(),o=new Array(64),s={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){s.messageLength=0,s.fullMessageLength=s.messageLength64=[];for(var r=s.messageLengthSize/4,n=0;n<r;++n)s.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},s}};return s.start(),s.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var a=r.length;s.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var c=s.fullMessageLength.length-1;c>=0;--c)s.fullMessageLength[c]+=a[1],a[1]=a[0]+(s.fullMessageLength[c]/4294967296>>>0),s.fullMessageLength[c]=s.fullMessageLength[c]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(r),i(e,o,t),(t.read>2048||0===t.length())&&t.compact(),s},s.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var a,c=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize&s.blockLength-1;n.putBytes(r.substr(0,s.blockLength-c));for(var u=8*s.fullMessageLength[0],l=0;l<s.fullMessageLength.length-1;++l)u+=(a=8*s.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=a>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};i(f,o,n);var d=j.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d.putInt32(f.h5),d.putInt32(f.h6),d.putInt32(f.h7),d},s};var r=null,n=!1,a=null;function i(e,t,r){for(var n,i,o,s,c,u,l,f,d,p,h,g,m,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,f=e.h2,d=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|f&(u^l),n=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(g^p&(h^g))+a[c]+t[c],m=g,g=h,h=p,p=d+n>>>0,d=f,f=l,l=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+d|0,e.h4=e.h4+p|0,e.h5=e.h5+h|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}}})),E((function(e){var r=null;!j.util.isNodejs||j.options.usePureJavaScript||process.versions["node-webkit"]||(r=t),(e.exports=j.prng=j.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},n=e.md,a=new Array(32),i=0;i<32;++i)a[i]=n.create();function o(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var a=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(a),t.generated=0}function c(e){var t=null,r=j.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var a=j.util.createBuffer();if(t)for(;a.length()<e;){var i=Math.max(1,Math.min(e-a.length(),65536)/4),o=new Uint32Array(Math.floor(i));try{t(o);for(var s=0;s<o.length;++s)a.putInt32(o[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(a.length()<e)for(var c,u,l,f=Math.floor(65536*Math.random());a.length()<e;)for(u=16807*(65535&f),u+=(32767&(c=16807*(f>>16)))<<16,f=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=f>>>(s<<3),l^=Math.floor(256*Math.random()),a.putByte(String.fromCharCode(255&l));return a.getBytes(e)}return t.pools=a,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,a=t.plugin.increment,i=t.plugin.formatKey,o=t.plugin.formatSeed,c=j.util.createBuffer();t.key=null,function u(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return j.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(u)}));var f=n(t.key,t.seed);t.generated+=f.length,c.putBytes(f),t.key=i(n(t.key,a(t.seed))),t.seed=o(n(t.key,t.seed)),j.util.setImmediate(u)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,a=t.plugin.formatKey,i=t.plugin.formatSeed;t.key=null;for(var s=j.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&o();var c=r(t.key,t.seed);t.generated+=c.length,s.putBytes(c),t.key=a(r(t.key,n(t.seed))),t.seed=i(r(t.key,t.seed))}return s.getBytes(e)},r?(t.seedFile=function(e,t){r.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,c(e))}catch(e){t(e)}},t.seedFileSync=c),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",a=0;a<r;a+=8)n+=String.fromCharCode(e>>a&255);t.collect(n)},t.registerWorker=function(e){e===self?t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})}:e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))},t}})),E((function(e){j.random&&j.random.getBytes?e.exports=j.random:function(t){var r={},n=new Array(4),a=j.util.createBuffer();function i(){var e=j.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=j.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),j.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=j.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return j.aes._updateBlock(e,t,n,!1),a.putInt32(n[0]),a.putInt32(n[1]),a.putInt32(n[2]),a.putInt32(n[3]),a.getBytes()},r.increment=function(e){return++e[3],e},r.md=j.md.sha256;var o=i(),s=null,c=j.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),!j.util.isNodejs&&!s){if(o.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var f in navigator)try{"string"==typeof navigator[f]&&(l+=navigator[f])}catch(e){}o.collect(l),l=null}t&&(t().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),t().keypress((function(e){o.collectInt(e.charCode,8)})))}if(j.random)for(var f in o)j.random[f]=o[f];else j.random=o;j.random.createInstance=i,e.exports=j.random}("undefined"!=typeof jQuery?jQuery:null)}));var ye=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ve=[1,2,3,5],be=function(e,t){return e<<t&65535|(65535&e)>>16-t},Ce=function(e,t){return(65535&e)>>t|e<<16-t&65535};j.rc2=j.rc2||{},j.rc2.expandKey=function(e,t){"string"==typeof e&&(e=j.util.createBuffer(e)),t=t||128;var r,n=e,a=e.length(),i=t,o=Math.ceil(i/8),s=255>>(7&i);for(r=a;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-a)&255]);for(n.setAt(128-o,ye[n.at(128-o)&s]),r=127-o;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+o)]);return n};var Ee,we=function(e,t,r){var n,a,i,o,s=!1,c=null,u=null,l=null,f=[];for(e=j.rc2.expandKey(e,t),i=0;i<64;i++)f.push(e.getInt16Le());r?(n=function(e){for(i=0;i<4;i++)e[i]+=f[o]+(e[(i+3)%4]&e[(i+2)%4])+(~e[(i+3)%4]&e[(i+1)%4]),e[i]=be(e[i],ve[i]),o++},a=function(e){for(i=0;i<4;i++)e[i]+=f[63&e[(i+3)%4]]}):(n=function(e){for(i=3;i>=0;i--)e[i]=Ce(e[i],ve[i]),e[i]-=f[o]+(e[(i+3)%4]&e[(i+2)%4])+(~e[(i+3)%4]&e[(i+1)%4]),o--},a=function(e){for(i=3;i>=0;i--)e[i]-=f[63&e[(i+3)%4]]});var d=function(e){var t=[];for(i=0;i<4;i++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}o=r?0:63;for(var a=0;a<e.length;a++)for(var s=0;s<e[a][0];s++)e[a][1](t);for(i=0;i<4;i++)null!==l&&(r?l.putInt16Le(t[i]):t[i]^=l.getInt16Le()),u.putInt16Le(t[i])},p=null;return p={start:function(e,t){e&&"string"==typeof e&&(e=j.util.createBuffer(e)),s=!1,c=j.util.createBuffer(),u=t||new j.util.createBuffer,l=e,p.output=u},update:function(e){for(s||c.putBuffer(e);c.length()>=8;)d([[5,n],[1,a],[6,n],[1,a],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,c,!r);else{var n=8===c.length()?8:8-c.length();c.fillWithByte(n,n)}if(t&&(s=!0,p.update()),!r&&(t=0===c.length()))if(e)t=e(8,u,!r);else{var a=u.length(),i=u.at(a-1);i>a?t=!1:u.truncate(i)}return t}}};function ke(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function Se(){return new ke(null)}function Be(e,t,r,n,a,i){for(var o=16383&t,s=t>>14;--i>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*o;a=((c=o*c+((16383&l)<<14)+r.data[n]+a)>>28)+(l>>14)+s*u,r.data[n++]=268435455&c}return a}j.rc2.startEncrypting=function(e,t,r){var n=j.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},j.rc2.createEncryptionCipher=function(e,t){return we(e,t,!0)},j.rc2.startDecrypting=function(e,t,r){var n=j.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},j.rc2.createDecryptionCipher=function(e,t){return we(e,t,!1)},j.jsbn=j.jsbn||{},j.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,Ee=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,a,i){for(var o=32767&t,s=t>>15;--i>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*o;a=((c=o*c+((32767&l)<<15)+r.data[n]+(1073741823&a))>>>30)+(l>>>15)+s*u+(a>>>30),r.data[n++]=1073741823&c}return a},Ee=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,a,i){for(;--i>=0;){var o=t*this.data[e++]+r.data[n]+a;a=Math.floor(o/67108864),r.data[n++]=67108863&o}return a},Ee=26):(ke.prototype.am=Be,Ee=28),ke.prototype.DB=Ee,ke.prototype.DM=(1<<Ee)-1,ke.prototype.DV=1<<Ee,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-Ee,ke.prototype.F2=2*Ee-52;var Ae,Te,Ie="0123456789abcdefghijklmnopqrstuvwxyz",_e=new Array;for(Ae="0".charCodeAt(0),Te=0;Te<=9;++Te)_e[Ae++]=Te;for(Ae="a".charCodeAt(0),Te=10;Te<36;++Te)_e[Ae++]=Te;for(Ae="A".charCodeAt(0),Te=10;Te<36;++Te)_e[Ae++]=Te;function xe(e){return Ie.charAt(e)}function Pe(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Re(e){var t=Se();return t.fromInt(e),t}function Ne(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Le(e){this.m=e}function Oe(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function De(e,t){return e&t}function Ue(e,t){return e|t}function Me(e,t){return e^t}function Ve(e,t){return e&~t}function Fe(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function je(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function Ke(){}function ze(e){return e}function qe(e){this.r2=Se(),this.q3=Se(),ke.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Le.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Le.prototype.revert=function(e){return e},Le.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},Le.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Le.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},Oe.prototype.convert=function(e){var t=Se();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ke.ZERO)>0&&this.m.subTo(t,t),t},Oe.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Oe.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Oe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Oe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},ke.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},ke.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},ke.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,a=!1,i=0;--n>=0;){var o=8==r?255&e[n]:Pe(e,n);o<0?"-"==e.charAt(n)&&(a=!0):(a=!1,0==i?this.data[this.t++]=o:i+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-i)-1)<<i,this.data[this.t++]=o>>this.DB-i):this.data[this.t-1]|=o<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,i>0&&(this.data[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),a&&ke.ZERO.subTo(this,this)},ke.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},ke.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},ke.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},ke.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,a=this.DB-n,i=(1<<a)-1,o=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+o+1]=this.data[r]>>a|s,s=(this.data[r]&i)<<n;for(r=o-1;r>=0;--r)t.data[r]=0;t.data[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()},ke.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,a=this.DB-n,i=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)t.data[o-r-1]|=(this.data[o]&i)<<a,t.data[o-r]=this.data[o]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&i)<<a),t.t=this.t-r,t.clamp()}},ke.prototype.subTo=function(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},ke.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),a=r.t;for(t.t=a+n.t;--a>=0;)t.data[a]=0;for(a=0;a<n.t;++a)t.data[a+r.t]=r.am(0,n.data[a],t,a,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ke.ZERO.subTo(t,t)},ke.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},ke.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var a=this.abs();if(a.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Se());var i=Se(),o=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,i),a.lShiftTo(c,r)):(n.copyTo(i),a.copyTo(r));var u=i.t,l=i.data[u-1];if(0!=l){var f=l*(1<<this.F1)+(u>1?i.data[u-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(i.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(i,i);i.t<u;)i.data[i.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*d+(r.data[g-1]+h)*p);if((r.data[g]+=i.am(0,v,r,m,0,u))<v)for(i.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),o!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&ke.ZERO.subTo(r,r)}}},ke.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},ke.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},ke.prototype.exp=function(e,t){if(e>4294967295||e<1)return ke.ONE;var r=Se(),n=Se(),a=t.convert(this),i=Ne(e)-1;for(a.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,a,r);else{var o=r;r=n,n=o}return t.revert(r)},ke.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,a=!1,i="",o=this.t,s=this.DB-o*this.DB%t;if(o-- >0)for(s<this.DB&&(r=this.data[o]>>s)>0&&(a=!0,i=xe(r));o>=0;)s<t?(r=(this.data[o]&(1<<s)-1)<<t-s,r|=this.data[--o]>>(s+=this.DB-t)):(r=this.data[o]>>(s-=t)&n,s<=0&&(s+=this.DB,--o)),r>0&&(a=!0),a&&(i+=xe(r));return a?i:"0"},ke.prototype.negate=function(){var e=Se();return ke.ZERO.subTo(this,e),e},ke.prototype.abs=function(){return this.s<0?this.negate():this},ke.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},ke.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Ne(this.data[this.t-1]^this.s&this.DM)},ke.prototype.mod=function(e){var t=Se();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ke.ZERO)>0&&e.subTo(t,t),t},ke.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new Le(t):new Oe(t),this.exp(e,r)},ke.ZERO=Re(0),ke.ONE=Re(1),Ke.prototype.convert=ze,Ke.prototype.revert=ze,Ke.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},Ke.prototype.sqrTo=function(e,t){e.squareTo(t)},qe.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Se();return e.copyTo(t),this.reduce(t),t},qe.prototype.revert=function(e){return e},qe.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},qe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},qe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var He=[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],Ge=(1<<26)/He[He.length-1];if(ke.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},ke.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Re(r),a=Se(),i=Se(),o="";for(this.divRemTo(n,a,i);a.signum()>0;)o=(r+i.intValue()).toString(e).substr(1)+o,a.divRemTo(n,a,i);return i.intValue().toString(e)+o},ke.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),a=!1,i=0,o=0,s=0;s<e.length;++s){var c=Pe(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(a=!0):(o=t*o+c,++i>=r&&(this.dMultiply(n),this.dAddOffset(o,0),i=0,o=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(o,0)),a&&ke.ZERO.subTo(this,this)},ke.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ke.ONE.shiftLeft(e-1),Ue,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ke.ONE.shiftLeft(e-1),this);else{var n=new Array,a=7&e;n.length=1+(e>>3),t.nextBytes(n),a>0?n[0]&=(1<<a)-1:n[0]=0,this.fromString(n,256)}},ke.prototype.bitwiseTo=function(e,t,r){var n,a,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(a=e.s&this.DM,n=i;n<this.t;++n)r.data[n]=t(this.data[n],a);r.t=this.t}else{for(a=this.s&this.DM,n=i;n<e.t;++n)r.data[n]=t(a,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},ke.prototype.changeBit=function(e,t){var r=ke.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},ke.prototype.addTo=function(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},ke.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},ke.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},ke.prototype.multiplyLowerTo=function(e,t,r){var n,a=Math.min(this.t+e.t,t);for(r.s=0,r.t=a;a>0;)r.data[--a]=0;for(n=r.t-this.t;a<n;++a)r.data[a+this.t]=this.am(0,e.data[a],r,a,0,this.t);for(n=Math.min(e.t,t);a<n;++a)this.am(0,e.data[a],r,a,0,t-a);r.clamp()},ke.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},ke.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},ke.prototype.millerRabin=function(e){var t=this.subtract(ke.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,a=t.shiftRight(r),i={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},o=0;o<e;++o){do{n=new ke(this.bitLength(),i)}while(n.compareTo(ke.ONE)<=0||n.compareTo(t)>=0);var s=n.modPow(a,this);if(0!=s.compareTo(ke.ONE)&&0!=s.compareTo(t)){for(var c=1;c++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ke.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},ke.prototype.clone=function(){var e=Se();return this.copyTo(e),e},ke.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},ke.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},ke.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},ke.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},ke.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,a=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[a++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==a&&(128&this.s)!=(128&r)&&++a,(a>0||r!=this.s)&&(t[a++]=r);return t},ke.prototype.equals=function(e){return 0==this.compareTo(e)},ke.prototype.min=function(e){return this.compareTo(e)<0?this:e},ke.prototype.max=function(e){return this.compareTo(e)>0?this:e},ke.prototype.and=function(e){var t=Se();return this.bitwiseTo(e,De,t),t},ke.prototype.or=function(e){var t=Se();return this.bitwiseTo(e,Ue,t),t},ke.prototype.xor=function(e){var t=Se();return this.bitwiseTo(e,Me,t),t},ke.prototype.andNot=function(e){var t=Se();return this.bitwiseTo(e,Ve,t),t},ke.prototype.not=function(){for(var e=Se(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},ke.prototype.shiftLeft=function(e){var t=Se();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},ke.prototype.shiftRight=function(e){var t=Se();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},ke.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+Fe(this.data[e]);return this.s<0?this.t*this.DB:-1},ke.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=je(this.data[r]^t);return e},ke.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},ke.prototype.setBit=function(e){return this.changeBit(e,Ue)},ke.prototype.clearBit=function(e){return this.changeBit(e,Ve)},ke.prototype.flipBit=function(e){return this.changeBit(e,Me)},ke.prototype.add=function(e){var t=Se();return this.addTo(e,t),t},ke.prototype.subtract=function(e){var t=Se();return this.subTo(e,t),t},ke.prototype.multiply=function(e){var t=Se();return this.multiplyTo(e,t),t},ke.prototype.divide=function(e){var t=Se();return this.divRemTo(e,t,null),t},ke.prototype.remainder=function(e){var t=Se();return this.divRemTo(e,null,t),t},ke.prototype.divideAndRemainder=function(e){var t=Se(),r=Se();return this.divRemTo(e,t,r),new Array(t,r)},ke.prototype.modPow=function(e,t){var r,n,a=e.bitLength(),i=Re(1);if(a<=0)return i;r=a<18?1:a<48?3:a<144?4:a<768?5:6,n=a<8?new Le(t):t.isEven()?new qe(t):new Oe(t);var o=new Array,s=3,c=r-1,u=(1<<r)-1;if(o[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(o[1],l);s<=u;)o[s]=Se(),n.mulTo(l,o[s-2],o[s]),s+=2}var f,d,p=e.t-1,h=!0,g=Se();for(a=Ne(e.data[p])-1;p>=0;){for(a>=c?f=e.data[p]>>a-c&u:(f=(e.data[p]&(1<<a+1)-1)<<c-a,p>0&&(f|=e.data[p-1]>>this.DB+a-c)),s=r;0==(1&f);)f>>=1,--s;if((a-=s)<0&&(a+=this.DB,--p),h)o[f].copyTo(i),h=!1;else{for(;s>1;)n.sqrTo(i,g),n.sqrTo(g,i),s-=2;s>0?n.sqrTo(i,g):(d=i,i=g,g=d),n.mulTo(g,o[f],i)}for(;p>=0&&0==(e.data[p]&1<<a);)n.sqrTo(i,g),d=i,i=g,g=d,--a<0&&(a=this.DB-1,--p)}return n.revert(i)},ke.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ke.ZERO;for(var r=e.clone(),n=this.clone(),a=Re(1),i=Re(0),o=Re(0),s=Re(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(a.isEven()&&i.isEven()||(a.addTo(this,a),i.subTo(e,i)),a.rShiftTo(1,a)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&a.subTo(o,a),i.subTo(s,i)):(n.subTo(r,n),t&&o.subTo(a,o),s.subTo(i,s))}return 0!=n.compareTo(ke.ONE)?ke.ZERO:s.compareTo(e)>=0?s.subtract(e):s.signum()<0?(s.addTo(e,s),s.signum()<0?s.add(e):s):s},ke.prototype.pow=function(e){return this.exp(e,new Ke)},ke.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var a=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(a<i&&(i=a),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(a=t.getLowestSetBit())>0&&t.rShiftTo(a,t),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r},ke.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=He[He.length-1]){for(t=0;t<He.length;++t)if(r.data[0]==He[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<He.length;){for(var n=He[t],a=t+1;a<He.length&&n<Ge;)n*=He[a++];for(n=r.modInt(n);t<a;)if(n%He[t++]==0)return!1}return r.millerRabin(e)},E((function(e){var t=e.exports=j.sha1=j.sha1||{};j.md.sha1=j.md.algorithms.sha1=t,t.create=function(){n||(r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),n=!0);var e=null,t=j.util.createBuffer(),i=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n<r;++n)o.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o}};return o.start(),o.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var s=r.length;o.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=o.fullMessageLength.length-1;c>=0;--c)o.fullMessageLength[c]+=s[1],s[1]=s[0]+(o.fullMessageLength[c]/4294967296>>>0),o.fullMessageLength[c]=o.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),a(e,i,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var s,c=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(r.substr(0,o.blockLength-c));for(var u=8*o.fullMessageLength[0],l=0;l<o.fullMessageLength.length-1;++l)u+=(s=8*o.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(f,i,n);var d=j.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d},o};var r=null,n=!1;function a(e,t,r){for(var n,a,i,o,s,c,u,l=r.length();l>=64;){for(a=e.h0,i=e.h1,o=e.h2,s=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(a<<5|a>>>27)+(s^i&(o^s))+c+1518500249+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(a<<5|a>>>27)+(s^i&(o^s))+c+1518500249+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+1859775393+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+1859775393+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i&o|s&(i^o))+c+2400959708+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+3395469782+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;e.h0=e.h0+a|0,e.h1=e.h1+i|0,e.h2=e.h2+o|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),E((function(e){var t=e.exports=j.pkcs1=j.pkcs1||{};function r(e,t,r){r||(r=j.md.sha1.create());for(var n="",a=Math.ceil(t/r.digestLength),i=0;i<a;++i){var o=String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,255&i);r.start(),r.update(e+o),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var a,i,o,s;"string"==typeof n?(a=n,i=arguments[3]||void 0,o=arguments[4]||void 0):n&&(a=n.label||void 0,i=n.seed||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),o?o.start():o=j.md.sha1.create(),s||(s=o);var c=Math.ceil(e.n.bitLength()/8),u=c-2*o.digestLength-2;if(t.length>u)throw(h=new Error("RSAES-OAEP input message length is too long.")).length=t.length,h.maxLength=u,h;a||(a=""),o.update(a,"raw");for(var l=o.digest(),f="",d=u-t.length,p=0;p<d;p++)f+="\0";var h,g=l.getBytes()+f+""+t;if(i){if(i.length!==o.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=i.length,h.digestLength=o.digestLength,h}else i=j.random.getBytes(o.digestLength);var m=r(i,c-o.digestLength-1,s),y=j.util.xorBytes(g,m,g.length),v=r(y,o.digestLength,s);return"\0"+j.util.xorBytes(i,v,i.length)+y},t.decode_rsa_oaep=function(e,t,n){var a,i,o;"string"==typeof n?(a=n,i=arguments[3]||void 0):n&&(a=n.label||void 0,i=n.md||void 0,n.mgf1&&n.mgf1.md&&(o=n.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(m=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,m.expectedLength=s,m;if(void 0===i?i=j.md.sha1.create():i.start(),o||(o=i),s<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");a||(a=""),i.update(a,"raw");for(var c=i.digest().getBytes(),u=t.charAt(0),l=t.substring(1,i.digestLength+1),f=t.substring(1+i.digestLength),d=r(f,i.digestLength,o),p=r(j.util.xorBytes(l,d,l.length),s-i.digestLength-1,o),h=j.util.xorBytes(f,p,f.length),g=h.substring(0,i.digestLength),m="\0"!==u,y=0;y<i.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=i.digestLength,C=i.digestLength;C<h.length;C++){var E=h.charCodeAt(C);m|=E&(v?65534:0),b+=v&=1&E^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),E((function(e){!function(){if(j.prime)e.exports=j.prime;else{var t=e.exports=j.prime=j.prime||{},r=j.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],a=new r(null);a.fromInt(30);var i=function(e,t){return e|t};t.generateProbablePrime=function(e,t,n){"function"==typeof t&&(n=t,t={});var a=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof a&&(a={name:a}),a.options=a.options||{};var i=t.prng||j.random,c={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===a.name)return function(e,t,n,a){return"workers"in n?function(e,t,n,a){if("undefined"==typeof Worker)return o(e,t,n,a);var i=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,f=n.workerScript||"forge/prime.worker.js";if(-1===c)return j.util.estimateCores((function(e,t){e&&(t=2),c=t-1,d()}));function d(){c=Math.max(1,c);for(var n=[],o=0;o<c;++o)n[o]=new Worker(f);for(o=0;o<c;++o)n[o].addEventListener("message",p);var d=!1;function p(o){if(!d){var c=o.data;if(c.found){for(var f=0;f<n.length;++f)n[f].terminate();return d=!0,a(null,new r(c.prime,16))}i.bitLength()>e&&(i=s(e,t));var p=i.toString(16);o.target.postMessage({hex:p,workLoad:u}),i.dAddOffset(l,0)}}}d()}(e,t,n,a):o(e,t,n,a)}(e,c,a.options,n);throw new Error("Invalid prime generation algorithm: "+a.name)}}function o(e,t,r,a){var i=s(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,a,i,o,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,a)),t.isProbablePrime(o))return u(null,t);t.dAddOffset(n[i++%8],0)}while(c<0||+new Date-l<c);j.util.setImmediate((function(){e(t,r,a,i,o,c,u)}))}(i,e,t,0,o,c,a)}function s(e,t){var n=new r(e,t),o=e-1;return n.testBit(o)||n.bitwiseTo(r.ONE.shiftLeft(o),i,n),n.dAddOffset(31-n.mod(a).byteValue(),0),n}}()})),void 0===Qe)var Qe=j.jsbn.BigInteger;var We=j.util.isNodejs?t:null,Xe=j.asn1,Ye=j.util;j.pki=j.pki||{},j.pki.rsa=j.rsa=j.rsa||{};var $e=j.pki,Ze=[6,4,2,4,2,4,6,2],Je={name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},et={name:"RSAPrivateKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},tt={name:"RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},rt=j.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},nt=function(e){var t;if(!(e.algorithm in $e.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=$e.oids[e.algorithm];var n=Xe.oidToDer(t).getBytes(),a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]),i=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);i.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),i.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return a.value.push(i),a.value.push(o),Xe.toDer(a).getBytes()},at=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(Qe.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(Qe.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new Qe(j.util.bytesToHex(j.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(Qe.ONE));for(var a=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),i=e.mod(t.q).modPow(t.dQ,t.q);a.compareTo(i)<0;)a=a.add(t.p);var o=a.subtract(i).multiply(t.qInv).mod(t.p).multiply(t.q).add(i);return o.multiply(n.modInverse(t.n)).mod(t.n)};function it(e,t,r){var n=j.util.createBuffer(),a=Math.ceil(t.n.bitLength()/8);if(e.length>a-11){var i=new Error("Message is too long for PKCS#1 v1.5 padding.");throw i.length=e.length,i.max=a-11,i}n.putByte(0),n.putByte(r);var o,s=a-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var c=0;c<s;++c)n.putByte(o)}else for(;s>0;){var u=0,l=j.random.getBytes(s);for(c=0;c<s;++c)0===(o=l.charCodeAt(c))?++u:n.putByte(o);s=u}return n.putByte(0),n.putBytes(e),n}function ot(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8),i=j.util.createBuffer(e),o=i.getByte(),s=i.getByte();if(0!==o||r&&0!==s&&1!==s||!r&&2!=s||r&&0===s&&void 0===n)throw new Error("Encryption block is invalid.");var c=0;if(0===s){c=a-3-n;for(var u=0;u<c;++u)if(0!==i.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;i.length()>1;){if(255!==i.getByte()){--i.read;break}++c}else if(2===s)for(c=0;i.length()>1;){if(0===i.getByte()){--i.read;break}++c}if(0!==i.getByte()||c!==a-3-i.length())throw new Error("Encryption block is invalid.");return i.getBytes()}function st(e,t,r){"function"==typeof t&&(r=t,t={});var n={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function a(){i(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?o(t,e.q):void i(e.qBits,o))}))}function i(e,t){j.prime.generateProbablePrime(e,n,t)}function o(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.p=null,void a();if(0!==e.q.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.q=null,void i(e.qBits,o);if(e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(Qe.ONE))return e.p=e.q=null,void a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void i(e.qBits,o);var c=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(n.prng=t.prng),a()}function ct(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=j.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ut(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function lt(e){return j.util.isNodejs&&"function"==typeof We[e]}function ft(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.crypto&&"object"==typeof Ye.globalScope.crypto.subtle&&"function"==typeof Ye.globalScope.crypto.subtle[e]}function dt(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.msCrypto&&"object"==typeof Ye.globalScope.msCrypto.subtle&&"function"==typeof Ye.globalScope.msCrypto.subtle[e]}function pt(e){for(var t=j.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if($e.rsa.encrypt=function(e,t,r){var n,a=r,i=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(a=2===r,n=it(e,t,r)):(n=j.util.createBuffer()).putBytes(e);for(var o=new Qe(n.toHex(),16),s=at(o,t,a).toString(16),c=j.util.createBuffer(),u=i-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(j.util.hexToBytes(s)),c.getBytes()},$e.rsa.decrypt=function(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8);if(e.length!==a){var i=new Error("Encrypted message length is invalid.");throw i.length=e.length,i.expected=a,i}var o=new Qe(j.util.createBuffer(e).toHex(),16);if(o.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=at(o,t,r).toString(16),c=j.util.createBuffer(),u=a-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(j.util.hexToBytes(s)),!1!==n?ot(c.getBytes(),t,r):c.getBytes()},$e.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,a=(r=r||{}).prng||j.random,i={nextBytes:function(e){for(var t=a.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},o=r.algorithm||"PRIMEINC";if("PRIMEINC"!==o)throw new Error("Invalid key generation algorithm: "+o);return(n={algorithm:o,state:0,bits:e,rng:i,eInt:t||65537,e:new Qe(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},$e.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new Qe(null);r.fromInt(30);for(var n,a=0,i=function(e,t){return e|t},o=+new Date,s=0;null===e.keys&&(t<=0||s<t);){if(0===e.state){var c=null===e.p?e.pBits:e.qBits,u=c-1;0===e.pqState?(e.num=new Qe(c,e.rng),e.num.testBit(u)||e.num.bitwiseTo(Qe.ONE.shiftLeft(u),i,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),a=0,++e.pqState):1===e.pqState?e.num.bitLength()>c?e.pqState=0:e.num.isProbablePrime(ut(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Ze[a++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(Qe.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)}}s+=(n=+new Date)-o,o=n}return null!==e.keys},$e.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(lt("generateKeyPair"))return We.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:$e.privateKeyFromPem(r),publicKey:$e.publicKeyFromPem(t)})}));if(ft("generateKey")&&ft("exportKey"))return Ye.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Ye.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=$e.privateKeyFromAsn1(Xe.fromDer(j.util.createBuffer(e)));n(null,{privateKey:t,publicKey:$e.setRsaPublicKey(t.n,t.e)})}}));if(dt("generateKey")&&dt("exportKey")){var a=Ye.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return a.oncomplete=function(e){var t=e.target.result,r=Ye.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=$e.privateKeyFromAsn1(Xe.fromDer(j.util.createBuffer(t)));n(null,{privateKey:r,publicKey:$e.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(a.onerror=function(e){n(e)})}}else if(lt("generateKeyPairSync")){var i=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(i.privateKey),publicKey:$e.publicKeyFromPem(i.publicKey)}}var o=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(o,0),o.keys;st(o,r,n)},$e.setRsaPublicKey=$e.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return it(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return j.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var a=t.encode(e,r,!0);return $e.rsa.encrypt(a,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=ot(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===ot(t,r,!0)}});var a=$e.rsa.decrypt(t,r,!0,!1);return n.verify(e,a,r.n.bitLength())}};return r},$e.setRsaPrivateKey=$e.rsa.setPrivateKey=function(e,t,r,n,a,i,o,s){var c={n:e,e:t,d:r,p:n,q:a,dP:i,dQ:o,qInv:s,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=$e.rsa.decrypt(e,c,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:ot};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return j.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,c,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:nt},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,c.n.bitLength());return $e.rsa.encrypt(n,c,r)}};return c},$e.wrapRsaPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,Xe.toDer(e).getBytes())])},$e.privateKeyFromAsn1=function(e){var t,r,n,a,i,o,s,c,u={},l=[];if(Xe.validate(e,Je,u,l)&&(e=Xe.fromDer(j.util.createBuffer(u.privateKey))),u={},l=[],!Xe.validate(e,et,u,l)){var f=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw f.errors=l,f}return t=j.util.createBuffer(u.privateKeyModulus).toHex(),r=j.util.createBuffer(u.privateKeyPublicExponent).toHex(),n=j.util.createBuffer(u.privateKeyPrivateExponent).toHex(),a=j.util.createBuffer(u.privateKeyPrime1).toHex(),i=j.util.createBuffer(u.privateKeyPrime2).toHex(),o=j.util.createBuffer(u.privateKeyExponent1).toHex(),s=j.util.createBuffer(u.privateKeyExponent2).toHex(),c=j.util.createBuffer(u.privateKeyCoefficient).toHex(),$e.setRsaPrivateKey(new Qe(t,16),new Qe(r,16),new Qe(n,16),new Qe(a,16),new Qe(i,16),new Qe(o,16),new Qe(s,16),new Qe(c,16))},$e.privateKeyToAsn1=$e.privateKeyToRSAPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.d)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.p)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.q)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dP)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dQ)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.qInv))])},$e.publicKeyFromAsn1=function(e){var t={},r=[];if(Xe.validate(e,rt,t,r)){var n,a=Xe.derToOid(t.publicKeyOid);if(a!==$e.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=a,n;e=t.rsaPublicKey}if(r=[],!Xe.validate(e,tt,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var i=j.util.createBuffer(t.publicKeyModulus).toHex(),o=j.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(i,16),new Qe(o,16))},$e.publicKeyToAsn1=$e.publicKeyToSubjectPublicKeyInfo=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.BITSTRING,!1,[$e.publicKeyToRSAPublicKey(e)])])},$e.publicKeyToRSAPublicKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e))])},void 0===ht)var ht=j.jsbn.BigInteger;var gt=j.asn1,mt=j.pki=j.pki||{},yt=(mt.pbe=j.pbe=j.pbe||{},mt.oids),vt={name:"EncryptedPrivateKeyInfo",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},bt={name:"PBES2Algorithms",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},Ct={name:"pkcs-12PbeParams",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"iterations"}]};function Et(e,t){return e.start().update(t).digest().getBytes()}function wt(e){var t;if(e){if(!(t=mt.oids[gt.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return kt(t)}function kt(e){var t=j.md;switch(e){case"hmacWithSHA224":t=j.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}mt.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,a,i,o=j.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,f;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],f=j.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],f=j.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],f=j.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,f=j.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(d),h=j.pkcs5.pbkdf2(t,o,s,n,p),g=j.random.getBytesSync(u);(v=f(h)).start(g),v.update(gt.toDer(e)),v.finish(),i=v.output.getBytes();var m=function(e,t,r,n){var a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,e),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,t.getBytes())]);return"hmacWithSHA1"!==n&&a.value.push(gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,j.util.hexToBytes(r.toString(16))),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(mt.oids[n]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.NULL,!1,"")])),a}(o,c,n,d);a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBES2).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBKDF2).getBytes()),m]),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(l).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,g)])])])}else{var y;if("3des"!==r.algorithm)throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y;n=24;var v,b=new j.util.ByteBuffer(o);h=mt.pbe.generatePkcs12Key(t,b,1,s,n),g=mt.pbe.generatePkcs12Key(t,b,2,s,n),(v=j.des.createEncryptionCipher(h)).start(g),v.update(gt.toDer(e)),v.finish(),i=v.output.getBytes(),a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,o),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,c.getBytes())])])}return gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[a,gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,i)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},a=[];if(!gt.validate(e,vt,n,a)){var i=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=a,i}var o=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(o,n.encryptionParams,t),c=j.util.createBuffer(n.encryptedData);return s.update(c),s.finish()&&(r=gt.fromDer(s.output)),r},mt.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:gt.toDer(e).getBytes()};return j.pem.encode(r,{maxline:t})},mt.encryptedPrivateKeyFromPem=function(e){var t=j.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return gt.fromDer(t.body)},mt.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=mt.wrapRsaPrivateKey(mt.privateKeyToAsn1(e));return n=mt.encryptPrivateKeyInfo(n,t,r),mt.encryptedPrivateKeyToPem(n)}var a,i,o,s;switch(r.algorithm){case"aes128":a="AES-128-CBC",o=16,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",o=24,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",o=32,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",o=24,i=j.random.getBytesSync(8),s=j.des.createEncryptionCipher;break;case"des":a="DES-CBC",o=8,i=j.random.getBytesSync(8),s=j.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=s(j.pbe.opensslDeriveBytes(t,i.substr(0,8),o));u.start(i),u.update(gt.toDer(mt.privateKeyToAsn1(e))),u.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:j.util.bytesToHex(i).toUpperCase()},body:u.output.getBytes()};return j.pem.encode(l)},mt.decryptRsaPrivateKey=function(e,t){var r=null,n=j.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=o,o;if(n.procType&&"ENCRYPTED"===n.procType.type){var a,i;switch(n.dekInfo.algorithm){case"DES-CBC":a=8,i=j.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,i=j.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,i=j.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,i=j.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,i=j.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,i=function(e){return j.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,i=function(e){return j.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,i=function(e){return j.rc2.createDecryptionCipher(e,128)};break;default:var o;throw(o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,o}var s=j.util.hexToBytes(n.dekInfo.parameters),c=i(j.pbe.opensslDeriveBytes(t,s.substr(0,8),a));if(c.start(s),c.update(j.util.createBuffer(n.body)),!c.finish())return r;r=c.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?mt.decryptPrivateKeyInfo(gt.fromDer(r),t):gt.fromDer(r))&&(r=mt.privateKeyFromAsn1(r)),r},mt.pbe.generatePkcs12Key=function(e,t,r,n,a,i){var o,s;if(null==i){if(!("sha1"in j.md))throw new Error('"sha1" hash algorithm unavailable.');i=j.md.sha1.create()}var c=i.digestLength,u=i.blockLength,l=new j.util.ByteBuffer,f=new j.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)f.putInt16(e.charCodeAt(s));f.putInt16(0)}var d=f.length(),p=t.length(),h=new j.util.ByteBuffer;h.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new j.util.ByteBuffer;for(s=0;s<g;s++)m.putByte(t.at(s%p));var y=u*Math.ceil(d/u),v=new j.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(f.at(s%d));var b=m;b.putBuffer(v);for(var C=Math.ceil(a/c),E=1;E<=C;E++){var w=new j.util.ByteBuffer;w.putBytes(h.bytes()),w.putBytes(b.bytes());for(var k=0;k<n;k++)i.start(),i.update(w.getBytes()),w=i.digest();var S=new j.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(w.at(s%c));var B=Math.ceil(p/u)+Math.ceil(d/u),A=new j.util.ByteBuffer;for(o=0;o<B;o++){var T=new j.util.ByteBuffer(b.getBytes(u)),I=511;for(s=S.length()-1;s>=0;s--)I>>=8,I+=S.at(s)+T.at(s),T.setAt(s,255&I);A.putBuffer(T)}b=A,l.putBuffer(w)}return l.truncate(l.length()-a),l},mt.pbe.getCipher=function(e,t,r){switch(e){case mt.oids.pkcs5PBES2:return mt.pbe.getCipherForPBES2(e,t,r);case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:return mt.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},mt.pbe.getCipherForPBES2=function(e,t,r){var n,a={},i=[];if(!gt.validate(t,bt,a,i))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,n;if((e=gt.derToOid(a.kdfOid))!==mt.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=gt.derToOid(a.encOid))!==mt.oids["aes128-CBC"]&&e!==mt.oids["aes192-CBC"]&&e!==mt.oids["aes256-CBC"]&&e!==mt.oids["des-EDE3-CBC"]&&e!==mt.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var o,s,c=a.kdfSalt,u=j.util.createBuffer(a.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":o=16,s=j.aes.createDecryptionCipher;break;case"aes192-CBC":o=24,s=j.aes.createDecryptionCipher;break;case"aes256-CBC":o=32,s=j.aes.createDecryptionCipher;break;case"des-EDE3-CBC":o=24,s=j.des.createDecryptionCipher;break;case"desCBC":o=8,s=j.des.createDecryptionCipher}var l=wt(a.prfOid),f=j.pkcs5.pbkdf2(r,c,u,o,l),d=a.encIv,p=s(f);return p.start(d),p},mt.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},a=[];if(!gt.validate(t,Ct,n,a))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,l;var i,o,s,c=j.util.createBuffer(n.salt),u=j.util.createBuffer(n.iterations);switch(u=u.getInt(u.length()<<3),e){case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:i=24,o=8,s=j.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:i=5,o=8,s=function(e,t){var r=j.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var f=wt(n.prfOid),d=mt.pbe.generatePkcs12Key(r,c,1,u,i,f);return f.start(),s(d,mt.pbe.generatePkcs12Key(r,c,2,u,o,f))},mt.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in j.md))throw new Error('"md5" hash algorithm unavailable.');n=j.md.md5.create()}null===t&&(t="");for(var a=[Et(n,e+t)],i=16,o=1;i<r;++o,i+=16)a.push(Et(n,a[o-1]+e+t));return a.join("").substr(0,r)},E((function(e){var t=j.asn1,r=e.exports=j.pkcs7asn1=j.pkcs7asn1||{};j.pkcs7=j.pkcs7||{},j.pkcs7.asn1=r;var n={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=n;var a={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(a)},r.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(a)};var i={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};r.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},n,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[i]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}})),E((function(e){j.mgf=j.mgf||{},(e.exports=j.mgf.mgf1=j.mgf1=j.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new j.util.ByteBuffer,a=Math.ceil(r/e.digestLength),i=0;i<a;i++){var o=new j.util.ByteBuffer;o.putInt32(i),e.start(),e.update(t+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),j.mgf=j.mgf||{},j.mgf.mgf1=j.mgf1,E((function(e){(e.exports=j.pss=j.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,a=r.digestLength,i=e.salt||null;if("string"==typeof i&&(i=j.util.createBuffer(i)),"saltLength"in e)t=e.saltLength;else{if(null===i)throw new Error("Salt length not specified or specific salt not given.");t=i.length()}if(null!==i&&i.length()!==t)throw new Error("Given salt length does not match length of given salt.");var o=e.prng||j.random;return{encode:function(e,s){var c,u,l=s-1,f=Math.ceil(l/8),d=e.digest().getBytes();if(f<a+t+2)throw new Error("Message is too long to encrypt.");u=null===i?o.getBytesSync(t):i.bytes();var p=new j.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(d),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new j.util.ByteBuffer;g.fillWithByte(0,f-t-a-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=f-a-1,v=n.generate(h,y),b="";for(c=0;c<y;c++)b+=String.fromCharCode(m.charCodeAt(c)^v.charCodeAt(c));var C=65280>>8*f-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,i,o){var s,c=o-1,u=Math.ceil(c/8);if(i=i.substr(-u),u<a+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==i.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-a-1,f=i.substr(0,l),d=i.substr(l,a),p=65280>>8*u-c&255;if(0!=(f.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(d,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(f.charCodeAt(s)^h.charCodeAt(s));g=String.fromCharCode(g.charCodeAt(0)&~p)+g.substr(1);var m=u-a-t-2;for(s=0;s<m;s++)if(0!==g.charCodeAt(s))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(m))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var y=g.substr(-t),v=new j.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(y),r.start(),r.update(v.getBytes()),d===r.digest().getBytes()}}}})),E((function(e){var t=j.asn1,r=e.exports=j.pki=j.pki||{},n=r.oids,a={};a.CN=n.commonName,a.commonName="CN",a.C=n.countryName,a.countryName="C",a.L=n.localityName,a.localityName="L",a.ST=n.stateOrProvinceName,a.stateOrProvinceName="ST",a.O=n.organizationName,a.organizationName="O",a.OU=n.organizationalUnitName,a.organizationalUnitName="OU",a.E=n.emailAddress,a.emailAddress="E";var i=j.pki.rsa.publicKeyValidator,o={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},i,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},s={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},c={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},i,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},u={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[c,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,a=0;null===n&&a<e.attributes.length;++a)r=e.attributes[a],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}r.RDNAttributesAsArray=function(e,r){for(var i,o,s,c=[],u=0;u<e.value.length;++u){i=e.value[u];for(var l=0;l<i.value.length;++l)s={},o=i.value[l],s.type=t.derToOid(o.value[0].value),s.value=o.value[1].value,s.valueTagClass=o.value[1].type,s.type in n&&(s.name=n[s.type],s.name in a&&(s.shortName=a[s.name])),r&&(r.update(s.type),r.update(s.value)),c.push(s)}return c},r.CRIAttributesAsArray=function(e){for(var i=[],o=0;o<e.length;++o)for(var s=e[o],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var f={};if(f.type=c,f.value=u[l].value,f.valueTagClass=u[l].type,f.type in n&&(f.name=n[f.type],f.name in a&&(f.shortName=a[f.name])),f.type===n.extensionRequest){f.extensions=[];for(var d=0;d<f.value.length;++d)f.extensions.push(r.certificateExtensionFromAsn1(f.value[d]))}i.push(f)}return i};var f=function(e,r,a){var i={};if(e!==n["RSASSA-PSS"])return i;a&&(i={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var o={},c=[];if(!t.validate(r,s,o,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==o.hashOid&&(i.hash=i.hash||{},i.hash.algorithmOid=t.derToOid(o.hashOid)),void 0!==o.maskGenOid&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=t.derToOid(o.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=t.derToOid(o.maskGenHashOid)),void 0!==o.saltLength&&(i.saltLength=o.saltLength.charCodeAt(0)),i};function d(e){for(var r,n,a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),i=e.attributes,o=0;o<i.length;++o){var s=(r=i[o]).value,c=t.Type.PRINTABLESTRING;"valueTagClass"in r&&(c=r.valueTagClass)===t.Type.UTF8&&(s=j.util.encodeUtf8(s)),n=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,c,!1,s)])]),a.value.push(n)}return a}function p(e){for(var i,o=0;o<e.length;++o){if(void 0===(i=e[o]).name&&(i.type&&i.type in r.oids?i.name=r.oids[i.type]:i.shortName&&i.shortName in a&&(i.name=r.oids[a[i.shortName]])),void 0===i.type){if(!i.name||!(i.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=i,c;i.type=r.oids[i.name]}if(void 0===i.shortName&&i.name&&i.name in a&&(i.shortName=a[i.name]),i.type===n.extensionRequest&&(i.valueConstructed=!0,i.valueTagClass=t.Type.SEQUENCE,!i.value&&i.extensions)){i.value=[];for(var s=0;s<i.extensions.length;++s)i.value.push(r.certificateExtensionToAsn1(h(i.extensions[s])))}var c;if(void 0===i.value)throw(c=new Error("Attribute value not specified.")).attribute=i,c}}function h(e,a){if(a=a||{},void 0===e.name&&e.id&&e.id in r.oids&&(e.name=r.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in r.oids))throw(C=new Error("Extension ID not specified.")).extension=e,C;e.id=r.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var i=0,o=0,s=0;e.digitalSignature&&(o|=128,i=7),e.nonRepudiation&&(o|=64,i=6),e.keyEncipherment&&(o|=32,i=5),e.dataEncipherment&&(o|=16,i=4),e.keyAgreement&&(o|=8,i=3),e.keyCertSign&&(o|=4,i=2),e.cRLSign&&(o|=2,i=1),e.encipherOnly&&(o|=1,i=0),e.decipherOnly&&(s|=128,i=7);var c=String.fromCharCode(i);0!==s?c+=String.fromCharCode(o)+String.fromCharCode(s):0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c)}else if("basicConstraints"===e.name)e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);var u=e.value.value;for(var l in e)!0===e[l]&&(l in n?u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n[l]).getBytes())):-1!==l.indexOf(".")&&u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes())))}else if("nsCertType"===e.name)i=0,o=0,e.client&&(o|=128,i=7),e.server&&(o|=64,i=6),e.email&&(o|=32,i=5),e.objsign&&(o|=16,i=4),e.reserved&&(o|=8,i=3),e.sslCA&&(o|=4,i=2),e.emailCA&&(o|=2,i=1),e.objCA&&(o|=1,i=0),c=String.fromCharCode(i),0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c);else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);for(var f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).value,7===y.type&&y.ip){if(null===(c=j.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));e.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}}else if("nsComment"===e.name&&a.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=t.create(t.Class.UNIVERSAL,t.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&a.cert){var p=a.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=p.toHex(),e.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p.getBytes())}else if("authorityKeyIdentifier"===e.name&&a.cert){if(e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value,e.keyIdentifier){var h=!0===e.keyIdentifier?a.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;u.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!1,h))}if(e.authorityCertIssuer){var g=[t.create(t.Class.CONTEXT_SPECIFIC,4,!0,[d(!0===e.authorityCertIssuer?a.cert.issuer:e.authorityCertIssuer)])];u.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=j.util.hexToBytes(!0===e.serialNumber?a.cert.serialNumber:e.serialNumber);u.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value;var y,v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),b=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).value,7===y.type&&y.ip){if(null===(c=j.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));b.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}v.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[b])),u.push(v)}var C;if(void 0===e.value)throw(C=new Error("Extension value not specified.")).extension=e,C;return e}function g(e,r){switch(e){case n["RSASSA-PSS"]:var a=[];return void 0!==r.hash.algorithmOid&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),void 0!==r.mgf.algorithmOid&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),void 0!==r.saltLength&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,a);default:return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}}function m(e){var r=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return r;for(var n=e.attributes,a=0;a<n.length;++a){var i=n[a],o=i.value,s=t.Type.UTF8;"valueTagClass"in i&&(s=i.valueTagClass),s===t.Type.UTF8&&(o=j.util.encodeUtf8(o));var c=!1;"valueConstructed"in i&&(c=i.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,o)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,a){var i=j.pem.decode(e)[0];if("CERTIFICATE"!==i.type&&"X509 CERTIFICATE"!==i.type&&"TRUSTED CERTIFICATE"!==i.type){var o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=i.type,o}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(i.body,a);return r.certificateFromAsn1(s,n)},r.certificateToPem=function(e,n){var a={type:"CERTIFICATE",body:t.toDer(r.certificateToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.publicKeyFromPem=function(e){var n=j.pem.decode(e)[0];if("PUBLIC KEY"!==n.type&&"RSA PUBLIC KEY"!==n.type){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.publicKeyFromAsn1(i)},r.publicKeyToPem=function(e,n){var a={type:"PUBLIC KEY",body:t.toDer(r.publicKeyToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.publicKeyToRSAPublicKeyPem=function(e,n){var a={type:"RSA PUBLIC KEY",body:t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.getPublicKeyFingerprint=function(e,n){var a,i=(n=n||{}).md||j.md.sha1.create();switch(n.type||"RSAPublicKey"){case"RSAPublicKey":a=t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":a=t.toDer(r.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+n.type+'".')}i.start(),i.update(a);var o=i.digest();if("hex"===n.encoding){var s=o.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return o.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return o},r.certificationRequestFromPem=function(e,n,a){var i=j.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==i.type){var o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=i.type,o}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(i.body,a);return r.certificationRequestFromAsn1(s,n)},r.certificationRequestToPem=function(e,n){var a={type:"CERTIFICATE REQUEST",body:t.toDer(r.certificationRequestToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return l(e.issuer,t)},e.issuer.addField=function(t){p([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){p(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){p(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)h(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,a=0;null===n&&a<e.extensions.length;++a)r=e.extensions[a],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(a,i){e.md=i||j.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.tbsCertificate=r.getTBSCertificate(e);var c=t.toDer(e.tbsCertificate);e.md.update(c.getBytes()),e.signature=a.sign(e.md)},e.verify=function(a){var i=!1;if(!e.issued(a)){var o=a.issuer,s=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=o.attributes,h.actualIssuer=s.attributes,h}var c=a.md;if(null===c){if(a.signatureOid in n)switch(n[a.signatureOid]){case"sha1WithRSAEncryption":c=j.md.sha1.create();break;case"md5WithRSAEncryption":c=j.md.md5.create();break;case"sha256WithRSAEncryption":c=j.md.sha256.create();break;case"sha384WithRSAEncryption":c=j.md.sha384.create();break;case"sha512WithRSAEncryption":c=j.md.sha512.create();break;case"RSASSA-PSS":c=j.md.sha256.create()}if(null===c)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=a.signatureOid,h;var u=a.tbsCertificate||r.getTBSCertificate(a),l=t.toDer(u);c.update(l.getBytes())}if(null!==c){var f;switch(a.signatureOid){case n.sha1WithRSAEncryption:f=void 0;break;case n["RSASSA-PSS"]:var d,p,h;if(void 0===(d=n[a.signatureParameters.mgf.hash.algorithmOid])||void 0===j.md[d])throw(h=new Error("Unsupported MGF hash function.")).oid=a.signatureParameters.mgf.hash.algorithmOid,h.name=d,h;if(void 0===(p=n[a.signatureParameters.mgf.algorithmOid])||void 0===j.mgf[p])throw(h=new Error("Unsupported MGF function.")).oid=a.signatureParameters.mgf.algorithmOid,h.name=p,h;if(p=j.mgf[p].create(j.md[d].create()),void 0===(d=n[a.signatureParameters.hash.algorithmOid])||void 0===j.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:a.signatureParameters.hash.algorithmOid,name:d};f=j.pss.create(j.md[d].create(),p,a.signatureParameters.saltLength)}i=e.publicKey.verify(c.digest().getBytes(),a.signature,f)}return i},e.isIssuer=function(t){var r=!1,n=e.issuer,a=t.subject;if(n.hash&&a.hash)r=n.hash===a.hash;else if(n.attributes.length===a.attributes.length){var i,o;r=!0;for(var s=0;r&&s<n.attributes.length;++s)i=n.attributes[s],o=a.attributes[s],i.type===o.type&&i.value===o.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=n.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var a=e.extensions[r];if(a.id===t){var i=e.generateSubjectKeyIdentifier().getBytes();return j.util.hexToBytes(a.subjectKeyIdentifier)===i}}return!1},e},r.certificateFromAsn1=function(e,a){var i={},s=[];if(!t.validate(e,o,i,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(i.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=i.certVersion?i.certVersion.charCodeAt(0):0;var u=j.util.createBuffer(i.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=j.asn1.derToOid(i.certSignatureOid),c.signatureParameters=f(c.signatureOid,i.certSignatureParams,!0),c.siginfo.algorithmOid=j.asn1.derToOid(i.certinfoSignatureOid),c.siginfo.parameters=f(c.siginfo.algorithmOid,i.certinfoSignatureParams,!1),c.signature=i.certSignature;var d=[];if(void 0!==i.certValidity1UTCTime&&d.push(t.utcTimeToDate(i.certValidity1UTCTime)),void 0!==i.certValidity2GeneralizedTime&&d.push(t.generalizedTimeToDate(i.certValidity2GeneralizedTime)),void 0!==i.certValidity3UTCTime&&d.push(t.utcTimeToDate(i.certValidity3UTCTime)),void 0!==i.certValidity4GeneralizedTime&&d.push(t.generalizedTimeToDate(i.certValidity4GeneralizedTime)),d.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=i.tbsCertificate,a){var h;if(c.md=null,c.signatureOid in n)switch(n[c.signatureOid]){case"sha1WithRSAEncryption":c.md=j.md.sha1.create();break;case"md5WithRSAEncryption":c.md=j.md.md5.create();break;case"sha256WithRSAEncryption":c.md=j.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=j.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=j.md.sha512.create();break;case"RSASSA-PSS":c.md=j.md.sha256.create()}if(null===c.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,h;var g=t.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var m=j.md.sha1.create();c.issuer.getField=function(e){return l(c.issuer,e)},c.issuer.addField=function(e){p([e]),c.issuer.attributes.push(e)},c.issuer.attributes=r.RDNAttributesAsArray(i.certIssuer,m),i.certIssuerUniqueId&&(c.issuer.uniqueId=i.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var y=j.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){p([e]),c.subject.attributes.push(e)},c.subject.attributes=r.RDNAttributesAsArray(i.certSubject,y),i.certSubjectUniqueId&&(c.subject.uniqueId=i.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),i.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(i.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(i.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var a=e.value[n],i=0;i<a.value.length;++i)t.push(r.certificateExtensionFromAsn1(a.value[i]));return t},r.certificateExtensionFromAsn1=function(e){var r={};if(r.id=t.derToOid(e.value[0].value),r.critical=!1,e.value[1].type===t.Type.BOOLEAN?(r.critical=0!==e.value[1].value.charCodeAt(0),r.value=e.value[2].value):r.value=e.value[1].value,r.id in n)if(r.name=n[r.id],"keyUsage"===r.name){var a=0,i=0;(s=t.fromDer(r.value)).value.length>1&&(a=s.value.charCodeAt(1),i=s.value.length>2?s.value.charCodeAt(2):0),r.digitalSignature=128==(128&a),r.nonRepudiation=64==(64&a),r.keyEncipherment=32==(32&a),r.dataEncipherment=16==(16&a),r.keyAgreement=8==(8&a),r.keyCertSign=4==(4&a),r.cRLSign=2==(2&a),r.encipherOnly=1==(1&a),r.decipherOnly=128==(128&i)}else if("basicConstraints"===r.name){(s=t.fromDer(r.value)).value.length>0&&s.value[0].type===t.Type.BOOLEAN?r.cA=0!==s.value[0].value.charCodeAt(0):r.cA=!1;var o=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?o=s.value[0].value:s.value.length>1&&(o=s.value[1].value),null!==o&&(r.pathLenConstraint=t.derToInteger(o))}else if("extKeyUsage"===r.name)for(var s=t.fromDer(r.value),c=0;c<s.value.length;++c){var u=t.derToOid(s.value[c].value);u in n?r[n[u]]=!0:r[u]=!0}else if("nsCertType"===r.name)a=0,(s=t.fromDer(r.value)).value.length>1&&(a=s.value.charCodeAt(1)),r.client=128==(128&a),r.server=64==(64&a),r.email=32==(32&a),r.objsign=16==(16&a),r.reserved=8==(8&a),r.sslCA=4==(4&a),r.emailCA=2==(2&a),r.objCA=1==(1&a);else if("subjectAltName"===r.name||"issuerAltName"===r.name){var l;r.altNames=[],s=t.fromDer(r.value);for(var f=0;f<s.value.length;++f){var d={type:(l=s.value[f]).type,value:l.value};switch(r.altNames.push(d),l.type){case 1:case 2:case 6:break;case 7:d.ip=j.util.bytesToIP(l.value);break;case 8:d.oid=t.derToOid(l.value)}}}else"subjectKeyIdentifier"===r.name&&(s=t.fromDer(r.value),r.subjectKeyIdentifier=j.util.bytesToHex(s.value));return r},r.certificationRequestFromAsn1=function(e,a){var i={},o=[];if(!t.validate(e,u,i,o))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=o,c;if(t.derToOid(i.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,s.signatureOid=j.asn1.derToOid(i.csrSignatureOid),s.signatureParameters=f(s.signatureOid,i.csrSignatureParams,!0),s.siginfo.algorithmOid=j.asn1.derToOid(i.csrSignatureOid),s.siginfo.parameters=f(s.siginfo.algorithmOid,i.csrSignatureParams,!1),s.signature=i.csrSignature,s.certificationRequestInfo=i.certificationRequestInfo,a){var c;if(s.md=null,s.signatureOid in n)switch(n[s.signatureOid]){case"sha1WithRSAEncryption":s.md=j.md.sha1.create();break;case"md5WithRSAEncryption":s.md=j.md.md5.create();break;case"sha256WithRSAEncryption":s.md=j.md.sha256.create();break;case"sha384WithRSAEncryption":s.md=j.md.sha384.create();break;case"sha512WithRSAEncryption":s.md=j.md.sha512.create();break;case"RSASSA-PSS":s.md=j.md.sha256.create()}if(null===s.md)throw(c=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=s.signatureOid,c;var d=t.toDer(s.certificationRequestInfo);s.md.update(d.getBytes())}var h=j.md.sha1.create();return s.subject.getField=function(e){return l(s.subject,e)},s.subject.addField=function(e){p([e]),s.subject.attributes.push(e)},s.subject.attributes=r.RDNAttributesAsArray(i.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(i.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(i.certificationRequestInfoAttributes||[]),s},r.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return l(e,t)},e.addAttribute=function(t){p([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){p(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){p(t),e.attributes=t},e.sign=function(a,i){e.md=i||j.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.certificationRequestInfo=r.getCertificationRequestInfo(e);var c=t.toDer(e.certificationRequestInfo);e.md.update(c.getBytes()),e.signature=a.sign(e.md)},e.verify=function(){var a=!1,i=e.md;if(null===i){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":i=j.md.sha1.create();break;case"md5WithRSAEncryption":i=j.md.md5.create();break;case"sha256WithRSAEncryption":i=j.md.sha256.create();break;case"sha384WithRSAEncryption":i=j.md.sha384.create();break;case"sha512WithRSAEncryption":i=j.md.sha512.create();break;case"RSASSA-PSS":i=j.md.sha256.create()}if(null===i)throw(f=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,f;var o=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(o);i.update(s.getBytes())}if(null!==i){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,f;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===j.md[u])throw(f=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,f.name=u,f;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===j.mgf[l])throw(f=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,f.name=l,f;if(l=j.mgf[l].create(j.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===j.md[u])throw(f=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,f.name=u,f;c=j.pss.create(j.md[u].create(),l,e.signatureParameters.saltLength)}a=e.publicKey.verify(i.digest().getBytes(),e.signature,c)}return a},e};var y=new Date("1950-01-01T00:00:00Z"),v=new Date("2050-01-01T00:00:00Z");function b(e){return e>=y&&e<v?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(e)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(e))}r.getTBSCertificate=function(e){var n=b(e.validity.notBefore),a=b(e.validity.notAfter),i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(e.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.siginfo.algorithmOid).getBytes()),g(e.siginfo.algorithmOid,e.siginfo.parameters)]),d(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,a]),d(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&i.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&i.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&i.value.push(r.certificateExtensionsToAsn1(e.extensions)),i},r.getCertificationRequestInfo=function(e){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),d(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return d(e)},r.certificateToAsn1=function(e){var n=e.tbsCertificate||r.getTBSCertificate(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.certificateExtensionsToAsn1=function(e){var n=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);n.value.push(a);for(var i=0;i<e.length;++i)a.value.push(r.certificateExtensionToAsn1(e[i]));return n},r.certificateExtensionToAsn1=function(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.id).getBytes())),e.critical&&r.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255)));var n=e.value;return"string"!=typeof e.value&&(n=t.toDer(n).getBytes()),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)),r},r.certificationRequestToAsn1=function(e){var n=e.certificationRequestInfo||r.getCertificationRequestInfo(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.createCaStore=function(e){var n={certs:{}};function a(e){return i(e),n.certs[e.hash]||null}function i(e){if(!e.hash){var t=j.md.sha1.create();e.attributes=r.RDNAttributesAsArray(d(e),t),e.hash=t.digest().toHex()}}if(n.getIssuer=function(e){return a(e.issuer)},n.addCertificate=function(e){if("string"==typeof e&&(e=j.pki.certificateFromPem(e)),i(e.subject),!n.hasCertificate(e))if(e.subject.hash in n.certs){var t=n.certs[e.subject.hash];j.util.isArray(t)||(t=[t]),t.push(e),n.certs[e.subject.hash]=t}else n.certs[e.subject.hash]=e},n.hasCertificate=function(e){"string"==typeof e&&(e=j.pki.certificateFromPem(e));var n=a(e.subject);if(!n)return!1;j.util.isArray(n)||(n=[n]);for(var i=t.toDer(r.certificateToAsn1(e)).getBytes(),o=0;o<n.length;++o)if(i===t.toDer(r.certificateToAsn1(n[o])).getBytes())return!0;return!1},n.listAllCertificates=function(){var e=[];for(var t in n.certs)if(n.certs.hasOwnProperty(t)){var r=n.certs[t];if(j.util.isArray(r))for(var a=0;a<r.length;++a)e.push(r[a]);else e.push(r)}return e},n.removeCertificate=function(e){var o;if("string"==typeof e&&(e=j.pki.certificateFromPem(e)),i(e.subject),!n.hasCertificate(e))return null;var s=a(e.subject);if(!j.util.isArray(s))return o=n.certs[e.subject.hash],delete n.certs[e.subject.hash],o;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(o=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],o},e)for(var o=0;o<e.length;++o){var s=e[o];n.addCertificate(s)}return n},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(e,t,n){"function"==typeof n&&(n={verify:n}),n=n||{};var a=(t=t.slice(0)).slice(0),i=n.validityCheckDate;void 0===i&&(i=new Date);var o=!0,s=null,c=0;do{var u=t.shift(),l=null,f=!1;if(i&&(i<u.validity.notBefore||i>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:i}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(f=!0,l=u),l){var d=l;j.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){l=d.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!f||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(null===s&&l&&!u.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),null===s)for(var h={keyUsage:!0,basicConstraints:!0},g=0;null===s&&g<u.extensions.length;++g){var m=u.extensions[g];!m.critical||m.name in h||(s={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(null===s&&(!o||0===t.length&&(!l||f))){var y=u.getExtension("basicConstraints"),v=u.getExtension("keyUsage");null!==v&&(v.keyCertSign&&null!==y||(s={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:r.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===s&&null!==v&&"pathLenConstraint"in y&&c-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}var b=null===s||s.error,C=n.verify?n.verify(b,c,a):b;if(!0!==C)throw!0===b&&(s={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||j.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,o=!1,++c}while(t.length>0);return!0}})),E((function(e){var t=j.asn1,r=j.pki,n=e.exports=j.pkcs12=j.pkcs12||{},a={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},i={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},a,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},o={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},s={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},c={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function u(e,t,r,n){for(var a=[],i=0;i<e.length;i++)for(var o=0;o<e[i].safeBags.length;o++){var s=e[i].safeBags[o];void 0!==n&&s.type!==n||(null!==t?void 0!==s.attributes[t]&&s.attributes[t].indexOf(r)>=0&&a.push(s):a.push(s))}return a}function l(e){if(e.composed||e.constructed){for(var t=j.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function f(e,n){var a={},i=[];if(!t.validate(e,j.pkcs7.asn1.encryptedDataValidator,a,i))throw(o=new Error("Cannot read EncryptedContentInfo.")).errors=i,o;var o,s=t.derToOid(a.contentType);if(s!==r.oids.data)throw(o=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,o;s=t.derToOid(a.encAlgorithm);var c=r.pbe.getCipher(s,a.encParameter,n),u=l(a.encryptedContentAsn1),f=j.util.createBuffer(u.value);if(c.update(f),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function d(e,n,a){if(!n&&0===e.length)return[];if((e=t.fromDer(e,n)).tagClass!==t.Class.UNIVERSAL||e.type!==t.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var i=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},f=[];if(!t.validate(u,o,l,f))throw(y=new Error("Cannot read SafeBag.")).errors=f,y;var d,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};i.push(g);var m=l.bagValue.value[0];switch(g.type){case r.oids.pkcs8ShroudedKeyBag:if(null===(m=r.decryptPrivateKeyInfo(m,a)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{g.key=r.privateKeyFromAsn1(m)}catch(e){g.key=null,g.asn1=m}continue;case r.oids.certBag:d=c,h=function(){if(t.derToOid(l.certId)!==r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=t.derToOid(l.certId),e}var a=t.fromDer(l.cert,n);try{g.cert=r.certificateFromAsn1(a,!0)}catch(e){g.cert=null,g.asn1=a}};break;default:var y;throw(y=new Error("Unsupported PKCS#12 SafeBag type.")).oid=g.type,y}if(void 0!==d&&!t.validate(m,d,l,f))throw(y=new Error("Cannot read PKCS#12 "+d.name)).errors=f,y;h()}return i}function p(e){var n={};if(void 0!==e)for(var a=0;a<e.length;++a){var i={},o=[];if(!t.validate(e[a],s,i,o)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=o,c}var u=t.derToOid(i.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<i.values.length;++l)n[r.oids[u]].push(i.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,o,s){"string"==typeof o?(s=o,o=!0):void 0===o&&(o=!0);var c={};if(!t.validate(e,i,c,[]))throw(p=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=p,p;var p,h={version:c.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=j.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=u(h.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=u(h.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=u(h.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return u(h.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return u(h.safeContents,"localKeyId",e,t)}};if(3!==c.version.charCodeAt(0))throw(p=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=c.version.charCodeAt(0),p;if(t.derToOid(c.contentType)!==r.oids.data)throw(p=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=t.derToOid(c.contentType),p;var g=c.content.value[0];if(g.tagClass!==t.Class.UNIVERSAL||g.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(g=l(g),c.mac){var m=null,y=0,v=t.derToOid(c.macAlgorithm);switch(v){case r.oids.sha1:m=j.md.sha1.create(),y=20;break;case r.oids.sha256:m=j.md.sha256.create(),y=32;break;case r.oids.sha384:m=j.md.sha384.create(),y=48;break;case r.oids.sha512:m=j.md.sha512.create(),y=64;break;case r.oids.md5:m=j.md.md5.create(),y=16}if(null===m)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+v);var b=new j.util.ByteBuffer(c.macSalt),C="macIterations"in c?parseInt(j.util.bytesToHex(c.macIterations),16):1,E=n.generateKey(s,b,3,C,y,m),w=j.hmac.create();if(w.start(m,E),w.update(g.value),w.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,i,o){if((n=t.fromDer(n,i)).tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||!0!==n.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var s=0;s<n.value.length;s++){var c=n.value[s],u={},p=[];if(!t.validate(c,a,u,p))throw(y=new Error("Cannot read ContentInfo.")).errors=p,y;var h={encrypted:!1},g=null,m=u.content.value[0];switch(t.derToOid(u.contentType)){case r.oids.data:if(m.tagClass!==t.Class.UNIVERSAL||m.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");g=l(m).value;break;case r.oids.encryptedData:g=f(m,o),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=d(g,i,o),e.safeContents.push(h)}}(h,g.value,o,s),h},n.toPkcs12Asn1=function(e,a,i,o){(o=o||{}).saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128","useMac"in o||(o.useMac=!0),"localKeyId"in o||(o.localKeyId=null),"generateLocalKeyId"in o||(o.generateLocalKeyId=!0);var s,c=o.localKeyId;if(null!==c)c=j.util.hexToBytes(c);else if(o.generateLocalKeyId)if(a){var u=j.util.isArray(a)?a[0]:a;"string"==typeof u&&(u=r.certificateFromPem(u)),(A=j.md.sha1.create()).update(t.toDer(r.certificateToAsn1(u)).getBytes()),c=A.digest().getBytes()}else c=j.random.getBytes(20);var l=[];null!==c&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,c)])])),"friendlyName"in o&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var f=[],d=[];null!==a&&(d=j.util.isArray(a)?a:[a]);for(var p=[],h=0;h<d.length;++h){"string"==typeof(a=d[h])&&(a=r.certificateFromPem(a));var g=0===h?s:void 0,m=r.certificateToAsn1(a),y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(m).getBytes())])])]),g]);p.push(y)}if(p.length>0){var v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,p),b=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(v).getBytes())])]);f.push(b)}var C=null;if(null!==e){var E=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===i?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[E]),s]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(E,i,o)]),s]);var w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[C]),k=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(w).getBytes())])]);f.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,f);if(o.useMac){var A=j.md.sha1.create(),T=new j.util.ByteBuffer(j.random.getBytes(o.saltSize)),I=o.count,_=(e=n.generateKey(i,T,3,I,20),j.hmac.create());_.start(A,e),_.update(t.toDer(B).getBytes());var x=_.getMac();S=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,x.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,T.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(I).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(B).getBytes())])]),S])},n.generateKey=j.pbe.generatePkcs12Key})),E((function(e){var t=j.asn1,r=e.exports=j.pki=j.pki||{};r.pemToDer=function(e){var t=j.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return j.util.createBuffer(t.body)},r.privateKeyFromPem=function(e){var n=j.pem.decode(e)[0];if("PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.privateKeyFromAsn1(i)},r.privateKeyToPem=function(e,n){var a={type:"RSA PRIVATE KEY",body:t.toDer(r.privateKeyToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.privateKeyInfoToPem=function(e,r){var n={type:"PRIVATE KEY",body:t.toDer(e).getBytes()};return j.pem.encode(n,{maxline:r})}}));var St=function(e,t,r,n){var a=j.util.createBuffer(),i=e.length>>1,o=i+(1&e.length),s=e.substr(0,o),c=e.substr(i,o),u=j.util.createBuffer(),l=j.hmac.create();r=t+r;var f=Math.ceil(n/16),d=Math.ceil(n/20);l.start("MD5",s);var p=j.util.createBuffer();u.putBytes(r);for(var h=0;h<f;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),p.putBuffer(l.digest());l.start("SHA1",c);var g=j.util.createBuffer();for(u.clear(),u.putBytes(r),h=0;h<d;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),g.putBuffer(l.digest());return a.putBytes(j.util.xorBytes(p.getBytes(),g.getBytes(),n)),a},Bt=function(e,t,r){var n=!1;try{var a=e.deflate(t.fragment.getBytes());t.fragment=j.util.createBuffer(a),t.length=a.length,n=!0}catch(e){}return n},At=function(e,t,r){var n=!1;try{var a=e.inflate(t.fragment.getBytes());t.fragment=j.util.createBuffer(a),t.length=a.length,n=!0}catch(e){}return n},Tt=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return j.util.createBuffer(e.getBytes(r))},It=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},_t={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};_t.SupportedVersions=[_t.Versions.TLS_1_1,_t.Versions.TLS_1_0],_t.Version=_t.SupportedVersions[0],_t.MaxFragment=15360,_t.ConnectionEnd={server:0,client:1},_t.PRFAlgorithm={tls_prf_sha256:0},_t.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},_t.CipherType={stream:0,block:1,aead:2},_t.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},_t.CompressionMethod={none:0,deflate:1},_t.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},_t.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},_t.Alert={},_t.Alert.Level={warning:1,fatal:2},_t.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},_t.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},_t.CipherSuites={},_t.getCipherSuite=function(e){var t=null;for(var r in _t.CipherSuites){var n=_t.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},_t.handleUnexpected=function(e,t){!e.open&&e.entity===_t.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})},_t.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(_t.queue(e,_t.createAlert(e,{level:_t.Alert.Level.warning,description:_t.Alert.Description.no_renegotiation})),_t.flush(e)),e.process()},_t.parseHelloMessage=function(e,t,r){var n=null,a=e.entity===_t.ConnectionEnd.client;if(r<38)e.error(e,{message:a?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});else{var i=t.fragment,o=i.length();if(n={version:{major:i.getByte(),minor:i.getByte()},random:j.util.createBuffer(i.getBytes(32)),session_id:Tt(i,1),extensions:[]},a?(n.cipher_suite=i.getBytes(2),n.compression_method=i.getByte()):(n.cipher_suites=Tt(i,2),n.compression_methods=Tt(i,1)),(o=r-(o-i.length()))>0){for(var s=Tt(i,2);s.length()>0;)n.extensions.push({type:[s.getByte(),s.getByte()],data:Tt(s,2)});if(!a)for(var c=0;c<n.extensions.length;++c){var u=n.extensions[c];if(0===u.type[0]&&0===u.type[1])for(var l=Tt(u.data,2);l.length()>0&&0===l.getByte();)e.session.extensions.server_name.serverNameList.push(Tt(l,2).getBytes())}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});if(a)e.session.cipherSuite=_t.getCipherSuite(n.cipher_suite);else for(var f=j.util.createBuffer(n.cipher_suites.bytes());f.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(f.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure},cipherSuite:j.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=a?n.compression_method:_t.CompressionMethod.none}return n},_t.createSecurityParameters=function(e,t){var r=e.entity===_t.ConnectionEnd.client,n=t.random.bytes(),a=r?e.session.sp.client_random:n,i=r?n:_t.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:_t.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:a,server_random:i}},_t.handleServerHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var a=n.session_id.bytes();a.length>0&&a===e.session.id?(e.expect=Lt,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=xt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.session.id=a,e.process()}},_t.handleClientHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){var a=n.session_id.bytes(),i=null;if(e.sessionCache&&(null===(i=e.sessionCache.getSession(a))?a="":(i.version.major!==n.version.major||i.version.minor>n.version.minor)&&(i=null,a="")),0===a.length&&(a=j.random.getBytes(32)),e.session.id=a,e.session.clientHelloVersion=n.version,e.session.sp={},i)e.version=e.session.version=i.version,e.session.sp=i.sp;else{for(var o,s=1;s<_t.SupportedVersions.length&&!((o=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:o.major,minor:o.minor},e.session.version=e.version}null!==i?(e.expect=jt,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?Mt:Vt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.open=!0,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHello(e)})),e.session.resuming?(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))):(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)})),e.fail||(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerKeyExchange(e)})),!1!==e.verifyClient&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateRequest(e)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHelloDone(e)})))),_t.flush(e),e.process()}},_t.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n,a,i=t.fragment,o={certificate_list:Tt(i,3)},s=[];try{for(;o.certificate_list.length()>0;)n=Tt(o.certificate_list,3),a=j.asn1.fromDer(n),n=j.pki.certificateFromAsn1(a,!0),s.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var c=e.entity===_t.ConnectionEnd.client;!c&&!0!==e.verifyClient||0!==s.length?0===s.length?e.expect=c?Pt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Pt:Vt)):e.error(e,{message:c?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}}),e.process()},_t.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});e.expect=Rt,e.process()},_t.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});var n=t.fragment,a={enc_pre_master_secret:Tt(n,2).getBytes()},i=null;if(e.getPrivateKey)try{i=e.getPrivateKey(e,e.session.serverCertificate),i=j.pki.privateKeyFromPem(i)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}if(null===i)return e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}});try{var o=e.session.sp;o.pre_master_secret=i.decrypt(a.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==o.pre_master_secret.charCodeAt(0)||s.minor!==o.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){o.pre_master_secret=j.random.getBytes(48)}e.expect=jt,null!==e.session.clientCertificate&&(e.expect=Ft),e.process()},_t.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment,a={certificate_types:Tt(n,1),certificate_authorities:Tt(n,2)};e.session.certificateRequest=a,e.expect=Nt,e.process()},_t.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var i={signature:Tt(n,2).getBytes()},o=j.util.createBuffer();o.putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest()),o=o.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(o,i.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(a),e.session.sha1.update(a)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure}})}e.expect=jt,e.process()},_t.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.insufficient_security}},a=e.verify(e,n.alert.description,0,[]);if(!0!==a)return(a||0===a)&&("object"!=typeof a||j.util.isArray(a)?"number"==typeof a&&(n.alert.description=a):(a.message&&(n.message=a.message),a.alert&&(n.alert.description=a.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)}),_t.queue(e,t)),t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createClientKeyExchange(e)}),_t.queue(e,t),e.expect=Ut;var i=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateVerify(e,t)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)})),e.expect=Lt,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return i(e,null);_t.getClientSignature(e,i)},_t.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var r=e.entity===_t.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=_t.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?Ot:Kt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var i=t.fragment.getBytes();(n=j.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var o=e.entity===_t.ConnectionEnd.client,s=o?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==i)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decrypt_error}});e.session.md5.update(a),e.session.sha1.update(a),(e.session.resuming&&o||!e.session.resuming&&!o)&&(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))),e.expect=o?Dt:zt,e.handshaking=!1,++e.handshakes,e.peerCertificate=o?e.session.serverCertificate:e.session.clientCertificate,_t.flush(e),e.isConnected=!0,e.connected(e),e.process()},_t.handleAlert=function(e,t){var r,n=t.fragment,a={level:n.getByte(),description:n.getByte()};switch(a.description){case _t.Alert.Description.close_notify:r="Connection closed.";break;case _t.Alert.Description.unexpected_message:r="Unexpected message.";break;case _t.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case _t.Alert.Description.decryption_failed:r="Decryption failed.";break;case _t.Alert.Description.record_overflow:r="Record overflow.";break;case _t.Alert.Description.decompression_failure:r="Decompression failed.";break;case _t.Alert.Description.handshake_failure:r="Handshake failure.";break;case _t.Alert.Description.bad_certificate:r="Bad certificate.";break;case _t.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case _t.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case _t.Alert.Description.certificate_expired:r="Certificate expired.";break;case _t.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case _t.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case _t.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case _t.Alert.Description.access_denied:r="Access denied.";break;case _t.Alert.Description.decode_error:r="Decode error.";break;case _t.Alert.Description.decrypt_error:r="Decrypt error.";break;case _t.Alert.Description.export_restriction:r="Export restriction.";break;case _t.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case _t.Alert.Description.insufficient_security:r="Insufficient security.";break;case _t.Alert.Description.internal_error:r="Internal error.";break;case _t.Alert.Description.user_canceled:r="User canceled.";break;case _t.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(a.description===_t.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===_t.ConnectionEnd.client?"server":"client",alert:a}),e.process()},_t.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt24();if(a>r.length())return e.fragmented=t,t.fragment=j.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var i=r.bytes(a+4);r.read+=4,n in ar[e.entity][e.expect]?(e.entity!==_t.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:j.md.md5.create(),sha1:j.md.sha1.create()}),n!==_t.HandshakeType.hello_request&&n!==_t.HandshakeType.certificate_verify&&n!==_t.HandshakeType.finished&&(e.session.md5.update(i),e.session.sha1.update(i)),ar[e.entity][e.expect][n](e,t,a)):_t.handleUnexpected(e,t)},_t.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},_t.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt16(),i=r.getBytes(a);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||a>i.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,i)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(i!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,j.util.createBuffer(i))}e.process()};var xt=1,Pt=2,Rt=3,Nt=4,Lt=5,Ot=6,Dt=7,Ut=8,Mt=1,Vt=2,Ft=3,jt=4,Kt=5,zt=6,qt=_t.handleUnexpected,Ht=_t.handleChangeCipherSpec,Gt=_t.handleAlert,Qt=_t.handleHandshake,Wt=_t.handleApplicationData,Xt=_t.handleHeartbeat,Yt=[];Yt[_t.ConnectionEnd.client]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]],Yt[_t.ConnectionEnd.server]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]];var $t=_t.handleHelloRequest,Zt=_t.handleServerHello,Jt=_t.handleCertificate,er=_t.handleServerKeyExchange,tr=_t.handleCertificateRequest,rr=_t.handleServerHelloDone,nr=_t.handleFinished,ar=[];ar[_t.ConnectionEnd.client]=[[qt,qt,Zt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]];var ir=_t.handleClientHello,or=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ar[_t.ConnectionEnd.server]=[[qt,ir,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,or,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,sr,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]],_t.generateKeys=function(e,t){var r=St,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var a=2*t.mac_key_length+2*t.enc_key_length,i=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;i&&(a+=2*t.fixed_iv_length);var o=r(t.master_secret,"key expansion",n,a),s={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return i&&(s.client_write_IV=o.getBytes(t.fixed_iv_length),s.server_write_IV=o.getBytes(t.fixed_iv_length)),s},_t.createConnectionState=function(e){var t=e.entity===_t.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}),!e.fail},e.session){var a=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(a),a.keys=_t.generateKeys(e,a),n.read.macKey=t?a.keys.server_write_MAC_key:a.keys.client_write_MAC_key,n.write.macKey=t?a.keys.client_write_MAC_key:a.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,a),a.compression_algorithm){case _t.CompressionMethod.none:break;case _t.CompressionMethod.deflate:n.read.compressFunction=At,n.write.compressFunction=Bt;break;default:throw new Error("Unsupported compression algorithm.")}}return n},_t.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=j.util.createBuffer();return r.putInt32(t),r.putBytes(j.random.getBytes(28)),r},_t.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},_t.createAlert=function(e,t){var r=j.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),_t.createRecord(e,{type:_t.ContentType.alert,data:r})},_t.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=j.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var a=t.length(),i=j.util.createBuffer();i.putByte(_t.CompressionMethod.none);var o=i.length(),s=j.util.createBuffer();if(e.virtualHost){var c=j.util.createBuffer();c.putByte(0),c.putByte(0);var u=j.util.createBuffer();u.putByte(0),It(u,2,j.util.createBuffer(e.virtualHost));var l=j.util.createBuffer();It(l,2,u),It(c,2,l),s.putBuffer(c)}var f=s.length();f>0&&(f+=2);var d=e.session.id,p=d.length+1+2+4+28+2+a+1+o+f,h=j.util.createBuffer();return h.putByte(_t.HandshakeType.client_hello),h.putInt24(p),h.putByte(e.version.major),h.putByte(e.version.minor),h.putBytes(e.session.sp.client_random),It(h,1,j.util.createBuffer(d)),It(h,2,t),It(h,1,i),f>0&&It(h,2,s),h},_t.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=j.util.createBuffer();return n.putByte(_t.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),It(n,1,j.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},_t.createCertificate=function(e){var t,r=e.entity===_t.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var a=j.util.createBuffer();if(null!==n)try{j.util.isArray(n)||(n=[n]);for(var i=null,o=0;o<n.length;++o){var s=j.pem.decode(n[o])[0];if("CERTIFICATE"!==s.type&&"X509 CERTIFICATE"!==s.type&&"TRUSTED CERTIFICATE"!==s.type){var c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=s.type,c}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var u=j.util.createBuffer(s.body);null===i&&(i=j.asn1.fromDer(u.bytes(),!1));var l=j.util.createBuffer();It(l,3,u),a.putBuffer(l)}n=j.pki.certificateFromAsn1(i),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var f=3+a.length(),d=j.util.createBuffer();return d.putByte(_t.HandshakeType.certificate),d.putInt24(f),It(d,3,a),d},_t.createClientKeyExchange=function(e){var t=j.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(j.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,a=j.util.createBuffer();return a.putByte(_t.HandshakeType.client_key_exchange),a.putInt24(n),a.putInt16(t.length),a.putBytes(t),a},_t.createServerKeyExchange=function(e){return j.util.createBuffer()},_t.getClientSignature=function(e,t){var r=j.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=j.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},_t.createCertificateVerify=function(e,t){var r=t.length+2,n=j.util.createBuffer();return n.putByte(_t.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},_t.createCertificateRequest=function(e){var t=j.util.createBuffer();t.putByte(1);var r=j.util.createBuffer();for(var n in e.caStore.certs){var a=e.caStore.certs[n],i=j.pki.distinguishedNameToAsn1(a.subject),o=j.asn1.toDer(i);r.putInt16(o.length()),r.putBuffer(o)}var s=1+t.length()+2+r.length(),c=j.util.createBuffer();return c.putByte(_t.HandshakeType.certificate_request),c.putInt24(s),It(c,1,t),It(c,2,r),c},_t.createServerHelloDone=function(e){var t=j.util.createBuffer();return t.putByte(_t.HandshakeType.server_hello_done),t.putInt24(0),t},_t.createChangeCipherSpec=function(){var e=j.util.createBuffer();return e.putByte(1),e},_t.createFinished=function(e){var t=j.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===_t.ConnectionEnd.client,n=e.session.sp,a=r?"client finished":"server finished";t=St(n.master_secret,a,t.getBytes(),12);var i=j.util.createBuffer();return i.putByte(_t.HandshakeType.finished),i.putInt24(t.length()),i.putBuffer(t),i},_t.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=j.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var a=n.length(),i=Math.max(16,a-r-3);return n.putBytes(j.random.getBytes(i)),n},_t.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==_t.ContentType.handshake&&t.type!==_t.ContentType.alert&&t.type!==_t.ContentType.change_cipher_spec)){if(t.type===_t.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=_t.MaxFragment)n=[t];else{n=[];for(var a=t.fragment.bytes();a.length>_t.MaxFragment;)n.push(_t.createRecord(e,{type:t.type,data:j.util.createBuffer(a.slice(0,_t.MaxFragment))})),a=a.slice(_t.MaxFragment);a.length>0&&n.push(_t.createRecord(e,{type:t.type,data:j.util.createBuffer(a)}))}for(var i=0;i<n.length&&!e.fail;++i){var o=n[i];e.state.current.write.update(e,o)&&e.records.push(o)}}},_t.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var cr=function(e){switch(e){case!0:return!0;case j.pki.certificateError.bad_certificate:return _t.Alert.Description.bad_certificate;case j.pki.certificateError.unsupported_certificate:return _t.Alert.Description.unsupported_certificate;case j.pki.certificateError.certificate_revoked:return _t.Alert.Description.certificate_revoked;case j.pki.certificateError.certificate_expired:return _t.Alert.Description.certificate_expired;case j.pki.certificateError.certificate_unknown:return _t.Alert.Description.certificate_unknown;case j.pki.certificateError.unknown_ca:return _t.Alert.Description.unknown_ca;default:return _t.Alert.Description.bad_certificate}};for(var ur in _t.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){cr(t);var a=e.verify(e,t,r,n);if(!0!==a){if("object"==typeof a&&!j.util.isArray(a)){var i=new Error("The application rejected the certificate.");throw i.send=!0,i.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},a.message&&(i.message=a.message),a.alert&&(i.alert.description=a.alert),i}a!==t&&(a=function(e){switch(e){case!0:return!0;case _t.Alert.Description.bad_certificate:return j.pki.certificateError.bad_certificate;case _t.Alert.Description.unsupported_certificate:return j.pki.certificateError.unsupported_certificate;case _t.Alert.Description.certificate_revoked:return j.pki.certificateError.certificate_revoked;case _t.Alert.Description.certificate_expired:return j.pki.certificateError.certificate_expired;case _t.Alert.Description.certificate_unknown:return j.pki.certificateError.certificate_unknown;case _t.Alert.Description.unknown_ca:return j.pki.certificateError.unknown_ca;default:return j.pki.certificateError.bad_certificate}}(a))}return a},j.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var a=t;("object"!=typeof a||j.util.isArray(a))&&(a={send:!0,alert:{level:_t.Alert.Level.fatal,description:cr(t)}}),"send"in a||(a.send=!0),"alert"in a||(a.alert={level:_t.Alert.Level.fatal,description:cr(a.error)}),e.error(e,a)}return!e.fail},_t.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=j.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var a in t=r.cache[n],delete r.cache[n],r.order)if(r.order[a]===n){r.order.splice(a,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=j.util.bytesToHex(e),r.order.push(n),r.cache[n]=t}}return r},_t.createConnection=function(e){var t=null;t=e.caStore?j.util.isArray(e.caStore)?j.pki.createCaStore(e.caStore):e.caStore:j.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],_t.CipherSuites)r.push(_t.CipherSuites[n]);var a=e.server?_t.ConnectionEnd.server:_t.ConnectionEnd.client,i=e.sessionCache?_t.createSessionCache(e.sessionCache):null,o={version:{major:_t.Version.major,minor:_t.Version.minor},entity:a,sessionId:e.sessionId,caStore:t,sessionCache:i,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:j.util.createBuffer(),tlsData:j.util.createBuffer(),data:j.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===_t.ConnectionEnd.client?"client":"server"),r.send&&(_t.queue(t,_t.createAlert(t,r.alert)),_t.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:_t.Version.major,minor:_t.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(_t.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=_t.createConnectionState(o)}};return o.reset(),o.handshake=function(e){if(o.entity!==_t.ConnectionEnd.client)o.error(o,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(o.handshaking)o.error(o,{message:"Handshake already in progress.",fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||"").length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:j.md.md5.create(),sha1:j.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=_t.createRandom().getBytes(),o.open=!0,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.handshake,data:_t.createClientHello(o)})),_t.flush(o)}},o.process=function(e){var t=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:j.util.createBuffer(),ready:!1};var a=e.record.version.major===e.version.major;a&&e.session&&e.session.version&&(a=e.record.version.minor===e.version.minor),a||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(o)),!o.fail&&null!==o.record&&o.record.ready&&function(e,t){var r=t.type-_t.ContentType.change_cipher_spec,n=Yt[e.entity][e.expect];r in n?n[r](e,t):_t.handleUnexpected(e,t)}(o,o.record)),t},o.prepare=function(e){return _t.queue(o,_t.createRecord(o,{type:_t.ContentType.application_data,data:j.util.createBuffer(e)})),_t.flush(o)},o.prepareHeartbeatRequest=function(e,t){return e instanceof j.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),o.expectedHeartbeatPayload=e,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(o)},o.close=function(e){if(!o.fail&&o.sessionCache&&o.session){var t={id:o.session.id,version:o.session.version,sp:o.session.sp};t.sp.keys=null,o.sessionCache.setSession(t.id,t)}o.open&&(o.open=!1,o.input.clear(),(o.isConnected||o.handshaking)&&(o.isConnected=o.handshaking=!1,_t.queue(o,_t.createAlert(o,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(o)),o.closed(o)),o.reset(e)},o},j.tls=j.tls||{},_t)"function"!=typeof _t[ur]&&(j.tls[ur]=_t[ur]);j.tls.prf_tls1=St,j.tls.hmac_sha1=function(e,t,r){var n=j.hmac.create();n.start("SHA1",e);var a=j.util.createBuffer();return a.putInt32(t[0]),a.putInt32(t[1]),a.putByte(r.type),a.putByte(r.version.major),a.putByte(r.version.minor),a.putInt16(r.length),a.putBytes(r.fragment.bytes()),n.update(a.getBytes()),n.digest().getBytes()},j.tls.createSessionCache=_t.createSessionCache,j.tls.createConnection=_t.createConnection,E((function(e){var t=e.exports=j.tls;function r(e,r,a){var i=r.entity===j.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:j.cipher.createDecipher("AES-CBC",i?a.keys.server_write_key:a.keys.client_write_key),iv:i?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:j.cipher.createCipher("AES-CBC",i?a.keys.client_write_key:a.keys.server_write_key),iv:i?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=o,e.write.cipherFunction=n,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=t.hmac_sha1}function n(e,r){var n,i=!1,o=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(o),r.updateSequenceNumber(),n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:j.random.getBytesSync(16),r.cipherState.init=!0;var s=r.cipherState.cipher;return s.start({iv:n}),e.version.minor>=t.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(a)&&(e.fragment=s.output,e.length=e.fragment.length(),i=!0),i}function a(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function i(e,t,r){var n=!0;if(r){for(var a=t.length(),i=t.last(),o=a-1-i;o<a-1;++o)n=n&&t.at(o)==i;n&&t.truncate(i+1)}return n}function o(e,r){var n,a=!1;n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:e.fragment.getBytes(16),r.cipherState.init=!0;var o=r.cipherState.cipher;o.start({iv:n}),o.update(e.fragment),a=o.finish(i);var s=r.macLength,c=j.random.getBytesSync(s),u=o.output.length();u>=s?(e.fragment=o.output.getBytes(u-s),c=o.output.getBytes(s)):e.fragment=o.output.getBytes(),e.fragment=j.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=r.macFunction(r.macKey,r.sequenceNumber,e);return r.updateSequenceNumber(),function(e,t,r){var n=j.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),t===(r=n.digest().getBytes())}(r.macKey,c,l)&&a}t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r}})),j.debug=j.debug||{},j.debug.storage={},j.debug.get=function(e,t){var r;return void 0===e?r=j.debug.storage:e in j.debug.storage&&(r=void 0===t?j.debug.storage[e]:j.debug.storage[e][t]),r},j.debug.set=function(e,t,r){e in j.debug.storage||(j.debug.storage[e]={}),j.debug.storage[e][t]=r},j.debug.clear=function(e,t){void 0===e?j.debug.storage={}:e in j.debug.storage&&(void 0===t?delete j.debug.storage[e]:delete j.debug.storage[e][t])},E((function(e){var t=e.exports=j.sha512=j.sha512||{};j.md.sha512=j.md.algorithms.sha512=t;var r=j.sha384=j.sha512.sha384=j.sha512.sha384||{};r.create=function(){return t.create("SHA-384")},j.md.sha384=j.md.algorithms.sha384=r,j.sha512.sha256=j.sha512.sha256||{create:function(){return t.create("SHA-512/256")}},j.md["sha512/256"]=j.md.algorithms["sha512/256"]=j.sha512.sha256,j.sha512.sha224=j.sha512.sha224||{create:function(){return t.create("SHA-512/224")}},j.md["sha512/224"]=j.md.algorithms["sha512/224"]=j.sha512.sha224,t.create=function(e){if(a||(n=String.fromCharCode(128),n+=j.util.fillString(String.fromCharCode(0),128),i=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(o={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],o["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],o["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],o["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),void 0===e&&(e="SHA-512"),!(e in o))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=o[e],r=null,c=j.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var f=64;switch(e){case"SHA-384":f=48;break;case"SHA-512/256":f=32;break;case"SHA-512/224":f=28}var d={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var e=d.messageLengthSize/4,n=0;n<e;++n)d.fullMessageLength.push(0);for(c=j.util.createBuffer(),r=new Array(t.length),n=0;n<t.length;++n)r[n]=t[n].slice(0);return d}};return d.start(),d.update=function(e,t){"utf8"===t&&(e=j.util.encodeUtf8(e));var n=e.length;d.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var a=d.fullMessageLength.length-1;a>=0;--a)d.fullMessageLength[a]+=n[1],n[1]=n[0]+(d.fullMessageLength[a]/4294967296>>>0),d.fullMessageLength[a]=d.fullMessageLength[a]>>>0,n[0]=n[1]/4294967296>>>0;return c.putBytes(e),s(r,u,c),(c.read>2048||0===c.length())&&c.compact(),d},d.digest=function(){var t=j.util.createBuffer();t.putBytes(c.bytes());var a,i=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(n.substr(0,d.blockLength-i));for(var o=8*d.fullMessageLength[0],l=0;l<d.fullMessageLength.length-1;++l)o+=(a=8*d.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(o>>>0),o=a>>>0;t.putInt32(o);var f=new Array(r.length);for(l=0;l<r.length;++l)f[l]=r[l].slice(0);s(f,u,t);var p,h=j.util.createBuffer();for(p="SHA-512"===e?f.length:"SHA-384"===e?f.length-2:f.length-4,l=0;l<p;++l)h.putInt32(f[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(f[l][1]);return h},d};var n=null,a=!1,i=null,o=null;function s(e,t,r){for(var n,a,o,s,c,u,l,f,d,p,h,g,m,y,v,b,C,E,w,k,S,B,A,T,I,_,x,P,R,N,L,O,D,U=r.length();U>=128;){for(x=0;x<16;++x)t[x][0]=r.getInt32()>>>0,t[x][1]=r.getInt32()>>>0;for(;x<80;++x)n=(((P=(N=t[x-2])[0])>>>19|(R=N[1])<<13)^(R>>>29|P<<3)^P>>>6)>>>0,a=((P<<13|R>>>19)^(R<<3|P>>>29)^(P<<26|R>>>6))>>>0,o=(((P=(O=t[x-15])[0])>>>1|(R=O[1])<<31)^(P>>>8|R<<24)^P>>>7)>>>0,s=((P<<31|R>>>1)^(P<<24|R>>>8)^(P<<25|R>>>7))>>>0,L=t[x-7],D=t[x-16],R=a+L[1]+s+D[1],t[x][0]=n+L[0]+o+D[0]+(R/4294967296>>>0)>>>0,t[x][1]=R>>>0;for(h=e[0][0],g=e[0][1],m=e[1][0],y=e[1][1],v=e[2][0],b=e[2][1],C=e[3][0],E=e[3][1],w=e[4][0],k=e[4][1],S=e[5][0],B=e[5][1],A=e[6][0],T=e[6][1],I=e[7][0],_=e[7][1],x=0;x<80;++x)l=((w>>>14|k<<18)^(w>>>18|k<<14)^(k>>>9|w<<23))>>>0,f=(A^w&(S^A))>>>0,c=((h>>>28|g<<4)^(g>>>2|h<<30)^(g>>>7|h<<25))>>>0,u=((h<<4|g>>>28)^(g<<30|h>>>2)^(g<<25|h>>>7))>>>0,d=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,R=_+(((w<<18|k>>>14)^(w<<14|k>>>18)^(k<<23|w>>>9))>>>0)+((T^k&(B^T))>>>0)+i[x][1]+t[x][1],n=I+l+f+i[x][0]+t[x][0]+(R/4294967296>>>0)>>>0,a=R>>>0,o=c+d+((R=u+p)/4294967296>>>0)>>>0,s=R>>>0,I=A,_=T,A=S,T=B,S=w,B=k,w=C+n+((R=E+a)/4294967296>>>0)>>>0,k=R>>>0,C=v,E=b,v=m,b=y,m=h,y=g,h=n+o+((R=a+s)/4294967296>>>0)>>>0,g=R>>>0;R=e[0][1]+g,e[0][0]=e[0][0]+h+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+m+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+b,e[2][0]=e[2][0]+v+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+k,e[4][0]=e[4][0]+w+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+B,e[5][0]=e[5][0]+S+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+T,e[6][0]=e[6][0]+A+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+_,e[7][0]=e[7][0]+I+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,U-=128}}}));var lr=j.asn1,fr={privateKeyValidator:{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:lr.Class.UNIVERSAL,type:lr.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},publicKeyValidator:{name:"SubjectPublicKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:lr.Class.UNIVERSAL,type:lr.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}},dr=fr.publicKeyValidator,pr=fr.privateKeyValidator;if(void 0===hr)var hr=j.jsbn.BigInteger;var gr=j.util.ByteBuffer,mr="undefined"==typeof Buffer?Uint8Array:Buffer;j.pki=j.pki||{},j.pki.ed25519=j.ed25519=j.ed25519||{};var yr=j.ed25519;function vr(e){var t=e.message;if(t instanceof Uint8Array||t instanceof mr)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new gr(t,r)}else if(!(t instanceof gr))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new mr(t.length()),a=0;a<n.length;++a)n[a]=t.at(a);return n}yr.constants={},yr.constants.PUBLIC_KEY_BYTE_LENGTH=32,yr.constants.PRIVATE_KEY_BYTE_LENGTH=64,yr.constants.SEED_BYTE_LENGTH=32,yr.constants.SIGN_BYTE_LENGTH=64,yr.constants.HASH_BYTE_LENGTH=64,yr.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=j.random.getBytesSync(yr.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==yr.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+yr.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=vr({message:t,encoding:"binary"});for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=new mr(yr.constants.PRIVATE_KEY_BYTE_LENGTH),a=0;a<32;++a)n[a]=t[a];return function(e,t){var r,n=[Kr(),Kr(),Kr(),Kr()],a=Tr(t,32);for(a[0]&=248,a[31]&=127,a[31]|=64,Mr(n,a),Rr(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},yr.privateKeyFromAsn1=function(e){var t={},r=[];if(!j.asn1.validate(e,pr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var a=j.asn1.derToOid(t.privateKeyOid),i=j.oids.EdDSA25519;if(a!==i)throw new Error('Invalid OID "'+a+'"; OID must be "'+i+'".');var o=t.privateKey;return{privateKeyBytes:vr({message:j.asn1.fromDer(o).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!j.asn1.validate(e,dr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var a=j.asn1.derToOid(t.publicKeyOid),i=j.oids.EdDSA25519;if(a!==i)throw new Error('Invalid OID "'+a+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:o,encoding:"binary"})},yr.publicKeyFromPrivateKey=function(e){var t=vr({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},yr.sign=function(e){var t=vr(e=e||{}),r=vr({message:e.privateKey,encoding:"binary"});if(r.length===yr.constants.SEED_BYTE_LENGTH)r=yr.generateKeyPair({seed:r}).privateKey;else if(r.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.SEED_BYTE_LENGTH+" or "+yr.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var a,i,o=new Float64Array(64),s=[Kr(),Kr(),Kr(),Kr()],c=Tr(n,32);for(c[0]&=248,c[31]&=127,c[31]|=64,a=0;a<r;++a)e[64+a]=t[a];for(a=0;a<32;++a)e[32+a]=c[32+a];var u=Tr(e.subarray(32),r+32);for(_r(u),Mr(s,u),Rr(e,s),a=32;a<64;++a)e[a]=n[a];var l=Tr(e,r+64);for(_r(l),a=32;a<64;++a)o[a]=0;for(a=0;a<32;++a)o[a]=u[a];for(a=0;a<32;++a)for(i=0;i<32;i++)o[a+i]+=l[a]*c[i];Ir(e.subarray(32),o)}(n,t,t.length,r);for(var a=new mr(yr.constants.SIGN_BYTE_LENGTH),i=0;i<a.length;++i)a[i]=n[i];return a},yr.verify=function(e){var t=vr(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=vr({message:e.signature,encoding:"binary"});if(r.length!==yr.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+yr.constants.SIGN_BYTE_LENGTH);var n=vr({message:e.publicKey,encoding:"binary"});if(n.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+yr.constants.PUBLIC_KEY_BYTE_LENGTH);var a,i=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(a=0;a<yr.constants.SIGN_BYTE_LENGTH;++a)i[a]=r[a];for(a=0;a<t.length;++a)i[a+yr.constants.SIGN_BYTE_LENGTH]=t[a];return function(e,t,r,n){var a,i=new mr(32),o=[Kr(),Kr(),Kr(),Kr()],s=[Kr(),Kr(),Kr(),Kr()];if(r<64)return-1;if(function(e,t){var r=Kr(),n=Kr(),a=Kr(),i=Kr(),o=Kr(),s=Kr(),c=Kr();return Vr(e[2],Cr),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),Hr(a,e[1]),Gr(i,a,Er),qr(a,a,e[2]),zr(i,e[2],i),Hr(o,i),Hr(s,o),Gr(c,s,o),Gr(r,c,a),Gr(r,r,i),function(e,t){var r,n=Kr();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)Hr(n,n),1!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),Gr(r,r,a),Gr(r,r,i),Gr(r,r,i),Gr(e[0],r,i),Hr(n,e[0]),Gr(n,n,i),Lr(n,a)&&Gr(e[0],e[0],Ar),Hr(n,e[0]),Gr(n,n,i),Lr(n,a)?-1:(Dr(e[0])===t[31]>>7&&qr(e[0],br,e[0]),Gr(e[3],e[0],e[1]),0)}(s,n))return-1;for(a=0;a<r;++a)e[a]=t[a];for(a=0;a<32;++a)e[a+32]=n[a];var c=Tr(e,r);if(_r(c),Ur(o,s,c),Mr(s,t.subarray(32)),xr(o,s),Rr(i,o),r-=64,Or(t,0,i,0)){for(a=0;a<r;++a)e[a]=0;return-1}for(a=0;a<r;++a)e[a]=t[a+64];return r}(o,i,i.length,n)>=0};var br=Kr(),Cr=Kr([1]),Er=Kr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),wr=Kr([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),kr=Kr([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Sr=Kr([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Ar=Kr([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Tr(e,t){var r=j.md.sha512.create(),n=new gr(e);r.update(n.getBytes(t),"binary");var a=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(a,"binary");for(var i=new mr(yr.constants.HASH_BYTE_LENGTH),o=0;o<64;++o)i[o]=a.charCodeAt(o);return i}function Ir(e,t){var r,n,a,i;for(n=63;n>=32;--n){for(r=0,a=n-32,i=n-12;a<i;++a)t[a]+=r-16*t[n]*Br[a-(n-32)],r=t[a]+128>>8,t[a]-=256*r;t[a]+=r,t[n]=0}for(r=0,a=0;a<32;++a)t[a]+=r-(t[31]>>4)*Br[a],r=t[a]>>8,t[a]&=255;for(a=0;a<32;++a)t[a]-=r*Br[a];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function _r(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Ir(e,t)}function xr(e,t){var r=Kr(),n=Kr(),a=Kr(),i=Kr(),o=Kr(),s=Kr(),c=Kr(),u=Kr(),l=Kr();qr(r,e[1],e[0]),qr(l,t[1],t[0]),Gr(r,r,l),zr(n,e[0],e[1]),zr(l,t[0],t[1]),Gr(n,n,l),Gr(a,e[3],t[3]),Gr(a,a,wr),Gr(i,e[2],t[2]),zr(i,i,i),qr(o,n,r),qr(s,i,a),zr(c,i,a),zr(u,n,r),Gr(e[0],o,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],o,u)}function Pr(e,t,r){for(var n=0;n<4;++n)jr(e[n],t[n],r)}function Rr(e,t){var r=Kr(),n=Kr(),a=Kr();!function(e,t){var r,n=Kr();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)Hr(n,n),2!==r&&4!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(a,t[2]),Gr(r,t[0],a),Gr(n,t[1],a),Nr(e,n),e[31]^=Dr(r)<<7}function Nr(e,t){var r,n,a,i=Kr(),o=Kr();for(r=0;r<16;++r)o[r]=t[r];for(Fr(o),Fr(o),Fr(o),n=0;n<2;++n){for(i[0]=o[0]-65517,r=1;r<15;++r)i[r]=o[r]-65535-(i[r-1]>>16&1),i[r-1]&=65535;i[15]=o[15]-32767-(i[14]>>16&1),a=i[15]>>16&1,i[14]&=65535,jr(o,i,1-a)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function Lr(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Or(r,0,n,0)}function Or(e,t,r,n){return function(e,t,r,n,a){var i,o=0;for(i=0;i<a;++i)o|=e[t+i]^r[n+i];return(1&o-1>>>8)-1}(e,t,r,n,32)}function Dr(e){var t=new mr(32);return Nr(t,e),1&t[0]}function Ur(e,t,r){var n,a;for(Vr(e[0],br),Vr(e[1],Cr),Vr(e[2],Cr),Vr(e[3],br),a=255;a>=0;--a)Pr(e,t,n=r[a/8|0]>>(7&a)&1),xr(t,e),xr(e,e),Pr(e,t,n)}function Mr(e,t){var r=[Kr(),Kr(),Kr(),Kr()];Vr(r[0],kr),Vr(r[1],Sr),Vr(r[2],Cr),Gr(r[3],kr,Sr),Ur(e,r,t)}function Vr(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function Fr(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function jr(e,t,r){for(var n,a=~(r-1),i=0;i<16;++i)n=a&(e[i]^t[i]),e[i]^=n,t[i]^=n}function Kr(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function zr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function qr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function Hr(e,t){Gr(e,t,t)}function Gr(e,t,r){var n,a,i=0,o=0,s=0,c=0,u=0,l=0,f=0,d=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,E=0,w=0,k=0,S=0,B=0,A=0,T=0,I=0,_=0,x=0,P=0,R=0,N=0,L=0,O=0,D=r[0],U=r[1],M=r[2],V=r[3],F=r[4],j=r[5],K=r[6],z=r[7],q=r[8],H=r[9],G=r[10],Q=r[11],W=r[12],X=r[13],Y=r[14],$=r[15];i+=(n=t[0])*D,o+=n*U,s+=n*M,c+=n*V,u+=n*F,l+=n*j,f+=n*K,d+=n*z,p+=n*q,h+=n*H,g+=n*G,m+=n*Q,y+=n*W,v+=n*X,b+=n*Y,C+=n*$,o+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*F,f+=n*j,d+=n*K,p+=n*z,h+=n*q,g+=n*H,m+=n*G,y+=n*Q,v+=n*W,b+=n*X,C+=n*Y,E+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,f+=n*F,d+=n*j,p+=n*K,h+=n*z,g+=n*q,m+=n*H,y+=n*G,v+=n*Q,b+=n*W,C+=n*X,E+=n*Y,w+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,f+=n*V,d+=n*F,p+=n*j,h+=n*K,g+=n*z,m+=n*q,y+=n*H,v+=n*G,b+=n*Q,C+=n*W,E+=n*X,w+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,f+=n*M,d+=n*V,p+=n*F,h+=n*j,g+=n*K,m+=n*z,y+=n*q,v+=n*H,b+=n*G,C+=n*Q,E+=n*W,w+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,f+=n*U,d+=n*M,p+=n*V,h+=n*F,g+=n*j,m+=n*K,y+=n*z,v+=n*q,b+=n*H,C+=n*G,E+=n*Q,w+=n*W,k+=n*X,S+=n*Y,B+=n*$,f+=(n=t[6])*D,d+=n*U,p+=n*M,h+=n*V,g+=n*F,m+=n*j,y+=n*K,v+=n*z,b+=n*q,C+=n*H,E+=n*G,w+=n*Q,k+=n*W,S+=n*X,B+=n*Y,A+=n*$,d+=(n=t[7])*D,p+=n*U,h+=n*M,g+=n*V,m+=n*F,y+=n*j,v+=n*K,b+=n*z,C+=n*q,E+=n*H,w+=n*G,k+=n*Q,S+=n*W,B+=n*X,A+=n*Y,T+=n*$,p+=(n=t[8])*D,h+=n*U,g+=n*M,m+=n*V,y+=n*F,v+=n*j,b+=n*K,C+=n*z,E+=n*q,w+=n*H,k+=n*G,S+=n*Q,B+=n*W,A+=n*X,T+=n*Y,I+=n*$,h+=(n=t[9])*D,g+=n*U,m+=n*M,y+=n*V,v+=n*F,b+=n*j,C+=n*K,E+=n*z,w+=n*q,k+=n*H,S+=n*G,B+=n*Q,A+=n*W,T+=n*X,I+=n*Y,_+=n*$,g+=(n=t[10])*D,m+=n*U,y+=n*M,v+=n*V,b+=n*F,C+=n*j,E+=n*K,w+=n*z,k+=n*q,S+=n*H,B+=n*G,A+=n*Q,T+=n*W,I+=n*X,_+=n*Y,x+=n*$,m+=(n=t[11])*D,y+=n*U,v+=n*M,b+=n*V,C+=n*F,E+=n*j,w+=n*K,k+=n*z,S+=n*q,B+=n*H,A+=n*G,T+=n*Q,I+=n*W,_+=n*X,x+=n*Y,P+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,E+=n*F,w+=n*j,k+=n*K,S+=n*z,B+=n*q,A+=n*H,T+=n*G,I+=n*Q,_+=n*W,x+=n*X,P+=n*Y,R+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,E+=n*V,w+=n*F,k+=n*j,S+=n*K,B+=n*z,A+=n*q,T+=n*H,I+=n*G,_+=n*Q,x+=n*W,P+=n*X,R+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,E+=n*M,w+=n*V,k+=n*F,S+=n*j,B+=n*K,A+=n*z,T+=n*q,I+=n*H,_+=n*G,x+=n*Q,P+=n*W,R+=n*X,N+=n*Y,L+=n*$,C+=(n=t[15])*D,o+=38*(w+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*F),u+=38*(B+=n*j),l+=38*(A+=n*K),f+=38*(T+=n*z),d+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(P+=n*Q),m+=38*(R+=n*W),y+=38*(N+=n*X),v+=38*(L+=n*Y),b+=38*(O+=n*$),i=(n=(i+=38*(E+=n*U))+(a=1)+65535)-65536*(a=Math.floor(n/65536)),o=(n=o+a+65535)-65536*(a=Math.floor(n/65536)),s=(n=s+a+65535)-65536*(a=Math.floor(n/65536)),c=(n=c+a+65535)-65536*(a=Math.floor(n/65536)),u=(n=u+a+65535)-65536*(a=Math.floor(n/65536)),l=(n=l+a+65535)-65536*(a=Math.floor(n/65536)),f=(n=f+a+65535)-65536*(a=Math.floor(n/65536)),d=(n=d+a+65535)-65536*(a=Math.floor(n/65536)),p=(n=p+a+65535)-65536*(a=Math.floor(n/65536)),h=(n=h+a+65535)-65536*(a=Math.floor(n/65536)),g=(n=g+a+65535)-65536*(a=Math.floor(n/65536)),m=(n=m+a+65535)-65536*(a=Math.floor(n/65536)),y=(n=y+a+65535)-65536*(a=Math.floor(n/65536)),v=(n=v+a+65535)-65536*(a=Math.floor(n/65536)),b=(n=b+a+65535)-65536*(a=Math.floor(n/65536)),C=(n=C+a+65535)-65536*(a=Math.floor(n/65536)),i=(n=(i+=a-1+37*(a-1))+(a=1)+65535)-65536*(a=Math.floor(n/65536)),o=(n=o+a+65535)-65536*(a=Math.floor(n/65536)),s=(n=s+a+65535)-65536*(a=Math.floor(n/65536)),c=(n=c+a+65535)-65536*(a=Math.floor(n/65536)),u=(n=u+a+65535)-65536*(a=Math.floor(n/65536)),l=(n=l+a+65535)-65536*(a=Math.floor(n/65536)),f=(n=f+a+65535)-65536*(a=Math.floor(n/65536)),d=(n=d+a+65535)-65536*(a=Math.floor(n/65536)),p=(n=p+a+65535)-65536*(a=Math.floor(n/65536)),h=(n=h+a+65535)-65536*(a=Math.floor(n/65536)),g=(n=g+a+65535)-65536*(a=Math.floor(n/65536)),m=(n=m+a+65535)-65536*(a=Math.floor(n/65536)),y=(n=y+a+65535)-65536*(a=Math.floor(n/65536)),v=(n=v+a+65535)-65536*(a=Math.floor(n/65536)),b=(n=b+a+65535)-65536*(a=Math.floor(n/65536)),C=(n=C+a+65535)-65536*(a=Math.floor(n/65536)),i+=a-1+37*(a-1),e[0]=i,e[1]=o,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=f,e[7]=d,e[8]=p,e[9]=h,e[10]=g,e[11]=m,e[12]=y,e[13]=v,e[14]=b,e[15]=C}j.kem=j.kem||{};var Qr=j.jsbn.BigInteger;function Wr(e,t,r,n){e.generate=function(e,a){for(var i=new j.util.ByteBuffer,o=Math.ceil(a/n)+r,s=new j.util.ByteBuffer,c=r;c<o;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();i.putBytes(u.getBytes(n))}return i.truncate(i.length()-a),i.getBytes()}}j.kem.rsa={},j.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||j.random;return{encrypt:function(t,n){var a,i=Math.ceil(t.n.bitLength()/8);do{a=new Qr(j.util.bytesToHex(r.getBytesSync(i)),16).mod(t.n)}while(a.compareTo(Qr.ONE)<=0);var o=i-(a=j.util.hexToBytes(a.toString(16))).length;return o>0&&(a=j.util.fillString(String.fromCharCode(0),o)+a),{encapsulation:t.encrypt(a,"NONE"),key:e.generate(a,n)}},decrypt:function(t,r,n){var a=t.decrypt(r,"NONE");return e.generate(a,n)}}},j.kem.kdf1=function(e,t){Wr(this,e,0,t||e.digestLength)},j.kem.kdf2=function(e,t){Wr(this,e,1,t||e.digestLength)},j.log=j.log||{},j.log.levels=["none","error","warning","info","debug","verbose","max"];var Xr={},Yr=[],$r=null;j.log.LEVEL_LOCKED=2,j.log.NO_LEVEL_CHECK=4,j.log.INTERPOLATE=8;for(var Zr=0;Zr<j.log.levels.length;++Zr){var Jr=j.log.levels[Zr];Xr[Jr]={index:Zr,name:Jr.toUpperCase()}}j.log.logMessage=function(e){for(var t=Xr[e.level].index,r=0;r<Yr.length;++r){var n=Yr[r];n.flags&j.log.NO_LEVEL_CHECK?n.f(e):t<=Xr[n.level].index&&n.f(n,e)}},j.log.prepareStandard=function(e){"standard"in e||(e.standard=Xr[e.level].name+" ["+e.category+"] "+e.message)},j.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=j.util.format.apply(this,t)}},j.log.prepareStandardFull=function(e){"standardFull"in e||(j.log.prepareStandard(e),e.standardFull=e.standard)};var en=["error","warning","info","debug","verbose"];for(Zr=0;Zr<en.length;++Zr)!function(e){j.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),a={timestamp:new Date,level:e,category:t,message:r,arguments:n};j.log.logMessage(a)}}(en[Zr]);if(j.log.makeLogger=function(e){var t={flags:0,f:e};return j.log.setLevel(t,"none"),t},j.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&j.log.LEVEL_LOCKED))for(var n=0;n<j.log.levels.length;++n)if(t==j.log.levels[n]){e.level=t,r=!0;break}return r},j.log.lock=function(e,t){void 0===t||t?e.flags|=j.log.LEVEL_LOCKED:e.flags&=~j.log.LEVEL_LOCKED},j.log.addLogger=function(e){Yr.push(e)},"undefined"!=typeof console&&"log"in console){var tn;if(console.error&&console.warn&&console.info&&console.debug){var rn={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},nn=function(e,t){j.log.prepareStandard(t);var r=rn[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};tn=j.log.makeLogger(nn)}else nn=function(e,t){j.log.prepareStandardFull(t),console.log(t.standardFull)},tn=j.log.makeLogger(nn);j.log.setLevel(tn,"debug"),j.log.addLogger(tn),$r=tn}else console={log:function(){}};if(null!==$r){var an=j.util.getQueryVariables();"console.level"in an&&j.log.setLevel($r,an["console.level"].slice(-1)[0]),"console.lock"in an&&"true"==an["console.lock"].slice(-1)[0]&&j.log.lock($r)}j.log.consoleLogger=$r,E((function(e){var t=j.asn1,r=e.exports=j.pkcs7=j.pkcs7||{};function n(e){var n={},a=[];if(!t.validate(e,r.asn1.recipientInfoValidator,n,a)){var i=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw i.errors=a,i}return{version:n.version.charCodeAt(0),issuer:j.pki.RDNAttributesAsArray(n.issuer),serialNumber:j.util.createBuffer(n.serial).toHex(),encryptedContent:{algorithm:t.derToOid(n.encAlgorithm),parameter:n.encParameter.value,content:n.encKey}}}function a(e){for(var r,n=[],a=0;a<e.length;++a)n.push((r=e[a],t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[j.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.encryptedContent.content)])));return n}function i(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[j.pki.distinguishedNameToAsn1({attributes:e.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(e.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&r.value.push(e.authenticatedAttributesAsn1),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var n=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),a=0;a<e.unauthenticatedAttributes.length;++a){var i=e.unauthenticatedAttributes[a];n.values.push(o(i))}r.value.push(n)}return r}function o(e){var r;if(e.type===j.pki.oids.contentType)r=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.value).getBytes());else if(e.type===j.pki.oids.messageDigest)r=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===j.pki.oids.signingTime){var n=new Date("1950-01-01T00:00:00Z"),a=new Date("2050-01-01T00:00:00Z"),i=e.value;if("string"==typeof i){var o=Date.parse(i);i=isNaN(o)?13===i.length?t.utcTimeToDate(i):t.generalizedTimeToDate(i):new Date(o)}r=i>=n&&i<a?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(i)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(i))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[r])])}function s(e,r,n){var a={};if(!t.validate(r,n,a,[])){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw i.errors=i,i}if(t.derToOid(a.contentType)!==j.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(a.encryptedContent){var o="";if(j.util.isArray(a.encryptedContent))for(var s=0;s<a.encryptedContent.length;++s){if(a.encryptedContent[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=a.encryptedContent[s].value}else o=a.encryptedContent;e.encryptedContent={algorithm:t.derToOid(a.encAlgorithm),parameter:j.util.createBuffer(a.encParameter.value),content:j.util.createBuffer(o)}}if(a.content){if(o="",j.util.isArray(a.content))for(s=0;s<a.content.length;++s){if(a.content[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=a.content[s].value}else o=a.content;e.content=j.util.createBuffer(o)}return e.version=a.version.charCodeAt(0),e.rawCapture=a,a}function c(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case j.pki.oids["aes128-CBC"]:case j.pki.oids["aes192-CBC"]:case j.pki.oids["aes256-CBC"]:t=j.aes.createDecryptionCipher(e.encryptedContent.key);break;case j.pki.oids.desCBC:case j.pki.oids["des-EDE3-CBC"]:t=j.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}r.messageFromPem=function(e){var n=j.pem.decode(e)[0];if("PKCS7"!==n.type){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.messageFromAsn1(i)},r.messageToPem=function(e,r){var n={type:"PKCS7",body:t.toDer(e.toAsn1()).getBytes()};return j.pem.encode(n,{maxline:r})},r.messageFromAsn1=function(e){var n={},a=[];if(!t.validate(e,r.asn1.contentInfoValidator,n,a)){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw i.errors=a,i}var o,s=t.derToOid(n.contentType);switch(s){case j.pki.oids.envelopedData:o=r.createEnvelopedData();break;case j.pki.oids.encryptedData:o=r.createEncryptedData();break;case j.pki.oids.signedData:o=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return o.fromAsn1(n.content.value[0]),o},r.createSignedData=function(){var e=null;return e={type:j.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(s(e,t,r.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,a=0;a<n.length;++a)e.certificates.push(j.pki.certificateFromAsn1(n[a]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(j.pki.certificateToAsn1(e.certificates[n]));var a=[],i=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),a.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,a)),i.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),i])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var a=t.certificate;"string"==typeof a&&(a=j.pki.certificateFromPem(a)),r=a.issuer.attributes,n=a.serialNumber}var i=t.key;if(!i)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof i&&(i=j.pki.privateKeyFromPem(i));var o=t.digestAlgorithm||j.pki.oids.sha1;switch(o){case j.pki.oids.sha1:case j.pki.oids.sha256:case j.pki.oids.sha384:case j.pki.oids.sha512:case j.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var f=s[l];if(c||f.type!==j.pki.oids.contentType){if(u||f.type!==j.pki.oids.messageDigest);else if(u=!0,c)break}else if(c=!0,u)break}if(!c||!u)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:i,version:1,issuer:r,serialNumber:n,digestAlgorithm:o,signatureAlgorithm:j.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:s,unauthenticatedAttributes:[]})},sign:function(r){var n;r=r||{},("object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(j.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof j.util.ByteBuffer?n=e.content.bytes():"string"==typeof e.content&&(n=j.util.encodeUtf8(e.content)),r.detached?e.detachedContent=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)])))),0!==e.signers.length&&function(r){var n;if(!(n=e.detachedContent?e.detachedContent:(n=e.contentInfo.value[1]).value[0]))throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var a=t.derToOid(e.contentInfo.value[0].value),s=t.toDer(n);for(var c in s.getByte(),t.getBerValueLength(s),s=s.getBytes(),r)r[c].start().update(s);for(var u=new Date,l=0;l<e.signers.length;++l){var f=e.signers[l];if(0===f.authenticatedAttributes.length){if(a!==j.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{f.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var d=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var h=f.authenticatedAttributes[p];h.type===j.pki.oids.messageDigest?h.value=r[f.digestAlgorithm].digest():h.type===j.pki.oids.signingTime&&(h.value||(h.value=u)),d.value.push(o(h)),f.authenticatedAttributesAsn1.value.push(o(h))}s=t.toDer(d).getBytes(),f.md.start().update(s)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(i(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var a=e.signers[n];(i=a.digestAlgorithm)in r||(r[i]=j.md[j.pki.oids[i]].create()),0===a.authenticatedAttributes.length?a.md=r[i]:a.md=j.md[j.pki.oids[i]].create()}for(var i in e.digestAlgorithmIdentifiers=[],r)e.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}())},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=j.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}}},r.createEncryptedData=function(){var e=null;return e={type:j.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:j.pki.oids["aes256-CBC"]},fromAsn1:function(t){s(e,t,r.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),c(e)}}},r.createEnvelopedData=function(){var e=null;return e={type:j.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:j.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=s(e,t,r.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(n(e[r]));return t}(a.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,a(e.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,(r=e.encryptedContent,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(j.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.parameter.getBytes())]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.content.getBytes())])]))])])]);var r},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var a=e.recipients[n],i=a.issuer;if(a.serialNumber===t.serialNumber&&i.length===r.length){for(var o=!0,s=0;s<r.length;++s)if(i[s].type!==r[s].type||i[s].value!==r[s].value){o=!1;break}if(o)return a}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case j.pki.oids.rsaEncryption:case j.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=j.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}c(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:j.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,a,i;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case j.pki.oids["aes128-CBC"]:n=16,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["aes192-CBC"]:n=24,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["aes256-CBC"]:n=32,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["des-EDE3-CBC"]:n=24,a=8,i=j.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=j.util.createBuffer(j.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=j.util.createBuffer(j.random.getBytes(a));var o=i(t);if(o.start(e.encryptedContent.parameter.copy()),o.update(e.content),!o.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=o.output}for(var s=0;s<e.recipients.length;++s){var c=e.recipients[s];if(void 0===c.encryptedContent.content)switch(c.encryptedContent.algorithm){case j.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}}}})),E((function(e){var t=e.exports=j.ssh=j.ssh||{};function r(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=j.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function n(e,t){e.putInt32(t.length),e.putString(t)}function a(){for(var e=j.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}t.privateKeyToPutty=function(e,t,i){var o=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+o+"\r\n",s+="Comment: "+(i=i||"")+"\r\n";var c=j.util.createBuffer();n(c,"ssh-rsa"),r(c,e.e),r(c,e.n);var u=j.util.encode64(c.bytes(),64),l=Math.floor(u.length/66)+1;s+="Public-Lines: "+l+"\r\n",s+=u;var f,d=j.util.createBuffer();if(r(d,e.d),r(d,e.p),r(d,e.q),r(d,e.qInv),t){var p=d.length()+16-1;p-=p%16;var h=a(d.bytes());h.truncate(h.length()-p+d.length()),d.putBuffer(h);var g=j.util.createBuffer();g.putBuffer(a("\0\0\0\0",t)),g.putBuffer(a("\0\0\0",t));var m=j.aes.createEncryptionCipher(g.truncate(8),"CBC");m.start(j.util.createBuffer().fillWithByte(0,16)),m.update(d.copy()),m.finish();var y=m.output;y.truncate(16),f=j.util.encode64(y.bytes(),64)}else f=j.util.encode64(d.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(f.length/66)+1)+"\r\n",s+=f;var v=a("putty-private-key-file-mac-key",t),b=j.util.createBuffer();n(b,"ssh-rsa"),n(b,o),n(b,i),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(d.length()),b.putBuffer(d);var C=j.hmac.create();return C.start("sha1",v),C.update(b.bytes()),s+"\r\nPrivate-MAC: "+C.digest().toHex()+"\r\n"},t.publicKeyToOpenSSH=function(e,t){t=t||"";var a=j.util.createBuffer();return n(a,"ssh-rsa"),r(a,e.e),r(a,e.n),"ssh-rsa "+j.util.encode64(a.bytes())+" "+t},t.privateKeyToOpenSSH=function(e,t){return t?j.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):j.pki.privateKeyToPem(e)},t.getPublicKeyFingerprint=function(e,t){var a=(t=t||{}).md||j.md.md5.create(),i=j.util.createBuffer();n(i,"ssh-rsa"),r(i,e.e),r(i,e.n),a.start(),a.update(i.getBytes());var o=a.digest();if("hex"===t.encoding){var s=o.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return o.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return o}}));var on="forge.task",sn={},cn=0;j.debug.set(on,"tasks",sn);var un={};j.debug.set(on,"queues",un);var ln="ready",fn="running",dn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=fn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=fn,mn.running.block=dn,mn.running.unblock=fn,mn.running.sleep=pn,mn.running.wakeup=fn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=dn,mn.blocked.start=dn,mn.blocked.block=dn,mn.blocked.unblock=dn,mn.blocked.sleep=dn,mn.blocked.wakeup=dn,mn.blocked.cancel=hn,mn.blocked.fail=gn,mn.sleeping={},mn.sleeping.stop=pn,mn.sleeping.start=pn,mn.sleeping.block=pn,mn.sleeping.unblock=pn,mn.sleeping.sleep=pn,mn.sleeping.wakeup=pn,mn.sleeping.cancel=hn,mn.sleeping.fail=gn,mn.done={},mn.done.stop=hn,mn.done.start=hn,mn.done.block=hn,mn.done.unblock=hn,mn.done.sleep=hn,mn.done.wakeup=hn,mn.done.cancel=hn,mn.done.fail=gn,mn.error={},mn.error.stop=gn,mn.error.start=gn,mn.error.block=gn,mn.error.unblock=gn,mn.error.sleep=gn,mn.error.wakeup=gn,mn.error.cancel=gn,mn.error.fail=gn;var yn=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=ln,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=cn++,sn[this.id]=this};yn.prototype.debug=function(e){e=e||"",j.log.debug(on,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",un)},yn.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new yn({run:t,name:e,parent:this});return r.state=fn,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},yn.prototype.parallel=function(e,t){return j.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var a=function(e,r){j.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},i=0;i<t.length;i++)a(e+"__parallel-"+r.id+"-"+i,i)}))},yn.prototype.stop=function(){this.state=mn[this.state].stop},yn.prototype.start=function(){this.error=!1,this.state=mn[this.state].start,this.state===fn&&(this.start=new Date,this.run(this),vn(this,0))},yn.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=mn[this.state].block)},yn.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==hn&&(this.state=fn,vn(this,0)),this.blocks},yn.prototype.sleep=function(e){e=void 0===e?0:e,this.state=mn[this.state].sleep;var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=fn,vn(t,0)}),e)},yn.prototype.wait=function(e){e.wait(this)},yn.prototype.wakeup=function(){this.state===pn&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=fn,vn(this,0))},yn.prototype.cancel=function(){this.state=mn[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},yn.prototype.fail=function(e){if(this.error=!0,bn(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,vn(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;bn(t,!0)}this.failureCallback&&this.failureCallback(this)}};var vn=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===fn)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||vn(n,t)}else bn(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,vn(e.parent,t))};r?setTimeout(n,0):n(t)},bn=function(e,t){e.state=hn,delete sn[e.id],null===e.parent&&(e.type in un?0===un[e.type].length?j.log.error(on,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?j.log.error(on,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(un[e.type].shift(),0===un[e.type].length?delete un[e.type]:un[e.type][0].start()):j.log.error(on,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};j.task=j.task||{},j.task.start=function(e){var t=new yn({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in un?un[e.type].push(t):(un[t.type]=[t],function(e){e.error=!1,e.state=mn[e.state].start,setTimeout((function(){e.state===fn&&(e.swapTime=+new Date,e.run(e),vn(e,0))}),0)}(t))},j.task.cancel=function(e){e in un&&(un[e]=[un[e][0]])},j.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e};var Cn=j,En=function(){function e(e){this.secretKey=e}return e.prototype.encrypt=function(e,t){throw new Error("Method not implemented.")},e.prototype.decrypt=function(e,t){return function(e,t,r){void 0===r&&(r=Cn.util.createBuffer(Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer));var n,a,i=Cn.cipher.createDecipher("AES-CBC",t);return i.start({iv:r}),i.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),a=(n=i.output.data).charCodeAt(n.length-1),n.slice(0,-a)}(e,(r=this.secretKey,n=t.transactionID,""+r.slice(0,16)+n.slice(0,16)));var r,n},e}(),wn=function(){function e(e,t,n,a){void 0===n&&(n="production"),void 0===a&&(a={supportTransaction:!1,enableEncryption:!1}),this.transactionEnabled=a.supportTransaction||!1,this.encryptionEnabled=a.enableEncryption||!1;var i=D(e,t,n,{headers:a.httpHeaders});this.transactionManager=new F(i),this.encryptionService=new En(t),this.compareFaceService=new f(i),this.clientSettingsService=new d(i),this.convertPDFService=new v(i),this.ekycPDFService=new b(i),this.readIDCardService=new r(i),this.requestVerifyIDCardService=new h(i),this.requestVerifyPortraitSerivce=new g(i),this.imagesService=new u(i),this.fileService=new l(i),this.verifyFaceLivenessService=new p(i),this.searchFaceService=new y(i),this.detectIDTamperingService=new m(i),this.httpClient=i}return e.prototype.enableTransaction=function(){this.transactionEnabled=!0},e.prototype.disableTransaction=function(){this.transactionEnabled=!1},e.prototype.enableEncryption=function(){this.encryptionEnabled=!0},e.prototype.disableEncryption=function(){this.encryptionEnabled=!1},e.prototype.compareFaces=function(e,t){return this.compareFaceService.request(e,t)},e.prototype.clientSettings=function(){return this.clientSettingsService.request()},e.prototype.uploadImage=function(e){return this.imagesService.request(e)},e.prototype.uploadFile=function(e){return this.fileService.uploadFile(e)},e.prototype.convertPDF=function(e,t){return this.convertPDFService.request(e,t)},e.prototype.ekycPDF=function(e,t){return this.ekycPDFService.request(e,t)},e.prototype.readIDCard=function(e,t){return this.readIDCardService.request(e,t)},e.prototype.requestVerifyIDCard=function(e,t){return this.requestVerifyIDCardService.request(e,t)},e.prototype.requestVerifyPortrait=function(e,t){return this.requestVerifyPortraitSerivce.request(e,t)},e.prototype.verifyFaceLiveness=function(e,t){return this.verifyFaceLivenessService.request(e,t)},e.prototype.searchFaces=function(e,t){return this.searchFaceService.request(e,t)},e.prototype.deleteFaces=function(e,t){return this.searchFaceService.deleteFaces(e,t)},e.prototype.indexFaces=function(e,t){return this.searchFaceService.indexFaces(e,t)},e.prototype.downloadFaceImage=function(e){return this.searchFaceService.downloadFaceImage(e)},e.prototype.downloadImage=function(e){return this.imagesService.download(e)},e.prototype.updateMetadata=function(e,t){return this.imagesService.updateMetadata(e,t)},e.prototype.detectIDTampering=function(e,t){return this.detectIDTamperingService.request(e,t)},a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"compareFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"convertPDF",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"readIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"searchFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"deleteFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"indexFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=f,e.ClientSettings=d,e.VerifyFaceLiveness=p,e.RequestVerifyIDCard=h,e.RequestVerifyPortrait=g,e.DetectIDTampering=m,e.SearchFaces=y,e.ConvertPDF=v,e.EkycPDF=b,e.HttpClient=_,e.MockClient=x,e.TVAuthorizer=L,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new L(e,t),a=function(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":default:return"https://vn-vision.trustingsocial.com/api"}}(r);return new _({authorizer:n,domain:a})},e.createHttpClient=D,e.SimpleTrustVisionAPI=U,e.default=wn,Object.defineProperty(e,"__esModule",{value:!0})}(t,a.default)})),W0=o(Q0);function X0(e){var t=e.className;return SC.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},SC.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"}))}X0.propTypes={className:SE.string},X0.defaultProps={className:""};var Y0,$0,Z0,J0,e1,t1,r1,n1,a1,i1,o1,s1=(Lv(L0={},hB.FaceDirection.LEFT,90),Lv(L0,hB.FaceDirection.RIGHT,270),Lv(L0,hB.FaceDirection.UP,180),Lv(L0,hB.FaceDirection.DOWN,0),L0),c1=fB(["0%{opacity:0.15;}50%{opacity:0.3;}100%{opacity:1;}"]),u1=cB.div(O0||(O0=zv(["\n width: 200px;\n height: 200px;\n position: relative;\n transform: scale(0.48);\n\n .top,\n .right,\n .bottom,\n .left {\n position: absolute;\n }\n\n .top {\n top: 0;\n left: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .right {\n right: 0;\n top: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .bottom {\n bottom: 0;\n left: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n\n .left {\n left: 0;\n top: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n"])),s1[hB.FaceDirection.DOWN],s1[hB.FaceDirection.LEFT],s1[hB.FaceDirection.UP],s1[hB.FaceDirection.RIGHT]),l1=cB.div(D0||(D0=zv(["\n width: 70px;\n transform: rotate(","deg);\n"])),(function(e){var t,r=e.direction;return null!==(t=s1[r])&&void 0!==t?t:0})),f1=cB.span(U0||(U0=zv(["\n display: flex;\n margin: 4px 0;\n width: 100%;\n height: 15px;\n animation: "," 1s infinite;\n animation-direction: alternate;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgba(255, 255, 255, 0.8);\n }\n\n &::before {\n transform: skewY(32deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-32deg);\n }\n"])),c1),d1=cB(f1)(M0||(M0=zv(["\n animation-delay: 0s;\n"]))),p1=cB(f1)(V0||(V0=zv(["\n animation-delay: 0.5s;\n"]))),h1=cB(f1)(F0||(F0=zv(["\n animation-delay: 1s;\n"])));function g1(e){var t=e.type;return t!==hB.FaceDirection.FRONTAL?SC.createElement(l1,{direction:t},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)):SC.createElement(u1,null,SC.createElement(l1,{className:"top"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"right"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"bottom"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"left"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)))}g1.propTypes={type:SE.oneOf([hB.FaceDirection.LEFT,hB.FaceDirection.RIGHT,hB.FaceDirection.UP,hB.FaceDirection.FRONTAL])},g1.defaultProps={type:hB.FaceDirection.LEFT};var m1={sm:650,md:750},y1=DX.Camera,v1=q0.FaceDetectionError,b1=q0.FaceVerificationInstructions,C1=q0.FaceVerificationStepsWrapper,E1=q0.StepItem,w1=q0.BottomButtonsOverlay,k1=q0.Button,S1=q0.CountDownOverlay,B1=q0.InstructionsOverlay,A1=cB(C1)(Y0||(Y0=zv(["\n height: 50px;\n"]))),T1=cB(v1)($0||($0=zv(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n\n ",";\n"])),(function(e){return e.isMobile&&QS(["font-size:0.875rem;"])})),I1=cB(b1)(Z0||(Z0=zv(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n padding: 0 1.75rem;\n color: ",";\n text-shadow: none;\n\n ",";\n"])),(function(e){return e.color}),(function(e){return e.isMobile&&QS(["font-size:0.875rem;"])})),_1=cB(X0)(J0||(J0=zv(["\n width: 100%;\n height: 100%;\n vertical-align: middle;\n margin: 0;\n color: ",";\n"])),(function(e){var t=e.color;return null!=t?t:"#06243c"})),x1=cB.img(e1||(e1=zv(["\n && {\n width: 20px;\n border-radius: 50%;\n margin: 0;\n\n ","\n }\n"])),(function(e){return"preview"===e.mode&&QS(["width:42px;"])})),P1=cB(E1)(t1||(t1=zv(["\n width: 50px;\n height: 50px;\n border: 1px solid #005993;\n border-radius: 50%;\n\n & + & {\n margin-left: 10px;\n }\n\n ","\n"])),(function(e){return!e.active&&QS(["border-color:#f2f6f9;opacity:0.3;"])})),R1=cB(PW)(r1||(r1=zv(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),N1=cB.div(n1||(n1=zv(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n"]))),L1=cB(N1)(a1||(a1=zv(["\n background: rgba(223, 0, 0, 0.2);\n"]))),O1=fB(["from{opacity:1;}to{opacity:0;}"]),D1=cB(N1)(i1||(i1=zv(["\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),O1),U1=uq.isMobile?{width:640}:null;function M1(e){var t=e.className,r=e.apiCheck,n=e.enableInstructionsOverlay,a=e.enableErrorOverlay,i=e.enableCapturingOverlay,o=e.frontalMinSize,s=e.mode,c=e.minPadding,u=e.backgroundColor,l=e.textColor,f=e.progressProps,d=e.customInstructions,p=e.customIcon,h=e.customDirectionIcon,g=e.onLivenessDetectionDone,m=e.onClose,y=e.onError,v=e.captureFrameSettings,b=e.onFramesCaptured,C=e.apiCredentials,E=SC.useCallback((function(e){var t=e.clientWidth,r=e.clientHeight,n=e.videoAreaWidth,a=e.videoAreaHeight,i=e.lostX,o=e.lostY,s=Math.max(60,o),u=Math.max(90,o);r>m1.sm&&(s=Math.max(70,o),u=Math.max(140,o)),r>m1.md&&(s=Math.max(70,o),u=Math.max(140,o));var l=Math.max(c,i),f=Math.max(c,i),d=Math.min(n,a),p=Math.max(Math.floor(Math.min(t-(l+f),r-(s+u),d)),160);return{x:Math.min(Math.floor(l+(t-f-l)/2-p/2),t-p),y:Math.min(Math.floor(s+(r-u-s)/2-p/2),r-p),width:p,height:p}}),[c]),w=SC.useMemo((function(){return{background:u,opacity:1}}),[u]),k=z0({apiCheck:r,frontalMinSize:o,mode:s,bgCameraMask:null,bgCameraMaskRed:null,surroundStyle:w,cropAreaDimension:E,customInstructions:d,customIcon:p,customDirectionIcon:h,onLivenessDetectionDone:g,captureFrameSettings:v,onFramesCaptured:b,apiCredentials:C}),S=k.countdownToTakePicture,B=k.cropArea,A=k.curStepIndex,T=k.directionIcon,I=k.faceDetectionError,_=k.handleTriggerPassiveMode,x=k.handleVideoPlayed,P=k.instructions,R=k.isActiveMode,N=k.refVideo,L=k.showCountdown,O=k.steps,D=k.videoPlayed,U=k.activeCapturing,M=k.warmupDone,V=50,F=12,j=14;window.innerHeight>m1.sm&&(V=50,F=24,j=34),window.innerHeight>m1.md&&(V=50,F=24,j=40);var K=j+V+F,z=a&&I;return SC.createElement(Pq,{ref:N,className:t,frontCamera:!0,flipHorizontal:!0,videoSettings:U1,onVideoPlayed:x,onClose:m,onError:y},!M&&SC.createElement(lX,null),D?SC.createElement(SC.Fragment,null,B.current?SC.createElement(Uq,{x:"".concat(B.current.x,"px"),y:"".concat(B.current.y,"px"),width:"".concat(B.current.width,"px"),height:"".concat(B.current.height,"px"),surroundStyle:B.current.surroundStyle},SC.createElement(_1,{color:u}),SC.createElement(R1,Ov({progress:A/O.length*100,hasError:z},f)),L?SC.createElement(S1,null,S):null,R&&n&&T?SC.createElement(B1,null,T):null,R&&i&&U?SC.createElement(D1,null):null,z?SC.createElement(L1,null):null):null,I?SC.createElement(T1,{top:30,isMobile:uq.isMobile},I):null,R?SC.createElement(SC.Fragment,null,P?SC.createElement(I1,{bottom:K,isMobile:uq.isMobile,color:l},P):null,SC.createElement(A1,{bottom:j},O.map((function(e,t){var r=e.name,n=e.icon,a=e.image.objUrl,i=A>=t;return SC.createElement(P1,{key:r,active:i},a?SC.createElement(x1,{src:a,alt:"",mode:"preview"}):function(e,t){return"string"==typeof e?SC.createElement(x1,{src:e,alt:""}):SC.cloneElement(e,t)}(n,{active:i}))})))):SC.createElement(SC.Fragment,null,I?null:SC.createElement(w1,null,SC.createElement(k1,{onClick:_},SC.createElement(y1,null))))):null)}function V1(e){return SC.createElement(qX,Ov({},e,{livenessComponent:M1}))}M1.propTypes={className:SE.string,apiCheck:SE.bool,enableInstructionsOverlay:SE.bool,enableErrorOverlay:SE.bool,enableCapturingOverlay:SE.bool,frontalMinSize:SE.number,mode:SE.string,minPadding:SE.number,backgroundColor:SE.string,textColor:SE.string,progressProps:SE.shape({className:SE.string,style:SE.shape({}),radius:SE.number,strokeWidth:SE.number,progress:SE.number,activeColor:SE.string,innerPadding:SE.number,outsideRingColor:SE.string,insideRingColor:SE.string,insideRingWidth:SE.number,dashedRingColor:SE.string,dashedRingWidth:SE.number,dashedRingLineThick:SE.number,dashedRingLineSpacing:SE.number,showOutsideRing:SE.bool,showDashedRing:SE.bool,showInsideRing:SE.bool}),title:SE.string,description:SE.string,customInstructions:SE.shape({}),customIcon:SE.shape({}),customDirectionIcon:SE.shape({}),onLivenessDetectionDone:SE.func,onClose:SE.func,onError:SE.func,captureFrameSettings:SE.shape({}),onFramesCaptured:SE.func,apiCredentials:SE.shape({accessKey:SE.string,secretKey:SE.string,apiUrl:SE.string})},M1.defaultProps={className:"",apiCheck:!1,enableInstructionsOverlay:!1,enableErrorOverlay:!1,enableCapturingOverlay:!1,frontalMinSize:720,mode:null,minPadding:5,backgroundColor:"#06243c",textColor:"#ffffff",progressProps:null,title:"Chụp ảnh chân dung",description:"Xin đưa khuôn mặt vào khung hình. Hình ảnh sẽ tự động được ghi lại.",customInstructions:null,customIcon:null,customDirectionIcon:(o1={},Lv(o1,hB.FaceDirection.LEFT,SC.createElement(g1,{type:hB.FaceDirection.LEFT})),Lv(o1,hB.FaceDirection.RIGHT,SC.createElement(g1,{type:hB.FaceDirection.RIGHT})),Lv(o1,hB.FaceDirection.UP,SC.createElement(g1,{type:hB.FaceDirection.UP})),Lv(o1,hB.FaceDirection.FRONTAL,SC.createElement(g1,{type:hB.FaceDirection.FRONTAL})),o1),onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"}};var F1=["apiCheck","mode","accessKey","secretKey","apiUrl","onLivenessDetectionDone","onError","tracking"],j1=hB.FaceDirection,K1="https://unpkg.com/@tsocial/tvweb-sdk@latest/assets",z1=function(){function e(t){var r=this,n=t.container,a=t.lang,i=void 0===a?"en":a,o=t.assetRoot,s=void 0===o?K1:o,c=t.resourceRoot,u=t.customUrls,l=void 0===u?{}:u,f=t.enableAntiDebug,d=void 0===f||f;Pv(this,e),Lv(this,"checkCamera",RX),Lv(this,"runWarmUpReadIDCard",xv(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.commonSettings.customUrls,e.abrupt("return",Y$(t));case 2:case"end":return e.stop()}}),e)})))),Lv(this,"runPreloadEKYCResources",xv(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.commonSettings.customUrls,j0(t);case 2:case"end":return e.stop()}}),e)})))),Lv(this,"destroyView",(function(){Pz.unmountComponentAtNode(r.container)})),G0(n,"container is a required parameter"),this.container=n;var p=p_({resourceRoot:c,initCustomUrls:l});this.commonSettings={lang:i,assetRoot:s,customUrls:p,enableAntiDebug:d,debug:!1,livenessTracking:{enable:!0}}}return Nv(e,[{key:"readIDCardWithApiCall",value:function(e){Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:Uv({},this.commonSettings)},SC.createElement(R0,Ov({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:this.commonSettings},SC.createElement(g0,Ov({onClose:this.destroyView},e))),this.container)}},{key:"livenessDetection",value:function(e){var t,r=e.apiCheck,n=e.mode,a=(e.accessKey,e.secretKey,e.apiUrl,e.onLivenessDetectionDone),i=e.onError,o=e.tracking,s=Kv(e,F1);Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:Uv({},this.commonSettings)},SC.createElement(Y_.SDKTrackingProvider,{value:{tracking:Uv(Uv({},this.commonSettings.livenessTracking),o)}},SC.createElement(V1,Ov({apiCheck:r,mode:n,onLivenessDetectionDone:a,onClose:this.destroyView,onError:i,enableInstructionsOverlay:!0,enableErrorOverlay:!0,enableCapturingOverlay:!0,backgroundColor:"#ffffff",textColor:"inherit",progressProps:{activeColor:"#f08200",insideRingWidth:8,outsideRingColor:"#f2f2f2",insideRingColor:"#ffffff",dashedRingColor:"#d7d7d7",dashedRingOpacity:1,dashedInsideRingColor:"#d7d7d7",dashedInsideRingWidth:1},customInstructions:(t={},Lv(t,j1.LEFT,{vi:"Vui lòng quay mặt sang bên trái"}),Lv(t,j1.RIGHT,{vi:"Vui lòng quay mặt sang bên phải"}),Lv(t,j1.UP,{vi:"Vui lòng ngước mặt lên"}),Lv(t,j1.FRONTAL,{vi:"Xin đưa khuôn mặt chính diện vào khung hình"}),t)},s,{enableRecording:!1})))),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,a=e.image1,i=e.image2,o=e.onSuccess,s=e.onError;fR.createRetryAPIClient(new W0(t,r,n)).compareFaces({image1:{id:a},image2:{id:i}}).then((function(e){o(e)})).catch((function(e){s(e)}))}}]),e}();t.APIUtils=fR,t.Animations=JY,t.AntiDebugUtils=DR,t.AssetUtils=J_,t.AsyncUtils=tx,t.BASE_Z_INDEX=dq,t.BlurUtils=Bx,t.Button=CZ,t.ButtonLink=EZ,t.Camera=Pq,t.CameraUtils=Tx,t.CommonUtils=_x,t.Constants=hB,t.CoordinateUtils=Lx,t.CropAreaOverlayWrapper=Uq,t.CryptoUtils=VR,t.FaceUtils=Kx,t.GlareUtils=tR,t.HashUtils=j_,t.HighlightResult=AJ,t.HighlightResultType=bJ,t.Icons=DX,t.ImageUtils=$P,t.LivenessDetection=qX,t.LivenessDetectionComponents=q0,t.LoadResourceUtils=CR,t.LocalStorageUtils=U_,t.MobileDetect=uq,t.ModelUtils=OR,t.NativeCamera=LX,t.PlacementArea=Dq,t.Popup=HW,t.PredictionUtils=Gx,t.ProgressCircle=PW,t.RatioWrapper=VZ,t.ReadIDCardUIOnly=g0,t.ReadIDCardWithApiCall=R0,t.RectangleMask=pY,t.RectangleMaskType=dY,t.SDK=z1,t.ScannerType=l0,t.SettingsContext=v_,t.Spacing=pZ,t.ThemeUtils=UR,t.TimeUtils=L_,t.TrackingContext=Y_,t.UserAgentUtils=P_,t.WarmupPopup=lX,t.checkCamera=RX,t.defaultClientSettings=a0,t.defaultReadIDCardSteps=f0,t.getCustomUrlsBySettings=p_,t.getQrScannerWorkerPath=FR,t.handleApiCheckReadIdCard=I0,t.preloadEKYCResources=j0,t.readIdCardFromImage=K0,t.readQRCodeFromImage=fJ,t.useLivenessDetection=z0,t.useMainProcessQRCodeScanner=dJ,t.useMainProcessReadIdCard=nZ,t.useSettingsReadIdCard=i0,t.useShowPopup=C$,t.warmUpQRCodeScanner=$Z,t.warmUpReadIdCard=Y$,t.warmupSelfieActive=iW,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
67
|
+
***************************************************************************** */function a(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,r,n){return new(r||(r=Promise))((function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var u=function(){function e(e){this.httpClient=e}return e.prototype.uploadImage=function(e){return this.httpClient.postFormData("/v1/images",e)},e.prototype.request=function(e){var t="application/pdf"===e.file.type;return this.httpClient.postFormData(t?"/v1/files":"/v1/images",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/images",e,t)},e.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/images/"+e)];case 1:return t=r.sent(),[4,URL.createObjectURL(t)];case 2:return[2,r.sent()]}}))}))},e.prototype.updateMetadata=function(e,t){return this.httpClient.patch("/v1/images/"+e,t)},e}(),l=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/files",e,t)},e.prototype.uploadFile=function(e){return this.httpClient.postFormData("/v1/files",e)},e.prototype.requestWithHeaders=function(e,t){return this.httpClient.postFormData("/v1/files",e,t)},e}(),f=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/compare_faces_sync",e,t)},e}(),d=function(){function e(e){this.httpClient=e}return e.prototype.getClientSettings=function(){return this.httpClient.get("/v1/client_settings")},e.prototype.request=function(){return this.httpClient.get("/v1/client_settings")},e}(),p=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_face_liveness_sync",e,t)},e}(),h=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_id_card_sanity_sync",e,t)},e}(),g=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/verify_portrait_sanity_sync",e,t)},e}(),m=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e.prototype.requestWithAuthHeaders=function(e,t){return this.httpClient.post("/v1/detect_id_card_tampering_sync",e,t)},e}(),y=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/search_faces_sync",e,t)},e.prototype.indexFaces=function(e,t){return this.httpClient.post("/v1/index_faces_sync",e,t)},e.prototype.deleteFaces=function(e,t){return this.httpClient.post("/v1/delete_faces",e,t)},e.prototype.downloadFaceImage=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.httpClient.downloadFile("/v1/face_images/"+e)];case 1:return t=r.sent(),[2,URL.createObjectURL(t)]}}))}))},e}(),v=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.postFormData("/v1/convert_pdf_sync",e,t)},e}(),b=function(){function e(e){this.httpClient=e}return e.prototype.request=function(e,t){return this.httpClient.post("/v1/ekyc_pdf",e,t)},e}(),C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:{};function E(e,t){return e(t={exports:{}},t.exports),t.exports}var w=E((function(e){var t,r;t=C,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var a=e[n];if("string"!=typeof a)throw new TypeError("Url must be a string. Received "+a);""!==a&&(n>0&&(a=a.replace(/^[\/]+/,"")),a=n<e.length-1?a.replace(/[\/]+$/,""):a.replace(/[\/]+$/,"/"),t.push(a))}var i=t.join("/"),o=(i=i.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o.shift()+(o.length>0?"?":"")+o.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()}));function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var S=function(e,t,r,n){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var i=/\+/g;e=e.split(t);var o=1e3;n&&"number"==typeof n.maxKeys&&(o=n.maxKeys);var s=e.length;o>0&&s>o&&(s=o);for(var c=0;c<s;++c){var u,l,f,d,p=e[c].replace(i,"%20"),h=p.indexOf(r);h>=0?(u=p.substr(0,h),l=p.substr(h+1)):(u=p,l=""),f=decodeURIComponent(u),d=decodeURIComponent(l),k(a,f)?Array.isArray(a[f])?a[f].push(d):a[f]=[a[f],d]:a[f]=d}return a},B=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},A=function(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){var a=encodeURIComponent(B(n))+r;return Array.isArray(e[n])?e[n].map((function(e){return a+encodeURIComponent(B(e))})).join(t):a+encodeURIComponent(B(e[n]))})).join(t):n?encodeURIComponent(B(n))+r+encodeURIComponent(B(e)):""},T=E((function(e,t){t.decode=t.parse=S,t.encode=t.stringify=A})),I=(T.decode,T.parse,T.encode,T.stringify),_=function(){function e(e){this.authorizer=e.authorizer,this.domain=e.domain,this.onError=e.onError,this.configHeaders=e.headers}return e.prototype.get=function(e,t,r){var n=new URL(this.resolveUrl(e));return t&&(n.search=I(t)),this.request(n.toString(),{requestPath:e,method:"GET",headers:r})},e.prototype.post=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"POST",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.postFormData=function(e,t,r){var n,a=t instanceof FormData?t:(n=t,Object.entries(n).reduce((function(e,t){var r=t[0],n=t[1];return Array.isArray(n)?n.forEach((function(t,a){return e.append(r+"["+a+"]",n)})):!(n instanceof Object)||n instanceof File||n instanceof Date||n instanceof Blob?e.append(r,n):Object.entries(n).forEach((function(t,a){return e.append(r+"["+a+"]",n[a])})),e}),new FormData)),i=this.resolveUrl(e);return this.request(i,{requestPath:e,method:"POST",body:a,headers:r})},e.prototype.patch=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"PATCH",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.delete=function(e,t,r){var a=this.resolveUrl(e);return this.request(a,{requestPath:e,method:"DELETE",body:JSON.stringify(t),headers:n({"Content-Type":"application/json"},r)})},e.prototype.downloadFile=function(e){var t=this.resolveUrl(e);return this.request(t,{requestPath:e,method:"GET"},"blob")},e.prototype.request=function(e,t,r){return void 0===r&&(r="json"),s(this,void 0,void 0,(function(){var a,i,o,s;return c(this,(function(c){switch(c.label){case 0:return a={},i={},this.authorizer&&(a=this.authorizer.getHeaders(t)),this.configHeaders&&(i=this.configHeaders),t.headers=n(n(n({},t.headers),a),i),[4,fetch(e,t)];case 1:return o=c.sent(),[4,"blob"===r?o.blob():o.json()];case 2:if((s=c.sent()).errors&&this.onError)throw this.onError(s.errors),s;return[2,s]}}))}))},e.prototype.resolveUrl=function(e){return w(this.domain,e)},e}(),x=function(){function e(e){this.mocks=e}return e.prototype.get=function(e,t){return this.findInMocks(e,t)},e.prototype.post=function(e,t){return this.findInMocks(e)},e.prototype.postFormData=function(e,t){return this.findInMocks(e)},e.prototype.patch=function(e,t){return this.findInMocks(e)},e.prototype.delete=function(e,t){return this.findInMocks(e)},e.prototype.downloadFile=function(e){return this.findInMocks(e)},e.prototype.resolveUrl=function(e){return this.mocks.resolveUrl?this.mocks.resolveUrl(e):e},e.prototype.findInMocks=function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this.mocks[e]?"function"==typeof this.mocks[e]?[2,Promise.resolve(this.mocks[e](t))]:[2,Promise.resolve(this.mocks[e])]:[2,Promise.reject(new Error(e+" is not presented in mocks"))]}))}))},e}(),P=E((function(e,t){var r;e.exports=r=r||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},a=n.lib={},i=a.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=a.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,a=e.sigBytes;if(this.clamp(),n%4)for(var i=0;i<a;i++){var o=r[i>>>2]>>>24-i%4*8&255;t[n+i>>>2]|=o<<24-(n+i)%4*8}else for(i=0;i<a;i+=4)t[n+i>>>2]=r[i>>>2];return this.sigBytes+=a,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],a=function(t){t=t;var r=987654321,n=4294967295;return function(){var a=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return a/=4294967296,(a+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var s=a(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new o.init(n,t)}}),s=n.enc={},c=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var i=t[a>>>2]>>>24-a%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},u=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],a=0;a<r;a++){var i=t[a>>>2]>>>24-a%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=a.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,a=r.sigBytes,i=this.blockSize,s=a/(4*i),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,u=e.min(4*c,a);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(n,l);var f=n.splice(0,c);r.sigBytes-=u}return new o.init(f,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(a.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new d.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math)})),R=E((function(e,t){var r,n,a;e.exports=(n=(r=a=P).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var a=[],i=0;i<r;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)a.push(n.charAt(o>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;a.length%4;)a.push(c);return a.join("")},parse:function(e){var t=e.length,r=this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var i=0;i<r.length;i++)a[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var s=e.indexOf(o);-1!==s&&(t=s)}return function(e,t,r){for(var a=[],i=0,o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2,c=r[e.charCodeAt(o)]>>>6-o%4*2;a[i>>>2]|=(s|c)<<24-i%4*8,i++}return n.create(a,i)}(e,t,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},a.enc.Base64)})),N=(E((function(e,t){var r;e.exports=(r=P,function(e){var t=r,n=t.lib,a=n.WordArray,i=n.Hasher,o=t.algo,s=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,a=0;a<64;)t(n)&&(a<8&&(s[a]=r(e.pow(n,.5))),c[a]=r(e.pow(n,1/3)),a++),n++}();var u=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new a.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],a=r[1],i=r[2],o=r[3],s=r[4],l=r[5],f=r[6],d=r[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var h=u[p-15],g=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=g+u[p-7]+y+u[p-16]}var v=n&a^n&i^a&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=d+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&l^~s&f)+c[p]+u[p];d=f,f=l,l=s,s=o+C|0,o=i,i=a,a=n,n=C+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+a|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+f|0,r[7]=r[7]+d|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,a=8*t.sigBytes;return r[a>>>5]|=128<<24-a%32,r[14+(a+64>>>9<<4)]=e.floor(n/4294967296),r[15+(a+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l)}(Math),r.SHA256)})),E((function(e,t){var r,n,a;e.exports=(n=(r=P).lib.Base,a=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=a.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,c=o.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))})),E((function(e,t){e.exports=P.HmacSHA256}))),L=function(){function e(e,t){this.accessKey=e,this.keySecret=t}return e.prototype.getHeaders=function(e){var t=function(e){function t(e){return e<10?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+(0===(r=e.getTimezoneOffset())?"Z":(n=r>0?"-":"+",r=Math.abs(r),n+t(Math.floor(r/60))+":"+t(r%60)));var r,n}(new Date);return{Authorization:this.generateAuthorization(e.requestPath,e.method,t),"X-TV-Timestamp":t}},e.prototype.generateAuthorization=function(e,t,r){var n=this.computeStringToSign(e,t,r),a=R.stringify(this.computeSignature(n));return this.formatAuthToken("TV",a)},e.prototype.formatAuthToken=function(e,t){return e+" "+this.accessKey+":"+t},e.prototype.computeStringToSign=function(e,t,r){return t+"\n"+e+"\n"+r},e.prototype.computeSignature=function(e){return N(e,this.keySecret)},e}();function O(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":return"https://vn-vision.trustingsocial.com/api";default:return e}}function D(e,t,r,n){void 0===r&&(r="production");var a=(void 0===n?{}:n).headers,i=new L(e,t),o=O(r);return new _({authorizer:i,domain:o,headers:a})}var U=function(){function e(e){void 0===e&&(e="production");var t=new _({domain:O(e)});this.imagesService=new u(t),this.detectIDTamperingService=new m(t)}return e.prototype.uploadImage=function(e,t){return this.imagesService.requestWithHeaders(e,t)},e.prototype.detectTampering=function(e,t){return this.detectIDTamperingService.requestWithAuthHeaders(e,t)},e}();function M(e){var t=e.headerIndex;return function(e,r,a){var i=a.value,o=n({},a);return o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,a,o,s;return c(this,(function(c){switch(c.label){case 0:return this.transactionEnabled?[4,this.transactionManager.begin()]:[3,4];case 1:return r=c.sent(),a=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),a=0;for(t=0;t<r;t++)for(var i=arguments[t],o=0,s=i.length;o<s;o++,a++)n[a]=i[o];return n}(e),(o=n({},a[t]))["X-TV-Transaction"]=r,a[t]=o,[4,i.apply(this,a)];case 2:return s=c.sent(),[4,this.transactionManager.end()];case 3:return c.sent(),[2,s];case 4:return[4,i.apply(this,e)];case 5:return[2,c.sent()]}}))}))},o}}function V(e){return void 0===e&&(e={encryptedField:"data"}),function(t,r,a){var i=a.value,o=n({},a);return o.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return s(this,void 0,void 0,(function(){var r,n;return c(this,(function(a){switch(a.label){case 0:return[4,i.apply(this,t)];case 1:return r=a.sent(),this.encryptionEnabled&&"string"==typeof r[e.encryptedField]?(n=this.encryptionService.decrypt(r[e.encryptedField],{transactionID:this.transactionManager.currentTransactionID}),[2,JSON.parse(n)]):[2,r]}}))}))},o}}var F=function(){function e(e){this.httpClient=e,this.transactionID="",this.totalTransactions=0,this.currentTransaction=0}return Object.defineProperty(e.prototype,"currentTransactionID",{get:function(){return this.transactionID},enumerable:!0,configurable:!0}),e.prototype.begin=function(){return s(this,void 0,void 0,(function(){var e,t,r=this;return c(this,(function(n){switch(n.label){case 0:return e=this.totalTransactions++,[4,new Promise((function(t,n){var a=window.performance.now(),i=setInterval((function(){e===r.currentTransaction&&(clearInterval(i),t(!0)),window.performance.now()-a>=3e3&&(clearInterval(i),n(new Error("Transaction timeout")))}),100)}))];case 1:return n.sent(),[4,this.httpClient.post("/v1/transactions",{})];case 2:return t=n.sent().data,this.transactionID=t.id,[2,t.id]}}))}))},e.prototype.end=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return[4,this.httpClient.post("/v1/transactions/"+this.transactionID+"/finish")];case 1:return e=t.sent(),this.transactionID="",this.currentTransaction++,[2,e]}}))}))},e}(),j={options:{usePureJavaScript:!1}},K={},z=K,q={};K.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var a=0,i=t.length,o=t.charAt(0),s=[0];for(a=0;a<e.length;++a){for(var c=0,u=e[a];c<s.length;++c)u+=s[c]<<8,s[c]=u%i,u=u/i|0;for(;u>0;)s.push(u%i),u=u/i|0}for(a=0;0===e[a]&&a<e.length-1;++a)n+=o;for(a=s.length-1;a>=0;--a)n+=t[s[a]]}else n=function(e,t){var r=0,n=t.length,a=t.charAt(0),i=[0];for(r=0;r<e.length();++r){for(var o=0,s=e.at(r);o<i.length;++o)s+=i[o]<<8,i[o]=s%n,s=s/n|0;for(;s>0;)i.push(s%n),s=s/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=a;for(r=i.length-1;r>=0;--r)c+=t[i[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},K.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=q[t];if(!r){r=q[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");var a=t.length,i=t.charAt(0),o=[0];for(n=0;n<e.length;n++){var s=r[e.charCodeAt(n)];if(void 0===s)return;for(var c=0,u=s;c<o.length;++c)u+=o[c]*a,o[c]=255&u,u>>=8;for(;u>0;)o.push(255&u),u>>=8}for(var l=0;e[l]===i&&l<e.length-1;++l)o.push(0);return"undefined"!=typeof Buffer?Buffer.from(o.reverse()):new Uint8Array(o.reverse())},E((function(e){var t=e.exports=j.util=j.util||{};function r(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function n(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(t.isArrayBuffer(e)||t.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var r=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,r)}catch(e){for(var a=0;a<r.length;++a)this.putByte(r[a])}}else(e instanceof n||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return t.nextTick=process.nextTick,void("function"==typeof setImmediate?t.setImmediate=setImmediate:t.setImmediate=t.nextTick);if("function"==typeof setImmediate)return t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(t.nextTick=function(e){return setImmediate(e)});if(t.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){var e="forge.setImmediate",r=[];t.setImmediate=function(t){r.push(t),1===r.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(t){if(t.source===window&&t.data===e){t.stopPropagation();var n=r.slice();r.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!=typeof MutationObserver){var n=Date.now(),a=!0,i=document.createElement("div");r=[],new MutationObserver((function(){var e=r.slice();r.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var o=t.setImmediate;t.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),o(e)):(r.push(e),1===r.length&&i.setAttribute("a",a=!a))}}t.nextTick=t.setImmediate}(),t.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,t.globalScope=t.isNodejs?C:"undefined"==typeof self?window:self,t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},t.isArrayBufferView=function(e){return e&&t.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},t.ByteBuffer=n,t.ByteStringBuffer=n,t.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},t.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},t.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},t.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(t.encodeUtf8(e))},t.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},t.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},t.ByteStringBuffer.prototype.putInt=function(e,t){r(t);var n="";do{t-=8,n+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(n)},t.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},t.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},t.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},t.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},t.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},t.ByteStringBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},t.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.DataBuffer=function(e,r){r=r||{},this.read=r.readOffset||0,this.growSize=r.growSize||1024;var n=t.isArrayBuffer(e),a=t.isArrayBufferView(e);if(n||a)return this.data=n?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in r?r.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in r&&(this.write=r.writeOffset)},t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},t.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},t.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},t.DataBuffer.prototype.putBytes=function(e,r){if(t.isArrayBufferView(e)){var n=(a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-a.byteOffset;return this.accommodate(n),new Uint8Array(this.data.buffer,this.write).set(a),this.write+=n,this}if(t.isArrayBuffer(e)){var a=new Uint8Array(e);return this.accommodate(a.byteLength),new Uint8Array(this.data.buffer).set(a,this.write),this.write+=a.byteLength,this}if(e instanceof t.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&t.isArrayBufferView(e.data))return a=new Uint8Array(e.data.byteLength,e.read,e.length()),this.accommodate(a.byteLength),new Uint8Array(e.data.byteLength,this.write).set(a),this.write+=a.byteLength,this;if(e instanceof t.ByteStringBuffer&&(e=e.data,r="binary"),r=r||"binary","string"==typeof e){var i;if("hex"===r)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(e,i,this.write),this;if("base64"===r)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(e,i,this.write),this;if("utf8"===r&&(e=t.encodeUtf8(e),r="binary"),"binary"===r||"raw"===r)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(i),this;if("utf16"===r)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+r)}throw Error("Invalid parameter: "+e)},t.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},t.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},t.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(e,t){r(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},t.DataBuffer.prototype.putSignedInt=function(e,t){return r(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},t.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},t.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},t.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},t.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},t.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},t.DataBuffer.prototype.getInt=function(e){r(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},t.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},t.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},t.DataBuffer.prototype.toString=function(e){var r=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return t.binary.raw.encode(r);if("hex"===e)return t.binary.hex.encode(r);if("base64"===e)return t.binary.base64.encode(r);if("utf8"===e)return t.text.utf8.decode(r);if("utf16"===e)return t.text.utf16.decode(r);throw new Error("Invalid encoding: "+e)},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var n="",a="",i="",o=0,s=0;r>0;--r,++o)a=e.charCodeAt(o)^t.charCodeAt(o),s>=10&&(n+=i,i="",s=0),i+=String.fromCharCode(a),++s;return n+i},t.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},t.bytesToHex=function(e){return t.createBuffer(e).toHex()},t.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(e,t){for(var r,n,i,o="",s="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),i=e.charCodeAt(c++),o+=a.charAt(r>>2),o+=a.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=a.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":a.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,a,o="",s=0;s<e.length;)t=i[e.charCodeAt(s++)-43],r=i[e.charCodeAt(s++)-43],n=i[e.charCodeAt(s++)-43],a=i[e.charCodeAt(s++)-43],o+=String.fromCharCode(t<<2|r>>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==a&&(o+=String.fromCharCode((3&n)<<6|a)));return o},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:z.encode,decode:z.decode}},t.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},t.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var a=r=r||0,i=0;i<e.length;++i)n[a++]=e.charCodeAt(i);return t?a-r:n},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var a=0,i=r=r||0;for(1&e.length&&(a=1,n[i++]=parseInt(e[0],16));a<e.length;a+=2)n[i++]=parseInt(e.substr(a,2),16);return t?i-r:n},t.binary.base64.encode=function(e,t){for(var r,n,i,o="",s="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],i=e[c++],o+=a.charAt(r>>2),o+=a.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=a.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":a.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},t.binary.base64.decode=function(e,t,r){var n,a,o,s,c=t;c||(c=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u<e.length;)n=i[e.charCodeAt(u++)-43],a=i[e.charCodeAt(u++)-43],o=i[e.charCodeAt(u++)-43],s=i[e.charCodeAt(u++)-43],c[l++]=n<<2|a>>4,64!==o&&(c[l++]=(15&a)<<4|o>>2,64!==s&&(c[l++]=(3&o)<<6|s));return t?l-r:c.subarray(0,l)},t.binary.base58.encode=function(e,r){return t.binary.baseN.encode(e,o,r)},t.binary.base58.decode=function(e,r){return t.binary.baseN.decode(e,o,r)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(e,r,n){e=t.encodeUtf8(e);var a=r;a||(a=new Uint8Array(e.length));for(var i=n=n||0,o=0;o<e.length;++o)a[i++]=e.charCodeAt(o);return r?i-n:a},t.text.utf8.decode=function(e){return t.decodeUtf8(String.fromCharCode.apply(null,e))},t.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var a=new Uint16Array(n.buffer),i=r=r||0,o=r,s=0;s<e.length;++s)a[o++]=e.charCodeAt(s),i+=2;return t?i-r:n},t.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},t.deflate=function(e,r,n){if(r=t.decode64(e.deflate(t.encode64(r)).rval),n){var a=2;32&r.charCodeAt(1)&&(a=6),r=r.substring(a,r.length-4)}return r},t.inflate=function(e,r,n){var a=e.inflate(t.encode64(r)).rval;return null===a?null:t.decode64(a)};var s=function(e,r,n){if(!e)throw new Error("WebStorage not available.");var a;if(null===n?a=e.removeItem(r):(n=t.encode64(JSON.stringify(n)),a=e.setItem(r,n)),void 0!==a&&!0!==a.rval){var i=new Error(a.error.message);throw i.id=a.error.id,i.name=a.error.name,i}},c=function(e,r){if(!e)throw new Error("WebStorage not available.");var n=e.getItem(r);if(e.init)if(null===n.rval){if(n.error){var a=new Error(n.error.message);throw a.id=n.error.id,a.name=n.error.name,a}n=null}else n=n.rval;return null!==n&&(n=JSON.parse(t.decode64(n))),n},u=function(e,t,r,n){var a=c(e,t);null===a&&(a={}),a[r]=n,s(e,t,a)},l=function(e,t,r){var n=c(e,t);return null!==n&&(n=r in n?n[r]:null),n},f=function(e,t,r){var n=c(e,t);if(null!==n&&r in n){delete n[r];var a=!0;for(var i in n){a=!1;break}a&&(n=null),s(e,t,n)}},d=function(e,t){s(e,t,null)},p=function(e,t,r){var n,a=null;void 0===r&&(r=["web","flash"]);var i=!1,o=null;for(var s in r){n=r[s];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");a=e.apply(this,t),i="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,a=e.apply(this,t),i=!0)}catch(e){o=e}if(i)break}if(!i)throw o;return a};t.setItem=function(e,t,r,n,a){p(u,arguments,a)},t.getItem=function(e,t,r,n){return p(l,arguments,n)},t.removeItem=function(e,t,r,n){p(f,arguments,n)},t.clearItems=function(e,t,r){p(d,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),n=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(80!==n.port&&"http"===n.scheme||443!==n.port&&"https"===n.scheme)&&(n.fullHost+=":"+n.port):"http"===n.scheme?n.port=80:"https"===n.scheme&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var h=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),n=0;n<r.length;n++){var a,i,o=r[n].indexOf("=");o>0?(a=r[n].substring(0,o),i=r[n].substring(o+1)):(a=r[n],i=null),a in t||(t[a]=[]),a in Object.prototype||null===i||t[a].push(unescape(i))}return t};return void 0===e?(null===h&&(h="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=h):t=r(e),t},t.parseFragment=function(e){var r=e,n="",a=e.indexOf("?");a>0&&(r=e.substring(0,a),n=e.substring(a+1));var i=r.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:r,queryString:n,path:i,query:""===n?{}:t.getQueryVariables(n)}},t.makeRequest=function(e){var r=t.parseFragment(e),n={path:r.pathString,query:r.queryString,getPath:function(e){return void 0===e?r.path:r.path[e]},getQuery:function(e,t){var n;return void 0===e?n=r.query:(n=r.query[e])&&void 0!==t&&(n=n[t]),n},getQueryLast:function(e,t){var r=n.getQuery(e);return r?r[r.length-1]:t}};return n},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,a=t.length;n<a;){var i=t[n++];if(n==a)e[i]=r;else{var o=i in e;(!o||o&&"object"!=typeof e[i]||o&&null===e[i])&&(e[i]={}),e=e[i]}}},t.getPath=function(e,t,r){for(var n=0,a=t.length,i=!0;i&&n<a&&"object"==typeof e&&null!==e;){var o=t[n++];(i=o in e)&&(e=e[o])}return i?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,n=t.length;r<n;){var a=t[r++];if(r==n)delete e[a];else{if(!(a in e)||"object"!=typeof e[a]||null===e[a])break;e=e[a]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,n=/%./g,a=0,i=[],o=0;t=n.exec(e);){(r=e.substring(o,n.lastIndex-2)).length>0&&i.push(r),o=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":a<arguments.length?i.push(arguments[1+a++]):i.push("<?>");break;case"%":i.push("%");break;default:i.push("<%"+s+"?>")}}return i.push(e.substring(o)),i.join("")},t.formatNumber=function(e,t,r,n){var a=e,i=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,s=void 0===n?".":n,c=a<0?"-":"",u=parseInt(a=Math.abs(+a||0).toFixed(i),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+s:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+s)+(i?o+Math.abs(a-u).toFixed(i).slice(2):"")},t.formatSize=function(e){return e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var r=t.createBuffer(),n=0;n<e.length;++n){var a=parseInt(e[n],10);if(isNaN(a))return null;r.putByte(a)}return r.getBytes()},t.bytesFromIPv6=function(e){for(var r=0,n=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++r,!0}))).length+r),a=t.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var o=t.hexToBytes(e[i]);o.length<2&&a.putByte(0),a.putBytes(o)}else a.fillWithByte(0,n),n=0;return a.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},t.bytesToIPv6=function(e){if(16!==e.length)return null;for(var r=[],n=[],a=0,i=0;i<e.length;i+=2){for(var o=t.bytesToHex(e[i]+e[i+1]);"0"===o[0]&&"0"!==o;)o=o.substr(1);if("0"===o){var s=n[n.length-1],c=r.length;s&&c===s.end+1?(s.end=c,s.end-s.start>n[a].end-n[a].start&&(a=n.length-1)):n.push({start:c,end:c})}r.push(o)}if(n.length>0){var u=n[a];u.end-u.start>0&&(r.splice(u.start,u.end-u.start+1,""),0===u.start&&r.unshift(""),7===u.end&&r.push(""))}return r.join(":")},t.estimateCores=function(e,r){if("function"==typeof e&&(r=e,e={}),e=e||{},"cores"in t&&!e.update)return r(null,t.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,r(null,t.cores);if("undefined"==typeof Worker)return t.cores=1,r(null,t.cores);if("undefined"==typeof Blob)return t.cores=2,r(null,t.cores);var n=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(a,i,o){if(0===i){var s=Math.floor(a.reduce((function(e,t){return e+t}),0)/a.length);return t.cores=Math.max(1,s),URL.revokeObjectURL(n),r(null,t.cores)}!function(e,t){for(var r=[],a=[],i=0;i<e;++i){var o=new Worker(n);o.addEventListener("message",(function(n){if(a.push(n.data),a.length===e){for(var i=0;i<e;++i)r[i].terminate();t(null,a)}})),r.push(o)}for(i=0;i<e;++i)r[i].postMessage(i)}(o,(function(t,r){a.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var a=t[n],i=r[n]=[],o=0;o<e;++o)if(n!==o){var s=t[o];(a.st>s.st&&a.st<s.et||s.st>a.st&&s.st<a.et)&&i.push(o)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(o,r)),e(a,i-1,o)}))}([],5,16)}})),j.cipher=j.cipher||{},j.cipher.algorithms=j.cipher.algorithms||{},j.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=j.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new j.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},j.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=j.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new j.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},j.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),j.cipher.algorithms[e]=t},j.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in j.cipher.algorithms?j.cipher.algorithms[e]:null};var H=j.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};function G(e,t){j.cipher.registerAlgorithm(e,(function(){return new j.aes.Algorithm(e,t)}))}H.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=j.util.createBuffer(),this.output=e.output||j.util.createBuffer(),this.mode.start(t)},H.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},H.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))},E((function(e){j.cipher=j.cipher||{};var t=e.exports=j.cipher.modes=j.cipher.modes||{};function r(e,t){if("string"==typeof e&&(e=j.util.createBuffer(e)),j.util.isArray(e)&&e.length>4){var r=e;e=j.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!j.util.isArray(e)){var a=[],i=t/4;for(n=0;n<i;++n)a.push(e.getInt32());e=a}return e}function n(e){e[e.length-1]=e[e.length-1]+1&4294967295}function a(e){return[e/4294967296|0,4294967295&e]}t.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.ecb.prototype.start=function(e){},t.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},t.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},t.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},t.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2||(e.truncate(n),0))},t.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32()^this._outBlock[a],t.putInt32(this._inBlock[a]);else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32()^this._outBlock[a],this._partialOutput.putInt32(this._partialBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32(),t.putInt32(this._inBlock[a]^this._outBlock[a]);else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[a]^this._outBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]),this._inBlock[a]=this._outBlock[a];else{var i=(this.blockSize-n)%this.blockSize;for(i>0&&(i=this.blockSize-i),this._partialOutput.clear(),a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(i>0)e.read-=this.blockSize;else for(a=0;a<this._ints;++a)this._inBlock[a]=this._outBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb.prototype.decrypt=t.ofb.prototype.encrypt,t.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0},t.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ctr.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var o=(this.blockSize-a)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},t.ctr.prototype.decrypt=t.ctr.prototype.encrypt,t.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=j.util.createBuffer(),this._partialBytes=0,this._R=3774873600},t.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=j.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?j.util.createBuffer(e.additionalData):j.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=j.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=j.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},t.gcm.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-a)%this.blockSize;for(o>0&&(o=this.blockSize-o),this._partialOutput.clear(),i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o<=0||r){if(r){var s=a%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},t.gcm.prototype.decrypt=function(e,t,r){var a=e.length();if(a<this.blockSize&&!(r&&a>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);a<this.blockSize?this._cipherLength+=a%this.blockSize:this._cipherLength+=this.blockSize},t.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=j.util.createBuffer();var n=this._aDataLength.concat(a(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^i[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},t.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),a=0;a<128;++a)e[a/32|0]&1<<31-a%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n);return r},t.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},t.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,a=this._m[r][n];t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3]}return t},t.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},t.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,a=16*r,i=new Array(a),o=0;o<a;++o){var s=[0,0,0,0],c=(n-1-o%n)*t;s[o/n|0]=1<<t-1<<c,i[o]=this.generateSubHashTable(this.multiply(s,e),t)}return i},t.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,a=new Array(r);a[n]=e.slice(0);for(var i=n>>>1;i>0;)this.pow(a[2*i],a[i]=[]),i>>=1;for(i=2;i<n;){for(var o=1;o<i;++o){var s=a[i],c=a[o];a[i+o]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}i*=2}for(a[0]=[0,0,0,0],i=n+1;i<r;++i){var u=a[i^n];a[i]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return a}})),j.aes=j.aes||{},j.aes.startEncrypting=function(e,t,r,n){var a=ne({key:e,output:r,decrypt:!1,mode:n});return a.start(t),a},j.aes.createEncryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!1,mode:t})},j.aes.startDecrypting=function(e,t,r,n){var a=ne({key:e,output:r,decrypt:!0,mode:n});return a.start(t),a},j.aes.createDecryptionCipher=function(e,t){return ne({key:e,output:null,decrypt:!0,mode:t})},j.aes.Algorithm=function(e,t){Z||ee();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return re(r._w,e,t,!1)},decrypt:function(e,t){return re(r._w,e,t,!0)}}}),r._init=!1},j.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(j.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=j.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}}else r=j.util.createBuffer(r);if(!j.util.isArray(r)){t=r,r=[];var a=t.length();if(16===a||24===a||32===a)for(a>>>=2,n=0;n<a;++n)r.push(t.getInt32())}if(!j.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var i=this.mode.name,o=-1!==["CFB","OFB","CTR","GCM"].indexOf(i);this._w=te(r,e.decrypt&&!o),this._init=!0}},j.aes._expandKey=function(e,t){return Z||ee(),te(e,t)},j.aes._updateBlock=re,G("AES-ECB",j.cipher.modes.ecb),G("AES-CBC",j.cipher.modes.cbc),G("AES-CFB",j.cipher.modes.cfb),G("AES-OFB",j.cipher.modes.ofb),G("AES-CTR",j.cipher.modes.ctr),G("AES-GCM",j.cipher.modes.gcm);var Q,W,X,Y,$,Z=!1,J=4;function ee(){Z=!0,X=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;for(Q=new Array(256),W=new Array(256),Y=new Array(4),$=new Array(4),t=0;t<4;++t)Y[t]=new Array(256),$[t]=new Array(256);var r,n,a,i,o,s,c,u=0,l=0;for(t=0;t<256;++t){i=(i=l^l<<1^l<<2^l<<3^l<<4)>>8^255&i^99,Q[u]=i,W[i]=u,s=(o=e[i])<<24^i<<16^i<<8^i^o,c=((r=e[u])^(n=e[r])^(a=e[n]))<<24^(u^a)<<16^(u^n^a)<<8^u^r^a;for(var f=0;f<4;++f)Y[f][u]=s,$[f][i]=c,s=s<<24|s>>>8,c=c<<24|c>>>8;0===u?u=l=1:(u=r^e[e[e[r^a]]],l^=e[e[l]])}}function te(e,t){for(var r,n=e.slice(0),a=1,i=n.length,o=J*(i+6+1),s=i;s<o;++s)r=n[s-1],s%i==0?(r=Q[r>>>16&255]<<24^Q[r>>>8&255]<<16^Q[255&r]<<8^Q[r>>>24]^X[a]<<24,a++):i>6&&s%i==4&&(r=Q[r>>>24]<<24^Q[r>>>16&255]<<16^Q[r>>>8&255]<<8^Q[255&r]),n[s]=n[s-i]^r;if(t){for(var c,u=$[0],l=$[1],f=$[2],d=$[3],p=n.slice(0),h=(s=0,(o=n.length)-J);s<o;s+=J,h-=J)if(0===s||s===o-J)p[s]=n[h],p[s+1]=n[h+3],p[s+2]=n[h+2],p[s+3]=n[h+1];else for(var g=0;g<J;++g)c=n[h+g],p[s+(3&-g)]=u[Q[c>>>24]]^l[Q[c>>>16&255]]^f[Q[c>>>8&255]]^d[Q[255&c]];n=p}return n}function re(e,t,r,n){var a,i,o,s,c,u,l,f,d,p,h,g,m=e.length/4-1;n?(a=$[0],i=$[1],o=$[2],s=$[3],c=W):(a=Y[0],i=Y[1],o=Y[2],s=Y[3],c=Q),u=t[0]^e[0],l=t[n?3:1]^e[1],f=t[2]^e[2],d=t[n?1:3]^e[3];for(var y=3,v=1;v<m;++v)p=a[u>>>24]^i[l>>>16&255]^o[f>>>8&255]^s[255&d]^e[++y],h=a[l>>>24]^i[f>>>16&255]^o[d>>>8&255]^s[255&u]^e[++y],g=a[f>>>24]^i[d>>>16&255]^o[u>>>8&255]^s[255&l]^e[++y],d=a[d>>>24]^i[u>>>16&255]^o[l>>>8&255]^s[255&f]^e[++y],u=p,l=h,f=g;r[0]=c[u>>>24]<<24^c[l>>>16&255]<<16^c[f>>>8&255]<<8^c[255&d]^e[++y],r[n?3:1]=c[l>>>24]<<24^c[f>>>16&255]<<16^c[d>>>8&255]<<8^c[255&u]^e[++y],r[2]=c[f>>>24]<<24^c[d>>>16&255]<<16^c[u>>>8&255]<<8^c[255&l]^e[++y],r[n?1:3]=c[d>>>24]<<24^c[u>>>16&255]<<16^c[l>>>8&255]<<8^c[255&f]^e[++y]}function ne(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?j.cipher.createDecipher(r,e.key):j.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var a=null;r instanceof j.util.ByteBuffer&&(a=r,r={}),(r=r||{}).output=a,r.iv=e,n.call(t,r)},t}function ae(e,t){j.cipher.registerAlgorithm(e,(function(){return new j.des.Algorithm(e,t)}))}E((function(e){j.pki=j.pki||{};var t=e.exports=j.pki.oids=j.oids=j.oids||{};function r(e,r){t[e]=r,t[r]=e}function n(e,r){t[e]=r}r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.5","serialName"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),n("2.5.29.1","authorityKeyIdentifier"),n("2.5.29.2","keyAttributes"),n("2.5.29.3","certificatePolicies"),n("2.5.29.4","keyUsageRestriction"),n("2.5.29.5","policyMapping"),n("2.5.29.6","subtreesConstraint"),n("2.5.29.7","subjectAltName"),n("2.5.29.8","issuerAltName"),n("2.5.29.9","subjectDirectoryAttributes"),n("2.5.29.10","basicConstraints"),n("2.5.29.11","nameConstraints"),n("2.5.29.12","policyConstraints"),n("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),n("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),n("2.5.29.20","cRLNumber"),n("2.5.29.21","cRLReason"),n("2.5.29.22","expirationDate"),n("2.5.29.23","instructionCode"),n("2.5.29.24","invalidityDate"),n("2.5.29.25","cRLDistributionPoints"),n("2.5.29.26","issuingDistributionPoint"),n("2.5.29.27","deltaCRLIndicator"),n("2.5.29.28","issuingDistributionPoint"),n("2.5.29.29","certificateIssuer"),n("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),n("2.5.29.33","policyMappings"),n("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),n("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),n("2.5.29.46","freshestCRL"),n("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping")})),E((function(e){var t=e.exports=j.asn1=j.asn1||{};function r(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,r,n,a,i){if(j.util.isArray(a)){for(var o=[],s=0;s<a.length;++s)void 0!==a[s]&&o.push(a[s]);a=o}var c={tagClass:e,type:r,constructed:n,composed:n||j.util.isArray(a),value:a};return i&&"bitStringContents"in i&&(c.bitStringContents=i.bitStringContents,c.original=t.copy(c)),c},t.copy=function(e,r){var n;if(j.util.isArray(e)){n=[];for(var a=0;a<e.length;++a)n.push(t.copy(e[a],r));return n}return"string"==typeof e?e:(n={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:t.copy(e.value,r)},r&&!r.excludeBitStringContents&&(n.bitStringContents=e.bitStringContents),n)},t.equals=function(e,r,n){if(j.util.isArray(e)){if(!j.util.isArray(r))return!1;if(e.length!==r.length)return!1;for(var a=0;a<e.length;++a)if(!t.equals(e[a],r[a]))return!1;return!0}if(typeof e!=typeof r)return!1;if("string"==typeof e)return e===r;var i=e.tagClass===r.tagClass&&e.type===r.type&&e.constructed===r.constructed&&e.composed===r.composed&&t.equals(e.value,r.value);return n&&n.includeBitStringContents&&(i=i&&e.bitStringContents===r.bitStringContents),i},t.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};var n=function(e,t){var n=e.getByte();if(t--,128!==n){var a;if(128&n){var i=127&n;r(e,t,i),a=e.getInt(i<<3)}else a=n;if(a<0)throw new Error("Negative length: "+a);return a}};t.fromDer=function(e,a){return void 0===a&&(a={strict:!0,decodeBitStrings:!0}),"boolean"==typeof a&&(a={strict:a,decodeBitStrings:!0}),"strict"in a||(a.strict=!0),"decodeBitStrings"in a||(a.decodeBitStrings=!0),"string"==typeof e&&(e=j.util.createBuffer(e)),function e(a,i,o,s){var c;r(a,i,2);var u=a.getByte();i--;var l=192&u,f=31&u;c=a.length();var d,p,h=n(a,i);if(i-=c-a.length(),void 0!==h&&h>i){if(s.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=a.length(),g.remaining=i,g.requested=h,g}h=i}var m=32==(32&u);if(m)if(d=[],void 0===h)for(;;){if(r(a,i,2),a.bytes(2)===String.fromCharCode(0,0)){a.getBytes(2),i-=2;break}c=a.length(),d.push(e(a,i,o+1,s)),i-=c-a.length()}else for(;h>0;)c=a.length(),d.push(e(a,h,o+1,s)),i-=c-a.length(),h-=c-a.length();if(void 0===d&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&(p=a.bytes(h)),void 0===d&&s.decodeBitStrings&&l===t.Class.UNIVERSAL&&f===t.Type.BITSTRING&&h>1){var y=a.read,v=i,b=0;if(f===t.Type.BITSTRING&&(r(a,i,1),b=a.getByte(),i--),0===b)try{c=a.length();var C=e(a,i,o+1,{verbose:s.verbose,strict:!0,decodeBitStrings:!0}),E=c-a.length();i-=E,f==t.Type.BITSTRING&&E++;var w=C.tagClass;E!==h||w!==t.Class.UNIVERSAL&&w!==t.Class.CONTEXT_SPECIFIC||(d=[C])}catch(e){}void 0===d&&(a.read=y,i=v)}if(void 0===d){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=i}if(f===t.Type.BMPSTRING)for(d="";h>0;h-=2)r(a,i,2),d+=String.fromCharCode(a.getInt16()),i-=2;else d=a.getBytes(h)}var k=void 0===p?null:{bitStringContents:p};return t.create(l,f,m,d,k)}(e,e.length(),0,a)},t.toDer=function(e){var r=j.util.createBuffer(),n=e.tagClass|e.type,a=j.util.createBuffer(),i=!1;if("bitStringContents"in e&&(i=!0,e.original&&(i=t.equals(e,e.original))),i)a.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:a.putByte(0);for(var o=0;o<e.value.length;++o)void 0!==e.value[o]&&a.putBuffer(t.toDer(e.value[o]))}else if(e.type===t.Type.BMPSTRING)for(o=0;o<e.value.length;++o)a.putInt16(e.value.charCodeAt(o));else e.type===t.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?a.putBytes(e.value.substr(1)):a.putBytes(e.value);if(r.putByte(n),a.length()<=127)r.putByte(127&a.length());else{var s=a.length(),c="";do{c+=String.fromCharCode(255&s),s>>>=8}while(s>0);for(r.putByte(128|c.length),o=c.length-1;o>=0;--o)r.putByte(c.charCodeAt(o))}return r.putBuffer(a),r},t.oidToDer=function(e){var t,r,n,a,i=e.split("."),o=j.util.createBuffer();o.putByte(40*parseInt(i[0],10)+parseInt(i[1],10));for(var s=2;s<i.length;++s){t=!0,r=[],n=parseInt(i[s],10);do{a=127&n,n>>>=7,t||(a|=128),r.push(a),t=!1}while(n>0);for(var c=r.length-1;c>=0;--c)o.putByte(r[c])}return o},t.derToOid=function(e){var t;"string"==typeof e&&(e=j.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,a=parseInt(e.substr(4,2),10),i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(s=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,a),t.setUTCHours(i,o,s,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,a=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var f=e.length-5,d=e.charAt(f);return"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0),"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,a),t.setUTCHours(i,o,s,c),t.setTime(+t+u)):(t.setFullYear(r,n,a),t.setHours(i,o,s,c)),t},t.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+"Z"},t.integerToDer=function(e){var t=j.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},t.derToInteger=function(e){"string"==typeof e&&(e=j.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},t.validate=function(e,r,n,a){var i=!1;if(e.tagClass!==r.tagClass&&void 0!==r.tagClass||e.type!==r.type&&void 0!==r.type)a&&(e.tagClass!==r.tagClass&&a.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+e.tagClass+'"'),e.type!==r.type&&a.push("["+r.name+'] Expected type "'+r.type+'", got "'+e.type+'"'));else if(e.constructed===r.constructed||void 0===r.constructed){if(i=!0,r.value&&j.util.isArray(r.value))for(var o=0,s=0;i&&s<r.value.length;++s)i=r.value[s].optional||!1,e.value[o]&&((i=t.validate(e.value[o],r.value[s],n,a))?++o:r.value[s].optional&&(i=!0)),!i&&a&&a.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');if(i&&n&&(r.capture&&(n[r.capture]=e.value),r.captureAsn1&&(n[r.captureAsn1]=e),r.captureBitStringContents&&"bitStringContents"in e&&(n[r.captureBitStringContents]=e.bitStringContents),r.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)n[r.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");n[r.captureBitStringValue]=e.bitStringContents.slice(1)}}else a&&a.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+e.constructed+'"');return i};var a=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(e,r,n){var i="";n=n||2,(r=r||0)>0&&(i+="\n");for(var o="",s=0;s<r*n;++s)o+=" ";switch(i+=o+"Tag: ",e.tagClass){case t.Class.UNIVERSAL:i+="Universal:";break;case t.Class.APPLICATION:i+="Application:";break;case t.Class.CONTEXT_SPECIFIC:i+="Context-Specific:";break;case t.Class.PRIVATE:i+="Private:"}if(e.tagClass===t.Class.UNIVERSAL)switch(i+=e.type,e.type){case t.Type.NONE:i+=" (None)";break;case t.Type.BOOLEAN:i+=" (Boolean)";break;case t.Type.INTEGER:i+=" (Integer)";break;case t.Type.BITSTRING:i+=" (Bit string)";break;case t.Type.OCTETSTRING:i+=" (Octet string)";break;case t.Type.NULL:i+=" (Null)";break;case t.Type.OID:i+=" (Object Identifier)";break;case t.Type.ODESC:i+=" (Object Descriptor)";break;case t.Type.EXTERNAL:i+=" (External or Instance of)";break;case t.Type.REAL:i+=" (Real)";break;case t.Type.ENUMERATED:i+=" (Enumerated)";break;case t.Type.EMBEDDED:i+=" (Embedded PDV)";break;case t.Type.UTF8:i+=" (UTF8)";break;case t.Type.ROID:i+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:i+=" (Sequence)";break;case t.Type.SET:i+=" (Set)";break;case t.Type.PRINTABLESTRING:i+=" (Printable String)";break;case t.Type.IA5String:i+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:i+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:i+=" (Generalized time)";break;case t.Type.BMPSTRING:i+=" (BMP String)"}else i+=e.type;if(i+="\n",i+=o+"Constructed: "+e.constructed+"\n",e.composed){var c=0,u="";for(s=0;s<e.value.length;++s)void 0!==e.value[s]&&(c+=1,u+=t.prettyPrint(e.value[s],r+1,n),s+1<e.value.length&&(u+=","));i+=o+"Sub values: "+c+u}else{if(i+=o+"Value: ",e.type===t.Type.OID){var l=t.derToOid(e.value);i+=l,j.pki&&j.pki.oids&&l in j.pki.oids&&(i+=" ("+j.pki.oids[l]+") ")}if(e.type===t.Type.INTEGER)try{i+=t.derToInteger(e.value)}catch(t){i+="0x"+j.util.bytesToHex(e.value)}else if(e.type===t.Type.BITSTRING){if(e.value.length>1?i+="0x"+j.util.bytesToHex(e.value.slice(1)):i+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?i+=" (1 unused bit shown)":f>1&&(i+=" ("+f+" unused bits shown)")}}else e.type===t.Type.OCTETSTRING?(a.test(e.value)||(i+="("+e.value+") "),i+="0x"+j.util.bytesToHex(e.value)):e.type===t.Type.UTF8?i+=j.util.decodeUtf8(e.value):e.type===t.Type.PRINTABLESTRING||e.type===t.Type.IA5String?i+=e.value:a.test(e.value)?i+="0x"+j.util.bytesToHex(e.value):0===e.value.length?i+="[null]":i+=e.value}return i}})),j.md=j.md||{},j.md.algorithms=j.md.algorithms||{},E((function(e){(e.exports=j.hmac=j.hmac||{}).create=function(){var e=null,t=null,r=null,n=null,a={start:function(a,i){if(null!==a)if("string"==typeof a){if(!((a=a.toLowerCase())in j.md.algorithms))throw new Error('Unknown hash algorithm "'+a+'"');t=j.md.algorithms[a].create()}else t=a;if(null===i)i=e;else{if("string"==typeof i)i=j.util.createBuffer(i);else if(j.util.isArray(i)){var o=i;i=j.util.createBuffer();for(var s=0;s<o.length;++s)i.putByte(o[s])}var c=i.length();for(c>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),r=j.util.createBuffer(),n=j.util.createBuffer(),c=i.length(),s=0;s<c;++s)o=i.at(s),r.putByte(54^o),n.putByte(92^o);if(c<t.blockLength)for(o=t.blockLength-c,s=0;s<o;++s)r.putByte(54),n.putByte(92);e=i,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(n),t.update(e),t.digest()}};return a.digest=a.getMac,a}})),E((function(e){var t=e.exports=j.md5=j.md5||{};j.md.md5=j.md.algorithms.md5=t,t.create=function(){o||function(){r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),n=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],a=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],i=new Array(64);for(var e=0;e<64;++e)i[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));o=!0}();var e=null,t=j.util.createBuffer(),c=new Array(16),u={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){u.messageLength=0,u.fullMessageLength=u.messageLength64=[];for(var r=u.messageLengthSize/4,n=0;n<r;++n)u.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},u}};return u.start(),u.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var a=r.length;u.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var i=u.fullMessageLength.length-1;i>=0;--i)u.fullMessageLength[i]+=a[1],a[1]=a[0]+(u.fullMessageLength[i]/4294967296>>>0),u.fullMessageLength[i]=u.fullMessageLength[i]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(r),s(e,c,t),(t.read>2048||0===t.length())&&t.compact(),u},u.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var a=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize&u.blockLength-1;n.putBytes(r.substr(0,u.blockLength-a));for(var i,o=0,l=u.fullMessageLength.length-1;l>=0;--l)o=(i=8*u.fullMessageLength[l]+o)/4294967296>>>0,n.putInt32Le(i>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};s(f,c,n);var d=j.util.createBuffer();return d.putInt32Le(f.h0),d.putInt32Le(f.h1),d.putInt32Le(f.h2),d.putInt32Le(f.h3),d},u};var r=null,n=null,a=null,i=null,o=!1;function s(e,t,r){for(var o,s,c,u,l,f,d,p=r.length();p>=64;){for(s=e.h0,c=e.h1,u=e.h2,l=e.h3,d=0;d<16;++d)t[d]=r.getInt32Le(),o=s+(l^c&(u^l))+i[d]+t[d],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<32;++d)o=s+(u^l&(c^u))+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<48;++d)o=s+(c^u^l)+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;for(;d<64;++d)o=s+(u^(c|~l))+i[d]+t[n[d]],s=l,l=u,u=c,c+=o<<(f=a[d])|o>>>32-f;e.h0=e.h0+s|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,p-=64}}})),E((function(e){var t=e.exports=j.pem=j.pem||{};function r(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},a=0;a<e.values.length;++a)r.push(e.values[a].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var i=0,o=-1;for(a=0;a<t.length;++a,++i)if(i>65&&-1!==o){var s=t[o];","===s?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+s+t.substr(o+1),i=a-o-1,o=-1,++a}else" "!==t[a]&&"\t"!==t[a]&&","!==t[a]||(o=a);return t}function n(e){return e.replace(/^\s+/,"")}t.encode=function(e,t){t=t||{};var n,a="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(a+=r(n={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(a+=r(n={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(n={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&n.values.push(e.dekInfo.parameters),a+=r(n)),e.headers)for(var i=0;i<e.headers.length;++i)a+=r(e.headers[i]);return e.procType&&(a+="\r\n"),(a+=j.util.encode64(e.body,t.maxline||64)+"\r\n")+"-----END "+e.type+"-----\r\n"},t.decode=function(e){for(var t,r=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;t=a.exec(e);){var s={type:t[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:j.util.decode64(t[3])};if(r.push(s),t[2]){for(var c=t[2].split(o),u=0;t&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var d=c[f];if(!/\s/.test(d[0]))break;l+=d,u=f}if(t=l.match(i)){for(var p={name:t[1],values:[]},h=t[2].split(","),g=0;g<h.length;++g)p.values.push(n(h[g]));if(s.procType)if(s.contentDomain||"Content-Domain"!==p.name)if(s.dekInfo||"DEK-Info"!==p.name)s.headers.push(p);else{if(0===p.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:h[0],parameters:h[1]||null}}else s.contentDomain=h[0]||"";else{if("Proc-Type"!==p.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==p.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:h[0],type:h[1]}}}++u}if("ENCRYPTED"===s.procType&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}})),j.des=j.des||{},j.des.startEncrypting=function(e,t,r,n){var a=he({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return a.start(t),a},j.des.createEncryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!1,mode:t})},j.des.startDecrypting=function(e,t,r,n){var a=he({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return a.start(t),a},j.des.createDecryptionCipher=function(e,t){return he({key:e,output:null,decrypt:!0,mode:t})},j.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return pe(r._keys,e,t,!1)},decrypt:function(e,t){return pe(r._keys,e,t,!0)}}}),r._init=!1},j.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=j.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],a=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],h=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],m=e.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,C=0;C<m;C++){var E=e.getInt32(),w=e.getInt32();E^=(t=252645135&(E>>>4^w))<<4,E^=t=65535&((w^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(w^=t<<-16)))<<2,E^=t=65535&((w^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(w^=t<<-16)))<<1,E^=t=16711935&((w^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(w^=t<<8)))<<1)<<8|(w^=t)>>>20&240,E=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=t;for(var k=0;k<v.length;++k){v[k]?(E=E<<2|E>>>26,w=w<<2|w>>>26):(E=E<<1|E>>>27,w=w<<1|w>>>27);var S=r[(E&=-15)>>>28]|n[E>>>24&15]|a[E>>>20&15]|i[E>>>16&15]|o[E>>>12&15]|s[E>>>8&15]|c[E>>>4&15],B=u[(w&=-15)>>>28]|l[w>>>24&15]|f[w>>>20&15]|d[w>>>16&15]|p[w>>>12&15]|h[w>>>8&15]|g[w>>>4&15];t=65535&(B>>>16^S),y[b++]=S^t,y[b++]=B^t<<16}}return y}(t),this._init=!0}},ae("DES-ECB",j.cipher.modes.ecb),ae("DES-CBC",j.cipher.modes.cbc),ae("DES-CFB",j.cipher.modes.cfb),ae("DES-OFB",j.cipher.modes.ofb),ae("DES-CTR",j.cipher.modes.ctr),ae("3DES-ECB",j.cipher.modes.ecb),ae("3DES-CBC",j.cipher.modes.cbc),ae("3DES-CFB",j.cipher.modes.cfb),ae("3DES-OFB",j.cipher.modes.ofb),ae("3DES-CTR",j.cipher.modes.ctr);var ie=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],oe=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],se=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],ce=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],ue=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],le=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],fe=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],de=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function pe(e,t,r,n){var a,i,o=32===e.length?3:9;a=3===o?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s=t[0],c=t[1];s^=(i=252645135&(s>>>4^c))<<4,s^=(i=65535&(s>>>16^(c^=i)))<<16,s^=i=858993459&((c^=i)>>>2^s),s^=i=16711935&((c^=i<<2)>>>8^s),s=(s^=(i=1431655765&(s>>>1^(c^=i<<8)))<<1)<<1|s>>>31,c=(c^=i)<<1|c>>>31;for(var u=0;u<o;u+=3){for(var l=a[u+1],f=a[u+2],d=a[u];d!=l;d+=f){var p=c^e[d],h=(c>>>4|c<<28)^e[d+1];i=s,s=c,c=i^(oe[p>>>24&63]|ce[p>>>16&63]|le[p>>>8&63]|de[63&p]|ie[h>>>24&63]|se[h>>>16&63]|ue[h>>>8&63]|fe[63&h])}i=s,s=c,c=i}c=c>>>1|c<<31,c^=i=1431655765&((s=s>>>1|s<<31)>>>1^c),c^=(i=16711935&(c>>>8^(s^=i<<1)))<<8,c^=(i=858993459&(c>>>2^(s^=i)))<<2,c^=i=65535&((s^=i)>>>16^c),c^=i=252645135&((s^=i<<16)>>>4^c),s^=i<<4,r[0]=s,r[1]=c}function he(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?j.cipher.createDecipher(r,e.key):j.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var a=null;r instanceof j.util.ByteBuffer&&(a=r,r={}),(r=r||{}).output=a,r.iv=e,n.call(t,r)},t}var ge,me=j.pkcs5=j.pkcs5||{};j.util.isNodejs&&!j.options.usePureJavaScript&&(ge=t),j.pbkdf2=me.pbkdf2=function(e,t,r,n,a,i){if("function"==typeof a&&(i=a,a=null),j.util.isNodejs&&!j.options.usePureJavaScript&&ge.pbkdf2&&(null===a||"object"!=typeof a)&&(ge.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),i?4===ge.pbkdf2Sync.length?ge.pbkdf2(e,t,r,n,(function(e,t){if(e)return i(e);i(null,t.toString("binary"))})):ge.pbkdf2(e,t,r,n,a,(function(e,t){if(e)return i(e);i(null,t.toString("binary"))})):4===ge.pbkdf2Sync.length?ge.pbkdf2Sync(e,t,r,n).toString("binary"):ge.pbkdf2Sync(e,t,r,n,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in j.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=j.md[a].create()}var o=a.digestLength;if(n>4294967295*o){var s=new Error("Derived key is too long.");if(i)return i(s);throw s}var c=Math.ceil(n/o),u=n-(c-1)*o,l=j.hmac.create();l.start(a,e);var f,d,p,h="";if(!i){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(j.util.int32ToBytes(g)),f=p=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(p),d=l.digest().getBytes(),f=j.util.xorBytes(f,d,o),p=d;h+=g<c?f:f.substr(0,u)}return h}function y(){if(g>c)return i(null,h);l.start(null,null),l.update(t),l.update(j.util.int32ToBytes(g)),f=p=l.digest().getBytes(),m=2,v()}function v(){if(m<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),f=j.util.xorBytes(f,d,o),p=d,++m,j.util.setImmediate(v);h+=g<c?f:f.substr(0,u),++g,y()}g=1,y()},E((function(e){var t=e.exports=j.sha256=j.sha256||{};j.md.sha256=j.md.algorithms.sha256=t,t.create=function(){n||(r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=!0);var e=null,t=j.util.createBuffer(),o=new Array(64),s={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){s.messageLength=0,s.fullMessageLength=s.messageLength64=[];for(var r=s.messageLengthSize/4,n=0;n<r;++n)s.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},s}};return s.start(),s.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var a=r.length;s.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var c=s.fullMessageLength.length-1;c>=0;--c)s.fullMessageLength[c]+=a[1],a[1]=a[0]+(s.fullMessageLength[c]/4294967296>>>0),s.fullMessageLength[c]=s.fullMessageLength[c]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(r),i(e,o,t),(t.read>2048||0===t.length())&&t.compact(),s},s.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var a,c=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize&s.blockLength-1;n.putBytes(r.substr(0,s.blockLength-c));for(var u=8*s.fullMessageLength[0],l=0;l<s.fullMessageLength.length-1;++l)u+=(a=8*s.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=a>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};i(f,o,n);var d=j.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d.putInt32(f.h5),d.putInt32(f.h6),d.putInt32(f.h7),d},s};var r=null,n=!1,a=null;function i(e,t,r){for(var n,i,o,s,c,u,l,f,d,p,h,g,m,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,f=e.h2,d=e.h3,p=e.h4,h=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|f&(u^l),n=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(g^p&(h^g))+a[c]+t[c],m=g,g=h,h=p,p=d+n>>>0,d=f,f=l,l=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+d|0,e.h4=e.h4+p|0,e.h5=e.h5+h|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}}})),E((function(e){var r=null;!j.util.isNodejs||j.options.usePureJavaScript||process.versions["node-webkit"]||(r=t),(e.exports=j.prng=j.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},n=e.md,a=new Array(32),i=0;i<32;++i)a[i]=n.create();function o(){if(t.pools[0].messageLength>=32)return s();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),s()}function s(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var a=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(a),t.generated=0}function c(e){var t=null,r=j.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var a=j.util.createBuffer();if(t)for(;a.length()<e;){var i=Math.max(1,Math.min(e-a.length(),65536)/4),o=new Uint32Array(Math.floor(i));try{t(o);for(var s=0;s<o.length;++s)a.putInt32(o[s])}catch(e){if(!("undefined"!=typeof QuotaExceededError&&e instanceof QuotaExceededError))throw e}}if(a.length()<e)for(var c,u,l,f=Math.floor(65536*Math.random());a.length()<e;)for(u=16807*(65535&f),u+=(32767&(c=16807*(f>>16)))<<16,f=4294967295&(u=(2147483647&(u+=c>>15))+(u>>31)),s=0;s<3;++s)l=f>>>(s<<3),l^=Math.floor(256*Math.random()),a.putByte(String.fromCharCode(255&l));return a.getBytes(e)}return t.pools=a,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,a=t.plugin.increment,i=t.plugin.formatKey,o=t.plugin.formatSeed,c=j.util.createBuffer();t.key=null,function u(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return j.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return s(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),s(),e()}))}(u)}));var f=n(t.key,t.seed);t.generated+=f.length,c.putBytes(f),t.key=i(n(t.key,a(t.seed))),t.seed=o(n(t.key,t.seed)),j.util.setImmediate(u)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,a=t.plugin.formatKey,i=t.plugin.formatSeed;t.key=null;for(var s=j.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&o();var c=r(t.key,t.seed);t.generated+=c.length,s.putBytes(c),t.key=a(r(t.key,n(t.seed))),t.seed=i(r(t.key,t.seed))}return s.getBytes(e)},r?(t.seedFile=function(e,t){r.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,c(e))}catch(e){t(e)}},t.seedFileSync=c),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",a=0;a<r;a+=8)n+=String.fromCharCode(e>>a&255);t.collect(n)},t.registerWorker=function(e){e===self?t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})}:e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))},t}})),E((function(e){j.random&&j.random.getBytes?e.exports=j.random:function(t){var r={},n=new Array(4),a=j.util.createBuffer();function i(){var e=j.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=j.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),j.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=j.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return j.aes._updateBlock(e,t,n,!1),a.putInt32(n[0]),a.putInt32(n[1]),a.putInt32(n[2]),a.putInt32(n[3]),a.getBytes()},r.increment=function(e){return++e[3],e},r.md=j.md.sha256;var o=i(),s=null,c=j.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(s=function(e){return u.getRandomValues(e)}),!j.util.isNodejs&&!s){if(o.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var f in navigator)try{"string"==typeof navigator[f]&&(l+=navigator[f])}catch(e){}o.collect(l),l=null}t&&(t().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),t().keypress((function(e){o.collectInt(e.charCode,8)})))}if(j.random)for(var f in o)j.random[f]=o[f];else j.random=o;j.random.createInstance=i,e.exports=j.random}("undefined"!=typeof jQuery?jQuery:null)}));var ye=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ve=[1,2,3,5],be=function(e,t){return e<<t&65535|(65535&e)>>16-t},Ce=function(e,t){return(65535&e)>>t|e<<16-t&65535};j.rc2=j.rc2||{},j.rc2.expandKey=function(e,t){"string"==typeof e&&(e=j.util.createBuffer(e)),t=t||128;var r,n=e,a=e.length(),i=t,o=Math.ceil(i/8),s=255>>(7&i);for(r=a;r<128;r++)n.putByte(ye[n.at(r-1)+n.at(r-a)&255]);for(n.setAt(128-o,ye[n.at(128-o)&s]),r=127-o;r>=0;r--)n.setAt(r,ye[n.at(r+1)^n.at(r+o)]);return n};var Ee,we=function(e,t,r){var n,a,i,o,s=!1,c=null,u=null,l=null,f=[];for(e=j.rc2.expandKey(e,t),i=0;i<64;i++)f.push(e.getInt16Le());r?(n=function(e){for(i=0;i<4;i++)e[i]+=f[o]+(e[(i+3)%4]&e[(i+2)%4])+(~e[(i+3)%4]&e[(i+1)%4]),e[i]=be(e[i],ve[i]),o++},a=function(e){for(i=0;i<4;i++)e[i]+=f[63&e[(i+3)%4]]}):(n=function(e){for(i=3;i>=0;i--)e[i]=Ce(e[i],ve[i]),e[i]-=f[o]+(e[(i+3)%4]&e[(i+2)%4])+(~e[(i+3)%4]&e[(i+1)%4]),o--},a=function(e){for(i=3;i>=0;i--)e[i]-=f[63&e[(i+3)%4]]});var d=function(e){var t=[];for(i=0;i<4;i++){var n=c.getInt16Le();null!==l&&(r?n^=l.getInt16Le():l.putInt16Le(n)),t.push(65535&n)}o=r?0:63;for(var a=0;a<e.length;a++)for(var s=0;s<e[a][0];s++)e[a][1](t);for(i=0;i<4;i++)null!==l&&(r?l.putInt16Le(t[i]):t[i]^=l.getInt16Le()),u.putInt16Le(t[i])},p=null;return p={start:function(e,t){e&&"string"==typeof e&&(e=j.util.createBuffer(e)),s=!1,c=j.util.createBuffer(),u=t||new j.util.createBuffer,l=e,p.output=u},update:function(e){for(s||c.putBuffer(e);c.length()>=8;)d([[5,n],[1,a],[6,n],[1,a],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,c,!r);else{var n=8===c.length()?8:8-c.length();c.fillWithByte(n,n)}if(t&&(s=!0,p.update()),!r&&(t=0===c.length()))if(e)t=e(8,u,!r);else{var a=u.length(),i=u.at(a-1);i>a?t=!1:u.truncate(i)}return t}}};function ke(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function Se(){return new ke(null)}function Be(e,t,r,n,a,i){for(var o=16383&t,s=t>>14;--i>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=s*c+u*o;a=((c=o*c+((16383&l)<<14)+r.data[n]+a)>>28)+(l>>14)+s*u,r.data[n++]=268435455&c}return a}j.rc2.startEncrypting=function(e,t,r){var n=j.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},j.rc2.createEncryptionCipher=function(e,t){return we(e,t,!0)},j.rc2.startDecrypting=function(e,t,r){var n=j.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},j.rc2.createDecryptionCipher=function(e,t){return we(e,t,!1)},j.jsbn=j.jsbn||{},j.jsbn.BigInteger=ke,"undefined"==typeof navigator?(ke.prototype.am=Be,Ee=28):"Microsoft Internet Explorer"==navigator.appName?(ke.prototype.am=function(e,t,r,n,a,i){for(var o=32767&t,s=t>>15;--i>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=s*c+u*o;a=((c=o*c+((32767&l)<<15)+r.data[n]+(1073741823&a))>>>30)+(l>>>15)+s*u+(a>>>30),r.data[n++]=1073741823&c}return a},Ee=30):"Netscape"!=navigator.appName?(ke.prototype.am=function(e,t,r,n,a,i){for(;--i>=0;){var o=t*this.data[e++]+r.data[n]+a;a=Math.floor(o/67108864),r.data[n++]=67108863&o}return a},Ee=26):(ke.prototype.am=Be,Ee=28),ke.prototype.DB=Ee,ke.prototype.DM=(1<<Ee)-1,ke.prototype.DV=1<<Ee,ke.prototype.FV=Math.pow(2,52),ke.prototype.F1=52-Ee,ke.prototype.F2=2*Ee-52;var Ae,Te,Ie="0123456789abcdefghijklmnopqrstuvwxyz",_e=new Array;for(Ae="0".charCodeAt(0),Te=0;Te<=9;++Te)_e[Ae++]=Te;for(Ae="a".charCodeAt(0),Te=10;Te<36;++Te)_e[Ae++]=Te;for(Ae="A".charCodeAt(0),Te=10;Te<36;++Te)_e[Ae++]=Te;function xe(e){return Ie.charAt(e)}function Pe(e,t){var r=_e[e.charCodeAt(t)];return null==r?-1:r}function Re(e){var t=Se();return t.fromInt(e),t}function Ne(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Le(e){this.m=e}function Oe(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function De(e,t){return e&t}function Ue(e,t){return e|t}function Me(e,t){return e^t}function Ve(e,t){return e&~t}function Fe(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function je(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function Ke(){}function ze(e){return e}function qe(e){this.r2=Se(),this.q3=Se(),ke.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Le.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Le.prototype.revert=function(e){return e},Le.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},Le.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Le.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},Oe.prototype.convert=function(e){var t=Se();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ke.ZERO)>0&&this.m.subTo(t,t),t},Oe.prototype.revert=function(e){var t=Se();return e.copyTo(t),this.reduce(t),t},Oe.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Oe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},Oe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},ke.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},ke.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},ke.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,a=!1,i=0;--n>=0;){var o=8==r?255&e[n]:Pe(e,n);o<0?"-"==e.charAt(n)&&(a=!0):(a=!1,0==i?this.data[this.t++]=o:i+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-i)-1)<<i,this.data[this.t++]=o>>this.DB-i):this.data[this.t-1]|=o<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,i>0&&(this.data[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),a&&ke.ZERO.subTo(this,this)},ke.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},ke.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},ke.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},ke.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,a=this.DB-n,i=(1<<a)-1,o=Math.floor(e/this.DB),s=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+o+1]=this.data[r]>>a|s,s=(this.data[r]&i)<<n;for(r=o-1;r>=0;--r)t.data[r]=0;t.data[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()},ke.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,a=this.DB-n,i=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)t.data[o-r-1]|=(this.data[o]&i)<<a,t.data[o-r]=this.data[o]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&i)<<a),t.t=this.t-r,t.clamp()}},ke.prototype.subTo=function(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},ke.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),a=r.t;for(t.t=a+n.t;--a>=0;)t.data[a]=0;for(a=0;a<n.t;++a)t.data[a+r.t]=r.am(0,n.data[a],t,a,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ke.ZERO.subTo(t,t)},ke.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},ke.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var a=this.abs();if(a.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Se());var i=Se(),o=this.s,s=e.s,c=this.DB-Ne(n.data[n.t-1]);c>0?(n.lShiftTo(c,i),a.lShiftTo(c,r)):(n.copyTo(i),a.copyTo(r));var u=i.t,l=i.data[u-1];if(0!=l){var f=l*(1<<this.F1)+(u>1?i.data[u-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,h=1<<this.F2,g=r.t,m=g-u,y=null==t?Se():t;for(i.dlShiftTo(m,y),r.compareTo(y)>=0&&(r.data[r.t++]=1,r.subTo(y,r)),ke.ONE.dlShiftTo(u,y),y.subTo(i,i);i.t<u;)i.data[i.t++]=0;for(;--m>=0;){var v=r.data[--g]==l?this.DM:Math.floor(r.data[g]*d+(r.data[g-1]+h)*p);if((r.data[g]+=i.am(0,v,r,m,0,u))<v)for(i.dlShiftTo(m,y),r.subTo(y,r);r.data[g]<--v;)r.subTo(y,r)}null!=t&&(r.drShiftTo(u,t),o!=s&&ke.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&ke.ZERO.subTo(r,r)}}},ke.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},ke.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},ke.prototype.exp=function(e,t){if(e>4294967295||e<1)return ke.ONE;var r=Se(),n=Se(),a=t.convert(this),i=Ne(e)-1;for(a.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,a,r);else{var o=r;r=n,n=o}return t.revert(r)},ke.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,a=!1,i="",o=this.t,s=this.DB-o*this.DB%t;if(o-- >0)for(s<this.DB&&(r=this.data[o]>>s)>0&&(a=!0,i=xe(r));o>=0;)s<t?(r=(this.data[o]&(1<<s)-1)<<t-s,r|=this.data[--o]>>(s+=this.DB-t)):(r=this.data[o]>>(s-=t)&n,s<=0&&(s+=this.DB,--o)),r>0&&(a=!0),a&&(i+=xe(r));return a?i:"0"},ke.prototype.negate=function(){var e=Se();return ke.ZERO.subTo(this,e),e},ke.prototype.abs=function(){return this.s<0?this.negate():this},ke.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},ke.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Ne(this.data[this.t-1]^this.s&this.DM)},ke.prototype.mod=function(e){var t=Se();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ke.ZERO)>0&&e.subTo(t,t),t},ke.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new Le(t):new Oe(t),this.exp(e,r)},ke.ZERO=Re(0),ke.ONE=Re(1),Ke.prototype.convert=ze,Ke.prototype.revert=ze,Ke.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},Ke.prototype.sqrTo=function(e,t){e.squareTo(t)},qe.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Se();return e.copyTo(t),this.reduce(t),t},qe.prototype.revert=function(e){return e},qe.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},qe.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},qe.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var He=[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],Ge=(1<<26)/He[He.length-1];if(ke.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},ke.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Re(r),a=Se(),i=Se(),o="";for(this.divRemTo(n,a,i);a.signum()>0;)o=(r+i.intValue()).toString(e).substr(1)+o,a.divRemTo(n,a,i);return i.intValue().toString(e)+o},ke.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),a=!1,i=0,o=0,s=0;s<e.length;++s){var c=Pe(e,s);c<0?"-"==e.charAt(s)&&0==this.signum()&&(a=!0):(o=t*o+c,++i>=r&&(this.dMultiply(n),this.dAddOffset(o,0),i=0,o=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(o,0)),a&&ke.ZERO.subTo(this,this)},ke.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ke.ONE.shiftLeft(e-1),Ue,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ke.ONE.shiftLeft(e-1),this);else{var n=new Array,a=7&e;n.length=1+(e>>3),t.nextBytes(n),a>0?n[0]&=(1<<a)-1:n[0]=0,this.fromString(n,256)}},ke.prototype.bitwiseTo=function(e,t,r){var n,a,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(a=e.s&this.DM,n=i;n<this.t;++n)r.data[n]=t(this.data[n],a);r.t=this.t}else{for(a=this.s&this.DM,n=i;n<e.t;++n)r.data[n]=t(a,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},ke.prototype.changeBit=function(e,t){var r=ke.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},ke.prototype.addTo=function(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},ke.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},ke.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},ke.prototype.multiplyLowerTo=function(e,t,r){var n,a=Math.min(this.t+e.t,t);for(r.s=0,r.t=a;a>0;)r.data[--a]=0;for(n=r.t-this.t;a<n;++a)r.data[a+this.t]=this.am(0,e.data[a],r,a,0,this.t);for(n=Math.min(e.t,t);a<n;++a)this.am(0,e.data[a],r,a,0,t-a);r.clamp()},ke.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},ke.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},ke.prototype.millerRabin=function(e){var t=this.subtract(ke.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,a=t.shiftRight(r),i={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},o=0;o<e;++o){do{n=new ke(this.bitLength(),i)}while(n.compareTo(ke.ONE)<=0||n.compareTo(t)>=0);var s=n.modPow(a,this);if(0!=s.compareTo(ke.ONE)&&0!=s.compareTo(t)){for(var c=1;c++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ke.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},ke.prototype.clone=function(){var e=Se();return this.copyTo(e),e},ke.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},ke.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},ke.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},ke.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},ke.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,a=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[a++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==a&&(128&this.s)!=(128&r)&&++a,(a>0||r!=this.s)&&(t[a++]=r);return t},ke.prototype.equals=function(e){return 0==this.compareTo(e)},ke.prototype.min=function(e){return this.compareTo(e)<0?this:e},ke.prototype.max=function(e){return this.compareTo(e)>0?this:e},ke.prototype.and=function(e){var t=Se();return this.bitwiseTo(e,De,t),t},ke.prototype.or=function(e){var t=Se();return this.bitwiseTo(e,Ue,t),t},ke.prototype.xor=function(e){var t=Se();return this.bitwiseTo(e,Me,t),t},ke.prototype.andNot=function(e){var t=Se();return this.bitwiseTo(e,Ve,t),t},ke.prototype.not=function(){for(var e=Se(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},ke.prototype.shiftLeft=function(e){var t=Se();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},ke.prototype.shiftRight=function(e){var t=Se();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},ke.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+Fe(this.data[e]);return this.s<0?this.t*this.DB:-1},ke.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=je(this.data[r]^t);return e},ke.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},ke.prototype.setBit=function(e){return this.changeBit(e,Ue)},ke.prototype.clearBit=function(e){return this.changeBit(e,Ve)},ke.prototype.flipBit=function(e){return this.changeBit(e,Me)},ke.prototype.add=function(e){var t=Se();return this.addTo(e,t),t},ke.prototype.subtract=function(e){var t=Se();return this.subTo(e,t),t},ke.prototype.multiply=function(e){var t=Se();return this.multiplyTo(e,t),t},ke.prototype.divide=function(e){var t=Se();return this.divRemTo(e,t,null),t},ke.prototype.remainder=function(e){var t=Se();return this.divRemTo(e,null,t),t},ke.prototype.divideAndRemainder=function(e){var t=Se(),r=Se();return this.divRemTo(e,t,r),new Array(t,r)},ke.prototype.modPow=function(e,t){var r,n,a=e.bitLength(),i=Re(1);if(a<=0)return i;r=a<18?1:a<48?3:a<144?4:a<768?5:6,n=a<8?new Le(t):t.isEven()?new qe(t):new Oe(t);var o=new Array,s=3,c=r-1,u=(1<<r)-1;if(o[1]=n.convert(this),r>1){var l=Se();for(n.sqrTo(o[1],l);s<=u;)o[s]=Se(),n.mulTo(l,o[s-2],o[s]),s+=2}var f,d,p=e.t-1,h=!0,g=Se();for(a=Ne(e.data[p])-1;p>=0;){for(a>=c?f=e.data[p]>>a-c&u:(f=(e.data[p]&(1<<a+1)-1)<<c-a,p>0&&(f|=e.data[p-1]>>this.DB+a-c)),s=r;0==(1&f);)f>>=1,--s;if((a-=s)<0&&(a+=this.DB,--p),h)o[f].copyTo(i),h=!1;else{for(;s>1;)n.sqrTo(i,g),n.sqrTo(g,i),s-=2;s>0?n.sqrTo(i,g):(d=i,i=g,g=d),n.mulTo(g,o[f],i)}for(;p>=0&&0==(e.data[p]&1<<a);)n.sqrTo(i,g),d=i,i=g,g=d,--a<0&&(a=this.DB-1,--p)}return n.revert(i)},ke.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ke.ZERO;for(var r=e.clone(),n=this.clone(),a=Re(1),i=Re(0),o=Re(0),s=Re(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(a.isEven()&&i.isEven()||(a.addTo(this,a),i.subTo(e,i)),a.rShiftTo(1,a)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);r.compareTo(n)>=0?(r.subTo(n,r),t&&a.subTo(o,a),i.subTo(s,i)):(n.subTo(r,n),t&&o.subTo(a,o),s.subTo(i,s))}return 0!=n.compareTo(ke.ONE)?ke.ZERO:s.compareTo(e)>=0?s.subtract(e):s.signum()<0?(s.addTo(e,s),s.signum()<0?s.add(e):s):s},ke.prototype.pow=function(e){return this.exp(e,new Ke)},ke.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var a=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(a<i&&(i=a),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(a=t.getLowestSetBit())>0&&t.rShiftTo(a,t),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r},ke.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=He[He.length-1]){for(t=0;t<He.length;++t)if(r.data[0]==He[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<He.length;){for(var n=He[t],a=t+1;a<He.length&&n<Ge;)n*=He[a++];for(n=r.modInt(n);t<a;)if(n%He[t++]==0)return!1}return r.millerRabin(e)},E((function(e){var t=e.exports=j.sha1=j.sha1||{};j.md.sha1=j.md.algorithms.sha1=t,t.create=function(){n||(r=String.fromCharCode(128),r+=j.util.fillString(String.fromCharCode(0),64),n=!0);var e=null,t=j.util.createBuffer(),i=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n<r;++n)o.fullMessageLength.push(0);return t=j.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o}};return o.start(),o.update=function(r,n){"utf8"===n&&(r=j.util.encodeUtf8(r));var s=r.length;o.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=o.fullMessageLength.length-1;c>=0;--c)o.fullMessageLength[c]+=s[1],s[1]=s[0]+(o.fullMessageLength[c]/4294967296>>>0),o.fullMessageLength[c]=o.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(r),a(e,i,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var n=j.util.createBuffer();n.putBytes(t.bytes());var s,c=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(r.substr(0,o.blockLength-c));for(var u=8*o.fullMessageLength[0],l=0;l<o.fullMessageLength.length-1;++l)u+=(s=8*o.fullMessageLength[l+1])/4294967296>>>0,n.putInt32(u>>>0),u=s>>>0;n.putInt32(u);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(f,i,n);var d=j.util.createBuffer();return d.putInt32(f.h0),d.putInt32(f.h1),d.putInt32(f.h2),d.putInt32(f.h3),d.putInt32(f.h4),d},o};var r=null,n=!1;function a(e,t,r){for(var n,a,i,o,s,c,u,l=r.length();l>=64;){for(a=e.h0,i=e.h1,o=e.h2,s=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(a<<5|a>>>27)+(s^i&(o^s))+c+1518500249+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(a<<5|a>>>27)+(s^i&(o^s))+c+1518500249+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+1859775393+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+1859775393+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i&o|s&(i^o))+c+2400959708+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(a<<5|a>>>27)+(i^o^s)+c+3395469782+n,c=s,s=o,o=(i<<30|i>>>2)>>>0,i=a,a=n;e.h0=e.h0+a|0,e.h1=e.h1+i|0,e.h2=e.h2+o|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,l-=64}}})),E((function(e){var t=e.exports=j.pkcs1=j.pkcs1||{};function r(e,t,r){r||(r=j.md.sha1.create());for(var n="",a=Math.ceil(t/r.digestLength),i=0;i<a;++i){var o=String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,255&i);r.start(),r.update(e+o),n+=r.digest().getBytes()}return n.substring(0,t)}t.encode_rsa_oaep=function(e,t,n){var a,i,o,s;"string"==typeof n?(a=n,i=arguments[3]||void 0,o=arguments[4]||void 0):n&&(a=n.label||void 0,i=n.seed||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(s=n.mgf1.md)),o?o.start():o=j.md.sha1.create(),s||(s=o);var c=Math.ceil(e.n.bitLength()/8),u=c-2*o.digestLength-2;if(t.length>u)throw(h=new Error("RSAES-OAEP input message length is too long.")).length=t.length,h.maxLength=u,h;a||(a=""),o.update(a,"raw");for(var l=o.digest(),f="",d=u-t.length,p=0;p<d;p++)f+="\0";var h,g=l.getBytes()+f+""+t;if(i){if(i.length!==o.digestLength)throw(h=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=i.length,h.digestLength=o.digestLength,h}else i=j.random.getBytes(o.digestLength);var m=r(i,c-o.digestLength-1,s),y=j.util.xorBytes(g,m,g.length),v=r(y,o.digestLength,s);return"\0"+j.util.xorBytes(i,v,i.length)+y},t.decode_rsa_oaep=function(e,t,n){var a,i,o;"string"==typeof n?(a=n,i=arguments[3]||void 0):n&&(a=n.label||void 0,i=n.md||void 0,n.mgf1&&n.mgf1.md&&(o=n.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s)throw(m=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,m.expectedLength=s,m;if(void 0===i?i=j.md.sha1.create():i.start(),o||(o=i),s<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");a||(a=""),i.update(a,"raw");for(var c=i.digest().getBytes(),u=t.charAt(0),l=t.substring(1,i.digestLength+1),f=t.substring(1+i.digestLength),d=r(f,i.digestLength,o),p=r(j.util.xorBytes(l,d,l.length),s-i.digestLength-1,o),h=j.util.xorBytes(f,p,f.length),g=h.substring(0,i.digestLength),m="\0"!==u,y=0;y<i.digestLength;++y)m|=c.charAt(y)!==g.charAt(y);for(var v=1,b=i.digestLength,C=i.digestLength;C<h.length;C++){var E=h.charCodeAt(C);m|=E&(v?65534:0),b+=v&=1&E^1}if(m||1!==h.charCodeAt(b))throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)}})),E((function(e){!function(){if(j.prime)e.exports=j.prime;else{var t=e.exports=j.prime=j.prime||{},r=j.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],a=new r(null);a.fromInt(30);var i=function(e,t){return e|t};t.generateProbablePrime=function(e,t,n){"function"==typeof t&&(n=t,t={});var a=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof a&&(a={name:a}),a.options=a.options||{};var i=t.prng||j.random,c={nextBytes:function(e){for(var t=i.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===a.name)return function(e,t,n,a){return"workers"in n?function(e,t,n,a){if("undefined"==typeof Worker)return o(e,t,n,a);var i=s(e,t),c=n.workers,u=n.workLoad||100,l=30*u/8,f=n.workerScript||"forge/prime.worker.js";if(-1===c)return j.util.estimateCores((function(e,t){e&&(t=2),c=t-1,d()}));function d(){c=Math.max(1,c);for(var n=[],o=0;o<c;++o)n[o]=new Worker(f);for(o=0;o<c;++o)n[o].addEventListener("message",p);var d=!1;function p(o){if(!d){var c=o.data;if(c.found){for(var f=0;f<n.length;++f)n[f].terminate();return d=!0,a(null,new r(c.prime,16))}i.bitLength()>e&&(i=s(e,t));var p=i.toString(16);o.target.postMessage({hex:p,workLoad:u}),i.dAddOffset(l,0)}}}d()}(e,t,n,a):o(e,t,n,a)}(e,c,a.options,n);throw new Error("Invalid prime generation algorithm: "+a.name)}}function o(e,t,r,a){var i=s(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var c=10;"maxBlockTime"in r&&(c=r.maxBlockTime),function e(t,r,a,i,o,c,u){var l=+new Date;do{if(t.bitLength()>r&&(t=s(r,a)),t.isProbablePrime(o))return u(null,t);t.dAddOffset(n[i++%8],0)}while(c<0||+new Date-l<c);j.util.setImmediate((function(){e(t,r,a,i,o,c,u)}))}(i,e,t,0,o,c,a)}function s(e,t){var n=new r(e,t),o=e-1;return n.testBit(o)||n.bitwiseTo(r.ONE.shiftLeft(o),i,n),n.dAddOffset(31-n.mod(a).byteValue(),0),n}}()})),void 0===Qe)var Qe=j.jsbn.BigInteger;var We=j.util.isNodejs?t:null,Xe=j.asn1,Ye=j.util;j.pki=j.pki||{},j.pki.rsa=j.rsa=j.rsa||{};var $e=j.pki,Ze=[6,4,2,4,2,4,6,2],Je={name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},et={name:"RSAPrivateKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},tt={name:"RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},rt=j.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Xe.Class.UNIVERSAL,type:Xe.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},nt=function(e){var t;if(!(e.algorithm in $e.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=$e.oids[e.algorithm];var n=Xe.oidToDer(t).getBytes(),a=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]),i=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[]);i.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,n)),i.value.push(Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,""));var o=Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,e.digest().getBytes());return a.value.push(i),a.value.push(o),Xe.toDer(a).getBytes()},at=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var n;t.dP||(t.dP=t.d.mod(t.p.subtract(Qe.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(Qe.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{n=new Qe(j.util.bytesToHex(j.random.getBytes(t.n.bitLength()/8)),16)}while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(Qe.ONE));for(var a=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),i=e.mod(t.q).modPow(t.dQ,t.q);a.compareTo(i)<0;)a=a.add(t.p);var o=a.subtract(i).multiply(t.qInv).mod(t.p).multiply(t.q).add(i);return o.multiply(n.modInverse(t.n)).mod(t.n)};function it(e,t,r){var n=j.util.createBuffer(),a=Math.ceil(t.n.bitLength()/8);if(e.length>a-11){var i=new Error("Message is too long for PKCS#1 v1.5 padding.");throw i.length=e.length,i.max=a-11,i}n.putByte(0),n.putByte(r);var o,s=a-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var c=0;c<s;++c)n.putByte(o)}else for(;s>0;){var u=0,l=j.random.getBytes(s);for(c=0;c<s;++c)0===(o=l.charCodeAt(c))?++u:n.putByte(o);s=u}return n.putByte(0),n.putBytes(e),n}function ot(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8),i=j.util.createBuffer(e),o=i.getByte(),s=i.getByte();if(0!==o||r&&0!==s&&1!==s||!r&&2!=s||r&&0===s&&void 0===n)throw new Error("Encryption block is invalid.");var c=0;if(0===s){c=a-3-n;for(var u=0;u<c;++u)if(0!==i.getByte())throw new Error("Encryption block is invalid.")}else if(1===s)for(c=0;i.length()>1;){if(255!==i.getByte()){--i.read;break}++c}else if(2===s)for(c=0;i.length()>1;){if(0===i.getByte()){--i.read;break}++c}if(0!==i.getByte()||c!==a-3-i.length())throw new Error("Encryption block is invalid.");return i.getBytes()}function st(e,t,r){"function"==typeof t&&(r=t,t={});var n={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function a(){i(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?o(t,e.q):void i(e.qBits,o))}))}function i(e,t){j.prime.generateProbablePrime(e,n,t)}function o(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.p=null,void a();if(0!==e.q.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE))return e.q=null,void i(e.qBits,o);if(e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(Qe.ONE))return e.p=e.q=null,void a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void i(e.qBits,o);var c=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(n.prng=t.prng),a()}function ct(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=j.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function ut(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function lt(e){return j.util.isNodejs&&"function"==typeof We[e]}function ft(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.crypto&&"object"==typeof Ye.globalScope.crypto.subtle&&"function"==typeof Ye.globalScope.crypto.subtle[e]}function dt(e){return void 0!==Ye.globalScope&&"object"==typeof Ye.globalScope.msCrypto&&"object"==typeof Ye.globalScope.msCrypto.subtle&&"function"==typeof Ye.globalScope.msCrypto.subtle[e]}function pt(e){for(var t=j.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}if($e.rsa.encrypt=function(e,t,r){var n,a=r,i=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(a=2===r,n=it(e,t,r)):(n=j.util.createBuffer()).putBytes(e);for(var o=new Qe(n.toHex(),16),s=at(o,t,a).toString(16),c=j.util.createBuffer(),u=i-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(j.util.hexToBytes(s)),c.getBytes()},$e.rsa.decrypt=function(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8);if(e.length!==a){var i=new Error("Encrypted message length is invalid.");throw i.length=e.length,i.expected=a,i}var o=new Qe(j.util.createBuffer(e).toHex(),16);if(o.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=at(o,t,r).toString(16),c=j.util.createBuffer(),u=a-Math.ceil(s.length/2);u>0;)c.putByte(0),--u;return c.putBytes(j.util.hexToBytes(s)),!1!==n?ot(c.getBytes(),t,r):c.getBytes()},$e.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,a=(r=r||{}).prng||j.random,i={nextBytes:function(e){for(var t=a.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},o=r.algorithm||"PRIMEINC";if("PRIMEINC"!==o)throw new Error("Invalid key generation algorithm: "+o);return(n={algorithm:o,state:0,bits:e,rng:i,eInt:t||65537,e:new Qe(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},$e.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new Qe(null);r.fromInt(30);for(var n,a=0,i=function(e,t){return e|t},o=+new Date,s=0;null===e.keys&&(t<=0||s<t);){if(0===e.state){var c=null===e.p?e.pBits:e.qBits,u=c-1;0===e.pqState?(e.num=new Qe(c,e.rng),e.num.testBit(u)||e.num.bitwiseTo(Qe.ONE.shiftLeft(u),i,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),a=0,++e.pqState):1===e.pqState?e.num.bitLength()>c?e.pqState=0:e.num.isProbablePrime(ut(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Ze[a++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(Qe.ONE).gcd(e.e).compareTo(Qe.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(Qe.ONE),e.q1=e.q.subtract(Qe.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(Qe.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:$e.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:$e.rsa.setPublicKey(e.n,e.e)}}s+=(n=+new Date)-o,o=n}return null!==e.keys},$e.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(lt("generateKeyPair"))return We.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:$e.privateKeyFromPem(r),publicKey:$e.publicKeyFromPem(t)})}));if(ft("generateKey")&&ft("exportKey"))return Ye.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return Ye.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=$e.privateKeyFromAsn1(Xe.fromDer(j.util.createBuffer(e)));n(null,{privateKey:t,publicKey:$e.setRsaPublicKey(t.n,t.e)})}}));if(dt("generateKey")&&dt("exportKey")){var a=Ye.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:pt(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return a.oncomplete=function(e){var t=e.target.result,r=Ye.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=$e.privateKeyFromAsn1(Xe.fromDer(j.util.createBuffer(t)));n(null,{privateKey:r,publicKey:$e.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(a.onerror=function(e){n(e)})}}else if(lt("generateKeyPairSync")){var i=We.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$e.privateKeyFromPem(i.privateKey),publicKey:$e.publicKeyFromPem(i.publicKey)}}var o=$e.rsa.createKeyPairGenerationState(e,t,r);if(!n)return $e.rsa.stepKeyPairGenerationState(o,0),o.keys;st(o,r,n)},$e.setRsaPublicKey=$e.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return it(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return j.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var a=t.encode(e,r,!0);return $e.rsa.encrypt(a,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=ot(t,r,!0),e===Xe.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===ot(t,r,!0)}});var a=$e.rsa.decrypt(t,r,!0,!1);return n.verify(e,a,r.n.bitLength())}};return r},$e.setRsaPrivateKey=$e.rsa.setPrivateKey=function(e,t,r,n,a,i,o,s){var c={n:e,e:t,d:r,p:n,q:a,dP:i,dQ:o,qInv:s,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=$e.rsa.decrypt(e,c,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:ot};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return j.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,c,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:nt},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,c.n.bitLength());return $e.rsa.encrypt(n,c,r)}};return c},$e.wrapRsaPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OCTETSTRING,!1,Xe.toDer(e).getBytes())])},$e.privateKeyFromAsn1=function(e){var t,r,n,a,i,o,s,c,u={},l=[];if(Xe.validate(e,Je,u,l)&&(e=Xe.fromDer(j.util.createBuffer(u.privateKey))),u={},l=[],!Xe.validate(e,et,u,l)){var f=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw f.errors=l,f}return t=j.util.createBuffer(u.privateKeyModulus).toHex(),r=j.util.createBuffer(u.privateKeyPublicExponent).toHex(),n=j.util.createBuffer(u.privateKeyPrivateExponent).toHex(),a=j.util.createBuffer(u.privateKeyPrime1).toHex(),i=j.util.createBuffer(u.privateKeyPrime2).toHex(),o=j.util.createBuffer(u.privateKeyExponent1).toHex(),s=j.util.createBuffer(u.privateKeyExponent2).toHex(),c=j.util.createBuffer(u.privateKeyCoefficient).toHex(),$e.setRsaPrivateKey(new Qe(t,16),new Qe(r,16),new Qe(n,16),new Qe(a,16),new Qe(i,16),new Qe(o,16),new Qe(s,16),new Qe(c,16))},$e.privateKeyToAsn1=$e.privateKeyToRSAPrivateKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,Xe.integerToDer(0).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.d)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.p)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.q)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dP)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.dQ)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.qInv))])},$e.publicKeyFromAsn1=function(e){var t={},r=[];if(Xe.validate(e,rt,t,r)){var n,a=Xe.derToOid(t.publicKeyOid);if(a!==$e.oids.rsaEncryption)throw(n=new Error("Cannot read public key. Unknown OID.")).oid=a,n;e=t.rsaPublicKey}if(r=[],!Xe.validate(e,tt,t,r))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,n;var i=j.util.createBuffer(t.publicKeyModulus).toHex(),o=j.util.createBuffer(t.publicKeyExponent).toHex();return $e.setRsaPublicKey(new Qe(i,16),new Qe(o,16))},$e.publicKeyToAsn1=$e.publicKeyToSubjectPublicKeyInfo=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.OID,!1,Xe.oidToDer($e.oids.rsaEncryption).getBytes()),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.NULL,!1,"")]),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.BITSTRING,!1,[$e.publicKeyToRSAPublicKey(e)])])},$e.publicKeyToRSAPublicKey=function(e){return Xe.create(Xe.Class.UNIVERSAL,Xe.Type.SEQUENCE,!0,[Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.n)),Xe.create(Xe.Class.UNIVERSAL,Xe.Type.INTEGER,!1,ct(e.e))])},void 0===ht)var ht=j.jsbn.BigInteger;var gt=j.asn1,mt=j.pki=j.pki||{},yt=(mt.pbe=j.pbe=j.pbe||{},mt.oids),vt={name:"EncryptedPrivateKeyInfo",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},bt={name:"PBES2Algorithms",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},Ct={name:"pkcs-12PbeParams",tagClass:gt.Class.UNIVERSAL,type:gt.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:gt.Class.UNIVERSAL,type:gt.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:gt.Class.UNIVERSAL,type:gt.Type.INTEGER,constructed:!1,capture:"iterations"}]};function Et(e,t){return e.start().update(t).digest().getBytes()}function wt(e){var t;if(e){if(!(t=mt.oids[gt.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return kt(t)}function kt(e){var t=j.md;switch(e){case"hmacWithSHA224":t=j.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}mt.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n,a,i,o=j.random.getBytesSync(r.saltSize),s=r.count,c=gt.integerToDer(s);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var u,l,f;switch(r.algorithm){case"aes128":n=16,u=16,l=yt["aes128-CBC"],f=j.aes.createEncryptionCipher;break;case"aes192":n=24,u=16,l=yt["aes192-CBC"],f=j.aes.createEncryptionCipher;break;case"aes256":n=32,u=16,l=yt["aes256-CBC"],f=j.aes.createEncryptionCipher;break;case"des":n=8,u=8,l=yt.desCBC,f=j.des.createEncryptionCipher;break;default:throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=kt(d),h=j.pkcs5.pbkdf2(t,o,s,n,p),g=j.random.getBytesSync(u);(v=f(h)).start(g),v.update(gt.toDer(e)),v.finish(),i=v.output.getBytes();var m=function(e,t,r,n){var a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,e),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,t.getBytes())]);return"hmacWithSHA1"!==n&&a.value.push(gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,j.util.hexToBytes(r.toString(16))),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(mt.oids[n]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.NULL,!1,"")])),a}(o,c,n,d);a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBES2).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt.pkcs5PBKDF2).getBytes()),m]),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(l).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,g)])])])}else{var y;if("3des"!==r.algorithm)throw(y=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,y;n=24;var v,b=new j.util.ByteBuffer(o);h=mt.pbe.generatePkcs12Key(t,b,1,s,n),g=mt.pbe.generatePkcs12Key(t,b,2,s,n),(v=j.des.createEncryptionCipher(h)).start(g),v.update(gt.toDer(e)),v.finish(),i=v.output.getBytes(),a=gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OID,!1,gt.oidToDer(yt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,o),gt.create(gt.Class.UNIVERSAL,gt.Type.INTEGER,!1,c.getBytes())])])}return gt.create(gt.Class.UNIVERSAL,gt.Type.SEQUENCE,!0,[a,gt.create(gt.Class.UNIVERSAL,gt.Type.OCTETSTRING,!1,i)])},mt.decryptPrivateKeyInfo=function(e,t){var r=null,n={},a=[];if(!gt.validate(e,vt,n,a)){var i=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=a,i}var o=gt.derToOid(n.encryptionOid),s=mt.pbe.getCipher(o,n.encryptionParams,t),c=j.util.createBuffer(n.encryptedData);return s.update(c),s.finish()&&(r=gt.fromDer(s.output)),r},mt.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:gt.toDer(e).getBytes()};return j.pem.encode(r,{maxline:t})},mt.encryptedPrivateKeyFromPem=function(e){var t=j.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return gt.fromDer(t.body)},mt.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var n=mt.wrapRsaPrivateKey(mt.privateKeyToAsn1(e));return n=mt.encryptPrivateKeyInfo(n,t,r),mt.encryptedPrivateKeyToPem(n)}var a,i,o,s;switch(r.algorithm){case"aes128":a="AES-128-CBC",o=16,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",o=24,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",o=32,i=j.random.getBytesSync(16),s=j.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",o=24,i=j.random.getBytesSync(8),s=j.des.createEncryptionCipher;break;case"des":a="DES-CBC",o=8,i=j.random.getBytesSync(8),s=j.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=s(j.pbe.opensslDeriveBytes(t,i.substr(0,8),o));u.start(i),u.update(gt.toDer(mt.privateKeyToAsn1(e))),u.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:j.util.bytesToHex(i).toUpperCase()},body:u.output.getBytes()};return j.pem.encode(l)},mt.decryptRsaPrivateKey=function(e,t){var r=null,n=j.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw(o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=o,o;if(n.procType&&"ENCRYPTED"===n.procType.type){var a,i;switch(n.dekInfo.algorithm){case"DES-CBC":a=8,i=j.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,i=j.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,i=j.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,i=j.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,i=j.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,i=function(e){return j.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,i=function(e){return j.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,i=function(e){return j.rc2.createDecryptionCipher(e,128)};break;default:var o;throw(o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".')).algorithm=n.dekInfo.algorithm,o}var s=j.util.hexToBytes(n.dekInfo.parameters),c=i(j.pbe.opensslDeriveBytes(t,s.substr(0,8),a));if(c.start(s),c.update(j.util.createBuffer(n.body)),!c.finish())return r;r=c.output.getBytes()}else r=n.body;return null!==(r="ENCRYPTED PRIVATE KEY"===n.type?mt.decryptPrivateKeyInfo(gt.fromDer(r),t):gt.fromDer(r))&&(r=mt.privateKeyFromAsn1(r)),r},mt.pbe.generatePkcs12Key=function(e,t,r,n,a,i){var o,s;if(null==i){if(!("sha1"in j.md))throw new Error('"sha1" hash algorithm unavailable.');i=j.md.sha1.create()}var c=i.digestLength,u=i.blockLength,l=new j.util.ByteBuffer,f=new j.util.ByteBuffer;if(null!=e){for(s=0;s<e.length;s++)f.putInt16(e.charCodeAt(s));f.putInt16(0)}var d=f.length(),p=t.length(),h=new j.util.ByteBuffer;h.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new j.util.ByteBuffer;for(s=0;s<g;s++)m.putByte(t.at(s%p));var y=u*Math.ceil(d/u),v=new j.util.ByteBuffer;for(s=0;s<y;s++)v.putByte(f.at(s%d));var b=m;b.putBuffer(v);for(var C=Math.ceil(a/c),E=1;E<=C;E++){var w=new j.util.ByteBuffer;w.putBytes(h.bytes()),w.putBytes(b.bytes());for(var k=0;k<n;k++)i.start(),i.update(w.getBytes()),w=i.digest();var S=new j.util.ByteBuffer;for(s=0;s<u;s++)S.putByte(w.at(s%c));var B=Math.ceil(p/u)+Math.ceil(d/u),A=new j.util.ByteBuffer;for(o=0;o<B;o++){var T=new j.util.ByteBuffer(b.getBytes(u)),I=511;for(s=S.length()-1;s>=0;s--)I>>=8,I+=S.at(s)+T.at(s),T.setAt(s,255&I);A.putBuffer(T)}b=A,l.putBuffer(w)}return l.truncate(l.length()-a),l},mt.pbe.getCipher=function(e,t,r){switch(e){case mt.oids.pkcs5PBES2:return mt.pbe.getCipherForPBES2(e,t,r);case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:return mt.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},mt.pbe.getCipherForPBES2=function(e,t,r){var n,a={},i=[];if(!gt.validate(t,bt,a,i))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=i,n;if((e=gt.derToOid(a.kdfOid))!==mt.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=gt.derToOid(a.encOid))!==mt.oids["aes128-CBC"]&&e!==mt.oids["aes192-CBC"]&&e!==mt.oids["aes256-CBC"]&&e!==mt.oids["des-EDE3-CBC"]&&e!==mt.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var o,s,c=a.kdfSalt,u=j.util.createBuffer(a.kdfIterationCount);switch(u=u.getInt(u.length()<<3),mt.oids[e]){case"aes128-CBC":o=16,s=j.aes.createDecryptionCipher;break;case"aes192-CBC":o=24,s=j.aes.createDecryptionCipher;break;case"aes256-CBC":o=32,s=j.aes.createDecryptionCipher;break;case"des-EDE3-CBC":o=24,s=j.des.createDecryptionCipher;break;case"desCBC":o=8,s=j.des.createDecryptionCipher}var l=wt(a.prfOid),f=j.pkcs5.pbkdf2(r,c,u,o,l),d=a.encIv,p=s(f);return p.start(d),p},mt.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},a=[];if(!gt.validate(t,Ct,n,a))throw(l=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,l;var i,o,s,c=j.util.createBuffer(n.salt),u=j.util.createBuffer(n.iterations);switch(u=u.getInt(u.length()<<3),e){case mt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:i=24,o=8,s=j.des.startDecrypting;break;case mt.oids["pbewithSHAAnd40BitRC2-CBC"]:i=5,o=8,s=function(e,t){var r=j.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var l;throw(l=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,l}var f=wt(n.prfOid),d=mt.pbe.generatePkcs12Key(r,c,1,u,i,f);return f.start(),s(d,mt.pbe.generatePkcs12Key(r,c,2,u,o,f))},mt.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in j.md))throw new Error('"md5" hash algorithm unavailable.');n=j.md.md5.create()}null===t&&(t="");for(var a=[Et(n,e+t)],i=16,o=1;i<r;++o,i+=16)a.push(Et(n,a[o-1]+e+t));return a.join("").substr(0,r)},E((function(e){var t=j.asn1,r=e.exports=j.pkcs7asn1=j.pkcs7asn1||{};j.pkcs7=j.pkcs7||{},j.pkcs7.asn1=r;var n={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=n;var a={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(a)},r.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(a)};var i={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};r.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},n,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[i]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}})),E((function(e){j.mgf=j.mgf||{},(e.exports=j.mgf.mgf1=j.mgf1=j.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new j.util.ByteBuffer,a=Math.ceil(r/e.digestLength),i=0;i<a;i++){var o=new j.util.ByteBuffer;o.putInt32(i),e.start(),e.update(t+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}}}})),j.mgf=j.mgf||{},j.mgf.mgf1=j.mgf1,E((function(e){(e.exports=j.pss=j.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,a=r.digestLength,i=e.salt||null;if("string"==typeof i&&(i=j.util.createBuffer(i)),"saltLength"in e)t=e.saltLength;else{if(null===i)throw new Error("Salt length not specified or specific salt not given.");t=i.length()}if(null!==i&&i.length()!==t)throw new Error("Given salt length does not match length of given salt.");var o=e.prng||j.random;return{encode:function(e,s){var c,u,l=s-1,f=Math.ceil(l/8),d=e.digest().getBytes();if(f<a+t+2)throw new Error("Message is too long to encrypt.");u=null===i?o.getBytesSync(t):i.bytes();var p=new j.util.ByteBuffer;p.fillWithByte(0,8),p.putBytes(d),p.putBytes(u),r.start(),r.update(p.getBytes());var h=r.digest().getBytes(),g=new j.util.ByteBuffer;g.fillWithByte(0,f-t-a-2),g.putByte(1),g.putBytes(u);var m=g.getBytes(),y=f-a-1,v=n.generate(h,y),b="";for(c=0;c<y;c++)b+=String.fromCharCode(m.charCodeAt(c)^v.charCodeAt(c));var C=65280>>8*f-l&255;return(b=String.fromCharCode(b.charCodeAt(0)&~C)+b.substr(1))+h+String.fromCharCode(188)},verify:function(e,i,o){var s,c=o-1,u=Math.ceil(c/8);if(i=i.substr(-u),u<a+t+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==i.charCodeAt(u-1))throw new Error("Encoded message does not end in 0xBC.");var l=u-a-1,f=i.substr(0,l),d=i.substr(l,a),p=65280>>8*u-c&255;if(0!=(f.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var h=n.generate(d,l),g="";for(s=0;s<l;s++)g+=String.fromCharCode(f.charCodeAt(s)^h.charCodeAt(s));g=String.fromCharCode(g.charCodeAt(0)&~p)+g.substr(1);var m=u-a-t-2;for(s=0;s<m;s++)if(0!==g.charCodeAt(s))throw new Error("Leftmost octets not zero as expected");if(1!==g.charCodeAt(m))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var y=g.substr(-t),v=new j.util.ByteBuffer;return v.fillWithByte(0,8),v.putBytes(e),v.putBytes(y),r.start(),r.update(v.getBytes()),d===r.digest().getBytes()}}}})),E((function(e){var t=j.asn1,r=e.exports=j.pki=j.pki||{},n=r.oids,a={};a.CN=n.commonName,a.commonName="CN",a.C=n.countryName,a.countryName="C",a.L=n.localityName,a.localityName="L",a.ST=n.stateOrProvinceName,a.stateOrProvinceName="ST",a.O=n.organizationName,a.organizationName="O",a.OU=n.organizationalUnitName,a.organizationalUnitName="OU",a.E=n.emailAddress,a.emailAddress="E";var i=j.pki.rsa.publicKeyValidator,o={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},i,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},s={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},c={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},i,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},u={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[c,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,a=0;null===n&&a<e.attributes.length;++a)r=e.attributes[a],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}r.RDNAttributesAsArray=function(e,r){for(var i,o,s,c=[],u=0;u<e.value.length;++u){i=e.value[u];for(var l=0;l<i.value.length;++l)s={},o=i.value[l],s.type=t.derToOid(o.value[0].value),s.value=o.value[1].value,s.valueTagClass=o.value[1].type,s.type in n&&(s.name=n[s.type],s.name in a&&(s.shortName=a[s.name])),r&&(r.update(s.type),r.update(s.value)),c.push(s)}return c},r.CRIAttributesAsArray=function(e){for(var i=[],o=0;o<e.length;++o)for(var s=e[o],c=t.derToOid(s.value[0].value),u=s.value[1].value,l=0;l<u.length;++l){var f={};if(f.type=c,f.value=u[l].value,f.valueTagClass=u[l].type,f.type in n&&(f.name=n[f.type],f.name in a&&(f.shortName=a[f.name])),f.type===n.extensionRequest){f.extensions=[];for(var d=0;d<f.value.length;++d)f.extensions.push(r.certificateExtensionFromAsn1(f.value[d]))}i.push(f)}return i};var f=function(e,r,a){var i={};if(e!==n["RSASSA-PSS"])return i;a&&(i={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var o={},c=[];if(!t.validate(r,s,o,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==o.hashOid&&(i.hash=i.hash||{},i.hash.algorithmOid=t.derToOid(o.hashOid)),void 0!==o.maskGenOid&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=t.derToOid(o.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=t.derToOid(o.maskGenHashOid)),void 0!==o.saltLength&&(i.saltLength=o.saltLength.charCodeAt(0)),i};function d(e){for(var r,n,a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),i=e.attributes,o=0;o<i.length;++o){var s=(r=i[o]).value,c=t.Type.PRINTABLESTRING;"valueTagClass"in r&&(c=r.valueTagClass)===t.Type.UTF8&&(s=j.util.encodeUtf8(s)),n=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,c,!1,s)])]),a.value.push(n)}return a}function p(e){for(var i,o=0;o<e.length;++o){if(void 0===(i=e[o]).name&&(i.type&&i.type in r.oids?i.name=r.oids[i.type]:i.shortName&&i.shortName in a&&(i.name=r.oids[a[i.shortName]])),void 0===i.type){if(!i.name||!(i.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=i,c;i.type=r.oids[i.name]}if(void 0===i.shortName&&i.name&&i.name in a&&(i.shortName=a[i.name]),i.type===n.extensionRequest&&(i.valueConstructed=!0,i.valueTagClass=t.Type.SEQUENCE,!i.value&&i.extensions)){i.value=[];for(var s=0;s<i.extensions.length;++s)i.value.push(r.certificateExtensionToAsn1(h(i.extensions[s])))}var c;if(void 0===i.value)throw(c=new Error("Attribute value not specified.")).attribute=i,c}}function h(e,a){if(a=a||{},void 0===e.name&&e.id&&e.id in r.oids&&(e.name=r.oids[e.id]),void 0===e.id){if(!e.name||!(e.name in r.oids))throw(C=new Error("Extension ID not specified.")).extension=e,C;e.id=r.oids[e.name]}if(void 0!==e.value)return e;if("keyUsage"===e.name){var i=0,o=0,s=0;e.digitalSignature&&(o|=128,i=7),e.nonRepudiation&&(o|=64,i=6),e.keyEncipherment&&(o|=32,i=5),e.dataEncipherment&&(o|=16,i=4),e.keyAgreement&&(o|=8,i=3),e.keyCertSign&&(o|=4,i=2),e.cRLSign&&(o|=2,i=1),e.encipherOnly&&(o|=1,i=0),e.decipherOnly&&(s|=128,i=7);var c=String.fromCharCode(i);0!==s?c+=String.fromCharCode(o)+String.fromCharCode(s):0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c)}else if("basicConstraints"===e.name)e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.pathLenConstraint).getBytes()));else if("extKeyUsage"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);var u=e.value.value;for(var l in e)!0===e[l]&&(l in n?u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n[l]).getBytes())):-1!==l.indexOf(".")&&u.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes())))}else if("nsCertType"===e.name)i=0,o=0,e.client&&(o|=128,i=7),e.server&&(o|=64,i=6),e.email&&(o|=32,i=5),e.objsign&&(o|=16,i=4),e.reserved&&(o|=8,i=3),e.sslCA&&(o|=4,i=2),e.emailCA&&(o|=2,i=1),e.objCA&&(o|=1,i=0),c=String.fromCharCode(i),0!==o&&(c+=String.fromCharCode(o)),e.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,c);else if("subjectAltName"===e.name||"issuerAltName"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);for(var f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).value,7===y.type&&y.ip){if(null===(c=j.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));e.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}}else if("nsComment"===e.name&&a.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=t.create(t.Class.UNIVERSAL,t.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&a.cert){var p=a.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=p.toHex(),e.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p.getBytes())}else if("authorityKeyIdentifier"===e.name&&a.cert){if(e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value,e.keyIdentifier){var h=!0===e.keyIdentifier?a.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;u.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!1,h))}if(e.authorityCertIssuer){var g=[t.create(t.Class.CONTEXT_SPECIFIC,4,!0,[d(!0===e.authorityCertIssuer?a.cert.issuer:e.authorityCertIssuer)])];u.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=j.util.hexToBytes(!0===e.serialNumber?a.cert.serialNumber:e.serialNumber);u.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=e.value.value;var y,v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),b=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(f=0;f<e.altNames.length;++f){if(c=(y=e.altNames[f]).value,7===y.type&&y.ip){if(null===(c=j.util.bytesFromIP(y.ip)))throw(C=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=e,C}else 8===y.type&&(c=y.oid?t.oidToDer(t.oidToDer(y.oid)):t.oidToDer(c));b.value.push(t.create(t.Class.CONTEXT_SPECIFIC,y.type,!1,c))}v.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[b])),u.push(v)}var C;if(void 0===e.value)throw(C=new Error("Extension value not specified.")).extension=e,C;return e}function g(e,r){switch(e){case n["RSASSA-PSS"]:var a=[];return void 0!==r.hash.algorithmOid&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),void 0!==r.mgf.algorithmOid&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),void 0!==r.saltLength&&a.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,a);default:return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}}function m(e){var r=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return r;for(var n=e.attributes,a=0;a<n.length;++a){var i=n[a],o=i.value,s=t.Type.UTF8;"valueTagClass"in i&&(s=i.valueTagClass),s===t.Type.UTF8&&(o=j.util.encodeUtf8(o));var c=!1;"valueConstructed"in i&&(c=i.valueConstructed);var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,c,o)])]);r.value.push(u)}return r}r.certificateFromPem=function(e,n,a){var i=j.pem.decode(e)[0];if("CERTIFICATE"!==i.type&&"X509 CERTIFICATE"!==i.type&&"TRUSTED CERTIFICATE"!==i.type){var o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=i.type,o}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=t.fromDer(i.body,a);return r.certificateFromAsn1(s,n)},r.certificateToPem=function(e,n){var a={type:"CERTIFICATE",body:t.toDer(r.certificateToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.publicKeyFromPem=function(e){var n=j.pem.decode(e)[0];if("PUBLIC KEY"!==n.type&&"RSA PUBLIC KEY"!==n.type){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.publicKeyFromAsn1(i)},r.publicKeyToPem=function(e,n){var a={type:"PUBLIC KEY",body:t.toDer(r.publicKeyToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.publicKeyToRSAPublicKeyPem=function(e,n){var a={type:"RSA PUBLIC KEY",body:t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.getPublicKeyFingerprint=function(e,n){var a,i=(n=n||{}).md||j.md.sha1.create();switch(n.type||"RSAPublicKey"){case"RSAPublicKey":a=t.toDer(r.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":a=t.toDer(r.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+n.type+'".')}i.start(),i.update(a);var o=i.digest();if("hex"===n.encoding){var s=o.toHex();return n.delimiter?s.match(/.{2}/g).join(n.delimiter):s}if("binary"===n.encoding)return o.getBytes();if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return o},r.certificationRequestFromPem=function(e,n,a){var i=j.pem.decode(e)[0];if("CERTIFICATE REQUEST"!==i.type){var o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=i.type,o}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=t.fromDer(i.body,a);return r.certificationRequestFromAsn1(s,n)},r.certificationRequestToPem=function(e,n){var a={type:"CERTIFICATE REQUEST",body:t.toDer(r.certificationRequestToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.createCertificate=function(){var e={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return l(e.issuer,t)},e.issuer.addField=function(t){p([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){p(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){p(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)h(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){"string"==typeof t&&(t={name:t});for(var r,n=null,a=0;null===n&&a<e.extensions.length;++a)r=e.extensions[a],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(a,i){e.md=i||j.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.tbsCertificate=r.getTBSCertificate(e);var c=t.toDer(e.tbsCertificate);e.md.update(c.getBytes()),e.signature=a.sign(e.md)},e.verify=function(a){var i=!1;if(!e.issued(a)){var o=a.issuer,s=e.subject;throw(h=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.")).expectedIssuer=o.attributes,h.actualIssuer=s.attributes,h}var c=a.md;if(null===c){if(a.signatureOid in n)switch(n[a.signatureOid]){case"sha1WithRSAEncryption":c=j.md.sha1.create();break;case"md5WithRSAEncryption":c=j.md.md5.create();break;case"sha256WithRSAEncryption":c=j.md.sha256.create();break;case"sha384WithRSAEncryption":c=j.md.sha384.create();break;case"sha512WithRSAEncryption":c=j.md.sha512.create();break;case"RSASSA-PSS":c=j.md.sha256.create()}if(null===c)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=a.signatureOid,h;var u=a.tbsCertificate||r.getTBSCertificate(a),l=t.toDer(u);c.update(l.getBytes())}if(null!==c){var f;switch(a.signatureOid){case n.sha1WithRSAEncryption:f=void 0;break;case n["RSASSA-PSS"]:var d,p,h;if(void 0===(d=n[a.signatureParameters.mgf.hash.algorithmOid])||void 0===j.md[d])throw(h=new Error("Unsupported MGF hash function.")).oid=a.signatureParameters.mgf.hash.algorithmOid,h.name=d,h;if(void 0===(p=n[a.signatureParameters.mgf.algorithmOid])||void 0===j.mgf[p])throw(h=new Error("Unsupported MGF function.")).oid=a.signatureParameters.mgf.algorithmOid,h.name=p,h;if(p=j.mgf[p].create(j.md[d].create()),void 0===(d=n[a.signatureParameters.hash.algorithmOid])||void 0===j.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:a.signatureParameters.hash.algorithmOid,name:d};f=j.pss.create(j.md[d].create(),p,a.signatureParameters.saltLength)}i=e.publicKey.verify(c.digest().getBytes(),a.signature,f)}return i},e.isIssuer=function(t){var r=!1,n=e.issuer,a=t.subject;if(n.hash&&a.hash)r=n.hash===a.hash;else if(n.attributes.length===a.attributes.length){var i,o;r=!0;for(var s=0;r&&s<n.attributes.length;++s)i=n.attributes[s],o=a.attributes[s],i.type===o.type&&i.value===o.value||(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=n.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var a=e.extensions[r];if(a.id===t){var i=e.generateSubjectKeyIdentifier().getBytes();return j.util.hexToBytes(a.subjectKeyIdentifier)===i}}return!1},e},r.certificateFromAsn1=function(e,a){var i={},s=[];if(!t.validate(e,o,i,s))throw(h=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.")).errors=s,h;if(t.derToOid(i.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificate();c.version=i.certVersion?i.certVersion.charCodeAt(0):0;var u=j.util.createBuffer(i.certSerialNumber);c.serialNumber=u.toHex(),c.signatureOid=j.asn1.derToOid(i.certSignatureOid),c.signatureParameters=f(c.signatureOid,i.certSignatureParams,!0),c.siginfo.algorithmOid=j.asn1.derToOid(i.certinfoSignatureOid),c.siginfo.parameters=f(c.siginfo.algorithmOid,i.certinfoSignatureParams,!1),c.signature=i.certSignature;var d=[];if(void 0!==i.certValidity1UTCTime&&d.push(t.utcTimeToDate(i.certValidity1UTCTime)),void 0!==i.certValidity2GeneralizedTime&&d.push(t.generalizedTimeToDate(i.certValidity2GeneralizedTime)),void 0!==i.certValidity3UTCTime&&d.push(t.utcTimeToDate(i.certValidity3UTCTime)),void 0!==i.certValidity4GeneralizedTime&&d.push(t.generalizedTimeToDate(i.certValidity4GeneralizedTime)),d.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=i.tbsCertificate,a){var h;if(c.md=null,c.signatureOid in n)switch(n[c.signatureOid]){case"sha1WithRSAEncryption":c.md=j.md.sha1.create();break;case"md5WithRSAEncryption":c.md=j.md.md5.create();break;case"sha256WithRSAEncryption":c.md=j.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=j.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=j.md.sha512.create();break;case"RSASSA-PSS":c.md=j.md.sha256.create()}if(null===c.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,h;var g=t.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var m=j.md.sha1.create();c.issuer.getField=function(e){return l(c.issuer,e)},c.issuer.addField=function(e){p([e]),c.issuer.attributes.push(e)},c.issuer.attributes=r.RDNAttributesAsArray(i.certIssuer,m),i.certIssuerUniqueId&&(c.issuer.uniqueId=i.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var y=j.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){p([e]),c.subject.attributes.push(e)},c.subject.attributes=r.RDNAttributesAsArray(i.certSubject,y),i.certSubjectUniqueId&&(c.subject.uniqueId=i.certSubjectUniqueId),c.subject.hash=y.digest().toHex(),i.certExtensions?c.extensions=r.certificateExtensionsFromAsn1(i.certExtensions):c.extensions=[],c.publicKey=r.publicKeyFromAsn1(i.subjectPublicKeyInfo),c},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var a=e.value[n],i=0;i<a.value.length;++i)t.push(r.certificateExtensionFromAsn1(a.value[i]));return t},r.certificateExtensionFromAsn1=function(e){var r={};if(r.id=t.derToOid(e.value[0].value),r.critical=!1,e.value[1].type===t.Type.BOOLEAN?(r.critical=0!==e.value[1].value.charCodeAt(0),r.value=e.value[2].value):r.value=e.value[1].value,r.id in n)if(r.name=n[r.id],"keyUsage"===r.name){var a=0,i=0;(s=t.fromDer(r.value)).value.length>1&&(a=s.value.charCodeAt(1),i=s.value.length>2?s.value.charCodeAt(2):0),r.digitalSignature=128==(128&a),r.nonRepudiation=64==(64&a),r.keyEncipherment=32==(32&a),r.dataEncipherment=16==(16&a),r.keyAgreement=8==(8&a),r.keyCertSign=4==(4&a),r.cRLSign=2==(2&a),r.encipherOnly=1==(1&a),r.decipherOnly=128==(128&i)}else if("basicConstraints"===r.name){(s=t.fromDer(r.value)).value.length>0&&s.value[0].type===t.Type.BOOLEAN?r.cA=0!==s.value[0].value.charCodeAt(0):r.cA=!1;var o=null;s.value.length>0&&s.value[0].type===t.Type.INTEGER?o=s.value[0].value:s.value.length>1&&(o=s.value[1].value),null!==o&&(r.pathLenConstraint=t.derToInteger(o))}else if("extKeyUsage"===r.name)for(var s=t.fromDer(r.value),c=0;c<s.value.length;++c){var u=t.derToOid(s.value[c].value);u in n?r[n[u]]=!0:r[u]=!0}else if("nsCertType"===r.name)a=0,(s=t.fromDer(r.value)).value.length>1&&(a=s.value.charCodeAt(1)),r.client=128==(128&a),r.server=64==(64&a),r.email=32==(32&a),r.objsign=16==(16&a),r.reserved=8==(8&a),r.sslCA=4==(4&a),r.emailCA=2==(2&a),r.objCA=1==(1&a);else if("subjectAltName"===r.name||"issuerAltName"===r.name){var l;r.altNames=[],s=t.fromDer(r.value);for(var f=0;f<s.value.length;++f){var d={type:(l=s.value[f]).type,value:l.value};switch(r.altNames.push(d),l.type){case 1:case 2:case 6:break;case 7:d.ip=j.util.bytesToIP(l.value);break;case 8:d.oid=t.derToOid(l.value)}}}else"subjectKeyIdentifier"===r.name&&(s=t.fromDer(r.value),r.subjectKeyIdentifier=j.util.bytesToHex(s.value));return r},r.certificationRequestFromAsn1=function(e,a){var i={},o=[];if(!t.validate(e,u,i,o))throw(c=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.")).errors=o,c;if(t.derToOid(i.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=r.createCertificationRequest();if(s.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,s.signatureOid=j.asn1.derToOid(i.csrSignatureOid),s.signatureParameters=f(s.signatureOid,i.csrSignatureParams,!0),s.siginfo.algorithmOid=j.asn1.derToOid(i.csrSignatureOid),s.siginfo.parameters=f(s.siginfo.algorithmOid,i.csrSignatureParams,!1),s.signature=i.csrSignature,s.certificationRequestInfo=i.certificationRequestInfo,a){var c;if(s.md=null,s.signatureOid in n)switch(n[s.signatureOid]){case"sha1WithRSAEncryption":s.md=j.md.sha1.create();break;case"md5WithRSAEncryption":s.md=j.md.md5.create();break;case"sha256WithRSAEncryption":s.md=j.md.sha256.create();break;case"sha384WithRSAEncryption":s.md=j.md.sha384.create();break;case"sha512WithRSAEncryption":s.md=j.md.sha512.create();break;case"RSASSA-PSS":s.md=j.md.sha256.create()}if(null===s.md)throw(c=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=s.signatureOid,c;var d=t.toDer(s.certificationRequestInfo);s.md.update(d.getBytes())}var h=j.md.sha1.create();return s.subject.getField=function(e){return l(s.subject,e)},s.subject.addField=function(e){p([e]),s.subject.attributes.push(e)},s.subject.attributes=r.RDNAttributesAsArray(i.certificationRequestInfoSubject,h),s.subject.hash=h.digest().toHex(),s.publicKey=r.publicKeyFromAsn1(i.subjectPublicKeyInfo),s.getAttribute=function(e){return l(s,e)},s.addAttribute=function(e){p([e]),s.attributes.push(e)},s.attributes=r.CRIAttributesAsArray(i.certificationRequestInfoAttributes||[]),s},r.createCertificationRequest=function(){var e={version:0,signatureOid:null,signature:null,siginfo:{}};return e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return l(e.subject,t)},e.subject.addField=function(t){p([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return l(e,t)},e.addAttribute=function(t){p([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){p(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){p(t),e.attributes=t},e.sign=function(a,i){e.md=i||j.md.sha1.create();var o=n[e.md.algorithm+"WithRSAEncryption"];if(!o){var s=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw s.algorithm=e.md.algorithm,s}e.signatureOid=e.siginfo.algorithmOid=o,e.certificationRequestInfo=r.getCertificationRequestInfo(e);var c=t.toDer(e.certificationRequestInfo);e.md.update(c.getBytes()),e.signature=a.sign(e.md)},e.verify=function(){var a=!1,i=e.md;if(null===i){if(e.signatureOid in n)switch(n[e.signatureOid]){case"sha1WithRSAEncryption":i=j.md.sha1.create();break;case"md5WithRSAEncryption":i=j.md.md5.create();break;case"sha256WithRSAEncryption":i=j.md.sha256.create();break;case"sha384WithRSAEncryption":i=j.md.sha384.create();break;case"sha512WithRSAEncryption":i=j.md.sha512.create();break;case"RSASSA-PSS":i=j.md.sha256.create()}if(null===i)throw(f=new Error("Could not compute certification request digest. Unknown signature OID.")).signatureOid=e.signatureOid,f;var o=e.certificationRequestInfo||r.getCertificationRequestInfo(e),s=t.toDer(o);i.update(s.getBytes())}if(null!==i){var c;switch(e.signatureOid){case n.sha1WithRSAEncryption:break;case n["RSASSA-PSS"]:var u,l,f;if(void 0===(u=n[e.signatureParameters.mgf.hash.algorithmOid])||void 0===j.md[u])throw(f=new Error("Unsupported MGF hash function.")).oid=e.signatureParameters.mgf.hash.algorithmOid,f.name=u,f;if(void 0===(l=n[e.signatureParameters.mgf.algorithmOid])||void 0===j.mgf[l])throw(f=new Error("Unsupported MGF function.")).oid=e.signatureParameters.mgf.algorithmOid,f.name=l,f;if(l=j.mgf[l].create(j.md[u].create()),void 0===(u=n[e.signatureParameters.hash.algorithmOid])||void 0===j.md[u])throw(f=new Error("Unsupported RSASSA-PSS hash function.")).oid=e.signatureParameters.hash.algorithmOid,f.name=u,f;c=j.pss.create(j.md[u].create(),l,e.signatureParameters.saltLength)}a=e.publicKey.verify(i.digest().getBytes(),e.signature,c)}return a},e};var y=new Date("1950-01-01T00:00:00Z"),v=new Date("2050-01-01T00:00:00Z");function b(e){return e>=y&&e<v?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(e)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(e))}r.getTBSCertificate=function(e){var n=b(e.validity.notBefore),a=b(e.validity.notAfter),i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(e.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.siginfo.algorithmOid).getBytes()),g(e.siginfo.algorithmOid,e.siginfo.parameters)]),d(e.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,a]),d(e.subject),r.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&i.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&i.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&i.value.push(r.certificateExtensionsToAsn1(e.extensions)),i},r.getCertificationRequestInfo=function(e){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),d(e.subject),r.publicKeyToAsn1(e.publicKey),m(e)])},r.distinguishedNameToAsn1=function(e){return d(e)},r.certificateToAsn1=function(e){var n=e.tbsCertificate||r.getTBSCertificate(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.certificateExtensionsToAsn1=function(e){var n=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);n.value.push(a);for(var i=0;i<e.length;++i)a.value.push(r.certificateExtensionToAsn1(e[i]));return n},r.certificateExtensionToAsn1=function(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.id).getBytes())),e.critical&&r.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255)));var n=e.value;return"string"!=typeof e.value&&(n=t.toDer(n).getBytes()),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)),r},r.certificationRequestToAsn1=function(e){var n=e.certificationRequestInfo||r.getCertificationRequestInfo(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),g(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.createCaStore=function(e){var n={certs:{}};function a(e){return i(e),n.certs[e.hash]||null}function i(e){if(!e.hash){var t=j.md.sha1.create();e.attributes=r.RDNAttributesAsArray(d(e),t),e.hash=t.digest().toHex()}}if(n.getIssuer=function(e){return a(e.issuer)},n.addCertificate=function(e){if("string"==typeof e&&(e=j.pki.certificateFromPem(e)),i(e.subject),!n.hasCertificate(e))if(e.subject.hash in n.certs){var t=n.certs[e.subject.hash];j.util.isArray(t)||(t=[t]),t.push(e),n.certs[e.subject.hash]=t}else n.certs[e.subject.hash]=e},n.hasCertificate=function(e){"string"==typeof e&&(e=j.pki.certificateFromPem(e));var n=a(e.subject);if(!n)return!1;j.util.isArray(n)||(n=[n]);for(var i=t.toDer(r.certificateToAsn1(e)).getBytes(),o=0;o<n.length;++o)if(i===t.toDer(r.certificateToAsn1(n[o])).getBytes())return!0;return!1},n.listAllCertificates=function(){var e=[];for(var t in n.certs)if(n.certs.hasOwnProperty(t)){var r=n.certs[t];if(j.util.isArray(r))for(var a=0;a<r.length;++a)e.push(r[a]);else e.push(r)}return e},n.removeCertificate=function(e){var o;if("string"==typeof e&&(e=j.pki.certificateFromPem(e)),i(e.subject),!n.hasCertificate(e))return null;var s=a(e.subject);if(!j.util.isArray(s))return o=n.certs[e.subject.hash],delete n.certs[e.subject.hash],o;for(var c=t.toDer(r.certificateToAsn1(e)).getBytes(),u=0;u<s.length;++u)c===t.toDer(r.certificateToAsn1(s[u])).getBytes()&&(o=s[u],s.splice(u,1));return 0===s.length&&delete n.certs[e.subject.hash],o},e)for(var o=0;o<e.length;++o){var s=e[o];n.addCertificate(s)}return n},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(e,t,n){"function"==typeof n&&(n={verify:n}),n=n||{};var a=(t=t.slice(0)).slice(0),i=n.validityCheckDate;void 0===i&&(i=new Date);var o=!0,s=null,c=0;do{var u=t.shift(),l=null,f=!1;if(i&&(i<u.validity.notBefore||i>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:i}),null===s){if(null===(l=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(f=!0,l=u),l){var d=l;j.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){l=d.shift();try{p=l.verify(u)}catch(e){}}p||(s={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==s||l&&!f||e.hasCertificate(u)||(s={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(null===s&&l&&!u.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),null===s)for(var h={keyUsage:!0,basicConstraints:!0},g=0;null===s&&g<u.extensions.length;++g){var m=u.extensions[g];!m.critical||m.name in h||(s={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(null===s&&(!o||0===t.length&&(!l||f))){var y=u.getExtension("basicConstraints"),v=u.getExtension("keyUsage");null!==v&&(v.keyCertSign&&null!==y||(s={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:r.certificateError.bad_certificate})),null!==s||null===y||y.cA||(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===s&&null!==v&&"pathLenConstraint"in y&&c-1>y.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}var b=null===s||s.error,C=n.verify?n.verify(b,c,a):b;if(!0!==C)throw!0===b&&(s={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(C||0===C)&&("object"!=typeof C||j.util.isArray(C)?"string"==typeof C&&(s.error=C):(C.message&&(s.message=C.message),C.error&&(s.error=C.error))),s;s=null,o=!1,++c}while(t.length>0);return!0}})),E((function(e){var t=j.asn1,r=j.pki,n=e.exports=j.pkcs12=j.pkcs12||{},a={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},i={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},a,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},o={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},s={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},c={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function u(e,t,r,n){for(var a=[],i=0;i<e.length;i++)for(var o=0;o<e[i].safeBags.length;o++){var s=e[i].safeBags[o];void 0!==n&&s.type!==n||(null!==t?void 0!==s.attributes[t]&&s.attributes[t].indexOf(r)>=0&&a.push(s):a.push(s))}return a}function l(e){if(e.composed||e.constructed){for(var t=j.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function f(e,n){var a={},i=[];if(!t.validate(e,j.pkcs7.asn1.encryptedDataValidator,a,i))throw(o=new Error("Cannot read EncryptedContentInfo.")).errors=i,o;var o,s=t.derToOid(a.contentType);if(s!==r.oids.data)throw(o=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=s,o;s=t.derToOid(a.encAlgorithm);var c=r.pbe.getCipher(s,a.encParameter,n),u=l(a.encryptedContentAsn1),f=j.util.createBuffer(u.value);if(c.update(f),!c.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return c.output.getBytes()}function d(e,n,a){if(!n&&0===e.length)return[];if((e=t.fromDer(e,n)).tagClass!==t.Class.UNIVERSAL||e.type!==t.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var i=[],s=0;s<e.value.length;s++){var u=e.value[s],l={},f=[];if(!t.validate(u,o,l,f))throw(y=new Error("Cannot read SafeBag.")).errors=f,y;var d,h,g={type:t.derToOid(l.bagId),attributes:p(l.bagAttributes)};i.push(g);var m=l.bagValue.value[0];switch(g.type){case r.oids.pkcs8ShroudedKeyBag:if(null===(m=r.decryptPrivateKeyInfo(m,a)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{g.key=r.privateKeyFromAsn1(m)}catch(e){g.key=null,g.asn1=m}continue;case r.oids.certBag:d=c,h=function(){if(t.derToOid(l.certId)!==r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=t.derToOid(l.certId),e}var a=t.fromDer(l.cert,n);try{g.cert=r.certificateFromAsn1(a,!0)}catch(e){g.cert=null,g.asn1=a}};break;default:var y;throw(y=new Error("Unsupported PKCS#12 SafeBag type.")).oid=g.type,y}if(void 0!==d&&!t.validate(m,d,l,f))throw(y=new Error("Cannot read PKCS#12 "+d.name)).errors=f,y;h()}return i}function p(e){var n={};if(void 0!==e)for(var a=0;a<e.length;++a){var i={},o=[];if(!t.validate(e[a],s,i,o)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=o,c}var u=t.derToOid(i.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<i.values.length;++l)n[r.oids[u]].push(i.values[l].value)}}return n}n.pkcs12FromAsn1=function(e,o,s){"string"==typeof o?(s=o,o=!0):void 0===o&&(o=!0);var c={};if(!t.validate(e,i,c,[]))throw(p=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=p,p;var p,h={version:c.version.charCodeAt(0),safeContents:[],getBags:function(e){var t,r={};return"localKeyId"in e?t=e.localKeyId:"localKeyIdHex"in e&&(t=j.util.hexToBytes(e.localKeyIdHex)),void 0===t&&!("friendlyName"in e)&&"bagType"in e&&(r[e.bagType]=u(h.safeContents,null,null,e.bagType)),void 0!==t&&(r.localKeyId=u(h.safeContents,"localKeyId",t,e.bagType)),"friendlyName"in e&&(r.friendlyName=u(h.safeContents,"friendlyName",e.friendlyName,e.bagType)),r},getBagsByFriendlyName:function(e,t){return u(h.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return u(h.safeContents,"localKeyId",e,t)}};if(3!==c.version.charCodeAt(0))throw(p=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=c.version.charCodeAt(0),p;if(t.derToOid(c.contentType)!==r.oids.data)throw(p=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=t.derToOid(c.contentType),p;var g=c.content.value[0];if(g.tagClass!==t.Class.UNIVERSAL||g.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(g=l(g),c.mac){var m=null,y=0,v=t.derToOid(c.macAlgorithm);switch(v){case r.oids.sha1:m=j.md.sha1.create(),y=20;break;case r.oids.sha256:m=j.md.sha256.create(),y=32;break;case r.oids.sha384:m=j.md.sha384.create(),y=48;break;case r.oids.sha512:m=j.md.sha512.create(),y=64;break;case r.oids.md5:m=j.md.md5.create(),y=16}if(null===m)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+v);var b=new j.util.ByteBuffer(c.macSalt),C="macIterations"in c?parseInt(j.util.bytesToHex(c.macIterations),16):1,E=n.generateKey(s,b,3,C,y,m),w=j.hmac.create();if(w.start(m,E),w.update(g.value),w.getMac().getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,i,o){if((n=t.fromDer(n,i)).tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||!0!==n.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var s=0;s<n.value.length;s++){var c=n.value[s],u={},p=[];if(!t.validate(c,a,u,p))throw(y=new Error("Cannot read ContentInfo.")).errors=p,y;var h={encrypted:!1},g=null,m=u.content.value[0];switch(t.derToOid(u.contentType)){case r.oids.data:if(m.tagClass!==t.Class.UNIVERSAL||m.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");g=l(m).value;break;case r.oids.encryptedData:g=f(m,o),h.encrypted=!0;break;default:var y;throw(y=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),y}h.safeBags=d(g,i,o),e.safeContents.push(h)}}(h,g.value,o,s),h},n.toPkcs12Asn1=function(e,a,i,o){(o=o||{}).saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128","useMac"in o||(o.useMac=!0),"localKeyId"in o||(o.localKeyId=null),"generateLocalKeyId"in o||(o.generateLocalKeyId=!0);var s,c=o.localKeyId;if(null!==c)c=j.util.hexToBytes(c);else if(o.generateLocalKeyId)if(a){var u=j.util.isArray(a)?a[0]:a;"string"==typeof u&&(u=r.certificateFromPem(u)),(A=j.md.sha1.create()).update(t.toDer(r.certificateToAsn1(u)).getBytes()),c=A.digest().getBytes()}else c=j.random.getBytes(20);var l=[];null!==c&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,c)])])),"friendlyName"in o&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),l.length>0&&(s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l));var f=[],d=[];null!==a&&(d=j.util.isArray(a)?a:[a]);for(var p=[],h=0;h<d.length;++h){"string"==typeof(a=d[h])&&(a=r.certificateFromPem(a));var g=0===h?s:void 0,m=r.certificateToAsn1(a),y=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(m).getBytes())])])]),g]);p.push(y)}if(p.length>0){var v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,p),b=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(v).getBytes())])]);f.push(b)}var C=null;if(null!==e){var E=r.wrapRsaPrivateKey(r.privateKeyToAsn1(e));C=null===i?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[E]),s]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(E,i,o)]),s]);var w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[C]),k=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(w).getBytes())])]);f.push(k)}var S,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,f);if(o.useMac){var A=j.md.sha1.create(),T=new j.util.ByteBuffer(j.random.getBytes(o.saltSize)),I=o.count,_=(e=n.generateKey(i,T,3,I,20),j.hmac.create());_.start(A,e),_.update(t.toDer(B).getBytes());var x=_.getMac();S=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,x.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,T.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(I).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(B).getBytes())])]),S])},n.generateKey=j.pbe.generatePkcs12Key})),E((function(e){var t=j.asn1,r=e.exports=j.pki=j.pki||{};r.pemToDer=function(e){var t=j.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return j.util.createBuffer(t.body)},r.privateKeyFromPem=function(e){var n=j.pem.decode(e)[0];if("PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.privateKeyFromAsn1(i)},r.privateKeyToPem=function(e,n){var a={type:"RSA PRIVATE KEY",body:t.toDer(r.privateKeyToAsn1(e)).getBytes()};return j.pem.encode(a,{maxline:n})},r.privateKeyInfoToPem=function(e,r){var n={type:"PRIVATE KEY",body:t.toDer(e).getBytes()};return j.pem.encode(n,{maxline:r})}}));var St=function(e,t,r,n){var a=j.util.createBuffer(),i=e.length>>1,o=i+(1&e.length),s=e.substr(0,o),c=e.substr(i,o),u=j.util.createBuffer(),l=j.hmac.create();r=t+r;var f=Math.ceil(n/16),d=Math.ceil(n/20);l.start("MD5",s);var p=j.util.createBuffer();u.putBytes(r);for(var h=0;h<f;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),p.putBuffer(l.digest());l.start("SHA1",c);var g=j.util.createBuffer();for(u.clear(),u.putBytes(r),h=0;h<d;++h)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),g.putBuffer(l.digest());return a.putBytes(j.util.xorBytes(p.getBytes(),g.getBytes(),n)),a},Bt=function(e,t,r){var n=!1;try{var a=e.deflate(t.fragment.getBytes());t.fragment=j.util.createBuffer(a),t.length=a.length,n=!0}catch(e){}return n},At=function(e,t,r){var n=!1;try{var a=e.inflate(t.fragment.getBytes());t.fragment=j.util.createBuffer(a),t.length=a.length,n=!0}catch(e){}return n},Tt=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32()}return j.util.createBuffer(e.getBytes(r))},It=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},_t={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};_t.SupportedVersions=[_t.Versions.TLS_1_1,_t.Versions.TLS_1_0],_t.Version=_t.SupportedVersions[0],_t.MaxFragment=15360,_t.ConnectionEnd={server:0,client:1},_t.PRFAlgorithm={tls_prf_sha256:0},_t.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},_t.CipherType={stream:0,block:1,aead:2},_t.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},_t.CompressionMethod={none:0,deflate:1},_t.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},_t.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},_t.Alert={},_t.Alert.Level={warning:1,fatal:2},_t.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},_t.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},_t.CipherSuites={},_t.getCipherSuite=function(e){var t=null;for(var r in _t.CipherSuites){var n=_t.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},_t.handleUnexpected=function(e,t){!e.open&&e.entity===_t.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})},_t.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(_t.queue(e,_t.createAlert(e,{level:_t.Alert.Level.warning,description:_t.Alert.Description.no_renegotiation})),_t.flush(e)),e.process()},_t.parseHelloMessage=function(e,t,r){var n=null,a=e.entity===_t.ConnectionEnd.client;if(r<38)e.error(e,{message:a?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});else{var i=t.fragment,o=i.length();if(n={version:{major:i.getByte(),minor:i.getByte()},random:j.util.createBuffer(i.getBytes(32)),session_id:Tt(i,1),extensions:[]},a?(n.cipher_suite=i.getBytes(2),n.compression_method=i.getByte()):(n.cipher_suites=Tt(i,2),n.compression_methods=Tt(i,1)),(o=r-(o-i.length()))>0){for(var s=Tt(i,2);s.length()>0;)n.extensions.push({type:[s.getByte(),s.getByte()],data:Tt(s,2)});if(!a)for(var c=0;c<n.extensions.length;++c){var u=n.extensions[c];if(0===u.type[0]&&0===u.type[1])for(var l=Tt(u.data,2);l.length()>0&&0===l.getByte();)e.session.extensions.server_name.serverNameList.push(Tt(l,2).getBytes())}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});if(a)e.session.cipherSuite=_t.getCipherSuite(n.cipher_suite);else for(var f=j.util.createBuffer(n.cipher_suites.bytes());f.length()>0&&(e.session.cipherSuite=_t.getCipherSuite(f.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure},cipherSuite:j.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=a?n.compression_method:_t.CompressionMethod.none}return n},_t.createSecurityParameters=function(e,t){var r=e.entity===_t.ConnectionEnd.client,n=t.random.bytes(),a=r?e.session.sp.client_random:n,i=r?n:_t.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:_t.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:a,server_random:i}},_t.handleServerHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var a=n.session_id.bytes();a.length>0&&a===e.session.id?(e.expect=Lt,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=xt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.session.id=a,e.process()}},_t.handleClientHello=function(e,t,r){var n=_t.parseHelloMessage(e,t,r);if(!e.fail){var a=n.session_id.bytes(),i=null;if(e.sessionCache&&(null===(i=e.sessionCache.getSession(a))?a="":(i.version.major!==n.version.major||i.version.minor>n.version.minor)&&(i=null,a="")),0===a.length&&(a=j.random.getBytes(32)),e.session.id=a,e.session.clientHelloVersion=n.version,e.session.sp={},i)e.version=e.session.version=i.version,e.session.sp=i.sp;else{for(var o,s=1;s<_t.SupportedVersions.length&&!((o=_t.SupportedVersions[s]).minor<=n.version.minor);++s);e.version={major:o.major,minor:o.minor},e.session.version=e.version}null!==i?(e.expect=jt,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=!1!==e.verifyClient?Mt:Vt,e.session.resuming=!1,_t.createSecurityParameters(e,n)),e.open=!0,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHello(e)})),e.session.resuming?(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))):(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)})),e.fail||(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerKeyExchange(e)})),!1!==e.verifyClient&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateRequest(e)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createServerHelloDone(e)})))),_t.flush(e),e.process()}},_t.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n,a,i=t.fragment,o={certificate_list:Tt(i,3)},s=[];try{for(;o.certificate_list.length()>0;)n=Tt(o.certificate_list,3),a=j.asn1.fromDer(n),n=j.pki.certificateFromAsn1(a,!0),s.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var c=e.entity===_t.ConnectionEnd.client;!c&&!0!==e.verifyClient||0!==s.length?0===s.length?e.expect=c?Pt:Vt:(c?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],_t.verifyCertificateChain(e,s)&&(e.expect=c?Pt:Vt)):e.error(e,{message:c?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}}),e.process()},_t.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});e.expect=Rt,e.process()},_t.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unsupported_certificate}});var n=t.fragment,a={enc_pre_master_secret:Tt(n,2).getBytes()},i=null;if(e.getPrivateKey)try{i=e.getPrivateKey(e,e.session.serverCertificate),i=j.pki.privateKeyFromPem(i)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}if(null===i)return e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}});try{var o=e.session.sp;o.pre_master_secret=i.decrypt(a.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==o.pre_master_secret.charCodeAt(0)||s.minor!==o.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){o.pre_master_secret=j.random.getBytes(48)}e.expect=jt,null!==e.session.clientCertificate&&(e.expect=Ft),e.process()},_t.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment,a={certificate_types:Tt(n,1),certificate_authorities:Tt(n,2)};e.session.certificateRequest=a,e.expect=Nt,e.process()},_t.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var i={signature:Tt(n,2).getBytes()},o=j.util.createBuffer();o.putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest()),o=o.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(o,i.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(a),e.session.sha1.update(a)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.handshake_failure}})}e.expect=jt,e.process()},_t.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.insufficient_security}},a=e.verify(e,n.alert.description,0,[]);if(!0!==a)return(a||0===a)&&("object"!=typeof a||j.util.isArray(a)?"number"==typeof a&&(n.alert.description=a):(a.message&&(n.message=a.message),a.alert&&(n.alert.description=a.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificate(e)}),_t.queue(e,t)),t=_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createClientKeyExchange(e)}),_t.queue(e,t),e.expect=Ut;var i=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createCertificateVerify(e,t)})),_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.pending=_t.createConnectionState(e),e.state.current.write=e.state.pending.write,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)})),e.expect=Lt,_t.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return i(e,null);_t.getClientSignature(e,i)},_t.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.illegal_parameter}});var r=e.entity===_t.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=_t.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?Ot:Kt,e.process()},_t.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var i=t.fragment.getBytes();(n=j.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var o=e.entity===_t.ConnectionEnd.client,s=o?"server finished":"client finished",c=e.session.sp;if((n=St(c.master_secret,s,n.getBytes(),12)).getBytes()!==i)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decrypt_error}});e.session.md5.update(a),e.session.sha1.update(a),(e.session.resuming&&o||!e.session.resuming&&!o)&&(_t.queue(e,_t.createRecord(e,{type:_t.ContentType.change_cipher_spec,data:_t.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,_t.queue(e,_t.createRecord(e,{type:_t.ContentType.handshake,data:_t.createFinished(e)}))),e.expect=o?Dt:zt,e.handshaking=!1,++e.handshakes,e.peerCertificate=o?e.session.serverCertificate:e.session.clientCertificate,_t.flush(e),e.isConnected=!0,e.connected(e),e.process()},_t.handleAlert=function(e,t){var r,n=t.fragment,a={level:n.getByte(),description:n.getByte()};switch(a.description){case _t.Alert.Description.close_notify:r="Connection closed.";break;case _t.Alert.Description.unexpected_message:r="Unexpected message.";break;case _t.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case _t.Alert.Description.decryption_failed:r="Decryption failed.";break;case _t.Alert.Description.record_overflow:r="Record overflow.";break;case _t.Alert.Description.decompression_failure:r="Decompression failed.";break;case _t.Alert.Description.handshake_failure:r="Handshake failure.";break;case _t.Alert.Description.bad_certificate:r="Bad certificate.";break;case _t.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case _t.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case _t.Alert.Description.certificate_expired:r="Certificate expired.";break;case _t.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case _t.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case _t.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case _t.Alert.Description.access_denied:r="Access denied.";break;case _t.Alert.Description.decode_error:r="Decode error.";break;case _t.Alert.Description.decrypt_error:r="Decrypt error.";break;case _t.Alert.Description.export_restriction:r="Export restriction.";break;case _t.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case _t.Alert.Description.insufficient_security:r="Insufficient security.";break;case _t.Alert.Description.internal_error:r="Internal error.";break;case _t.Alert.Description.user_canceled:r="User canceled.";break;case _t.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(a.description===_t.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===_t.ConnectionEnd.client?"server":"client",alert:a}),e.process()},_t.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt24();if(a>r.length())return e.fragmented=t,t.fragment=j.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var i=r.bytes(a+4);r.read+=4,n in ar[e.entity][e.expect]?(e.entity!==_t.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:j.md.md5.create(),sha1:j.md.sha1.create()}),n!==_t.HandshakeType.hello_request&&n!==_t.HandshakeType.certificate_verify&&n!==_t.HandshakeType.finished&&(e.session.md5.update(i),e.session.sha1.update(i)),ar[e.entity][e.expect][n](e,t,a)):_t.handleUnexpected(e,t)},_t.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},_t.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt16(),i=r.getBytes(a);if(n===_t.HeartbeatMessageType.heartbeat_request){if(e.handshaking||a>i.length)return e.process();_t.queue(e,_t.createRecord(e,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_response,i)})),_t.flush(e)}else if(n===_t.HeartbeatMessageType.heartbeat_response){if(i!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,j.util.createBuffer(i))}e.process()};var xt=1,Pt=2,Rt=3,Nt=4,Lt=5,Ot=6,Dt=7,Ut=8,Mt=1,Vt=2,Ft=3,jt=4,Kt=5,zt=6,qt=_t.handleUnexpected,Ht=_t.handleChangeCipherSpec,Gt=_t.handleAlert,Qt=_t.handleHandshake,Wt=_t.handleApplicationData,Xt=_t.handleHeartbeat,Yt=[];Yt[_t.ConnectionEnd.client]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]],Yt[_t.ConnectionEnd.server]=[[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[Ht,Gt,qt,qt,Xt],[qt,Gt,Qt,qt,Xt],[qt,Gt,Qt,Wt,Xt],[qt,Gt,Qt,qt,Xt]];var $t=_t.handleHelloRequest,Zt=_t.handleServerHello,Jt=_t.handleCertificate,er=_t.handleServerKeyExchange,tr=_t.handleCertificateRequest,rr=_t.handleServerHelloDone,nr=_t.handleFinished,ar=[];ar[_t.ConnectionEnd.client]=[[qt,qt,Zt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,er,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,tr,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,rr,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[$t,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]];var ir=_t.handleClientHello,or=_t.handleClientKeyExchange,sr=_t.handleCertificateVerify;ar[_t.ConnectionEnd.server]=[[qt,ir,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,Jt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,or,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,sr,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,nr],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt],[qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt,qt]],_t.generateKeys=function(e,t){var r=St,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var a=2*t.mac_key_length+2*t.enc_key_length,i=e.version.major===_t.Versions.TLS_1_0.major&&e.version.minor===_t.Versions.TLS_1_0.minor;i&&(a+=2*t.fixed_iv_length);var o=r(t.master_secret,"key expansion",n,a),s={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return i&&(s.client_write_IV=o.getBytes(t.fixed_iv_length),s.server_write_IV=o.getBytes(t.fixed_iv_length)),s},_t.createConnectionState=function(e){var t=e.entity===_t.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}),!e.fail},e.session){var a=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(a),a.keys=_t.generateKeys(e,a),n.read.macKey=t?a.keys.server_write_MAC_key:a.keys.client_write_MAC_key,n.write.macKey=t?a.keys.client_write_MAC_key:a.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,a),a.compression_algorithm){case _t.CompressionMethod.none:break;case _t.CompressionMethod.deflate:n.read.compressFunction=At,n.write.compressFunction=Bt;break;default:throw new Error("Unsupported compression algorithm.")}}return n},_t.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=j.util.createBuffer();return r.putInt32(t),r.putBytes(j.random.getBytes(28)),r},_t.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},_t.createAlert=function(e,t){var r=j.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),_t.createRecord(e,{type:_t.ContentType.alert,data:r})},_t.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=j.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var a=t.length(),i=j.util.createBuffer();i.putByte(_t.CompressionMethod.none);var o=i.length(),s=j.util.createBuffer();if(e.virtualHost){var c=j.util.createBuffer();c.putByte(0),c.putByte(0);var u=j.util.createBuffer();u.putByte(0),It(u,2,j.util.createBuffer(e.virtualHost));var l=j.util.createBuffer();It(l,2,u),It(c,2,l),s.putBuffer(c)}var f=s.length();f>0&&(f+=2);var d=e.session.id,p=d.length+1+2+4+28+2+a+1+o+f,h=j.util.createBuffer();return h.putByte(_t.HandshakeType.client_hello),h.putInt24(p),h.putByte(e.version.major),h.putByte(e.version.minor),h.putBytes(e.session.sp.client_random),It(h,1,j.util.createBuffer(d)),It(h,2,t),It(h,1,i),f>0&&It(h,2,s),h},_t.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=j.util.createBuffer();return n.putByte(_t.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),It(n,1,j.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},_t.createCertificate=function(e){var t,r=e.entity===_t.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var a=j.util.createBuffer();if(null!==n)try{j.util.isArray(n)||(n=[n]);for(var i=null,o=0;o<n.length;++o){var s=j.pem.decode(n[o])[0];if("CERTIFICATE"!==s.type&&"X509 CERTIFICATE"!==s.type&&"TRUSTED CERTIFICATE"!==s.type){var c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=s.type,c}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var u=j.util.createBuffer(s.body);null===i&&(i=j.asn1.fromDer(u.bytes(),!1));var l=j.util.createBuffer();It(l,3,u),a.putBuffer(l)}n=j.pki.certificateFromAsn1(i),r?e.session.clientCertificate=n:e.session.serverCertificate=n}catch(t){return e.error(e,{message:"Could not send certificate list.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate}})}var f=3+a.length(),d=j.util.createBuffer();return d.putByte(_t.HandshakeType.certificate),d.putInt24(f),It(d,3,a),d},_t.createClientKeyExchange=function(e){var t=j.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(j.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=(t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret)).length+2,a=j.util.createBuffer();return a.putByte(_t.HandshakeType.client_key_exchange),a.putInt24(n),a.putInt16(t.length),a.putBytes(t),a},_t.createServerKeyExchange=function(e){return j.util.createBuffer()},_t.getClientSignature=function(e,t){var r=j.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var n=null;if(e.getPrivateKey)try{n=e.getPrivateKey(e,e.session.clientCertificate),n=j.pki.privateKeyFromPem(n)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}})}null===n?e.error(e,{message:"No private key set.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.internal_error}}):t=n.sign(t,null),r(e,t)},e.getSignature(e,r,t)},_t.createCertificateVerify=function(e,t){var r=t.length+2,n=j.util.createBuffer();return n.putByte(_t.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n},_t.createCertificateRequest=function(e){var t=j.util.createBuffer();t.putByte(1);var r=j.util.createBuffer();for(var n in e.caStore.certs){var a=e.caStore.certs[n],i=j.pki.distinguishedNameToAsn1(a.subject),o=j.asn1.toDer(i);r.putInt16(o.length()),r.putBuffer(o)}var s=1+t.length()+2+r.length(),c=j.util.createBuffer();return c.putByte(_t.HandshakeType.certificate_request),c.putInt24(s),It(c,1,t),It(c,2,r),c},_t.createServerHelloDone=function(e){var t=j.util.createBuffer();return t.putByte(_t.HandshakeType.server_hello_done),t.putInt24(0),t},_t.createChangeCipherSpec=function(){var e=j.util.createBuffer();return e.putByte(1),e},_t.createFinished=function(e){var t=j.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===_t.ConnectionEnd.client,n=e.session.sp,a=r?"client finished":"server finished";t=St(n.master_secret,a,t.getBytes(),12);var i=j.util.createBuffer();return i.putByte(_t.HandshakeType.finished),i.putInt24(t.length()),i.putBuffer(t),i},_t.createHeartbeat=function(e,t,r){void 0===r&&(r=t.length);var n=j.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var a=n.length(),i=Math.max(16,a-r-3);return n.putBytes(j.random.getBytes(i)),n},_t.queue=function(e,t){if(t&&(0!==t.fragment.length()||t.type!==_t.ContentType.handshake&&t.type!==_t.ContentType.alert&&t.type!==_t.ContentType.change_cipher_spec)){if(t.type===_t.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=_t.MaxFragment)n=[t];else{n=[];for(var a=t.fragment.bytes();a.length>_t.MaxFragment;)n.push(_t.createRecord(e,{type:t.type,data:j.util.createBuffer(a.slice(0,_t.MaxFragment))})),a=a.slice(_t.MaxFragment);a.length>0&&n.push(_t.createRecord(e,{type:t.type,data:j.util.createBuffer(a)}))}for(var i=0;i<n.length&&!e.fail;++i){var o=n[i];e.state.current.write.update(e,o)&&e.records.push(o)}}},_t.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var cr=function(e){switch(e){case!0:return!0;case j.pki.certificateError.bad_certificate:return _t.Alert.Description.bad_certificate;case j.pki.certificateError.unsupported_certificate:return _t.Alert.Description.unsupported_certificate;case j.pki.certificateError.certificate_revoked:return _t.Alert.Description.certificate_revoked;case j.pki.certificateError.certificate_expired:return _t.Alert.Description.certificate_expired;case j.pki.certificateError.certificate_unknown:return _t.Alert.Description.certificate_unknown;case j.pki.certificateError.unknown_ca:return _t.Alert.Description.unknown_ca;default:return _t.Alert.Description.bad_certificate}};for(var ur in _t.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(t,r,n){cr(t);var a=e.verify(e,t,r,n);if(!0!==a){if("object"==typeof a&&!j.util.isArray(a)){var i=new Error("The application rejected the certificate.");throw i.send=!0,i.alert={level:_t.Alert.Level.fatal,description:_t.Alert.Description.bad_certificate},a.message&&(i.message=a.message),a.alert&&(i.alert.description=a.alert),i}a!==t&&(a=function(e){switch(e){case!0:return!0;case _t.Alert.Description.bad_certificate:return j.pki.certificateError.bad_certificate;case _t.Alert.Description.unsupported_certificate:return j.pki.certificateError.unsupported_certificate;case _t.Alert.Description.certificate_revoked:return j.pki.certificateError.certificate_revoked;case _t.Alert.Description.certificate_expired:return j.pki.certificateError.certificate_expired;case _t.Alert.Description.certificate_unknown:return j.pki.certificateError.certificate_unknown;case _t.Alert.Description.unknown_ca:return j.pki.certificateError.unknown_ca;default:return j.pki.certificateError.bad_certificate}}(a))}return a},j.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var a=t;("object"!=typeof a||j.util.isArray(a))&&(a={send:!0,alert:{level:_t.Alert.Level.fatal,description:cr(t)}}),"send"in a||(a.send=!0),"alert"in a||(a.alert={level:_t.Alert.Level.fatal,description:cr(a.error)}),e.error(e,a)}return!e.fail},_t.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var n in(r={}).cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(e){var t=null,n=null;if(e?n=j.util.bytesToHex(e):r.order.length>0&&(n=r.order[0]),null!==n&&n in r.cache)for(var a in t=r.cache[n],delete r.cache[n],r.order)if(r.order[a]===n){r.order.splice(a,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=j.util.bytesToHex(e),r.order.push(n),r.cache[n]=t}}return r},_t.createConnection=function(e){var t=null;t=e.caStore?j.util.isArray(e.caStore)?j.pki.createCaStore(e.caStore):e.caStore:j.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],_t.CipherSuites)r.push(_t.CipherSuites[n]);var a=e.server?_t.ConnectionEnd.server:_t.ConnectionEnd.client,i=e.sessionCache?_t.createSessionCache(e.sessionCache):null,o={version:{major:_t.Version.major,minor:_t.Version.minor},entity:a,sessionId:e.sessionId,caStore:t,sessionCache:i,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:j.util.createBuffer(),tlsData:j.util.createBuffer(),data:j.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===_t.ConnectionEnd.client?"client":"server"),r.send&&(_t.queue(t,_t.createAlert(t,r.alert)),_t.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:_t.Version.major,minor:_t.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(_t.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=_t.createConnectionState(o)}};return o.reset(),o.handshake=function(e){if(o.entity!==_t.ConnectionEnd.client)o.error(o,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(o.handshaking)o.error(o,{message:"Handshake already in progress.",fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||"").length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:j.md.md5.create(),sha1:j.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=_t.createRandom().getBytes(),o.open=!0,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.handshake,data:_t.createClientHello(o)})),_t.flush(o)}},o.process=function(e){var t=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:j.util.createBuffer(),ready:!1};var a=e.record.version.major===e.version.major;a&&e.session&&e.session.version&&(a=e.record.version.minor===e.version.minor),a||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:_t.Alert.Level.fatal,description:_t.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(o)),!o.fail&&null!==o.record&&o.record.ready&&function(e,t){var r=t.type-_t.ContentType.change_cipher_spec,n=Yt[e.entity][e.expect];r in n?n[r](e,t):_t.handleUnexpected(e,t)}(o,o.record)),t},o.prepare=function(e){return _t.queue(o,_t.createRecord(o,{type:_t.ContentType.application_data,data:j.util.createBuffer(e)})),_t.flush(o)},o.prepareHeartbeatRequest=function(e,t){return e instanceof j.util.ByteBuffer&&(e=e.bytes()),void 0===t&&(t=e.length),o.expectedHeartbeatPayload=e,_t.queue(o,_t.createRecord(o,{type:_t.ContentType.heartbeat,data:_t.createHeartbeat(_t.HeartbeatMessageType.heartbeat_request,e,t)})),_t.flush(o)},o.close=function(e){if(!o.fail&&o.sessionCache&&o.session){var t={id:o.session.id,version:o.session.version,sp:o.session.sp};t.sp.keys=null,o.sessionCache.setSession(t.id,t)}o.open&&(o.open=!1,o.input.clear(),(o.isConnected||o.handshaking)&&(o.isConnected=o.handshaking=!1,_t.queue(o,_t.createAlert(o,{level:_t.Alert.Level.warning,description:_t.Alert.Description.close_notify})),_t.flush(o)),o.closed(o)),o.reset(e)},o},j.tls=j.tls||{},_t)"function"!=typeof _t[ur]&&(j.tls[ur]=_t[ur]);j.tls.prf_tls1=St,j.tls.hmac_sha1=function(e,t,r){var n=j.hmac.create();n.start("SHA1",e);var a=j.util.createBuffer();return a.putInt32(t[0]),a.putInt32(t[1]),a.putByte(r.type),a.putByte(r.version.major),a.putByte(r.version.minor),a.putInt16(r.length),a.putBytes(r.fragment.bytes()),n.update(a.getBytes()),n.digest().getBytes()},j.tls.createSessionCache=_t.createSessionCache,j.tls.createConnection=_t.createConnection,E((function(e){var t=e.exports=j.tls;function r(e,r,a){var i=r.entity===j.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:j.cipher.createDecipher("AES-CBC",i?a.keys.server_write_key:a.keys.client_write_key),iv:i?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:j.cipher.createCipher("AES-CBC",i?a.keys.client_write_key:a.keys.server_write_key),iv:i?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=o,e.write.cipherFunction=n,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=t.hmac_sha1}function n(e,r){var n,i=!1,o=r.macFunction(r.macKey,r.sequenceNumber,e);e.fragment.putBytes(o),r.updateSequenceNumber(),n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:j.random.getBytesSync(16),r.cipherState.init=!0;var s=r.cipherState.cipher;return s.start({iv:n}),e.version.minor>=t.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(a)&&(e.fragment=s.output,e.length=e.fragment.length(),i=!0),i}function a(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function i(e,t,r){var n=!0;if(r){for(var a=t.length(),i=t.last(),o=a-1-i;o<a-1;++o)n=n&&t.at(o)==i;n&&t.truncate(i+1)}return n}function o(e,r){var n,a=!1;n=e.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:e.fragment.getBytes(16),r.cipherState.init=!0;var o=r.cipherState.cipher;o.start({iv:n}),o.update(e.fragment),a=o.finish(i);var s=r.macLength,c=j.random.getBytesSync(s),u=o.output.length();u>=s?(e.fragment=o.output.getBytes(u-s),c=o.output.getBytes(s)):e.fragment=o.output.getBytes(),e.fragment=j.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=r.macFunction(r.macKey,r.sequenceNumber,e);return r.updateSequenceNumber(),function(e,t,r){var n=j.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),t===(r=n.digest().getBytes())}(r.macKey,c,l)&&a}t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r}})),j.debug=j.debug||{},j.debug.storage={},j.debug.get=function(e,t){var r;return void 0===e?r=j.debug.storage:e in j.debug.storage&&(r=void 0===t?j.debug.storage[e]:j.debug.storage[e][t]),r},j.debug.set=function(e,t,r){e in j.debug.storage||(j.debug.storage[e]={}),j.debug.storage[e][t]=r},j.debug.clear=function(e,t){void 0===e?j.debug.storage={}:e in j.debug.storage&&(void 0===t?delete j.debug.storage[e]:delete j.debug.storage[e][t])},E((function(e){var t=e.exports=j.sha512=j.sha512||{};j.md.sha512=j.md.algorithms.sha512=t;var r=j.sha384=j.sha512.sha384=j.sha512.sha384||{};r.create=function(){return t.create("SHA-384")},j.md.sha384=j.md.algorithms.sha384=r,j.sha512.sha256=j.sha512.sha256||{create:function(){return t.create("SHA-512/256")}},j.md["sha512/256"]=j.md.algorithms["sha512/256"]=j.sha512.sha256,j.sha512.sha224=j.sha512.sha224||{create:function(){return t.create("SHA-512/224")}},j.md["sha512/224"]=j.md.algorithms["sha512/224"]=j.sha512.sha224,t.create=function(e){if(a||(n=String.fromCharCode(128),n+=j.util.fillString(String.fromCharCode(0),128),i=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(o={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],o["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],o["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],o["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),void 0===e&&(e="SHA-512"),!(e in o))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=o[e],r=null,c=j.util.createBuffer(),u=new Array(80),l=0;l<80;++l)u[l]=new Array(2);var f=64;switch(e){case"SHA-384":f=48;break;case"SHA-512/256":f=32;break;case"SHA-512/224":f=28}var d={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var e=d.messageLengthSize/4,n=0;n<e;++n)d.fullMessageLength.push(0);for(c=j.util.createBuffer(),r=new Array(t.length),n=0;n<t.length;++n)r[n]=t[n].slice(0);return d}};return d.start(),d.update=function(e,t){"utf8"===t&&(e=j.util.encodeUtf8(e));var n=e.length;d.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var a=d.fullMessageLength.length-1;a>=0;--a)d.fullMessageLength[a]+=n[1],n[1]=n[0]+(d.fullMessageLength[a]/4294967296>>>0),d.fullMessageLength[a]=d.fullMessageLength[a]>>>0,n[0]=n[1]/4294967296>>>0;return c.putBytes(e),s(r,u,c),(c.read>2048||0===c.length())&&c.compact(),d},d.digest=function(){var t=j.util.createBuffer();t.putBytes(c.bytes());var a,i=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(n.substr(0,d.blockLength-i));for(var o=8*d.fullMessageLength[0],l=0;l<d.fullMessageLength.length-1;++l)o+=(a=8*d.fullMessageLength[l+1])/4294967296>>>0,t.putInt32(o>>>0),o=a>>>0;t.putInt32(o);var f=new Array(r.length);for(l=0;l<r.length;++l)f[l]=r[l].slice(0);s(f,u,t);var p,h=j.util.createBuffer();for(p="SHA-512"===e?f.length:"SHA-384"===e?f.length-2:f.length-4,l=0;l<p;++l)h.putInt32(f[l][0]),l===p-1&&"SHA-512/224"===e||h.putInt32(f[l][1]);return h},d};var n=null,a=!1,i=null,o=null;function s(e,t,r){for(var n,a,o,s,c,u,l,f,d,p,h,g,m,y,v,b,C,E,w,k,S,B,A,T,I,_,x,P,R,N,L,O,D,U=r.length();U>=128;){for(x=0;x<16;++x)t[x][0]=r.getInt32()>>>0,t[x][1]=r.getInt32()>>>0;for(;x<80;++x)n=(((P=(N=t[x-2])[0])>>>19|(R=N[1])<<13)^(R>>>29|P<<3)^P>>>6)>>>0,a=((P<<13|R>>>19)^(R<<3|P>>>29)^(P<<26|R>>>6))>>>0,o=(((P=(O=t[x-15])[0])>>>1|(R=O[1])<<31)^(P>>>8|R<<24)^P>>>7)>>>0,s=((P<<31|R>>>1)^(P<<24|R>>>8)^(P<<25|R>>>7))>>>0,L=t[x-7],D=t[x-16],R=a+L[1]+s+D[1],t[x][0]=n+L[0]+o+D[0]+(R/4294967296>>>0)>>>0,t[x][1]=R>>>0;for(h=e[0][0],g=e[0][1],m=e[1][0],y=e[1][1],v=e[2][0],b=e[2][1],C=e[3][0],E=e[3][1],w=e[4][0],k=e[4][1],S=e[5][0],B=e[5][1],A=e[6][0],T=e[6][1],I=e[7][0],_=e[7][1],x=0;x<80;++x)l=((w>>>14|k<<18)^(w>>>18|k<<14)^(k>>>9|w<<23))>>>0,f=(A^w&(S^A))>>>0,c=((h>>>28|g<<4)^(g>>>2|h<<30)^(g>>>7|h<<25))>>>0,u=((h<<4|g>>>28)^(g<<30|h>>>2)^(g<<25|h>>>7))>>>0,d=(h&m|v&(h^m))>>>0,p=(g&y|b&(g^y))>>>0,R=_+(((w<<18|k>>>14)^(w<<14|k>>>18)^(k<<23|w>>>9))>>>0)+((T^k&(B^T))>>>0)+i[x][1]+t[x][1],n=I+l+f+i[x][0]+t[x][0]+(R/4294967296>>>0)>>>0,a=R>>>0,o=c+d+((R=u+p)/4294967296>>>0)>>>0,s=R>>>0,I=A,_=T,A=S,T=B,S=w,B=k,w=C+n+((R=E+a)/4294967296>>>0)>>>0,k=R>>>0,C=v,E=b,v=m,b=y,m=h,y=g,h=n+o+((R=a+s)/4294967296>>>0)>>>0,g=R>>>0;R=e[0][1]+g,e[0][0]=e[0][0]+h+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+m+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+b,e[2][0]=e[2][0]+v+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+E,e[3][0]=e[3][0]+C+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+k,e[4][0]=e[4][0]+w+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+B,e[5][0]=e[5][0]+S+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+T,e[6][0]=e[6][0]+A+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+_,e[7][0]=e[7][0]+I+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,U-=128}}}));var lr=j.asn1,fr={privateKeyValidator:{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:lr.Class.UNIVERSAL,type:lr.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},publicKeyValidator:{name:"SubjectPublicKeyInfo",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:lr.Class.UNIVERSAL,type:lr.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:lr.Class.UNIVERSAL,type:lr.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:lr.Class.UNIVERSAL,type:lr.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}},dr=fr.publicKeyValidator,pr=fr.privateKeyValidator;if(void 0===hr)var hr=j.jsbn.BigInteger;var gr=j.util.ByteBuffer,mr="undefined"==typeof Buffer?Uint8Array:Buffer;j.pki=j.pki||{},j.pki.ed25519=j.ed25519=j.ed25519||{};var yr=j.ed25519;function vr(e){var t=e.message;if(t instanceof Uint8Array||t instanceof mr)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new gr(t,r)}else if(!(t instanceof gr))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new mr(t.length()),a=0;a<n.length;++a)n[a]=t.at(a);return n}yr.constants={},yr.constants.PUBLIC_KEY_BYTE_LENGTH=32,yr.constants.PRIVATE_KEY_BYTE_LENGTH=64,yr.constants.SEED_BYTE_LENGTH=32,yr.constants.SIGN_BYTE_LENGTH=64,yr.constants.HASH_BYTE_LENGTH=64,yr.generateKeyPair=function(e){var t=(e=e||{}).seed;if(void 0===t)t=j.random.getBytesSync(yr.constants.SEED_BYTE_LENGTH);else if("string"==typeof t){if(t.length!==yr.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+yr.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=vr({message:t,encoding:"binary"});for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=new mr(yr.constants.PRIVATE_KEY_BYTE_LENGTH),a=0;a<32;++a)n[a]=t[a];return function(e,t){var r,n=[Kr(),Kr(),Kr(),Kr()],a=Tr(t,32);for(a[0]&=248,a[31]&=127,a[31]|=64,Mr(n,a),Rr(e,n),r=0;r<32;++r)t[r+32]=e[r]}(r,n),{publicKey:r,privateKey:n}},yr.privateKeyFromAsn1=function(e){var t={},r=[];if(!j.asn1.validate(e,pr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var a=j.asn1.derToOid(t.privateKeyOid),i=j.oids.EdDSA25519;if(a!==i)throw new Error('Invalid OID "'+a+'"; OID must be "'+i+'".');var o=t.privateKey;return{privateKeyBytes:vr({message:j.asn1.fromDer(o).value,encoding:"binary"})}},yr.publicKeyFromAsn1=function(e){var t={},r=[];if(!j.asn1.validate(e,dr,t,r)){var n=new Error("Invalid Key.");throw n.errors=r,n}var a=j.asn1.derToOid(t.publicKeyOid),i=j.oids.EdDSA25519;if(a!==i)throw new Error('Invalid OID "'+a+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vr({message:o,encoding:"binary"})},yr.publicKeyFromPrivateKey=function(e){var t=vr({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new mr(yr.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},yr.sign=function(e){var t=vr(e=e||{}),r=vr({message:e.privateKey,encoding:"binary"});if(r.length===yr.constants.SEED_BYTE_LENGTH)r=yr.generateKeyPair({seed:r}).privateKey;else if(r.length!==yr.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+yr.constants.SEED_BYTE_LENGTH+" or "+yr.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var a,i,o=new Float64Array(64),s=[Kr(),Kr(),Kr(),Kr()],c=Tr(n,32);for(c[0]&=248,c[31]&=127,c[31]|=64,a=0;a<r;++a)e[64+a]=t[a];for(a=0;a<32;++a)e[32+a]=c[32+a];var u=Tr(e.subarray(32),r+32);for(_r(u),Mr(s,u),Rr(e,s),a=32;a<64;++a)e[a]=n[a];var l=Tr(e,r+64);for(_r(l),a=32;a<64;++a)o[a]=0;for(a=0;a<32;++a)o[a]=u[a];for(a=0;a<32;++a)for(i=0;i<32;i++)o[a+i]+=l[a]*c[i];Ir(e.subarray(32),o)}(n,t,t.length,r);for(var a=new mr(yr.constants.SIGN_BYTE_LENGTH),i=0;i<a.length;++i)a[i]=n[i];return a},yr.verify=function(e){var t=vr(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=vr({message:e.signature,encoding:"binary"});if(r.length!==yr.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+yr.constants.SIGN_BYTE_LENGTH);var n=vr({message:e.publicKey,encoding:"binary"});if(n.length!==yr.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+yr.constants.PUBLIC_KEY_BYTE_LENGTH);var a,i=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length),o=new mr(yr.constants.SIGN_BYTE_LENGTH+t.length);for(a=0;a<yr.constants.SIGN_BYTE_LENGTH;++a)i[a]=r[a];for(a=0;a<t.length;++a)i[a+yr.constants.SIGN_BYTE_LENGTH]=t[a];return function(e,t,r,n){var a,i=new mr(32),o=[Kr(),Kr(),Kr(),Kr()],s=[Kr(),Kr(),Kr(),Kr()];if(r<64)return-1;if(function(e,t){var r=Kr(),n=Kr(),a=Kr(),i=Kr(),o=Kr(),s=Kr(),c=Kr();return Vr(e[2],Cr),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),Hr(a,e[1]),Gr(i,a,Er),qr(a,a,e[2]),zr(i,e[2],i),Hr(o,i),Hr(s,o),Gr(c,s,o),Gr(r,c,a),Gr(r,r,i),function(e,t){var r,n=Kr();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)Hr(n,n),1!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),Gr(r,r,a),Gr(r,r,i),Gr(r,r,i),Gr(e[0],r,i),Hr(n,e[0]),Gr(n,n,i),Lr(n,a)&&Gr(e[0],e[0],Ar),Hr(n,e[0]),Gr(n,n,i),Lr(n,a)?-1:(Dr(e[0])===t[31]>>7&&qr(e[0],br,e[0]),Gr(e[3],e[0],e[1]),0)}(s,n))return-1;for(a=0;a<r;++a)e[a]=t[a];for(a=0;a<32;++a)e[a+32]=n[a];var c=Tr(e,r);if(_r(c),Ur(o,s,c),Mr(s,t.subarray(32)),xr(o,s),Rr(i,o),r-=64,Or(t,0,i,0)){for(a=0;a<r;++a)e[a]=0;return-1}for(a=0;a<r;++a)e[a]=t[a+64];return r}(o,i,i.length,n)>=0};var br=Kr(),Cr=Kr([1]),Er=Kr([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),wr=Kr([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),kr=Kr([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Sr=Kr([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Ar=Kr([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Tr(e,t){var r=j.md.sha512.create(),n=new gr(e);r.update(n.getBytes(t),"binary");var a=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(a,"binary");for(var i=new mr(yr.constants.HASH_BYTE_LENGTH),o=0;o<64;++o)i[o]=a.charCodeAt(o);return i}function Ir(e,t){var r,n,a,i;for(n=63;n>=32;--n){for(r=0,a=n-32,i=n-12;a<i;++a)t[a]+=r-16*t[n]*Br[a-(n-32)],r=t[a]+128>>8,t[a]-=256*r;t[a]+=r,t[n]=0}for(r=0,a=0;a<32;++a)t[a]+=r-(t[31]>>4)*Br[a],r=t[a]>>8,t[a]&=255;for(a=0;a<32;++a)t[a]-=r*Br[a];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function _r(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Ir(e,t)}function xr(e,t){var r=Kr(),n=Kr(),a=Kr(),i=Kr(),o=Kr(),s=Kr(),c=Kr(),u=Kr(),l=Kr();qr(r,e[1],e[0]),qr(l,t[1],t[0]),Gr(r,r,l),zr(n,e[0],e[1]),zr(l,t[0],t[1]),Gr(n,n,l),Gr(a,e[3],t[3]),Gr(a,a,wr),Gr(i,e[2],t[2]),zr(i,i,i),qr(o,n,r),qr(s,i,a),zr(c,i,a),zr(u,n,r),Gr(e[0],o,s),Gr(e[1],u,c),Gr(e[2],c,s),Gr(e[3],o,u)}function Pr(e,t,r){for(var n=0;n<4;++n)jr(e[n],t[n],r)}function Rr(e,t){var r=Kr(),n=Kr(),a=Kr();!function(e,t){var r,n=Kr();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)Hr(n,n),2!==r&&4!==r&&Gr(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(a,t[2]),Gr(r,t[0],a),Gr(n,t[1],a),Nr(e,n),e[31]^=Dr(r)<<7}function Nr(e,t){var r,n,a,i=Kr(),o=Kr();for(r=0;r<16;++r)o[r]=t[r];for(Fr(o),Fr(o),Fr(o),n=0;n<2;++n){for(i[0]=o[0]-65517,r=1;r<15;++r)i[r]=o[r]-65535-(i[r-1]>>16&1),i[r-1]&=65535;i[15]=o[15]-32767-(i[14]>>16&1),a=i[15]>>16&1,i[14]&=65535,jr(o,i,1-a)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function Lr(e,t){var r=new mr(32),n=new mr(32);return Nr(r,e),Nr(n,t),Or(r,0,n,0)}function Or(e,t,r,n){return function(e,t,r,n,a){var i,o=0;for(i=0;i<a;++i)o|=e[t+i]^r[n+i];return(1&o-1>>>8)-1}(e,t,r,n,32)}function Dr(e){var t=new mr(32);return Nr(t,e),1&t[0]}function Ur(e,t,r){var n,a;for(Vr(e[0],br),Vr(e[1],Cr),Vr(e[2],Cr),Vr(e[3],br),a=255;a>=0;--a)Pr(e,t,n=r[a/8|0]>>(7&a)&1),xr(t,e),xr(e,e),Pr(e,t,n)}function Mr(e,t){var r=[Kr(),Kr(),Kr(),Kr()];Vr(r[0],kr),Vr(r[1],Sr),Vr(r[2],Cr),Gr(r[3],kr,Sr),Ur(e,r,t)}function Vr(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function Fr(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function jr(e,t,r){for(var n,a=~(r-1),i=0;i<16;++i)n=a&(e[i]^t[i]),e[i]^=n,t[i]^=n}function Kr(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function zr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function qr(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function Hr(e,t){Gr(e,t,t)}function Gr(e,t,r){var n,a,i=0,o=0,s=0,c=0,u=0,l=0,f=0,d=0,p=0,h=0,g=0,m=0,y=0,v=0,b=0,C=0,E=0,w=0,k=0,S=0,B=0,A=0,T=0,I=0,_=0,x=0,P=0,R=0,N=0,L=0,O=0,D=r[0],U=r[1],M=r[2],V=r[3],F=r[4],j=r[5],K=r[6],z=r[7],q=r[8],H=r[9],G=r[10],Q=r[11],W=r[12],X=r[13],Y=r[14],$=r[15];i+=(n=t[0])*D,o+=n*U,s+=n*M,c+=n*V,u+=n*F,l+=n*j,f+=n*K,d+=n*z,p+=n*q,h+=n*H,g+=n*G,m+=n*Q,y+=n*W,v+=n*X,b+=n*Y,C+=n*$,o+=(n=t[1])*D,s+=n*U,c+=n*M,u+=n*V,l+=n*F,f+=n*j,d+=n*K,p+=n*z,h+=n*q,g+=n*H,m+=n*G,y+=n*Q,v+=n*W,b+=n*X,C+=n*Y,E+=n*$,s+=(n=t[2])*D,c+=n*U,u+=n*M,l+=n*V,f+=n*F,d+=n*j,p+=n*K,h+=n*z,g+=n*q,m+=n*H,y+=n*G,v+=n*Q,b+=n*W,C+=n*X,E+=n*Y,w+=n*$,c+=(n=t[3])*D,u+=n*U,l+=n*M,f+=n*V,d+=n*F,p+=n*j,h+=n*K,g+=n*z,m+=n*q,y+=n*H,v+=n*G,b+=n*Q,C+=n*W,E+=n*X,w+=n*Y,k+=n*$,u+=(n=t[4])*D,l+=n*U,f+=n*M,d+=n*V,p+=n*F,h+=n*j,g+=n*K,m+=n*z,y+=n*q,v+=n*H,b+=n*G,C+=n*Q,E+=n*W,w+=n*X,k+=n*Y,S+=n*$,l+=(n=t[5])*D,f+=n*U,d+=n*M,p+=n*V,h+=n*F,g+=n*j,m+=n*K,y+=n*z,v+=n*q,b+=n*H,C+=n*G,E+=n*Q,w+=n*W,k+=n*X,S+=n*Y,B+=n*$,f+=(n=t[6])*D,d+=n*U,p+=n*M,h+=n*V,g+=n*F,m+=n*j,y+=n*K,v+=n*z,b+=n*q,C+=n*H,E+=n*G,w+=n*Q,k+=n*W,S+=n*X,B+=n*Y,A+=n*$,d+=(n=t[7])*D,p+=n*U,h+=n*M,g+=n*V,m+=n*F,y+=n*j,v+=n*K,b+=n*z,C+=n*q,E+=n*H,w+=n*G,k+=n*Q,S+=n*W,B+=n*X,A+=n*Y,T+=n*$,p+=(n=t[8])*D,h+=n*U,g+=n*M,m+=n*V,y+=n*F,v+=n*j,b+=n*K,C+=n*z,E+=n*q,w+=n*H,k+=n*G,S+=n*Q,B+=n*W,A+=n*X,T+=n*Y,I+=n*$,h+=(n=t[9])*D,g+=n*U,m+=n*M,y+=n*V,v+=n*F,b+=n*j,C+=n*K,E+=n*z,w+=n*q,k+=n*H,S+=n*G,B+=n*Q,A+=n*W,T+=n*X,I+=n*Y,_+=n*$,g+=(n=t[10])*D,m+=n*U,y+=n*M,v+=n*V,b+=n*F,C+=n*j,E+=n*K,w+=n*z,k+=n*q,S+=n*H,B+=n*G,A+=n*Q,T+=n*W,I+=n*X,_+=n*Y,x+=n*$,m+=(n=t[11])*D,y+=n*U,v+=n*M,b+=n*V,C+=n*F,E+=n*j,w+=n*K,k+=n*z,S+=n*q,B+=n*H,A+=n*G,T+=n*Q,I+=n*W,_+=n*X,x+=n*Y,P+=n*$,y+=(n=t[12])*D,v+=n*U,b+=n*M,C+=n*V,E+=n*F,w+=n*j,k+=n*K,S+=n*z,B+=n*q,A+=n*H,T+=n*G,I+=n*Q,_+=n*W,x+=n*X,P+=n*Y,R+=n*$,v+=(n=t[13])*D,b+=n*U,C+=n*M,E+=n*V,w+=n*F,k+=n*j,S+=n*K,B+=n*z,A+=n*q,T+=n*H,I+=n*G,_+=n*Q,x+=n*W,P+=n*X,R+=n*Y,N+=n*$,b+=(n=t[14])*D,C+=n*U,E+=n*M,w+=n*V,k+=n*F,S+=n*j,B+=n*K,A+=n*z,T+=n*q,I+=n*H,_+=n*G,x+=n*Q,P+=n*W,R+=n*X,N+=n*Y,L+=n*$,C+=(n=t[15])*D,o+=38*(w+=n*M),s+=38*(k+=n*V),c+=38*(S+=n*F),u+=38*(B+=n*j),l+=38*(A+=n*K),f+=38*(T+=n*z),d+=38*(I+=n*q),p+=38*(_+=n*H),h+=38*(x+=n*G),g+=38*(P+=n*Q),m+=38*(R+=n*W),y+=38*(N+=n*X),v+=38*(L+=n*Y),b+=38*(O+=n*$),i=(n=(i+=38*(E+=n*U))+(a=1)+65535)-65536*(a=Math.floor(n/65536)),o=(n=o+a+65535)-65536*(a=Math.floor(n/65536)),s=(n=s+a+65535)-65536*(a=Math.floor(n/65536)),c=(n=c+a+65535)-65536*(a=Math.floor(n/65536)),u=(n=u+a+65535)-65536*(a=Math.floor(n/65536)),l=(n=l+a+65535)-65536*(a=Math.floor(n/65536)),f=(n=f+a+65535)-65536*(a=Math.floor(n/65536)),d=(n=d+a+65535)-65536*(a=Math.floor(n/65536)),p=(n=p+a+65535)-65536*(a=Math.floor(n/65536)),h=(n=h+a+65535)-65536*(a=Math.floor(n/65536)),g=(n=g+a+65535)-65536*(a=Math.floor(n/65536)),m=(n=m+a+65535)-65536*(a=Math.floor(n/65536)),y=(n=y+a+65535)-65536*(a=Math.floor(n/65536)),v=(n=v+a+65535)-65536*(a=Math.floor(n/65536)),b=(n=b+a+65535)-65536*(a=Math.floor(n/65536)),C=(n=C+a+65535)-65536*(a=Math.floor(n/65536)),i=(n=(i+=a-1+37*(a-1))+(a=1)+65535)-65536*(a=Math.floor(n/65536)),o=(n=o+a+65535)-65536*(a=Math.floor(n/65536)),s=(n=s+a+65535)-65536*(a=Math.floor(n/65536)),c=(n=c+a+65535)-65536*(a=Math.floor(n/65536)),u=(n=u+a+65535)-65536*(a=Math.floor(n/65536)),l=(n=l+a+65535)-65536*(a=Math.floor(n/65536)),f=(n=f+a+65535)-65536*(a=Math.floor(n/65536)),d=(n=d+a+65535)-65536*(a=Math.floor(n/65536)),p=(n=p+a+65535)-65536*(a=Math.floor(n/65536)),h=(n=h+a+65535)-65536*(a=Math.floor(n/65536)),g=(n=g+a+65535)-65536*(a=Math.floor(n/65536)),m=(n=m+a+65535)-65536*(a=Math.floor(n/65536)),y=(n=y+a+65535)-65536*(a=Math.floor(n/65536)),v=(n=v+a+65535)-65536*(a=Math.floor(n/65536)),b=(n=b+a+65535)-65536*(a=Math.floor(n/65536)),C=(n=C+a+65535)-65536*(a=Math.floor(n/65536)),i+=a-1+37*(a-1),e[0]=i,e[1]=o,e[2]=s,e[3]=c,e[4]=u,e[5]=l,e[6]=f,e[7]=d,e[8]=p,e[9]=h,e[10]=g,e[11]=m,e[12]=y,e[13]=v,e[14]=b,e[15]=C}j.kem=j.kem||{};var Qr=j.jsbn.BigInteger;function Wr(e,t,r,n){e.generate=function(e,a){for(var i=new j.util.ByteBuffer,o=Math.ceil(a/n)+r,s=new j.util.ByteBuffer,c=r;c<o;++c){s.putInt32(c),t.start(),t.update(e+s.getBytes());var u=t.digest();i.putBytes(u.getBytes(n))}return i.truncate(i.length()-a),i.getBytes()}}j.kem.rsa={},j.kem.rsa.create=function(e,t){var r=(t=t||{}).prng||j.random;return{encrypt:function(t,n){var a,i=Math.ceil(t.n.bitLength()/8);do{a=new Qr(j.util.bytesToHex(r.getBytesSync(i)),16).mod(t.n)}while(a.compareTo(Qr.ONE)<=0);var o=i-(a=j.util.hexToBytes(a.toString(16))).length;return o>0&&(a=j.util.fillString(String.fromCharCode(0),o)+a),{encapsulation:t.encrypt(a,"NONE"),key:e.generate(a,n)}},decrypt:function(t,r,n){var a=t.decrypt(r,"NONE");return e.generate(a,n)}}},j.kem.kdf1=function(e,t){Wr(this,e,0,t||e.digestLength)},j.kem.kdf2=function(e,t){Wr(this,e,1,t||e.digestLength)},j.log=j.log||{},j.log.levels=["none","error","warning","info","debug","verbose","max"];var Xr={},Yr=[],$r=null;j.log.LEVEL_LOCKED=2,j.log.NO_LEVEL_CHECK=4,j.log.INTERPOLATE=8;for(var Zr=0;Zr<j.log.levels.length;++Zr){var Jr=j.log.levels[Zr];Xr[Jr]={index:Zr,name:Jr.toUpperCase()}}j.log.logMessage=function(e){for(var t=Xr[e.level].index,r=0;r<Yr.length;++r){var n=Yr[r];n.flags&j.log.NO_LEVEL_CHECK?n.f(e):t<=Xr[n.level].index&&n.f(n,e)}},j.log.prepareStandard=function(e){"standard"in e||(e.standard=Xr[e.level].name+" ["+e.category+"] "+e.message)},j.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]||e.arguments),e.full=j.util.format.apply(this,t)}},j.log.prepareStandardFull=function(e){"standardFull"in e||(j.log.prepareStandard(e),e.standardFull=e.standard)};var en=["error","warning","info","debug","verbose"];for(Zr=0;Zr<en.length;++Zr)!function(e){j.log[e]=function(t,r){var n=Array.prototype.slice.call(arguments).slice(2),a={timestamp:new Date,level:e,category:t,message:r,arguments:n};j.log.logMessage(a)}}(en[Zr]);if(j.log.makeLogger=function(e){var t={flags:0,f:e};return j.log.setLevel(t,"none"),t},j.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&j.log.LEVEL_LOCKED))for(var n=0;n<j.log.levels.length;++n)if(t==j.log.levels[n]){e.level=t,r=!0;break}return r},j.log.lock=function(e,t){void 0===t||t?e.flags|=j.log.LEVEL_LOCKED:e.flags&=~j.log.LEVEL_LOCKED},j.log.addLogger=function(e){Yr.push(e)},"undefined"!=typeof console&&"log"in console){var tn;if(console.error&&console.warn&&console.info&&console.debug){var rn={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},nn=function(e,t){j.log.prepareStandard(t);var r=rn[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};tn=j.log.makeLogger(nn)}else nn=function(e,t){j.log.prepareStandardFull(t),console.log(t.standardFull)},tn=j.log.makeLogger(nn);j.log.setLevel(tn,"debug"),j.log.addLogger(tn),$r=tn}else console={log:function(){}};if(null!==$r){var an=j.util.getQueryVariables();"console.level"in an&&j.log.setLevel($r,an["console.level"].slice(-1)[0]),"console.lock"in an&&"true"==an["console.lock"].slice(-1)[0]&&j.log.lock($r)}j.log.consoleLogger=$r,E((function(e){var t=j.asn1,r=e.exports=j.pkcs7=j.pkcs7||{};function n(e){var n={},a=[];if(!t.validate(e,r.asn1.recipientInfoValidator,n,a)){var i=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw i.errors=a,i}return{version:n.version.charCodeAt(0),issuer:j.pki.RDNAttributesAsArray(n.issuer),serialNumber:j.util.createBuffer(n.serial).toHex(),encryptedContent:{algorithm:t.derToOid(n.encAlgorithm),parameter:n.encParameter.value,content:n.encKey}}}function a(e){for(var r,n=[],a=0;a<e.length;++a)n.push((r=e[a],t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[j.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.encryptedContent.content)])));return n}function i(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[j.pki.distinguishedNameToAsn1({attributes:e.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,j.util.hexToBytes(e.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&r.value.push(e.authenticatedAttributesAsn1),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var n=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),a=0;a<e.unauthenticatedAttributes.length;++a){var i=e.unauthenticatedAttributes[a];n.values.push(o(i))}r.value.push(n)}return r}function o(e){var r;if(e.type===j.pki.oids.contentType)r=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.value).getBytes());else if(e.type===j.pki.oids.messageDigest)r=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===j.pki.oids.signingTime){var n=new Date("1950-01-01T00:00:00Z"),a=new Date("2050-01-01T00:00:00Z"),i=e.value;if("string"==typeof i){var o=Date.parse(i);i=isNaN(o)?13===i.length?t.utcTimeToDate(i):t.generalizedTimeToDate(i):new Date(o)}r=i>=n&&i<a?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(i)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(i))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[r])])}function s(e,r,n){var a={};if(!t.validate(r,n,a,[])){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw i.errors=i,i}if(t.derToOid(a.contentType)!==j.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(a.encryptedContent){var o="";if(j.util.isArray(a.encryptedContent))for(var s=0;s<a.encryptedContent.length;++s){if(a.encryptedContent[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=a.encryptedContent[s].value}else o=a.encryptedContent;e.encryptedContent={algorithm:t.derToOid(a.encAlgorithm),parameter:j.util.createBuffer(a.encParameter.value),content:j.util.createBuffer(o)}}if(a.content){if(o="",j.util.isArray(a.content))for(s=0;s<a.content.length;++s){if(a.content[s].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=a.content[s].value}else o=a.content;e.content=j.util.createBuffer(o)}return e.version=a.version.charCodeAt(0),e.rawCapture=a,a}function c(e){if(void 0===e.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===e.content){var t;switch(e.encryptedContent.algorithm){case j.pki.oids["aes128-CBC"]:case j.pki.oids["aes192-CBC"]:case j.pki.oids["aes256-CBC"]:t=j.aes.createDecryptionCipher(e.encryptedContent.key);break;case j.pki.oids.desCBC:case j.pki.oids["des-EDE3-CBC"]:t=j.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}r.messageFromPem=function(e){var n=j.pem.decode(e)[0];if("PKCS7"!==n.type){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=n.type,a}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var i=t.fromDer(n.body);return r.messageFromAsn1(i)},r.messageToPem=function(e,r){var n={type:"PKCS7",body:t.toDer(e.toAsn1()).getBytes()};return j.pem.encode(n,{maxline:r})},r.messageFromAsn1=function(e){var n={},a=[];if(!t.validate(e,r.asn1.contentInfoValidator,n,a)){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw i.errors=a,i}var o,s=t.derToOid(n.contentType);switch(s){case j.pki.oids.envelopedData:o=r.createEnvelopedData();break;case j.pki.oids.encryptedData:o=r.createEncryptedData();break;case j.pki.oids.signedData:o=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return o.fromAsn1(n.content.value[0]),o},r.createSignedData=function(){var e=null;return e={type:j.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(s(e,t,r.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,a=0;a<n.length;++a)e.certificates.push(j.pki.certificateFromAsn1(n[a]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(j.pki.certificateToAsn1(e.certificates[n]));var a=[],i=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),a.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,a)),i.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,e.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),i])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var a=t.certificate;"string"==typeof a&&(a=j.pki.certificateFromPem(a)),r=a.issuer.attributes,n=a.serialNumber}var i=t.key;if(!i)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof i&&(i=j.pki.privateKeyFromPem(i));var o=t.digestAlgorithm||j.pki.oids.sha1;switch(o){case j.pki.oids.sha1:case j.pki.oids.sha256:case j.pki.oids.sha384:case j.pki.oids.sha512:case j.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var s=t.authenticatedAttributes||[];if(s.length>0){for(var c=!1,u=!1,l=0;l<s.length;++l){var f=s[l];if(c||f.type!==j.pki.oids.contentType){if(u||f.type!==j.pki.oids.messageDigest);else if(u=!0,c)break}else if(c=!0,u)break}if(!c||!u)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:i,version:1,issuer:r,serialNumber:n,digestAlgorithm:o,signatureAlgorithm:j.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:s,unauthenticatedAttributes:[]})},sign:function(r){var n;r=r||{},("object"!=typeof e.content||null===e.contentInfo)&&(e.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(j.pki.oids.data).getBytes())]),"content"in e&&(e.content instanceof j.util.ByteBuffer?n=e.content.bytes():"string"==typeof e.content&&(n=j.util.encodeUtf8(e.content)),r.detached?e.detachedContent=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)])))),0!==e.signers.length&&function(r){var n;if(!(n=e.detachedContent?e.detachedContent:(n=e.contentInfo.value[1]).value[0]))throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var a=t.derToOid(e.contentInfo.value[0].value),s=t.toDer(n);for(var c in s.getByte(),t.getBerValueLength(s),s=s.getBytes(),r)r[c].start().update(s);for(var u=new Date,l=0;l<e.signers.length;++l){var f=e.signers[l];if(0===f.authenticatedAttributes.length){if(a!==j.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{f.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var d=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var h=f.authenticatedAttributes[p];h.type===j.pki.oids.messageDigest?h.value=r[f.digestAlgorithm].digest():h.type===j.pki.oids.signingTime&&(h.value||(h.value=u)),d.value.push(o(h)),f.authenticatedAttributesAsn1.value.push(o(h))}s=t.toDer(d).getBytes(),f.md.start().update(s)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(i(e[r]));return t}(e.signers)}(function(){for(var r={},n=0;n<e.signers.length;++n){var a=e.signers[n];(i=a.digestAlgorithm)in r||(r[i]=j.md[j.pki.oids[i]].create()),0===a.authenticatedAttributes.length?a.md=r[i]:a.md=j.md[j.pki.oids[i]].create()}for(var i in e.digestAlgorithmIdentifiers=[],r)e.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}())},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=j.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}}},r.createEncryptedData=function(){var e=null;return e={type:j.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:j.pki.oids["aes256-CBC"]},fromAsn1:function(t){s(e,t,r.asn1.encryptedDataValidator)},decrypt:function(t){void 0!==t&&(e.encryptedContent.key=t),c(e)}}},r.createEnvelopedData=function(){var e=null;return e={type:j.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:j.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=s(e,t,r.asn1.envelopedDataValidator);e.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(n(e[r]));return t}(a.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,a(e.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,(r=e.encryptedContent,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(j.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.parameter.getBytes())]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.content.getBytes())])]))])])]);var r},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var a=e.recipients[n],i=a.issuer;if(a.serialNumber===t.serialNumber&&i.length===r.length){for(var o=!0,s=0;s<r.length;++s)if(i[s].type!==r[s].type||i[s].value!==r[s].value){o=!1;break}if(o)return a}}return null},decrypt:function(t,r){if(void 0===e.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case j.pki.oids.rsaEncryption:case j.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=j.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}c(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:j.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===e.encryptedContent.content){var n,a,i;switch(r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key,r){case j.pki.oids["aes128-CBC"]:n=16,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["aes192-CBC"]:n=24,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["aes256-CBC"]:n=32,a=16,i=j.aes.createEncryptionCipher;break;case j.pki.oids["des-EDE3-CBC"]:n=24,a=8,i=j.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=j.util.createBuffer(j.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=j.util.createBuffer(j.random.getBytes(a));var o=i(t);if(o.start(e.encryptedContent.parameter.copy()),o.update(e.content),!o.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=o.output}for(var s=0;s<e.recipients.length;++s){var c=e.recipients[s];if(void 0===c.encryptedContent.content)switch(c.encryptedContent.algorithm){case j.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}}}})),E((function(e){var t=e.exports=j.ssh=j.ssh||{};function r(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=j.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function n(e,t){e.putInt32(t.length),e.putString(t)}function a(){for(var e=j.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}t.privateKeyToPutty=function(e,t,i){var o=""===(t=t||"")?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: ssh-rsa\r\n";s+="Encryption: "+o+"\r\n",s+="Comment: "+(i=i||"")+"\r\n";var c=j.util.createBuffer();n(c,"ssh-rsa"),r(c,e.e),r(c,e.n);var u=j.util.encode64(c.bytes(),64),l=Math.floor(u.length/66)+1;s+="Public-Lines: "+l+"\r\n",s+=u;var f,d=j.util.createBuffer();if(r(d,e.d),r(d,e.p),r(d,e.q),r(d,e.qInv),t){var p=d.length()+16-1;p-=p%16;var h=a(d.bytes());h.truncate(h.length()-p+d.length()),d.putBuffer(h);var g=j.util.createBuffer();g.putBuffer(a("\0\0\0\0",t)),g.putBuffer(a("\0\0\0",t));var m=j.aes.createEncryptionCipher(g.truncate(8),"CBC");m.start(j.util.createBuffer().fillWithByte(0,16)),m.update(d.copy()),m.finish();var y=m.output;y.truncate(16),f=j.util.encode64(y.bytes(),64)}else f=j.util.encode64(d.bytes(),64);s+="\r\nPrivate-Lines: "+(l=Math.floor(f.length/66)+1)+"\r\n",s+=f;var v=a("putty-private-key-file-mac-key",t),b=j.util.createBuffer();n(b,"ssh-rsa"),n(b,o),n(b,i),b.putInt32(c.length()),b.putBuffer(c),b.putInt32(d.length()),b.putBuffer(d);var C=j.hmac.create();return C.start("sha1",v),C.update(b.bytes()),s+"\r\nPrivate-MAC: "+C.digest().toHex()+"\r\n"},t.publicKeyToOpenSSH=function(e,t){t=t||"";var a=j.util.createBuffer();return n(a,"ssh-rsa"),r(a,e.e),r(a,e.n),"ssh-rsa "+j.util.encode64(a.bytes())+" "+t},t.privateKeyToOpenSSH=function(e,t){return t?j.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):j.pki.privateKeyToPem(e)},t.getPublicKeyFingerprint=function(e,t){var a=(t=t||{}).md||j.md.md5.create(),i=j.util.createBuffer();n(i,"ssh-rsa"),r(i,e.e),r(i,e.n),a.start(),a.update(i.getBytes());var o=a.digest();if("hex"===t.encoding){var s=o.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}if("binary"===t.encoding)return o.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".');return o}}));var on="forge.task",sn={},cn=0;j.debug.set(on,"tasks",sn);var un={};j.debug.set(on,"queues",un);var ln="ready",fn="running",dn="blocked",pn="sleeping",hn="done",gn="error",mn={ready:{}};mn.ready.stop=ln,mn.ready.start=fn,mn.ready.cancel=hn,mn.ready.fail=gn,mn.running={},mn.running.stop=ln,mn.running.start=fn,mn.running.block=dn,mn.running.unblock=fn,mn.running.sleep=pn,mn.running.wakeup=fn,mn.running.cancel=hn,mn.running.fail=gn,mn.blocked={},mn.blocked.stop=dn,mn.blocked.start=dn,mn.blocked.block=dn,mn.blocked.unblock=dn,mn.blocked.sleep=dn,mn.blocked.wakeup=dn,mn.blocked.cancel=hn,mn.blocked.fail=gn,mn.sleeping={},mn.sleeping.stop=pn,mn.sleeping.start=pn,mn.sleeping.block=pn,mn.sleeping.unblock=pn,mn.sleeping.sleep=pn,mn.sleeping.wakeup=pn,mn.sleeping.cancel=hn,mn.sleeping.fail=gn,mn.done={},mn.done.stop=hn,mn.done.start=hn,mn.done.block=hn,mn.done.unblock=hn,mn.done.sleep=hn,mn.done.wakeup=hn,mn.done.cancel=hn,mn.done.fail=gn,mn.error={},mn.error.stop=gn,mn.error.start=gn,mn.error.block=gn,mn.error.unblock=gn,mn.error.sleep=gn,mn.error.wakeup=gn,mn.error.cancel=gn,mn.error.fail=gn;var yn=function(e){this.id=-1,this.name=e.name||"?",this.parent=e.parent||null,this.run=e.run,this.subtasks=[],this.error=!1,this.state=ln,this.blocks=0,this.timeoutId=null,this.swapTime=null,this.userData=null,this.id=cn++,sn[this.id]=this};yn.prototype.debug=function(e){e=e||"",j.log.debug(on,e,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",un)},yn.prototype.next=function(e,t){"function"==typeof e&&(t=e,e=this.name);var r=new yn({run:t,name:e,parent:this});return r.state=fn,r.type=this.type,r.successCallback=this.successCallback||null,r.failureCallback=this.failureCallback||null,this.subtasks.push(r),this},yn.prototype.parallel=function(e,t){return j.util.isArray(e)&&(t=e,e=this.name),this.next(e,(function(r){var n=r;n.block(t.length);for(var a=function(e,r){j.task.start({type:e,run:function(e){t[r](e)},success:function(e){n.unblock()},failure:function(e){n.unblock()}})},i=0;i<t.length;i++)a(e+"__parallel-"+r.id+"-"+i,i)}))},yn.prototype.stop=function(){this.state=mn[this.state].stop},yn.prototype.start=function(){this.error=!1,this.state=mn[this.state].start,this.state===fn&&(this.start=new Date,this.run(this),vn(this,0))},yn.prototype.block=function(e){e=void 0===e?1:e,this.blocks+=e,this.blocks>0&&(this.state=mn[this.state].block)},yn.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==hn&&(this.state=fn,vn(this,0)),this.blocks},yn.prototype.sleep=function(e){e=void 0===e?0:e,this.state=mn[this.state].sleep;var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=fn,vn(t,0)}),e)},yn.prototype.wait=function(e){e.wait(this)},yn.prototype.wakeup=function(){this.state===pn&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=fn,vn(this,0))},yn.prototype.cancel=function(){this.state=mn[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},yn.prototype.fail=function(e){if(this.error=!0,bn(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,vn(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;bn(t,!0)}this.failureCallback&&this.failureCallback(this)}};var vn=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===fn)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||vn(n,t)}else bn(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,vn(e.parent,t))};r?setTimeout(n,0):n(t)},bn=function(e,t){e.state=hn,delete sn[e.id],null===e.parent&&(e.type in un?0===un[e.type].length?j.log.error(on,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):un[e.type][0]!==e?j.log.error(on,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(un[e.type].shift(),0===un[e.type].length?delete un[e.type]:un[e.type][0].start()):j.log.error(on,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};j.task=j.task||{},j.task.start=function(e){var t=new yn({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in un?un[e.type].push(t):(un[t.type]=[t],function(e){e.error=!1,e.state=mn[e.state].start,setTimeout((function(){e.state===fn&&(e.swapTime=+new Date,e.run(e),vn(e,0))}),0)}(t))},j.task.cancel=function(e){e in un&&(un[e]=[un[e][0]])},j.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e};var Cn=j,En=function(){function e(e){this.secretKey=e}return e.prototype.encrypt=function(e,t){throw new Error("Method not implemented.")},e.prototype.decrypt=function(e,t){return function(e,t,r){void 0===r&&(r=Cn.util.createBuffer(Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer));var n,a,i=Cn.cipher.createDecipher("AES-CBC",t);return i.start({iv:r}),i.update(Cn.util.createBuffer(Cn.util.hexToBytes(e))),a=(n=i.output.data).charCodeAt(n.length-1),n.slice(0,-a)}(e,(r=this.secretKey,n=t.transactionID,""+r.slice(0,16)+n.slice(0,16)));var r,n},e}(),wn=function(){function e(e,t,n,a){void 0===n&&(n="production"),void 0===a&&(a={supportTransaction:!1,enableEncryption:!1}),this.transactionEnabled=a.supportTransaction||!1,this.encryptionEnabled=a.enableEncryption||!1;var i=D(e,t,n,{headers:a.httpHeaders});this.transactionManager=new F(i),this.encryptionService=new En(t),this.compareFaceService=new f(i),this.clientSettingsService=new d(i),this.convertPDFService=new v(i),this.ekycPDFService=new b(i),this.readIDCardService=new r(i),this.requestVerifyIDCardService=new h(i),this.requestVerifyPortraitSerivce=new g(i),this.imagesService=new u(i),this.fileService=new l(i),this.verifyFaceLivenessService=new p(i),this.searchFaceService=new y(i),this.detectIDTamperingService=new m(i),this.httpClient=i}return e.prototype.enableTransaction=function(){this.transactionEnabled=!0},e.prototype.disableTransaction=function(){this.transactionEnabled=!1},e.prototype.enableEncryption=function(){this.encryptionEnabled=!0},e.prototype.disableEncryption=function(){this.encryptionEnabled=!1},e.prototype.compareFaces=function(e,t){return this.compareFaceService.request(e,t)},e.prototype.clientSettings=function(){return this.clientSettingsService.request()},e.prototype.uploadImage=function(e){return this.imagesService.request(e)},e.prototype.uploadFile=function(e){return this.fileService.uploadFile(e)},e.prototype.convertPDF=function(e,t){return this.convertPDFService.request(e,t)},e.prototype.ekycPDF=function(e,t){return this.ekycPDFService.request(e,t)},e.prototype.readIDCard=function(e,t){return this.readIDCardService.request(e,t)},e.prototype.requestVerifyIDCard=function(e,t){return this.requestVerifyIDCardService.request(e,t)},e.prototype.requestVerifyPortrait=function(e,t){return this.requestVerifyPortraitSerivce.request(e,t)},e.prototype.verifyFaceLiveness=function(e,t){return this.verifyFaceLivenessService.request(e,t)},e.prototype.searchFaces=function(e,t){return this.searchFaceService.request(e,t)},e.prototype.deleteFaces=function(e,t){return this.searchFaceService.deleteFaces(e,t)},e.prototype.indexFaces=function(e,t){return this.searchFaceService.indexFaces(e,t)},e.prototype.downloadFaceImage=function(e){return this.searchFaceService.downloadFaceImage(e)},e.prototype.downloadImage=function(e){return this.imagesService.download(e)},e.prototype.updateMetadata=function(e,t){return this.imagesService.updateMetadata(e,t)},e.prototype.detectIDTampering=function(e,t){return this.detectIDTamperingService.request(e,t)},a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"compareFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"convertPDF",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"readIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyIDCard",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"requestVerifyPortrait",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"verifyFaceLiveness",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"searchFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"deleteFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"indexFaces",null),a([M({headerIndex:1}),V(),o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",Promise)],e.prototype,"detectIDTampering",null),e}();e.ReadIDCard=r,e.UploadImage=u,e.UploadFile=l,e.CompareFaces=f,e.ClientSettings=d,e.VerifyFaceLiveness=p,e.RequestVerifyIDCard=h,e.RequestVerifyPortrait=g,e.DetectIDTampering=m,e.SearchFaces=y,e.ConvertPDF=v,e.EkycPDF=b,e.HttpClient=_,e.MockClient=x,e.TVAuthorizer=L,e.createHelpers=function(e,t,r){void 0===r&&(r="production");var n=new L(e,t),a=function(e){switch(e){case"testing":return"https://tv-testing.trustingsocial.com/api";case"staging":return"https://tv-staging.trustingsocial.com/api";case"production":default:return"https://vn-vision.trustingsocial.com/api"}}(r);return new _({authorizer:n,domain:a})},e.createHttpClient=D,e.SimpleTrustVisionAPI=U,e.default=wn,Object.defineProperty(e,"__esModule",{value:!0})}(t,a.default)})),W0=o(Q0);function X0(e){var t=e.className;return SC.createElement("svg",{className:t,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg"},SC.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"}))}X0.propTypes={className:SE.string},X0.defaultProps={className:""};var Y0,$0,Z0,J0,e1,t1,r1,n1,a1,i1,o1,s1=(Lv(L0={},hB.FaceDirection.LEFT,90),Lv(L0,hB.FaceDirection.RIGHT,270),Lv(L0,hB.FaceDirection.UP,180),Lv(L0,hB.FaceDirection.DOWN,0),L0),c1=fB(["0%{opacity:0.15;}50%{opacity:0.3;}100%{opacity:1;}"]),u1=cB.div(O0||(O0=zv(["\n width: 200px;\n height: 200px;\n position: relative;\n transform: scale(0.48);\n\n .top,\n .right,\n .bottom,\n .left {\n position: absolute;\n }\n\n .top {\n top: 0;\n left: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .right {\n right: 0;\n top: 50%;\n transform: rotate(","deg) translateX(-50%);\n }\n\n .bottom {\n bottom: 0;\n left: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n\n .left {\n left: 0;\n top: 50%;\n transform: rotate(","deg) translateX(50%);\n }\n"])),s1[hB.FaceDirection.DOWN],s1[hB.FaceDirection.LEFT],s1[hB.FaceDirection.UP],s1[hB.FaceDirection.RIGHT]),l1=cB.div(D0||(D0=zv(["\n width: 70px;\n transform: rotate(","deg);\n"])),(function(e){var t,r=e.direction;return null!==(t=s1[r])&&void 0!==t?t:0})),f1=cB.span(U0||(U0=zv(["\n display: flex;\n margin: 4px 0;\n width: 100%;\n height: 15px;\n animation: "," 1s infinite;\n animation-direction: alternate;\n\n &::before,\n &::after {\n content: '';\n height: 100%;\n width: 50%;\n background: rgba(255, 255, 255, 0.8);\n }\n\n &::before {\n transform: skewY(32deg);\n }\n\n &::after {\n width: 50%;\n transform: skewY(-32deg);\n }\n"])),c1),d1=cB(f1)(M0||(M0=zv(["\n animation-delay: 0s;\n"]))),p1=cB(f1)(V0||(V0=zv(["\n animation-delay: 0.5s;\n"]))),h1=cB(f1)(F0||(F0=zv(["\n animation-delay: 1s;\n"])));function g1(e){var t=e.type;return t!==hB.FaceDirection.FRONTAL?SC.createElement(l1,{direction:t},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)):SC.createElement(u1,null,SC.createElement(l1,{className:"top"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"right"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"bottom"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)),SC.createElement(l1,{className:"left"},SC.createElement(d1,null),SC.createElement(p1,null),SC.createElement(h1,null)))}g1.propTypes={type:SE.oneOf([hB.FaceDirection.LEFT,hB.FaceDirection.RIGHT,hB.FaceDirection.UP,hB.FaceDirection.FRONTAL])},g1.defaultProps={type:hB.FaceDirection.LEFT};var m1={sm:650,md:750},y1=DX.Camera,v1=q0.FaceDetectionError,b1=q0.FaceVerificationInstructions,C1=q0.FaceVerificationStepsWrapper,E1=q0.StepItem,w1=q0.BottomButtonsOverlay,k1=q0.Button,S1=q0.CountDownOverlay,B1=q0.InstructionsOverlay,A1=cB(C1)(Y0||(Y0=zv(["\n height: 50px;\n"]))),T1=cB(v1)($0||($0=zv(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n\n ",";\n"])),(function(e){return e.isMobile&&QS(["font-size:0.875rem;"])})),I1=cB(b1)(Z0||(Z0=zv(["\n position: absolute;\n font-size: 1.125rem;\n text-align: center;\n padding: 0 1.75rem;\n color: ",";\n text-shadow: none;\n\n ",";\n"])),(function(e){return e.color}),(function(e){return e.isMobile&&QS(["font-size:0.875rem;"])})),_1=cB(X0)(J0||(J0=zv(["\n width: 100%;\n height: 100%;\n vertical-align: middle;\n margin: 0;\n color: ",";\n"])),(function(e){var t=e.color;return null!=t?t:"#06243c"})),x1=cB.img(e1||(e1=zv(["\n && {\n width: 20px;\n border-radius: 50%;\n margin: 0;\n\n ","\n }\n"])),(function(e){return"preview"===e.mode&&QS(["width:42px;"])})),P1=cB(E1)(t1||(t1=zv(["\n width: 50px;\n height: 50px;\n border: 1px solid #005993;\n border-radius: 50%;\n\n & + & {\n margin-left: 10px;\n }\n\n ","\n"])),(function(e){return!e.active&&QS(["border-color:#f2f6f9;opacity:0.3;"])})),R1=cB(PW)(r1||(r1=zv(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),N1=cB.div(n1||(n1=zv(["\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n z-index: -1;\n"]))),L1=cB(N1)(a1||(a1=zv(["\n background: rgba(223, 0, 0, 0.2);\n"]))),O1=fB(["from{opacity:1;}to{opacity:0;}"]),D1=cB(N1)(i1||(i1=zv(["\n background: rgba(255, 255, 255, 0.3);\n animation: "," 1s infinite;\n"])),O1),U1=uq.isMobile?{width:640}:null;function M1(e){var t=e.className,r=e.apiCheck,n=e.enableInstructionsOverlay,a=e.enableErrorOverlay,i=e.enableCapturingOverlay,o=e.frontalMinSize,s=e.mode,c=e.minPadding,u=e.backgroundColor,l=e.textColor,f=e.progressProps,d=e.customInstructions,p=e.customIcon,h=e.customDirectionIcon,g=e.onLivenessDetectionDone,m=e.onClose,y=e.onError,v=e.captureFrameSettings,b=e.onFramesCaptured,C=e.apiCredentials,E=SC.useCallback((function(e){var t=e.clientWidth,r=e.clientHeight,n=e.videoAreaWidth,a=e.videoAreaHeight,i=e.lostX,o=e.lostY,s=Math.max(60,o),u=Math.max(90,o);r>m1.sm&&(s=Math.max(70,o),u=Math.max(140,o)),r>m1.md&&(s=Math.max(70,o),u=Math.max(140,o));var l=Math.max(c,i),f=Math.max(c,i),d=Math.min(n,a),p=Math.max(Math.floor(Math.min(t-(l+f),r-(s+u),d)),160);return{x:Math.min(Math.floor(l+(t-f-l)/2-p/2),t-p),y:Math.min(Math.floor(s+(r-u-s)/2-p/2),r-p),width:p,height:p}}),[c]),w=SC.useMemo((function(){return{background:u,opacity:1}}),[u]),k=z0({apiCheck:r,frontalMinSize:o,mode:s,bgCameraMask:null,bgCameraMaskRed:null,surroundStyle:w,cropAreaDimension:E,customInstructions:d,customIcon:p,customDirectionIcon:h,onLivenessDetectionDone:g,captureFrameSettings:v,onFramesCaptured:b,apiCredentials:C}),S=k.countdownToTakePicture,B=k.cropArea,A=k.curStepIndex,T=k.directionIcon,I=k.faceDetectionError,_=k.handleTriggerPassiveMode,x=k.handleVideoPlayed,P=k.instructions,R=k.isActiveMode,N=k.refVideo,L=k.showCountdown,O=k.steps,D=k.videoPlayed,U=k.activeCapturing,M=k.warmupDone,V=50,F=12,j=14;window.innerHeight>m1.sm&&(V=50,F=24,j=34),window.innerHeight>m1.md&&(V=50,F=24,j=40);var K=j+V+F,z=a&&I;return SC.createElement(Pq,{ref:N,className:t,frontCamera:!0,flipHorizontal:!0,videoSettings:U1,onVideoPlayed:x,onClose:m,onError:y},!M&&SC.createElement(lX,null),D?SC.createElement(SC.Fragment,null,B.current?SC.createElement(Uq,{x:"".concat(B.current.x,"px"),y:"".concat(B.current.y,"px"),width:"".concat(B.current.width,"px"),height:"".concat(B.current.height,"px"),surroundStyle:B.current.surroundStyle},SC.createElement(_1,{color:u}),SC.createElement(R1,Ov({progress:A/O.length*100,hasError:z},f)),L?SC.createElement(S1,null,S):null,R&&n&&T?SC.createElement(B1,null,T):null,R&&i&&U?SC.createElement(D1,null):null,z?SC.createElement(L1,null):null):null,I?SC.createElement(T1,{top:30,isMobile:uq.isMobile,error:I}):null,R?SC.createElement(SC.Fragment,null,P?SC.createElement(I1,{bottom:K,isMobile:uq.isMobile,color:l},P):null,SC.createElement(A1,{bottom:j},O.map((function(e,t){var r=e.name,n=e.icon,a=e.image.objUrl,i=A>=t;return SC.createElement(P1,{key:r,active:i},a?SC.createElement(x1,{src:a,alt:"",mode:"preview"}):function(e,t){return"string"==typeof e?SC.createElement(x1,{src:e,alt:""}):SC.cloneElement(e,t)}(n,{active:i}))})))):SC.createElement(SC.Fragment,null,I?null:SC.createElement(w1,null,SC.createElement(k1,{onClick:_},SC.createElement(y1,null))))):null)}function V1(e){return SC.createElement(qX,Ov({},e,{livenessComponent:M1}))}M1.propTypes={className:SE.string,apiCheck:SE.bool,enableInstructionsOverlay:SE.bool,enableErrorOverlay:SE.bool,enableCapturingOverlay:SE.bool,frontalMinSize:SE.number,mode:SE.string,minPadding:SE.number,backgroundColor:SE.string,textColor:SE.string,progressProps:SE.shape({className:SE.string,style:SE.shape({}),radius:SE.number,strokeWidth:SE.number,progress:SE.number,activeColor:SE.string,innerPadding:SE.number,outsideRingColor:SE.string,insideRingColor:SE.string,insideRingWidth:SE.number,dashedRingColor:SE.string,dashedRingWidth:SE.number,dashedRingLineThick:SE.number,dashedRingLineSpacing:SE.number,showOutsideRing:SE.bool,showDashedRing:SE.bool,showInsideRing:SE.bool}),title:SE.string,description:SE.string,customInstructions:SE.shape({}),customIcon:SE.shape({}),customDirectionIcon:SE.shape({}),onLivenessDetectionDone:SE.func,onClose:SE.func,onError:SE.func,captureFrameSettings:SE.shape({}),onFramesCaptured:SE.func,apiCredentials:SE.shape({accessKey:SE.string,secretKey:SE.string,apiUrl:SE.string})},M1.defaultProps={className:"",apiCheck:!1,enableInstructionsOverlay:!1,enableErrorOverlay:!1,enableCapturingOverlay:!1,frontalMinSize:720,mode:null,minPadding:5,backgroundColor:"#06243c",textColor:"#ffffff",progressProps:null,title:"Chụp ảnh chân dung",description:"Xin đưa khuôn mặt vào khung hình. Hình ảnh sẽ tự động được ghi lại.",customInstructions:null,customIcon:null,customDirectionIcon:(o1={},Lv(o1,hB.FaceDirection.LEFT,SC.createElement(g1,{type:hB.FaceDirection.LEFT})),Lv(o1,hB.FaceDirection.RIGHT,SC.createElement(g1,{type:hB.FaceDirection.RIGHT})),Lv(o1,hB.FaceDirection.UP,SC.createElement(g1,{type:hB.FaceDirection.UP})),Lv(o1,hB.FaceDirection.FRONTAL,SC.createElement(g1,{type:hB.FaceDirection.FRONTAL})),o1),onLivenessDetectionDone:null,onClose:null,onError:function(){},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:function(){},apiCredentials:{accessKey:"5767c20d-87aa-4cad-8dbb-f5429f76c34b",secretKey:"c1446919-e60a-4575-a05d-304318212a1b",apiUrl:"https://tv-testing.trustingsocial.com/api"}};var F1=["apiCheck","mode","accessKey","secretKey","apiUrl","onLivenessDetectionDone","onError","tracking"],j1=hB.FaceDirection,K1="https://unpkg.com/@tsocial/tvweb-sdk@latest/assets",z1=function(){function e(t){var r=this,n=t.container,a=t.lang,i=void 0===a?"en":a,o=t.assetRoot,s=void 0===o?K1:o,c=t.resourceRoot,u=t.customUrls,l=void 0===u?{}:u,f=t.enableAntiDebug,d=void 0===f||f;Pv(this,e),Lv(this,"checkCamera",RX),Lv(this,"runWarmUpReadIDCard",xv(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.commonSettings.customUrls,e.abrupt("return",Y$(t));case 2:case"end":return e.stop()}}),e)})))),Lv(this,"runPreloadEKYCResources",xv(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.commonSettings.customUrls,j0(t);case 2:case"end":return e.stop()}}),e)})))),Lv(this,"destroyView",(function(){Pz.unmountComponentAtNode(r.container)})),G0(n,"container is a required parameter"),this.container=n;var p=p_({resourceRoot:c,initCustomUrls:l});this.commonSettings={lang:i,assetRoot:s,customUrls:p,enableAntiDebug:d,debug:!1,livenessTracking:{enable:!0}}}return Nv(e,[{key:"readIDCardWithApiCall",value:function(e){Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:Uv({},this.commonSettings)},SC.createElement(R0,Ov({onClose:this.destroyView},e))),this.container)}},{key:"readIDCardUIOnly",value:function(e){Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:this.commonSettings},SC.createElement(g0,Ov({onClose:this.destroyView},e))),this.container)}},{key:"livenessDetection",value:function(e){var t,r=e.apiCheck,n=e.mode,a=(e.accessKey,e.secretKey,e.apiUrl,e.onLivenessDetectionDone),i=e.onError,o=e.tracking,s=Kv(e,F1);Pz.render(SC.createElement(v_.SDKSettingsProvider,{value:Uv({},this.commonSettings)},SC.createElement(Y_.SDKTrackingProvider,{value:{tracking:Uv(Uv({},this.commonSettings.livenessTracking),o)}},SC.createElement(V1,Ov({apiCheck:r,mode:n,onLivenessDetectionDone:a,onClose:this.destroyView,onError:i,enableInstructionsOverlay:!0,enableErrorOverlay:!0,enableCapturingOverlay:!0,backgroundColor:"#ffffff",textColor:"inherit",progressProps:{activeColor:"#f08200",insideRingWidth:8,outsideRingColor:"#f2f2f2",insideRingColor:"#ffffff",dashedRingColor:"#d7d7d7",dashedRingOpacity:1,dashedInsideRingColor:"#d7d7d7",dashedInsideRingWidth:1},customInstructions:(t={},Lv(t,j1.LEFT,{vi:"Vui lòng quay mặt sang bên trái"}),Lv(t,j1.RIGHT,{vi:"Vui lòng quay mặt sang bên phải"}),Lv(t,j1.UP,{vi:"Vui lòng ngước mặt lên"}),Lv(t,j1.FRONTAL,{vi:"Xin đưa khuôn mặt chính diện vào khung hình"}),t)},s,{enableRecording:!1})))),this.container)}},{key:"compareFaces",value:function(e){var t=e.accessKey,r=e.secretKey,n=e.apiUrl,a=e.image1,i=e.image2,o=e.onSuccess,s=e.onError;fR.createRetryAPIClient(new W0(t,r,n)).compareFaces({image1:{id:a},image2:{id:i}}).then((function(e){o(e)})).catch((function(e){s(e)}))}}]),e}();t.APIUtils=fR,t.Animations=JY,t.AntiDebugUtils=DR,t.AssetUtils=J_,t.AsyncUtils=tx,t.BASE_Z_INDEX=dq,t.BlurUtils=Bx,t.Button=CZ,t.ButtonLink=EZ,t.Camera=Pq,t.CameraUtils=Tx,t.CommonUtils=_x,t.Constants=hB,t.CoordinateUtils=Lx,t.CropAreaOverlayWrapper=Uq,t.CryptoUtils=VR,t.FaceUtils=Kx,t.GlareUtils=tR,t.HashUtils=j_,t.HighlightResult=AJ,t.HighlightResultType=bJ,t.Icons=DX,t.ImageUtils=$P,t.LivenessDetection=qX,t.LivenessDetectionComponents=q0,t.LoadResourceUtils=CR,t.LocalStorageUtils=U_,t.MobileDetect=uq,t.ModelUtils=OR,t.NativeCamera=LX,t.PlacementArea=Dq,t.Popup=HW,t.PredictionUtils=Gx,t.ProgressCircle=PW,t.RatioWrapper=VZ,t.ReadIDCardUIOnly=g0,t.ReadIDCardWithApiCall=R0,t.RectangleMask=pY,t.RectangleMaskType=dY,t.SDK=z1,t.ScannerType=l0,t.SettingsContext=v_,t.Spacing=pZ,t.ThemeUtils=UR,t.TimeUtils=L_,t.TrackingContext=Y_,t.UserAgentUtils=P_,t.WarmupPopup=lX,t.checkCamera=RX,t.defaultClientSettings=a0,t.defaultReadIDCardSteps=f0,t.getCustomUrlsBySettings=p_,t.getQrScannerWorkerPath=FR,t.handleApiCheckReadIdCard=I0,t.preloadEKYCResources=j0,t.readIdCardFromImage=K0,t.readQRCodeFromImage=fJ,t.useLivenessDetection=z0,t.useMainProcessQRCodeScanner=dJ,t.useMainProcessReadIdCard=nZ,t.useSettingsReadIdCard=i0,t.useShowPopup=C$,t.warmUpQRCodeScanner=$Z,t.warmUpReadIdCard=Y$,t.warmupSelfieActive=iW,Object.defineProperty(t,"__esModule",{value:!0})}));
|