MeshCentral/public/commander.htm

1119 lines
568 KiB
HTML
Raw Normal View History

2018-10-03 22:03:09 +03:00
<!DOCTYPE html><html style=height:100%><head><meta http-equiv=X-UA-Compatible content="IE=edge"><meta content="text/html;charset=utf-8" http-equiv=Content-Type><meta name=format-detection content="telephone=no"><link rel="icon" type=image/png href="data:image/png;base64,iVBORw0KGgo="><style>body{height:100%;max-height:100%;overflow:hidden;font-family:arial, helvetica, sans-serif;font-size:9pt;color:black;background:white;margin-top:0;margin-left:0;margin-right:0;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}li{margin:0;padding:0;}label{display:block;color:windowtext;background-color:window;margin:0;padding:0;width:100%;}label:hover{background-color:highlight;color:highlighttext;}a:visited{text-decoration:none;color:#04f;}a:link{text-decoration:none;color:#04f;}a:hover{color:#a32;}h1{font-size:11pt;font-weight:bold;color:black;margin-left:5px;margin-top:10px;margin-bottom:6px;}h2{font-size:9pt;font-weight:bold;color:black;margin-left:6px;margin-top:6px;margin-bottom:0;}p{margin-left:6px;margin-top:4px;margin-bottom:0;margin-right:2px;}td{font-size:9pt;}th{font-size:9pt;}th:hover{cursor:pointer;background:#aaa;}.header{position:fixed;top:0;left:0;right:0;height:24px;background:#c0c0c0;}.progressbar{position:fixed;top:24px;left:0;right:0;height:2px;background:#ff9e30;}.in{margin-left:40px;}.log{background:#bbbab5;}.log1{background:#bbbab5;}.log tbody tr:nth-child(odd){background:#e8eefe;}.fullcell{position:fixed;top:26px;right:0;bottom:0;left:0px;overflow:hidden;}.maincell{position:fixed;top:26px;right:0;bottom:0;left:156px;overflow:auto;padding-left:2px;vertical-align:top;}.navbar{position:fixed;top:26px;left:0;bottom:0;width:156px;border-right:2px solid #ff9e30;vertical-align:top;background:#72726f;background:linear-gradient(45deg, #72726f 0%,#a6a5a0 100%);}.nav1{padding:1px 0px 1px 8px;margin:0px;font-weight:bold;color:black;white-space:nowrap;cursor:pointer;}.nav2{margin-left:32px;margin-top:0;color:black;cursor:pointer;}.r{font-size:11pt;}.r0{background:white;}.r1{border-bottom:1px solid gray;text-align:left;}.r2{text-align:left;}.r3{border-bottom:1px solid gray;text-align:left;}.r3:hover{background-color:#83827b;cursor:pointer;}.spread{height:100%;width:100%;background-color:white;}.timer{border:1px solid #abcae1;background-color:#abcae1;}.tm{font-size:7pt;}.top1{font-size:14pt;font-weight:bold;color:white;margin-top:11px;}.top2{color:white;}.warn{font-weight:bold;color:#c00000;}.icon1{width:14px;height:15px;background-repeat:no-repeat;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dw
2018-08-24 02:55:06 +03:00
function inputBoxFocus(a){Q(a).focus();var b=Q(a).value;Q(a).value="";Q(a).value=b}function ReadShort(a,b){return(a.charCodeAt(b)<<8)+a.charCodeAt(b+1)}function ReadShortX(a,b){return(a.charCodeAt(b+1)<<8)+a.charCodeAt(b)}function ReadInt(a,b){return 16777216*a.charCodeAt(b)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}function ReadSInt(a,b){return(a.charCodeAt(b)<<24)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}
function ReadIntX(a,b){return 16777216*a.charCodeAt(b+3)+(a.charCodeAt(b+2)<<16)+(a.charCodeAt(b+1)<<8)+a.charCodeAt(b)}function ShortToStr(a){return String.fromCharCode(a>>8&255,a&255)}function ShortToStrX(a){return String.fromCharCode(a&255,a>>8&255)}function IntToStr(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}function IntToStrX(a){return String.fromCharCode(a&255,a>>8&255,a>>16&255,a>>24&255)}function MakeToArray(a){return a&&null!=a&&"object"!=typeof a?[a]:a}
function SplitArray(a){return a.split(",")}function Clone(a){return JSON.parse(JSON.stringify(a))}function EscapeHtml(a){if("string"==typeof a)return a.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");if("boolean"==typeof a||"number"==typeof a)return a}function ArrayElementMove(a,b,c){a.splice(c,0,a.splice(b,1)[0])}
function ObjectToStringEx(a,b){var c="";if(0!=a&&(!a||null==a))return"(Null)";if(a instanceof Array)for(var d in a)c+="<br />"+gap(b)+"Item #"+d+": "+ObjectToStringEx(a[d],b+1);else if(a instanceof Object)for(d in a)c+="<br />"+gap(b)+d+" = "+ObjectToStringEx(a[d],b+1);else c+=EscapeHtml(a);return c}
function ObjectToStringEx2(a,b){var c="";if(0!=a&&(!a||null==a))return"(Null)";if(a instanceof Array)for(var d in a)c+="\r\n"+gap2(b)+"Item #"+d+": "+ObjectToStringEx2(a[d],b+1);else if(a instanceof Object)for(d in a)c+="\r\n"+gap2(b)+d+" = "+ObjectToStringEx2(a[d],b+1);else c+=EscapeHtml(a);return c}function gap(a){for(var b="",c=0;c<4*a;c++)b+="&nbsp;";return b}function gap2(a){for(var b="",c=0;c<4*a;c++)b+=" ";return b}function ObjectToString(a){return ObjectToStringEx(a,0)}
function ObjectToString2(a){return ObjectToStringEx2(a,0)}function hex2rstr(a){if("string"!=typeof a||0==a.length)return"";var b="";a=(""+a).match(/../g);for(var c;c=a.shift();)b+=String.fromCharCode("0x"+c);return b}function char2hex(a){return(a+256).toString(16).substr(-2).toUpperCase()}function rstr2hex(a){var b="",c;for(c=0;c<a.length;c++)b+=char2hex(a.charCodeAt(c));return b}function encode_utf8(a){return unescape(encodeURIComponent(a))}
function decode_utf8(a){return decodeURIComponent(escape(a))}function data2blob(a){for(var b=Array(a.length),c=0;c<a.length;c++)b[c]=a.charCodeAt(c);return new Blob([new Uint8Array(b)])}function random(a){return Math.floor(Math.random()*a)}function trademarks(a){return a.replace(/\(R\)/g,"&reg;").replace(/\(TM\)/g,"&trade;")}
var CreateWsmanComm=function(a,b,c,d,f){function n(){k.socketState=2;k.socketParseState=0;k.socketAccumulator="";k.socketHeader=null;k.socketData="";for(i in k.pendingAjaxCall)k.sendRequest(k.pendingAjaxCall[i][0],k.pendingAjaxCall[i][3],k.pendingAjaxCall[i][4])}function p(a){k.inDataCount++;if("object"==typeof a.data){var c=new FileReader;if(c.readAsBinaryString)c.onload=function(a){r(a.target.result)},c.readAsBinaryString(new Blob([a.data]));else if(c.readAsArrayBuffer)c.onloadend=function(a){r(a.target.result)},
c.readAsArrayBuffer(a.data);else{c="";a=new Uint8Array(a.data);for(var b=a.byteLength,l=0;l<b;l++)c+=String.fromCharCode(a[l]);r(c)}}else"string"==typeof a.data&&r(a.data)}function r(a){if("object"===typeof a){var c="";a=new Uint8Array(a);for(var b=a.byteLength,l=0;l<b;l++)c+=String.fromCharCode(a[l]);a=c}else if("string"!==typeof a)return;for(k.socketAccumulator+=a;;){if(0==k.socketParseState){a=k.socketAccumulator.indexOf("\r\n\r\n");if(0>a)break;k.socketHeader=k.socketAccumulator.substring(0,a).split("\r\n");
if(null==k.amtVersion)for(l in k.socketHeader)0==k.socketHeader[l].indexOf("Server: Intel(R) Active Management Technology ")&&(k.amtVersion=k.socketHeader[l].substring(46));k.socketAccumulator=k.socketAccumulator.substring(a+4);k.socketParseState=1;k.socketData="";k.socketXHeader={Directive:k.socketHeader[0].split(" ")};for(l in k.socketHeader)0!=l&&(a=k.socketHeader[l].indexOf(":"),k.socketXHeader[k.socketHeader[l].substring(0,a).toLowerCase()]=k.socketHeader[l].substring(a+2))}if(1==k.socketParseState){c=
-1;if(void 0==k.socketXHeader.connection||"close"!=k.socketXHeader.connection.toLowerCase()||void 0!=k.socketXHeader["transfer-encoding"]&&"chunked"==k.socketXHeader["transfer-encoding"].toLowerCase())if(void 0!=k.socketXHeader["content-length"]){c=parseInt(k.socketXHeader["content-length"]);if(k.socketAccumulator.length<c)break;a=k.socketAccumulator.substring(0,c);k.socketAccumulator=k.socketAccumulator.substring(c);k.socketData=a;c=0}else{b=k.socketAccumulator.indexOf("\r\n");if(0>b)break;c=parseInt(k.socketAccumulator.substring(0,
b),16);if(isNaN(c)){k.websocket&&k.websocket.close();break}if(k.socketAccumulator.length<b+2+c+2)break;a=k.socketAccumulator.substring(b+2,b+2+c);k.socketAccumulator=k.socketAccumulator.substring(b+2+c+2);k.socketData+=a}else c=0;0==c&&(b=k.socketXHeader,a=k.socketData,c=parseInt(b.Directive[1]),isNaN(c)&&(c=602),401==c&&3>++k.authcounter?k.challengeParams=k.parseDigest(b["www-authenticate"]):(b=k.pendingAjaxCall.shift(),k.authcounter=0,k.ActiveAjaxCount--,k.gotNextMessages(a,"success",{status:c},
b),k.PerformNextAjax()),k.socketParseState=0,k.socketHeader=null)}}}function l(a){0==k.inDataCount&&(k.tlsv1only=1-k.tlsv1only);k.socketState=0;null!=k.socket&&(k.socket.close(),k.socket=null);if(0<k.pendingAjaxCall.length){a=k.pendingAjaxCall.shift();var c=a[5];k.PerformAjaxExNodeJS2(a[0],a[1],a[2],a[3],a[4],--c)}}var k={PendingAjax:[],ActiveAjaxCount:0,MaxActiveAjaxCount:1,FailAllError:0,challengeParams:null,noncecounter:1,authcounter:0,socket:null,socketState:0};k.host=a;k.port=b;k.user=c;k.pass=
d;k.tls=f;k.tlsv1only=0;k.cnonce=Math.random().toString(36).substring(7);k.inDataCount=0;k.amtVersion=null;k.PerformAjax=function(a,c,b,l,h,g){k.ActiveAjaxCount<k.MaxActiveAjaxCount&&0==k.PendingAjax.length?k.PerformAjaxEx(a,c,b,h,g):1==l?k.PendingAjax.unshift([a,c,b,h,g]):k.PendingAjax.push([a,c,b,h,g])};k.PerformNextAjax=function(){if(!(k.ActiveAjaxCount>=k.MaxActiveAjaxCount||0==k.PendingAjax.length)){var a=k.PendingAjax.shift();k.PerformAjaxEx(a[0],a[1],a[2],a[3],a[4]);k.PerformNextAjax()}};k.PerformAjaxEx=
function(a,c,b,l,h){if(0!=k.FailAllError)k.gotNextMessagesError({status:k.FailAllError},"error",null,[a,c,b,l,h]);else return a||(a=""),k.ActiveAjaxCount++,k.PerformAjaxExNodeJS(a,c,b,l,h)};k.pendingAjaxCall=[];k.PerformAjaxExNodeJS=function(a,c,b,l,h){k.PerformAjaxExNodeJS2(a,c,b,l,h,3)};k.PerformAjaxExNodeJS2=function(a,c,b,l,h,g){0>=g||0!=k.FailAllError?(k.ActiveAjaxCount--,999!=k.FailAllError&&k.gotNextMessages(null,"error",{status:0==k.FailAllError?408:k.FailAllError},[a,c,b,l,h]),k.PerformNextAjax()):
(k.pendingAjaxCall.push([a,c,b,l,h,g]),0==k.socketState?k.xxConnectHttpSocket():2==k.socketState&&k.sendRequest(a,l,h))};k.sendRequest=function(a,c,b){c=c?c:"/wsman";b=b?b:"POST";var l=b+" "+c+" HTTP/1.1\r\n";null!=k.challengeParams&&(b=hex_md5(hex_md5(k.user+":"+k.challengeParams.realm+":"+k.pass)+":"+k.challengeParams.nonce+":"+k.noncecounter+":"+k.cnonce+":"+k.challengeParams.qop+":"+hex_md5(b+":"+c)),l+="Authorization: "+k.renderDigest({username:k.user,realm:k.challengeParams.realm,nonce:k.challengeParams.nonce,
uri:c,qop:k.challengeParams.qop,response:b,nc:k.noncecounter++,cnonce:k.cnonce})+"\r\n");a=l+="Host: "+k.host+":"+k.port+"\r\nContent-Length: "+a.length+"\r\n\r\n"+a;if(2==k.socketState&&null!=k.socket&&k.socket.readyState==WebSocket.OPEN){c=new Uint8Array(a.length);for(l=0;l<a.length;++l)c[l]=a.charCodeAt(l);try{k.socket.send(c.buffer)}catch(h){}}};k.parseDigest=function(a){a=a.substring(7).split(",");for(i in a)a[i]=a[i].trim();return a.reduce(function(a,c){var b=c.split("=");a[b[0]]=b[1].replace(/"/g,
"");return a},{})};k.renderDigest=function(a){var c=[];for(i in a)c.push(i);return"Digest "+c.reduce(function(c,b){return c+","+b+'="'+a[b]+'"'},"").substring(1)};k.xxConnectHttpSocket=function(){k.inDataCount=0;k.socketState=1;k.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=1&host="+k.host+"&port="+k.port+"&tls="+k.tls+"&tls1only="+k.tlsv1only+("*"==c?"&serverauth=1":
"")+("undefined"===typeof d?"&serverauth=1&user="+c:""));k.socket.onopen=n;k.socket.onmessage=p;k.socket.onclose=l};k.gotNextMessages=function(a,c,b,l){if(999!=k.FailAllError)if(0!=k.FailAllError)l[1](null,k.FailAllError,l[2]);else if(200!=b.status)l[1](null,b.status,l[2]);else l[1](a,200,l[2])};k.gotNextMessagesError=function(a,c,b,l){if(999!=k.FailAllError)if(0!=k.FailAllError)l[1](null,k.FailAllError,l[2]);else l[1](k,null,{Header:{HttpError:a.status}},a.status,l[2])};k.CancelAllQueries=function(a){for(;0<
k.PendingAjax.length;){var c=k.PendingAjax.shift();c[1](null,a,c[2])}null!=k.websocket&&(k.websocket.close(),k.websocket=null,k.socketState=0)};return k},CreateAmtRedirect=function(a){var b={};b.m=a;a.parent=b;b.State=0;b.socket=null;b.host=null;b.port=0;b.user=null;b.pass=null;b.authuri="/RedirectionService";b.tlsv1only=0;b.connectstate=0;b.protocol=a.protocol;b.amtaccumulator="";b.amtsequence=1;b.amtkeepalivetimer=null;b.onStateChanged=null;b.Start=function(a,d,f,n,p){b.host=a;b.port=d;b.user=f;
b.pass=n;b.connectstate=0;b.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+a+"&port="+d+"&tls="+p+("*"==f?"&serverauth=1":"")+("undefined"===typeof n?"&serverauth=1&user="+f:"")+"&tls1only="+b.tlsv1only);b.socket.onopen=b.xxOnSocketConnected;b.socket.onmessage=b.xxOnMessage;b.socket.onclose=b.xxOnSocketClosed;b.xxStateChange(1)};b.xxOnSocketConnected=
function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CONNECT");b.xxStateChange(2);1==b.protocol&&b.xxSend(b.RedirectStartSol);2==b.protocol&&b.xxSend(b.RedirectStartKvm);3==b.protocol&&b.xxSend(b.RedirectStartIder)};b.xxOnMessage=function(a){if("object"==typeof a.data){var d=new FileReader;if(d.readAsBinaryString)d.onload=function(a){b.xxOnSocketData(a.target.result)},d.readAsBinaryString(new Blob([a.data]));else if(d.readAsArrayBuffer)d.onloadend=function(a){b.xxOnSocketData(a.target.result)},
d.readAsArrayBuffer(a.data);else{d="";a=new Uint8Array(a.data);for(var f=a.byteLength,n=0;n<f;n++)d+=String.fromCharCode(a[n]);b.xxOnSocketData(d)}}else b.xxOnSocketData(a.data)};b.xxOnSocketData=function(a){if(a&&-1!=b.connectstate){if("object"===typeof a){var d="",f=new Uint8Array(a),n=f.byteLength;for(a=0;a<n;a++)d+=String.fromCharCode(f[a]);a=d}else if("string"!==typeof a)return;if((2==b.protocol||3==b.protocol)&&1==b.connectstate)return b.m.ProcessData(a);b.amtaccumulator+=a;for(urlvars&&urlvars.redirtrace&&
console.log("REDIR-RECV("+b.amtaccumulator.length+"): "+rstr2hex(b.amtaccumulator));1<=b.amtaccumulator.length;){a=0;switch(b.amtaccumulator.charCodeAt(0)){case 17:if(4>b.amtaccumulator.length)return;switch(b.amtaccumulator.charCodeAt(1)){case 0:if(13>b.amtaccumulator.length)return;d=b.amtaccumulator.charCodeAt(12);if(b.amtaccumulator.length<13+d)return;b.xxSend(String.fromCharCode(19,0,0,0,0,0,0,0,0));a=13+d;break;default:b.Stop()}break;case 20:if(9>b.amtaccumulator.length)return;var p=ReadIntX(b.amtaccumulator,
5);if(b.amtaccumulator.length<9+p)return;var n=b.amtaccumulator.charCodeAt(1),d=b.amtaccumulator.charCodeAt(4),r=[];for(a=0;a<p;a++)r.push(b.amtaccumulator.charCodeAt(9+a));f=b.amtaccumulator.substring(9,9+p);a=9+p;if(0==d)0<=r.indexOf(4)?b.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(b.user.length+b.authuri.length+8)+String.fromCharCode(b.user.length)+b.user+String.fromCharCode(0,0)+String.fromCharCode(b.authuri.length)+b.authuri+String.fromCharCode(0,0,0,0)):0<=r.indexOf(3)?b.xxSend(String.fromCharCode(19,
0,0,0,3)+IntToStrX(b.user.length+b.authuri.length+7)+String.fromCharCode(b.user.length)+b.user+String.fromCharCode(0,0)+String.fromCharCode(b.authuri.length)+b.authuri+String.fromCharCode(0,0,0)):0<=r.indexOf(1)?b.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(b.user.length+b.pass.length+2)+String.fromCharCode(b.user.length)+b.user+String.fromCharCode(b.pass.length)+b.pass):b.Stop();else if(3!=d&&4!=d||1!=n)0==n?(1==b.protocol&&b.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(b.amtsequence++)+ShortToStrX(1E4)+
2018-10-03 22:03:09 +03:00
ShortToStrX(100)+ShortToStrX(0)+ShortToStrX(1E4)+ShortToStrX(100)+ShortToStrX(0)+IntToStrX(0)),2==b.protocol&&b.xxSend(String.fromCharCode(64,0,0,0,0,0,0,0)),3==b.protocol&&(b.connectstate=1,b.xxStateChange(3))):b.Stop();else{var p=0,r=f.charCodeAt(p),n=f.substring(p+1,p+1+r),p=p+(r+1),l=f.charCodeAt(p),r=f.substring(p+1,p+1+l),p=p+(l+1),l=0,l=null,k=b.xxRandomNonce(32),v="";4==d&&(l=f.charCodeAt(p),l=f.substring(p+1,p+1+l),v="00000002:"+k+":"+l+":");f=hex_md5(hex_md5(b.user+":"+n+":"+b.pass)+":"+
r+":"+v+hex_md5("POST:"+b.authuri));p=b.user.length+n.length+r.length+b.authuri.length+k.length+8+f.length+7;4==d&&(p+=l.length+1);f=String.fromCharCode(19,0,0,0,d)+IntToStrX(p)+String.fromCharCode(b.user.length)+b.user+String.fromCharCode(n.length)+n+String.fromCharCode(r.length)+r+String.fromCharCode(b.authuri.length)+b.authuri+String.fromCharCode(k.length)+k+String.fromCharCode(8)+"00000002"+String.fromCharCode(f.length)+f;4==d&&(f+=String.fromCharCode(l.length)+l);b.xxSend(f)}break;case 33:if(23>
2018-08-24 02:55:06 +03:00
b.amtaccumulator.length)break;a=23;b.xxSend(String.fromCharCode(39,0,0,0)+IntToStrX(b.amtsequence++)+String.fromCharCode(0,0,27,0,0,0));1==b.protocol&&(b.amtkeepalivetimer=setInterval(b.xxSendAmtKeepAlive,2E3));b.connectstate=1;b.xxStateChange(3);break;case 41:if(10>b.amtaccumulator.length)break;a=10;break;case 42:if(10>b.amtaccumulator.length)break;d=10+((b.amtaccumulator.charCodeAt(9)&255)<<8)+(b.amtaccumulator.charCodeAt(8)&255);if(b.amtaccumulator.length<d)break;b.m.ProcessData(b.amtaccumulator.substring(10,
d));a=d;break;case 43:if(8>b.amtaccumulator.length)break;a=8;break;case 65:if(8>b.amtaccumulator.length)break;b.connectstate=1;b.m.Start();8<b.amtaccumulator.length&&b.m.ProcessData(b.amtaccumulator.substring(8));a=b.amtaccumulator.length;break;default:console.log("Unknown Intel AMT command: "+b.amtaccumulator.charCodeAt(0)+" acclen="+b.amtaccumulator.length);b.Stop();return}if(0==a)break;b.amtaccumulator=b.amtaccumulator.substring(a)}}};b.xxSend=function(a){urlvars&&urlvars.redirtrace&&console.log("REDIR-SEND("+
a.length+"): "+rstr2hex(a));if(null!=b.socket&&b.socket.readyState==WebSocket.OPEN){for(var d=new Uint8Array(a.length),f=0;f<a.length;++f)d[f]=a.charCodeAt(f);b.socket.send(d.buffer)}};b.Send=function(a){null!=b.socket&&1==b.connectstate&&(1==b.protocol?b.xxSend(String.fromCharCode(40,0,0,0)+IntToStrX(b.amtsequence++)+ShortToStrX(a.length)+a):b.xxSend(a))};b.xxSendAmtKeepAlive=function(){null!=b.socket&&b.xxSend(String.fromCharCode(43,0,0,0)+IntToStrX(b.amtsequence++))};b.xxRandomNonceX="abcdef0123456789";
b.xxRandomNonce=function(a){for(var d="",f=0;f<a;f++)d+=b.xxRandomNonceX.charAt(Math.floor(Math.random()*b.xxRandomNonceX.length));return d};b.xxOnSocketClosed=function(){urlvars&&urlvars.redirtrace&&console.log("REDIR-CLOSED");b.Stop()};b.xxStateChange=function(a){if(b.State!=a&&(b.State=a,b.m.xxStateChange(b.State),null!=b.onStateChanged))b.onStateChanged(b,b.State)};b.Stop=function(){b.xxStateChange(0);b.connectstate=-1;b.amtaccumulator="";null!=b.socket&&(b.socket.close(),b.socket=null);null!=
b.amtkeepalivetimer&&(clearInterval(b.amtkeepalivetimer),b.amtkeepalivetimer=null)};b.RedirectStartSol=String.fromCharCode(16,0,0,0,83,79,76,32);b.RedirectStartKvm=String.fromCharCode(16,1,0,0,75,86,77,82);b.RedirectStartIder=String.fromCharCode(16,0,0,0,73,68,69,82);return b},WsmanStackCreateService=function(a,b,c,d,f,n){function p(a){for(var c,b={},l=0;l<a.childNodes.length;l++){var h=a.childNodes[l];c=null==h.childElementCount||0==h.childElementCount?h.textContent:p(h);"true"==c&&(c=!0);"false"==
2018-11-15 02:44:28 +03:00
c&&(c=!1);parseInt(c)+""===c&&(c=parseInt(c));var g=c;if(null!=h.attributes&&0<h.attributes.length)for(g={Value:c},c=0;c<h.attributes.length;c++)g["@"+h.attributes[c].name]=h.attributes[c].value;b[h.localName]instanceof Array?b[h.localName].push(g):b[h.localName]=null==b[h.localName]?g:[b[h.localName],g]}return b}function r(a){if(!a)return"";var c="",b;for(b in a)a.hasOwnProperty(b)&&0===b.indexOf("@")&&(c+=" "+b.substring(1)+'="'+a[b]+'"');return c}function l(a){if(!a)return"";if("string"==typeof a)return a;
2018-08-24 02:55:06 +03:00
if(a.InstanceID)return'<w:SelectorSet><w:Selector Name="InstanceID">'+a.InstanceID+"</w:Selector></w:SelectorSet>";var c="<w:SelectorSet>",b;for(b in a)if(a.hasOwnProperty(b)){c+='<w:Selector Name="'+b+'">';if(a[b].ReferenceParameters){var c=c+"<a:EndpointReference>",c=c+("<a:Address>"+a[b].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+a[b].ReferenceParameters.ResourceURI+"</w:ResourceURI><w:SelectorSet>"),l=a[b].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(l))for(var h=
0;h<l.length;h++)c+="<w:Selector"+r(l[h])+">"+l[h].Value+"</w:Selector>";else c+="<w:Selector"+r(l)+">"+l.Value+"</w:Selector>";c+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else c+=a[b];c+="</w:Selector>"}return c+"</w:SelectorSet>"}var k={NextMessageId:1,Address:"/wsman"};k.comm=CreateWsmanComm(a,b,c,d,f,n);k.PerformAjax=function(a,c,b,l,h){null==h&&(h="");k.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+
2018-11-15 02:44:28 +03:00
h+"><Header><a:Action>"+a,function(a,b,l){200!=b?c(k,null,{Header:{HttpError:b}},b,l):(a=k.ParseWsman(a))&&null!=a?c(k,a.Header.ResourceURI,a,200,l):c(k,null,{Header:{HttpError:b}},601,l)},b,l)};k.CancelAllQueries=function(a){k.comm.CancelAllQueries(a)};k.GetNameFromUrl=function(a){var c=a.lastIndexOf("/");return-1==c?a:a.substring(c+1)};k.ExecSubscribe=function(a,c,b,d,h,g,E,m,F,w){var y="",C="";m="";null!=F&&null!=w&&(y='<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>'+
F+'</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">'+w+"</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>",C='<w:Auth Profile="http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/digest"/>');null!=m&&(m="<a:ReferenceParameters><m:arg>"+m+"</m:arg></a:ReferenceParameters>");"PushWithAck"==c?c="dmtf.org/wbem/wsman/1/wsman/PushWithAck":"Push"==c&&(c="xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push");
a="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+l(E)+y+'</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.'+c+'"><e:NotifyTo><a:Address>'+b+"</a:Address>"+m+"</e:NotifyTo>"+C+"</e:Delivery></e:Subscribe>";k.PerformAjax(a+"</Body></Envelope>",d,h,
2018-08-24 02:55:06 +03:00
g,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:m="http://x.com"')};k.ExecUnSubscribe=function(a,c,b,d,h){a="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+l(h)+"</Header><Body><e:Unsubscribe/>";k.PerformAjax(a+"</Body></Envelope>",c,b,d,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')};
2018-11-15 02:44:28 +03:00
k.ExecPut=function(a,c,b,d,h,g){g="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>"+l(g)+"</Header><Body>";if(a&&null!=c){var E=k.GetNameFromUrl(a);a="<r:"+E+' xmlns:r="'+a+'">';for(var m in c)if(c.hasOwnProperty(m)&&
0!==m.indexOf("__")&&0!==m.indexOf("@")&&null!=c[m]&&"function"!==typeof c[m])if("object"===typeof c[m]&&c[m].ReferenceParameters){a+="<r:"+m+"><a:Address>"+c[m].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+c[m].ReferenceParameters.ResourceURI+"</w:ResourceURI><w:SelectorSet>";var F=c[m].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(F))for(var w=0;w<F.length;w++)a+="<w:Selector"+r(F[w])+">"+F[w].Value+"</w:Selector>";else a+="<w:Selector"+r(F)+">"+F.Value+"</w:Selector>";
a+="</w:SelectorSet></a:ReferenceParameters></r:"+m+">"}else if(Array.isArray(c[m]))for(w=0;w<c[m].length;w++)a+="<r:"+m+">"+c[m][w].toString()+"</r:"+m+">";else a+="<r:"+m+">"+c[m].toString()+"</r:"+m+">";c=a+("</r:"+E+">")}else c="";k.PerformAjax(g+c+"</Body></Envelope>",b,d,h)};k.ExecCreate=function(a,c,b,d,h,g){var E=k.GetNameFromUrl(a);a="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +
"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+l(g)+"</Header><Body><g:"+E+' xmlns:g="'+a+'">';for(var m in c)a+="<g:"+m+">"+c[m]+"</g:"+m+">";k.PerformAjax(a+"</g:"+E+"></Body></Envelope>",b,d,h)};k.ExecDelete=function(a,c,b,d,h){a="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +
2018-08-24 02:55:06 +03:00
"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+l(c)+"</Header><Body /></Envelope>";k.PerformAjax(a,b,d,h)};k.ExecGet=function(a,c,b,l){k.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>",
2018-11-15 02:44:28 +03:00
c,b,l)};k.ExecMethod=function(a,c,b,l,h,g,d){var m="",F;for(F in b)if(null!=b[F])if(Array.isArray(b[F]))for(var w in b[F])m+="<r:"+F+">"+b[F][w]+"</r:"+F+">";else m+="<r:"+F+">"+b[F]+"</r:"+F+">";k.ExecMethodXml(a,c,m,l,h,g,d)};k.ExecMethodXml=function(a,c,b,d,h,g,E){k.PerformAjax(a+"/"+c+"</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+
l(E)+"</Header><Body><r:"+c+'_INPUT xmlns:r="'+a+'">'+b+"</r:"+c+"_INPUT></Body></Envelope>",d,h,g)};k.ExecEnum=function(a,c,b,l){k.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration" /></Body></Envelope>',
2018-08-24 02:55:06 +03:00
c,b,l)};k.ExecPull=function(a,c,b,l,h){k.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>"+k.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+k.NextMessageId++ +'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"><EnumerationContext>'+c+"</EnumerationContext></Pull></Body></Envelope>",
b,l,h)};k.ParseWsman=function(a){try{if(!a.childNodes){var c=a;if(window.DOMParser)a=(new DOMParser).parseFromString(c,"text/xml");else{var b=new ActiveXObject("Microsoft.XMLDOM");b.async=!1;b.loadXML(c);a=b}}var c={Header:{}},l=a.getElementsByTagName("Header")[0],h;l||(l=a.getElementsByTagName("a:Header")[0]);if(!l)return null;for(b=0;b<l.childNodes.length;b++){var g=l.childNodes[b];c.Header[g.localName]=g.textContent}var d=a.getElementsByTagName("Body")[0];d||(d=a.getElementsByTagName("a:Body")[0]);
if(!d)return null;0<d.childNodes.length&&(h=d.childNodes[0].localName,h.indexOf("_OUTPUT")==h.length-7&&(h=h.substring(0,h.length-7)),c.Header.Method=h,c.Body=p(d.childNodes[0]));return c}catch(m){return console.log("Unable to parse XML: "+a),null}};return k};
2018-11-15 02:44:28 +03:00
function AmtStackCreateService(a){function b(){var a=e.GetPendingActions();u<a&&(u=a);null!=e.onProcessChanged&&B!=a&&(B=a,e.onProcessChanged(a,u));0==a&&(u=0)}function c(a,c,b,l,g,h,z){200!=g?(b(e,a,null,g,h),f(1)):null!=c&&"EnumerateResponse"==c.Header.Method&&c.Body.EnumerationContext?e.wsman.ExecPull(l,c.Body.EnumerationContext,function(c,l,g,w){d(a,g,b,l,[],w,h,z)}):(b(e,a,null,603,h),f(1))}function d(a,c,l,g,h,m,z,k){if(200!=m)l(e,a,null,m,z),f(1);else if(null==c||"PullResponse"!=c.Header.Method)l(e,
a,null,604,z),f(1);else{for(var v in c.Body.Items)if(c.Body.Items[v]instanceof Array)for(var u in c.Body.Items[v])"function"!=typeof c.Body.Items[v][u]&&h.push(c.Body.Items[v][u]);else"function"!=typeof c.Body.Items[v]&&h.push(c.Body.Items[v]);c.Body.EnumerationContext?e.wsman.ExecPull(g,c.Body.EnumerationContext,function(c,b,g,w){d(a,g,l,b,h,w,z,1)}):(f(1),l(e,a,h,m,z),b())}}function f(a){e.ActiveEnumsCount-=a;e.ActiveEnumsCount>=e.MaxActiveEnumsCount||0==e.PendingEnums.length?b():(a=e.PendingEnums.shift(),
e.Enum(a[0],a[1],a[2]),f(0))}function n(a,c,l,g,h,d,z){e.PendingBatchOperations-=2;var m=c.shift(),k=e.Enum;"*"==m[0]&&(k=e.Get,m=m.substring(1));k(m,function(h,m,k,A,D){D[2][m]={response:null==k?null:k.Body,responses:k,status:A};0==D[1].length||401==A||1!=d&&200!=A&&400!=A?(e.PendingBatchOperations-=2*c.length,b(),l(e,a,D[2],A,g)):(b(),n(a,c,l,g,D[2],z))},[a,c,h],z);b()}function p(a){a.names.length<=a.current?a.callback(e,a.name,a.responses,200,a.tag):(e.wsman.ExecGet(e.CompleteName(a.names[a.current]),
function(c,b,l,g){null==l||200!=g?a.callback(e,a.name,null,g,a.tag):(a.responses[l.Header.Method]=l,p(a))},a.pri),a.current++);b()}function r(a,c,b,g,h){if(200!=g||"0"!=b.Body.ReturnValue)h[0](e,null,h[2]);else e.AMT_MessageLog_GetRecords(b.Body.IterationIdentifier,390,l,h)}function l(a,c,b,g,h){if(200!=g||"0"!=b.Body.ReturnValue)h[0](e,null,h[2]);else{var d,z,m;c=h[2];g=new Date;var v=b.Body.RecordArray;"string"===typeof v&&(b.Body.RecordArray=[b.Body.RecordArray]);for(d in v){a=null;try{a=window.atob(v[d])}catch(u){}if(null!=
a&&(z=ReadIntX(a,0),0<z&&4294967295>z)){m={DeviceAddress:a.charCodeAt(4),EventSensorType:a.charCodeAt(5),EventType:a.charCodeAt(6),EventOffset:a.charCodeAt(7),EventSourceType:a.charCodeAt(8),EventSeverity:a.charCodeAt(9),SensorNumber:a.charCodeAt(10),Entity:a.charCodeAt(11),EntityInstance:a.charCodeAt(12),EventData:[],Time:new Date(1E3*(z+60*g.getTimezoneOffset()))};for(z=13;21>z;z++)m.EventData.push(a.charCodeAt(z));m.EntityStr=E[m.Entity];m.Desc=k(m.EventSensorType,m.EventOffset,m.EventData,m.Entity);
2018-08-24 02:55:06 +03:00
m.EntityStr||(m.EntityStr="Unknown");c.push(m)}}if(1!=b.Body.NoMoreRecords)e.AMT_MessageLog_GetRecords(b.Body.IterationIdentifier,390,l,[h[0],c,h[2]]);else h[0](e,c,h[2])}}function k(a,c,b,l){if(15==a)return 235==b[0]?"Invalid Data":0==c?h[b[1]]:g[b[1]];if(18==a&&170==b[0])return"Agent watchdog "+char2hex(b[4])+char2hex(b[3])+char2hex(b[2])+char2hex(b[1])+"-"+char2hex(b[6])+char2hex(b[5])+"-... changed to "+e.WatchdogCurrentStates[b[7]];if(5==a&&0==c)return"Case intrusion";if(192==a&&0==c&&170==b[0]&&
48==b[1]){if(0==b[2])return"A remote Serial Over LAN session was established.";if(1==b[2])return"Remote Serial Over LAN session finished. User control was restored.";if(2==b[2])return"A remote IDE-Redirection session was established.";if(3==b[2])return"Remote IDE-Redirection session finished. User control was restored."}if(36==a)return a=(b[1]<<24)+(b[2]<<16)+(b[3]<<8)+b[4],c="#"+b[0],170==b[0]&&(c="wired"),4294967293==a?"All received packet filter was matched on "+c+" interface.":4294967292==a?"All outbound packet filter was matched on "+
c+" interface.":4294967290==a?"Spoofed packet filter was matched on "+c+" interface.":"Filter "+a+" was matched on "+c+" interface.";if(192==a)return 0==b[2]?"Security policy invoked. Some or all network traffic (TX) was stopped.":2==b[2]?"Security policy invoked. Some or all network traffic (RX) was stopped.":"Security policy invoked.";if(193==a){if(170==b[0]&&48==b[1]&&0==b[2]&&0==b[3])return"User request for remote connection.";if(170==b[0]&&32==b[1]&&3==b[2]&&1==b[3])return"EAC error: attempt to get posture while NAC in Intel\ufffd AMT is disabled.";
2018-11-15 02:44:28 +03:00
if(170==b[0]&&32==b[1]&&4==b[2]&&0==b[3])return"Certificate revoked. "}return 6==a?"Authentication failed "+(b[1]+(b[2]<<8))+" times. The system may be under attack.":30==a?"No bootable media":32==a?"Operating system lockup or power interrupt":35==a?"System boot failure":37==a?"System firmware started (at least one CPU is properly executing).":"Unknown Sensor Type #"+a}function v(a,c,b,l,g){if(200!=l)g[0](e,[],l);else{var h,d,k=g[1],x=new Date,u;if(0<b.Body.RecordsReturned)for(d in b.Body.EventRecords=
MakeToArray(b.Body.EventRecords),b.Body.EventRecords){a=null;try{a=window.atob(b.Body.EventRecords[d])}catch(B){console.log(B+" "+b.Body.EventRecords[d])}c={AuditAppID:ReadShort(a,0),EventID:ReadShort(a,2),InitiatorType:a.charCodeAt(4)};c.AuditApp=m[c.AuditAppID];c.Event=m[100*c.AuditAppID+c.EventID];c.Event||(c.Event="#"+c.EventID);0==c.InitiatorType&&(h=a.charCodeAt(5),c.Initiator=a.substring(6,6+h),h=6+h);1==c.InitiatorType&&(c.KerberosUserInDomain=ReadInt(a,5),h=a.charCodeAt(9),c.Initiator=GetSidString(a.substring(10,
10+h)),h=10+h);2==c.InitiatorType&&(c.Initiator="<i>Local</i>",h=5);3==c.InitiatorType&&(c.Initiator="<i>KVM Default Port</i>",h=5);u=ReadInt(a,h);c.Time=new Date(1E3*(u+60*x.getTimezoneOffset()));h+=4;c.MCLocationType=a.charCodeAt(h++);u=a.charCodeAt(h++);c.NetAddress=a.substring(h,h+u);h+=u;u=a.charCodeAt(h++);c.Ex=a.substring(h,h+u);c.ExStr=e.GetAuditLogExtendedDataStr(100*c.AuditAppID+c.EventID,c.Ex);k.push(c)}if(b.Body.TotalRecordCount>k.length)e.AMT_AuditLog_ReadRecords(k.length+1,v,[g[0],k]);
else g[0](e,k,l)}}var e={};e.wsman=a;e.pfx=["http://intel.com/wbem/wscim/1/amt-schema/1/","http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/","http://intel.com/wbem/wscim/1/ips-schema/1/"];e.PendingEnums=[];e.PendingBatchOperations=0;e.ActiveEnumsCount=0;e.MaxActiveEnumsCount=1;e.onProcessChanged=null;var u=0,B=0;e.GetPendingActions=function(){return 2*e.PendingEnums.length+e.ActiveEnumsCount+e.wsman.comm.PendingAjax.length+e.wsman.comm.ActiveAjaxCount+e.PendingBatchOperations};e.Subscribe=function(a,
c,l,h,g,d,z,m,k,v){e.wsman.ExecSubscribe(e.CompleteName(a),c,l,function(c,l,y,d){b();h(e,a,y,d,g)},0,d,z,m,k,v);b()};e.UnSubscribe=function(a,c,l,h,g){e.wsman.ExecUnSubscribe(e.CompleteName(a),function(h,g,d,m){b();c(e,a,d,m,l)},0,h,g);b()};e.Get=function(a,c,l,h){e.wsman.ExecGet(e.CompleteName(a),function(h,g,d,m){b();c(e,a,d,m,l)},0,h);b()};e.Put=function(a,c,l,h,g,d){e.wsman.ExecPut(e.CompleteName(a),c,function(c,g,d,m){b();l(e,a,d,m,h)},0,g,d);b()};e.Create=function(a,c,l,h,g){e.wsman.ExecCreate(e.CompleteName(a),
c,function(c,g,d,m){b();l(e,a,d,m,h)},0,g);b()};e.Delete=function(a,c,l,h,g){e.wsman.ExecDelete(e.CompleteName(a),c,function(c,g,d,m){b();l(e,a,d,m,h)},0,g);b()};e.Exec=function(a,c,l,h,g,d,z){e.wsman.ExecMethod(e.CompleteName(a),c,l,function(c,l,y,d){b();h(e,a,e.CompleteExecResponse(y),d,g)},0,d,z);b()};e.ExecWithXml=function(a,c,l,h,g,d,z){e.wsman.ExecMethodXml(e.CompleteName(a),c,execArgumentsToXml(l),function(c,l,y,d){b();h(e,a,e.CompleteExecResponse(y),d,g)},0,d,z);b()};e.Enum=function(a,l,y,
h){e.ActiveEnumsCount<e.MaxActiveEnumsCount?(e.ActiveEnumsCount++,e.wsman.ExecEnum(e.CompleteName(a),function(y,h,g,d,m){b();c(a,g,l,h,d,m)},y,h)):e.PendingEnums.push([a,l,y,h]);b()};e.BatchEnum=function(a,c,l,h,g,d){e.PendingBatchOperations+=2*c.length;n(a,Clone(c),l,h,{},g,d);b()};e.BatchGet=function(a,c,l,h,g){p({name:a,names:c,callback:l,current:0,responses:{},tag:h,pri:g});b()};e.CompleteName=function(a){if(0==a.indexOf("AMT_"))return e.pfx[0]+a;if(0==a.indexOf("CIM_"))return e.pfx[1]+a;if(0==
2018-08-24 02:55:06 +03:00
a.indexOf("IPS_"))return e.pfx[2]+a};e.CompleteExecResponse=function(a){a&&null!=a&&a.Body&&void 0!=a.Body.ReturnValue&&(a.Body.ReturnValueStr=e.AmtStatusToStr(a.Body.ReturnValue));return a};e.RequestPowerStateChange=function(a,c){e.CIM_PowerManagementService_RequestPowerStateChange(a,'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="CreationClassName">CIM_ComputerSystem</Selector><Selector Name="Name">ManagedSystem</Selector></SelectorSet></ReferenceParameters>',
null,null,c)};e.SetBootConfigRole=function(a,c){e.CIM_BootService_SetBootConfigRole('<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>',
a,c)};e.CancelAllQueries=function(a){e.wsman.CancelAllQueries(a)};e.AMT_AgentPresenceWatchdog_RegisterAgent=function(a){e.Exec("AMT_AgentPresenceWatchdog","RegisterAgent",{},a)};e.AMT_AgentPresenceWatchdog_AssertPresence=function(a,c){e.Exec("AMT_AgentPresenceWatchdog","AssertPresence",{SequenceNumber:a},c)};e.AMT_AgentPresenceWatchdog_AssertShutdown=function(a,c){e.Exec("AMT_AgentPresenceWatchdog","AssertShutdown",{SequenceNumber:a},c)};e.AMT_AgentPresenceWatchdog_AddAction=function(a,c,b,l,h,g,
2018-10-03 22:03:09 +03:00
d,m,k){e.Exec("AMT_AgentPresenceWatchdog","AddAction",{OldState:a,NewState:c,EventOnTransition:b,ActionSd:l,ActionEac:h},g,d,m,k)};e.AMT_AgentPresenceWatchdog_DeleteAllActions=function(a,c,b,l){e.Exec("AMT_AgentPresenceWatchdog","DeleteAllActions",{},a,c,b,l)};e.AMT_AgentPresenceWatchdogAction_GetActionEac=function(a){e.Exec("AMT_AgentPresenceWatchdogAction","GetActionEac",{},a)};e.AMT_AgentPresenceWatchdogVA_RegisterAgent=function(a){e.Exec("AMT_AgentPresenceWatchdogVA","RegisterAgent",{},a)};e.AMT_AgentPresenceWatchdogVA_AssertPresence=
2018-08-24 02:55:06 +03:00
function(a,c){e.Exec("AMT_AgentPresenceWatchdogVA","AssertPresence",{SequenceNumber:a},c)};e.AMT_AgentPresenceWatchdogVA_AssertShutdown=function(a,c){e.Exec("AMT_AgentPresenceWatchdogVA","AssertShutdown",{SequenceNumber:a},c)};e.AMT_AgentPresenceWatchdogVA_AddAction=function(a,c,b,l,h,g){e.Exec("AMT_AgentPresenceWatchdogVA","AddAction",{OldState:a,NewState:c,EventOnTransition:b,ActionSd:l,ActionEac:h},g)};e.AMT_AgentPresenceWatchdogVA_DeleteAllActions=function(a,c){e.Exec("AMT_AgentPresenceWatchdogVA",
"DeleteAllActions",{_method_dummy:a},c)};e.AMT_AuditLog_ClearLog=function(a){e.Exec("AMT_AuditLog","ClearLog",{},a)};e.AMT_AuditLog_RequestStateChange=function(a,c,b){e.Exec("AMT_AuditLog","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.AMT_AuditLog_ReadRecords=function(a,c,b){e.Exec("AMT_AuditLog","ReadRecords",{StartIndex:a},c,b)};e.AMT_AuditLog_SetAuditLock=function(a,c,b,l){e.Exec("AMT_AuditLog","SetAuditLock",{LockTimeoutInSeconds:a,Flag:c,Handle:b},l)};e.AMT_AuditLog_ExportAuditLogSignature=
function(a,c){e.Exec("AMT_AuditLog","ExportAuditLogSignature",{SigningMechanism:a},c)};e.AMT_AuditLog_SetSigningKeyMaterial=function(a,c,b,l,h){e.Exec("AMT_AuditLog","SetSigningKeyMaterial",{SigningMechanismType:a,SigningKey:c,LengthOfCertificates:b,Certificates:l},h)};e.AMT_AuditPolicyRule_SetAuditPolicy=function(a,c,b,l,h){e.Exec("AMT_AuditPolicyRule","SetAuditPolicy",{Enable:a,AuditedAppID:c,EventID:b,PolicyType:l},h)};e.AMT_AuditPolicyRule_SetAuditPolicyBulk=function(a,c,b,l,h){e.Exec("AMT_AuditPolicyRule",
"SetAuditPolicyBulk",{Enable:a,AuditedAppID:c,EventID:b,PolicyType:l},h)};e.AMT_AuthorizationService_AddUserAclEntryEx=function(a,c,b,l,h,g){e.Exec("AMT_AuthorizationService","AddUserAclEntryEx",{DigestUsername:a,DigestPassword:c,KerberosUserSid:b,AccessPermission:l,Realms:h},g)};e.AMT_AuthorizationService_EnumerateUserAclEntries=function(a,c){e.Exec("AMT_AuthorizationService","EnumerateUserAclEntries",{StartIndex:a},c)};e.AMT_AuthorizationService_GetUserAclEntryEx=function(a,c,b){e.Exec("AMT_AuthorizationService",
2018-10-03 22:03:09 +03:00
"GetUserAclEntryEx",{Handle:a},c,b)};e.AMT_AuthorizationService_UpdateUserAclEntryEx=function(a,c,b,l,h,g,d){e.Exec("AMT_AuthorizationService","UpdateUserAclEntryEx",{Handle:a,DigestUsername:c,DigestPassword:b,KerberosUserSid:l,AccessPermission:h,Realms:g},d)};e.AMT_AuthorizationService_RemoveUserAclEntry=function(a,c){e.Exec("AMT_AuthorizationService","RemoveUserAclEntry",{Handle:a},c)};e.AMT_AuthorizationService_SetAdminAclEntryEx=function(a,c,b){e.Exec("AMT_AuthorizationService","SetAdminAclEntryEx",
2018-08-24 02:55:06 +03:00
{Username:a,DigestPassword:c},b)};e.AMT_AuthorizationService_GetAdminAclEntry=function(a){e.Exec("AMT_AuthorizationService","GetAdminAclEntry",{},a)};e.AMT_AuthorizationService_GetAdminAclEntryStatus=function(a){e.Exec("AMT_AuthorizationService","GetAdminAclEntryStatus",{},a)};e.AMT_AuthorizationService_GetAdminNetAclEntryStatus=function(a){e.Exec("AMT_AuthorizationService","GetAdminNetAclEntryStatus",{},a)};e.AMT_AuthorizationService_SetAclEnabledState=function(a,c,b,l){e.Exec("AMT_AuthorizationService",
"SetAclEnabledState",{Handle:a,Enabled:c},b,l)};e.AMT_AuthorizationService_GetAclEnabledState=function(a,c,b){e.Exec("AMT_AuthorizationService","GetAclEnabledState",{Handle:a},c,b)};e.AMT_EndpointAccessControlService_RequestStateChange=function(a,c,b){e.Exec("AMT_EndpointAccessControlService","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.AMT_EndpointAccessControlService_GetPosture=function(a,c){e.Exec("AMT_EndpointAccessControlService","GetPosture",{PostureType:a},c)};e.AMT_EndpointAccessControlService_GetPostureHash=
function(a,c){e.Exec("AMT_EndpointAccessControlService","GetPostureHash",{PostureType:a},c)};e.AMT_EndpointAccessControlService_UpdatePostureState=function(a,c){e.Exec("AMT_EndpointAccessControlService","UpdatePostureState",{UpdateType:a},c)};e.AMT_EndpointAccessControlService_GetEacOptions=function(a){e.Exec("AMT_EndpointAccessControlService","GetEacOptions",{},a)};e.AMT_EndpointAccessControlService_SetEacOptions=function(a,c,b){e.Exec("AMT_EndpointAccessControlService","SetEacOptions",{EacVendors:a,
PostureHashAlgorithm:c},b)};e.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy=function(a,c){e.Exec("AMT_EnvironmentDetectionSettingData","SetSystemDefensePolicy",{Policy:a},c)};e.AMT_EnvironmentDetectionSettingData_EnableVpnRouting=function(a,c){e.Exec("AMT_EnvironmentDetectionSettingData","EnableVpnRouting",{Enable:a},c)};e.AMT_EthernetPortSettings_SetLinkPreference=function(a,c,b){e.Exec("AMT_EthernetPortSettings","SetLinkPreference",{LinkPreference:a,Timeout:c},b)};e.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats=
function(a,c){e.Exec("AMT_HeuristicPacketFilterStatistics","ResetSelectedStats",{SelectedStatistics:a},c)};e.AMT_KerberosSettingData_GetCredentialCacheState=function(a){e.Exec("AMT_KerberosSettingData","GetCredentialCacheState",{},a)};e.AMT_KerberosSettingData_SetCredentialCacheState=function(a,c){e.Exec("AMT_KerberosSettingData","SetCredentialCacheState",{Enable:a},c)};e.AMT_MessageLog_CancelIteration=function(a,c){e.Exec("AMT_MessageLog","CancelIteration",{IterationIdentifier:a},c)};e.AMT_MessageLog_RequestStateChange=
function(a,c,b){e.Exec("AMT_MessageLog","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.AMT_MessageLog_ClearLog=function(a){e.Exec("AMT_MessageLog","ClearLog",{},a)};e.AMT_MessageLog_GetRecords=function(a,c,b,l){e.Exec("AMT_MessageLog","GetRecords",{IterationIdentifier:a,MaxReadRecords:c},b,l)};e.AMT_MessageLog_GetRecord=function(a,c,b){e.Exec("AMT_MessageLog","GetRecord",{IterationIdentifier:a,PositionToNext:c},b)};e.AMT_MessageLog_PositionAtRecord=function(a,c,b,l){e.Exec("AMT_MessageLog",
"PositionAtRecord",{IterationIdentifier:a,MoveAbsolute:c,RecordNumber:b},l)};e.AMT_MessageLog_PositionToFirstRecord=function(a,c){e.Exec("AMT_MessageLog","PositionToFirstRecord",{},a,c)};e.AMT_MessageLog_FreezeLog=function(a,c){e.Exec("AMT_MessageLog","FreezeLog",{Freeze:a},c)};e.AMT_PublicKeyManagementService_AddCRL=function(a,c,b){e.Exec("AMT_PublicKeyManagementService","AddCRL",{Url:a,SerialNumbers:c},b)};e.AMT_PublicKeyManagementService_ResetCRLList=function(a,c){e.Exec("AMT_PublicKeyManagementService",
"ResetCRLList",{_method_dummy:a},c)};e.AMT_PublicKeyManagementService_AddCertificate=function(a,c){e.Exec("AMT_PublicKeyManagementService","AddCertificate",{CertificateBlob:a},c)};e.AMT_PublicKeyManagementService_AddTrustedRootCertificate=function(a,c){e.Exec("AMT_PublicKeyManagementService","AddTrustedRootCertificate",{CertificateBlob:a},c)};e.AMT_PublicKeyManagementService_AddKey=function(a,c){e.Exec("AMT_PublicKeyManagementService","AddKey",{KeyBlob:a},c)};e.AMT_PublicKeyManagementService_GeneratePKCS10Request=
function(a,c,b,l){e.Exec("AMT_PublicKeyManagementService","GeneratePKCS10Request",{KeyPair:a,DNName:c,Usage:b},l)};e.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx=function(a,c,b,l){e.Exec("AMT_PublicKeyManagementService","GeneratePKCS10RequestEx",{KeyPair:a,SigningAlgorithm:c,NullSignedCertificateRequest:b},l)};e.AMT_PublicKeyManagementService_GenerateKeyPair=function(a,c,b){e.Exec("AMT_PublicKeyManagementService","GenerateKeyPair",{KeyAlgorithm:a,KeyLength:c},b)};e.AMT_RedirectionService_RequestStateChange=
2018-11-15 02:44:28 +03:00
function(a,c){e.Exec("AMT_RedirectionService","RequestStateChange",{RequestedState:a},c)};e.AMT_RedirectionService_TerminateSession=function(a,c){e.Exec("AMT_RedirectionService","TerminateSession",{SessionType:a},c)};e.AMT_RemoteAccessService_AddMpServer=function(a,c,b,l,h,g,d,m,k){e.Exec("AMT_RemoteAccessService","AddMpServer",{AccessInfo:a,InfoFormat:c,Port:b,AuthMethod:l,Certificate:h,Username:g,Password:d,CN:m},k)};e.AMT_RemoteAccessService_AddRemoteAccessPolicyRule=function(a,c,b,l,h,g){e.Exec("AMT_RemoteAccessService",
"AddRemoteAccessPolicyRule",{Trigger:a,TunnelLifeTime:c,ExtendedData:b,MpServer:l,InternalMpServer:h},g)};e.AMT_RemoteAccessService_CloseRemoteAccessConnection=function(a,c){e.Exec("AMT_RemoteAccessService","CloseRemoteAccessConnection",{_method_dummy:a},c)};e.AMT_SetupAndConfigurationService_CommitChanges=function(a,c){e.Exec("AMT_SetupAndConfigurationService","CommitChanges",{_method_dummy:a},c)};e.AMT_SetupAndConfigurationService_Unprovision=function(a,c){e.Exec("AMT_SetupAndConfigurationService",
"Unprovision",{ProvisioningMode:a},c)};e.AMT_SetupAndConfigurationService_PartialUnprovision=function(a,c){e.Exec("AMT_SetupAndConfigurationService","PartialUnprovision",{_method_dummy:a},c)};e.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection=function(a,c){e.Exec("AMT_SetupAndConfigurationService","ResetFlashWearOutProtection",{_method_dummy:a},c)};e.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod=function(a,c){e.Exec("AMT_SetupAndConfigurationService","ExtendProvisioningPeriod",
{Duration:a},c)};e.AMT_SetupAndConfigurationService_SetMEBxPassword=function(a,c){e.Exec("AMT_SetupAndConfigurationService","SetMEBxPassword",{Password:a},c)};e.AMT_SetupAndConfigurationService_SetTLSPSK=function(a,c,b){e.Exec("AMT_SetupAndConfigurationService","SetTLSPSK",{PID:a,PPS:c},b)};e.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord=function(a){e.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecord",{},a)};e.AMT_SetupAndConfigurationService_GetUuid=function(a){e.Exec("AMT_SetupAndConfigurationService",
"GetUuid",{},a)};e.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents=function(a){e.Exec("AMT_SetupAndConfigurationService","GetUnprovisionBlockingComponents",{},a)};e.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2=function(a){e.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecordV2",{},a)};e.AMT_SystemDefensePolicy_GetTimeout=function(a){e.Exec("AMT_SystemDefensePolicy","GetTimeout",{},a)};e.AMT_SystemDefensePolicy_SetTimeout=function(a,c){e.Exec("AMT_SystemDefensePolicy",
"SetTimeout",{Timeout:a},c)};e.AMT_SystemDefensePolicy_UpdateStatistics=function(a,c,b,l,h,g){e.Exec("AMT_SystemDefensePolicy","UpdateStatistics",{NetworkInterface:a,ResetOnRead:c},b,l,h,g)};e.AMT_SystemPowerScheme_SetPowerScheme=function(a,c,b){e.Exec("AMT_SystemPowerScheme","SetPowerScheme",{},a,b,0,{InstanceID:c})};e.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch=function(a,c){e.Exec("AMT_TimeSynchronizationService","GetLowAccuracyTimeSynch",{},a,c)};e.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch=
function(a,c,b,l,h){e.Exec("AMT_TimeSynchronizationService","SetHighAccuracyTimeSynch",{Ta0:a,Tm1:c,Tm2:b},l,h)};e.AMT_UserInitiatedConnectionService_RequestStateChange=function(a,c,b){e.Exec("AMT_UserInitiatedConnectionService","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.AMT_WebUIService_RequestStateChange=function(a,c,b){e.Exec("AMT_WebUIService","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.AMT_WiFiPortConfigurationService_AddWiFiSettings=function(a,c,b,l,h,g){e.ExecWithXml("AMT_WiFiPortConfigurationService",
"AddWiFiSettings",{WiFiEndpoint:a,WiFiEndpointSettingsInput:c,IEEE8021xSettingsInput:b,ClientCredential:l,CACredential:h},g)};e.AMT_WiFiPortConfigurationService_UpdateWiFiSettings=function(a,c,b,l,h,g){e.ExecWithXml("AMT_WiFiPortConfigurationService","UpdateWiFiSettings",{WiFiEndpointSettings:a,WiFiEndpointSettingsInput:c,IEEE8021xSettingsInput:b,ClientCredential:l,CACredential:h},g)};e.AMT_WiFiPortConfigurationService_DeleteAllITProfiles=function(a,c){e.Exec("AMT_WiFiPortConfigurationService","DeleteAllITProfiles",
2018-08-24 02:55:06 +03:00
{_method_dummy:a},c)};e.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles=function(a,c){e.Exec("AMT_WiFiPortConfigurationService","DeleteAllUserProfiles",{_method_dummy:a},c)};e.CIM_Account_RequestStateChange=function(a,c,b){e.Exec("CIM_Account","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_AccountManagementService_CreateAccount=function(a,c,b){e.Exec("CIM_AccountManagementService","CreateAccount",{System:a,AccountTemplate:c},b)};e.CIM_BootConfigSetting_ChangeBootOrder=function(a,
c){e.Exec("CIM_BootConfigSetting","ChangeBootOrder",{Source:a},c)};e.CIM_BootService_SetBootConfigRole=function(a,c,b){e.Exec("CIM_BootService","SetBootConfigRole",{BootConfigSetting:a,Role:c},b,0,1)};e.CIM_Card_ConnectorPower=function(a,c,b){e.Exec("CIM_Card","ConnectorPower",{Connector:a,PoweredOn:c},b)};e.CIM_Card_IsCompatible=function(a,c){e.Exec("CIM_Card","IsCompatible",{ElementToCheck:a},c)};e.CIM_Chassis_IsCompatible=function(a,c){e.Exec("CIM_Chassis","IsCompatible",{ElementToCheck:a},c)};
e.CIM_Fan_SetSpeed=function(a,c){e.Exec("CIM_Fan","SetSpeed",{DesiredSpeed:a},c)};e.CIM_KVMRedirectionSAP_RequestStateChange=function(a,c,b){e.Exec("CIM_KVMRedirectionSAP","RequestStateChange",{RequestedState:a},b)};e.CIM_MediaAccessDevice_LockMedia=function(a,c){e.Exec("CIM_MediaAccessDevice","LockMedia",{Lock:a},c)};e.CIM_MediaAccessDevice_SetPowerState=function(a,c,b){e.Exec("CIM_MediaAccessDevice","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_MediaAccessDevice_Reset=function(a){e.Exec("CIM_MediaAccessDevice",
"Reset",{},a)};e.CIM_MediaAccessDevice_EnableDevice=function(a,c){e.Exec("CIM_MediaAccessDevice","EnableDevice",{Enabled:a},c)};e.CIM_MediaAccessDevice_OnlineDevice=function(a,c){e.Exec("CIM_MediaAccessDevice","OnlineDevice",{Online:a},c)};e.CIM_MediaAccessDevice_QuiesceDevice=function(a,c){e.Exec("CIM_MediaAccessDevice","QuiesceDevice",{Quiesce:a},c)};e.CIM_MediaAccessDevice_SaveProperties=function(a){e.Exec("CIM_MediaAccessDevice","SaveProperties",{},a)};e.CIM_MediaAccessDevice_RestoreProperties=
function(a){e.Exec("CIM_MediaAccessDevice","RestoreProperties",{},a)};e.CIM_MediaAccessDevice_RequestStateChange=function(a,c,b){e.Exec("CIM_MediaAccessDevice","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_PhysicalFrame_IsCompatible=function(a,c){e.Exec("CIM_PhysicalFrame","IsCompatible",{ElementToCheck:a},c)};e.CIM_PhysicalPackage_IsCompatible=function(a,c){e.Exec("CIM_PhysicalPackage","IsCompatible",{ElementToCheck:a},c)};e.CIM_PowerManagementService_RequestPowerStateChange=
function(a,c,b,l,h){e.Exec("CIM_PowerManagementService","RequestPowerStateChange",{PowerState:a,ManagedElement:c,Time:b,TimeoutPeriod:l},h,0,1)};e.CIM_PowerSupply_SetPowerState=function(a,c,b){e.Exec("CIM_PowerSupply","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_PowerSupply_Reset=function(a){e.Exec("CIM_PowerSupply","Reset",{},a)};e.CIM_PowerSupply_EnableDevice=function(a,c){e.Exec("CIM_PowerSupply","EnableDevice",{Enabled:a},c)};e.CIM_PowerSupply_OnlineDevice=function(a,c){e.Exec("CIM_PowerSupply",
"OnlineDevice",{Online:a},c)};e.CIM_PowerSupply_QuiesceDevice=function(a,c){e.Exec("CIM_PowerSupply","QuiesceDevice",{Quiesce:a},c)};e.CIM_PowerSupply_SaveProperties=function(a){e.Exec("CIM_PowerSupply","SaveProperties",{},a)};e.CIM_PowerSupply_RestoreProperties=function(a){e.Exec("CIM_PowerSupply","RestoreProperties",{},a)};e.CIM_PowerSupply_RequestStateChange=function(a,c,b){e.Exec("CIM_PowerSupply","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_Processor_SetPowerState=function(a,
c,b){e.Exec("CIM_Processor","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_Processor_Reset=function(a){e.Exec("CIM_Processor","Reset",{},a)};e.CIM_Processor_EnableDevice=function(a,c){e.Exec("CIM_Processor","EnableDevice",{Enabled:a},c)};e.CIM_Processor_OnlineDevice=function(a,c){e.Exec("CIM_Processor","OnlineDevice",{Online:a},c)};e.CIM_Processor_QuiesceDevice=function(a,c){e.Exec("CIM_Processor","QuiesceDevice",{Quiesce:a},c)};e.CIM_Processor_SaveProperties=function(a){e.Exec("CIM_Processor","SaveProperties",
{},a)};e.CIM_Processor_RestoreProperties=function(a){e.Exec("CIM_Processor","RestoreProperties",{},a)};e.CIM_Processor_RequestStateChange=function(a,c,b){e.Exec("CIM_Processor","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_RecordLog_ClearLog=function(a){e.Exec("CIM_RecordLog","ClearLog",{},a)};e.CIM_RecordLog_RequestStateChange=function(a,c,b){e.Exec("CIM_RecordLog","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_RedirectionService_RequestStateChange=function(a,
c,b){e.Exec("CIM_RedirectionService","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_Sensor_SetPowerState=function(a,c,b){e.Exec("CIM_Sensor","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_Sensor_Reset=function(a){e.Exec("CIM_Sensor","Reset",{},a)};e.CIM_Sensor_EnableDevice=function(a,c){e.Exec("CIM_Sensor","EnableDevice",{Enabled:a},c)};e.CIM_Sensor_OnlineDevice=function(a,c){e.Exec("CIM_Sensor","OnlineDevice",{Online:a},c)};e.CIM_Sensor_QuiesceDevice=function(a,c){e.Exec("CIM_Sensor",
"QuiesceDevice",{Quiesce:a},c)};e.CIM_Sensor_SaveProperties=function(a){e.Exec("CIM_Sensor","SaveProperties",{},a)};e.CIM_Sensor_RestoreProperties=function(a){e.Exec("CIM_Sensor","RestoreProperties",{},a)};e.CIM_Sensor_RequestStateChange=function(a,c,b){e.Exec("CIM_Sensor","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_StatisticalData_ResetSelectedStats=function(a,c){e.Exec("CIM_StatisticalData","ResetSelectedStats",{SelectedStatistics:a},c)};e.CIM_Watchdog_KeepAlive=function(a){e.Exec("CIM_Watchdog",
"KeepAlive",{},a)};e.CIM_Watchdog_SetPowerState=function(a,c,b){e.Exec("CIM_Watchdog","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_Watchdog_Reset=function(a){e.Exec("CIM_Watchdog","Reset",{},a)};e.CIM_Watchdog_EnableDevice=function(a,c){e.Exec("CIM_Watchdog","EnableDevice",{Enabled:a},c)};e.CIM_Watchdog_OnlineDevice=function(a,c){e.Exec("CIM_Watchdog","OnlineDevice",{Online:a},c)};e.CIM_Watchdog_QuiesceDevice=function(a,c){e.Exec("CIM_Watchdog","QuiesceDevice",{Quiesce:a},c)};e.CIM_Watchdog_SaveProperties=
function(a){e.Exec("CIM_Watchdog","SaveProperties",{},a)};e.CIM_Watchdog_RestoreProperties=function(a){e.Exec("CIM_Watchdog","RestoreProperties",{},a)};e.CIM_Watchdog_RequestStateChange=function(a,c,b){e.Exec("CIM_Watchdog","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.CIM_WiFiPort_SetPowerState=function(a,c,b){e.Exec("CIM_WiFiPort","SetPowerState",{PowerState:a,Time:c},b)};e.CIM_WiFiPort_Reset=function(a){e.Exec("CIM_WiFiPort","Reset",{},a)};e.CIM_WiFiPort_EnableDevice=function(a,
c){e.Exec("CIM_WiFiPort","EnableDevice",{Enabled:a},c)};e.CIM_WiFiPort_OnlineDevice=function(a,c){e.Exec("CIM_WiFiPort","OnlineDevice",{Online:a},c)};e.CIM_WiFiPort_QuiesceDevice=function(a,c){e.Exec("CIM_WiFiPort","QuiesceDevice",{Quiesce:a},c)};e.CIM_WiFiPort_SaveProperties=function(a){e.Exec("CIM_WiFiPort","SaveProperties",{},a)};e.CIM_WiFiPort_RestoreProperties=function(a){e.Exec("CIM_WiFiPort","RestoreProperties",{},a)};e.CIM_WiFiPort_RequestStateChange=function(a,c,b){e.Exec("CIM_WiFiPort",
2018-10-03 22:03:09 +03:00
"RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.IPS_HostBasedSetupService_Setup=function(a,c,b,l,h,g,d){e.Exec("IPS_HostBasedSetupService","Setup",{NetAdminPassEncryptionType:a,NetworkAdminPassword:c,McNonce:b,Certificate:l,SigningAlgorithm:h,DigitalSignature:g},d)};e.IPS_HostBasedSetupService_AddNextCertInChain=function(a,c,b,l){e.Exec("IPS_HostBasedSetupService","AddNextCertInChain",{NextCertificate:a,IsLeafCertificate:c,IsRootCertificate:b},l)};e.IPS_HostBasedSetupService_AdminSetup=
2018-08-24 02:55:06 +03:00
function(a,c,b,l,h,g){e.Exec("IPS_HostBasedSetupService","AdminSetup",{NetAdminPassEncryptionType:a,NetworkAdminPassword:c,McNonce:b,SigningAlgorithm:l,DigitalSignature:h},g)};e.IPS_HostBasedSetupService_UpgradeClientToAdmin=function(a,c,b,l){e.Exec("IPS_HostBasedSetupService","UpgradeClientToAdmin",{McNonce:a,SigningAlgorithm:c,DigitalSignature:b},l)};e.IPS_HostBasedSetupService_DisableClientControlMode=function(a,c){e.Exec("IPS_HostBasedSetupService","DisableClientControlMode",{_method_dummy:a},
c)};e.IPS_KVMRedirectionSettingData_TerminateSession=function(a){e.Exec("IPS_KVMRedirectionSettingData","TerminateSession",{},a)};e.IPS_KVMRedirectionSettingData_DataChannelRead=function(a){e.Exec("IPS_KVMRedirectionSettingData","DataChannelRead",{},a)};e.IPS_KVMRedirectionSettingData_DataChannelWrite=function(a,c){e.Exec("IPS_KVMRedirectionSettingData","DataChannelWrite",{DataMessage:a},c)};e.IPS_OptInService_StartOptIn=function(a){e.Exec("IPS_OptInService","StartOptIn",{},a)};e.IPS_OptInService_CancelOptIn=
function(a){e.Exec("IPS_OptInService","CancelOptIn",{},a)};e.IPS_OptInService_SendOptInCode=function(a,c){e.Exec("IPS_OptInService","SendOptInCode",{OptInCode:a},c)};e.IPS_OptInService_StartService=function(a){e.Exec("IPS_OptInService","StartService",{},a)};e.IPS_OptInService_StopService=function(a){e.Exec("IPS_OptInService","StopService",{},a)};e.IPS_OptInService_RequestStateChange=function(a,c,b){e.Exec("IPS_OptInService","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.IPS_ProvisioningRecordLog_RequestStateChange=
function(a,c,b){e.Exec("IPS_ProvisioningRecordLog","RequestStateChange",{RequestedState:a,TimeoutPeriod:c},b)};e.IPS_ProvisioningRecordLog_ClearLog=function(a,c){e.Exec("IPS_ProvisioningRecordLog","ClearLog",{_method_dummy:a},c)};e.IPS_ScreenConfigurationService_SetSessionState=function(a,c,b){e.Exec("IPS_ScreenConfigurationService","SetSessionState",{SessionState:a,ConsecutiveRebootsNum:c},b)};e.IPS_SecIOService_RequestStateChange=function(a,c,b){e.Exec("IPS_SecIOService","RequestStateChange",{RequestedState:a,
2018-10-03 22:03:09 +03:00
TimeoutPeriod:c},b)};e.IPS_HTTPProxyService_AddProxyAccessPoint=function(a,c,b,l,h){e.Exec("IPS_HTTPProxyService","AddProxyAccessPoint",{AccessInfo:a,InfoFormat:c,Port:b,NetworkDnsSuffix:l},h)};e.AmtStatusToStr=function(a){return e.AmtStatusCodes[a]?e.AmtStatusCodes[a]:"UNKNOWN_ERROR"};e.AmtStatusCodes={0:"SUCCESS",1:"INTERNAL_ERROR",2:"NOT_READY",3:"INVALID_PT_MODE",4:"INVALID_MESSAGE_LENGTH",5:"TABLE_FINGERPRINT_NOT_AVAILABLE",6:"INTEGRITY_CHECK_FAILED",7:"UNSUPPORTED_ISVS_VERSION",8:"APPLICATION_NOT_REGISTERED",
9:"INVALID_REGISTRATION_DATA",10:"APPLICATION_DOES_NOT_EXIST",11:"NOT_ENOUGH_STORAGE",12:"INVALID_NAME",13:"BLOCK_DOES_NOT_EXIST",14:"INVALID_BYTE_OFFSET",15:"INVALID_BYTE_COUNT",16:"NOT_PERMITTED",17:"NOT_OWNER",18:"BLOCK_LOCKED_BY_OTHER",19:"BLOCK_NOT_LOCKED",20:"INVALID_GROUP_PERMISSIONS",21:"GROUP_DOES_NOT_EXIST",22:"INVALID_MEMBER_COUNT",23:"MAX_LIMIT_REACHED",24:"INVALID_AUTH_TYPE",25:"AUTHENTICATION_FAILED",26:"INVALID_DHCP_MODE",27:"INVALID_IP_ADDRESS",28:"INVALID_DOMAIN_NAME",29:"UNSUPPORTED_VERSION",
30:"REQUEST_UNEXPECTED",31:"INVALID_TABLE_TYPE",32:"INVALID_PROVISIONING_STATE",33:"UNSUPPORTED_OBJECT",34:"INVALID_TIME",35:"INVALID_INDEX",36:"INVALID_PARAMETER",37:"INVALID_NETMASK",38:"FLASH_WRITE_LIMIT_EXCEEDED",39:"INVALID_IMAGE_LENGTH",40:"INVALID_IMAGE_SIGNATURE",41:"PROPOSE_ANOTHER_VERSION",42:"INVALID_PID_FORMAT",43:"INVALID_PPS_FORMAT",44:"BIST_COMMAND_BLOCKED",45:"CONNECTION_FAILED",46:"CONNECTION_TOO_MANY",47:"RNG_GENERATION_IN_PROGRESS",48:"RNG_NOT_READY",49:"CERTIFICATE_NOT_READY",
1024:"DISABLED_BY_POLICY",2048:"NETWORK_IF_ERROR_BASE",2049:"UNSUPPORTED_OEM_NUMBER",2050:"UNSUPPORTED_BOOT_OPTION",2051:"INVALID_COMMAND",2052:"INVALID_SPECIAL_COMMAND",2053:"INVALID_HANDLE",2054:"INVALID_PASSWORD",2055:"INVALID_REALM",2056:"STORAGE_ACL_ENTRY_IN_USE",2057:"DATA_MISSING",2058:"DUPLICATE",2059:"EVENTLOG_FROZEN",2060:"PKI_MISSING_KEYS",2061:"PKI_GENERATING_KEYS",2062:"INVALID_KEY",2063:"INVALID_CERT",2064:"CERT_KEY_NOT_MATCH",2065:"MAX_KERB_DOMAIN_REACHED",2066:"UNSUPPORTED",2067:"INVALID_PRIORITY",
2068:"NOT_FOUND",2069:"INVALID_CREDENTIALS",2070:"INVALID_PASSPHRASE",2072:"NO_ASSOCIATION",2075:"AUDIT_FAIL",2076:"BLOCKING_COMPONENT",2081:"USER_CONSENT_REQUIRED",4096:"APP_INTERNAL_ERROR",4097:"NOT_INITIALIZED",4098:"LIB_VERSION_UNSUPPORTED",4099:"INVALID_PARAM",4100:"RESOURCES",4101:"HARDWARE_ACCESS_ERROR",4102:"REQUESTOR_NOT_REGISTERED",4103:"NETWORK_ERROR",4104:"PARAM_BUFFER_TOO_SHORT",4105:"COM_NOT_INITIALIZED_IN_THREAD",4106:"URL_REQUIRED"};e.GetMessageLog=function(a,c){e.AMT_MessageLog_PositionToFirstRecord(r,
[a,c,[]])};var h="Unspecified.;No system memory is physically installed in the system.;No usable system memory, all installed memory has experienced an unrecoverable failure.;Unrecoverable hard-disk/ATAPI/IDE device failure.;Unrecoverable system-board failure.;Unrecoverable diskette subsystem failure.;Unrecoverable hard-disk controller failure.;Unrecoverable PS/2 or USB keyboard failure.;Removable boot media not found.;Unrecoverable video controller failure.;No video device detected.;Firmware (BIOS) ROM corruption detected.;CPU voltage mismatch (processors that share same supply have mismatched voltage requirements);CPU speed matching failure".split(";"),
2018-08-24 02:55:06 +03:00
g="Unspecified.;Memory initialization.;Starting hard-disk initialization and test;Secondary processor(s) initialization;User authentication;User-initiated system setup;USB resource configuration;PCI resource configuration;Option ROM initialization;Video initialization;Cache initialization;SM Bus initialization;Keyboard controller initialization;Embedded controller/management controller initialization;Docking station attachment;Enabling docking station;Docking station ejection;Disabling docking station;Calling operating system wake-up vector;Starting operating system boot process;Baseboard or motherboard initialization;reserved;Floppy initialization;Keyboard test;Pointing device test;Primary processor initialization".split(";"),
2018-11-15 02:44:28 +03:00
E="Unspecified;Other;Unknown;Processor;Disk;Peripheral;System management module;System board;Memory module;Processor module;Power supply;Add in card;Front panel board;Back panel board;Power system board;Drive backplane;System internal expansion board;Other system board;Processor board;Power unit;Power module;Power management board;Chassis back panel board;System chassis;Sub chassis;Other chassis board;Disk drive bay;Peripheral bay;Device bay;Fan cooling;Cooling unit;Cable interconnect;Memory device;System management software;BIOS;Intel(r) ME;System bus;Group;Intel(r) ME;External environment;Battery;Processing blade;Connectivity switch;Processor/memory module;I/O module;Processor I/O module;Management controller firmware;IPMI channel;PCI bus;PCI express bus;SCSI bus;SATA/SAS bus;Processor front side bus".split(";");
2018-08-24 02:55:06 +03:00
e.RealmNames=";;Redirection;;Hardware Asset;Remote Control;Storage;Event Manager;Storage Admin;Agent Presence Local;Agent Presence Remote;Circuit Breaker;Network Time;General Information;Firmware Update;EIT;LocalUN;Endpoint Access Control;Endpoint Access Control Admin;Event Log Reader;Audit Log;ACL Realm;;;Local System".split(";");e.WatchdogCurrentStates={1:"Not Started",2:"Stopped",4:"Running",8:"Expired",16:"Suspended"};var m={16:"Security Admin",17:"RCO",18:"Redirection Manager",19:"Firmware Update Manager",
20:"Security Audit Log",21:"Network Time",22:"Network Administration",23:"Storage Administration",24:"Event Manager",25:"Circuit Breaker Manager",26:"Agent Presence Manager",27:"Wireless Configuration",28:"EAC",29:"KVM",30:"User Opt-In Events",32:"Screen Blanking",33:"Watchdog Events",1600:"Provisioning Started",1601:"Provisioning Completed",1602:"ACL Entry Added",1603:"ACL Entry Modified",1604:"ACL Entry Removed",1605:"ACL Access with Invalid Credentials",1606:"ACL Entry State",1607:"TLS State Changed",
1608:"TLS Server Certificate Set",1609:"TLS Server Certificate Remove",1610:"TLS Trusted Root Certificate Added",1611:"TLS Trusted Root Certificate Removed",1612:"TLS Preshared Key Set",1613:"Kerberos Settings Modified",1614:"Kerberos Master Key Modified",1615:"Flash Wear out Counters Reset",1616:"Power Package Modified",1617:"Set Realm Authentication Mode",1618:"Upgrade Client to Admin Control Mode",1619:"Unprovisioning Started",1700:"Performed Power Up",1701:"Performed Power Down",1702:"Performed Power Cycle",
1703:"Performed Reset",1704:"Set Boot Options",1800:"IDER Session Opened",1801:"IDER Session Closed",1802:"IDER Enabled",1803:"IDER Disabled",1804:"SoL Session Opened",1805:"SoL Session Closed",1806:"SoL Enabled",1807:"SoL Disabled",1808:"KVM Session Started",1809:"KVM Session Ended",1810:"KVM Enabled",1811:"KVM Disabled",1812:"VNC Password Failed 3 Times",1900:"Firmware Updated",1901:"Firmware Update Failed",2E3:"Security Audit Log Cleared",2001:"Security Audit Policy Modified",2002:"Security Audit Log Disabled",
2003:"Security Audit Log Enabled",2004:"Security Audit Log Exported",2005:"Security Audit Log Recovered",2100:"Intel&reg; ME Time Set",2200:"TCPIP Parameters Set",2201:"Host Name Set",2202:"Domain Name Set",2203:"VLAN Parameters Set",2204:"Link Policy Set",2205:"IPv6 Parameters Set",2300:"Global Storage Attributes Set",2301:"Storage EACL Modified",2302:"Storage FPACL Modified",2303:"Storage Write Operation",2400:"Alert Subscribed",2401:"Alert Unsubscribed",2402:"Event Log Cleared",2403:"Event Log Frozen",
2500:"CB Filter Added",2501:"CB Filter Removed",2502:"CB Policy Added",2503:"CB Policy Removed",2504:"CB Default Policy Set",2505:"CB Heuristics Option Set",2506:"CB Heuristics State Cleared",2600:"Agent Watchdog Added",2601:"Agent Watchdog Removed",2602:"Agent Watchdog Action Set",2700:"Wireless Profile Added",2701:"Wireless Profile Removed",2702:"Wireless Profile Updated",2800:"EAC Posture Signer SET",2801:"EAC Enabled",2802:"EAC Disabled",2803:"EAC Posture State",2804:"EAC Set Options",2900:"KVM Opt-in Enabled",
2901:"KVM Opt-in Disabled",2902:"KVM Password Changed",2903:"KVM Consent Succeeded",2904:"KVM Consent Failed",3E3:"Opt-In Policy Change",3001:"Send Consent Code Event",3002:"Start Opt-In Blocked Event"};e.GetAuditLogExtendedDataStr=function(a,c){if((1602==a||1604==a)&&0==c.charCodeAt(0))return c.substring(2,2+c.charCodeAt(1));if(1603==a)return 0==c.charCodeAt(1)?c.substring(3):null;if(1605==a)return["Invalid ME access","Invalid MEBx access"][c.charCodeAt(0)];if(1606==a){var b=["Disabled","Enabled"][c.charCodeAt(0)];
0==c.charCodeAt(1)&&(b+=", "+c.substring(3));return b}return 1607==a?"Remote "+["NoAuth","ServerAuth","MutualAuth"][c.charCodeAt(0)]+", Local "+["NoAuth","ServerAuth","MutualAuth"][c.charCodeAt(1)]:1617==a?e.RealmNames[ReadInt(c,0)]+", "+["NoAuth","Auth","Disabled"][c.charCodeAt(4)]:1619==a?["BIOS","MEBx","Local MEI","Local WSMAN","Remote WSAMN"][c.charCodeAt(0)]:1900==a?"From "+ReadShort(c,0)+"."+ReadShort(c,2)+"."+ReadShort(c,4)+"."+ReadShort(c,6)+" to "+ReadShort(c,8)+"."+ReadShort(c,10)+"."+ReadShort(c,
2018-10-03 22:03:09 +03:00
12)+"."+ReadShort(c,14):2100==a?(b=new Date,b.setTime(1E3*ReadInt(c,0)+6E4*(new Date).getTimezoneOffset()),b.toLocaleString()):3E3==a?"From "+["None","KVM","All"][c.charCodeAt(0)]+" to "+["None","KVM","All"][c.charCodeAt(1)]:3001==a?["Success","Failed 3 times"][c.charCodeAt(0)]:null};e.GetAuditLog=function(a){e.AMT_AuditLog_ReadRecords(1,v,[a,[]])};return e}function hex_md5(a){return forge.md.md5.create().update(a).digest().toHex()}function rstr_md5(a){return hex2rstr(hex_md5(a))}
2018-08-24 02:55:06 +03:00
function execArgumentsToXml(a){if(void 0===a||null===a)return null;var b="",c;for(c in a){var d=a[c];d&&(b="reference"===d.__parameterType?b+referenceToXml(c,d):b+instanceToXml(c,d))}return b}
function instanceToXml(a,b){if(void 0===b||null===b)return null;var c=!!b.__namespace,d=c?"<q:":"<",f=c?"</q:":"</",c="<r:"+a+(c?' xmlns:q="'+b.__namespace+'"':"")+">",n;for(n in b)b.hasOwnProperty(n)&&0!==n.indexOf("__")&&("function"===typeof b[n]||Array.isArray(b[n])||("object"===typeof b[n]?console.error("only convert one level down..."):c+=d+n+">"+b[n].toString()+f+n+">"));return c+("</r:"+a+">")}
function referenceToXml(a,b){if(void 0===b||null===b)return null;var c="<r:"+a+"><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+b.__resourceUri+"</w:ResourceURI><w:SelectorSet>",d;for(d in b)b.hasOwnProperty(d)&&0!==d.indexOf("__")&&("function"===typeof b[d]||"object"===typeof b[d]||Array.isArray(b[d])||(c+='<w:Selector Name="'+d+'">'+b[d].toString()+"</w:Selector>"));return c+("</w:SelectorSet></a:ReferenceParameters></r:"+a+">")}
function GetSidString(a){for(var b="S-"+a.charCodeAt(0)+"-"+a.charCodeAt(7),c=2;c<a.length/4;c++)b+="-"+ReadIntX(a,4*c);return b}
function GetSidByteArray(a){if(!a||null==a)return null;a=a.split("-");if(4>a.length||"s"!=a[0]&&"S"!=a[0])return null;for(var b=1;b<a.length;b++){var c=parseInt(a[b]);if(c!=a[b])return null;a[b]=c}c=String.fromCharCode(a[1])+String.fromCharCode(a.length-3)+ShortToStr(Math.floor(a[2]/Math.pow(2,32)))+IntToStr(a[2]&65535);for(b=3;b<a.length;b++)c+=IntToStrX(a[b]);return c}
2018-11-15 02:44:28 +03:00
(function(a,b){"function"===typeof define&&define.amd?define([],b):a.forge=b()})(this,function(){var a,b,c;(function(d){function f(a,c){var b,l,h,g,d,y,e,k,v,u=c&&c.split("/"),B=m.map,E=B&&B["*"]||{};if(a&&"."===a.charAt(0))if(c){u=u.slice(0,u.length-1);a=a.split("/");d=a.length-1;m.nodeIdCompat&&C.test(a[d])&&(a[d]=a[d].replace(C,""));a=u.concat(a);for(d=0;d<a.length;d+=1)if(b=a[d],"."===b)a.splice(d,1),--d;else if(".."===b)if(1!==d||".."!==a[2]&&".."!==a[0])0<d&&(a.splice(d-1,2),d-=2);else break;
a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((u||E)&&B){b=a.split("/");for(d=b.length;0<d;--d){l=b.slice(0,d).join("/");if(u)for(v=u.length;0<v;--v)if(h=B[u.slice(0,v).join("/")])if(h=h[l]){g=h;y=d;break}if(g)break;!e&&E&&E[l]&&(e=E[l],k=d)}!g&&e&&(g=e,y=k);g&&(b.splice(0,y,g),a=b.join("/"))}return a}function n(a,c){return function(){return u.apply(d,y.call(arguments,0).concat([a,c]))}}function p(a){return function(c){return f(c,a)}}function r(a){return function(c){g[a]=c}}function l(a){if(w.call(E,
a)){var c=E[a];delete E[a];F[a]=!0;e.apply(d,c)}if(!w.call(g,a)&&!w.call(F,a))throw Error("No "+a);return g[a]}function k(a){var c,b=a?a.indexOf("!"):-1;-1<b&&(c=a.substring(0,b),a=a.substring(b+1,a.length));return[c,a]}function v(a){return function(){return m&&m.config&&m.config[a]||{}}}var e,u,B,h,g={},E={},m={},F={},w=Object.prototype.hasOwnProperty,y=[].slice,C=/\.js$/;B=function(a,c){var b,h=k(a),g=h[0];a=h[1];g&&(g=f(g,c),b=l(g));g?a=b&&b.normalize?b.normalize(a,p(c)):f(a,c):(a=f(a,c),h=k(a),
g=h[0],a=h[1],g&&(b=l(g)));return{f:g?g+"!"+a:a,n:a,pr:g,p:b}};h={require:function(a){return n(a)},exports:function(a){var c=g[a];return"undefined"!==typeof c?c:g[a]={}},module:function(a){return{id:a,uri:"",exports:g[a],config:v(a)}}};e=function(a,c,b,y){var m,e,k,v,C=[];e=typeof b;var u;y=y||a;if("undefined"===e||"function"===e){c=!c.length&&b.length?["require","exports","module"]:c;for(v=0;v<c.length;v+=1)if(k=B(c[v],y),e=k.f,"require"===e)C[v]=h.require(a);else if("exports"===e)C[v]=h.exports(a),
u=!0;else if("module"===e)m=C[v]=h.module(a);else if(w.call(g,e)||w.call(E,e)||w.call(F,e))C[v]=l(e);else if(k.p)k.p.load(k.n,n(y,!0),r(e),{}),C[v]=g[e];else throw Error(a+" missing "+e);c=b?b.apply(g[a],C):void 0;a&&(m&&m.exports!==d&&m.exports!==g[a]?g[a]=m.exports:c===d&&u||(g[a]=c))}else a&&(g[a]=b)};a=b=u=function(a,c,b,g,y){if("string"===typeof a)return h[a]?h[a](c):l(B(a,c).f);if(!a.splice){m=a;m.deps&&u(m.deps,m.callback);if(!c)return;c.splice?(a=c,c=b,b=null):a=d}c=c||function(){};"function"===
typeof b&&(b=g,g=y);g?e(d,a,c,b):setTimeout(function(){e(d,a,c,b)},4);return u};u.config=function(a){return u(a)};a._defined=g;c=function(a,c,b){c.splice||(b=c,c=[]);w.call(g,a)||w.call(E,a)||(E[a]=[a,c,b])};c.amd={jQuery:!0}})();c("node_modules/almond/almond",function(){});(function(){function a(c){function b(a){this.data="";this.read=0;if("string"===typeof a)this.data=a;else if(d.isArrayBuffer(a)||d.isArrayBufferView(a)){a=new Uint8Array(a);try{this.data=String.fromCharCode.apply(null,a)}catch(c){for(var l=
2018-08-24 02:55:06 +03:00
0;l<a.length;++l)this.putByte(a[l])}}else if(a instanceof b||"object"===typeof a&&"string"===typeof a.data&&"number"===typeof a.read)this.data=a.data,this.read=a.read;this._constructedStringLength=0}var d=c.util=c.util||{};(function(){if("undefined"!==typeof process&&process.nextTick)d.nextTick=process.nextTick,d.setImmediate="function"===typeof setImmediate?setImmediate:d.nextTick;else if("function"===typeof setImmediate)d.setImmediate=setImmediate,d.nextTick=function(a){return setImmediate(a)};
else{d.setImmediate=function(a){setTimeout(a,0)};if("undefined"!==typeof window&&"function"===typeof window.postMessage){var a=[];d.setImmediate=function(c){a.push(c);1===a.length&&window.postMessage("forge.setImmediate","*")};window.addEventListener("message",function(c){c.source===window&&"forge.setImmediate"===c.data&&(c.stopPropagation(),c=a.slice(),a.length=0,c.forEach(function(a){a()}))},!0)}if("undefined"!==typeof MutationObserver){var c=Date.now(),b=!0,l=document.createElement("div"),a=[];
(new MutationObserver(function(){var c=a.slice();a.length=0;c.forEach(function(a){a()})})).observe(l,{attributes:!0});var h=d.setImmediate;d.setImmediate=function(d){15<Date.now()-c?(c=Date.now(),h(d)):(a.push(d),1===a.length&&l.setAttribute("a",b=!b))}}d.nextTick=d.setImmediate}})();d.isArray=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};d.isArrayBuffer=function(a){return"undefined"!==typeof ArrayBuffer&&a instanceof ArrayBuffer};d.isArrayBufferView=function(a){return a&&
d.isArrayBuffer(a.buffer)&&void 0!==a.byteLength};d.ByteBuffer=b;d.ByteStringBuffer=b;d.ByteStringBuffer.prototype._optimizeConstructedString=function(a){this._constructedStringLength+=a;4096<this._constructedStringLength&&(this.data.substr(0,1),this._constructedStringLength=0)};d.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};d.ByteStringBuffer.prototype.isEmpty=function(){return 0>=this.length()};d.ByteStringBuffer.prototype.putByte=function(a){return this.putBytes(String.fromCharCode(a))};
d.ByteStringBuffer.prototype.fillWithByte=function(a,c){a=String.fromCharCode(a);for(var b=this.data;0<c;)c&1&&(b+=a),c>>>=1,0<c&&(a+=a);this.data=b;this._optimizeConstructedString(c);return this};d.ByteStringBuffer.prototype.putBytes=function(a){this.data+=a;this._optimizeConstructedString(a.length);return this};d.ByteStringBuffer.prototype.putString=function(a){return this.putBytes(d.encodeUtf8(a))};d.ByteStringBuffer.prototype.putInt16=function(a){return this.putBytes(String.fromCharCode(a>>8&
255)+String.fromCharCode(a&255))};d.ByteStringBuffer.prototype.putInt24=function(a){return this.putBytes(String.fromCharCode(a>>16&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255))};d.ByteStringBuffer.prototype.putInt32=function(a){return this.putBytes(String.fromCharCode(a>>24&255)+String.fromCharCode(a>>16&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255))};d.ByteStringBuffer.prototype.putInt16Le=function(a){return this.putBytes(String.fromCharCode(a&255)+String.fromCharCode(a>>
8&255))};d.ByteStringBuffer.prototype.putInt24Le=function(a){return this.putBytes(String.fromCharCode(a&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a>>16&255))};d.ByteStringBuffer.prototype.putInt32Le=function(a){return this.putBytes(String.fromCharCode(a&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a>>16&255)+String.fromCharCode(a>>24&255))};d.ByteStringBuffer.prototype.putInt=function(a,c){var b="";do c-=8,b+=String.fromCharCode(a>>c&255);while(0<c);return this.putBytes(b)};
d.ByteStringBuffer.prototype.putSignedInt=function(a,c){0>a&&(a+=2<<c-1);return this.putInt(a,c)};d.ByteStringBuffer.prototype.putBuffer=function(a){return this.putBytes(a.getBytes())};d.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};d.ByteStringBuffer.prototype.getInt16=function(){var a=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);this.read+=2;return a};d.ByteStringBuffer.prototype.getInt24=function(){var a=this.data.charCodeAt(this.read)<<
16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);this.read+=3;return a};d.ByteStringBuffer.prototype.getInt32=function(){var a=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);this.read+=4;return a};d.ByteStringBuffer.prototype.getInt16Le=function(){var a=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;this.read+=2;return a};d.ByteStringBuffer.prototype.getInt24Le=
function(){var a=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;this.read+=3;return a};d.ByteStringBuffer.prototype.getInt32Le=function(){var a=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;this.read+=4;return a};d.ByteStringBuffer.prototype.getInt=function(a){var c=0;do c=(c<<8)+this.data.charCodeAt(this.read++),a-=8;while(0<a);return c};d.ByteStringBuffer.prototype.getSignedInt=
function(a){var c=this.getInt(a);a=2<<a-2;c>=a&&(c-=a<<1);return c};d.ByteStringBuffer.prototype.getBytes=function(a){var c;a?(a=Math.min(this.length(),a),c=this.data.slice(this.read,this.read+a),this.read+=a):0===a?c="":(c=0===this.read?this.data:this.data.slice(this.read),this.clear());return c};d.ByteStringBuffer.prototype.bytes=function(a){return"undefined"===typeof a?this.data.slice(this.read):this.data.slice(this.read,this.read+a)};d.ByteStringBuffer.prototype.at=function(a){return this.data.charCodeAt(this.read+
a)};d.ByteStringBuffer.prototype.setAt=function(a,c){this.data=this.data.substr(0,this.read+a)+String.fromCharCode(c)+this.data.substr(this.read+a+1);return this};d.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};d.ByteStringBuffer.prototype.copy=function(){var a=d.createBuffer(this.data);a.read=this.read;return a};d.ByteStringBuffer.prototype.compact=function(){0<this.read&&(this.data=this.data.slice(this.read),this.read=0);return this};d.ByteStringBuffer.prototype.clear=
function(){this.data="";this.read=0;return this};d.ByteStringBuffer.prototype.truncate=function(a){a=Math.max(0,this.length()-a);this.data=this.data.substr(this.read,a);this.read=0;return this};d.ByteStringBuffer.prototype.toHex=function(){for(var a="",c=this.read;c<this.data.length;++c){var b=this.data.charCodeAt(c);16>b&&(a+="0");a+=b.toString(16)}return a};d.ByteStringBuffer.prototype.toString=function(){return d.decodeUtf8(this.bytes())};d.DataBuffer=function(a,c){c=c||{};this.read=c.readOffset||
0;this.growSize=c.growSize||1024;var b=d.isArrayBuffer(a),l=d.isArrayBufferView(a);b||l?(this.data=b?new DataView(a):new DataView(a.buffer,a.byteOffset,a.byteLength),this.write="writeOffset"in c?c.writeOffset:this.data.byteLength):(this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!==a&&void 0!==a&&this.putBytes(a),"writeOffset"in c&&(this.write=c.writeOffset))};d.DataBuffer.prototype.length=function(){return this.write-this.read};d.DataBuffer.prototype.isEmpty=function(){return 0>=this.length()};
d.DataBuffer.prototype.accommodate=function(a,c){if(this.length()>=a)return this;c=Math.max(c||this.growSize,a);var b=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),l=new Uint8Array(this.length()+c);l.set(b);this.data=new DataView(l.buffer);return this};d.DataBuffer.prototype.putByte=function(a){this.accommodate(1);this.data.setUint8(this.write++,a);return this};d.DataBuffer.prototype.fillWithByte=function(a,c){this.accommodate(c);for(var b=0;b<c;++b)this.data.setUint8(a);
return this};d.DataBuffer.prototype.putBytes=function(a,c){if(d.isArrayBufferView(a)){var b=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),l=b.byteLength-b.byteOffset;this.accommodate(l);var h=new Uint8Array(this.data.buffer,this.write);h.set(b);this.write+=l;return this}if(d.isArrayBuffer(a))return b=new Uint8Array(a),this.accommodate(b.byteLength),h=new Uint8Array(this.data.buffer),h.set(b,this.write),this.write+=b.byteLength,this;if(a instanceof d.DataBuffer||"object"===typeof a&&"number"===
typeof a.read&&"number"===typeof a.write&&d.isArrayBufferView(a.data))return b=new Uint8Array(a.data.byteLength,a.read,a.length()),this.accommodate(b.byteLength),h=new Uint8Array(a.data.byteLength,this.write),h.set(b),this.write+=b.byteLength,this;a instanceof d.ByteStringBuffer&&(a=a.data,c="binary");c=c||"binary";if("string"===typeof a){if("hex"===c)return this.accommodate(Math.ceil(a.length/2)),b=new Uint8Array(this.data.buffer,this.write),this.write+=d.binary.hex.decode(a,b,this.write),this;if("base64"===
c)return this.accommodate(3*Math.ceil(a.length/4)),b=new Uint8Array(this.data.buffer,this.write),this.write+=d.binary.base64.decode(a,b,this.write),this;"utf8"===c&&(a=d.encodeUtf8(a),c="binary");if("binary"===c||"raw"===c)return this.accommodate(a.length),b=new Uint8Array(this.data.buffer,this.write),this.write+=d.binary.raw.decode(b),this;if("utf16"===c)return this.accommodate(2*a.length),b=new Uint16Array(this.data.buffer,this.write),this.write+=d.text.utf16.encode(b),this;throw Error("Invalid encoding: "+
c);}throw Error("Invalid parameter: "+a);};d.DataBuffer.prototype.putBuffer=function(a){this.putBytes(a);a.clear();return this};d.DataBuffer.prototype.putString=function(a){return this.putBytes(a,"utf16")};d.DataBuffer.prototype.putInt16=function(a){this.accommodate(2);this.data.setInt16(this.write,a);this.write+=2;return this};d.DataBuffer.prototype.putInt24=function(a){this.accommodate(3);this.data.setInt16(this.write,a>>8&65535);this.data.setInt8(this.write,a>>16&255);this.write+=3;return this};
d.DataBuffer.prototype.putInt32=function(a){this.accommodate(4);this.data.setInt32(this.write,a);this.write+=4;return this};d.DataBuffer.prototype.putInt16Le=function(a){this.accommodate(2);this.data.setInt16(this.write,a,!0);this.write+=2;return this};d.DataBuffer.prototype.putInt24Le=function(a){this.accommodate(3);this.data.setInt8(this.write,a>>16&255);this.data.setInt16(this.write,a>>8&65535,!0);this.write+=3;return this};d.DataBuffer.prototype.putInt32Le=function(a){this.accommodate(4);this.data.setInt32(this.write,
a,!0);this.write+=4;return this};d.DataBuffer.prototype.putInt=function(a,c){this.accommodate(c/8);do c-=8,this.data.setInt8(this.write++,a>>c&255);while(0<c);return this};d.DataBuffer.prototype.putSignedInt=function(a,c){this.accommodate(c/8);0>a&&(a+=2<<c-1);return this.putInt(a,c)};d.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};d.DataBuffer.prototype.getInt16=function(){var a=this.data.getInt16(this.read);this.read+=2;return a};d.DataBuffer.prototype.getInt24=
function(){var a=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);this.read+=3;return a};d.DataBuffer.prototype.getInt32=function(){var a=this.data.getInt32(this.read);this.read+=4;return a};d.DataBuffer.prototype.getInt16Le=function(){var a=this.data.getInt16(this.read,!0);this.read+=2;return a};d.DataBuffer.prototype.getInt24Le=function(){var a=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;this.read+=3;return a};d.DataBuffer.prototype.getInt32Le=function(){var a=
this.data.getInt32(this.read,!0);this.read+=4;return a};d.DataBuffer.prototype.getInt=function(a){var c=0;do c=(c<<8)+this.data.getInt8(this.read++),a-=8;while(0<a);return c};d.DataBuffer.prototype.getSignedInt=function(a){var c=this.getInt(a);a=2<<a-2;c>=a&&(c-=a<<1);return c};d.DataBuffer.prototype.getBytes=function(a){var c;a?(a=Math.min(this.length(),a),c=this.data.slice(this.read,this.read+a),this.read+=a):0===a?c="":(c=0===this.read?this.data:this.data.slice(this.read),this.clear());return c};
d.DataBuffer.prototype.bytes=function(a){return"undefined"===typeof a?this.data.slice(this.read):this.data.slice(this.read,this.read+a)};d.DataBuffer.prototype.at=function(a){return this.data.getUint8(this.read+a)};d.DataBuffer.prototype.setAt=function(a,c){this.data.setUint8(a,c);return this};d.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};d.DataBuffer.prototype.copy=function(){return new d.DataBuffer(this)};d.DataBuffer.prototype.compact=function(){if(0<this.read){var a=
new Uint8Array(this.data.buffer,this.read),c=new Uint8Array(a.byteLength);c.set(a);this.data=new DataView(c);this.write-=this.read;this.read=0}return this};d.DataBuffer.prototype.clear=function(){this.data=new DataView(new ArrayBuffer(0));this.read=this.write=0;return this};d.DataBuffer.prototype.truncate=function(a){this.write=Math.max(0,this.length()-a);this.read=Math.min(this.read,this.write);return this};d.DataBuffer.prototype.toHex=function(){for(var a="",c=this.read;c<this.data.byteLength;++c){var b=
this.data.getUint8(c);16>b&&(a+="0");a+=b.toString(16)}return a};d.DataBuffer.prototype.toString=function(a){var c=new Uint8Array(this.data,this.read,this.length());a=a||"utf8";if("binary"===a||"raw"===a)return d.binary.raw.encode(c);if("hex"===a)return d.binary.hex.encode(c);if("base64"===a)return d.binary.base64.encode(c);if("utf8"===a)return d.text.utf8.decode(c);if("utf16"===a)return d.text.utf16.decode(c);throw Error("Invalid encoding: "+a);};d.createBuffer=function(a,c){void 0!==a&&"utf8"===
(c||"raw")&&(a=d.encodeUtf8(a));return new d.ByteBuffer(a)};d.fillString=function(a,c){for(var b="";0<c;)c&1&&(b+=a),c>>>=1,0<c&&(a+=a);return b};d.xorBytes=function(a,c,b){for(var l="",d="",h="",g=0,m=0;0<b;--b,++g)d=a.charCodeAt(g)^c.charCodeAt(g),10<=m&&(l+=h,h="",m=0),h+=String.fromCharCode(d),++m;return l+h};d.hexToBytes=function(a){var c="",b=0;a.length&1&&(b=1,c+=String.fromCharCode(parseInt(a[0],16)));for(;b<a.length;b+=2)c+=String.fromCharCode(parseInt(a.substr(b,2),16));return c};d.bytesToHex=
function(a){return d.createBuffer(a).toHex()};d.int32ToBytes=function(a){return String.fromCharCode(a>>24&255)+String.fromCharCode(a>>16&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255)};var e=[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];d.encode64=function(a,c){for(var b="",l="",d,h,g,m=0;m<a.length;)d=
a.charCodeAt(m++),h=a.charCodeAt(m++),g=a.charCodeAt(m++),b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d>>2),b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((d&3)<<4|h>>4),isNaN(h)?b+="==":(b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((h&15)<<2|g>>6),b+=isNaN(g)?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g&63)),c&&b.length>c&&(l+=b.substr(0,c)+"\r\n",b=b.substr(c));return l+
b};d.decode64=function(a){a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c="",b,l,d,h,g=0;g<a.length;)b=e[a.charCodeAt(g++)-43],l=e[a.charCodeAt(g++)-43],d=e[a.charCodeAt(g++)-43],h=e[a.charCodeAt(g++)-43],c+=String.fromCharCode(b<<2|l>>4),64!==d&&(c+=String.fromCharCode((l&15)<<4|d>>2),64!==h&&(c+=String.fromCharCode((d&3)<<6|h)));return c};d.encodeUtf8=function(a){return unescape(encodeURIComponent(a))};d.decodeUtf8=function(a){return decodeURIComponent(escape(a))};d.binary={raw:{},hex:{},base64:{}};
d.binary.raw.encode=function(a){return String.fromCharCode.apply(null,a)};d.binary.raw.decode=function(a,c,b){var l=c;l||(l=new Uint8Array(a.length));for(var d=b=b||0,h=0;h<a.length;++h)l[d++]=a.charCodeAt(h);return c?d-b:l};d.binary.hex.encode=d.bytesToHex;d.binary.hex.decode=function(a,c,b){var l=c;l||(l=new Uint8Array(Math.ceil(a.length/2)));b=b||0;var d=0,h=b;a.length&1&&(d=1,l[h++]=parseInt(a[0],16));for(;d<a.length;d+=2)l[h++]=parseInt(a.substr(d,2),16);return c?h-b:l};d.binary.base64.encode=
function(a,c){for(var b="",l="",d,h,g,m=0;m<a.byteLength;)d=a[m++],h=a[m++],g=a[m++],b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d>>2),b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((d&3)<<4|h>>4),isNaN(h)?b+="==":(b+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt((h&15)<<2|g>>6),b+=isNaN(g)?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g&63)),c&&b.length>c&&(l+=b.substr(0,
2018-10-03 22:03:09 +03:00
c)+"\r\n",b=b.substr(c));return l+b};d.binary.base64.decode=function(a,c,b){var l=c;l||(l=new Uint8Array(3*Math.ceil(a.length/4)));a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");b=b||0;for(var d,h,g,m,k=0,u=b;k<a.length;)d=e[a.charCodeAt(k++)-43],h=e[a.charCodeAt(k++)-43],g=e[a.charCodeAt(k++)-43],m=e[a.charCodeAt(k++)-43],l[u++]=d<<2|h>>4,64!==g&&(l[u++]=(h&15)<<4|g>>2,64!==m&&(l[u++]=(g&3)<<6|m));return c?u-b:l.subarray(0,u)};d.text={utf8:{},utf16:{}};d.text.utf8.encode=function(a,c,b){a=d.encodeUtf8(a);
2018-08-24 02:55:06 +03:00
var l=c;l||(l=new Uint8Array(a.length));for(var h=b=b||0,g=0;g<a.length;++g)l[h++]=a.charCodeAt(g);return c?h-b:l};d.text.utf8.decode=function(a){return d.decodeUtf8(String.fromCharCode.apply(null,a))};d.text.utf16.encode=function(a,c,b){var l=c;l||(l=new Uint8Array(2*a.length));for(var d=new Uint16Array(l.buffer),h=b=b||0,g=b,m=0;m<a.length;++m)d[g++]=a.charCodeAt(m),h+=2;return c?h-b:l};d.text.utf16.decode=function(a){return String.fromCharCode.apply(null,new Uint16Array(a.buffer))};d.deflate=function(a,
2018-10-03 22:03:09 +03:00
c,b){c=d.decode64(a.deflate(d.encode64(c)).rval);b&&(a=2,c.charCodeAt(1)&32&&(a=6),c=c.substring(a,c.length-4));return c};d.inflate=function(a,c,b){a=a.inflate(d.encode64(c)).rval;return null===a?null:d.decode64(a)};var u=function(a,c,b){if(!a)throw Error("WebStorage not available.");null===b?a=a.removeItem(c):(b=d.encode64(JSON.stringify(b)),a=a.setItem(c,b));if("undefined"!==typeof a&&!0!==a.rval)throw c=Error(a.error.message),c.id=a.error.id,c.name=a.error.name,c;},B=function(a,c){if(!a)throw Error("WebStorage not available.");
2018-11-15 02:44:28 +03:00
var b=a.getItem(c);if(a.init)if(null===b.rval){if(b.error){var l=Error(b.error.message);l.id=b.error.id;l.name=b.error.name;throw l;}b=null}else b=b.rval;null!==b&&(b=JSON.parse(d.decode64(b)));return b},h=function(a,c,b,l){var d=B(a,c);null===d&&(d={});d[b]=l;u(a,c,d)},g=function(a,c,b){a=B(a,c);null!==a&&(a=b in a?a[b]:null);return a},E=function(a,c,b){var l=B(a,c);if(null!==l&&b in l){delete l[b];b=!0;for(var d in l){b=!1;break}b&&(l=null);u(a,c,l)}},m=function(a,c){u(a,c,null)},f=function(a,c,
b){var l=null;"undefined"===typeof b&&(b=["web","flash"]);var d,h=!1,g=null,m;for(m in b){d=b[m];try{if("flash"===d||"both"===d){if(null===c[0])throw Error("Flash local storage not available.");l=a.apply(this,c);h="flash"===d}if("web"===d||"both"===d)c[0]=localStorage,l=a.apply(this,c),h=!0}catch(e){g=e}if(h)break}if(!h)throw g;return l};d.setItem=function(a,c,b,l,d){f(h,arguments,d)};d.getItem=function(a,c,b,l){return f(g,arguments,l)};d.removeItem=function(a,c,b,l){f(E,arguments,l)};d.clearItems=
function(a,c,b){f(m,arguments,b)};d.parseUrl=function(a){var c=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;c.lastIndex=0;c=c.exec(a);if(a=null===c?null:{full:a,scheme:c[1],host:c[2],port:c[3],path:c[4]})a.fullHost=a.host,a.port?80!==a.port&&"http"===a.scheme?a.fullHost+=":"+a.port:443!==a.port&&"https"===a.scheme&&(a.fullHost+=":"+a.port):"http"===a.scheme?a.port=80:"https"===a.scheme&&(a.port=443),a.full=a.scheme+"://"+a.fullHost;return a};var w=null;d.getQueryVariables=function(a){var c=function(a){var c=
{};a=a.split("&");for(var b=0;b<a.length;b++){var l=a[b].indexOf("="),d;0<l?(d=a[b].substring(0,l),l=a[b].substring(l+1)):(d=a[b],l=null);d in c||(c[d]=[]);d in Object.prototype||null===l||c[d].push(unescape(l))}return c};"undefined"===typeof a?(null===w&&(w="undefined"!==typeof window&&window.location&&window.location.search?c(window.location.search.substring(1)):{}),a=w):a=c(a);return a};d.parseFragment=function(a){var c=a,b="",l=a.indexOf("?");0<l&&(c=a.substring(0,l),b=a.substring(l+1));a=c.split("/");
2018-08-24 02:55:06 +03:00
0<a.length&&""===a[0]&&a.shift();l=""===b?{}:d.getQueryVariables(b);return{pathString:c,queryString:b,path:a,query:l}};d.makeRequest=function(a){var c=d.parseFragment(a),b={path:c.pathString,query:c.queryString,getPath:function(a){return"undefined"===typeof a?c.path:c.path[a]},getQuery:function(a,b){var l;"undefined"===typeof a?l=c.query:(l=c.query[a])&&"undefined"!==typeof b&&(l=l[b]);return l},getQueryLast:function(a,c){var l=b.getQuery(a);return l?l[l.length-1]:c}};return b};d.makeLink=function(a,
c,b){a=jQuery.isArray(a)?a.join("/"):a;c=jQuery.param(c||{});b=b||"";return a+(0<c.length?"?"+c:"")+(0<b.length?"#"+b:"")};d.setPath=function(a,c,b){if("object"===typeof a&&null!==a)for(var l=0,d=c.length;l<d;){var h=c[l++];if(l==d)a[h]=b;else{var g=h in a;if(!g||g&&"object"!==typeof a[h]||g&&null===a[h])a[h]={};a=a[h]}}};d.getPath=function(a,c,b){for(var l=0,d=c.length,h=!0;h&&l<d&&"object"===typeof a&&null!==a;){var g=c[l++];(h=g in a)&&(a=a[g])}return h?a:b};d.deletePath=function(a,c){if("object"===
typeof a&&null!==a)for(var b=0,l=c.length;b<l;){var d=c[b++];if(b==l)delete a[d];else{if(!(d in a)||"object"!==typeof a[d]||null===a[d])break;a=a[d]}}};d.isEmpty=function(a){for(var c in a)if(a.hasOwnProperty(c))return!1;return!0};d.format=function(a){var c=/%./g,b,l,d=0,h=[];for(l=0;b=c.exec(a);)switch(l=a.substring(l,c.lastIndex-2),0<l.length&&h.push(l),l=c.lastIndex,b=b[0][1],b){case "s":case "o":d<arguments.length?h.push(arguments[d++ +1]):h.push("<?>");break;case "%":h.push("%");break;default:h.push("<#"+
b+"?>")}h.push(a.substring(l));return h.join("")};d.formatNumber=function(a,c,b,l){var d=isNaN(c=Math.abs(c))?2:c;c=void 0===b?",":b;l=void 0===l?".":l;b=0>a?"-":"";var h=parseInt(a=Math.abs(+a||0).toFixed(d),10)+"",g=3<h.length?h.length%3:0;return b+(g?h.substr(0,g)+l:"")+h.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+l)+(d?c+Math.abs(a-h).toFixed(d).slice(2):"")};d.formatSize=function(a){return a=1073741824<=a?d.formatNumber(a/1073741824,2,".","")+" GiB":1048576<=a?d.formatNumber(a/1048576,2,".","")+
" MiB":1024<=a?d.formatNumber(a/1024,0)+" KiB":d.formatNumber(a,0)+" bytes"};d.bytesFromIP=function(a){return-1!==a.indexOf(".")?d.bytesFromIPv4(a):-1!==a.indexOf(":")?d.bytesFromIPv6(a):null};d.bytesFromIPv4=function(a){a=a.split(".");if(4!==a.length)return null;for(var c=d.createBuffer(),b=0;b<a.length;++b){var l=parseInt(a[b],10);if(isNaN(l))return null;c.putByte(l)}return c.getBytes()};d.bytesFromIPv6=function(a){var c=0;a=a.split(":").filter(function(a){0===a.length&&++c;return!0});for(var b=
2*(8-a.length+c),l=d.createBuffer(),h=0;8>h;++h)if(a[h]&&0!==a[h].length){var g=d.hexToBytes(a[h]);2>g.length&&l.putByte(0);l.putBytes(g)}else l.fillWithByte(0,b),b=0;return l.getBytes()};d.bytesToIP=function(a){return 4===a.length?d.bytesToIPv4(a):16===a.length?d.bytesToIPv6(a):null};d.bytesToIPv4=function(a){if(4!==a.length)return null;for(var c=[],b=0;b<a.length;++b)c.push(a.charCodeAt(b));return c.join(".")};d.bytesToIPv6=function(a){if(16!==a.length)return null;for(var c=[],b=[],l=0,h=0;h<a.length;h+=
2){for(var g=d.bytesToHex(a[h]+a[h+1]);"0"===g[0]&&"0"!==g;)g=g.substr(1);if("0"===g){var m=b[b.length-1],e=c.length;m&&e===m.end+1?(m.end=e,m.end-m.start>b[l].end-b[l].start&&(l=b.length-1)):b.push({start:e,end:e})}c.push(g)}0<b.length&&(a=b[l],0<a.end-a.start&&(c.splice(a.start,a.end-a.start+1,""),0===a.start&&c.unshift(""),7===a.end&&c.push("")));return c.join(":")};d.estimateCores=function(a,c){function b(a,m,e){if(0===m){var k=Math.floor(a.reduce(function(a,c){return a+c},0)/a.length);d.cores=
Math.max(1,k);URL.revokeObjectURL(g);return c(null,d.cores)}l(e,function(c,l){a.push(h(e,l));b(a,m-1,e)})}function l(a,c){for(var b=[],d=[],h=0;h<a;++h){var m=new Worker(g);m.addEventListener("message",function(l){d.push(l.data);if(d.length===a){for(l=0;l<a;++l)b[l].terminate();c(null,d)}});b.push(m)}for(h=0;h<a;++h)b[h].postMessage(h)}function h(a,c){for(var b=[],l=0;l<a;++l)for(var d=c[l],g=b[l]=[],m=0;m<a;++m)if(l!==m){var e=c[m];(d.st>e.st&&d.st<e.et||e.st>d.st&&e.st<d.et)&&g.push(m)}return b.reduce(function(a,
c){return Math.max(a,c.length)},0)}"function"===typeof a&&(c=a,a={});a=a||{};if("cores"in d&&!a.update)return c(null,d.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&0<navigator.hardwareConcurrency)return d.cores=navigator.hardwareConcurrency,c(null,d.cores);if("undefined"===typeof Worker)return d.cores=1,c(null,d.cores);if("undefined"===typeof Blob)return d.cores=2,c(null,d.cores);var g=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(a){a=
Date.now();for(var c=a+4;Date.now()<c;);self.postMessage({st:a,et:c})})}.toString(),")()"],{type:"application/javascript"}));b([],5,16)}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.util)return b.util;b.defined.util=!0;for(var k=0;k<e.length;++k)e[k](b);
return b.util}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/util",["require","module"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.cipher=c.cipher||{};c.cipher.algorithms=c.cipher.algorithms||{};c.cipher.createCipher=function(a,b){var d=a;"string"===typeof d&&(d=c.cipher.getAlgorithm(d))&&
(d=d());if(!d)throw Error("Unsupported algorithm: "+a);return new c.cipher.BlockCipher({algorithm:d,key:b,decrypt:!1})};c.cipher.createDecipher=function(a,b){var d=a;"string"===typeof d&&(d=c.cipher.getAlgorithm(d))&&(d=d());if(!d)throw Error("Unsupported algorithm: "+a);return new c.cipher.BlockCipher({algorithm:d,key:b,decrypt:!0})};c.cipher.registerAlgorithm=function(a,b){a=a.toUpperCase();c.cipher.algorithms[a]=b};c.cipher.getAlgorithm=function(a){a=a.toUpperCase();return a in c.cipher.algorithms?
c.cipher.algorithms[a]:null};var b=c.cipher.BlockCipher=function(a){this.algorithm=a.algorithm;this.mode=this.algorithm.mode;this.blockSize=this.mode.blockSize;this._finish=!1;this.output=this._input=null;this._op=a.decrypt?this.mode.decrypt:this.mode.encrypt;this._decrypt=a.decrypt;this.algorithm.initialize(a)};b.prototype.start=function(a){a=a||{};var b={},d;for(d in a)b[d]=a[d];b.decrypt=this._decrypt;this._finish=!1;this._input=c.util.createBuffer();this.output=a.output||c.util.createBuffer();
this.mode.start(b)};b.prototype.update=function(a){for(a&&this._input.putBuffer(a);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};b.prototype.finish=function(a){!a||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(c){return a(this.blockSize,c,!1)},this.mode.unpad=function(c){return a(this.blockSize,c,!0)});var c={};c.decrypt=this._decrypt;c.overflow=this._input.length()%this.blockSize;if(!this._decrypt&&this.mode.pad&&
!this.mode.pad(this._input,c))return!1;this._finish=!0;this.update();return this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,c)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,c)?!1:!0}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.cipher)return b.cipher;
b.defined.cipher=!0;for(var k=0;k<e.length;++k)e[k](b);return b.cipher}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/cipher",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a){"string"===typeof a&&(a=c.util.createBuffer(a));if(c.util.isArray(a)&&
2018-10-03 22:03:09 +03:00
4<a.length){var d=a;a=c.util.createBuffer();for(var g=0;g<d.length;++g)a.putByte(d[g])}c.util.isArray(a)||(a=[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()]);return a}function d(a){a[a.length-1]=a[a.length-1]+1&4294967295}function e(a){return[a/4294967296|0,a&4294967295]}c.cipher=c.cipher||{};var u=c.cipher.modes=c.cipher.modes||{};u.ecb=function(a){a=a||{};this.name="ECB";this.cipher=a.cipher;this.blockSize=a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=Array(this._ints);this._outBlock=
Array(this._ints)};u.ecb.prototype.start=function(a){};u.ecb.prototype.encrypt=function(a,c,b){if(a.length()<this.blockSize&&!(b&&0<a.length()))return!0;for(b=0;b<this._ints;++b)this._inBlock[b]=a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(b=0;b<this._ints;++b)c.putInt32(this._outBlock[b])};u.ecb.prototype.decrypt=function(a,c,b){if(a.length()<this.blockSize&&!(b&&0<a.length()))return!0;for(b=0;b<this._ints;++b)this._inBlock[b]=a.getInt32();this.cipher.decrypt(this._inBlock,
this._outBlock);for(b=0;b<this._ints;++b)c.putInt32(this._outBlock[b])};u.ecb.prototype.pad=function(a,c){var b=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();a.fillWithByte(b,b);return!0};u.ecb.prototype.unpad=function(a,c){if(0<c.overflow)return!1;var b=a.length(),b=a.at(b-1);if(b>this.blockSize<<2)return!1;a.truncate(b);return!0};u.cbc=function(a){a=a||{};this.name="CBC";this.cipher=a.cipher;this.blockSize=a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=Array(this._ints);
this._outBlock=Array(this._ints)};u.cbc.prototype.start=function(a){if(null===a.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in a)this._iv=b(a.iv),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.");};u.cbc.prototype.encrypt=function(a,c,b){if(a.length()<this.blockSize&&!(b&&0<a.length()))return!0;for(b=0;b<this._ints;++b)this._inBlock[b]=this._prev[b]^a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(b=0;b<this._ints;++b)c.putInt32(this._outBlock[b]);
this._prev=this._outBlock};u.cbc.prototype.decrypt=function(a,c,b){if(a.length()<this.blockSize&&!(b&&0<a.length()))return!0;for(b=0;b<this._ints;++b)this._inBlock[b]=a.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(b=0;b<this._ints;++b)c.putInt32(this._prev[b]^this._outBlock[b]);this._prev=this._inBlock.slice(0)};u.cbc.prototype.pad=function(a,c){var b=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();a.fillWithByte(b,b);return!0};u.cbc.prototype.unpad=function(a,
c){if(0<c.overflow)return!1;var b=a.length(),b=a.at(b-1);if(b>this.blockSize<<2)return!1;a.truncate(b);return!0};u.cfb=function(a){a=a||{};this.name="CFB";this.cipher=a.cipher;this.blockSize=a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=Array(this._ints);this._partialBlock=Array(this._ints);this._partialOutput=c.util.createBuffer();this._partialBytes=0};u.cfb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=b(a.iv);this._inBlock=
this._iv.slice(0);this._partialBytes=0};u.cfb.prototype.encrypt=function(a,c,b){var l=a.length();if(0===l)return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&l>=this.blockSize)for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32()^this._outBlock[d],c.putInt32(this._inBlock[d]);else{var e=(this.blockSize-l)%this.blockSize;0<e&&(e=this.blockSize-e);this._partialOutput.clear();for(d=0;d<this._ints;++d)this._partialBlock[d]=a.getInt32()^this._outBlock[d],this._partialOutput.putInt32(this._partialBlock[d]);
if(0<e)a.read-=this.blockSize;else for(d=0;d<this._ints;++d)this._inBlock[d]=this._partialBlock[d];0<this._partialBytes&&this._partialOutput.getBytes(this._partialBytes);if(0<e&&!b)return c.putBytes(this._partialOutput.getBytes(e-this._partialBytes)),this._partialBytes=e,!0;c.putBytes(this._partialOutput.getBytes(l-this._partialBytes));this._partialBytes=0}};u.cfb.prototype.decrypt=function(a,c,b){var l=a.length();if(0===l)return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&
2018-08-24 02:55:06 +03:00
l>=this.blockSize)for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32(),c.putInt32(this._inBlock[d]^this._outBlock[d]);else{var e=(this.blockSize-l)%this.blockSize;0<e&&(e=this.blockSize-e);this._partialOutput.clear();for(d=0;d<this._ints;++d)this._partialBlock[d]=a.getInt32(),this._partialOutput.putInt32(this._partialBlock[d]^this._outBlock[d]);if(0<e)a.read-=this.blockSize;else for(d=0;d<this._ints;++d)this._inBlock[d]=this._partialBlock[d];0<this._partialBytes&&this._partialOutput.getBytes(this._partialBytes);
2018-10-03 22:03:09 +03:00
if(0<e&&!b)return c.putBytes(this._partialOutput.getBytes(e-this._partialBytes)),this._partialBytes=e,!0;c.putBytes(this._partialOutput.getBytes(l-this._partialBytes));this._partialBytes=0}};u.ofb=function(a){a=a||{};this.name="OFB";this.cipher=a.cipher;this.blockSize=a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=Array(this._ints);this._partialOutput=c.util.createBuffer();this._partialBytes=0};u.ofb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");
this._iv=b(a.iv);this._inBlock=this._iv.slice(0);this._partialBytes=0};u.ofb.prototype.encrypt=function(a,c,b){var l=a.length();if(0===a.length())return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&l>=this.blockSize)for(var d=0;d<this._ints;++d)c.putInt32(a.getInt32()^this._outBlock[d]),this._inBlock[d]=this._outBlock[d];else{var e=(this.blockSize-l)%this.blockSize;0<e&&(e=this.blockSize-e);this._partialOutput.clear();for(d=0;d<this._ints;++d)this._partialOutput.putInt32(a.getInt32()^
this._outBlock[d]);if(0<e)a.read-=this.blockSize;else for(d=0;d<this._ints;++d)this._inBlock[d]=this._outBlock[d];0<this._partialBytes&&this._partialOutput.getBytes(this._partialBytes);if(0<e&&!b)return c.putBytes(this._partialOutput.getBytes(e-this._partialBytes)),this._partialBytes=e,!0;c.putBytes(this._partialOutput.getBytes(l-this._partialBytes));this._partialBytes=0}};u.ofb.prototype.decrypt=u.ofb.prototype.encrypt;u.ctr=function(a){a=a||{};this.name="CTR";this.cipher=a.cipher;this.blockSize=
a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=Array(this._ints);this._partialOutput=c.util.createBuffer();this._partialBytes=0};u.ctr.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=b(a.iv);this._inBlock=this._iv.slice(0);this._partialBytes=0};u.ctr.prototype.encrypt=function(a,c,b){var l=a.length();if(0===l)return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&l>=this.blockSize)for(var e=0;e<
2018-08-24 02:55:06 +03:00
this._ints;++e)c.putInt32(a.getInt32()^this._outBlock[e]);else{var k=(this.blockSize-l)%this.blockSize;0<k&&(k=this.blockSize-k);this._partialOutput.clear();for(e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);0<k&&(a.read-=this.blockSize);0<this._partialBytes&&this._partialOutput.getBytes(this._partialBytes);if(0<k&&!b)return c.putBytes(this._partialOutput.getBytes(k-this._partialBytes)),this._partialBytes=k,!0;c.putBytes(this._partialOutput.getBytes(l-this._partialBytes));
2018-10-03 22:03:09 +03:00
this._partialBytes=0}d(this._inBlock)};u.ctr.prototype.decrypt=u.ctr.prototype.encrypt;u.gcm=function(a){a=a||{};this.name="GCM";this.cipher=a.cipher;this.blockSize=a.blockSize||16;this._ints=this.blockSize/4;this._inBlock=Array(this._ints);this._outBlock=Array(this._ints);this._partialOutput=c.util.createBuffer();this._partialBytes=0;this._R=3774873600};u.gcm.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");var b=c.util.createBuffer(a.iv);this._cipherLength=0;var g;
2018-08-24 02:55:06 +03:00
g="additionalData"in a?c.util.createBuffer(a.additionalData):c.util.createBuffer();this._tagLength="tagLength"in a?a.tagLength:128;this._tag=null;if(a.decrypt&&(this._tag=c.util.createBuffer(a.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error("Authentication tag does not match tag length.");this._hashBlock=Array(this._ints);this.tag=null;this._hashSubkey=Array(this._ints);this.cipher.encrypt([0,0,0,0],this._hashSubkey);this.componentBits=4;this._m=this.generateHashTable(this._hashSubkey,
this.componentBits);a=b.length();if(12===a)this._j0=[b.getInt32(),b.getInt32(),b.getInt32(),1];else{for(this._j0=[0,0,0,0];0<b.length();)this._j0=this.ghash(this._hashSubkey,this._j0,[b.getInt32(),b.getInt32(),b.getInt32(),b.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(e(8*a)))}this._inBlock=this._j0.slice(0);d(this._inBlock);this._partialBytes=0;g=c.util.createBuffer(g);this._aDataLength=e(8*g.length());(b=g.length()%this.blockSize)&&g.fillWithByte(0,this.blockSize-b);
2018-10-03 22:03:09 +03:00
for(this._s=[0,0,0,0];0<g.length();)this._s=this.ghash(this._hashSubkey,this._s,[g.getInt32(),g.getInt32(),g.getInt32(),g.getInt32()])};u.gcm.prototype.encrypt=function(a,c,b){var l=a.length();if(0===l)return!0;this.cipher.encrypt(this._inBlock,this._outBlock);if(0===this._partialBytes&&l>=this.blockSize){for(var e=0;e<this._ints;++e)c.putInt32(this._outBlock[e]^=a.getInt32());this._cipherLength+=this.blockSize}else{var k=(this.blockSize-l)%this.blockSize;0<k&&(k=this.blockSize-k);this._partialOutput.clear();
2018-08-24 02:55:06 +03:00
for(e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(0===k||b){b?(e=l%this.blockSize,this._cipherLength+=e,this._partialOutput.truncate(this.blockSize-e)):this._cipherLength+=this.blockSize;for(e=0;e<this._ints;++e)this._outBlock[e]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}0<this._partialBytes&&this._partialOutput.getBytes(this._partialBytes);if(0<k&&!b)return a.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(k-this._partialBytes)),
2018-10-03 22:03:09 +03:00
this._partialBytes=k,!0;c.putBytes(this._partialOutput.getBytes(l-this._partialBytes));this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock);d(this._inBlock)};u.gcm.prototype.decrypt=function(a,c,b){var l=a.length();if(l<this.blockSize&&!(b&&0<l))return!0;this.cipher.encrypt(this._inBlock,this._outBlock);d(this._inBlock);this._hashBlock[0]=a.getInt32();this._hashBlock[1]=a.getInt32();this._hashBlock[2]=a.getInt32();this._hashBlock[3]=a.getInt32();this._s=this.ghash(this._hashSubkey,
this._s,this._hashBlock);for(a=0;a<this._ints;++a)c.putInt32(this._outBlock[a]^this._hashBlock[a]);this._cipherLength=l<this.blockSize?this._cipherLength+l%this.blockSize:this._cipherLength+this.blockSize};u.gcm.prototype.afterFinish=function(a,b){var d=!0;b.decrypt&&b.overflow&&a.truncate(this.blockSize-b.overflow);this.tag=c.util.createBuffer();var k=this._aDataLength.concat(e(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,k);k=[];this.cipher.encrypt(this._j0,k);for(var m=0;m<
this._ints;++m)this.tag.putInt32(this._s[m]^k[m]);this.tag.truncate(this.tag.length()%(this._tagLength/8));b.decrypt&&this.tag.bytes()!==this._tag&&(d=!1);return d};u.gcm.prototype.multiply=function(a,c){for(var b=[0,0,0,0],l=c.slice(0),d=0;128>d;++d)a[d/32|0]&1<<31-d%32&&(b[0]^=l[0],b[1]^=l[1],b[2]^=l[2],b[3]^=l[3]),this.pow(l,l);return b};u.gcm.prototype.pow=function(a,c){for(var b=a[3]&1,l=3;0<l;--l)c[l]=a[l]>>>1|(a[l-1]&1)<<31;c[0]=a[0]>>>1;b&&(c[0]^=this._R)};u.gcm.prototype.tableMultiply=function(a){for(var c=
[0,0,0,0],b=0;32>b;++b){var l=this._m[b][a[b/8|0]>>>4*(7-b%8)&15];c[0]^=l[0];c[1]^=l[1];c[2]^=l[2];c[3]^=l[3]}return c};u.gcm.prototype.ghash=function(a,c,b){c[0]^=b[0];c[1]^=b[1];c[2]^=b[2];c[3]^=b[3];return this.tableMultiply(c)};u.gcm.prototype.generateHashTable=function(a,c){for(var b=8/c,l=4*b,b=16*b,d=Array(b),e=0;e<b;++e){var k=[0,0,0,0];k[e/l|0]=1<<c-1<<(l-1-e%l)*c;d[e]=this.generateSubHashTable(this.multiply(k,a),c)}return d};u.gcm.prototype.generateSubHashTable=function(a,c){var b=1<<c,
l=b>>>1,d=Array(b);d[l]=a.slice(0);for(var e=l>>>1;0<e;)this.pow(d[2*e],d[e]=[]),e>>=1;for(e=2;e<l;){for(var k=1;k<e;++k){var u=d[e],f=d[k];d[e+k]=[u[0]^f[0],u[1]^f[1],u[2]^f[2],u[3]^f[3]]}e*=2}d[0]=[0,0,0,0];for(e=l+1;e<b;++e)k=d[e^l],d[e]=[a[0]^k[0],a[1]^k[1],a[2]^k[2],a[3]^k[3]];return d}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=
2018-08-24 02:55:06 +03:00
n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.cipherModes)return b.cipherModes;b.defined.cipherModes=!0;for(var k=0;k<e.length;++k)e[k](b);return b.cipherModes}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/cipherModes",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,
2018-11-15 02:44:28 +03:00
0))})})();(function(){function a(c){function b(a,d){c.cipher.registerAlgorithm(a,function(){return new c.aes.Algorithm(a,d)})}function d(){h=!0;F=[0,1,2,4,8,16,32,64,128,27,54];for(var a=Array(256),c=0;128>c;++c)a[c]=c<<1,a[c+128]=c+128<<1^283;E=Array(256);m=Array(256);w=Array(4);y=Array(4);for(c=0;4>c;++c)w[c]=Array(256),y[c]=Array(256);for(var b=0,l=0,g,e,k,u,f,c=0;256>c;++c){u=l^l<<1^l<<2^l<<3^l<<4;u=u>>8^u&255^99;E[b]=u;m[u]=b;f=a[u];g=a[b];e=a[g];k=a[e];f^=f<<24^u<<16^u<<8^u;e=(g^e^k)<<24^(b^
k)<<16^(b^e^k)<<8^b^g^k;for(var v=0;4>v;++v)w[v][b]=f,y[v][u]=e,f=f<<24|f>>>8,e=e<<24|e>>>8;0===b?b=l=1:(b=g^a[a[a[g^k]]],l^=a[a[l]])}}function e(a,c){for(var b=a.slice(0),l,d=1,h=b.length,e=g*(h+6+1),k=h;k<e;++k)l=b[k-1],0===k%h?(l=E[l>>>16&255]<<24^E[l>>>8&255]<<16^E[l&255]<<8^E[l>>>24]^F[d]<<24,d++):6<h&&4===k%h&&(l=E[l>>>24]<<24^E[l>>>16&255]<<16^E[l>>>8&255]<<8^E[l&255]),b[k]=b[k-h]^l;if(c){for(var d=y[0],h=y[1],m=y[2],u=y[3],f=b.slice(0),e=b.length,k=0,v=e-g;k<e;k+=g,v-=g)if(0===k||k===e-g)f[k]=
b[v],f[k+1]=b[v+3],f[k+2]=b[v+2],f[k+3]=b[v+1];else for(var w=0;w<g;++w)l=b[v+w],f[k+(3&-w)]=d[E[l>>>24]]^h[E[l>>>16&255]]^m[E[l>>>8&255]]^u[E[l&255]];b=f}return b}function u(a,c,b,l){var d=a.length/4-1,h,g,e,k,u;l?(h=y[0],g=y[1],e=y[2],k=y[3],u=m):(h=w[0],g=w[1],e=w[2],k=w[3],u=E);var f,v,B,F,n,p;f=c[0]^a[0];v=c[l?3:1]^a[1];B=c[2]^a[2];c=c[l?1:3]^a[3];for(var r=3,S=1;S<d;++S)F=h[f>>>24]^g[v>>>16&255]^e[B>>>8&255]^k[c&255]^a[++r],n=h[v>>>24]^g[B>>>16&255]^e[c>>>8&255]^k[f&255]^a[++r],p=h[B>>>24]^
g[c>>>16&255]^e[f>>>8&255]^k[v&255]^a[++r],c=h[c>>>24]^g[f>>>16&255]^e[v>>>8&255]^k[B&255]^a[++r],f=F,v=n,B=p;b[0]=u[f>>>24]<<24^u[v>>>16&255]<<16^u[B>>>8&255]<<8^u[c&255]^a[++r];b[l?3:1]=u[v>>>24]<<24^u[B>>>16&255]<<16^u[c>>>8&255]<<8^u[f&255]^a[++r];b[2]=u[B>>>24]<<24^u[c>>>16&255]<<16^u[f>>>8&255]<<8^u[v&255]^a[++r];b[l?1:3]=u[c>>>24]<<24^u[f>>>16&255]<<16^u[v>>>8&255]<<8^u[B&255]^a[++r]}function f(a){a=a||{};var b="AES-"+(a.mode||"CBC").toUpperCase(),d;d=a.decrypt?c.cipher.createDecipher(b,a.key):
2018-08-24 02:55:06 +03:00
c.cipher.createCipher(b,a.key);var h=d.start;d.start=function(a,b){var g=null;b instanceof c.util.ByteBuffer&&(g=b,b={});b=b||{};b.output=g;b.iv=a;h.call(d,b)};return d}c.aes=c.aes||{};c.aes.startEncrypting=function(a,c,b,l){a=f({key:a,output:b,decrypt:!1,mode:l});a.start(c);return a};c.aes.createEncryptionCipher=function(a,c){return f({key:a,output:null,decrypt:!1,mode:c})};c.aes.startDecrypting=function(a,c,b,l){a=f({key:a,output:b,decrypt:!0,mode:l});a.start(c);return a};c.aes.createDecryptionCipher=
2018-10-03 22:03:09 +03:00
function(a,c){return f({key:a,output:null,decrypt:!0,mode:c})};c.aes.Algorithm=function(a,c){h||d();var b=this;b.name=a;b.mode=new c({blockSize:16,cipher:{encrypt:function(a,c){return u(b._w,a,c,!1)},decrypt:function(a,c){return u(b._w,a,c,!0)}}});b._init=!1};c.aes.Algorithm.prototype.initialize=function(a){if(!this._init){var b=a.key,d;if("string"===typeof b&&(16===b.length||24===b.length||32===b.length))b=c.util.createBuffer(b);else if(c.util.isArray(b)&&(16===b.length||24===b.length||32===b.length)){d=
b;for(var b=c.util.createBuffer(),h=0;h<d.length;++h)b.putByte(d[h])}if(!c.util.isArray(b)){d=b;var b=[],g=d.length();if(16===g||24===g||32===g)for(g>>>=2,h=0;h<g;++h)b.push(d.getInt32())}if(!c.util.isArray(b)||4!==b.length&&6!==b.length&&8!==b.length)throw Error("Invalid key parameter.");d=-1!==["CFB","OFB","CTR","GCM"].indexOf(this.mode.name);this._w=e(b,a.decrypt&&!d);this._init=!0}};c.aes._expandKey=function(a,c){h||d();return e(a,c)};c.aes._updateBlock=u;b("AES-ECB",c.cipher.modes.ecb);b("AES-CBC",
2018-11-15 02:44:28 +03:00
c.cipher.modes.cbc);b("AES-CFB",c.cipher.modes.cfb);b("AES-OFB",c.cipher.modes.ofb);b("AES-CTR",c.cipher.modes.ctr);b("AES-GCM",c.cipher.modes.gcm);var h=!1,g=4,E,m,F,w,y}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.aes)return b.aes;b.defined.aes=
2018-08-24 02:55:06 +03:00
!0;for(var k=0;k<e.length;++k)e[k](b);return b.aes}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/aes",["require","module","./cipher","./cipherModes","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.pki=c.pki||{};c=c.pki.oids=c.oids=c.oids||{};c["1.2.840.113549.1.1.1"]="rsaEncryption";
c.rsaEncryption="1.2.840.113549.1.1.1";c["1.2.840.113549.1.1.4"]="md5WithRSAEncryption";c.md5WithRSAEncryption="1.2.840.113549.1.1.4";c["1.2.840.113549.1.1.5"]="sha1WithRSAEncryption";c.sha1WithRSAEncryption="1.2.840.113549.1.1.5";c["1.2.840.113549.1.1.7"]="RSAES-OAEP";c["RSAES-OAEP"]="1.2.840.113549.1.1.7";c["1.2.840.113549.1.1.8"]="mgf1";c.mgf1="1.2.840.113549.1.1.8";c["1.2.840.113549.1.1.9"]="pSpecified";c.pSpecified="1.2.840.113549.1.1.9";c["1.2.840.113549.1.1.10"]="RSASSA-PSS";c["RSASSA-PSS"]=
"1.2.840.113549.1.1.10";c["1.2.840.113549.1.1.11"]="sha256WithRSAEncryption";c.sha256WithRSAEncryption="1.2.840.113549.1.1.11";c["1.2.840.113549.1.1.12"]="sha384WithRSAEncryption";c.sha384WithRSAEncryption="1.2.840.113549.1.1.12";c["1.2.840.113549.1.1.13"]="sha512WithRSAEncryption";c.sha512WithRSAEncryption="1.2.840.113549.1.1.13";c["1.3.14.3.2.7"]="desCBC";c.desCBC="1.3.14.3.2.7";c["1.3.14.3.2.26"]="sha1";c.sha1="1.3.14.3.2.26";c["2.16.840.1.101.3.4.2.1"]="sha256";c.sha256="2.16.840.1.101.3.4.2.1";
c["2.16.840.1.101.3.4.2.2"]="sha384";c.sha384="2.16.840.1.101.3.4.2.2";c["2.16.840.1.101.3.4.2.3"]="sha512";c.sha512="2.16.840.1.101.3.4.2.3";c["1.2.840.113549.2.5"]="md5";c.md5="1.2.840.113549.2.5";c["1.2.840.113549.1.7.1"]="data";c.data="1.2.840.113549.1.7.1";c["1.2.840.113549.1.7.2"]="signedData";c.signedData="1.2.840.113549.1.7.2";c["1.2.840.113549.1.7.3"]="envelopedData";c.envelopedData="1.2.840.113549.1.7.3";c["1.2.840.113549.1.7.4"]="signedAndEnvelopedData";c.signedAndEnvelopedData="1.2.840.113549.1.7.4";
c["1.2.840.113549.1.7.5"]="digestedData";c.digestedData="1.2.840.113549.1.7.5";c["1.2.840.113549.1.7.6"]="encryptedData";c.encryptedData="1.2.840.113549.1.7.6";c["1.2.840.113549.1.9.1"]="emailAddress";c.emailAddress="1.2.840.113549.1.9.1";c["1.2.840.113549.1.9.2"]="unstructuredName";c.unstructuredName="1.2.840.113549.1.9.2";c["1.2.840.113549.1.9.3"]="contentType";c.contentType="1.2.840.113549.1.9.3";c["1.2.840.113549.1.9.4"]="messageDigest";c.messageDigest="1.2.840.113549.1.9.4";c["1.2.840.113549.1.9.5"]=
"signingTime";c.signingTime="1.2.840.113549.1.9.5";c["1.2.840.113549.1.9.6"]="counterSignature";c.counterSignature="1.2.840.113549.1.9.6";c["1.2.840.113549.1.9.7"]="challengePassword";c.challengePassword="1.2.840.113549.1.9.7";c["1.2.840.113549.1.9.8"]="unstructuredAddress";c.unstructuredAddress="1.2.840.113549.1.9.8";c["1.2.840.113549.1.9.14"]="extensionRequest";c.extensionRequest="1.2.840.113549.1.9.14";c["1.2.840.113549.1.9.20"]="friendlyName";c.friendlyName="1.2.840.113549.1.9.20";c["1.2.840.113549.1.9.21"]=
"localKeyId";c.localKeyId="1.2.840.113549.1.9.21";c["1.2.840.113549.1.9.22.1"]="x509Certificate";c.x509Certificate="1.2.840.113549.1.9.22.1";c["1.2.840.113549.1.12.10.1.1"]="keyBag";c.keyBag="1.2.840.113549.1.12.10.1.1";c["1.2.840.113549.1.12.10.1.2"]="pkcs8ShroudedKeyBag";c.pkcs8ShroudedKeyBag="1.2.840.113549.1.12.10.1.2";c["1.2.840.113549.1.12.10.1.3"]="certBag";c.certBag="1.2.840.113549.1.12.10.1.3";c["1.2.840.113549.1.12.10.1.4"]="crlBag";c.crlBag="1.2.840.113549.1.12.10.1.4";c["1.2.840.113549.1.12.10.1.5"]=
"secretBag";c.secretBag="1.2.840.113549.1.12.10.1.5";c["1.2.840.113549.1.12.10.1.6"]="safeContentsBag";c.safeContentsBag="1.2.840.113549.1.12.10.1.6";c["1.2.840.113549.1.5.13"]="pkcs5PBES2";c.pkcs5PBES2="1.2.840.113549.1.5.13";c["1.2.840.113549.1.5.12"]="pkcs5PBKDF2";c.pkcs5PBKDF2="1.2.840.113549.1.5.12";c["1.2.840.113549.1.12.1.1"]="pbeWithSHAAnd128BitRC4";c.pbeWithSHAAnd128BitRC4="1.2.840.113549.1.12.1.1";c["1.2.840.113549.1.12.1.2"]="pbeWithSHAAnd40BitRC4";c.pbeWithSHAAnd40BitRC4="1.2.840.113549.1.12.1.2";
c["1.2.840.113549.1.12.1.3"]="pbeWithSHAAnd3-KeyTripleDES-CBC";c["pbeWithSHAAnd3-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.3";c["1.2.840.113549.1.12.1.4"]="pbeWithSHAAnd2-KeyTripleDES-CBC";c["pbeWithSHAAnd2-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.4";c["1.2.840.113549.1.12.1.5"]="pbeWithSHAAnd128BitRC2-CBC";c["pbeWithSHAAnd128BitRC2-CBC"]="1.2.840.113549.1.12.1.5";c["1.2.840.113549.1.12.1.6"]="pbewithSHAAnd40BitRC2-CBC";c["pbewithSHAAnd40BitRC2-CBC"]="1.2.840.113549.1.12.1.6";c["1.2.840.113549.3.7"]=
"des-EDE3-CBC";c["des-EDE3-CBC"]="1.2.840.113549.3.7";c["2.16.840.1.101.3.4.1.2"]="aes128-CBC";c["aes128-CBC"]="2.16.840.1.101.3.4.1.2";c["2.16.840.1.101.3.4.1.22"]="aes192-CBC";c["aes192-CBC"]="2.16.840.1.101.3.4.1.22";c["2.16.840.1.101.3.4.1.42"]="aes256-CBC";c["aes256-CBC"]="2.16.840.1.101.3.4.1.42";c["2.5.4.3"]="commonName";c.commonName="2.5.4.3";c["2.5.4.5"]="serialName";c.serialName="2.5.4.5";c["2.5.4.6"]="countryName";c.countryName="2.5.4.6";c["2.5.4.7"]="localityName";c.localityName="2.5.4.7";
c["2.5.4.8"]="stateOrProvinceName";c.stateOrProvinceName="2.5.4.8";c["2.5.4.10"]="organizationName";c.organizationName="2.5.4.10";c["2.5.4.11"]="organizationalUnitName";c.organizationalUnitName="2.5.4.11";c["2.16.840.1.113730.1.1"]="nsCertType";c.nsCertType="2.16.840.1.113730.1.1";c["2.5.29.1"]="authorityKeyIdentifier";c["2.5.29.2"]="keyAttributes";c["2.5.29.3"]="certificatePolicies";c["2.5.29.4"]="keyUsageRestriction";c["2.5.29.5"]="policyMapping";c["2.5.29.6"]="subtreesConstraint";c["2.5.29.7"]=
"subjectAltName";c["2.5.29.8"]="issuerAltName";c["2.5.29.9"]="subjectDirectoryAttributes";c["2.5.29.10"]="basicConstraints";c["2.5.29.11"]="nameConstraints";c["2.5.29.12"]="policyConstraints";c["2.5.29.13"]="basicConstraints";c["2.5.29.14"]="subjectKeyIdentifier";c.subjectKeyIdentifier="2.5.29.14";c["2.5.29.15"]="keyUsage";c.keyUsage="2.5.29.15";c["2.5.29.16"]="privateKeyUsagePeriod";c["2.5.29.17"]="subjectAltName";c.subjectAltName="2.5.29.17";c["2.5.29.18"]="issuerAltName";c.issuerAltName="2.5.29.18";
c["2.5.29.19"]="basicConstraints";c.basicConstraints="2.5.29.19";c["2.5.29.20"]="cRLNumber";c["2.5.29.21"]="cRLReason";c["2.5.29.22"]="expirationDate";c["2.5.29.23"]="instructionCode";c["2.5.29.24"]="invalidityDate";c["2.5.29.25"]="cRLDistributionPoints";c["2.5.29.26"]="issuingDistributionPoint";c["2.5.29.27"]="deltaCRLIndicator";c["2.5.29.28"]="issuingDistributionPoint";c["2.5.29.29"]="certificateIssuer";c["2.5.29.30"]="nameConstraints";c["2.5.29.31"]="cRLDistributionPoints";c["2.5.29.32"]="certificatePolicies";
c["2.5.29.33"]="policyMappings";c["2.5.29.34"]="policyConstraints";c["2.5.29.35"]="authorityKeyIdentifier";c["2.5.29.36"]="policyConstraints";c["2.5.29.37"]="extKeyUsage";c.extKeyUsage="2.5.29.37";c["2.5.29.46"]="freshestCRL";c["2.5.29.54"]="inhibitAnyPolicy";c["1.3.6.1.5.5.7.3.1"]="serverAuth";c.serverAuth="1.3.6.1.5.5.7.3.1";c["1.3.6.1.5.5.7.3.2"]="clientAuth";c.clientAuth="1.3.6.1.5.5.7.3.2";c["1.3.6.1.5.5.7.3.3"]="codeSigning";c.codeSigning="1.3.6.1.5.5.7.3.3";c["1.3.6.1.5.5.7.3.4"]="emailProtection";
c.emailProtection="1.3.6.1.5.5.7.3.4";c["1.3.6.1.5.5.7.3.8"]="timeStamping";c.timeStamping="1.3.6.1.5.5.7.3.8"}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.oids)return b.oids;b.defined.oids=!0;for(var k=0;k<e.length;++k)e[k](b);return b.oids}},
r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/oids",["require","module"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=c.asn1=c.asn1||{};b.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};b.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};b.create=function(a,b,d,g){if(c.util.isArray(g)){for(var e=[],m=0;m<g.length;++m)void 0!==g[m]&&e.push(g[m]);g=e}return{tagClass:a,type:b,constructed:d,composed:d||c.util.isArray(g),value:g}};var d=b.getBerValueLength=function(a){var c=a.getByte();if(128!==c)return c&128?a.getInt((c&127)<<3):c};b.fromDer=function(a,e){void 0===e&&(e=!0);
2018-11-15 02:44:28 +03:00
"string"===typeof a&&(a=c.util.createBuffer(a));if(2>a.length()){var h=Error("Too few bytes to parse DER.");h.bytes=a.length();throw h;}var g=a.getByte(),h=g&192,f=g&31,m=d(a);if(a.length()<m){if(e)throw h=Error("Too few bytes to read ASN.1 value."),h.detail=a.length()+" < "+m,h;m=a.length()}var F,w=32===(g&32);F=w;if(!F&&h===b.Class.UNIVERSAL&&f===b.Type.BITSTRING&&1<m){var y=a.read;if(0===a.getByte()&&(g=a.getByte(),g&=192,g===b.Class.UNIVERSAL||g===b.Class.CONTEXT_SPECIFIC))try{if(F=d(a)===m-(a.read-
y))++y,--m}catch(C){}a.read=y}if(F)if(F=[],void 0===m)for(;;){if(a.bytes(2)===String.fromCharCode(0,0)){a.getBytes(2);break}F.push(b.fromDer(a,e))}else for(y=a.length();0<m;)F.push(b.fromDer(a,e)),m-=y-a.length(),y=a.length();else{if(void 0===m){if(e)throw Error("Non-constructed ASN.1 object of indefinite length.");m=a.length()}if(f===b.Type.BMPSTRING)for(F="",y=0;y<m;y+=2)F+=String.fromCharCode(a.getInt16());else F=a.getBytes(m)}return b.create(h,f,w,F)};b.toDer=function(a){var d=c.util.createBuffer(),
2018-08-24 02:55:06 +03:00
h=a.tagClass|a.type,g=c.util.createBuffer();if(a.composed){a.constructed?h|=32:g.putByte(0);for(var e=0;e<a.value.length;++e)void 0!==a.value[e]&&g.putBuffer(b.toDer(a.value[e]))}else if(a.type===b.Type.BMPSTRING)for(e=0;e<a.value.length;++e)g.putInt16(a.value.charCodeAt(e));else g.putBytes(a.value);d.putByte(h);if(127>=g.length())d.putByte(g.length()&127);else{e=g.length();a="";do a+=String.fromCharCode(e&255),e>>>=8;while(0<e);d.putByte(a.length|128);for(e=a.length-1;0<=e;--e)d.putByte(a.charCodeAt(e))}d.putBuffer(g);
return d};b.oidToDer=function(a){a=a.split(".");var b=c.util.createBuffer();b.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var d,g,e,m,k=2;k<a.length;++k){d=!0;g=[];e=parseInt(a[k],10);do m=e&127,e>>>=7,d||(m|=128),g.push(m),d=!1;while(0<e);for(d=g.length-1;0<=d;--d)b.putByte(g[d])}return b};b.derToOid=function(a){var b;"string"===typeof a&&(a=c.util.createBuffer(a));var d=a.getByte();b=Math.floor(d/40)+"."+d%40;for(var g=0;0<a.length();)d=a.getByte(),g<<=7,d&128?g+=d&127:(b+="."+(g+d),g=0);
2018-11-15 02:44:28 +03:00
return b};b.utcTimeToDate=function(a){var c=new Date,b=parseInt(a.substr(0,2),10),b=50<=b?1900+b:2E3+b,d=parseInt(a.substr(2,2),10)-1,l=parseInt(a.substr(4,2),10),e=parseInt(a.substr(6,2),10),k=parseInt(a.substr(8,2),10),f=0;if(11<a.length){var v=a.charAt(10),C=10;"+"!==v&&"-"!==v&&(f=parseInt(a.substr(10,2),10),C+=2)}c.setUTCFullYear(b,d,l);c.setUTCHours(e,k,f,0);C&&(v=a.charAt(C),"+"===v||"-"===v)&&(b=parseInt(a.substr(C+1,2),10),a=parseInt(a.substr(C+4,2),10),a=6E4*(60*b+a),"+"===v?c.setTime(+c-
a):c.setTime(+c+a));return c};b.generalizedTimeToDate=function(a){var c=new Date,b=parseInt(a.substr(0,4),10),d=parseInt(a.substr(4,2),10)-1,l=parseInt(a.substr(6,2),10),e=parseInt(a.substr(8,2),10),k=parseInt(a.substr(10,2),10),f=parseInt(a.substr(12,2),10),v=0,C=0,A=!1;"Z"===a.charAt(a.length-1)&&(A=!0);var n=a.length-5,z=a.charAt(n);if("+"===z||"-"===z)C=parseInt(a.substr(n+1,2),10),n=parseInt(a.substr(n+4,2),10),C=6E4*(60*C+n),"+"===z&&(C*=-1),A=!0;"."===a.charAt(14)&&(v=1E3*parseFloat(a.substr(14),
10));A?(c.setUTCFullYear(b,d,l),c.setUTCHours(e,k,f,v),c.setTime(+c+C)):(c.setFullYear(b,d,l),c.setHours(e,k,f,v));return c};b.dateToUtcTime=function(a){if("string"===typeof a)return a;var c="",b=[];b.push((""+a.getUTCFullYear()).substr(2));b.push(""+(a.getUTCMonth()+1));b.push(""+a.getUTCDate());b.push(""+a.getUTCHours());b.push(""+a.getUTCMinutes());b.push(""+a.getUTCSeconds());for(a=0;a<b.length;++a)2>b[a].length&&(c+="0"),c+=b[a];return c+"Z"};b.dateToGeneralizedTime=function(a){if("string"===
2018-08-24 02:55:06 +03:00
typeof a)return a;var c="",b=[];b.push(""+a.getUTCFullYear());b.push(""+(a.getUTCMonth()+1));b.push(""+a.getUTCDate());b.push(""+a.getUTCHours());b.push(""+a.getUTCMinutes());b.push(""+a.getUTCSeconds());for(a=0;a<b.length;++a)2>b[a].length&&(c+="0"),c+=b[a];return c+"Z"};b.integerToDer=function(a){var b=c.util.createBuffer();if(-128<=a&&128>a)return b.putSignedInt(a,8);if(-32768<=a&&32768>a)return b.putSignedInt(a,16);if(-8388608<=a&&8388608>a)return b.putSignedInt(a,24);if(-2147483648<=a&&2147483648>
a)return b.putSignedInt(a,32);b=Error("Integer too large; max is 32-bits.");b.integer=a;throw b;};b.derToInteger=function(a){"string"===typeof a&&(a=c.util.createBuffer(a));var b=8*a.length();if(32<b)throw Error("Integer too large; max is 32-bits.");return a.getSignedInt(b)};b.validate=function(a,d,h,g){var e=!1;if(a.tagClass!==d.tagClass&&"undefined"!==typeof d.tagClass||a.type!==d.type&&"undefined"!==typeof d.type)g&&(a.tagClass!==d.tagClass&&g.push("["+d.name+'] Expected tag class "'+d.tagClass+
'", got "'+a.tagClass+'"'),a.type!==d.type&&g.push("["+d.name+'] Expected type "'+d.type+'", got "'+a.type+'"'));else if(a.constructed===d.constructed||"undefined"===typeof d.constructed){e=!0;if(d.value&&c.util.isArray(d.value))for(var m=0,f=0;e&&f<d.value.length;++f)e=d.value[f].optional||!1,a.value[m]&&((e=b.validate(a.value[m],d.value[f],h,g))?++m:d.value[f].optional&&(e=!0)),!e&&g&&g.push("["+d.name+'] Tag class "'+d.tagClass+'", type "'+d.type+'" expected value length "'+d.value.length+'", got "'+
a.value.length+'"');e&&h&&(d.capture&&(h[d.capture]=a.value),d.captureAsn1&&(h[d.captureAsn1]=a))}else g&&g.push("["+d.name+'] Expected constructed "'+d.constructed+'", got "'+a.constructed+'"');return e};var e=/[^\\u0000-\\u00ff]/;b.prettyPrint=function(a,d,h){var g="";d=d||0;h=h||2;0<d&&(g+="\n");for(var f="",m=0;m<d*h;++m)f+=" ";g+=f+"Tag: ";switch(a.tagClass){case b.Class.UNIVERSAL:g+="Universal:";break;case b.Class.APPLICATION:g+="Application:";break;case b.Class.CONTEXT_SPECIFIC:g+="Context-Specific:";
break;case b.Class.PRIVATE:g+="Private:"}if(a.tagClass===b.Class.UNIVERSAL)switch(g+=a.type,a.type){case b.Type.NONE:g+=" (None)";break;case b.Type.BOOLEAN:g+=" (Boolean)";break;case b.Type.BITSTRING:g+=" (Bit string)";break;case b.Type.INTEGER:g+=" (Integer)";break;case b.Type.OCTETSTRING:g+=" (Octet string)";break;case b.Type.NULL:g+=" (Null)";break;case b.Type.OID:g+=" (Object Identifier)";break;case b.Type.ODESC:g+=" (Object Descriptor)";break;case b.Type.EXTERNAL:g+=" (External or Instance of)";
break;case b.Type.REAL:g+=" (Real)";break;case b.Type.ENUMERATED:g+=" (Enumerated)";break;case b.Type.EMBEDDED:g+=" (Embedded PDV)";break;case b.Type.UTF8:g+=" (UTF8)";break;case b.Type.ROID:g+=" (Relative Object Identifier)";break;case b.Type.SEQUENCE:g+=" (Sequence)";break;case b.Type.SET:g+=" (Set)";break;case b.Type.PRINTABLESTRING:g+=" (Printable String)";break;case b.Type.IA5String:g+=" (IA5String (ASCII))";break;case b.Type.UTCTIME:g+=" (UTC time)";break;case b.Type.GENERALIZEDTIME:g+=" (Generalized time)";
2018-11-15 02:44:28 +03:00
break;case b.Type.BMPSTRING:g+=" (BMP String)"}else g+=a.type;g=g+"\n"+(f+"Constructed: "+a.constructed+"\n");if(a.composed){for(var v=0,w="",m=0;m<a.value.length;++m)void 0!==a.value[m]&&(v+=1,w+=b.prettyPrint(a.value[m],d+1,h),m+1<a.value.length&&(w+=","));g+=f+"Sub values: "+v+w}else if(g+=f+"Value: ",a.type===b.Type.OID&&(d=b.derToOid(a.value),g+=d,c.pki&&c.pki.oids&&d in c.pki.oids&&(g+=" ("+c.pki.oids[d]+") ")),a.type===b.Type.INTEGER)try{g+=b.derToInteger(a.value)}catch(y){g+="0x"+c.util.bytesToHex(a.value)}else a.type===
2018-08-24 02:55:06 +03:00
b.Type.OCTETSTRING?(e.test(a.value)||(g+="("+a.value+") "),g+="0x"+c.util.bytesToHex(a.value)):g=a.type===b.Type.UTF8?g+c.util.decodeUtf8(a.value):a.type===b.Type.PRINTABLESTRING||a.type===b.Type.IA5String?g+a.value:e.test(a.value)?g+("0x"+c.util.bytesToHex(a.value)):0===a.value.length?g+"[null]":g+a.value;return g}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,
b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.asn1)return b.asn1;b.defined.asn1=!0;for(var k=0;k<e.length;++k)e[k](b);return b.asn1}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/asn1",["require","module","./util","./oids"],function(){p.apply(null,Array.prototype.slice.call(arguments,
0))})})();(function(){function a(c){function b(){f=String.fromCharCode(128);f+=c.util.fillString(String.fromCharCode(0),64);B=[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];h=[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];g=Array(64);for(var a=0;64>a;++a)g[a]=Math.floor(4294967296*
2018-11-15 02:44:28 +03:00
Math.abs(Math.sin(a+1)));E=!0}function d(a,c,b){for(var l,e,k,f,z,D,x,v=b.length();64<=v;){e=a.h0;k=a.h1;f=a.h2;z=a.h3;for(x=0;16>x;++x)c[x]=b.getInt32Le(),l=z^k&(f^z),l=e+l+g[x]+c[x],D=h[x],e=z,z=f,f=k,k+=l<<D|l>>>32-D;for(;32>x;++x)l=f^z&(k^f),l=e+l+g[x]+c[B[x]],D=h[x],e=z,z=f,f=k,k+=l<<D|l>>>32-D;for(;48>x;++x)l=k^f^z,l=e+l+g[x]+c[B[x]],D=h[x],e=z,z=f,f=k,k+=l<<D|l>>>32-D;for(;64>x;++x)l=f^(k|~z),l=e+l+g[x]+c[B[x]],D=h[x],e=z,z=f,f=k,k+=l<<D|l>>>32-D;a.h0=a.h0+e|0;a.h1=a.h1+k|0;a.h2=a.h2+f|0;a.h3=
a.h3+z|0;v-=64}}var e=c.md5=c.md5||{};c.md=c.md||{};c.md.algorithms=c.md.algorithms||{};c.md.md5=c.md.algorithms.md5=e;e.create=function(){E||b();var a=null,h=c.util.createBuffer(),g=Array(16),e={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){e.messageLength=0;e.fullMessageLength=e.messageLength64=[];for(var b=e.messageLengthSize/4,d=0;d<b;++d)e.fullMessageLength.push(0);h=c.util.createBuffer();a={h0:1732584193,h1:4023233417,
h2:2562383102,h3:271733878};return e}};e.start();e.update=function(b,k){"utf8"===k&&(b=c.util.encodeUtf8(b));var f=b.length;e.messageLength+=f;for(var f=[f/4294967296>>>0,f>>>0],z=e.fullMessageLength.length-1;0<=z;--z)e.fullMessageLength[z]+=f[1],f[1]=f[0]+(e.fullMessageLength[z]/4294967296>>>0),e.fullMessageLength[z]>>>=0,f[0]=f[1]/4294967296>>>0;h.putBytes(b);d(a,g,h);(2048<h.read||0===h.length())&&h.compact();return e};e.digest=function(){var b=c.util.createBuffer();b.putBytes(h.bytes());b.putBytes(f.substr(0,
e.blockLength-(e.fullMessageLength[e.fullMessageLength.length-1]+e.messageLengthSize&e.blockLength-1)));for(var k,E=0,z=e.fullMessageLength.length-1;0<=z;--z)k=8*e.fullMessageLength[z]+E,E=k/4294967296>>>0,b.putInt32Le(k>>>0);k={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3};d(k,g,b);b=c.util.createBuffer();b.putInt32Le(k.h0);b.putInt32Le(k.h1);b.putInt32Le(k.h2);b.putInt32Le(k.h3);return b};return e};var f=null,B=null,h=null,g=null,E=!1}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=
2018-08-24 02:55:06 +03:00
!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.md5)return b.md5;b.defined.md5=!0;for(var k=0;k<e.length;++k)e[k](b);return b.md5}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,
2018-11-15 02:44:28 +03:00
0))};c("js/md5",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,d){for(var l,e,k,f,v,u,A,n,z=d.length();64<=z;){e=a.h0;k=a.h1;f=a.h2;v=a.h3;u=a.h4;for(n=0;16>n;++n)l=d.getInt32(),c[n]=l,A=v^k&(f^v),l=(e<<5|e>>>27)+A+u+1518500249+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;for(;20>n;++n)l=c[n-3]^c[n-8]^c[n-14]^c[n-16],l=l<<1|l>>>31,c[n]=l,A=v^k&(f^v),l=(e<<5|e>>>27)+A+u+1518500249+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;for(;32>
2018-10-03 22:03:09 +03:00
n;++n)l=c[n-3]^c[n-8]^c[n-14]^c[n-16],l=l<<1|l>>>31,c[n]=l,A=k^f^v,l=(e<<5|e>>>27)+A+u+1859775393+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;for(;40>n;++n)l=c[n-6]^c[n-16]^c[n-28]^c[n-32],l=l<<2|l>>>30,c[n]=l,A=k^f^v,l=(e<<5|e>>>27)+A+u+1859775393+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;for(;60>n;++n)l=c[n-6]^c[n-16]^c[n-28]^c[n-32],l=l<<2|l>>>30,c[n]=l,A=k&f|v&(k^f),l=(e<<5|e>>>27)+A+u+2400959708+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;for(;80>n;++n)l=c[n-6]^c[n-16]^c[n-28]^c[n-32],l=l<<2|l>>>30,c[n]=l,A=k^f^v,l=(e<<5|e>>>
2018-11-15 02:44:28 +03:00
27)+A+u+3395469782+l,u=v,v=f,f=k<<30|k>>>2,k=e,e=l;a.h0=a.h0+e|0;a.h1=a.h1+k|0;a.h2=a.h2+f|0;a.h3=a.h3+v|0;a.h4=a.h4+u|0;z-=64}}var d=c.sha1=c.sha1||{};c.md=c.md||{};c.md.algorithms=c.md.algorithms||{};c.md.sha1=c.md.algorithms.sha1=d;d.create=function(){f||(e=String.fromCharCode(128),e+=c.util.fillString(String.fromCharCode(0),64),f=!0);var a=null,d=c.util.createBuffer(),g=Array(80),v={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){v.messageLength=
0;v.fullMessageLength=v.messageLength64=[];for(var b=v.messageLengthSize/4,g=0;g<b;++g)v.fullMessageLength.push(0);d=c.util.createBuffer();a={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return v}};v.start();v.update=function(e,f){"utf8"===f&&(e=c.util.encodeUtf8(e));var u=e.length;v.messageLength+=u;for(var u=[u/4294967296>>>0,u>>>0],y=v.fullMessageLength.length-1;0<=y;--y)v.fullMessageLength[y]+=u[1],u[1]=u[0]+(v.fullMessageLength[y]/4294967296>>>0),v.fullMessageLength[y]>>>=
0,u[0]=u[1]/4294967296>>>0;d.putBytes(e);b(a,g,d);(2048<d.read||0===d.length())&&d.compact();return v};v.digest=function(){var m=c.util.createBuffer();m.putBytes(d.bytes());m.putBytes(e.substr(0,v.blockLength-(v.fullMessageLength[v.fullMessageLength.length-1]+v.messageLengthSize&v.blockLength-1)));c.util.createBuffer();for(var f,u,y=8*v.fullMessageLength[0],C=0;C<v.fullMessageLength.length;++C)f=8*v.fullMessageLength[C+1],u=f/4294967296>>>0,y+=u,m.putInt32(y>>>0),y=f;f={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3,
2018-10-03 22:03:09 +03:00
h4:a.h4};b(f,g,m);m=c.util.createBuffer();m.putInt32(f.h0);m.putInt32(f.h1);m.putInt32(f.h2);m.putInt32(f.h3);m.putInt32(f.h4);return m};return v};var e=null,f=!1}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.sha1)return b.sha1;b.defined.sha1=
2018-11-15 02:44:28 +03:00
!0;for(var k=0;k<e.length;++k)e[k](b);return b.sha1}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/sha1",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,d){for(var l,e,k,f,v,u,L,z,D,x,G,p,q,r=d.length();64<=r;){for(v=0;16>v;++v)c[v]=d.getInt32();
for(;64>v;++v)l=c[v-2],l=(l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10,e=c[v-15],e=(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3,c[v]=l+c[v-7]+e+c[v-16]|0;u=a.h0;L=a.h1;z=a.h2;D=a.h3;x=a.h4;G=a.h5;p=a.h6;q=a.h7;for(v=0;64>v;++v)l=(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7),k=p^x&(G^p),e=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),f=u&L|z&(u^L),l=q+l+k+n[v]+c[v],e+=f,q=p,p=G,G=x,x=D+l|0,D=z,z=L,L=u,u=l+e|0;a.h0=a.h0+u|0;a.h1=a.h1+L|0;a.h2=a.h2+z|0;a.h3=a.h3+D|0;a.h4=a.h4+x|0;a.h5=a.h5+G|0;a.h6=a.h6+p|0;a.h7=a.h7+q|0;r-=
2018-08-24 02:55:06 +03:00
64}}var d=c.sha256=c.sha256||{};c.md=c.md||{};c.md.algorithms=c.md.algorithms||{};c.md.sha256=c.md.algorithms.sha256=d;d.create=function(){f||(e=String.fromCharCode(128),e+=c.util.fillString(String.fromCharCode(0),64),n=[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,
2018-10-03 22:03:09 +03:00
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],f=!0);var a=null,d=c.util.createBuffer(),v=Array(64),m={algorithm:"sha256",blockLength:64,digestLength:32,
2018-11-15 02:44:28 +03:00
messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){m.messageLength=0;m.fullMessageLength=m.messageLength64=[];for(var b=m.messageLengthSize/4,e=0;e<b;++e)m.fullMessageLength.push(0);d=c.util.createBuffer();a={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225};return m}};m.start();m.update=function(e,f){"utf8"===f&&(e=c.util.encodeUtf8(e));var u=e.length;m.messageLength+=u;for(var u=[u/4294967296>>>0,u>>>0],C=m.fullMessageLength.length-
1;0<=C;--C)m.fullMessageLength[C]+=u[1],u[1]=u[0]+(m.fullMessageLength[C]/4294967296>>>0),m.fullMessageLength[C]>>>=0,u[0]=u[1]/4294967296>>>0;d.putBytes(e);b(a,v,d);(2048<d.read||0===d.length())&&d.compact();return m};m.digest=function(){var f=c.util.createBuffer();f.putBytes(d.bytes());f.putBytes(e.substr(0,m.blockLength-(m.fullMessageLength[m.fullMessageLength.length-1]+m.messageLengthSize&m.blockLength-1)));c.util.createBuffer();for(var u,y,C=8*m.fullMessageLength[0],n=0;n<m.fullMessageLength.length;++n)u=
8*m.fullMessageLength[n+1],y=u/4294967296>>>0,C+=y,f.putInt32(C>>>0),C=u;u={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4,h5:a.h5,h6:a.h6,h7:a.h7};b(u,v,f);f=c.util.createBuffer();f.putInt32(u.h0);f.putInt32(u.h1);f.putInt32(u.h2);f.putInt32(u.h3);f.putInt32(u.h4);f.putInt32(u.h5);f.putInt32(u.h6);f.putInt32(u.h7);return f};return m};var e=null,f=!1,n=null}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge=
2018-08-24 02:55:06 +03:00
{}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.sha256)return b.sha256;b.defined.sha256=!0;for(var k=0;k<e.length;++k)e[k](b);return b.sha256}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/sha256",["require","module","./util"],function(){p.apply(null,
2018-11-15 02:44:28 +03:00
Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,d){for(var l,e,g,k,f,z,D,x,u,v,q,n,B,J,P,K,p,r,T,S,V,R,I,H,N,Y=d.length();128<=Y;){for(N=0;16>N;++N)c[N][0]=d.getInt32()>>>0,c[N][1]=d.getInt32()>>>0;for(;80>N;++N)f=c[N-2],u=f[0],f=f[1],l=((u>>>19|f<<13)^(f>>>29|u<<3)^u>>>6)>>>0,e=((u<<13|f>>>19)^(f<<3|u>>>29)^(u<<26|f>>>6))>>>0,f=c[N-15],u=f[0],f=f[1],g=((u>>>1|f<<31)^(u>>>8|f<<24)^u>>>7)>>>0,k=((u<<31|f>>>1)^(u<<24|f>>>8)^(u<<25|f>>>7))>>>0,u=c[N-7],v=c[N-16],
f=e+u[1]+k+v[1],c[N][0]=l+u[0]+g+v[0]+(f/4294967296>>>0)>>>0,c[N][1]=f>>>0;u=a[0][0];v=a[0][1];q=a[1][0];n=a[1][1];B=a[2][0];J=a[2][1];P=a[3][0];K=a[3][1];p=a[4][0];r=a[4][1];T=a[5][0];S=a[5][1];V=a[6][0];R=a[6][1];I=a[7][0];H=a[7][1];for(N=0;80>N;++N)l=((p>>>14|r<<18)^(p>>>18|r<<14)^(r>>>9|p<<23))>>>0,f=((p<<18|r>>>14)^(p<<14|r>>>18)^(r<<23|p>>>9))>>>0,e=(V^p&(T^V))>>>0,z=(R^r&(S^R))>>>0,g=((u>>>28|v<<4)^(v>>>2|u<<30)^(v>>>7|u<<25))>>>0,k=((u<<4|v>>>28)^(v<<30|u>>>2)^(v<<25|u>>>7))>>>0,D=(u&q|B&
(u^q))>>>0,x=(v&n|J&(v^n))>>>0,f=H+f+z+h[N][1]+c[N][1],l=I+l+e+h[N][0]+c[N][0]+(f/4294967296>>>0)>>>0,e=f>>>0,f=k+x,g=g+D+(f/4294967296>>>0)>>>0,k=f>>>0,I=V,H=R,V=T,R=S,T=p,S=r,f=K+e,p=P+l+(f/4294967296>>>0)>>>0,r=f>>>0,P=B,K=J,B=q,J=n,q=u,n=v,f=e+k,u=l+g+(f/4294967296>>>0)>>>0,v=f>>>0;f=a[0][1]+v;a[0][0]=a[0][0]+u+(f/4294967296>>>0)>>>0;a[0][1]=f>>>0;f=a[1][1]+n;a[1][0]=a[1][0]+q+(f/4294967296>>>0)>>>0;a[1][1]=f>>>0;f=a[2][1]+J;a[2][0]=a[2][0]+B+(f/4294967296>>>0)>>>0;a[2][1]=f>>>0;f=a[3][1]+K;a[3][0]=
2018-10-03 22:03:09 +03:00
a[3][0]+P+(f/4294967296>>>0)>>>0;a[3][1]=f>>>0;f=a[4][1]+r;a[4][0]=a[4][0]+p+(f/4294967296>>>0)>>>0;a[4][1]=f>>>0;f=a[5][1]+S;a[5][0]=a[5][0]+T+(f/4294967296>>>0)>>>0;a[5][1]=f>>>0;f=a[6][1]+R;a[6][0]=a[6][0]+V+(f/4294967296>>>0)>>>0;a[6][1]=f>>>0;f=a[7][1]+H;a[7][0]=a[7][0]+I+(f/4294967296>>>0)>>>0;a[7][1]=f>>>0;Y-=128}}var d=c.sha512=c.sha512||{};c.md=c.md||{};c.md.algorithms=c.md.algorithms||{};c.md.sha512=c.md.algorithms.sha512=d;var e=c.sha384=c.sha512.sha384=c.sha512.sha384||{};e.create=function(){return d.create("SHA-384")};
2018-08-24 02:55:06 +03:00
c.md.sha384=c.md.algorithms.sha384=e;c.sha512.sha256=c.sha512.sha256||{create:function(){return d.create("SHA-512/256")}};c.md["sha512/256"]=c.md.algorithms["sha512/256"]=c.sha512.sha256;c.sha512.sha224=c.sha512.sha224||{create:function(){return d.create("SHA-512/224")}};c.md["sha512/224"]=c.md.algorithms["sha512/224"]=c.sha512.sha224;d.create=function(a){n||(f=String.fromCharCode(128),f+=c.util.fillString(String.fromCharCode(0),128),h=[[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]],g={"SHA-512":[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],"SHA-384":[[3418070365,
3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],"SHA-512/256":[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],"SHA-512/224":[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],
2018-11-15 02:44:28 +03:00
[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]]},n=!0);"undefined"===typeof a&&(a="SHA-512");if(!(a in g))throw Error("Invalid SHA-512 algorithm: "+a);for(var d=g[a],e=null,v=c.util.createBuffer(),y=Array(80),C=0;80>C;++C)y[C]=Array(2);var A={algorithm:a.replace("-","").toLowerCase(),blockLength:128,digestLength:64,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){A.messageLength=0;A.fullMessageLength=A.messageLength128=[];for(var a=A.messageLengthSize/
4,b=0;b<a;++b)A.fullMessageLength.push(0);v=c.util.createBuffer();e=Array(d.length);for(b=0;b<d.length;++b)e[b]=d[b].slice(0);return A}};A.start();A.update=function(a,d){"utf8"===d&&(a=c.util.encodeUtf8(a));var g=a.length;A.messageLength+=g;for(var g=[g/4294967296>>>0,g>>>0],h=A.fullMessageLength.length-1;0<=h;--h)A.fullMessageLength[h]+=g[1],g[1]=g[0]+(A.fullMessageLength[h]/4294967296>>>0),A.fullMessageLength[h]>>>=0,g[0]=g[1]/4294967296>>>0;v.putBytes(a);b(e,y,v);(2048<v.read||0===v.length())&&
v.compact();return A};A.digest=function(){var d=c.util.createBuffer();d.putBytes(v.bytes());d.putBytes(f.substr(0,A.blockLength-(A.fullMessageLength[A.fullMessageLength.length-1]+A.messageLengthSize&A.blockLength-1)));c.util.createBuffer();for(var g,h,m=8*A.fullMessageLength[0],G=0;G<A.fullMessageLength.length;++G)g=8*A.fullMessageLength[G+1],h=g/4294967296>>>0,m+=h,d.putInt32(m>>>0),m=g;g=Array(e.length);for(G=0;G<e.length;++G)g[G]=e[G].slice(0);b(g,y,d);d=c.util.createBuffer();h="SHA-512"===a?g.length:
2018-08-24 02:55:06 +03:00
"SHA-384"===a?g.length-2:g.length-4;for(G=0;G<h;++G)d.putInt32(g[G][0]),G===h-1&&"SHA-512/224"===a||d.putInt32(g[G][1]);return d};return A};var f=null,n=!1,h=null,g=null}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.sha512)return b.sha512;b.defined.sha512=
!0;for(var k=0;k<e.length;++k)e[k](b);return b.sha512}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/sha512",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.md=c.md||{};c.md.algorithms={md5:c.md5,sha1:c.sha1,sha256:c.sha256};c.md.md5=c.md5;c.md.sha1=c.sha1;
c.md.sha256=c.sha256}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.md)return b.md;b.defined.md=!0;for(var k=0;k<e.length;++k)e[k](b);return b.md}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,
Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/md","require module ./md5 ./sha1 ./sha256 ./sha512".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){(c.hmac=c.hmac||{}).create=function(){var a=null,b=null,d=null,f={start:function(f,h){if(null!==f)if("string"===typeof f)if(f=f.toLowerCase(),f in c.md.algorithms)a=c.md.algorithms[f].create();else throw Error('Unknown hash algorithm "'+
2018-10-03 22:03:09 +03:00
f+'"');else a=f;if(null!==h){if("string"===typeof h)h=c.util.createBuffer(h);else if(c.util.isArray(h)){var g=h;h=c.util.createBuffer();for(var u=0;u<g.length;++u)h.putByte(g[u])}var m=h.length();m>a.blockLength&&(a.start(),a.update(h.bytes()),h=a.digest());b=c.util.createBuffer();d=c.util.createBuffer();m=h.length();for(u=0;u<m;++u)g=h.at(u),b.putByte(54^g),d.putByte(92^g);if(m<a.blockLength)for(g=a.blockLength-m,u=0;u<g;++u)b.putByte(54),d.putByte(92);b=b.bytes();d=d.bytes()}a.start();a.update(b)},
2018-08-24 02:55:06 +03:00
update:function(c){a.update(c)},getMac:function(){var c=a.digest().bytes();a.start();a.update(d);a.update(c);return a.digest()}};f.digest=f.getMac;return f}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.hmac)return b.hmac;b.defined.hmac=!0;for(var k=
0;k<e.length;++k)e[k](b);return b.hmac}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/hmac",["require","module","./md","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a){for(var c=a.name+": ",d=[],l=function(a,c){return" "+c},g=0;g<a.values.length;++g)d.push(a.values[g].replace(/^(\S+\r\n)/,
l));c+=d.join(",")+"\r\n";d=0;a=-1;for(g=0;g<c.length;++g,++d)if(65<d&&-1!==a)d=c[a],","===d?(++a,c=c.substr(0,a)+"\r\n "+c.substr(a)):c=c.substr(0,a)+"\r\n"+d+c.substr(a+1),d=g-a-1,a=-1,++g;else if(" "===c[g]||"\t"===c[g]||","===c[g])a=g;return c}var d=c.pem=c.pem||{};d.encode=function(a,d){d=d||{};var f="-----BEGIN "+a.type+"-----\r\n",h;a.procType&&(h={name:"Proc-Type",values:[String(a.procType.version),a.procType.type]},f+=b(h));a.contentDomain&&(h={name:"Content-Domain",values:[a.contentDomain]},
f+=b(h));a.dekInfo&&(h={name:"DEK-Info",values:[a.dekInfo.algorithm]},a.dekInfo.parameters&&h.values.push(a.dekInfo.parameters),f+=b(h));if(a.headers)for(h=0;h<a.headers.length;++h)f+=b(a.headers[h]);a.procType&&(f+="\r\n");f+=c.util.encode64(a.body,d.maxline||64)+"\r\n";return f+="-----END "+a.type+"-----\r\n"};d.decode=function(a){for(var b=[],d=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,h=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,
2018-11-15 02:44:28 +03:00
g=/\r?\n/,k;;){k=d.exec(a);if(!k)break;var f={type:k[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:c.util.decode64(k[3])};b.push(f);if(k[2]){for(var v=k[2].split(g),w=0;k&&w<v.length;){k=v[w].replace(/\s+$/,"");for(var y=w+1;y<v.length;++y){var n=v[y];if(!/\s/.test(n[0]))break;k+=n;w=y}if(k=k.match(h)){for(var y={name:k[1],values:[]},n=k[2].split(","),A=0;A<n.length;++A)y.values.push(n[A].replace(/^\s+/,""));if(f.procType)if(f.contentDomain||"Content-Domain"!==y.name)if(f.dekInfo||
"DEK-Info"!==y.name)f.headers.push(y);else{if(0===y.values.length)throw Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');f.dekInfo={algorithm:n[0],parameters:n[1]||null}}else f.contentDomain=n[0]||"";else{if("Proc-Type"!==y.name)throw Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==y.values.length)throw Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');f.procType={version:n[0],
type:n[1]}}}++w}if("ENCRYPTED"===f.procType&&!f.dekInfo)throw Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".');}}if(0===b.length)throw Error("Invalid PEM formatted message.");return b}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);
2018-08-24 02:55:06 +03:00
b=b||{};b.defined=b.defined||{};if(b.defined.pem)return b.pem;b.defined.pem=!0;for(var k=0;k<e.length;++k)e[k](b);return b.pem}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pem",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,d){c.cipher.registerAlgorithm(a,
2018-11-15 02:44:28 +03:00
function(){return new c.des.Algorithm(a,d)})}function d(a,c,b,l){var e=32===a.length?3:9;l=3===e?l?[30,-2,-2]:[0,32,2]:l?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var k=c[0],x=c[1];c=(k>>>4^x)&252645135;x^=c;k^=c<<4;c=(k>>>16^x)&65535;x^=c;k^=c<<16;c=(x>>>2^k)&858993459;k^=c;x^=c<<2;c=(x>>>8^k)&16711935;k^=c;x^=c<<8;c=(k>>>1^x)&1431655765;for(var x=x^c,k=k^c<<1,k=k<<1|k>>>31,x=x<<1|x>>>31,v=0;v<e;v+=3){for(var p=l[v+1],q=l[v+2],r=l[v];r!=p;r+=q){var M=x^a[r],J=(x>>>4|x<<28)^a[r+1];c=k;
k=x;x=c^(n[M>>>24&63]|g[M>>>16&63]|m[M>>>8&63]|w[M&63]|f[J>>>24&63]|h[J>>>16&63]|E[J>>>8&63]|F[J&63])}c=k;k=x;x=c}k=k>>>1|k<<31;x=x>>>1|x<<31;c=(k>>>1^x)&1431655765;x^=c;k^=c<<1;c=(x>>>8^k)&16711935;k^=c;x^=c<<8;c=(x>>>2^k)&858993459;k^=c;x^=c<<2;c=(k>>>16^x)&65535;x^=c;k^=c<<16;c=(k>>>4^x)&252645135;b[0]=k^c<<4;b[1]=x^c}function e(a){a=a||{};var b="DES-"+(a.mode||"CBC").toUpperCase(),d;d=a.decrypt?c.cipher.createDecipher(b,a.key):c.cipher.createCipher(b,a.key);var g=d.start;d.start=function(a,b){var e=
2018-08-24 02:55:06 +03:00
null;b instanceof c.util.ByteBuffer&&(e=b,b={});b=b||{};b.output=e;b.iv=a;g.call(d,b)};return d}c.des=c.des||{};c.des.startEncrypting=function(a,c,b,d){a=e({key:a,output:b,decrypt:!1,mode:d||(null===c?"ECB":"CBC")});a.start(c);return a};c.des.createEncryptionCipher=function(a,c){return e({key:a,output:null,decrypt:!1,mode:c})};c.des.startDecrypting=function(a,c,b,d){a=e({key:a,output:b,decrypt:!0,mode:d||(null===c?"ECB":"CBC")});a.start(c);return a};c.des.createDecryptionCipher=function(a,c){return e({key:a,
output:null,decrypt:!0,mode:c})};c.des.Algorithm=function(a,c){var b=this;b.name=a;b.mode=new c({blockSize:8,cipher:{encrypt:function(a,c){return d(b._keys,a,c,!1)},decrypt:function(a,c){return d(b._keys,a,c,!0)}}});b._init=!1};c.des.Algorithm.prototype.initialize=function(a){if(!this._init){a=c.util.createBuffer(a.key);if(0===this.name.indexOf("3DES")&&24!==a.length())throw Error("Invalid Triple-DES key size: "+8*a.length());for(var b=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,
516,536871424,536871428,66048,66052,536936960,536936964],d=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],g=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],e=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],h=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],
k=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],f=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],m=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],q=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[0,268435456,8,268435464,0,268435456,
2018-11-15 02:44:28 +03:00
8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],v=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],J=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],w=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],n=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],E=8<a.length()?3:
1,F=[],B=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],p=0,r,R=0;R<E;R++){var I=a.getInt32(),H=a.getInt32();r=(I>>>4^H)&252645135;H^=r;I^=r<<4;r=(H>>>-16^I)&65535;I^=r;H^=r<<-16;r=(I>>>2^H)&858993459;H^=r;I^=r<<2;r=(H>>>-16^I)&65535;I^=r;H^=r<<-16;r=(I>>>1^H)&1431655765;H^=r;I^=r<<1;r=(H>>>8^I)&16711935;I^=r;H^=r<<8;r=(I>>>1^H)&1431655765;H^=r;I^=r<<1;r=I<<8|H>>>20&240;for(var I=H<<24|H<<8&16711680|H>>>8&65280|H>>>24&240,H=r,N=0;N<B.length;++N){B[N]?(I=I<<2|I>>>26,H=H<<2|H>>>26):(I=I<<1|I>>>27,H=H<<1|H>>>27);
var I=I&-15,H=H&-15,Y=b[I>>>28]|d[I>>>24&15]|g[I>>>20&15]|e[I>>>16&15]|h[I>>>12&15]|k[I>>>8&15]|f[I>>>4&15],Z=m[H>>>28]|q[H>>>24&15]|u[H>>>20&15]|v[H>>>16&15]|J[H>>>12&15]|w[H>>>8&15]|n[H>>>4&15];r=(Z>>>16^Y)&65535;F[p++]=Y^r;F[p++]=Z^r<<16}}this._keys=F;this._init=!0}};b("DES-ECB",c.cipher.modes.ecb);b("DES-CBC",c.cipher.modes.cbc);b("DES-CFB",c.cipher.modes.cfb);b("DES-OFB",c.cipher.modes.ofb);b("DES-CTR",c.cipher.modes.ctr);b("3DES-ECB",c.cipher.modes.ecb);b("3DES-CBC",c.cipher.modes.cbc);b("3DES-CFB",
2018-08-24 02:55:06 +03:00
c.cipher.modes.cfb);b("3DES-OFB",c.cipher.modes.ofb);b("3DES-CTR",c.cipher.modes.ctr);var f=[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],n=[-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],h=[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,
2018-11-15 02:44:28 +03:00
8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],g=[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],E=[256,34078976,34078720,1107296512,
2018-08-24 02:55:06 +03:00
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],m=[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,
2018-11-15 02:44:28 +03:00
4194320,536887312,0,541081600,536870912,4194320,536887312],F=[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],w=[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,
2018-08-24 02:55:06 +03:00
268435456,268701696]}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.des)return b.des;b.defined.des=!0;for(var k=0;k<e.length;++k)e[k](b);return b.des}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,
2018-11-15 02:44:28 +03:00
Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/des",["require","module","./cipher","./cipherModes","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var d=c.pkcs5=c.pkcs5||{},f="undefined"!==typeof process&&process.versions&&process.versions.node,e;f&&!c.disableNativeCode&&(e=b("crypto"));c.pbkdf2=d.pbkdf2=function(a,b,d,g,k,m){function n(){if(r>C)return m(null,z);p.start(null,
null);p.update(b);p.update(c.util.int32ToBytes(r));D=G=p.digest().getBytes();q=2;w()}function w(){if(q<=d)return p.start(null,null),p.update(G),x=p.digest().getBytes(),D=c.util.xorBytes(D,x,y),G=x,++q,c.util.setImmediate(w);z+=r<C?D:D.substr(0,A);++r;n()}"function"===typeof k&&(m=k,k=null);if(f&&!c.disableNativeCode&&e.pbkdf2&&(null===k||"object"!==typeof k)&&(4<e.pbkdf2Sync.length||!k||"sha1"===k))return"string"!==typeof k&&(k="sha1"),b=new Buffer(b,"binary"),m?4===e.pbkdf2Sync.length?e.pbkdf2(a,
b,d,g,function(a,c){if(a)return m(a);m(null,c.toString("binary"))}):e.pbkdf2(a,b,d,g,k,function(a,c){if(a)return m(a);m(null,c.toString("binary"))}):4===e.pbkdf2Sync.length?e.pbkdf2Sync(a,b,d,g).toString("binary"):e.pbkdf2Sync(a,b,d,g,k).toString("binary");if("undefined"===typeof k||null===k)k=c.md.sha1.create();if("string"===typeof k){if(!(k in c.md.algorithms))throw Error("Unknown hash algorithm: "+k);k=c.md[k].create()}var y=k.digestLength;if(g>4294967295*y){a=Error("Derived key is too long.");
if(m)return m(a);throw a;}var C=Math.ceil(g/y),A=g-(C-1)*y,p=c.hmac.create();p.start(k,a);var z="",D,x,G;if(!m){for(var r=1;r<=C;++r){p.start(null,null);p.update(b);p.update(c.util.int32ToBytes(r));D=G=p.digest().getBytes();for(var q=2;q<=d;++q)p.start(null,null),p.update(G),x=p.digest().getBytes(),D=c.util.xorBytes(D,x,y),G=x;z+=r<C?D:D.substr(0,A)}return z}r=1;n()}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===
2018-08-24 02:55:06 +03:00
typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pbkdf2)return b.pbkdf2;b.defined.pbkdf2=!0;for(var k=0;k<e.length;++k)e[k](b);return b.pbkdf2}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pbkdf2",["require","module",
"./hmac","./md","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var d="undefined"!==typeof process&&process.versions&&process.versions.node,f=null;c.disableNativeCode||!d||process.versions["node-webkit"]||(f=b("crypto"));(c.prng=c.prng||{}).create=function(a){function b(a){if(32<=g.pools[0].messageLength)return d(),a();g.seedFile(32-g.pools[0].messageLength<<5,function(c,b){if(c)return a(c);g.collect(b);d();a()})}function d(){var a=g.plugin.md.create();
a.update(g.pools[0].digest().getBytes());g.pools[0].start();for(var c=1,b=1;32>b;++b)c=31===c?2147483648:c<<2,0===c%g.reseeds&&(a.update(g.pools[b].digest().getBytes()),g.pools[b].start());c=a.digest().getBytes();a.start();a.update(c);a=a.digest().getBytes();g.key=g.plugin.formatKey(c);g.seed=g.plugin.formatSeed(a);g.reseeds=4294967295===g.reseeds?0:g.reseeds+1;g.generated=0}function h(a){var b=null;if("undefined"!==typeof window){var d=window.crypto||window.msCrypto;d&&d.getRandomValues&&(b=function(a){return d.getRandomValues(a)})}var g=
c.util.createBuffer();if(b)for(;g.length()<a;){var e=Math.max(1,Math.min(a-g.length(),65536)/4),h=new Uint32Array(Math.floor(e));try{for(b(h),e=0;e<h.length;++e)g.putInt32(h[e])}catch(k){if(!("undefined"!==typeof QuotaExceededError&&k instanceof QuotaExceededError))throw k;}}if(g.length()<a)for(b=Math.floor(65536*Math.random());g.length()<a;)for(e=16807*(b&65535),b=16807*(b>>16),e+=(b&32767)<<16,e+=b>>15,e=(e&2147483647)+(e>>31),b=e&4294967295,e=0;3>e;++e)h=b>>>(e<<3),h^=Math.floor(256*Math.random()),
2018-11-15 02:44:28 +03:00
g.putByte(String.fromCharCode(h&255));return g.getBytes(a)}var g={plugin:a,key:null,seed:null,time:null,reseeds:0,generated:0};a=a.md;for(var k=Array(32),m=0;32>m;++m)k[m]=a.create();g.pools=k;g.pool=0;g.generate=function(a,d){function e(x){if(x)return d(x);if(D.length()>=a)return d(null,D.getBytes(a));1048575<g.generated&&(g.key=null);if(null===g.key)return c.util.nextTick(function(){b(e)});x=h(g.key,g.seed);g.generated+=x.length;D.putBytes(x);g.key=f(h(g.key,k(g.seed)));g.seed=m(h(g.key,g.seed));
c.util.setImmediate(e)}if(!d)return g.generateSync(a);var h=g.plugin.cipher,k=g.plugin.increment,f=g.plugin.formatKey,m=g.plugin.formatSeed,D=c.util.createBuffer();g.key=null;e()};g.generateSync=function(a){var b=g.plugin.cipher,e=g.plugin.increment,h=g.plugin.formatKey,k=g.plugin.formatSeed;g.key=null;for(var f=c.util.createBuffer();f.length()<a;){1048575<g.generated&&(g.key=null);null===g.key&&(32<=g.pools[0].messageLength||g.collect(g.seedFileSync(32-g.pools[0].messageLength<<5)),d());var m=b(g.key,
2018-08-24 02:55:06 +03:00
g.seed);g.generated+=m.length;f.putBytes(m);g.key=h(b(g.key,e(g.seed)));g.seed=k(b(g.key,g.seed))}return f.getBytes(a)};f?(g.seedFile=function(a,c){f.randomBytes(a,function(a,b){if(a)return c(a);c(null,b.toString())})},g.seedFileSync=function(a){return f.randomBytes(a).toString()}):(g.seedFile=function(a,c){try{c(null,h(a))}catch(b){c(b)}},g.seedFileSync=h);g.collect=function(a){for(var c=a.length,b=0;b<c;++b)g.pools[g.pool].update(a.substr(b,1)),g.pool=31===g.pool?0:g.pool+1};g.collectInt=function(a,
c){for(var b="",d=0;d<c;d+=8)b+=String.fromCharCode(a>>d&255);g.collect(b)};g.registerWorker=function(a){a===self?g.seedFile=function(a,c){function b(a){a=a.data;a.forge&&a.forge.prng&&(self.removeEventListener("message",b),c(a.forge.prng.err,a.forge.prng.bytes))}self.addEventListener("message",b);self.postMessage({forge:{prng:{needed:a}}})}:a.addEventListener("message",function(c){c=c.data;c.forge&&c.forge.prng&&g.seedFile(c.forge.prng.needed,function(c,b){a.postMessage({forge:{prng:{err:c,bytes:b}}})})})};
return g}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.prng)return b.prng;b.defined.prng=!0;for(var k=0;k<e.length;++k)e[k](b);return b.prng}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,
0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/prng",["require","module","./md","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.random&&c.random.getBytes||function(a){function b(){var a=c.prng.create(d);a.getBytes=function(c,b){return a.generate(c,b)};a.getBytesSync=function(c){return a.generate(c)};return a}var d={},f=Array(4),n=c.util.createBuffer();d.formatKey=function(a){var b=c.util.createBuffer(a);a=Array(4);
a[0]=b.getInt32();a[1]=b.getInt32();a[2]=b.getInt32();a[3]=b.getInt32();return c.aes._expandKey(a,!1)};d.formatSeed=function(a){var b=c.util.createBuffer(a);a=Array(4);a[0]=b.getInt32();a[1]=b.getInt32();a[2]=b.getInt32();a[3]=b.getInt32();return a};d.cipher=function(a,b){c.aes._updateBlock(a,b,f,!1);n.putInt32(f[0]);n.putInt32(f[1]);n.putInt32(f[2]);n.putInt32(f[3]);return n.getBytes()};d.increment=function(a){++a[3];return a};d.md=c.md.sha256;var h=b(),g="undefined"!==typeof process&&process.versions&&
2018-11-15 02:44:28 +03:00
process.versions.node,E=null;if("undefined"!==typeof window){var m=window.crypto||window.msCrypto;m&&m.getRandomValues&&(E=function(a){return m.getRandomValues(a)})}if(c.disableNativeCode||!g&&!E){h.collectInt(+new Date,32);if("undefined"!==typeof navigator){var g="",F;for(F in navigator)try{"string"==typeof navigator[F]&&(g+=navigator[F])}catch(w){}h.collect(g);g=null}a&&(a().mousemove(function(a){h.collectInt(a.clientX,16);h.collectInt(a.clientY,16)}),a().keypress(function(a){h.collectInt(a.charCode,
8)}))}if(c.random)for(F in h)c.random[F]=h[F];else c.random=h;c.random.createInstance=b}("undefined"!==typeof jQuery?jQuery:null)}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.random)return b.random;b.defined.random=!0;for(var k=0;k<e.length;++k)e[k](b);
2018-08-24 02:55:06 +03:00
return b.random}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/random","require module ./aes ./md ./prng ./util".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=[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,
2018-10-03 22:03:09 +03:00
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],d=[1,2,3,5];c.rc2=c.rc2||{};c.rc2.expandKey=function(a,d){"string"===typeof a&&(a=c.util.createBuffer(a));d=d||128;var e=a,g=a.length(),f=d,m=Math.ceil(f/8),f=255>>(f&7),v;for(v=g;128>v;v++)e.putByte(b[e.at(v-
2018-11-15 02:44:28 +03:00
1)+e.at(v-g)&255]);e.setAt(128-m,b[e.at(128-m)&f]);for(v=127-m;0<=v;v--)e.setAt(v,b[e.at(v+1)^e.at(v+m)]);return e};var e=function(a,b,e){var g=!1,k=null,f=null,n=null,w,y,p,A,r=[];a=c.rc2.expandKey(a,b);for(p=0;64>p;p++)r.push(a.getInt16Le());e?(w=function(a){for(p=0;4>p;p++){a[p]+=r[A]+(a[(p+3)%4]&a[(p+2)%4])+(~a[(p+3)%4]&a[(p+1)%4]);var c=a[p],b=d[p];a[p]=c<<b&65535|(c&65535)>>16-b;A++}},y=function(a){for(p=0;4>p;p++)a[p]+=r[a[(p+3)%4]&63]}):(w=function(a){for(p=3;0<=p;p--){var c=a[p],b=d[p];a[p]=
(c&65535)>>b|c<<16-b&65535;a[p]-=r[A]+(a[(p+3)%4]&a[(p+2)%4])+(~a[(p+3)%4]&a[(p+1)%4]);A--}},y=function(a){for(p=3;0<=p;p--)a[p]-=r[a[(p+3)%4]&63]});var z=null;return z={start:function(a,b){a&&"string"===typeof a&&(a=c.util.createBuffer(a));g=!1;k=c.util.createBuffer();f=b||new c.util.createBuffer;n=a;z.output=f},update:function(a){for(g||k.putBuffer(a);8<=k.length();){a=[[5,w],[1,y],[6,w],[1,y],[5,w]];var c=[];for(p=0;4>p;p++){var b=k.getInt16Le();null!==n&&(e?b^=n.getInt16Le():n.putInt16Le(b));
c.push(b&65535)}A=e?0:63;for(b=0;b<a.length;b++)for(var d=0;d<a[b][0];d++)a[b][1](c);for(p=0;4>p;p++)null!==n&&(e?n.putInt16Le(c[p]):c[p]^=n.getInt16Le()),f.putInt16Le(c[p])}},finish:function(a){var c=!0;if(e)if(a)c=a(8,k,!e);else{var b=8===k.length()?8:8-k.length();k.fillWithByte(b,b)}c&&(g=!0,z.update());!e&&(c=0===k.length())&&(a?c=a(8,f,!e):(a=f.length(),b=f.at(a-1),b>a?c=!1:f.truncate(b)));return c}}};c.rc2.startEncrypting=function(a,b,d){a=c.rc2.createEncryptionCipher(a,128);a.start(b,d);return a};
2018-08-24 02:55:06 +03:00
c.rc2.createEncryptionCipher=function(a,c){return e(a,c,!0)};c.rc2.startDecrypting=function(a,b,d){a=c.rc2.createDecryptionCipher(a,128);a.start(b,d);return a};c.rc2.createDecryptionCipher=function(a,c){return e(a,c,!1)}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||
{};if(b.defined.rc2)return b.rc2;b.defined.rc2=!0;for(var k=0;k<e.length;++k)e[k](b);return b.rc2}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/rc2",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,d){this.data=[];null!=a&&("number"==typeof a?
this.fromNumber(a,c,d):null==c&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,c))}function d(){return new b(null)}function e(a,c,b,d,l,g){for(;0<=--g;){var e=c*this.data[a++]+b.data[d]+l;l=Math.floor(e/67108864);b.data[d++]=e&67108863}return l}function f(a,c,b,d,l,g){var e=c&32767;for(c>>=15;0<=--g;){var h=this.data[a]&32767,k=this.data[a++]>>15,m=c*h+k*e,h=e*h+((m&32767)<<15)+b.data[d]+(l&1073741823);l=(h>>>30)+(m>>>15)+c*k+(l>>>30);b.data[d++]=h&1073741823}return l}function n(a,c,
2018-11-15 02:44:28 +03:00
b,d,l,g){var e=c&16383;for(c>>=14;0<=--g;){var h=this.data[a]&16383,f=this.data[a++]>>14,k=c*h+f*e,h=e*h+((k&16383)<<14)+b.data[d]+l;l=(h>>28)+(k>>14)+c*f;b.data[d++]=h&268435455}return l}function h(a,c){var b=X[a.charCodeAt(c)];return null==b?-1:b}function g(a){var c=d();c.fromInt(a);return c}function p(a){var c=1,b;0!=(b=a>>>16)&&(a=b,c+=16);0!=(b=a>>8)&&(a=b,c+=8);0!=(b=a>>4)&&(a=b,c+=4);0!=(b=a>>2)&&(a=b,c+=2);0!=a>>1&&(c+=1);return c}function m(a){this.m=a}function F(a){this.m=a;this.mp=a.invDigit();
this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<a.DB-15)-1;this.mt2=2*a.t}function w(a,c){return a&c}function y(a,c){return a|c}function r(a,c){return a^c}function A(a,c){return a&~c}function L(){}function z(a){return a}function D(a){this.r2=d();this.q3=d();b.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a}function x(){return{nextBytes:function(a){for(var c=0;c<a.length;++c)a[c]=Math.floor(256*Math.random())}}}var G;"undefined"===typeof navigator?(b.prototype.am=n,G=28):"Microsoft Internet Explorer"==
2018-08-24 02:55:06 +03:00
navigator.appName?(b.prototype.am=f,G=30):"Netscape"!=navigator.appName?(b.prototype.am=e,G=26):(b.prototype.am=n,G=28);b.prototype.DB=G;b.prototype.DM=(1<<G)-1;b.prototype.DV=1<<G;b.prototype.FV=Math.pow(2,52);b.prototype.F1=52-G;b.prototype.F2=2*G-52;var X=[],q;G=48;for(q=0;9>=q;++q)X[G++]=q;G=97;for(q=10;36>q;++q)X[G++]=q;G=65;for(q=10;36>q;++q)X[G++]=q;m.prototype.convert=function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a};m.prototype.revert=function(a){return a};m.prototype.reduce=
2018-11-15 02:44:28 +03:00
function(a){a.divRemTo(this.m,null,a)};m.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b);this.reduce(b)};m.prototype.sqrTo=function(a,c){a.squareTo(c);this.reduce(c)};F.prototype.convert=function(a){var c=d();a.abs().dlShiftTo(this.m.t,c);c.divRemTo(this.m,null,c);0>a.s&&0<c.compareTo(b.ZERO)&&this.m.subTo(c,c);return c};F.prototype.revert=function(a){var c=d();a.copyTo(c);this.reduce(c);return c};F.prototype.reduce=function(a){for(;a.t<=this.mt2;)a.data[a.t++]=0;for(var c=0;c<this.m.t;++c){var b=
a.data[c]&32767,d=b*this.mpl+((b*this.mph+(a.data[c]>>15)*this.mpl&this.um)<<15)&a.DM,b=c+this.m.t;for(a.data[b]+=this.m.am(0,d,a,c,0,this.m.t);a.data[b]>=a.DV;)a.data[b]-=a.DV,a.data[++b]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)};F.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b);this.reduce(b)};F.prototype.sqrTo=function(a,c){a.squareTo(c);this.reduce(c)};b.prototype.copyTo=function(a){for(var c=this.t-1;0<=c;--c)a.data[c]=this.data[c];a.t=this.t;a.s=this.s};
2018-08-24 02:55:06 +03:00
b.prototype.fromInt=function(a){this.t=1;this.s=0>a?-1:0;0<a?this.data[0]=a:-1>a?this.data[0]=a+this.DV:this.t=0};b.prototype.fromString=function(a,c){var d;if(16==c)d=4;else if(8==c)d=3;else if(256==c)d=8;else if(2==c)d=1;else if(32==c)d=5;else if(4==c)d=2;else{this.fromRadix(a,c);return}this.s=this.t=0;for(var l=a.length,g=!1,e=0;0<=--l;){var f=8==d?a[l]&255:h(a,l);0>f?"-"==a.charAt(l)&&(g=!0):(g=!1,0==e?this.data[this.t++]=f:e+d>this.DB?(this.data[this.t-1]|=(f&(1<<this.DB-e)-1)<<e,this.data[this.t++]=
f>>this.DB-e):this.data[this.t-1]|=f<<e,e+=d,e>=this.DB&&(e-=this.DB))}8==d&&0!=(a[0]&128)&&(this.s=-1,0<e&&(this.data[this.t-1]|=(1<<this.DB-e)-1<<e));this.clamp();g&&b.ZERO.subTo(this,this)};b.prototype.clamp=function(){for(var a=this.s&this.DM;0<this.t&&this.data[this.t-1]==a;)--this.t};b.prototype.dlShiftTo=function(a,c){var b;for(b=this.t-1;0<=b;--b)c.data[b+a]=this.data[b];for(b=a-1;0<=b;--b)c.data[b]=0;c.t=this.t+a;c.s=this.s};b.prototype.drShiftTo=function(a,c){for(var b=a;b<this.t;++b)c.data[b-
a]=this.data[b];c.t=Math.max(this.t-a,0);c.s=this.s};b.prototype.lShiftTo=function(a,c){var b=a%this.DB,d=this.DB-b,l=(1<<d)-1,e=Math.floor(a/this.DB),g=this.s<<b&this.DM,h;for(h=this.t-1;0<=h;--h)c.data[h+e+1]=this.data[h]>>d|g,g=(this.data[h]&l)<<b;for(h=e-1;0<=h;--h)c.data[h]=0;c.data[e]=g;c.t=this.t+e+1;c.s=this.s;c.clamp()};b.prototype.rShiftTo=function(a,c){c.s=this.s;var b=Math.floor(a/this.DB);if(b>=this.t)c.t=0;else{var d=a%this.DB,l=this.DB-d,e=(1<<d)-1;c.data[0]=this.data[b]>>d;for(var g=
b+1;g<this.t;++g)c.data[g-b-1]|=(this.data[g]&e)<<l,c.data[g-b]=this.data[g]>>d;0<d&&(c.data[this.t-b-1]|=(this.s&e)<<l);c.t=this.t-b;c.clamp()}};b.prototype.subTo=function(a,c){for(var b=0,d=0,l=Math.min(a.t,this.t);b<l;)d+=this.data[b]-a.data[b],c.data[b++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;b<this.t;)d+=this.data[b],c.data[b++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;b<a.t;)d-=a.data[b],c.data[b++]=d&this.DM,d>>=this.DB;d-=a.s}c.s=0>d?-1:0;-1>d?c.data[b++]=this.DV+d:0<d&&
(c.data[b++]=d);c.t=b;c.clamp()};b.prototype.multiplyTo=function(a,c){var d=this.abs(),l=a.abs(),e=d.t;for(c.t=e+l.t;0<=--e;)c.data[e]=0;for(e=0;e<l.t;++e)c.data[e+d.t]=d.am(0,l.data[e],c,e,0,d.t);c.s=0;c.clamp();this.s!=a.s&&b.ZERO.subTo(c,c)};b.prototype.squareTo=function(a){for(var c=this.abs(),b=a.t=2*c.t;0<=--b;)a.data[b]=0;for(b=0;b<c.t-1;++b){var d=c.am(b,c.data[b],a,2*b,0,1);(a.data[b+c.t]+=c.am(b+1,2*c.data[b],a,2*b+1,d,c.t-b-1))>=c.DV&&(a.data[b+c.t]-=c.DV,a.data[b+c.t+1]=1)}0<a.t&&(a.data[a.t-
2018-11-15 02:44:28 +03:00
1]+=c.am(b,c.data[b],a,2*b,0,1));a.s=0;a.clamp()};b.prototype.divRemTo=function(a,c,l){var e=a.abs();if(!(0>=e.t)){var g=this.abs();if(g.t<e.t)null!=c&&c.fromInt(0),null!=l&&this.copyTo(l);else{null==l&&(l=d());var h=d(),f=this.s;a=a.s;var m=this.DB-p(e.data[e.t-1]);0<m?(e.lShiftTo(m,h),g.lShiftTo(m,l)):(e.copyTo(h),g.copyTo(l));e=h.t;g=h.data[e-1];if(0!=g){var z=g*(1<<this.F1)+(1<e?h.data[e-2]>>this.F2:0),q=this.FV/z,z=(1<<this.F1)/z,x=1<<this.F2,D=l.t,u=D-e,n=null==c?d():c;h.dlShiftTo(u,n);0<=l.compareTo(n)&&
(l.data[l.t++]=1,l.subTo(n,l));b.ONE.dlShiftTo(e,n);for(n.subTo(h,h);h.t<e;)h.data[h.t++]=0;for(;0<=--u;){var w=l.data[--D]==g?this.DM:Math.floor(l.data[D]*q+(l.data[D-1]+x)*z);if((l.data[D]+=h.am(0,w,l,u,0,e))<w)for(h.dlShiftTo(u,n),l.subTo(n,l);l.data[D]<--w;)l.subTo(n,l)}null!=c&&(l.drShiftTo(e,c),f!=a&&b.ZERO.subTo(c,c));l.t=e;l.clamp();0<m&&l.rShiftTo(m,l);0>f&&b.ZERO.subTo(l,l)}}}};b.prototype.invDigit=function(){if(1>this.t)return 0;var a=this.data[0];if(0==(a&1))return 0;var c=a&3,c=c*(2-
2018-08-24 02:55:06 +03:00
(a&15)*c)&15,c=c*(2-(a&255)*c)&255,c=c*(2-((a&65535)*c&65535))&65535,c=c*(2-a*c%this.DV)%this.DV;return 0<c?this.DV-c:-c};b.prototype.isEven=function(){return 0==(0<this.t?this.data[0]&1:this.s)};b.prototype.exp=function(a,c){if(4294967295<a||1>a)return b.ONE;var l=d(),e=d(),g=c.convert(this),h=p(a)-1;for(g.copyTo(l);0<=--h;)if(c.sqrTo(l,e),0<(a&1<<h))c.mulTo(e,g,l);else var f=l,l=e,e=f;return c.revert(l)};b.prototype.toString=function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=
4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var c=(1<<a)-1,b,d=!1,l="",e=this.t,g=this.DB-e*this.DB%a;if(0<e--)for(g<this.DB&&0<(b=this.data[e]>>g)&&(d=!0,l="0123456789abcdefghijklmnopqrstuvwxyz".charAt(b));0<=e;)g<a?(b=(this.data[e]&(1<<g)-1)<<a-g,b|=this.data[--e]>>(g+=this.DB-a)):(b=this.data[e]>>(g-=a)&c,0>=g&&(g+=this.DB,--e)),0<b&&(d=!0),d&&(l+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(b));return d?l:"0"};b.prototype.negate=function(){var a=
d();b.ZERO.subTo(this,a);return a};b.prototype.abs=function(){return 0>this.s?this.negate():this};b.prototype.compareTo=function(a){var c=this.s-a.s;if(0!=c)return c;var b=this.t,c=b-a.t;if(0!=c)return 0>this.s?-c:c;for(;0<=--b;)if(0!=(c=this.data[b]-a.data[b]))return c;return 0};b.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)};b.prototype.mod=function(a){var c=d();this.abs().divRemTo(a,null,c);0>this.s&&0<c.compareTo(b.ZERO)&&a.subTo(c,
2018-11-15 02:44:28 +03:00
c);return c};b.prototype.modPowInt=function(a,c){var b;b=256>a||c.isEven()?new m(c):new F(c);return this.exp(a,b)};b.ZERO=g(0);b.ONE=g(1);L.prototype.convert=z;L.prototype.revert=z;L.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b)};L.prototype.sqrTo=function(a,c){a.squareTo(c)};D.prototype.convert=function(a){if(0>a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var c=d();a.copyTo(c);this.reduce(c);return c};D.prototype.revert=function(a){return a};D.prototype.reduce=function(a){a.drShiftTo(this.m.t-
1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)};D.prototype.mulTo=function(a,c,b){a.multiplyTo(c,b);this.reduce(b)};D.prototype.sqrTo=function(a,c){a.squareTo(c);this.reduce(c)};var O=[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,
2018-08-24 02:55:06 +03:00
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],M=67108864/O[O.length-1];b.prototype.chunkSize=function(a){return Math.floor(Math.LN2*this.DB/Math.log(a))};b.prototype.toRadix=function(a){null==a&&(a=10);if(0==this.signum()||2>a||36<a)return"0";var c=this.chunkSize(a),c=Math.pow(a,
2018-11-15 02:44:28 +03:00
c),b=g(c),l=d(),e=d(),h="";for(this.divRemTo(b,l,e);0<l.signum();)h=(c+e.intValue()).toString(a).substr(1)+h,l.divRemTo(b,l,e);return e.intValue().toString(a)+h};b.prototype.fromRadix=function(a,c){this.fromInt(0);null==c&&(c=10);for(var d=this.chunkSize(c),l=Math.pow(c,d),e=!1,g=0,f=0,m=0;m<a.length;++m){var z=h(a,m);0>z?"-"==a.charAt(m)&&0==this.signum()&&(e=!0):(f=c*f+z,++g>=d&&(this.dMultiply(l),this.dAddOffset(f,0),f=g=0))}0<g&&(this.dMultiply(Math.pow(c,g)),this.dAddOffset(f,0));e&&b.ZERO.subTo(this,
this)};b.prototype.fromNumber=function(a,c,d){if("number"==typeof c)if(2>a)this.fromInt(1);else for(this.fromNumber(a,d),this.testBit(a-1)||this.bitwiseTo(b.ONE.shiftLeft(a-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(c);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(b.ONE.shiftLeft(a-1),this);else{d=[];var l=a&7;d.length=(a>>3)+1;c.nextBytes(d);d[0]=0<l?d[0]&(1<<l)-1:0;this.fromString(d,256)}};b.prototype.bitwiseTo=function(a,c,b){var d,l,e=Math.min(a.t,this.t);for(d=
2018-08-24 02:55:06 +03:00
0;d<e;++d)b.data[d]=c(this.data[d],a.data[d]);if(a.t<this.t){l=a.s&this.DM;for(d=e;d<this.t;++d)b.data[d]=c(this.data[d],l);b.t=this.t}else{l=this.s&this.DM;for(d=e;d<a.t;++d)b.data[d]=c(l,a.data[d]);b.t=a.t}b.s=c(this.s,a.s);b.clamp()};b.prototype.changeBit=function(a,c){var d=b.ONE.shiftLeft(a);this.bitwiseTo(d,c,d);return d};b.prototype.addTo=function(a,c){for(var b=0,d=0,l=Math.min(a.t,this.t);b<l;)d+=this.data[b]+a.data[b],c.data[b++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;b<this.t;)d+=
this.data[b],c.data[b++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;b<a.t;)d+=a.data[b],c.data[b++]=d&this.DM,d>>=this.DB;d+=a.s}c.s=0>d?-1:0;0<d?c.data[b++]=d:-1>d&&(c.data[b++]=this.DV+d);c.t=b;c.clamp()};b.prototype.dMultiply=function(a){this.data[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()};b.prototype.dAddOffset=function(a,c){if(0!=a){for(;this.t<=c;)this.data[this.t++]=0;for(this.data[c]+=a;this.data[c]>=this.DV;)this.data[c]-=this.DV,++c>=this.t&&(this.data[this.t++]=
0),++this.data[c]}};b.prototype.multiplyLowerTo=function(a,c,b){var d=Math.min(this.t+a.t,c);b.s=0;for(b.t=d;0<d;)b.data[--d]=0;var l;for(l=b.t-this.t;d<l;++d)b.data[d+this.t]=this.am(0,a.data[d],b,d,0,this.t);for(l=Math.min(a.t,c);d<l;++d)this.am(0,a.data[d],b,d,0,c-d);b.clamp()};b.prototype.multiplyUpperTo=function(a,c,b){--c;var d=b.t=this.t+a.t-c;for(b.s=0;0<=--d;)b.data[d]=0;for(d=Math.max(c-this.t,0);d<a.t;++d)b.data[this.t+d-c]=this.am(c-d,a.data[d],b,0,0,this.t+d-c);b.clamp();b.drShiftTo(1,
2018-11-15 02:44:28 +03:00
b)};b.prototype.modInt=function(a){if(0>=a)return 0;var c=this.DV%a,b=0>this.s?a-1:0;if(0<this.t)if(0==c)b=this.data[0]%a;else for(var d=this.t-1;0<=d;--d)b=(c*b+this.data[d])%a;return b};b.prototype.millerRabin=function(a){var c=this.subtract(b.ONE),d=c.getLowestSetBit();if(0>=d)return!1;for(var l=c.shiftRight(d),e=x(),g,h=0;h<a;++h){do g=new b(this.bitLength(),e);while(0>=g.compareTo(b.ONE)||0<=g.compareTo(c));g=g.modPow(l,this);if(0!=g.compareTo(b.ONE)&&0!=g.compareTo(c)){for(var f=1;f++<d&&0!=
2018-08-24 02:55:06 +03:00
g.compareTo(c);)if(g=g.modPowInt(2,this),0==g.compareTo(b.ONE))return!1;if(0!=g.compareTo(c))return!1}}return!0};b.prototype.clone=function(){var a=d();this.copyTo(a);return a};b.prototype.intValue=function(){if(0>this.s){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]};b.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24};b.prototype.shortValue=
function(){return 0==this.t?this.s:this.data[0]<<16>>16};b.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this.data[0]?0:1};b.prototype.toByteArray=function(){var a=this.t,c=[];c[0]=this.s;var b=this.DB-a*this.DB%8,d,l=0;if(0<a--)for(b<this.DB&&(d=this.data[a]>>b)!=(this.s&this.DM)>>b&&(c[l++]=d|this.s<<this.DB-b);0<=a;)if(8>b?(d=(this.data[a]&(1<<b)-1)<<8-b,d|=this.data[--a]>>(b+=this.DB-8)):(d=this.data[a]>>(b-=8)&255,0>=b&&(b+=this.DB,--a)),0!=(d&128)&&(d|=-256),0==l&&
2018-11-15 02:44:28 +03:00
(this.s&128)!=(d&128)&&++l,0<l||d!=this.s)c[l++]=d;return c};b.prototype.equals=function(a){return 0==this.compareTo(a)};b.prototype.min=function(a){return 0>this.compareTo(a)?this:a};b.prototype.max=function(a){return 0<this.compareTo(a)?this:a};b.prototype.and=function(a){var c=d();this.bitwiseTo(a,w,c);return c};b.prototype.or=function(a){var c=d();this.bitwiseTo(a,y,c);return c};b.prototype.xor=function(a){var c=d();this.bitwiseTo(a,r,c);return c};b.prototype.andNot=function(a){var c=d();this.bitwiseTo(a,
2018-08-24 02:55:06 +03:00
A,c);return c};b.prototype.not=function(){for(var a=d(),c=0;c<this.t;++c)a.data[c]=this.DM&~this.data[c];a.t=this.t;a.s=~this.s;return a};b.prototype.shiftLeft=function(a){var c=d();0>a?this.rShiftTo(-a,c):this.lShiftTo(a,c);return c};b.prototype.shiftRight=function(a){var c=d();0>a?this.lShiftTo(-a,c):this.rShiftTo(a,c);return c};b.prototype.getLowestSetBit=function(){for(var a=0;a<this.t;++a)if(0!=this.data[a]){var c=a*this.DB;a=this.data[a];if(0==a)a=-1;else{var b=0;0==(a&65535)&&(a>>=16,b+=16);
2018-11-15 02:44:28 +03:00
0==(a&255)&&(a>>=8,b+=8);0==(a&15)&&(a>>=4,b+=4);0==(a&3)&&(a>>=2,b+=2);0==(a&1)&&++b;a=b}return c+a}return 0>this.s?this.t*this.DB:-1};b.prototype.bitCount=function(){for(var a=0,c=this.s&this.DM,b=0;b<this.t;++b){for(var d=this.data[b]^c,l=0;0!=d;)d&=d-1,++l;a+=l}return a};b.prototype.testBit=function(a){var c=Math.floor(a/this.DB);return c>=this.t?0!=this.s:0!=(this.data[c]&1<<a%this.DB)};b.prototype.setBit=function(a){return this.changeBit(a,y)};b.prototype.clearBit=function(a){return this.changeBit(a,
2018-08-24 02:55:06 +03:00
A)};b.prototype.flipBit=function(a){return this.changeBit(a,r)};b.prototype.add=function(a){var c=d();this.addTo(a,c);return c};b.prototype.subtract=function(a){var c=d();this.subTo(a,c);return c};b.prototype.multiply=function(a){var c=d();this.multiplyTo(a,c);return c};b.prototype.divide=function(a){var c=d();this.divRemTo(a,c,null);return c};b.prototype.remainder=function(a){var c=d();this.divRemTo(a,null,c);return c};b.prototype.divideAndRemainder=function(a){var c=d(),b=d();this.divRemTo(a,c,
2018-11-15 02:44:28 +03:00
b);return[c,b]};b.prototype.modPow=function(a,c){var b=a.bitLength(),l,e=g(1),h;if(0>=b)return e;l=18>b?1:48>b?3:144>b?4:768>b?5:6;h=8>b?new m(c):c.isEven()?new D(c):new F(c);var f=[],k=3,z=l-1,q=(1<<l)-1;f[1]=h.convert(this);if(1<l)for(b=d(),h.sqrTo(f[1],b);k<=q;)f[k]=d(),h.mulTo(b,f[k-2],f[k]),k+=2;for(var x=a.t-1,u,n=!0,w=d(),b=p(a.data[x])-1;0<=x;){b>=z?u=a.data[x]>>b-z&q:(u=(a.data[x]&(1<<b+1)-1)<<z-b,0<x&&(u|=a.data[x-1]>>this.DB+b-z));for(k=l;0==(u&1);)u>>=1,--k;0>(b-=k)&&(b+=this.DB,--x);
if(n)f[u].copyTo(e),n=!1;else{for(;1<k;)h.sqrTo(e,w),h.sqrTo(w,e),k-=2;0<k?h.sqrTo(e,w):(k=e,e=w,w=k);h.mulTo(w,f[u],e)}for(;0<=x&&0==(a.data[x]&1<<b);)h.sqrTo(e,w),k=e,e=w,w=k,0>--b&&(b=this.DB-1,--x)}return h.revert(e)};b.prototype.modInverse=function(a){var c=a.isEven();if(this.isEven()&&c||0==a.signum())return b.ZERO;for(var d=a.clone(),l=this.clone(),e=g(1),h=g(0),f=g(0),m=g(1);0!=d.signum();){for(;d.isEven();)d.rShiftTo(1,d),c?(e.isEven()&&h.isEven()||(e.addTo(this,e),h.subTo(a,h)),e.rShiftTo(1,
2018-08-24 02:55:06 +03:00
e)):h.isEven()||h.subTo(a,h),h.rShiftTo(1,h);for(;l.isEven();)l.rShiftTo(1,l),c?(f.isEven()&&m.isEven()||(f.addTo(this,f),m.subTo(a,m)),f.rShiftTo(1,f)):m.isEven()||m.subTo(a,m),m.rShiftTo(1,m);0<=d.compareTo(l)?(d.subTo(l,d),c&&e.subTo(f,e),h.subTo(m,h)):(l.subTo(d,l),c&&f.subTo(e,f),m.subTo(h,m))}if(0!=l.compareTo(b.ONE))return b.ZERO;if(0<=m.compareTo(a))return m.subtract(a);if(0>m.signum())m.addTo(a,m);else return m;return 0>m.signum()?m.add(a):m};b.prototype.pow=function(a){return this.exp(a,
2018-11-15 02:44:28 +03:00
new L)};b.prototype.gcd=function(a){var c=0>this.s?this.negate():this.clone();a=0>a.s?a.negate():a.clone();if(0>c.compareTo(a)){var b=c,c=a;a=b}var b=c.getLowestSetBit(),d=a.getLowestSetBit();if(0>d)return c;b<d&&(d=b);0<d&&(c.rShiftTo(d,c),a.rShiftTo(d,a));for(;0<c.signum();)0<(b=c.getLowestSetBit())&&c.rShiftTo(b,c),0<(b=a.getLowestSetBit())&&a.rShiftTo(b,a),0<=c.compareTo(a)?(c.subTo(a,c),c.rShiftTo(1,c)):(a.subTo(c,a),a.rShiftTo(1,a));0<d&&a.lShiftTo(d,a);return a};b.prototype.isProbablePrime=
2018-08-24 02:55:06 +03:00
function(a){var c,b=this.abs();if(1==b.t&&b.data[0]<=O[O.length-1]){for(c=0;c<O.length;++c)if(b.data[0]==O[c])return!0;return!1}if(b.isEven())return!1;for(c=1;c<O.length;){for(var d=O[c],l=c+1;l<O.length&&d<M;)d*=O[l++];for(d=b.modInt(d);c<l;)if(0==d%O[c++])return!1}return b.millerRabin(a)};c.jsbn=c.jsbn||{};c.jsbn.BigInteger=b}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,
p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.jsbn)return b.jsbn;b.defined.jsbn=!0;for(var f=0;f<e.length;++f)e[f](b);return b.jsbn}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/jsbn",["require","module"],function(){p.apply(null,Array.prototype.slice.call(arguments,
2018-11-15 02:44:28 +03:00
0))})})();(function(){function a(c){function b(a,d,f){f||(f=c.md.sha1.create());for(var h="",g=Math.ceil(d/f.digestLength),k=0;k<g;++k){var m=String.fromCharCode(k>>24&255,k>>16&255,k>>8&255,k&255);f.start();f.update(a+m);h+=f.digest().getBytes()}return h.substring(0,d)}var d=c.pkcs1=c.pkcs1||{};d.encode_rsa_oaep=function(a,d,f,h,g){var v,m,n,w;"string"===typeof f?(v=f,m=h||void 0,n=g||void 0):f&&(v=f.label||void 0,m=f.seed||void 0,n=f.md||void 0,f.mgf1&&f.mgf1.md&&(w=f.mgf1.md));n?n.start():n=c.md.sha1.create();
w||(w=n);a=Math.ceil(a.n.bitLength()/8);f=a-2*n.digestLength-2;if(d.length>f)throw w=Error("RSAES-OAEP input message length is too long."),w.length=d.length,w.maxLength=f,w;v||(v="");n.update(v,"raw");v=n.digest();h="";f-=d.length;for(g=0;g<f;g++)h+="\x00";d=v.getBytes()+h+"\u0001"+d;if(!m)m=c.random.getBytes(n.digestLength);else if(m.length!==n.digestLength)throw w=Error("Invalid RSAES-OAEP seed. The seed length must match the digest length."),w.seedLength=m.length,w.digestLength=n.digestLength,
w;a=b(m,a-n.digestLength-1,w);d=c.util.xorBytes(d,a,d.length);n=b(d,n.digestLength,w);return"\x00"+c.util.xorBytes(m,n,m.length)+d};d.decode_rsa_oaep=function(a,d,f,h){var g,v,m;"string"===typeof f?(g=f,v=h||void 0):f&&(g=f.label||void 0,v=f.md||void 0,f.mgf1&&f.mgf1.md&&(m=f.mgf1.md));f=Math.ceil(a.n.bitLength()/8);if(d.length!==f)throw m=Error("RSAES-OAEP encoded message length is invalid."),m.length=d.length,m.expectedLength=f,m;void 0===v?v=c.md.sha1.create():v.start();m||(m=v);if(f<2*v.digestLength+
2018-10-03 22:03:09 +03:00
2)throw Error("RSAES-OAEP key is too short for the hash function.");g||(g="");v.update(g,"raw");g=v.digest().getBytes();a=d.charAt(0);h=d.substring(1,v.digestLength+1);d=d.substring(1+v.digestLength);var n=b(d,v.digestLength,m);h=c.util.xorBytes(h,n,h.length);m=b(h,f-v.digestLength-1,m);d=c.util.xorBytes(d,m,d.length);f=d.substring(0,v.digestLength);m="\x00"!==a;for(a=0;a<v.digestLength;++a)m|=g.charAt(a)!==f.charAt(a);g=1;for(v=a=v.digestLength;v<d.length;v++)f=d.charCodeAt(v),h=f&1^1,m|=f&(g?65534:
2018-08-24 02:55:06 +03:00
0),g&=h,a+=g;if(m||1!==d.charCodeAt(a))throw Error("Invalid RSAES-OAEP padding.");return d.substring(a+1)}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pkcs1)return b.pkcs1;b.defined.pkcs1=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pkcs1}},
r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pkcs1",["require","module","./util","./random","./sha1"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,l,g){return"workers"in l?e(a,c,l,g):d(a,c,l,g)}function d(a,b,e,g){var h=f(a,b),k=0,m=n(h.bitLength());"millerRabinTests"in
2018-11-15 02:44:28 +03:00
e&&(m=e.millerRabinTests);var x=10;"maxBlockTime"in e&&(x=e.maxBlockTime);var G=+new Date;do{h.bitLength()>a&&(h=f(a,b));if(h.isProbablePrime(m))return g(null,h);h.dAddOffset(p[k++%8],0)}while(0>x||+new Date-G<x);c.util.setImmediate(function(){d(a,b,e,g)})}function e(a,b,e,h){function k(){function c(l){if(!v){--e;var k=l.data;if(k.found){for(l=0;l<d.length;++l)d[l].terminate();v=!0;return h(null,new g(k.prime,16))}m.bitLength()>a&&(m=f(a,b));k=m.toString(16);l.target.postMessage({hex:k,workLoad:x});
m.dAddOffset(n,0)}}D=Math.max(1,D);for(var d=[],l=0;l<D;++l)d[l]=new Worker(p);for(var e=D,l=0;l<D;++l)d[l].addEventListener("message",c);var v=!1}if("undefined"===typeof Worker)return d(a,b,e,h);var m=f(a,b),D=e.workers,x=e.workLoad||100,n=30*x/8,p=e.workerScript||"forge/prime.worker.js";if(-1===D)return c.util.estimateCores(function(a,c){a&&(c=2);D=c-1;k()});k()}function f(a,c){var b=new g(a,c),d=a-1;b.testBit(d)||b.bitwiseTo(g.ONE.shiftLeft(d),r,b);b.dAddOffset(31-b.mod(m).byteValue(),0);return b}
2018-08-24 02:55:06 +03:00
function n(a){return 100>=a?27:150>=a?18:200>=a?15:250>=a?12:300>=a?9:350>=a?8:400>=a?7:500>=a?6:600>=a?5:800>=a?4:1250>=a?3:2}if(!c.prime){var h=c.prime=c.prime||{},g=c.jsbn.BigInteger,p=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var r=function(a,c){return a|c};h.generateProbablePrime=function(a,d,e){"function"===typeof d&&(e=d,d={});d=d||{};var g=d.algorithm||"PRIMEINC";"string"===typeof g&&(g={name:g});g.options=g.options||{};var h=d.prng||c.random;d={nextBytes:function(a){for(var c=h.getBytesSync(a.length),
b=0;b<a.length;++b)a[b]=c.charCodeAt(b)}};if("PRIMEINC"===g.name)return b(a,d,g.options,e);throw Error("Invalid prime generation algorithm: "+g.name);}}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.prime)return b.prime;b.defined.prime=!0;for(var f=
0;f<e.length;++f)e[f](b);return b.prime}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/prime",["require","module","./util","./jsbn","./random"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,d,e){var g=c.util.createBuffer();d=Math.ceil(d.n.bitLength()/8);if(a.length>d-11)throw g=
Error("Message is too long for PKCS#1 v1.5 padding."),g.length=a.length,g.max=d-11,g;g.putByte(0);g.putByte(e);d=d-3-a.length;if(0===e||1===e){e=0===e?0:255;for(var h=0;h<d;++h)g.putByte(e)}else for(;0<d;){for(var f=0,k=c.random.getBytes(d),h=0;h<d;++h)e=k.charCodeAt(h),0===e?++f:g.putByte(e);d=f}g.putByte(0);g.putBytes(a);return g}function d(a,b,e,g){b=Math.ceil(b.n.bitLength()/8);a=c.util.createBuffer(a);var h=a.getByte(),f=a.getByte();if(0!==h||e&&0!==f&&1!==f||!e&&2!=f||e&&0===f&&"undefined"===
typeof g)throw Error("Encryption block is invalid.");e=0;if(0===f)for(e=b-3-g,g=0;g<e;++g){if(0!==a.getByte())throw Error("Encryption block is invalid.");}else if(1===f)for(e=0;1<a.length();){if(255!==a.getByte()){--a.read;break}++e}else if(2===f)for(e=0;1<a.length();){if(0===a.getByte()){--a.read;break}++e}if(0!==a.getByte()||e!==b-3-a.length())throw Error("Encryption block is invalid.");return a.getBytes()}function e(a,b,d){function e(){g(a.pBits,function(c,b){if(c)return d(c);a.p=b;if(null!==a.q)return f(c,
a.q);g(a.qBits,f)})}function g(a,b){c.prime.generateProbablePrime(a,k,b)}function f(c,b){if(c)return d(c);a.q=b;if(0>a.p.compareTo(a.q)){var l=a.p;a.p=a.q;a.q=l}0!==a.p.subtract(h.ONE).gcd(a.e).compareTo(h.ONE)?(a.p=null,e()):0!==a.q.subtract(h.ONE).gcd(a.e).compareTo(h.ONE)?(a.q=null,g(a.qBits,f)):(a.p1=a.p.subtract(h.ONE),a.q1=a.q.subtract(h.ONE),a.phi=a.p1.multiply(a.q1),0!==a.phi.gcd(a.e).compareTo(h.ONE)?(a.p=a.q=null,e()):(a.n=a.p.multiply(a.q),a.n.bitLength()!==a.bits?(a.q=null,g(a.qBits,f)):
(l=a.e.modInverse(a.phi),a.keys={privateKey:p.rsa.setPrivateKey(a.n,a.e,l,a.p,a.q,l.mod(a.p1),l.mod(a.q1),a.q.modInverse(a.p)),publicKey:p.rsa.setPublicKey(a.n,a.e)},d(null,a.keys))))}"function"===typeof b&&(d=b,b={});b=b||{};var k={algorithm:{name:b.algorithm||"PRIMEINC",options:{workers:b.workers||2,workLoad:b.workLoad||100,workerScript:b.workerScript}}};"prng"in b&&(k.prng=b.prng);e()}function f(a){a=a.toString(16);"8"<=a[0]&&(a="00"+a);return c.util.hexToBytes(a)}function n(a){return 100>=a?27:
150>=a?18:200>=a?15:250>=a?12:300>=a?9:350>=a?8:400>=a?7:500>=a?6:600>=a?5:800>=a?4:1250>=a?3:2}if("undefined"===typeof h)var h=c.jsbn.BigInteger;var g=c.asn1;c.pki=c.pki||{};c.pki.rsa=c.rsa=c.rsa||{};var p=c.pki,m=[6,4,2,4,2,4,6,2],r={name:"PrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:g.Class.UNIVERSAL,
2018-11-15 02:44:28 +03:00
type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},w={name:"RSAPrivateKey",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",
2018-08-24 02:55:06 +03:00
tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",
2018-11-15 02:44:28 +03:00
tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},y={name:"RSAPublicKey",tagClass:g.Class.UNIVERSAL,
type:g.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},C=c.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:g.Class.UNIVERSAL,
2018-08-24 02:55:06 +03:00
type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:g.Class.UNIVERSAL,type:g.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},A=function(a){var c;if(a.algorithm in p.oids)c=p.oids[a.algorithm];
2018-11-15 02:44:28 +03:00
else throw c=Error("Unknown message digest algorithm."),c.algorithm=a.algorithm,c;var b=g.oidToDer(c).getBytes();c=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]);var d=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]);d.value.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,b));d.value.push(g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,""));a=g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,a.digest().getBytes());c.value.push(d);c.value.push(a);return g.toDer(c).getBytes()},L=function(a,b,d){if(d)return a.modPow(b.e,
2018-08-24 02:55:06 +03:00
b.n);if(!b.p||!b.q)return a.modPow(b.d,b.n);b.dP||(b.dP=b.d.mod(b.p.subtract(h.ONE)));b.dQ||(b.dQ=b.d.mod(b.q.subtract(h.ONE)));b.qInv||(b.qInv=b.q.modInverse(b.p));do d=new h(c.util.bytesToHex(c.random.getBytes(b.n.bitLength()/8)),16);while(0<=d.compareTo(b.n)||!d.gcd(b.n).equals(h.ONE));a=a.multiply(d.modPow(b.e,b.n)).mod(b.n);var e=a.mod(b.p).modPow(b.dP,b.p);for(a=a.mod(b.q).modPow(b.dQ,b.q);0>e.compareTo(a);)e=e.add(b.p);a=e.subtract(a).multiply(b.qInv).mod(b.p).multiply(b.q).add(a);return a=
2018-11-15 02:44:28 +03:00
a.multiply(d.modInverse(b.n)).mod(b.n)};p.rsa.encrypt=function(a,d,e){var g=e,f=Math.ceil(d.n.bitLength()/8);!1!==e&&!0!==e?(g=2===e,e=b(a,d,e)):(e=c.util.createBuffer(),e.putBytes(a));a=new h(e.toHex(),16);d=L(a,d,g).toString(16);g=c.util.createBuffer();for(f-=Math.ceil(d.length/2);0<f;)g.putByte(0),--f;g.putBytes(c.util.hexToBytes(d));return g.getBytes()};p.rsa.decrypt=function(a,b,e,g){var f=Math.ceil(b.n.bitLength()/8);if(a.length!==f)throw b=Error("Encrypted message length is invalid."),b.length=
a.length,b.expected=f,b;a=new h(c.util.createBuffer(a).toHex(),16);if(0<=a.compareTo(b.n))throw Error("Encrypted message is invalid.");a=L(a,b,e).toString(16);for(var k=c.util.createBuffer(),f=f-Math.ceil(a.length/2);0<f;)k.putByte(0),--f;k.putBytes(c.util.hexToBytes(a));return!1!==g?d(k.getBytes(),b,e):k.getBytes()};p.rsa.createKeyPairGenerationState=function(a,b,d){"string"===typeof a&&(a=parseInt(a,10));a=a||2048;d=d||{};var e=d.prng||c.random,g={nextBytes:function(a){for(var c=e.getBytesSync(a.length),
2018-08-24 02:55:06 +03:00
b=0;b<a.length;++b)a[b]=c.charCodeAt(b)}};d=d.algorithm||"PRIMEINC";if("PRIMEINC"===d)a={algorithm:d,state:0,bits:a,rng:g,eInt:b||65537,e:new h(null),p:null,q:null,qBits:a>>1,pBits:a-(a>>1),pqState:0,num:null,keys:null},a.e.fromInt(a.eInt);else throw Error("Invalid key generation algorithm: "+d);return a};p.rsa.stepKeyPairGenerationState=function(a,c){"algorithm"in a||(a.algorithm="PRIMEINC");var b=new h(null);b.fromInt(30);for(var d=0,l=function(a,c){return a|c},e=+new Date,g,f=0;null===a.keys&&
(0>=c||f<c);){if(0===a.state){g=null===a.p?a.pBits:a.qBits;var k=g-1;0===a.pqState?(a.num=new h(g,a.rng),a.num.testBit(k)||a.num.bitwiseTo(h.ONE.shiftLeft(k),l,a.num),a.num.dAddOffset(31-a.num.mod(b).byteValue(),0),d=0,++a.pqState):1===a.pqState?a.num.bitLength()>g?a.pqState=0:a.num.isProbablePrime(n(a.num.bitLength()))?++a.pqState:a.num.dAddOffset(m[d++%8],0):2===a.pqState?a.pqState=0===a.num.subtract(h.ONE).gcd(a.e).compareTo(h.ONE)?3:0:3===a.pqState&&(a.pqState=0,null===a.p?a.p=a.num:a.q=a.num,
null!==a.p&&null!==a.q&&++a.state,a.num=null)}else 1===a.state?(0>a.p.compareTo(a.q)&&(a.num=a.p,a.p=a.q,a.q=a.num),++a.state):2===a.state?(a.p1=a.p.subtract(h.ONE),a.q1=a.q.subtract(h.ONE),a.phi=a.p1.multiply(a.q1),++a.state):3===a.state?0===a.phi.gcd(a.e).compareTo(h.ONE)?++a.state:(a.p=null,a.q=null,a.state=0):4===a.state?(a.n=a.p.multiply(a.q),a.n.bitLength()===a.bits?++a.state:(a.q=null,a.state=0)):5===a.state&&(g=a.e.modInverse(a.phi),a.keys={privateKey:p.rsa.setPrivateKey(a.n,a.e,g,a.p,a.q,
g.mod(a.p1),g.mod(a.q1),a.q.modInverse(a.p)),publicKey:p.rsa.setPublicKey(a.n,a.e)});g=+new Date;f+=g-e;e=g}return null!==a.keys};p.rsa.generateKeyPair=function(a,c,b,d){1===arguments.length?"object"===typeof a?(b=a,a=void 0):"function"===typeof a&&(d=a,a=void 0):2===arguments.length?"number"===typeof a?"function"===typeof c?(d=c,c=void 0):"number"!==typeof c&&(b=c,c=void 0):(b=a,d=c,c=a=void 0):3===arguments.length&&("number"===typeof c?"function"===typeof b&&(d=b,b=void 0):(d=b,b=c,c=void 0));b=
b||{};void 0===a&&(a=b.bits||2048);void 0===c&&(c=b.e||65537);var l=p.rsa.createKeyPairGenerationState(a,c,b);if(!d)return p.rsa.stepKeyPairGenerationState(l,0),l.keys;e(l,b,d)};p.setRsaPublicKey=p.rsa.setPublicKey=function(a,e){var h={n:a,e:e,encrypt:function(a,d,e){"string"===typeof d?d=d.toUpperCase():void 0===d&&(d="RSAES-PKCS1-V1_5");if("RSAES-PKCS1-V1_5"===d)d={encode:function(a,c,d){return b(a,c,2).getBytes()}};else if("RSA-OAEP"===d||"RSAES-OAEP"===d)d={encode:function(a,b){return c.pkcs1.encode_rsa_oaep(b,
a,e)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(d))d={encode:function(a){return a}};else if("string"===typeof d)throw Error('Unsupported encryption scheme: "'+d+'".');a=d.encode(a,h,!0);return p.rsa.encrypt(a,h,!0)},verify:function(a,c,b){"string"===typeof b?b=b.toUpperCase():void 0===b&&(b="RSASSA-PKCS1-V1_5");if("RSASSA-PKCS1-V1_5"===b)b={verify:function(a,c){c=d(c,h,!0);var b=g.fromDer(c);return a===b.value[1].value}};else if("NONE"===b||"NULL"===b||null===b)b={verify:function(a,c){c=d(c,
2018-10-03 22:03:09 +03:00
h,!0);return a===c}};c=p.rsa.decrypt(c,h,!0,!1);return b.verify(a,c,h.n.bitLength())}};return h};p.setRsaPrivateKey=p.rsa.setPrivateKey=function(a,b,e,g,h,f,k,m){var u={n:a,e:b,d:e,p:g,q:h,dP:f,dQ:k,qInv:m,decrypt:function(a,b,e){"string"===typeof b?b=b.toUpperCase():void 0===b&&(b="RSAES-PKCS1-V1_5");a=p.rsa.decrypt(a,u,!1,!1);if("RSAES-PKCS1-V1_5"===b)b={decode:d};else if("RSA-OAEP"===b||"RSAES-OAEP"===b)b={decode:function(a,b){return c.pkcs1.decode_rsa_oaep(b,a,e)}};else if(-1!==["RAW","NONE",
"NULL",null].indexOf(b))b={decode:function(a){return a}};else throw Error('Unsupported encryption scheme: "'+b+'".');return b.decode(a,u,!1)},sign:function(a,c){var b=!1;"string"===typeof c&&(c=c.toUpperCase());if(void 0===c||"RSASSA-PKCS1-V1_5"===c)c={encode:A},b=1;else if("NONE"===c||"NULL"===c||null===c)c={encode:function(){return a}},b=1;var d=c.encode(a,u.n.bitLength());return p.rsa.encrypt(d,u,b)}};return u};p.wrapRsaPrivateKey=function(a){return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,
2018-11-15 02:44:28 +03:00
[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(0).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(p.oids.rsaEncryption).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")]),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,g.toDer(a).getBytes())])};p.privateKeyFromAsn1=function(a){var b={},d=[];g.validate(a,r,b,d)&&(a=g.fromDer(c.util.createBuffer(b.privateKey)));b={};d=[];if(!g.validate(a,w,b,d))throw b=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey."),
2018-08-24 02:55:06 +03:00
b.errors=d,b;var e,f,k,m,u,d=c.util.createBuffer(b.privateKeyModulus).toHex();a=c.util.createBuffer(b.privateKeyPublicExponent).toHex();e=c.util.createBuffer(b.privateKeyPrivateExponent).toHex();f=c.util.createBuffer(b.privateKeyPrime1).toHex();k=c.util.createBuffer(b.privateKeyPrime2).toHex();m=c.util.createBuffer(b.privateKeyExponent1).toHex();u=c.util.createBuffer(b.privateKeyExponent2).toHex();b=c.util.createBuffer(b.privateKeyCoefficient).toHex();return p.setRsaPrivateKey(new h(d,16),new h(a,
16),new h(e,16),new h(f,16),new h(k,16),new h(m,16),new h(u,16),new h(b,16))};p.privateKeyToAsn1=p.privateKeyToRSAPrivateKey=function(a){return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(0).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.n)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.e)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.d)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.p)),g.create(g.Class.UNIVERSAL,
2018-11-15 02:44:28 +03:00
g.Type.INTEGER,!1,f(a.q)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.dP)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.dQ)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.qInv))])};p.publicKeyFromAsn1=function(a){var b={},d=[];if(g.validate(a,C,b,d)){d=g.derToOid(b.publicKeyOid);if(d!==p.oids.rsaEncryption)throw b=Error("Cannot read public key. Unknown OID."),b.oid=d,b;a=b.rsaPublicKey}d=[];if(!g.validate(a,y,b,d))throw b=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey."),
2018-08-24 02:55:06 +03:00
b.errors=d,b;d=c.util.createBuffer(b.publicKeyModulus).toHex();b=c.util.createBuffer(b.publicKeyExponent).toHex();return p.setRsaPublicKey(new h(d,16),new h(b,16))};p.publicKeyToAsn1=p.publicKeyToSubjectPublicKeyInfo=function(a){return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(p.oids.rsaEncryption).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")]),g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,
!1,[p.publicKeyToRSAPublicKey(a)])])};p.publicKeyToRSAPublicKey=function(a){return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.n)),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f(a.e))])}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||
{};b.defined=b.defined||{};if(b.defined.rsa)return b.rsa;b.defined.rsa=!0;for(var f=0;f<e.length;++f)e[f](b);return b.rsa}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/rsa","require module ./asn1 ./jsbn ./oids ./pkcs1 ./prime ./random ./util".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,
c){return a.start().update(c).digest().getBytes()}if("undefined"===typeof d)var d=c.jsbn.BigInteger;var e=c.asn1,f=c.pki=c.pki||{};f.pbe=c.pbe=c.pbe||{};var n=f.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encryptionOid"},
{name:"AlgorithmIdentifier.parameters",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},g={name:"PBES2Algorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",
tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,onstructed:!0,capture:"kdfIterationCount"}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:e.Class.UNIVERSAL,
type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},p={name:"pkcs-12PbeParams",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"salt"},
2018-11-15 02:44:28 +03:00
{name:"pkcs-12PbeParams.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"iterations"}]};f.encryptPrivateKeyInfo=function(a,b,d){d=d||{};d.saltSize=d.saltSize||8;d.count=d.count||2048;d.algorithm=d.algorithm||"aes128";var g=c.random.getBytesSync(d.saltSize),h=d.count,k=e.integerToDer(h),v;if(0===d.algorithm.indexOf("aes")||"des"===d.algorithm){var z,D;switch(d.algorithm){case "aes128":z=v=16;d=n["aes128-CBC"];D=c.aes.createEncryptionCipher;break;case "aes192":v=24;
z=16;d=n["aes192-CBC"];D=c.aes.createEncryptionCipher;break;case "aes256":v=32;z=16;d=n["aes256-CBC"];D=c.aes.createEncryptionCipher;break;case "des":z=v=8;d=n.desCBC;D=c.des.createEncryptionCipher;break;default:throw g=Error("Cannot encrypt private key. Unknown encryption algorithm."),g.algorithm=d.algorithm,g;}var x=c.pkcs5.pbkdf2(b,g,h,v);b=c.random.getBytesSync(z);h=D(x);h.start(b);h.update(e.toDer(a));h.finish();a=h.output.getBytes();g=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,
2018-08-24 02:55:06 +03:00
e.Type.OID,!1,e.oidToDer(n.pkcs5PBES2).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.pkcs5PBKDF2).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,g),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,k.getBytes())])]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d).getBytes()),e.create(e.Class.UNIVERSAL,
2018-11-15 02:44:28 +03:00
e.Type.OCTETSTRING,!1,b)])])])}else if("3des"===d.algorithm)v=24,d=new c.util.ByteBuffer(g),x=f.pbe.generatePkcs12Key(b,d,1,h,v),b=f.pbe.generatePkcs12Key(b,d,2,h,v),h=c.des.createEncryptionCipher(x),h.start(b),h.update(e.toDer(a)),h.finish(),a=h.output.getBytes(),g=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,
2018-08-24 02:55:06 +03:00
!1,g),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,k.getBytes())])]);else throw g=Error("Cannot encrypt private key. Unknown encryption algorithm."),g.algorithm=d.algorithm,g;return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[g,e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,a)])};f.decryptPrivateKeyInfo=function(a,b){var d=null,g={},k=[];if(!e.validate(a,h,g,k))throw d=Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo."),d.errors=k,d;k=e.derToOid(g.encryptionOid);
k=f.pbe.getCipher(k,g.encryptionParams,b);g=c.util.createBuffer(g.encryptedData);k.update(g);k.finish()&&(d=e.fromDer(k.output));return d};f.encryptedPrivateKeyToPem=function(a,b){var d={type:"ENCRYPTED PRIVATE KEY",body:e.toDer(a).getBytes()};return c.pem.encode(d,{maxline:b})};f.encryptedPrivateKeyFromPem=function(a){a=c.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==a.type){var b=Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');b.headerType=
a.type;throw b;}if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return e.fromDer(a.body)};f.encryptRsaPrivateKey=function(a,b,d){d=d||{};if(!d.legacy)return a=f.wrapRsaPrivateKey(f.privateKeyToAsn1(a)),a=f.encryptPrivateKeyInfo(a,b,d),f.encryptedPrivateKeyToPem(a);var g,h,k;switch(d.algorithm){case "aes128":d="AES-128-CBC";h=16;g=c.random.getBytesSync(16);k=c.aes.createEncryptionCipher;break;case "aes192":d="AES-192-CBC";
h=24;g=c.random.getBytesSync(16);k=c.aes.createEncryptionCipher;break;case "aes256":d="AES-256-CBC";h=32;g=c.random.getBytesSync(16);k=c.aes.createEncryptionCipher;break;case "3des":d="DES-EDE3-CBC";h=24;g=c.random.getBytesSync(8);k=c.des.createEncryptionCipher;break;case "des":d="DES-CBC";h=8;g=c.random.getBytesSync(8);k=c.des.createEncryptionCipher;break;default:throw a=Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+d.algorithm+'".'),a.algorithm=d.algorithm,a;}b=c.pbe.opensslDeriveBytes(b,
g.substr(0,8),h);b=k(b);b.start(g);b.update(e.toDer(f.privateKeyToAsn1(a)));b.finish();a={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:d,parameters:c.util.bytesToHex(g).toUpperCase()},body:b.output.getBytes()};return c.pem.encode(a)};f.decryptRsaPrivateKey=function(a,b){var d=null,g=c.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==g.type&&"PRIVATE KEY"!==g.type&&"RSA PRIVATE KEY"!==g.type)throw d=Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".'),
d.headerType=d,d;if(g.procType&&"ENCRYPTED"===g.procType.type){var h,k;switch(g.dekInfo.algorithm){case "DES-CBC":h=8;k=c.des.createDecryptionCipher;break;case "DES-EDE3-CBC":h=24;k=c.des.createDecryptionCipher;break;case "AES-128-CBC":h=16;k=c.aes.createDecryptionCipher;break;case "AES-192-CBC":h=24;k=c.aes.createDecryptionCipher;break;case "AES-256-CBC":h=32;k=c.aes.createDecryptionCipher;break;case "RC2-40-CBC":h=5;k=function(a){return c.rc2.createDecryptionCipher(a,40)};break;case "RC2-64-CBC":h=
2018-11-15 02:44:28 +03:00
8;k=function(a){return c.rc2.createDecryptionCipher(a,64)};break;case "RC2-128-CBC":h=16;k=function(a){return c.rc2.createDecryptionCipher(a,128)};break;default:throw d=Error('Could not decrypt private key; unsupported encryption algorithm "'+g.dekInfo.algorithm+'".'),d.algorithm=g.dekInfo.algorithm,d;}var n=c.util.hexToBytes(g.dekInfo.parameters);h=c.pbe.opensslDeriveBytes(b,n.substr(0,8),h);k=k(h);k.start(n);k.update(c.util.createBuffer(g.body));if(k.finish())d=k.output.getBytes();else return d}else d=
g.body;d="ENCRYPTED PRIVATE KEY"===g.type?f.decryptPrivateKeyInfo(e.fromDer(d),b):e.fromDer(d);null!==d&&(d=f.privateKeyFromAsn1(d));return d};f.pbe.generatePkcs12Key=function(a,b,d,g,e,h){var f,k;if("undefined"===typeof h||null===h)h=c.md.sha1.create();var n=h.digestLength,v=h.blockLength,u=new c.util.ByteBuffer,p=new c.util.ByteBuffer;if(null!==a&&void 0!==a){for(k=0;k<a.length;k++)p.putInt16(a.charCodeAt(k));p.putInt16(0)}a=p.length();var q=b.length(),r=new c.util.ByteBuffer;r.fillWithByte(d,v);
var E=v*Math.ceil(q/v);d=new c.util.ByteBuffer;for(k=0;k<E;k++)d.putByte(b.at(k%q));E=v*Math.ceil(a/v);b=new c.util.ByteBuffer;for(k=0;k<E;k++)b.putByte(p.at(k%a));p=d;p.putBuffer(b);b=Math.ceil(e/n);for(d=1;d<=b;d++){E=new c.util.ByteBuffer;E.putBytes(r.bytes());E.putBytes(p.bytes());for(k=0;k<g;k++)h.start(),h.update(E.getBytes()),E=h.digest();var B=new c.util.ByteBuffer;for(k=0;k<v;k++)B.putByte(E.at(k%n));var P=Math.ceil(q/v)+Math.ceil(a/v),K=new c.util.ByteBuffer;for(f=0;f<P;f++){var W=new c.util.ByteBuffer(p.getBytes(v)),
U=511;for(k=B.length()-1;0<=k;k--)U>>=8,U+=B.at(k)+W.at(k),W.setAt(k,U&255);K.putBuffer(W)}p=K;u.putBuffer(E)}u.truncate(u.length()-e);return u};f.pbe.getCipher=function(a,c,b){switch(a){case f.oids.pkcs5PBES2:return f.pbe.getCipherForPBES2(a,c,b);case f.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case f.oids["pbewithSHAAnd40BitRC2-CBC"]:return f.pbe.getCipherForPKCS12PBE(a,c,b);default:throw c=Error("Cannot read encrypted PBE data block. Unsupported OID."),c.oid=a,c.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC",
2018-08-24 02:55:06 +03:00
"pbewithSHAAnd40BitRC2-CBC"],c;}};f.pbe.getCipherForPBES2=function(a,b,d){var h={};a=[];if(!e.validate(b,g,h,a)){var k=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");k.errors=a;throw k;}a=e.derToOid(h.kdfOid);if(a!==f.oids.pkcs5PBKDF2)throw k=Error("Cannot read encrypted private key. Unsupported key derivation function OID."),k.oid=a,k.supportedOids=["pkcs5PBKDF2"],k;a=e.derToOid(h.encOid);if(a!==f.oids["aes128-CBC"]&&
2018-10-03 22:03:09 +03:00
a!==f.oids["aes192-CBC"]&&a!==f.oids["aes256-CBC"]&&a!==f.oids["des-EDE3-CBC"]&&a!==f.oids.desCBC)throw k=Error("Cannot read encrypted private key. Unsupported encryption scheme OID."),k.oid=a,k.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],k;b=h.kdfSalt;var v=c.util.createBuffer(h.kdfIterationCount),v=v.getInt(v.length()<<3),n;switch(f.oids[a]){case "aes128-CBC":n=16;k=c.aes.createDecryptionCipher;break;case "aes192-CBC":n=24;k=c.aes.createDecryptionCipher;break;
case "aes256-CBC":n=32;k=c.aes.createDecryptionCipher;break;case "des-EDE3-CBC":n=24;k=c.des.createDecryptionCipher;break;case "desCBC":n=8,k=c.des.createDecryptionCipher}a=c.pkcs5.pbkdf2(d,b,v,n);h=h.encIv;k=k(a);k.start(h);return k};f.pbe.getCipherForPKCS12PBE=function(a,b,d){var g={},h=[];if(!e.validate(b,p,g,h))throw d=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo."),d.errors=h,d;var h=c.util.createBuffer(g.salt),g=c.util.createBuffer(g.iterations),
2018-08-24 02:55:06 +03:00
g=g.getInt(g.length()<<3),k;switch(a){case f.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24;b=8;a=c.des.startDecrypting;break;case f.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5;b=8;a=function(a,b){var d=c.rc2.createDecryptionCipher(a,40);d.start(b,null);return d};break;default:throw d=Error("Cannot read PKCS #12 PBE data block. Unsupported OID."),d.oid=a,d;}k=f.pbe.generatePkcs12Key(d,h,1,g,k);d=f.pbe.generatePkcs12Key(d,h,2,g,b);return a(k,d)};f.pbe.opensslDeriveBytes=function(a,d,g,e){if("undefined"===
2018-10-03 22:03:09 +03:00
typeof e||null===e)e=c.md.md5.create();null===d&&(d="");for(var h=[b(e,a+d)],f=16,n=1;f<g;++n,f+=16)h.push(b(e,h[n-1]+a+d));return h.join("").substr(0,g)}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pbe)return b.pbe;b.defined.pbe=!0;for(var f=
2018-08-24 02:55:06 +03:00
0;f<e.length;++f)e[f](b);return b.pbe}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pbe","require module ./aes ./asn1 ./des ./md ./oids ./pem ./pbkdf2 ./random ./rc2 ./rsa ./util".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=c.asn1,d=c.pkcs7asn1=c.pkcs7asn1||{};c.pkcs7=
c.pkcs7||{};c.pkcs7.asn1=d;c={name:"ContentInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};d.contentInfoValidator=c;var e={name:"EncryptedContentInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",
tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:b.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",
tagClass:b.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};d.envelopedDataValidator={name:"EnvelopedData",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:b.Class.UNIVERSAL,type:b.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(e)};d.encryptedDataValidator={name:"EncryptedData",
tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"version"}].concat(e)};d.signedDataValidator={name:"SignedData",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:b.Class.UNIVERSAL,type:b.Type.SET,constructed:!0,
captureAsn1:"digestAlgorithms"},c,{name:"SignedData.Certificates",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:b.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:b.Class.UNIVERSAL,type:b.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:b.Class.UNIVERSAL,
type:b.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,
value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:b.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,
constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:b.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]};d.recipientInfoValidator={name:"RecipientInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,
constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,
value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:b.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===
typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pkcs7asn1)return b.pkcs7asn1;b.defined.pkcs7asn1=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pkcs7asn1}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pkcs7asn1",
["require","module","./asn1","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.mgf=c.mgf||{};(c.mgf.mgf1=c.mgf1=c.mgf1||{}).create=function(a){return{generate:function(b,d){for(var f=new c.util.ByteBuffer,n=Math.ceil(d/a.digestLength),h=0;h<n;h++){var g=new c.util.ByteBuffer;g.putInt32(h);a.start();a.update(b+g.getBytes());f.putBuffer(a.digest())}f.truncate(f.length()-d);return f.getBytes()}}}}if("function"!==typeof c)if("object"===typeof module&&
module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.mgf1)return b.mgf1;b.defined.mgf1=!0;for(var f=0;f<e.length;++f)e[f](b);return b.mgf1}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,
Array.prototype.slice.call(arguments,0))};c("js/mgf1",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.mgf=c.mgf||{};c.mgf.mgf1=c.mgf1}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||
{};if(b.defined.mgf)return b.mgf;b.defined.mgf=!0;for(var f=0;f<e.length;++f)e[f](b);return b.mgf}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/mgf",["require","module","./mgf1"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){(c.pss=c.pss||{}).create=function(a){3===arguments.length&&
2018-11-15 02:44:28 +03:00
(a={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var b=a.md,d=a.mgf,f=b.digestLength,n=a.salt||null;"string"===typeof n&&(n=c.util.createBuffer(n));var h;if("saltLength"in a)h=a.saltLength;else if(null!==n)h=n.length();else throw Error("Salt length not specified or specific salt not given.");if(null!==n&&n.length()!==h)throw Error("Given salt length does not match length of given salt.");var g=a.prng||c.random;return{encode:function(a,k){var p,w=k-1,r=Math.ceil(w/8),C=a.digest().getBytes();
if(r<f+h+2)throw Error("Message is too long to encrypt.");var A;A=null===n?g.getBytesSync(h):n.bytes();p=new c.util.ByteBuffer;p.fillWithByte(0,8);p.putBytes(C);p.putBytes(A);b.start();b.update(p.getBytes());C=b.digest().getBytes();p=new c.util.ByteBuffer;p.fillWithByte(0,r-h-f-2);p.putByte(1);p.putBytes(A);var L=p.getBytes(),z=r-f-1,D=d.generate(C,z);A="";for(p=0;p<z;p++)A+=String.fromCharCode(L.charCodeAt(p)^D.charCodeAt(p));w=65280>>8*r-w&255;A=String.fromCharCode(A.charCodeAt(0)&~w)+A.substr(1);
return A+C+String.fromCharCode(188)},verify:function(a,g,k){var n;n=k-1;k=Math.ceil(n/8);g=g.substr(-k);if(k<f+h+2)throw Error("Inconsistent parameters to PSS signature verification.");if(188!==g.charCodeAt(k-1))throw Error("Encoded message does not end in 0xBC.");var p=k-f-1,r=g.substr(0,p);g=g.substr(p,f);var A=65280>>8*k-n&255;if(0!==(r.charCodeAt(0)&A))throw Error("Bits beyond keysize not zero as expected.");var B=d.generate(g,p),z="";for(n=0;n<p;n++)z+=String.fromCharCode(r.charCodeAt(n)^B.charCodeAt(n));
z=String.fromCharCode(z.charCodeAt(0)&~A)+z.substr(1);k=k-f-h-2;for(n=0;n<k;n++)if(0!==z.charCodeAt(n))throw Error("Leftmost octets not zero as expected");if(1!==z.charCodeAt(k))throw Error("Inconsistent PSS signature, 0x01 marker not found");k=z.substr(-h);p=new c.util.ByteBuffer;p.fillWithByte(0,8);p.putBytes(a);p.putBytes(k);b.start();b.update(p.getBytes());a=b.digest().getBytes();return g===a}}}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,
2018-08-24 02:55:06 +03:00
module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pss)return b.pss;b.defined.pss=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pss}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pss",
["require","module","./random","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c){"string"===typeof c&&(c={shortName:c});for(var d=null,g,e=0;null===d&&e<a.attributes.length;++e)g=a.attributes[e],c.type&&c.type===g.type?d=g:c.name&&c.name===g.name?d=g:c.shortName&&c.shortName===g.shortName&&(d=g);return d}function d(a){var b=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]),e;a=a.attributes;for(var h=0;h<a.length;++h){e=a[h];
var f=e.value,k=g.Type.PRINTABLESTRING;"valueTagClass"in e&&(k=e.valueTagClass,k===g.Type.UTF8&&(f=c.util.encodeUtf8(f)));e=g.create(g.Class.UNIVERSAL,g.Type.SET,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(e.type).getBytes()),g.create(g.Class.UNIVERSAL,k,!1,f)])]);b.value.push(e)}return b}function e(a){for(var c,b=0;b<a.length;++b){c=a[b];"undefined"===typeof c.name&&(c.type&&c.type in p.oids?c.name=p.oids[c.type]:c.shortName&&c.shortName in
r&&(c.name=p.oids[r[c.shortName]]));if("undefined"===typeof c.type)if(c.name&&c.name in p.oids)c.type=p.oids[c.name];else throw a=Error("Attribute type not specified."),a.attribute=c,a;"undefined"===typeof c.shortName&&c.name&&c.name in r&&(c.shortName=r[c.name]);if(c.type===m.extensionRequest&&(c.valueConstructed=!0,c.valueTagClass=g.Type.SEQUENCE,!c.value&&c.extensions)){c.value=[];for(var d=0;d<c.extensions.length;++d)c.value.push(p.certificateExtensionToAsn1(f(c.extensions[d])))}if("undefined"===
typeof c.value)throw a=Error("Attribute value not specified."),a.attribute=c,a;}}function f(a,b){b=b||{};"undefined"===typeof a.name&&a.id&&a.id in p.oids&&(a.name=p.oids[a.id]);if("undefined"===typeof a.id)if(a.name&&a.name in p.oids)a.id=p.oids[a.name];else{var d=Error("Extension ID not specified.");d.extension=a;throw d;}if("undefined"!==typeof a.value)return a;if("keyUsage"===a.name){var e=d=0,h=0;a.digitalSignature&&(e|=128,d=7);a.nonRepudiation&&(e|=64,d=6);a.keyEncipherment&&(e|=32,d=5);a.dataEncipherment&&
(e|=16,d=4);a.keyAgreement&&(e|=8,d=3);a.keyCertSign&&(e|=4,d=2);a.cRLSign&&(e|=2,d=1);a.encipherOnly&&(e|=1,d=0);a.decipherOnly&&(h|=128,d=7);d=String.fromCharCode(d);0!==h?d+=String.fromCharCode(e)+String.fromCharCode(h):0!==e&&(d+=String.fromCharCode(e));a.value=g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,!1,d)}else if("basicConstraints"===a.name)a.value=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]),a.cA&&a.value.value.push(g.create(g.Class.UNIVERSAL,g.Type.BOOLEAN,!1,String.fromCharCode(255))),
"pathLenConstraint"in a&&a.value.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(a.pathLenConstraint).getBytes()));else if("extKeyUsage"===a.name)for(e in a.value=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]),d=a.value.value,a)!0===a[e]&&(e in m?d.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m[e]).getBytes())):-1!==e.indexOf(".")&&d.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(e).getBytes())));else if("nsCertType"===a.name)e=d=0,a.client&&(e|=128,
d=7),a.server&&(e|=64,d=6),a.email&&(e|=32,d=5),a.objsign&&(e|=16,d=4),a.reserved&&(e|=8,d=3),a.sslCA&&(e|=4,d=2),a.emailCA&&(e|=2,d=1),a.objCA&&(e|=1,d=0),d=String.fromCharCode(d),0!==e&&(d+=String.fromCharCode(e)),a.value=g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,!1,d);else if("subjectAltName"===a.name||"issuerAltName"===a.name)for(a.value=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]),h=0;h<a.altNames.length;++h){e=a.altNames[h];d=e.value;if(7===e.type&&e.ip){if(d=c.util.bytesFromIP(e.ip),
null===d)throw d=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.'),d.extension=a,d;}else 8===e.type&&(d=e.oid?g.oidToDer(g.oidToDer(e.oid)):g.oidToDer(d));a.value.value.push(g.create(g.Class.CONTEXT_SPECIFIC,e.type,!1,d))}else"subjectKeyIdentifier"===a.name&&b.cert&&(d=b.cert.generateSubjectKeyIdentifier(),a.subjectKeyIdentifier=d.toHex(),a.value=g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,d.getBytes()));if("undefined"===typeof a.value)throw d=Error("Extension value not specified."),
d.extension=a,d;return a}function n(a,c){switch(a){case m["RSASSA-PSS"]:var b=[];void 0!==c.hash.algorithmOid&&b.push(g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(c.hash.algorithmOid).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])]));void 0!==c.mgf.algorithmOid&&b.push(g.create(g.Class.CONTEXT_SPECIFIC,1,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,
!1,g.oidToDer(c.mgf.algorithmOid).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(c.mgf.hash.algorithmOid).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])])]));void 0!==c.saltLength&&b.push(g.create(g.Class.CONTEXT_SPECIFIC,2,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(c.saltLength).getBytes())]));return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,b);default:return g.create(g.Class.UNIVERSAL,g.Type.NULL,
!1,"")}}function h(a){var b=g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===a.attributes.length)return b;a=a.attributes;for(var d=0;d<a.length;++d){var e=a[d],h=e.value,f=g.Type.UTF8;"valueTagClass"in e&&(f=e.valueTagClass);f===g.Type.UTF8&&(h=c.util.encodeUtf8(h));var k=!1;"valueConstructed"in e&&(k=e.valueConstructed);e=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(e.type).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SET,!0,[g.create(g.Class.UNIVERSAL,
2018-11-15 02:44:28 +03:00
f,k,h)])]);b.value.push(e)}return b}var g=c.asn1,p=c.pki=c.pki||{},m=p.oids,r={};r.CN=m.commonName;r.commonName="CN";r.C=m.countryName;r.countryName="C";r.L=m.localityName;r.localityName="L";r.ST=m.stateOrProvinceName;r.stateOrProvinceName="ST";r.O=m.organizationName;r.organizationName="O";r.OU=m.organizationalUnitName;r.organizationalUnitName="OU";r.E=m.emailAddress;r.emailAddress="E";var w=c.pki.rsa.publicKeyValidator,y={name:"Certificate",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,
2018-08-24 02:55:06 +03:00
value:[{name:"Certificate.TBSCertificate",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:g.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,
capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:g.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,
constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:g.Class.UNIVERSAL,type:g.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:g.Class.UNIVERSAL,type:g.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},
2018-11-15 02:44:28 +03:00
{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:g.Class.UNIVERSAL,type:g.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:g.Class.UNIVERSAL,type:g.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},w,{name:"Certificate.TBSCertificate.issuerUniqueID",
2018-08-24 02:55:06 +03:00
tagClass:g.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:g.Class.UNIVERSAL,type:g.Type.BITSTRING,constructed:!1,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:g.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:g.Class.UNIVERSAL,type:g.Type.BITSTRING,constructed:!1,capture:"certSubjectUniqueId"}]},
{name:"Certificate.TBSCertificate.extensions",tagClass:g.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:g.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},
2018-11-15 02:44:28 +03:00
{name:"Certificate.signatureValue",tagClass:g.Class.UNIVERSAL,type:g.Type.BITSTRING,constructed:!1,capture:"certSignature"}]},C={name:"rsapss",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:g.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:g.Class.UNIVERSAL,type:g.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,
2018-08-24 02:55:06 +03:00
type:g.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:g.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:g.Class.UNIVERSAL,type:g.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:g.Class.UNIVERSAL,
type:g.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:g.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:g.Class.UNIVERSAL,type:g.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:g.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",
tagClass:g.Class.UNIVERSAL,type:g.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},A={name:"CertificationRequest",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",
2018-11-15 02:44:28 +03:00
tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},w,{name:"CertificationRequestInfo.attributes",tagClass:g.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",
2018-08-24 02:55:06 +03:00
tagClass:g.Class.UNIVERSAL,type:g.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:g.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:g.Class.UNIVERSAL,
type:g.Type.BITSTRING,constructed:!1,capture:"csrSignature"}]};p.RDNAttributesAsArray=function(a,c){for(var b=[],d,e,h,l=0;l<a.value.length;++l){d=a.value[l];for(var f=0;f<d.value.length;++f)h={},e=d.value[f],h.type=g.derToOid(e.value[0].value),h.value=e.value[1].value,h.valueTagClass=e.value[1].type,h.type in m&&(h.name=m[h.type],h.name in r&&(h.shortName=r[h.name])),c&&(c.update(h.type),c.update(h.value)),b.push(h)}return b};p.CRIAttributesAsArray=function(a){for(var c=[],b=0;b<a.length;++b)for(var d=
2018-11-15 02:44:28 +03:00
a[b],e=g.derToOid(d.value[0].value),d=d.value[1].value,h=0;h<d.length;++h){var l={};l.type=e;l.value=d[h].value;l.valueTagClass=d[h].type;l.type in m&&(l.name=m[l.type],l.name in r&&(l.shortName=r[l.name]));if(l.type===m.extensionRequest){l.extensions=[];for(var f=0;f<l.value.length;++f)l.extensions.push(p.certificateExtensionFromAsn1(l.value[f]))}c.push(l)}return c};var L=function(a,c,b){var d={};if(a!==m["RSASSA-PSS"])return d;b&&(d={hash:{algorithmOid:m.sha1},mgf:{algorithmOid:m.mgf1,hash:{algorithmOid:m.sha1}},
saltLength:20});b={};a=[];if(!g.validate(c,C,b,a))throw c=Error("Cannot read RSASSA-PSS parameter block."),c.errors=a,c;void 0!==b.hashOid&&(d.hash=d.hash||{},d.hash.algorithmOid=g.derToOid(b.hashOid));void 0!==b.maskGenOid&&(d.mgf=d.mgf||{},d.mgf.algorithmOid=g.derToOid(b.maskGenOid),d.mgf.hash=d.mgf.hash||{},d.mgf.hash.algorithmOid=g.derToOid(b.maskGenHashOid));void 0!==b.saltLength&&(d.saltLength=b.saltLength.charCodeAt(0));return d};p.certificateFromPem=function(a,b,d){a=c.pem.decode(a)[0];if("CERTIFICATE"!==
2018-08-24 02:55:06 +03:00
a.type&&"X509 CERTIFICATE"!==a.type&&"TRUSTED CERTIFICATE"!==a.type)throw b=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".'),b.headerType=a.type,b;if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert certificate from PEM; PEM is encrypted.");d=g.fromDer(a.body,d);return p.certificateFromAsn1(d,b)};p.certificateToPem=function(a,b){var d={type:"CERTIFICATE",body:g.toDer(p.certificateToAsn1(a)).getBytes()};
return c.pem.encode(d,{maxline:b})};p.publicKeyFromPem=function(a){a=c.pem.decode(a)[0];if("PUBLIC KEY"!==a.type&&"RSA PUBLIC KEY"!==a.type){var b=Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');b.headerType=a.type;throw b;}if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert public key from PEM; PEM is encrypted.");a=g.fromDer(a.body);return p.publicKeyFromAsn1(a)};p.publicKeyToPem=function(a,b){var d={type:"PUBLIC KEY",
body:g.toDer(p.publicKeyToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.publicKeyToRSAPublicKeyPem=function(a,b){var d={type:"RSA PUBLIC KEY",body:g.toDer(p.publicKeyToRSAPublicKey(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.getPublicKeyFingerprint=function(a,b){b=b||{};var d=b.md||c.md.sha1.create(),e;switch(b.type||"RSAPublicKey"){case "RSAPublicKey":e=g.toDer(p.publicKeyToRSAPublicKey(a)).getBytes();break;case "SubjectPublicKeyInfo":e=g.toDer(p.publicKeyToAsn1(a)).getBytes();
break;default:throw Error('Unknown fingerprint type "'+b.type+'".');}d.start();d.update(e);d=d.digest();if("hex"===b.encoding)return d=d.toHex(),b.delimiter?d.match(/.{2}/g).join(b.delimiter):d;if("binary"===b.encoding)return d.getBytes();if(b.encoding)throw Error('Unknown encoding "'+b.encoding+'".');return d};p.certificationRequestFromPem=function(a,b,d){a=c.pem.decode(a)[0];if("CERTIFICATE REQUEST"!==a.type)throw b=Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".'),
b.headerType=a.type,b;if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert certification request from PEM; PEM is encrypted.");d=g.fromDer(a.body,d);return p.certificationRequestFromAsn1(d,b)};p.certificationRequestToPem=function(a,b){var d={type:"CERTIFICATE REQUEST",body:g.toDer(p.certificationRequestToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};p.createCertificate=function(){var a={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};a.siginfo.algorithmOid=
null;a.validity={};a.validity.notBefore=new Date;a.validity.notAfter=new Date;a.issuer={};a.issuer.getField=function(c){return b(a.issuer,c)};a.issuer.addField=function(c){e([c]);a.issuer.attributes.push(c)};a.issuer.attributes=[];a.issuer.hash=null;a.subject={};a.subject.getField=function(c){return b(a.subject,c)};a.subject.addField=function(c){e([c]);a.subject.attributes.push(c)};a.subject.attributes=[];a.subject.hash=null;a.extensions=[];a.publicKey=null;a.md=null;a.setSubject=function(c,b){e(c);
a.subject.attributes=c;delete a.subject.uniqueId;b&&(a.subject.uniqueId=b);a.subject.hash=null};a.setIssuer=function(c,b){e(c);a.issuer.attributes=c;delete a.issuer.uniqueId;b&&(a.issuer.uniqueId=b);a.issuer.hash=null};a.setExtensions=function(c){for(var b=0;b<c.length;++b)f(c[b],{cert:a});a.extensions=c};a.getExtension=function(c){"string"===typeof c&&(c={name:c});for(var b=null,d,e=0;null===b&&e<a.extensions.length;++e)d=a.extensions[e],c.id&&d.id===c.id?b=d:c.name&&d.name===c.name&&(b=d);return b};
a.sign=function(b,d){a.md=d||c.md.sha1.create();var e=m[a.md.algorithm+"WithRSAEncryption"];if(!e)throw e=Error("Could not compute certificate digest. Unknown message digest algorithm OID."),e.algorithm=a.md.algorithm,e;a.signatureOid=a.siginfo.algorithmOid=e;a.tbsCertificate=p.getTBSCertificate(a);e=g.toDer(a.tbsCertificate);a.md.update(e.getBytes());a.signature=b.sign(a.md)};a.verify=function(b){var d=!1;if(!a.issued(b)){var d=a.subject,e=Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");
e.expectedIssuer=b.issuer.attributes;e.actualIssuer=d.attributes;throw e;}e=b.md;if(null===e){if(b.signatureOid in m)switch(m[b.signatureOid]){case "sha1WithRSAEncryption":e=c.md.sha1.create();break;case "md5WithRSAEncryption":e=c.md.md5.create();break;case "sha256WithRSAEncryption":e=c.md.sha256.create();break;case "sha512WithRSAEncryption":e=c.md.sha512.create();break;case "RSASSA-PSS":e=c.md.sha256.create()}if(null===e)throw e=Error("Could not compute certificate digest. Unknown signature OID."),
e.signatureOid=b.signatureOid,e;var h=b.tbsCertificate||p.getTBSCertificate(b),h=g.toDer(h);e.update(h.getBytes())}if(null!==e){var f;switch(b.signatureOid){case m.sha1WithRSAEncryption:f=void 0;break;case m["RSASSA-PSS"]:d=m[b.signatureParameters.mgf.hash.algorithmOid];if(void 0===d||void 0===c.md[d])throw e=Error("Unsupported MGF hash function."),e.oid=b.signatureParameters.mgf.hash.algorithmOid,e.name=d,e;f=m[b.signatureParameters.mgf.algorithmOid];if(void 0===f||void 0===c.mgf[f])throw e=Error("Unsupported MGF function."),
e.oid=b.signatureParameters.mgf.algorithmOid,e.name=f,e;f=c.mgf[f].create(c.md[d].create());d=m[b.signatureParameters.hash.algorithmOid];if(void 0===d||void 0===c.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:b.signatureParameters.hash.algorithmOid,name:d};f=c.pss.create(c.md[d].create(),f,b.signatureParameters.saltLength)}d=a.publicKey.verify(e.digest().getBytes(),b.signature,f)}return d};a.isIssuer=function(c){var b=!1,d=a.issuer;c=c.subject;if(d.hash&&c.hash)b=d.hash===c.hash;
else if(d.attributes.length===c.attributes.length)for(var b=!0,e,g,h=0;b&&h<d.attributes.length;++h)if(e=d.attributes[h],g=c.attributes[h],e.type!==g.type||e.value!==g.value)b=!1;return b};a.issued=function(c){return c.isIssuer(a)};a.generateSubjectKeyIdentifier=function(){return p.getPublicKeyFingerprint(a.publicKey,{type:"RSAPublicKey"})};a.verifySubjectKeyIdentifier=function(){for(var b=m.subjectKeyIdentifier,d=0;d<a.extensions.length;++d){var e=a.extensions[d];if(e.id===b)return b=a.generateSubjectKeyIdentifier().getBytes(),
2018-11-15 02:44:28 +03:00
c.util.hexToBytes(e.subjectKeyIdentifier)===b}return!1};return a};p.certificateFromAsn1=function(a,d){var h={},f=[];if(!g.validate(a,y,h,f))throw h=Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate."),h.errors=f,h;if("string"!==typeof h.certSignature){for(var f="\x00",n=0;n<h.certSignature.length;++n)f+=g.toDer(h.certSignature[n]).getBytes();h.certSignature=f}f=g.derToOid(h.publicKeyOid);if(f!==p.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");
var q=p.createCertificate();q.version=h.certVersion?h.certVersion.charCodeAt(0):0;f=c.util.createBuffer(h.certSerialNumber);q.serialNumber=f.toHex();q.signatureOid=c.asn1.derToOid(h.certSignatureOid);q.signatureParameters=L(q.signatureOid,h.certSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(h.certinfoSignatureOid);q.siginfo.parameters=L(q.siginfo.algorithmOid,h.certinfoSignatureParams,!1);f=c.util.createBuffer(h.certSignature);++f.read;q.signature=f.getBytes();f=[];void 0!==h.certValidity1UTCTime&&
2018-08-24 02:55:06 +03:00
f.push(g.utcTimeToDate(h.certValidity1UTCTime));void 0!==h.certValidity2GeneralizedTime&&f.push(g.generalizedTimeToDate(h.certValidity2GeneralizedTime));void 0!==h.certValidity3UTCTime&&f.push(g.utcTimeToDate(h.certValidity3UTCTime));void 0!==h.certValidity4GeneralizedTime&&f.push(g.generalizedTimeToDate(h.certValidity4GeneralizedTime));if(2<f.length)throw Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(2>f.length)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");
q.validity.notBefore=f[0];q.validity.notAfter=f[1];q.tbsCertificate=h.tbsCertificate;if(d){q.md=null;if(q.signatureOid in m)switch(f=m[q.signatureOid],f){case "sha1WithRSAEncryption":q.md=c.md.sha1.create();break;case "md5WithRSAEncryption":q.md=c.md.md5.create();break;case "sha256WithRSAEncryption":q.md=c.md.sha256.create();break;case "sha512WithRSAEncryption":q.md=c.md.sha512.create();break;case "RSASSA-PSS":q.md=c.md.sha256.create()}if(null===q.md)throw h=Error("Could not compute certificate digest. Unknown signature OID."),
h.signatureOid=q.signatureOid,h;f=g.toDer(q.tbsCertificate);q.md.update(f.getBytes())}f=c.md.sha1.create();q.issuer.getField=function(a){return b(q.issuer,a)};q.issuer.addField=function(a){e([a]);q.issuer.attributes.push(a)};q.issuer.attributes=p.RDNAttributesAsArray(h.certIssuer,f);h.certIssuerUniqueId&&(q.issuer.uniqueId=h.certIssuerUniqueId);q.issuer.hash=f.digest().toHex();f=c.md.sha1.create();q.subject.getField=function(a){return b(q.subject,a)};q.subject.addField=function(a){e([a]);q.subject.attributes.push(a)};
q.subject.attributes=p.RDNAttributesAsArray(h.certSubject,f);h.certSubjectUniqueId&&(q.subject.uniqueId=h.certSubjectUniqueId);q.subject.hash=f.digest().toHex();q.extensions=h.certExtensions?p.certificateExtensionsFromAsn1(h.certExtensions):[];q.publicKey=p.publicKeyFromAsn1(h.subjectPublicKeyInfo);return q};p.certificateExtensionsFromAsn1=function(a){for(var c=[],b=0;b<a.value.length;++b)for(var d=a.value[b],e=0;e<d.value.length;++e)c.push(p.certificateExtensionFromAsn1(d.value[e]));return c};p.certificateExtensionFromAsn1=
function(a){var b={};b.id=g.derToOid(a.value[0].value);b.critical=!1;a.value[1].type===g.Type.BOOLEAN?(b.critical=0!==a.value[1].value.charCodeAt(0),b.value=a.value[2].value):b.value=a.value[1].value;if(b.id in m)if(b.name=m[b.id],"keyUsage"===b.name){a=g.fromDer(b.value);var d=0,e=0;1<a.value.length&&(d=a.value.charCodeAt(1),e=2<a.value.length?a.value.charCodeAt(2):0);b.digitalSignature=128===(d&128);b.nonRepudiation=64===(d&64);b.keyEncipherment=32===(d&32);b.dataEncipherment=16===(d&16);b.keyAgreement=
8===(d&8);b.keyCertSign=4===(d&4);b.cRLSign=2===(d&2);b.encipherOnly=1===(d&1);b.decipherOnly=128===(e&128)}else if("basicConstraints"===b.name)a=g.fromDer(b.value),b.cA=0<a.value.length&&a.value[0].type===g.Type.BOOLEAN?0!==a.value[0].value.charCodeAt(0):!1,d=null,0<a.value.length&&a.value[0].type===g.Type.INTEGER?d=a.value[0].value:1<a.value.length&&(d=a.value[1].value),null!==d&&(b.pathLenConstraint=g.derToInteger(d));else if("extKeyUsage"===b.name)for(a=g.fromDer(b.value),d=0;d<a.value.length;++d)e=
g.derToOid(a.value[d].value),e in m?b[m[e]]=!0:b[e]=!0;else if("nsCertType"===b.name)a=g.fromDer(b.value),d=0,1<a.value.length&&(d=a.value.charCodeAt(1)),b.client=128===(d&128),b.server=64===(d&64),b.email=32===(d&32),b.objsign=16===(d&16),b.reserved=8===(d&8),b.sslCA=4===(d&4),b.emailCA=2===(d&2),b.objCA=1===(d&1);else if("subjectAltName"===b.name||"issuerAltName"===b.name)for(b.altNames=[],a=g.fromDer(b.value),e=0;e<a.value.length;++e){var d=a.value[e],h={type:d.type,value:d.value};b.altNames.push(h);
switch(d.type){case 7:h.ip=c.util.bytesToIP(d.value);break;case 8:h.oid=g.derToOid(d.value)}}else"subjectKeyIdentifier"===b.name&&(a=g.fromDer(b.value),b.subjectKeyIdentifier=c.util.bytesToHex(a.value));return b};p.certificationRequestFromAsn1=function(a,d){var h={},f=[];if(!g.validate(a,A,h,f))throw h=Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest."),h.errors=f,h;if("string"!==typeof h.csrSignature){for(var f="\x00",n=0;n<h.csrSignature.length;++n)f+=
2018-11-15 02:44:28 +03:00
g.toDer(h.csrSignature[n]).getBytes();h.csrSignature=f}f=g.derToOid(h.publicKeyOid);if(f!==p.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var q=p.createCertificationRequest();q.version=h.csrVersion?h.csrVersion.charCodeAt(0):0;q.signatureOid=c.asn1.derToOid(h.csrSignatureOid);q.signatureParameters=L(q.signatureOid,h.csrSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(h.csrSignatureOid);q.siginfo.parameters=L(q.siginfo.algorithmOid,h.csrSignatureParams,!1);f=
2018-08-24 02:55:06 +03:00
c.util.createBuffer(h.csrSignature);++f.read;q.signature=f.getBytes();q.certificationRequestInfo=h.certificationRequestInfo;if(d){q.md=null;if(q.signatureOid in m)switch(f=m[q.signatureOid],f){case "sha1WithRSAEncryption":q.md=c.md.sha1.create();break;case "md5WithRSAEncryption":q.md=c.md.md5.create();break;case "sha256WithRSAEncryption":q.md=c.md.sha256.create();break;case "sha512WithRSAEncryption":q.md=c.md.sha512.create();break;case "RSASSA-PSS":q.md=c.md.sha256.create()}if(null===q.md)throw h=
Error("Could not compute certification request digest. Unknown signature OID."),h.signatureOid=q.signatureOid,h;f=g.toDer(q.certificationRequestInfo);q.md.update(f.getBytes())}f=c.md.sha1.create();q.subject.getField=function(a){return b(q.subject,a)};q.subject.addField=function(a){e([a]);q.subject.attributes.push(a)};q.subject.attributes=p.RDNAttributesAsArray(h.certificationRequestInfoSubject,f);q.subject.hash=f.digest().toHex();q.publicKey=p.publicKeyFromAsn1(h.subjectPublicKeyInfo);q.getAttribute=
function(a){return b(q,a)};q.addAttribute=function(a){e([a]);q.attributes.push(a)};q.attributes=p.CRIAttributesAsArray(h.certificationRequestInfoAttributes||[]);return q};p.createCertificationRequest=function(){var a={version:0,signatureOid:null,signature:null,siginfo:{}};a.siginfo.algorithmOid=null;a.subject={};a.subject.getField=function(c){return b(a.subject,c)};a.subject.addField=function(c){e([c]);a.subject.attributes.push(c)};a.subject.attributes=[];a.subject.hash=null;a.publicKey=null;a.attributes=
[];a.getAttribute=function(c){return b(a,c)};a.addAttribute=function(c){e([c]);a.attributes.push(c)};a.md=null;a.setSubject=function(c){e(c);a.subject.attributes=c;a.subject.hash=null};a.setAttributes=function(c){e(c);a.attributes=c};a.sign=function(b,d){a.md=d||c.md.sha1.create();var e=m[a.md.algorithm+"WithRSAEncryption"];if(!e)throw e=Error("Could not compute certification request digest. Unknown message digest algorithm OID."),e.algorithm=a.md.algorithm,e;a.signatureOid=a.siginfo.algorithmOid=
e;a.certificationRequestInfo=p.getCertificationRequestInfo(a);e=g.toDer(a.certificationRequestInfo);a.md.update(e.getBytes());a.signature=b.sign(a.md)};a.verify=function(){var b=!1,d=a.md;if(null===d){if(a.signatureOid in m)switch(m[a.signatureOid]){case "sha1WithRSAEncryption":d=c.md.sha1.create();break;case "md5WithRSAEncryption":d=c.md.md5.create();break;case "sha256WithRSAEncryption":d=c.md.sha256.create();break;case "sha512WithRSAEncryption":d=c.md.sha512.create();break;case "RSASSA-PSS":d=c.md.sha256.create()}if(null===
d)throw d=Error("Could not compute certification request digest. Unknown signature OID."),d.signatureOid=a.signatureOid,d;var e=a.certificationRequestInfo||p.getCertificationRequestInfo(a),e=g.toDer(e);d.update(e.getBytes())}if(null!==d){var h;switch(a.signatureOid){case m["RSASSA-PSS"]:b=m[a.signatureParameters.mgf.hash.algorithmOid];if(void 0===b||void 0===c.md[b])throw d=Error("Unsupported MGF hash function."),d.oid=a.signatureParameters.mgf.hash.algorithmOid,d.name=b,d;h=m[a.signatureParameters.mgf.algorithmOid];
if(void 0===h||void 0===c.mgf[h])throw d=Error("Unsupported MGF function."),d.oid=a.signatureParameters.mgf.algorithmOid,d.name=h,d;h=c.mgf[h].create(c.md[b].create());b=m[a.signatureParameters.hash.algorithmOid];if(void 0===b||void 0===c.md[b])throw d=Error("Unsupported RSASSA-PSS hash function."),d.oid=a.signatureParameters.hash.algorithmOid,d.name=b,d;h=c.pss.create(c.md[b].create(),h,a.signatureParameters.saltLength)}b=a.publicKey.verify(d.digest().getBytes(),a.signature,h)}return b};return a};
p.getTBSCertificate=function(a){var b=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(a.version).getBytes())]),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,c.util.hexToBytes(a.serialNumber)),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(a.siginfo.algorithmOid).getBytes()),n(a.siginfo.algorithmOid,a.siginfo.parameters)]),d(a.issuer),g.create(g.Class.UNIVERSAL,
g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.UTCTIME,!1,g.dateToUtcTime(a.validity.notBefore)),g.create(g.Class.UNIVERSAL,g.Type.UTCTIME,!1,g.dateToUtcTime(a.validity.notAfter))]),d(a.subject),p.publicKeyToAsn1(a.publicKey)]);a.issuer.uniqueId&&b.value.push(g.create(g.Class.CONTEXT_SPECIFIC,1,!0,[g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,!1,String.fromCharCode(0)+a.issuer.uniqueId)]));a.subject.uniqueId&&b.value.push(g.create(g.Class.CONTEXT_SPECIFIC,2,!0,[g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,
!1,String.fromCharCode(0)+a.subject.uniqueId)]));0<a.extensions.length&&b.value.push(p.certificateExtensionsToAsn1(a.extensions));return b};p.getCertificationRequestInfo=function(a){return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(a.version).getBytes()),d(a.subject),p.publicKeyToAsn1(a.publicKey),h(a)])};p.distinguishedNameToAsn1=function(a){return d(a)};p.certificateToAsn1=function(a){var c=a.tbsCertificate||p.getTBSCertificate(a);
return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[c,g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(a.signatureOid).getBytes()),n(a.signatureOid,a.signatureParameters)]),g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,!1,String.fromCharCode(0)+a.signature)])};p.certificateExtensionsToAsn1=function(a){var c=g.create(g.Class.CONTEXT_SPECIFIC,3,!0,[]),b=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]);c.value.push(b);for(var d=0;d<a.length;++d)b.value.push(p.certificateExtensionToAsn1(a[d]));
return c};p.certificateExtensionToAsn1=function(a){var c=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[]);c.value.push(g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(a.id).getBytes()));a.critical&&c.value.push(g.create(g.Class.UNIVERSAL,g.Type.BOOLEAN,!1,String.fromCharCode(255)));var b=a.value;"string"!==typeof a.value&&(b=g.toDer(b).getBytes());c.value.push(g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,b));return c};p.certificationRequestToAsn1=function(a){var c=a.certificationRequestInfo||
p.getCertificationRequestInfo(a);return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[c,g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(a.signatureOid).getBytes()),n(a.signatureOid,a.signatureParameters)]),g.create(g.Class.UNIVERSAL,g.Type.BITSTRING,!1,String.fromCharCode(0)+a.signature)])};p.createCaStore=function(a){function b(a){if(!a.hash){var h=c.md.sha1.create();a.attributes=p.RDNAttributesAsArray(d(a),h);a.hash=h.digest().toHex()}return e.certs[a.hash]||
null}var e={certs:{},getIssuer:function(a){return b(a.issuer)},addCertificate:function(a){"string"===typeof a&&(a=c.pki.certificateFromPem(a));if(!a.subject.hash){var b=c.md.sha1.create();a.subject.attributes=p.RDNAttributesAsArray(d(a.subject),b);a.subject.hash=b.digest().toHex()}a.subject.hash in e.certs?(b=e.certs[a.subject.hash],c.util.isArray(b)||(b=[b]),b.push(a)):e.certs[a.subject.hash]=a},hasCertificate:function(a){var d=b(a.subject);if(!d)return!1;c.util.isArray(d)||(d=[d]);a=g.toDer(p.certificateToAsn1(a)).getBytes();
for(var e=0;e<d.length;++e){var h=g.toDer(p.certificateToAsn1(d[e])).getBytes();if(a===h)return!0}return!1}};if(a)for(var h=0;h<a.length;++h)e.addCertificate(a[h]);return e};p.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"};
p.verifyCertificateChain=function(a,b,d){b=b.slice(0);var e=b.slice(0),h=new Date,g=!0,f=null,k=0;do{var m=b.shift(),n=null,u=!1;if(h<m.validity.notBefore||h>m.validity.notAfter)f={message:"Certificate is not valid yet or has expired.",error:p.certificateError.certificate_expired,notBefore:m.validity.notBefore,notAfter:m.validity.notAfter,now:h};if(null===f){n=b[0]||a.getIssuer(m);null===n&&m.isIssuer(m)&&(u=!0,n=m);if(n){var v=n;c.util.isArray(v)||(v=[v]);for(var r=!1;!r&&0<v.length;){n=v.shift();
2018-11-15 02:44:28 +03:00
try{r=n.verify(m)}catch(w){}}r||(f={message:"Certificate signature is invalid.",error:p.certificateError.bad_certificate})}null!==f||n&&!u||a.hasCertificate(m)||(f={message:"Certificate is not trusted.",error:p.certificateError.unknown_ca})}null===f&&n&&!m.isIssuer(n)&&(f={message:"Certificate issuer is invalid.",error:p.certificateError.bad_certificate});if(null===f)for(v={keyUsage:!0,basicConstraints:!0},r=0;null===f&&r<m.extensions.length;++r){var y=m.extensions[r];!y.critical||y.name in v||(f=
2018-08-24 02:55:06 +03:00
{message:"Certificate has an unsupported critical extension.",error:p.certificateError.unsupported_certificate})}null!==f||g&&(0!==b.length||n&&!u)||(g=m.getExtension("basicConstraints"),m=m.getExtension("keyUsage"),null!==m&&(m.keyCertSign&&null!==g||(f={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:p.certificateError.bad_certificate})),
null!==f||null===g||g.cA||(f={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:p.certificateError.bad_certificate}),null===f&&null!==m&&"pathLenConstraint"in g&&k-1>g.pathLenConstraint&&(f={message:"Certificate basicConstraints pathLenConstraint violated.",error:p.certificateError.bad_certificate}));m=null===f?!0:f.error;g=d?d(m,k,e):m;if(!0===g)f=null;else{!0===m&&(f={message:"The application rejected the certificate.",error:p.certificateError.bad_certificate});
if(g||0===g)"object"!==typeof g||c.util.isArray(g)?"string"===typeof g&&(f.error=g):(g.message&&(f.message=g.message),g.error&&(f.error=g.error));throw f;}g=!1;++k}while(0<b.length);return!0}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.x509)return b.x509;
b.defined.x509=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pki}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/x509","require module ./aes ./asn1 ./des ./md ./mgf ./oids ./pem ./pss ./rsa ./util".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,c,d,e){for(var g=
[],h=0;h<a.length;h++)for(var f=0;f<a[h].safeBags.length;f++){var l=a[h].safeBags[f];if(void 0===e||l.type===e)null===c?g.push(l):void 0!==l.attributes[c]&&0<=l.attributes[c].indexOf(d)&&g.push(l)}return g}function d(a){if(a.composed||a.constructed){for(var b=c.util.createBuffer(),e=0;e<a.value.length;++e)b.putBytes(a.value[e].value);a.composed=a.constructed=!1;a.value=b.getBytes()}return a}function e(a,b,e,k){b=h.fromDer(b,e);if(b.tagClass!==h.Class.UNIVERSAL||b.type!==h.Type.SEQUENCE||!0!==b.constructed)throw Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");
2018-11-15 02:44:28 +03:00
for(var n=0;n<b.value.length;n++){var p={},r=[];if(!h.validate(b.value[n],m,p,r))throw a=Error("Cannot read ContentInfo."),a.errors=r,a;var r={encrypted:!1},q=null,q=p.content.value[0];switch(h.derToOid(p.contentType)){case g.oids.data:if(q.tagClass!==h.Class.UNIVERSAL||q.type!==h.Type.OCTETSTRING)throw Error("PKCS#12 SafeContents Data is not an OCTET STRING.");q=d(q).value;break;case g.oids.encryptedData:var w=k,p={},y=[];if(!h.validate(q,c.pkcs7.asn1.encryptedDataValidator,p,y))throw a=Error("Cannot read EncryptedContentInfo."),
a.errors=y,a;q=h.derToOid(p.contentType);if(q!==g.oids.data)throw a=Error("PKCS#12 EncryptedContentInfo ContentType is not Data."),a.oid=q,a;q=h.derToOid(p.encAlgorithm);q=g.pbe.getCipher(q,p.encParameter,w);p=d(p.encryptedContentAsn1);p=c.util.createBuffer(p.value);q.update(p);if(!q.finish())throw Error("Failed to decrypt PKCS#12 SafeContents.");q=q.output.getBytes();r.encrypted=!0;break;default:throw a=Error("Unsupported PKCS#12 contentType."),a.contentType=h.derToOid(p.contentType),a;}r.safeBags=
f(q,e,k);a.safeContents.push(r)}}function f(a,c,b){if(!c&&0===a.length)return[];a=h.fromDer(a,c);if(a.tagClass!==h.Class.UNIVERSAL||a.type!==h.Type.SEQUENCE||!0!==a.constructed)throw Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var d=[],e=0;e<a.value.length;e++){var l={},k=[];if(!h.validate(a.value[e],w,l,k))throw a=Error("Cannot read SafeBag."),a.errors=k,a;var m={type:h.derToOid(l.bagId),attributes:n(l.bagAttributes)};d.push(m);var p,u,v=l.bagValue.value[0];switch(m.type){case g.oids.pkcs8ShroudedKeyBag:if(v=
g.decryptPrivateKeyInfo(v,b),null===v)throw Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case g.oids.keyBag:try{m.key=g.privateKeyFromAsn1(v)}catch(r){m.key=null,m.asn1=v}continue;case g.oids.certBag:p=C;u=function(){if(h.derToOid(l.certId)!==g.oids.x509Certificate){var a=Error("Unsupported certificate type, only X.509 supported.");a.oid=h.derToOid(l.certId);throw a;}a=h.fromDer(l.cert,c);try{m.cert=g.certificateFromAsn1(a,!0)}catch(b){m.cert=null,m.asn1=a}};break;default:throw a=
Error("Unsupported PKCS#12 SafeBag type."),a.oid=m.type,a;}if(void 0!==p&&!h.validate(v,p,l,k))throw a=Error("Cannot read PKCS#12 "+p.name),a.errors=k,a;u()}return d}function n(a){var c={};if(void 0!==a)for(var b=0;b<a.length;++b){var d={},e=[];if(!h.validate(a[b],y,d,e))throw a=Error("Cannot read PKCS#12 BagAttribute."),a.errors=e,a;e=h.derToOid(d.oid);if(void 0!==g.oids[e]){c[g.oids[e]]=[];for(var f=0;f<d.values.length;++f)c[g.oids[e]].push(d.values[f].value)}}return c}var h=c.asn1,g=c.pki,p=c.pkcs12=
2018-08-24 02:55:06 +03:00
c.pkcs12||{},m={name:"ContentInfo",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:h.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},r={name:"PFX",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:h.Class.UNIVERSAL,type:h.Type.INTEGER,constructed:!1,capture:"version"},
m,{name:"PFX.macData",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",
2018-11-15 02:44:28 +03:00
tagClass:h.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:h.Class.UNIVERSAL,type:h.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:h.Class.UNIVERSAL,type:h.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:h.Class.UNIVERSAL,type:h.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},w={name:"SafeBag",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,
value:[{name:"SafeBag.bagId",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:h.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:h.Class.UNIVERSAL,type:h.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},y={name:"Attribute",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,
capture:"oid"},{name:"Attribute.attrValues",tagClass:h.Class.UNIVERSAL,type:h.Type.SET,constructed:!0,capture:"values"}]},C={name:"CertBag",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:h.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:h.Class.UNIVERSAL,type:h.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};
2018-10-03 22:03:09 +03:00
p.pkcs12FromAsn1=function(a,f,m){"string"===typeof f?(m=f,f=!0):void 0===f&&(f=!0);var n={};if(!h.validate(a,r,n,[]))throw f=Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX."),f.errors=f,f;var u={version:n.version.charCodeAt(0),safeContents:[],getBags:function(a){var d={},e;"localKeyId"in a?e=a.localKeyId:"localKeyIdHex"in a&&(e=c.util.hexToBytes(a.localKeyIdHex));void 0===e&&!("friendlyName"in a)&&"bagType"in a&&(d[a.bagType]=b(u.safeContents,null,null,a.bagType));void 0!==e&&
(d.localKeyId=b(u.safeContents,"localKeyId",e,a.bagType));"friendlyName"in a&&(d.friendlyName=b(u.safeContents,"friendlyName",a.friendlyName,a.bagType));return d},getBagsByFriendlyName:function(a,c){return b(u.safeContents,"friendlyName",a,c)},getBagsByLocalKeyId:function(a,c){return b(u.safeContents,"localKeyId",a,c)}};if(3!==n.version.charCodeAt(0))throw f=Error("PKCS#12 PFX of version other than 3 not supported."),f.version=n.version.charCodeAt(0),f;if(h.derToOid(n.contentType)!==g.oids.data)throw f=
2018-11-15 02:44:28 +03:00
Error("Only PKCS#12 PFX in password integrity mode supported."),f.oid=h.derToOid(n.contentType),f;a=n.content.value[0];if(a.tagClass!==h.Class.UNIVERSAL||a.type!==h.Type.OCTETSTRING)throw Error("PKCS#12 authSafe content data is not an OCTET STRING.");a=d(a);if(n.mac){var w=null,y=0,q=h.derToOid(n.macAlgorithm);switch(q){case g.oids.sha1:w=c.md.sha1.create();y=20;break;case g.oids.sha256:w=c.md.sha256.create();y=32;break;case g.oids.sha384:w=c.md.sha384.create();y=48;break;case g.oids.sha512:w=c.md.sha512.create();
y=64;break;case g.oids.md5:w=c.md.md5.create(),y=16}if(null===w)throw Error("PKCS#12 uses unsupported MAC algorithm: "+q);var q=new c.util.ByteBuffer(n.macSalt),B="macIterations"in n?parseInt(c.util.bytesToHex(n.macIterations),16):1,y=p.generateKey(m,q,3,B,y,w),q=c.hmac.create();q.start(w,y);q.update(a.value);if(q.getMac().getBytes()!==n.macDigest)throw Error("PKCS#12 MAC could not be verified. Invalid password?");}e(u,a.value,f,m);return u};p.toPkcs12Asn1=function(a,b,d,e){e=e||{};e.saltSize=e.saltSize||
2018-08-24 02:55:06 +03:00
8;e.count=e.count||2048;e.algorithm=e.algorithm||e.encAlgorithm||"aes128";"useMac"in e||(e.useMac=!0);"localKeyId"in e||(e.localKeyId=null);"generateLocalKeyId"in e||(e.generateLocalKeyId=!0);var f=e.localKeyId,k;if(null!==f)f=c.util.hexToBytes(f);else if(e.generateLocalKeyId)if(b){var m=c.util.isArray(b)?b[0]:b;"string"===typeof m&&(m=g.certificateFromPem(m));f=c.md.sha1.create();f.update(h.toDer(g.certificateToAsn1(m)).getBytes());f=f.digest().getBytes()}else f=c.random.getBytes(20);m=[];null!==
f&&m.push(h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.localKeyId).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SET,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,f)])]));"friendlyName"in e&&m.push(h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.friendlyName).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SET,!0,[h.create(h.Class.UNIVERSAL,h.Type.BMPSTRING,!1,e.friendlyName)])]));
0<m.length&&(k=h.create(h.Class.UNIVERSAL,h.Type.SET,!0,m));f=[];m=[];null!==b&&(m=c.util.isArray(b)?b:[b]);for(var n=[],u=0;u<m.length;++u){b=m[u];"string"===typeof b&&(b=g.certificateFromPem(b));var v=0===u?k:void 0;b=g.certificateToAsn1(b);b=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.certBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.x509Certificate).getBytes()),
h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(b).getBytes())])])]),v]);n.push(b)}0<n.length&&(b=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,n),b=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(b).getBytes())])]),f.push(b));b=null;null!==a&&(a=g.wrapRsaPrivateKey(g.privateKeyToAsn1(a)),
b=null===d?h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.keyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[a]),k]):h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.pkcs8ShroudedKeyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[g.encryptPrivateKeyInfo(a,d,e)]),k]),a=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[b]),a=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,
[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(a).getBytes())])]),f.push(a));k=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,f);var r;e.useMac&&(f=c.md.sha1.create(),r=new c.util.ByteBuffer(c.random.getBytes(e.saltSize)),e=e.count,a=p.generateKey(d,r,3,e,20),d=c.hmac.create(),d.start(f,a),d.update(h.toDer(k).getBytes()),d=d.getMac(),r=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,
!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.sha1).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,"")]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,d.getBytes())]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,r.getBytes()),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(e).getBytes())]));return h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,
h.Type.INTEGER,!1,h.integerToDer(3).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(g.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(k).getBytes())])]),r])};p.generateKey=c.pbe.generatePkcs12Key}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,
p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pkcs12)return b.pkcs12;b.defined.pkcs12=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pkcs12}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/pkcs12","require module ./asn1 ./hmac ./oids ./pkcs7asn1 ./pbe ./random ./rsa ./sha1 ./util ./x509".split(" "),
function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=c.asn1,d=c.pki=c.pki||{};d.pemToDer=function(a){a=c.pem.decode(a)[0];if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert PEM to DER; PEM is encrypted.");return c.util.createBuffer(a.body)};d.privateKeyFromPem=function(a){a=c.pem.decode(a)[0];if("PRIVATE KEY"!==a.type&&"RSA PRIVATE KEY"!==a.type){var f=Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
f.headerType=a.type;throw f;}if(a.procType&&"ENCRYPTED"===a.procType.type)throw Error("Could not convert private key from PEM; PEM is encrypted.");a=b.fromDer(a.body);return d.privateKeyFromAsn1(a)};d.privateKeyToPem=function(a,f){var n={type:"RSA PRIVATE KEY",body:b.toDer(d.privateKeyToAsn1(a)).getBytes()};return c.pem.encode(n,{maxline:f})};d.privateKeyInfoToPem=function(a,d){var f={type:"PRIVATE KEY",body:b.toDer(a).getBytes()};return c.pem.encode(f,{maxline:d})}}if("function"!==typeof c)if("object"===
typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pki)return b.pki;b.defined.pki=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pki}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,
Array.prototype.slice.call(arguments,0))};c("js/pki","require module ./asn1 ./oids ./pbe ./pem ./pbkdf2 ./pkcs12 ./pss ./rsa ./util ./x509".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b=function(a,b,d,e){var g=c.util.createBuffer(),h=a.length>>1,f=h+(a.length&1),k=a.substr(0,f),f=a.substr(h,f);a=c.util.createBuffer();h=c.hmac.create();d=b+d;var m=Math.ceil(e/16);b=Math.ceil(e/20);h.start("MD5",k);k=c.util.createBuffer();a.putBytes(d);
for(var n=0;n<m;++n)h.start(null,null),h.update(a.getBytes()),a.putBuffer(h.digest()),h.start(null,null),h.update(a.bytes()+d),k.putBuffer(h.digest());h.start("SHA1",f);f=c.util.createBuffer();a.clear();a.putBytes(d);for(n=0;n<b;++n)h.start(null,null),h.update(a.getBytes()),a.putBuffer(h.digest()),h.start(null,null),h.update(a.bytes()+d),f.putBuffer(h.digest());g.putBytes(c.util.xorBytes(k.getBytes(),f.getBytes(),e));return g},d=function(a,b,d){d=!1;try{var e=a.deflate(b.fragment.getBytes());b.fragment=
c.util.createBuffer(e);b.length=e.length;d=!0}catch(h){}return d},e=function(a,b,d){d=!1;try{var e=a.inflate(b.fragment.getBytes());b.fragment=c.util.createBuffer(e);b.length=e.length;d=!0}catch(h){}return d},f=function(a,b){var d=0;switch(b){case 1:d=a.getByte();break;case 2:d=a.getInt16();break;case 3:d=a.getInt24();break;case 4:d=a.getInt32()}return c.util.createBuffer(a.getBytes(d))},n=function(a,c,b){a.putInt(b.length(),c<<3);a.putBuffer(b)},h={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,
minor:2},TLS_1_2:{major:3,minor:3}}};h.SupportedVersions=[h.Versions.TLS_1_1,h.Versions.TLS_1_0];h.Version=h.SupportedVersions[0];h.MaxFragment=15360;h.ConnectionEnd={server:0,client:1};h.PRFAlgorithm={tls_prf_sha256:0};h.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};h.CipherType={stream:0,block:1,aead:2};h.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};h.CompressionMethod={none:0,deflate:1};h.ContentType={change_cipher_spec:20,alert:21,handshake:22,
application_data:23,heartbeat:24};h.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};h.Alert={};h.Alert.Level={warning:1,fatal:2};h.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};h.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};h.CipherSuites={};h.getCipherSuite=function(a){var c=null,b;for(b in h.CipherSuites){var d=h.CipherSuites[b];if(d.id[0]===a.charCodeAt(0)&&d.id[1]===a.charCodeAt(1)){c=d;break}}return c};
h.handleUnexpected=function(a,c){(a.open||a.entity!==h.ConnectionEnd.client)&&a.error(a,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unexpected_message}})};h.handleHelloRequest=function(a,c,b){!a.handshaking&&0<a.handshakes&&(h.queue(a,h.createAlert(a,{level:h.Alert.Level.warning,description:h.Alert.Description.no_renegotiation})),h.flush(a));a.process()};h.parseHelloMessage=function(a,b,d){var e=null,g=a.entity===
h.ConnectionEnd.client;if(38>d)a.error(a,{message:g?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});else{b=b.fragment;var k=b.length(),e={version:{major:b.getByte(),minor:b.getByte()},random:c.util.createBuffer(b.getBytes(32)),session_id:f(b,1),extensions:[]};g?(e.cipher_suite=b.getBytes(2),e.compression_method=b.getByte()):(e.cipher_suites=f(b,2),e.compression_methods=
f(b,1));k=d-(k-b.length());if(0<k){for(d=f(b,2);0<d.length();)e.extensions.push({type:[d.getByte(),d.getByte()],data:f(d,2)});if(!g)for(d=0;d<e.extensions.length;++d)if(b=e.extensions[d],0===b.type[0]&&0===b.type[1])for(b=f(b.data,2);0<b.length()&&0===b.getByte();)a.session.extensions.server_name.serverNameList.push(f(b,2).getBytes())}if(a.session.version&&(e.version.major!==a.session.version.major||e.version.minor!==a.session.version.minor))return a.error(a,{message:"TLS version change is disallowed during renegotiation.",
send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});if(g)a.session.cipherSuite=h.getCipherSuite(e.cipher_suite);else for(d=c.util.createBuffer(e.cipher_suites.bytes());0<d.length()&&(a.session.cipherSuite=h.getCipherSuite(d.getBytes(2)),null===a.session.cipherSuite););if(null===a.session.cipherSuite)return a.error(a,{message:"No cipher suites in common.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure},cipherSuite:c.util.bytesToHex(e.cipher_suite)});
a.session.compressionMethod=g?e.compression_method:h.CompressionMethod.none}return e};h.createSecurityParameters=function(a,c){var b=a.entity===h.ConnectionEnd.client,d=c.random.bytes(),e=b?a.session.sp.client_random:d,b=b?d:h.createRandom().getBytes();a.session.sp={entity:a.entity,prf_algorithm:h.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:a.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:e,server_random:b}};h.handleServerHello=function(a,c,b){c=h.parseHelloMessage(a,c,b);if(!a.fail){if(c.version.minor<=a.version.minor)a.version.minor=c.version.minor;else return a.error(a,{message:"Incompatible TLS version.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});a.session.version=a.version;b=c.session_id.bytes();0<b.length&&b===a.session.id?
2018-11-15 02:44:28 +03:00
(a.expect=w,a.session.resuming=!0,a.session.sp.server_random=c.random.bytes()):(a.expect=g,a.session.resuming=!1,h.createSecurityParameters(a,c));a.session.id=b;a.process()}};h.handleClientHello=function(a,b,d){b=h.parseHelloMessage(a,b,d);if(!a.fail){var e=b.session_id.bytes();d=null;if(a.sessionCache)if(d=a.sessionCache.getSession(e),null===d)e="";else if(d.version.major!==b.version.major||d.version.minor>b.version.minor)d=null,e="";0===e.length&&(e=c.random.getBytes(32));a.session.id=e;a.session.clientHelloVersion=
b.version;a.session.sp={};if(d)a.version=a.session.version=d.version,a.session.sp=d.sp;else{for(var g,e=1;e<h.SupportedVersions.length&&!(g=h.SupportedVersions[e],g.minor<=b.version.minor);++e);a.version={major:g.major,minor:g.minor};a.session.version=a.version}null!==d?(a.expect=x,a.session.resuming=!0,a.session.sp.client_random=b.random.bytes()):(a.expect=!1!==a.verifyClient?L:z,a.session.resuming=!1,h.createSecurityParameters(a,b));a.open=!0;h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,
2018-08-24 02:55:06 +03:00
data:h.createServerHello(a)}));a.session.resuming?(h.queue(a,h.createRecord(a,{type:h.ContentType.change_cipher_spec,data:h.createChangeCipherSpec()})),a.state.pending=h.createConnectionState(a),a.state.current.write=a.state.pending.write,h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createFinished(a)}))):(h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createCertificate(a)})),a.fail||(h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createServerKeyExchange(a)})),
!1!==a.verifyClient&&h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createCertificateRequest(a)})),h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createServerHelloDone(a)}))));h.flush(a);a.process()}};h.handleCertificate=function(a,b,d){if(3>d)return a.error(a,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});d=f(b.fragment,3);var e,g;b=[];try{for(;0<d.length();)e=
2018-11-15 02:44:28 +03:00
f(d,3),g=c.asn1.fromDer(e),e=c.pki.certificateFromAsn1(g,!0),b.push(e)}catch(k){return a.error(a,{message:"Could not parse certificate list.",cause:k,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}e=a.entity===h.ConnectionEnd.client;!e&&!0!==a.verifyClient||0!==b.length?0===b.length?a.expect=e?p:z:(e?a.session.serverCertificate=b[0]:a.session.clientCertificate=b[0],h.verifyCertificateChain(a,b)&&(a.expect=e?p:z)):a.error(a,{message:e?"No server certificate provided.":
2018-08-24 02:55:06 +03:00
"No client certificate provided.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});a.process()};h.handleServerKeyExchange=function(a,c,b){if(0<b)return a.error(a,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});a.expect=m;a.process()};h.handleClientKeyExchange=function(a,b,d){if(48>d)return a.error(a,{message:"Invalid key parameters. Only RSA is supported.",
send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});b=f(b.fragment,2).getBytes();d=null;if(a.getPrivateKey)try{d=a.getPrivateKey(a,a.session.serverCertificate),d=c.pki.privateKeyFromPem(d)}catch(e){a.error(a,{message:"Could not get private key.",cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}if(null===d)return a.error(a,{message:"No private key set.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});
2018-11-15 02:44:28 +03:00
try{var g=a.session.sp;g.pre_master_secret=d.decrypt(b);var k=a.session.clientHelloVersion;if(k.major!==g.pre_master_secret.charCodeAt(0)||k.minor!==g.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.");}catch(e){g.pre_master_secret=c.random.getBytes(48)}a.expect=x;null!==a.session.clientCertificate&&(a.expect=D);a.process()};h.handleCertificateRequest=function(a,c,b){if(3>b)return a.error(a,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,
2018-08-24 02:55:06 +03:00
description:h.Alert.Description.illegal_parameter}});c=c.fragment;c={certificate_types:f(c,1),certificate_authorities:f(c,2)};a.session.certificateRequest=c;a.expect=r;a.process()};h.handleCertificateVerify=function(a,b,d){if(2>d)return a.error(a,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});d=b.fragment;d.read-=4;b=d.bytes();d.read+=4;d=f(d,2).getBytes();var e=c.util.createBuffer();e.putBuffer(a.session.md5.digest());
2018-11-15 02:44:28 +03:00
e.putBuffer(a.session.sha1.digest());e=e.getBytes();try{if(!a.session.clientCertificate.publicKey.verify(e,d,"NONE"))throw Error("CertificateVerify signature does not match.");a.session.md5.update(b);a.session.sha1.update(b)}catch(g){return a.error(a,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure}})}a.expect=x;a.process()};h.handleServerHelloDone=function(a,b,d){if(0<d)return a.error(a,{message:"Invalid ServerHelloDone message. Invalid length.",
2018-08-24 02:55:06 +03:00
send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.record_overflow}});if(null===a.serverCertificate&&(b={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.insufficient_security}},d=a.verify(a,b.alert.description,0,[]),!0!==d)){if(d||0===d)"object"!==typeof d||c.util.isArray(d)?"number"===typeof d&&(b.alert.description=d):(d.message&&(b.message=d.message),d.alert&&(b.alert.description=d.alert));
return a.error(a,b)}null!==a.session.certificateRequest&&(b=h.createRecord(a,{type:h.ContentType.handshake,data:h.createCertificate(a)}),h.queue(a,b));b=h.createRecord(a,{type:h.ContentType.handshake,data:h.createClientKeyExchange(a)});h.queue(a,b);a.expect=A;b=function(a,c){null!==a.session.certificateRequest&&null!==a.session.clientCertificate&&h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createCertificateVerify(a,c)}));h.queue(a,h.createRecord(a,{type:h.ContentType.change_cipher_spec,
2018-11-15 02:44:28 +03:00
data:h.createChangeCipherSpec()}));a.state.pending=h.createConnectionState(a);a.state.current.write=a.state.pending.write;h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createFinished(a)}));a.expect=w;h.flush(a);a.process()};if(null===a.session.certificateRequest||null===a.session.clientCertificate)return b(a,null);h.getClientSignature(a,b)};h.handleChangeCipherSpec=function(a,c){if(1!==c.fragment.getByte())return a.error(a,{message:"Invalid ChangeCipherSpec message received.",send:!0,
alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var b=a.entity===h.ConnectionEnd.client;if(a.session.resuming&&b||!a.session.resuming&&!b)a.state.pending=h.createConnectionState(a);a.state.current.read=a.state.pending.read;if(!a.session.resuming&&b||a.session.resuming&&!b)a.state.pending=null;a.expect=b?y:G;a.process()};h.handleFinished=function(a,d,e){e=d.fragment;e.read-=4;var g=e.bytes();e.read+=4;d=d.fragment.getBytes();e=c.util.createBuffer();e.putBuffer(a.session.md5.digest());
2018-08-24 02:55:06 +03:00
e.putBuffer(a.session.sha1.digest());var f=a.entity===h.ConnectionEnd.client;e=b(a.session.sp.master_secret,f?"server finished":"client finished",e.getBytes(),12);if(e.getBytes()!==d)return a.error(a,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decrypt_error}});a.session.md5.update(g);a.session.sha1.update(g);if(a.session.resuming&&f||!a.session.resuming&&!f)h.queue(a,h.createRecord(a,{type:h.ContentType.change_cipher_spec,
2018-11-15 02:44:28 +03:00
data:h.createChangeCipherSpec()})),a.state.current.write=a.state.pending.write,a.state.pending=null,h.queue(a,h.createRecord(a,{type:h.ContentType.handshake,data:h.createFinished(a)}));a.expect=f?C:X;a.handshaking=!1;++a.handshakes;a.peerCertificate=f?a.session.serverCertificate:a.session.clientCertificate;h.flush(a);a.isConnected=!0;a.connected(a);a.process()};h.handleAlert=function(a,c){var b=c.fragment,b={level:b.getByte(),description:b.getByte()},d;switch(b.description){case h.Alert.Description.close_notify:d=
2018-08-24 02:55:06 +03:00
"Connection closed.";break;case h.Alert.Description.unexpected_message:d="Unexpected message.";break;case h.Alert.Description.bad_record_mac:d="Bad record MAC.";break;case h.Alert.Description.decryption_failed:d="Decryption failed.";break;case h.Alert.Description.record_overflow:d="Record overflow.";break;case h.Alert.Description.decompression_failure:d="Decompression failed.";break;case h.Alert.Description.handshake_failure:d="Handshake failure.";break;case h.Alert.Description.bad_certificate:d=
"Bad certificate.";break;case h.Alert.Description.unsupported_certificate:d="Unsupported certificate.";break;case h.Alert.Description.certificate_revoked:d="Certificate revoked.";break;case h.Alert.Description.certificate_expired:d="Certificate expired.";break;case h.Alert.Description.certificate_unknown:d="Certificate unknown.";break;case h.Alert.Description.illegal_parameter:d="Illegal parameter.";break;case h.Alert.Description.unknown_ca:d="Unknown certificate authority.";break;case h.Alert.Description.access_denied:d=
"Access denied.";break;case h.Alert.Description.decode_error:d="Decode error.";break;case h.Alert.Description.decrypt_error:d="Decrypt error.";break;case h.Alert.Description.export_restriction:d="Export restriction.";break;case h.Alert.Description.protocol_version:d="Unsupported protocol version.";break;case h.Alert.Description.insufficient_security:d="Insufficient security.";break;case h.Alert.Description.internal_error:d="Internal error.";break;case h.Alert.Description.user_canceled:d="User canceled.";
break;case h.Alert.Description.no_renegotiation:d="Renegotiation not supported.";break;default:d="Unknown error."}if(b.description===h.Alert.Description.close_notify)return a.close();a.error(a,{message:d,send:!1,origin:a.entity===h.ConnectionEnd.client?"server":"client",alert:b});a.process()};h.handleHandshake=function(a,b){var d=b.fragment,e=d.getByte(),g=d.getInt24();if(g>d.length())return a.fragmented=b,b.fragment=c.util.createBuffer(),d.read-=4,a.process();a.fragmented=null;d.read-=4;var f=d.bytes(g+
4);d.read+=4;e in T[a.entity][a.expect]?(a.entity!==h.ConnectionEnd.server||a.open||a.fail||(a.handshaking=!0,a.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:c.md.md5.create(),sha1:c.md.sha1.create()}),e!==h.HandshakeType.hello_request&&e!==h.HandshakeType.certificate_verify&&e!==h.HandshakeType.finished&&(a.session.md5.update(f),a.session.sha1.update(f)),T[a.entity][a.expect][e](a,b,g)):
h.handleUnexpected(a,b)};h.handleApplicationData=function(a,c){a.data.putBuffer(c.fragment);a.dataReady(a);a.process()};h.handleHeartbeat=function(a,b){var d=b.fragment,e=d.getByte(),g=d.getInt16(),d=d.getBytes(g);if(e===h.HeartbeatMessageType.heartbeat_request){if(a.handshaking||g>d.length)return a.process();h.queue(a,h.createRecord(a,{type:h.ContentType.heartbeat,data:h.createHeartbeat(h.HeartbeatMessageType.heartbeat_response,d)}));h.flush(a)}else if(e===h.HeartbeatMessageType.heartbeat_response){if(d!==
2018-11-15 02:44:28 +03:00
a.expectedHeartbeatPayload)return a.process();a.heartbeatReceived&&a.heartbeatReceived(a,c.util.createBuffer(d))}a.process()};var g=1,p=2,m=3,r=4,w=5,y=6,C=7,A=8,L=1,z=2,D=3,x=4,G=5,X=6,q=h.handleUnexpected,O=h.handleChangeCipherSpec,M=h.handleAlert,J=h.handleHandshake,P=h.handleApplicationData,K=h.handleHeartbeat,W=[];W[h.ConnectionEnd.client]=[[q,M,J,q,K],[q,M,J,q,K],[q,M,J,q,K],[q,M,J,q,K],[q,M,J,q,K],[O,M,q,q,K],[q,M,J,q,K],[q,M,J,P,K],[q,M,J,q,K]];W[h.ConnectionEnd.server]=[[q,M,J,q,K],[q,M,
J,q,K],[q,M,J,q,K],[q,M,J,q,K],[O,M,q,q,K],[q,M,J,q,K],[q,M,J,P,K],[q,M,J,q,K]];var O=h.handleHelloRequest,M=h.handleCertificate,J=h.handleServerKeyExchange,P=h.handleCertificateRequest,K=h.handleServerHelloDone,U=h.handleFinished,T=[];T[h.ConnectionEnd.client]=[[q,q,h.handleServerHello,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,M,J,P,K,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,q,J,P,K,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,q,q,P,K,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,q,q,q,K,q,q,q,q,q,q],
2018-08-24 02:55:06 +03:00
[O,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,U],[O,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[O,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q]];T[h.ConnectionEnd.server]=[[q,h.handleClientHello,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[q,q,q,q,q,q,q,q,q,q,q,M,q,q,q,q,q,q,q,q,q],[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,h.handleClientKeyExchange,q,q,q,q],[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,h.handleCertificateVerify,q,q,q,q,q],[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[q,q,q,q,q,
q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,U],[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q],[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q]];h.generateKeys=function(a,c){var d=c.client_random+c.server_random;a.session.resuming||(c.master_secret=b(c.pre_master_secret,"master secret",d,48).bytes(),c.pre_master_secret=null);var d=c.server_random+c.client_random,e=2*c.mac_key_length+2*c.enc_key_length,g=a.version.major===h.Versions.TLS_1_0.major&&a.version.minor===h.Versions.TLS_1_0.minor;g&&(e+=2*c.fixed_iv_length);d=
b(c.master_secret,"key expansion",d,e);e={client_write_MAC_key:d.getBytes(c.mac_key_length),server_write_MAC_key:d.getBytes(c.mac_key_length),client_write_key:d.getBytes(c.enc_key_length),server_write_key:d.getBytes(c.enc_key_length)};g&&(e.client_write_IV=d.getBytes(c.fixed_iv_length),e.server_write_IV=d.getBytes(c.fixed_iv_length));return e};h.createConnectionState=function(a){var c=a.entity===h.ConnectionEnd.client,b=function(){var a={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,
cipherState:null,cipherFunction:function(a){return!0},compressionState:null,compressFunction:function(a){return!0},updateSequenceNumber:function(){4294967295===a.sequenceNumber[1]?(a.sequenceNumber[1]=0,++a.sequenceNumber[0]):++a.sequenceNumber[1]}};return a},g={read:b(),write:b()};g.read.update=function(a,c){g.read.cipherFunction(c,g.read)?g.read.compressFunction(a,c,g.read)||a.error(a,{message:"Could not decompress record.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decompression_failure}}):
a.error(a,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_record_mac}});return!a.fail};g.write.update=function(a,c){g.write.compressFunction(a,c,g.write)?g.write.cipherFunction(c,g.write)||a.error(a,{message:"Could not encrypt record.",send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):a.error(a,{message:"Could not compress record.",send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});
return!a.fail};if(a.session)switch(b=a.session.sp,a.session.cipherSuite.initSecurityParameters(b),b.keys=h.generateKeys(a,b),g.read.macKey=c?b.keys.server_write_MAC_key:b.keys.client_write_MAC_key,g.write.macKey=c?b.keys.client_write_MAC_key:b.keys.server_write_MAC_key,a.session.cipherSuite.initConnectionState(g,a,b),b.compression_algorithm){case h.CompressionMethod.none:break;case h.CompressionMethod.deflate:g.read.compressFunction=e;g.write.compressFunction=d;break;default:throw Error("Unsupported compression algorithm.");
}return g};h.createRandom=function(){var a=new Date,a=+a+6E4*a.getTimezoneOffset(),b=c.util.createBuffer();b.putInt32(a);b.putBytes(c.random.getBytes(28));return b};h.createRecord=function(a,c){return c.data?{type:c.type,version:{major:a.version.major,minor:a.version.minor},length:c.data.length(),fragment:c.data}:null};h.createAlert=function(a,b){var d=c.util.createBuffer();d.putByte(b.level);d.putByte(b.description);return h.createRecord(a,{type:h.ContentType.alert,data:d})};h.createClientHello=
function(a){a.session.clientHelloVersion={major:a.version.major,minor:a.version.minor};for(var b=c.util.createBuffer(),d=0;d<a.cipherSuites.length;++d){var e=a.cipherSuites[d];b.putByte(e.id[0]);b.putByte(e.id[1])}var g=b.length(),d=c.util.createBuffer();d.putByte(h.CompressionMethod.none);var f=d.length(),e=c.util.createBuffer();if(a.virtualHost){var k=c.util.createBuffer();k.putByte(0);k.putByte(0);var m=c.util.createBuffer();m.putByte(0);n(m,2,c.util.createBuffer(a.virtualHost));var p=c.util.createBuffer();
n(p,2,m);n(k,2,p);e.putBuffer(k)}k=e.length();0<k&&(k+=2);m=a.session.id;g=m.length+1+2+4+28+2+g+1+f+k;f=c.util.createBuffer();f.putByte(h.HandshakeType.client_hello);f.putInt24(g);f.putByte(a.version.major);f.putByte(a.version.minor);f.putBytes(a.session.sp.client_random);n(f,1,c.util.createBuffer(m));n(f,2,b);n(f,1,d);0<k&&n(f,2,e);return f};h.createServerHello=function(a){var b=a.session.id,d=b.length+1+2+4+28+2+1,e=c.util.createBuffer();e.putByte(h.HandshakeType.server_hello);e.putInt24(d);e.putByte(a.version.major);
e.putByte(a.version.minor);e.putBytes(a.session.sp.server_random);n(e,1,c.util.createBuffer(b));e.putByte(a.session.cipherSuite.id[0]);e.putByte(a.session.cipherSuite.id[1]);e.putByte(a.session.compressionMethod);return e};h.createCertificate=function(a){var b=a.entity===h.ConnectionEnd.client,d=null;a.getCertificate&&(d=a.getCertificate(a,b?a.session.certificateRequest:a.session.extensions.server_name.serverNameList));var e=c.util.createBuffer();if(null!==d)try{c.util.isArray(d)||(d=[d]);for(var g=
null,f=0;f<d.length;++f){var k=c.pem.decode(d[f])[0];if("CERTIFICATE"!==k.type&&"X509 CERTIFICATE"!==k.type&&"TRUSTED CERTIFICATE"!==k.type){var m=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');m.headerType=k.type;throw m;}if(k.procType&&"ENCRYPTED"===k.procType.type)throw Error("Could not convert certificate from PEM; PEM is encrypted.");var p=c.util.createBuffer(k.body);null===g&&(g=c.asn1.fromDer(p.bytes(),!1));
var q=c.util.createBuffer();n(q,3,p);e.putBuffer(q)}d=c.pki.certificateFromAsn1(g);b?a.session.clientCertificate=d:a.session.serverCertificate=d}catch(u){return a.error(a,{message:"Could not send certificate list.",cause:u,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}a=3+e.length();b=c.util.createBuffer();b.putByte(h.HandshakeType.certificate);b.putInt24(a);n(b,3,e);return b};h.createClientKeyExchange=function(a){var b=c.util.createBuffer();b.putByte(a.session.clientHelloVersion.major);
b.putByte(a.session.clientHelloVersion.minor);b.putBytes(c.random.getBytes(46));var d=a.session.sp;d.pre_master_secret=b.getBytes();b=a.session.serverCertificate.publicKey.encrypt(d.pre_master_secret);a=b.length+2;d=c.util.createBuffer();d.putByte(h.HandshakeType.client_key_exchange);d.putInt24(a);d.putInt16(b.length);d.putBytes(b);return d};h.createServerKeyExchange=function(a){return c.util.createBuffer()};h.getClientSignature=function(a,b){var d=c.util.createBuffer();d.putBuffer(a.session.md5.digest());
d.putBuffer(a.session.sha1.digest());d=d.getBytes();a.getSignature=a.getSignature||function(a,b,d){var e=null;if(a.getPrivateKey)try{e=a.getPrivateKey(a,a.session.clientCertificate),e=c.pki.privateKeyFromPem(e)}catch(g){a.error(a,{message:"Could not get private key.",cause:g,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}null===e?a.error(a,{message:"No private key set.",send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):
b=e.sign(b,null);d(a,b)};a.getSignature(a,d,b)};h.createCertificateVerify=function(a,b){var d=b.length+2,e=c.util.createBuffer();e.putByte(h.HandshakeType.certificate_verify);e.putInt24(d);e.putInt16(b.length);e.putBytes(b);return e};h.createCertificateRequest=function(a){var b=c.util.createBuffer();b.putByte(1);var d=c.util.createBuffer(),e;for(e in a.caStore.certs){var g=c.pki.distinguishedNameToAsn1(a.caStore.certs[e].subject);d.putBuffer(c.asn1.toDer(g))}a=1+b.length()+2+d.length();e=c.util.createBuffer();
e.putByte(h.HandshakeType.certificate_request);e.putInt24(a);n(e,1,b);n(e,2,d);return e};h.createServerHelloDone=function(a){a=c.util.createBuffer();a.putByte(h.HandshakeType.server_hello_done);a.putInt24(0);return a};h.createChangeCipherSpec=function(){var a=c.util.createBuffer();a.putByte(1);return a};h.createFinished=function(a){var d=c.util.createBuffer();d.putBuffer(a.session.md5.digest());d.putBuffer(a.session.sha1.digest());d=b(a.session.sp.master_secret,a.entity===h.ConnectionEnd.client?"client finished":
"server finished",d.getBytes(),12);a=c.util.createBuffer();a.putByte(h.HandshakeType.finished);a.putInt24(d.length());a.putBuffer(d);return a};h.createHeartbeat=function(a,b,d){"undefined"===typeof d&&(d=b.length);var e=c.util.createBuffer();e.putByte(a);e.putInt16(d);e.putBytes(b);a=e.length();e.putBytes(c.random.getBytes(Math.max(16,a-d-3)));return e};h.queue=function(a,b){if(b){if(b.type===h.ContentType.handshake){var d=b.fragment.bytes();a.session.md5.update(d);a.session.sha1.update(d)}if(b.fragment.length()<=
h.MaxFragment)d=[b];else{for(var d=[],e=b.fragment.bytes();e.length>h.MaxFragment;)d.push(h.createRecord(a,{type:b.type,data:c.util.createBuffer(e.slice(0,h.MaxFragment))})),e=e.slice(h.MaxFragment);0<e.length&&d.push(h.createRecord(a,{type:b.type,data:c.util.createBuffer(e)}))}for(e=0;e<d.length&&!a.fail;++e){var g=d[e];a.state.current.write.update(a,g)&&a.records.push(g)}}};h.flush=function(a){for(var c=0;c<a.records.length;++c){var b=a.records[c];a.tlsData.putByte(b.type);a.tlsData.putByte(b.version.major);
2018-10-03 22:03:09 +03:00
a.tlsData.putByte(b.version.minor);a.tlsData.putInt16(b.fragment.length());a.tlsData.putBuffer(a.records[c].fragment)}a.records=[];return a.tlsDataReady(a)};var S=function(a){switch(a){case !0:return!0;case c.pki.certificateError.bad_certificate:return h.Alert.Description.bad_certificate;case c.pki.certificateError.unsupported_certificate:return h.Alert.Description.unsupported_certificate;case c.pki.certificateError.certificate_revoked:return h.Alert.Description.certificate_revoked;case c.pki.certificateError.certificate_expired:return h.Alert.Description.certificate_expired;
2018-08-24 02:55:06 +03:00
case c.pki.certificateError.certificate_unknown:return h.Alert.Description.certificate_unknown;case c.pki.certificateError.unknown_ca:return h.Alert.Description.unknown_ca;default:return h.Alert.Description.bad_certificate}},V=function(a){switch(a){case !0:return!0;case h.Alert.Description.bad_certificate:return c.pki.certificateError.bad_certificate;case h.Alert.Description.unsupported_certificate:return c.pki.certificateError.unsupported_certificate;case h.Alert.Description.certificate_revoked:return c.pki.certificateError.certificate_revoked;
2018-10-03 22:03:09 +03:00
case h.Alert.Description.certificate_expired:return c.pki.certificateError.certificate_expired;case h.Alert.Description.certificate_unknown:return c.pki.certificateError.certificate_unknown;case h.Alert.Description.unknown_ca:return c.pki.certificateError.unknown_ca;default:return c.pki.certificateError.bad_certificate}};h.verifyCertificateChain=function(a,b){try{c.pki.verifyCertificateChain(a.caStore,b,function(b,d,e){S(b);d=a.verify(a,b,d,e);if(!0!==d){if("object"===typeof d&&!c.util.isArray(d))throw b=
Error("The application rejected the certificate."),b.send=!0,b.alert={level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate},d.message&&(b.message=d.message),d.alert&&(b.alert.description=d.alert),b;d!==b&&(d=V(d))}return d})}catch(d){var e=d;if("object"!==typeof e||c.util.isArray(e))e={send:!0,alert:{level:h.Alert.Level.fatal,description:S(d)}};"send"in e||(e.send=!0);"alert"in e||(e.alert={level:h.Alert.Level.fatal,description:S(e.error)});a.error(a,e)}return!a.fail};h.createSessionCache=
2018-08-24 02:55:06 +03:00
function(a,b){var d=null;if(a&&a.getSession&&a.setSession&&a.order)d=a;else{d={};d.cache=a||{};d.capacity=Math.max(b||100,1);d.order=[];for(var e in a)d.order.length<=b?d.order.push(e):delete a[e];d.getSession=function(a){var b=null,e=null;a?e=c.util.bytesToHex(a):0<d.order.length&&(e=d.order[0]);if(null!==e&&e in d.cache){b=d.cache[e];delete d.cache[e];for(var g in d.order)if(d.order[g]===e){d.order.splice(g,1);break}}return b};d.setSession=function(a,b){if(d.order.length===d.capacity){var e=d.order.shift();
delete d.cache[e]}e=c.util.bytesToHex(a);d.order.push(e);d.cache[e]=b}}return d};h.createConnection=function(a){var b=null,b=a.caStore?c.util.isArray(a.caStore)?c.pki.createCaStore(a.caStore):a.caStore:c.pki.createCaStore(),d=a.cipherSuites||null;if(null===d){var d=[],e;for(e in h.CipherSuites)d.push(h.CipherSuites[e])}e=a.server?h.ConnectionEnd.server:h.ConnectionEnd.client;var g=a.sessionCache?h.createSessionCache(a.sessionCache):null,f={version:{major:h.Version.major,minor:h.Version.minor},entity:e,
sessionId:a.sessionId,caStore:b,sessionCache:g,cipherSuites:d,connected:a.connected,virtualHost:a.virtualHost||null,verifyClient:a.verifyClient||!1,verify:a.verify||function(a,c,b,d){return c},getCertificate:a.getCertificate||null,getPrivateKey:a.getPrivateKey||null,getSignature:a.getSignature||null,input:c.util.createBuffer(),tlsData:c.util.createBuffer(),data:c.util.createBuffer(),tlsDataReady:a.tlsDataReady,dataReady:a.dataReady,heartbeatReceived:a.heartbeatReceived,closed:a.closed,error:function(c,
b){b.origin=b.origin||(c.entity===h.ConnectionEnd.client?"client":"server");b.send&&(h.queue(c,h.createAlert(c,b.alert)),h.flush(c));var d=!1!==b.fatal;d&&(c.fail=!0);a.error(c,b);d&&c.close(!1)},deflate:a.deflate||null,inflate:a.inflate||null,reset:function(a){f.version={major:h.Version.major,minor:h.Version.minor};f.record=null;f.session=null;f.peerCertificate=null;f.state={pending:null,current:null};f.expect=0;f.fragmented=null;f.records=[];f.open=!1;f.handshakes=0;f.handshaking=!1;f.isConnected=
!1;f.fail=!(a||"undefined"===typeof a);f.input.clear();f.tlsData.clear();f.data.clear();f.state.current=h.createConnectionState(f)}};f.reset();f.handshake=function(a){if(f.entity!==h.ConnectionEnd.client)f.error(f,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(f.handshaking)f.error(f,{message:"Handshake already in progress.",fatal:!1});else{f.fail&&!f.open&&0===f.handshakes&&(f.fail=!1);f.handshaking=!0;a=a||"";var b=null;0<a.length&&(f.sessionCache&&(b=f.sessionCache.getSession(a)),
null===b&&(a=""));0===a.length&&f.sessionCache&&(b=f.sessionCache.getSession(),null!==b&&(a=b.id));f.session={id:a,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:c.md.md5.create(),sha1:c.md.sha1.create()};b&&(f.version=b.version,f.session.sp=b.sp);f.session.sp.client_random=h.createRandom().getBytes();f.open=!0;h.queue(f,h.createRecord(f,{type:h.ContentType.handshake,data:h.createClientHello(f)}));h.flush(f)}};f.process=
function(a){var b=0;a&&f.input.putBytes(a);if(!f.fail){null!==f.record&&f.record.ready&&f.record.fragment.isEmpty()&&(f.record=null);if(null===f.record){b=0;a=f.input;var d=a.length();5>d?b=5-d:(f.record={type:a.getByte(),version:{major:a.getByte(),minor:a.getByte()},length:a.getInt16(),fragment:c.util.createBuffer(),ready:!1},(a=f.record.version.major===f.version.major)&&f.session&&f.session.version&&(a=f.record.version.minor===f.version.minor),a||f.error(f,{message:"Incompatible TLS version.",send:!0,
alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}}))}if(!f.fail&&null!==f.record&&!f.record.ready){b=f;a=0;var d=b.input,e=d.length();e<b.record.length?a=b.record.length-e:(b.record.fragment.putBytes(d.getBytes(b.record.length)),d.compact(),b.state.current.read.update(b,b.record)&&(null!==b.fragmented&&(b.fragmented.type===b.record.type?(b.fragmented.fragment.putBuffer(b.record.fragment),b.record=b.fragmented):b.error(b,{message:"Invalid fragmented record.",send:!0,
alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unexpected_message}})),b.record.ready=!0));b=a}if(!f.fail&&null!==f.record&&f.record.ready)if(a=f.record,d=a.type-h.ContentType.change_cipher_spec,e=W[f.entity][f.expect],d in e)e[d](f,a);else h.handleUnexpected(f,a)}return b};f.prepare=function(a){h.queue(f,h.createRecord(f,{type:h.ContentType.application_data,data:c.util.createBuffer(a)}));return h.flush(f)};f.prepareHeartbeatRequest=function(a,b){a instanceof c.util.ByteBuffer&&(a=
a.bytes());"undefined"===typeof b&&(b=a.length);f.expectedHeartbeatPayload=a;h.queue(f,h.createRecord(f,{type:h.ContentType.heartbeat,data:h.createHeartbeat(h.HeartbeatMessageType.heartbeat_request,a,b)}));return h.flush(f)};f.close=function(a){if(!f.fail&&f.sessionCache&&f.session){var c={id:f.session.id,version:f.session.version,sp:f.session.sp};c.sp.keys=null;f.sessionCache.setSession(c.id,c)}if(f.open){f.open=!1;f.input.clear();if(f.isConnected||f.handshaking)f.isConnected=f.handshaking=!1,h.queue(f,
2018-10-03 22:03:09 +03:00
h.createAlert(f,{level:h.Alert.Level.warning,description:h.Alert.Description.close_notify})),h.flush(f);f.closed(f)}f.reset(a)};return f};c.tls=c.tls||{};for(var R in h)"function"!==typeof h[R]&&(c.tls[R]=h[R]);c.tls.prf_tls1=b;c.tls.hmac_sha1=function(a,b,d){var e=c.hmac.create();e.start("SHA1",a);a=c.util.createBuffer();a.putInt32(b[0]);a.putInt32(b[1]);a.putByte(d.type);a.putByte(d.version.major);a.putByte(d.version.minor);a.putInt16(d.length);a.putBytes(d.fragment.bytes());e.update(a.getBytes());
2018-08-24 02:55:06 +03:00
return e.digest().getBytes()};c.tls.createSessionCache=h.createSessionCache;c.tls.createConnection=h.createConnection}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.tls)return b.tls;b.defined.tls=!0;for(var f=0;f<e.length;++f)e[f](b);return b.tls}},
r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/tls","require module ./asn1 ./hmac ./md ./pem ./pki ./random ./util".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,e,g){e=e.entity===c.tls.ConnectionEnd.client;a.read.cipherState={init:!1,cipher:c.cipher.createDecipher("AES-CBC",
e?g.keys.server_write_key:g.keys.client_write_key),iv:e?g.keys.server_write_IV:g.keys.client_write_IV};a.write.cipherState={init:!1,cipher:c.cipher.createCipher("AES-CBC",e?g.keys.client_write_key:g.keys.server_write_key),iv:e?g.keys.client_write_IV:g.keys.server_write_IV};a.read.cipherFunction=n;a.write.cipherFunction=d;a.read.macLength=a.write.macLength=g.mac_length;a.read.macFunction=a.write.macFunction=h.hmac_sha1}function d(a,b){var g=!1,f=b.macFunction(b.macKey,b.sequenceNumber,a);a.fragment.putBytes(f);
b.updateSequenceNumber();f=a.version.minor===h.Versions.TLS_1_0.minor?b.cipherState.init?null:b.cipherState.iv:c.random.getBytesSync(16);b.cipherState.init=!0;var k=b.cipherState.cipher;k.start({iv:f});a.version.minor>=h.Versions.TLS_1_1.minor&&k.output.putBytes(f);k.update(a.fragment);k.finish(e)&&(a.fragment=k.output,a.length=a.fragment.length(),g=!0);return g}function e(a,c,b){b||(a-=c.length()%a,c.fillWithByte(a-1,a));return!0}function f(a,c,b){a=!0;if(b){b=c.length();for(var d=c.last(),e=b-1-
2018-10-03 22:03:09 +03:00
d;e<b-1;++e)a=a&&c.at(e)==d;a&&c.truncate(d+1)}return a}function n(a,b){var d=!1;++g;d=a.version.minor===h.Versions.TLS_1_0.minor?b.cipherState.init?null:b.cipherState.iv:a.fragment.getBytes(16);b.cipherState.init=!0;var e=b.cipherState.cipher;e.start({iv:d});e.update(a.fragment);var d=e.finish(f),k=b.macLength,p=c.random.getBytesSync(k),v=e.output.length();v>=k?(a.fragment=e.output.getBytes(v-k),p=e.output.getBytes(k)):a.fragment=e.output.getBytes();a.fragment=c.util.createBuffer(a.fragment);a.length=
a.fragment.length();k=b.macFunction(b.macKey,b.sequenceNumber,a);b.updateSequenceNumber();e=b.macKey;v=c.hmac.create();v.start("SHA1",e);v.update(p);p=v.digest().getBytes();v.start(null,null);v.update(k);k=v.digest().getBytes();return p===k&&d}var h=c.tls;h.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(a){a.bulk_cipher_algorithm=h.BulkCipherAlgorithm.aes;a.cipher_type=h.CipherType.block;a.enc_key_length=16;a.block_length=16;
2018-08-24 02:55:06 +03:00
a.fixed_iv_length=16;a.record_iv_length=16;a.mac_algorithm=h.MACAlgorithm.hmac_sha1;a.mac_length=20;a.mac_key_length=20},initConnectionState:b};h.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(a){a.bulk_cipher_algorithm=h.BulkCipherAlgorithm.aes;a.cipher_type=h.CipherType.block;a.enc_key_length=32;a.block_length=16;a.fixed_iv_length=16;a.record_iv_length=16;a.mac_algorithm=h.MACAlgorithm.hmac_sha1;a.mac_length=20;a.mac_key_length=
20},initConnectionState:b};var g=0}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.aesCipherSuites)return b.aesCipherSuites;b.defined.aesCipherSuites=!0;for(var f=0;f<e.length;++f)e[f](b);return b.aesCipherSuites}},r=c;c=function(a,b){n="string"===
typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/aesCipherSuites",["require","module","./aes","./tls"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.debug=c.debug||{};c.debug.storage={};c.debug.get=function(a,b){var d;"undefined"===typeof a?d=c.debug.storage:a in c.debug.storage&&(d="undefined"===typeof b?c.debug.storage[a]:
c.debug.storage[a][b]);return d};c.debug.set=function(a,b,d){a in c.debug.storage||(c.debug.storage[a]={});c.debug.storage[a][b]=d};c.debug.clear=function(a,b){"undefined"===typeof a?c.debug.storage={}:a in c.debug.storage&&("undefined"===typeof b?delete c.debug.storage[a]:delete c.debug.storage[a][b])}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=
function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.debug)return b.debug;b.defined.debug=!0;for(var f=0;f<e.length;++f)e[f](b);return b.debug}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/debug",["require","module"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();
2018-10-03 22:03:09 +03:00
(function(){function a(c){function b(a,d,f,h){a.generate=function(a,b){for(var e=new c.util.ByteBuffer,k=Math.ceil(b/h)+f,n=new c.util.ByteBuffer,p=f;p<k;++p){n.putInt32(p);d.start();d.update(a+n.getBytes());var v=d.digest();e.putBytes(v.getBytes(h))}e.truncate(e.length()-b);return e.getBytes()}}c.kem=c.kem||{};var d=c.jsbn.BigInteger;c.kem.rsa={};c.kem.rsa.create=function(a,b){b=b||{};var f=b.prng||c.random;return{encrypt:function(b,g){var k=Math.ceil(b.n.bitLength()/8),m;do m=(new d(c.util.bytesToHex(f.getBytesSync(k)),
2018-08-24 02:55:06 +03:00
16)).mod(b.n);while(m.equals(d.ZERO));m=c.util.hexToBytes(m.toString(16));k-=m.length;0<k&&(m=c.util.fillString(String.fromCharCode(0),k)+m);k=b.encrypt(m,"NONE");m=a.generate(m,g);return{encapsulation:k,key:m}},decrypt:function(c,b,d){c=c.decrypt(b,"NONE");return a.generate(c,d)}}};c.kem.kdf1=function(a,c){b(this,a,0,c||a.digestLength)};c.kem.kdf2=function(a,c){b(this,a,1,c||a.digestLength)}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===
typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.kem)return b.kem;b.defined.kem=!0;for(var f=0;f<e.length;++f)e[f](b);return b.kem}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/kem",["require","module","./util","./random",
"./jsbn"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){c.log=c.log||{};c.log.levels="none error warning info debug verbose max".split(" ");var b={},d=[],e=null;c.log.LEVEL_LOCKED=2;c.log.NO_LEVEL_CHECK=4;c.log.INTERPOLATE=8;for(var f=0;f<c.log.levels.length;++f){var n=c.log.levels[f];b[n]={index:f,name:n.toUpperCase()}}c.log.logMessage=function(a){for(var e=b[a.level].index,f=0;f<d.length;++f){var h=d[f];h.flags&c.log.NO_LEVEL_CHECK?h.f(a):e<=b[h.level].index&&
h.f(h,a)}};c.log.prepareStandard=function(a){"standard"in a||(a.standard=b[a.level].name+" ["+a.category+"] "+a.message)};c.log.prepareFull=function(a){if(!("full"in a)){var b=[a.message],b=b.concat([]);a.full=c.util.format.apply(this,b)}};c.log.prepareStandardFull=function(a){"standardFull"in a||(c.log.prepareStandard(a),a.standardFull=a.standard)};n=["error","warning","info","debug","verbose"];for(f=0;f<n.length;++f)(function(a){c.log[a]=function(b,d){var e=Array.prototype.slice.call(arguments).slice(2);
c.log.logMessage({timestamp:new Date,level:a,category:b,message:d,arguments:e})}})(n[f]);c.log.makeLogger=function(a){a={flags:0,f:a};c.log.setLevel(a,"none");return a};c.log.setLevel=function(a,b){var d=!1;if(a&&!(a.flags&c.log.LEVEL_LOCKED))for(var e=0;e<c.log.levels.length;++e)if(b==c.log.levels[e]){a.level=b;d=!0;break}return d};c.log.lock=function(a,b){a.flags="undefined"===typeof b||b?a.flags|c.log.LEVEL_LOCKED:a.flags&~c.log.LEVEL_LOCKED};c.log.addLogger=function(a){d.push(a)};if("undefined"!==
typeof console&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug)var h={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},e=function(a,b){c.log.prepareStandard(b);var d=h[b.level],e=[b.standard],e=e.concat(b.arguments.slice());d.apply(console,e)};else e=function(a,b){c.log.prepareStandardFull(b);console.log(b.standardFull)};e=c.log.makeLogger(e);c.log.setLevel(e,"debug");c.log.addLogger(e)}else console={log:function(){}};
null!==e&&(f=c.util.getQueryVariables(),"console.level"in f&&c.log.setLevel(e,f["console.level"].slice(-1)[0]),"console.lock"in f&&"true"==f["console.lock"].slice(-1)[0]&&c.log.lock(e));c.log.consoleLogger=e}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.log)return b.log;
b.defined.log=!0;for(var f=0;f<e.length;++f)e[f](b);return b.log}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/log",["require","module","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a){var d={},e=[];if(!m.validate(a,r.asn1.recipientInfoValidator,d,e))throw a=Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo."),
a.errors=e,a;return{version:d.version.charCodeAt(0),issuer:c.pki.RDNAttributesAsArray(d.issuer),serialNumber:c.util.createBuffer(d.serial).toHex(),encryptedContent:{algorithm:m.derToOid(d.encAlgorithm),parameter:d.encParameter.value,content:d.encKey}}}function d(a){return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(a.version).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[c.pki.distinguishedNameToAsn1({attributes:a.issuer}),
m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,c.util.hexToBytes(a.serialNumber))]),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.encryptedContent.algorithm).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,a.encryptedContent.content)])}function e(a){for(var c=[],b=0;b<a.length;++b)c.push(d(a[b]));return c}function f(a){var b=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,
m.Type.INTEGER,!1,m.integerToDer(a.version).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[c.pki.distinguishedNameToAsn1({attributes:a.issuer}),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,c.util.hexToBytes(a.serialNumber))]),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.digestAlgorithm).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")])]);a.authenticatedAttributesAsn1&&b.value.push(a.authenticatedAttributesAsn1);b.value.push(m.create(m.Class.UNIVERSAL,
m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.signatureAlgorithm).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")]));b.value.push(m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,a.signature));if(0<a.unauthenticatedAttributes.length){for(var d=m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[]),e=0;e<a.unauthenticatedAttributes.length;++e)d.values.push(n(a.unauthenticatedAttributes[e]));b.value.push(d)}return b}function n(a){var b;if(a.type===c.pki.oids.contentType)b=
m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.value).getBytes());else if(a.type===c.pki.oids.messageDigest)b=m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,a.value.bytes());else if(a.type===c.pki.oids.signingTime){b=new Date("Jan 1, 1950 00:00:00Z");var d=new Date("Jan 1, 2050 00:00:00Z"),e=a.value;if("string"===typeof e)var f=Date.parse(e),e=isNaN(f)?13===e.length?m.utcTimeToDate(e):m.generalizedTimeToDate(e):new Date(f);b=e>=b&&e<d?m.create(m.Class.UNIVERSAL,m.Type.UTCTIME,!1,m.dateToUtcTime(e)):
m.create(m.Class.UNIVERSAL,m.Type.GENERALIZEDTIME,!1,m.dateToGeneralizedTime(e))}return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.type).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[b])])}function h(a){return[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(c.pki.oids.data).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.algorithm).getBytes()),m.create(m.Class.UNIVERSAL,
m.Type.OCTETSTRING,!1,a.parameter.getBytes())]),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,a.content.getBytes())])]}function g(a,b,d){var e={};if(!m.validate(b,d,e,[]))throw a=Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message."),a.errors=a,a;if(m.derToOid(e.contentType)!==c.pki.oids.data)throw Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(e.encryptedContent){b="";if(c.util.isArray(e.encryptedContent))for(d=
0;d<e.encryptedContent.length;++d){if(e.encryptedContent[d].type!==m.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");b+=e.encryptedContent[d].value}else b=e.encryptedContent;a.encryptedContent={algorithm:m.derToOid(e.encAlgorithm),parameter:c.util.createBuffer(e.encParameter.value),content:c.util.createBuffer(b)}}if(e.content){b="";if(c.util.isArray(e.content))for(d=0;d<e.content.length;++d){if(e.content[d].type!==m.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");
b+=e.content[d].value}else b=e.content;a.content=c.util.createBuffer(b)}a.version=e.version.charCodeAt(0);return a.rawCapture=e}function p(a){if(void 0===a.encryptedContent.key)throw Error("Symmetric key not available.");if(void 0===a.content){var b;switch(a.encryptedContent.algorithm){case c.pki.oids["aes128-CBC"]:case c.pki.oids["aes192-CBC"]:case c.pki.oids["aes256-CBC"]:b=c.aes.createDecryptionCipher(a.encryptedContent.key);break;case c.pki.oids.desCBC:case c.pki.oids["des-EDE3-CBC"]:b=c.des.createDecryptionCipher(a.encryptedContent.key);
break;default:throw Error("Unsupported symmetric cipher, OID "+a.encryptedContent.algorithm);}b.start(a.encryptedContent.parameter);b.update(a.encryptedContent.content);if(!b.finish())throw Error("Symmetric decryption failed.");a.content=b.output}}var m=c.asn1,r=c.pkcs7=c.pkcs7||{};r.messageFromPem=function(a){a=c.pem.decode(a)[0];if("PKCS7"!==a.type){var b=Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');b.headerType=a.type;throw b;}if(a.procType&&"ENCRYPTED"===
a.procType.type)throw Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");a=m.fromDer(a.body);return r.messageFromAsn1(a)};r.messageToPem=function(a,b){var d={type:"PKCS7",body:m.toDer(a.toAsn1()).getBytes()};return c.pem.encode(d,{maxline:b})};r.messageFromAsn1=function(a){var b={},d=[];if(!m.validate(a,r.asn1.contentInfoValidator,b,d))throw b=Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo."),b.errors=d,b;d=m.derToOid(b.contentType);switch(d){case c.pki.oids.envelopedData:d=
r.createEnvelopedData();break;case c.pki.oids.encryptedData:d=r.createEncryptedData();break;case c.pki.oids.signedData:d=r.createSignedData();break;default:throw Error("Cannot read PKCS#7 message. ContentType with OID "+d+" is not (yet) supported.");}d.fromAsn1(b.content.value[0]);return d};r.createSignedData=function(){var a=null;return a={type:c.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(b){g(a,
b,r.asn1.signedDataValidator);a.certificates=[];a.crls=[];a.digestAlgorithmIdentifiers=[];a.contentInfo=null;a.signerInfos=[];b=a.rawCapture.certificates.value;for(var d=0;d<b.length;++d)a.certificates.push(c.pki.certificateFromAsn1(b[d]))},toAsn1:function(){a.contentInfo||a.sign();for(var b=[],d=0;d<a.certificates.length;++d)b.push(c.pki.certificateToAsn1(a.certificates[d]));var d=[],e=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,
m.Type.INTEGER,!1,m.integerToDer(a.version).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,a.digestAlgorithmIdentifiers),a.contentInfo])]);0<b.length&&e.value[0].value.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,b));0<d.length&&e.value[0].value.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,d));e.value[0].value.push(m.create(m.Class.UNIVERSAL,m.Type.SET,!0,a.signerInfos));return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.type).getBytes()),
e])},addSigner:function(b){var d=b.issuer,e=b.serialNumber;b.certificate&&(e=b.certificate,"string"===typeof e&&(e=c.pki.certificateFromPem(e)),d=e.issuer.attributes,e=e.serialNumber);var f=b.key;if(!f)throw Error("Could not add PKCS#7 signer; no private key specified.");"string"===typeof f&&(f=c.pki.privateKeyFromPem(f));var g=b.digestAlgorithm||c.pki.oids.sha1;switch(g){case c.pki.oids.sha1:case c.pki.oids.sha256:case c.pki.oids.sha384:case c.pki.oids.sha512:case c.pki.oids.md5:break;default:throw Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+
g);}b=b.authenticatedAttributes||[];if(0<b.length){for(var h=!1,k=!1,m=0;m<b.length;++m){var n=b[m];if(!h&&n.type===c.pki.oids.contentType){if(h=!0,k)break}else if(!k&&n.type===c.pki.oids.messageDigest&&(k=!0,h))break}if(!h||!k)throw 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.");}a.signers.push({key:f,version:1,issuer:d,serialNumber:e,digestAlgorithm:g,
signatureAlgorithm:c.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:b,unauthenticatedAttributes:[]})},sign:function(){if("object"!==typeof a.content||null===a.contentInfo)if(a.contentInfo=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(c.pki.oids.data).getBytes())]),"content"in a){var b;a.content instanceof c.util.ByteBuffer?b=a.content.bytes():"string"===typeof a.content&&(b=c.util.encodeUtf8(a.content));a.contentInfo.value.push(m.create(m.Class.CONTEXT_SPECIFIC,
0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,b)]))}if(0!==a.signers.length){b={};for(var d=0;d<a.signers.length;++d){var e=a.signers[d],g=e.digestAlgorithm;g in b||(b[g]=c.md[c.pki.oids[g]].create());e.md=0===e.authenticatedAttributes.length?b[g]:c.md[c.pki.oids[g]].create()}a.digestAlgorithmIdentifiers=[];for(g in b)a.digestAlgorithmIdentifiers.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(g).getBytes()),m.create(m.Class.UNIVERSAL,
m.Type.NULL,!1,"")]));if(2>a.contentInfo.value.length)throw Error("Could not sign PKCS#7 message; there is no content to sign.");var g=m.derToOid(a.contentInfo.value[0].value),d=a.contentInfo.value[1],d=d.value[0],h=m.toDer(d);h.getByte();m.getBerValueLength(h);var h=h.getBytes(),k;for(k in b)b[k].start().update(h);k=new Date;for(d=0;d<a.signers.length;++d){e=a.signers[d];if(0===e.authenticatedAttributes.length){if(g!==c.pki.oids.data)throw Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.");
2018-11-15 02:44:28 +03:00
}else{e.authenticatedAttributesAsn1=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var h=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[]),p=0;p<e.authenticatedAttributes.length;++p){var v=e.authenticatedAttributes[p];v.type===c.pki.oids.messageDigest?v.value=b[e.digestAlgorithm].digest():v.type!==c.pki.oids.signingTime||v.value||(v.value=k);h.value.push(n(v));e.authenticatedAttributesAsn1.value.push(n(v))}h=m.toDer(h).getBytes();e.md.start().update(h)}e.signature=e.key.sign(e.md,"RSASSA-PKCS1-V1_5")}b=
2018-08-24 02:55:06 +03:00
a;g=a.signers;k=[];for(d=0;d<g.length;++d)k.push(f(g[d]));b.signerInfos=k}},verify:function(){throw Error("PKCS#7 signature verification not yet implemented.");},addCertificate:function(b){"string"===typeof b&&(b=c.pki.certificateFromPem(b));a.certificates.push(b)},addCertificateRevokationList:function(a){throw Error("PKCS#7 CRL support not yet implemented.");}}};r.createEncryptedData=function(){var a=null;return a={type:c.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:c.pki.oids["aes256-CBC"]},
fromAsn1:function(c){g(a,c,r.asn1.encryptedDataValidator)},decrypt:function(c){void 0!==c&&(a.encryptedContent.key=c);p(a)}}};r.createEnvelopedData=function(){var a=null;return a={type:c.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:c.pki.oids["aes256-CBC"]},fromAsn1:function(c){var d=g(a,c,r.asn1.envelopedDataValidator);c=a;for(var d=d.recipientInfos.value,e=[],f=0;f<d.length;++f)e.push(b(d[f]));c.recipients=e},toAsn1:function(){return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,
!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(a.type).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(a.version).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,e(a.recipients)),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,h(a.encryptedContent))])])])},findRecipient:function(c){for(var b=c.issuer.attributes,d=0;d<a.recipients.length;++d){var e=a.recipients[d],f=e.issuer;if(e.serialNumber===
c.serialNumber&&f.length===b.length){for(var g=!0,h=0;h<b.length;++h)if(f[h].type!==b[h].type||f[h].value!==b[h].value){g=!1;break}if(g)return e}}return null},decrypt:function(b,d){if(void 0===a.encryptedContent.key&&void 0!==b&&void 0!==d)switch(b.encryptedContent.algorithm){case c.pki.oids.rsaEncryption:case c.pki.oids.desCBC:var e=d.decrypt(b.encryptedContent.content);a.encryptedContent.key=c.util.createBuffer(e);break;default:throw Error("Unsupported asymmetric cipher, OID "+b.encryptedContent.algorithm);
}p(a)},addRecipient:function(b){a.recipients.push({version:0,issuer:b.issuer.attributes,serialNumber:b.serialNumber,encryptedContent:{algorithm:c.pki.oids.rsaEncryption,key:b.publicKey}})},encrypt:function(b,d){if(void 0===a.encryptedContent.content){d=d||a.encryptedContent.algorithm;b=b||a.encryptedContent.key;var e,f,g;switch(d){case c.pki.oids["aes128-CBC"]:f=e=16;g=c.aes.createEncryptionCipher;break;case c.pki.oids["aes192-CBC"]:e=24;f=16;g=c.aes.createEncryptionCipher;break;case c.pki.oids["aes256-CBC"]:e=
32;f=16;g=c.aes.createEncryptionCipher;break;case c.pki.oids["des-EDE3-CBC"]:e=24;f=8;g=c.des.createEncryptionCipher;break;default:throw Error("Unsupported symmetric cipher, OID "+d);}if(void 0===b)b=c.util.createBuffer(c.random.getBytes(e));else if(b.length()!=e)throw Error("Symmetric key has wrong length; got "+b.length()+" bytes, expected "+e+".");a.encryptedContent.algorithm=d;a.encryptedContent.key=b;a.encryptedContent.parameter=c.util.createBuffer(c.random.getBytes(f));e=g(b);e.start(a.encryptedContent.parameter.copy());
e.update(a.content);if(!e.finish())throw Error("Symmetric encryption failed.");a.encryptedContent.content=e.output}for(e=0;e<a.recipients.length;++e)if(f=a.recipients[e],void 0===f.encryptedContent.content)switch(f.encryptedContent.algorithm){case c.pki.oids.rsaEncryption:f.encryptedContent.content=f.encryptedContent.key.encrypt(a.encryptedContent.key.data);break;default:throw Error("Unsupported asymmetric cipher, OID "+f.encryptedContent.algorithm);}}}}}if("function"!==typeof c)if("object"===typeof module&&
module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.pkcs7)return b.pkcs7;b.defined.pkcs7=!0;for(var f=0;f<e.length;++f)e[f](b);return b.pkcs7}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,
Array.prototype.slice.call(arguments,0))};c("js/pkcs7","require module ./aes ./asn1 ./des ./oids ./pem ./pkcs7asn1 ./random ./util ./x509".split(" "),function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){function b(a,d){var e=d.toString(16);"8"<=e[0]&&(e="00"+e);e=c.util.hexToBytes(e);a.putInt32(e.length);a.putBytes(e)}function d(a,c){a.putInt32(c.length);a.putString(c)}function e(){for(var a=c.md.sha1.create(),b=arguments.length,d=0;d<b;++d)a.update(arguments[d]);
2018-10-03 22:03:09 +03:00
return a.digest()}var f=c.ssh=c.ssh||{};f.privateKeyToPutty=function(a,f,g){g=g||"";f=f||"";var n=""===f?"none":"aes256-cbc",m;m="PuTTY-User-Key-File-2: ssh-rsa\r\n"+("Encryption: "+n+"\r\n")+("Comment: "+g+"\r\n");var p=c.util.createBuffer();d(p,"ssh-rsa");b(p,a.e);b(p,a.n);var u=c.util.encode64(p.bytes(),64),r=Math.floor(u.length/66)+1;m+="Public-Lines: "+r+"\r\n";m+=u;u=c.util.createBuffer();b(u,a.d);b(u,a.p);b(u,a.q);b(u,a.qInv);f?(r=u.length()+16-1,r-=r%16,a=e(u.bytes()),a.truncate(a.length()-
r+u.length()),u.putBuffer(a),r=c.util.createBuffer(),r.putBuffer(e("\x00\x00\x00\x00",f)),r.putBuffer(e("\x00\x00\x00\u0001",f)),r=c.aes.createEncryptionCipher(r.truncate(8),"CBC"),r.start(c.util.createBuffer().fillWithByte(0,16)),r.update(u.copy()),r.finish(),r=r.output,r.truncate(16),a=c.util.encode64(r.bytes(),64)):a=c.util.encode64(u.bytes(),64);r=Math.floor(a.length/66)+1;m+="\r\nPrivate-Lines: "+r+"\r\n";m+=a;f=e("putty-private-key-file-mac-key",f);r=c.util.createBuffer();d(r,"ssh-rsa");d(r,
n);d(r,g);r.putInt32(p.length());r.putBuffer(p);r.putInt32(u.length());r.putBuffer(u);g=c.hmac.create();g.start("sha1",f);g.update(r.bytes());return m+="\r\nPrivate-MAC: "+g.digest().toHex()+"\r\n"};f.publicKeyToOpenSSH=function(a,e){e=e||"";var f=c.util.createBuffer();d(f,"ssh-rsa");b(f,a.e);b(f,a.n);return"ssh-rsa "+c.util.encode64(f.bytes())+" "+e};f.privateKeyToOpenSSH=function(a,b){return b?c.pki.encryptRsaPrivateKey(a,b,{legacy:!0,algorithm:"aes128"}):c.pki.privateKeyToPem(a)};f.getPublicKeyFingerprint=
2018-08-24 02:55:06 +03:00
function(a,e){e=e||{};var f=e.md||c.md.md5.create(),n=c.util.createBuffer();d(n,"ssh-rsa");b(n,a.e);b(n,a.n);f.start();f.update(n.getBytes());f=f.digest();if("hex"===e.encoding)return f=f.toHex(),e.delimiter?f.match(/.{2}/g).join(e.delimiter):f;if("binary"===e.encoding)return f.getBytes();if(e.encoding)throw Error('Unknown encoding "'+e.encoding+'".');return f}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&
(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.ssh)return b.ssh;b.defined.ssh=!0;for(var f=0;f<e.length;++f)e[f](b);return b.ssh}},r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/ssh","require module ./aes ./hmac ./md5 ./sha1 ./util".split(" "),
function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){function a(c){var b={},d=0;c.debug.set("forge.task","tasks",b);var e={};c.debug.set("forge.task","queues",e);var f={ready:{}};f.ready.stop="ready";f.ready.start="running";f.ready.cancel="done";f.ready.fail="error";f.running={};f.running.stop="ready";f.running.start="running";f.running.block="blocked";f.running.unblock="running";f.running.sleep="sleeping";f.running.wakeup="running";f.running.cancel="done";f.running.fail=
"error";f.blocked={};f.blocked.stop="blocked";f.blocked.start="blocked";f.blocked.block="blocked";f.blocked.unblock="blocked";f.blocked.sleep="blocked";f.blocked.wakeup="blocked";f.blocked.cancel="done";f.blocked.fail="error";f.sleeping={};f.sleeping.stop="sleeping";f.sleeping.start="sleeping";f.sleeping.block="sleeping";f.sleeping.unblock="sleeping";f.sleeping.sleep="sleeping";f.sleeping.wakeup="sleeping";f.sleeping.cancel="done";f.sleeping.fail="error";f.done={};f.done.stop="done";f.done.start=
"done";f.done.block="done";f.done.unblock="done";f.done.sleep="done";f.done.wakeup="done";f.done.cancel="done";f.done.fail="error";f.error={};f.error.stop="error";f.error.start="error";f.error.block="error";f.error.unblock="error";f.error.sleep="error";f.error.wakeup="error";f.error.cancel="error";f.error.fail="error";var n=function(a){this.id=-1;this.name=a.name||"?";this.parent=a.parent||null;this.run=a.run;this.subtasks=[];this.error=!1;this.state="ready";this.blocks=0;this.userData=this.swapTime=
this.timeoutId=null;this.id=d++;b[this.id]=this};n.prototype.debug=function(a){c.log.debug("forge.task",a||"","[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",e)};n.prototype.next=function(a,c){"function"===typeof a&&(c=a,a=this.name);var b=new n({run:c,name:a,parent:this});b.state="running";b.type=this.type;b.successCallback=this.successCallback||null;b.failureCallback=this.failureCallback||null;this.subtasks.push(b);return this};n.prototype.parallel=function(a,b){c.util.isArray(a)&&
(b=a,a=this.name);return this.next(a,function(d){d.block(b.length);for(var e=function(a,e){c.task.start({type:a,run:function(a){b[e](a)},success:function(a){d.unblock()},failure:function(a){d.unblock()}})},f=0;f<b.length;f++)e(a+"__parallel-"+d.id+"-"+f,f)})};n.prototype.stop=function(){this.state=f[this.state].stop};n.prototype.start=function(){this.error=!1;this.state=f[this.state].start;"running"===this.state&&(this.start=new Date,this.run(this),g(this,0))};n.prototype.block=function(a){this.blocks+=
"undefined"===typeof a?1:a;0<this.blocks&&(this.state=f[this.state].block)};n.prototype.unblock=function(a){this.blocks-="undefined"===typeof a?1:a;0===this.blocks&&"done"!==this.state&&(this.state="running",g(this,0));return this.blocks};n.prototype.sleep=function(a){this.state=f[this.state].sleep;var c=this;this.timeoutId=setTimeout(function(){c.timeoutId=null;c.state="running";g(c,0)},"undefined"===typeof a?0:a)};n.prototype.wait=function(a){a.wait(this)};n.prototype.wakeup=function(){"sleeping"===
this.state&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state="running",g(this,0))};n.prototype.cancel=function(){this.state=f[this.state].cancel;this.permitsNeeded=0;null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null);this.subtasks=[]};n.prototype.fail=function(a){this.error=!0;p(this,!0);if(a)a.error=this.error,a.swapTime=this.swapTime,a.userData=this.userData,g(a,0);else{if(null!==this.parent){for(a=this.parent;null!==a.parent;)a.error=this.error,a.swapTime=this.swapTime,
a.userData=this.userData,a=a.parent;p(a,!0)}this.failureCallback&&this.failureCallback(this)}};var h=function(a){a.error=!1;a.state=f[a.state].start;setTimeout(function(){"running"===a.state&&(a.swapTime=+new Date,a.run(a),g(a,0))},0)},g=function(a,c){var b=30<c||20<+new Date-a.swapTime,d=function(c){c++;if("running"===a.state)if(b&&(a.swapTime=+new Date),0<a.subtasks.length){var d=a.subtasks.shift();d.error=a.error;d.swapTime=a.swapTime;d.userData=a.userData;d.run(d);d.error||g(d,c)}else p(a),a.error||
null===a.parent||(a.parent.error=a.error,a.parent.swapTime=a.swapTime,a.parent.userData=a.userData,g(a.parent,c))};b?setTimeout(d,0):d(c)},p=function(a,d){a.state="done";delete b[a.id];null===a.parent&&(a.type in e?0===e[a.type].length?c.log.error("forge.task","[%s][%s] task queue empty [%s]",a.id,a.name,a.type):e[a.type][0]!==a?c.log.error("forge.task","[%s][%s] task not first in queue [%s]",a.id,a.name,a.type):(e[a.type].shift(),0===e[a.type].length?delete e[a.type]:e[a.type][0].start()):c.log.error("forge.task",
"[%s][%s] task queue missing [%s]",a.id,a.name,a.type),d||(a.error&&a.failureCallback?a.failureCallback(a):!a.error&&a.successCallback&&a.successCallback(a)))};c.task=c.task||{};c.task.start=function(a){var c=new n({run:a.run,name:a.name||"?"});c.type=a.type;c.successCallback=a.success||null;c.failureCallback=a.failure||null;c.type in e?e[a.type].push(c):(e[c.type]=[c],h(c))};c.task.cancel=function(a){a in e&&(e[a]=[e[a][0]])};c.task.createCondition=function(){var a={tasks:{},wait:function(c){c.id in
a.tasks||(c.block(),a.tasks[c.id]=c)},notify:function(){var c=a.tasks;a.tasks={};for(var b in c)c[b].unblock()}};return a}}if("function"!==typeof c)if("object"===typeof module&&module.exports){var f=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,p=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);b=b||{};b.defined=b.defined||{};if(b.defined.task)return b.task;b.defined.task=!0;for(var f=0;f<e.length;++f)e[f](b);return b.task}},
r=c;c=function(a,b){n="string"===typeof a?b.slice(2):a.slice(2);if(f)return delete c,r.apply(null,Array.prototype.slice.call(arguments,0));c=r;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/task",["require","module","./debug","./log","./util"],function(){p.apply(null,Array.prototype.slice.call(arguments,0))})})();(function(){if("function"!==typeof c)if("object"===typeof module&&module.exports){var a=!0;c=function(a,c){c(b,module)}}else{"undefined"===typeof forge&&(forge={disableNativeCode:!1});
return}var f,n=function(a,c){c.exports=function(c){var b=f.map(function(c){return a(c)});c=c||{};c.defined=c.defined||{};if(c.defined.forge)return c.forge;c.defined.forge=!0;for(var d=0;d<b.length;++d)b[d](c);return c};c.exports.disableNativeCode=!0;c.exports(c.exports)},p=c;c=function(b,l){f="string"===typeof b?l.slice(2):b.slice(2);if(a)return delete c,p.apply(null,Array.prototype.slice.call(arguments,0));c=p;return c.apply(null,Array.prototype.slice.call(arguments,0))};c("js/forge","require module ./aes ./aesCipherSuites ./asn1 ./cipher ./cipherModes ./debug ./des ./hmac ./kem ./log ./md ./mgf1 ./pbkdf2 ./pem ./pkcs7 ./pkcs1 ./pkcs12 ./pki ./prime ./prng ./pss ./random ./rc2 ./ssh ./task ./tls ./util".split(" "),
function(){n.apply(null,Array.prototype.slice.call(arguments,0))})})();return b("js/forge")});function amtcert_linkCertPrivateKey(a,b){for(var c in a){var d=a[c];try{if(0==xxCertPrivateKeys.length)break;for(var f=forge.pki.publicKeyToPem(forge.pki.certificateFromAsn1(forge.asn1.fromDer(d.X509Certificate)).publicKey).substring(60).replace(/(\r\n|\n|\r)/gm,""),n=0;n<b.length;n++)f===b[n].DERKey+"-----END PUBLIC KEY-----"&&(b[n].XCert=d,d.XPrivateKey=b[n])}catch(p){console.log(p)}}}
function amtcert_loadP12File(a,b,c){try{var d=window.forge.util.decode64(btoa(a)),f=window.forge.asn1.fromDer(d),n=window.forge.pkcs12.pkcs12FromAsn1(f,b),p=n.getBags({bagType:window.forge.pki.oids.pkcs8ShroudedKeyBag});console.assert(p[window.forge.pki.oids.pkcs8ShroudedKeyBag]&&0<p[window.forge.pki.oids.pkcs8ShroudedKeyBag].length);var r=p[window.forge.pki.oids.pkcs8ShroudedKeyBag][0].key,l=window.forge.pki.privateKeyToAsn1(r),k=window.forge.pki.wrapRsaPrivateKey(l);window.forge.asn1.toDer(k).getBytes();
2018-10-03 22:03:09 +03:00
var v=n.getBags({bagType:window.forge.pki.oids.certBag})[window.forge.pki.oids.certBag][0].cert.subject.attributes,e=n.getBags({bagType:forge.pki.oids.certBag})[forge.pki.oids.certBag][0].cert;c(r,v,e);return!0}catch(u){}return!1}function amtcert_signWithCaKey(a,b,c,d,f){b&&null!=b||(b=amtcert_createCertificate(d).key);return amtcert_createCertificate(c,b,a,d,f)}
2018-08-24 02:55:06 +03:00
function amtcert_createCertificate(a,b,c,d,f){var n,p=forge.pki.createCertificate();c?p.publicKey=forge.pki.publicKeyFromPem("-----BEGIN PUBLIC KEY-----"+c+"-----END PUBLIC KEY-----"):(n=forge.pki.rsa.generateKeyPair(2048),p.publicKey=n.publicKey);p.serialNumber=""+Math.floor(1E5*Math.random()+1);p.validity.notBefore=new Date;p.validity.notBefore.setFullYear(p.validity.notBefore.getFullYear()-1);p.validity.notAfter=new Date;p.validity.notAfter.setFullYear(p.validity.notAfter.getFullYear()+30);var r=
[];a.CN&&r.push({name:"commonName",value:a.CN});a.C&&r.push({name:"countryName",value:a.C});a.ST&&r.push({shortName:"ST",value:a.ST});a.O&&r.push({name:"organizationName",value:a.O});p.setSubject(r);b?(a=[],d.CN&&a.push({name:"commonName",value:d.CN}),d.C&&a.push({name:"countryName",value:d.C}),d.ST&&a.push({shortName:"ST",value:d.ST}),d.O&&a.push({name:"organizationName",value:d.O}),p.setIssuer(a)):p.setIssuer(r);void 0==b?p.setExtensions([{name:"basicConstraints",cA:!0},{name:"nsCertType",sslCA:!0,
emailCA:!0,objCA:!0},{name:"subjectKeyIdentifier"}]):(null==f?f={name:"extKeyUsage",serverAuth:!0}:f.name="extKeyUsage",p.setExtensions([{name:"basicConstraints"},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},f,{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0},{name:"subjectKeyIdentifier"}]));b?p.sign(b,forge.md.sha256.create()):p.sign(n.privateKey,forge.md.sha256.create());return c?p:{cert:p,key:n.privateKey}}
function _stringToArrayBuffer(a){for(var b=new ArrayBuffer(a.length),c=new Uint8Array(b),d=0,f=a.length;d<f;d++)c[d]=a.charCodeAt(d);return b}function _arrayBufferToString(a){var b="";a=new Uint8Array(a);for(var c=a.byteLength,d=0;d<c;d++)b+=String.fromCharCode(a[d]);return b}script_functionTable1="nop jump set print dialog getitem substr indexof split join length jsonparse jsonstr add substract parseint wsbatchenum wsput wscreate wsdelete wsexec scriptspeed wssubscribe wsunsubscribe readchar signwithdummyca".split(" ");
script_functionTable2="encodeuri decodeuri passwordcheck atob btoa hex2str str2hex random md5 maketoarray readshort readshortx readint readsint readintx shorttostr shorttostrx inttostr inttostrx".split(" ");script_functionTableX2=[encodeURI,decodeURI,passwordcheck,window.atob.bind(window),window.btoa.bind(window),hex2rstr,rstr2hex,random,rstr_md5,MakeToArray,ReadShort,ReadShortX,ReadInt,ReadSInt,ReadIntX,ShortToStr,ShortToStrX,IntToStr,IntToStrX];script_functionTable3="pullsystemstatus pulleventlog pullauditlog pullcertificates pullwatchdog pullsystemdefense pullhardware pulluserinfo pullremoteaccess highlightblock disconnect getsidstring getsidbytearray pulleventsubscriptions".split(" ");
script_functionTableX3=[PullSystemStatus,PullEventLog,PullAuditLog,PullCertificates,PullWatchdog,PullSystemDefense,PullHardware,PullUserInfo,PullRemoteAccess,script_HighlightBlock,,function(a,b){return GetSidString(b)},function(a,b){return GetSidByteArray(b)},PullEventSubscriptions];
function script_setup(a,b){var c={startvars:b};if(6>a.length)return console.error("Invalid script length"),null;if(612182341!=ReadInt(a,0))return console.error("Invalid binary script"),null;if(1<ReadShort(a,4))return console.error("Unsupported script version"),null;c.script=a.substring(6);c.reset=function(a){c.stop();c.ip=0;c.variables=b;c.state=1};c.start=function(a){c.stop();c.stepspeed=a;0<a&&(c.timer=setInterval(function(){c.step()},a))};c.stop=function(){null!=c.timer&&clearInterval(c.timer);
c.timer=null;c.stepspeed=0};c.getVar=function(a){return void 0==a?void 0:c.getVarEx(a.split("."),c.variables)};c.getVarEx=function(a,b){try{return void 0==a?void 0:0==a.length?b:c.getVarEx(a.slice(1),b[a[0]])}catch(n){return null}};c.setVar=function(a,b){c.setVarEx(a.split("."),c.variables,b)};c.setVarEx=function(a,b,n){1==a.length?b[a[0]]=n:c.setVarEx(a.slice(1),b[a[0]],n)};c.step=function(){if(1==c.state){if(c.ip<c.script.length){var a=ReadShort(c.script,c.ip),b=ReadShort(c.script,c.ip+2),n=ReadShort(c.script,
2018-10-03 22:03:09 +03:00
c.ip+4),p=c.ip+6,r=[],l;for(l in c.variables)l.startsWith("__")&&delete c.variables[l];for(l=0;l<n;l++){var k=ReadShort(c.script,p),v=c.script.substring(p+2,p+2+k),e=v.charCodeAt(0),v=v.substring(1);if(2>e){for(;1<v.split("{").length;)var u=v.split("{").pop().split("}").shift(),v=v.replace("{"+u+"}",c.getVar(u));1==e&&(c.variables["__"+l]=decodeURI(v),v="__"+l);r.push(v)}if(2==e||3==e)c.variables["__"+l]=ReadSInt(v,0),r.push("__"+l);p+=2+k}c.ip+=b;b=[];for(l=0;10>l;l++)b.push(c.getVar(r[l]));var B;
2018-08-24 02:55:06 +03:00
try{if(1E4>a)switch(a){case 0:break;case 1:if(b[2]){if("<"==b[2]&&b[1]<b[3]||"<="==b[2]&&b[1]<=b[3]||"!="==b[2]&&b[1]!=b[3]||"="==b[2]&&b[1]==b[3]||">="==b[2]&&b[1]>=b[3]||">"==b[2]&&b[1]>b[3])c.ip=b[0]}else c.ip=b[0];break;case 2:void 0==r[1]?delete c.variables[r[0]]:c.setVar(r[0],b[1]);break;case 3:if(c.onConsole)c.onConsole(c.toString(b[0]),c);else console.log(c.toString(b[0]));break;case 4:c.state=2;c.dialog=!0;setDialogMode(11,b[0],b[2],c.xxStepDialogOk,b[1],c);break;case 5:for(l in b[1])b[1][l][b[2]]==
b[3]&&(B=l);break;case 6:B=b[1].substr(b[2],b[3]);break;case 7:B=b[1].indexOf(b[2]);break;case 8:B=b[1].split(b[2]);break;case 9:B=b[1].join(b[2]);break;case 10:B=b[1].length;break;case 11:B=JSON.parse(b[1]);break;case 12:B=JSON.stringify(b[1]);break;case 13:B=b[1]+b[2];break;case 14:B=b[1]-b[2];break;case 15:B=parseInt(b[1]);break;case 16:c.state=2;c.amtstack.BatchEnum(b[0],b[1],c.xxWsmanReturn,c);break;case 17:c.state=2;c.amtstack.Put(b[0],b[1],c.xxWsmanReturn,c);break;case 18:c.state=2;c.amtstack.Create(b[0],
b[1],c.xxWsmanReturn,c);break;case 19:c.state=2;c.amtstack.Delete(b[0],b[1],c.xxWsmanReturn,c);break;case 20:c.state=2;c.amtstack.Exec(b[0],b[1],b[2],c.xxWsmanReturn,c,0,b[3]);break;case 21:c.stepspeed=b[0];null!=c.timer&&(clearInterval(c.timer),c.timer=setInterval(function(){c.step()},c.stepspeed));break;case 22:c.state=2;c.amtstack.Subscribe(b[0],b[1],b[2],c.xxWsmanReturn,c,0,b[3],b[4],b[5],b[6]);break;case 23:c.state=2;c.amtstack.UnSubscribe(b[0],c.xxWsmanReturn,c,0,b[1]);break;case 24:console.log(b[1],
b[2],b[1].charCodeAt(b[2]));B=b[1].charCodeAt(b[2]);break;case 25:c.state=2;amtcert_signWithCaKey(b[0],null,b[1],{CN:"Untrusted Root Certificate"},c.xxSignWithDummyCaReturn);break;default:c.state=9,console.error("Script Error, unknown command: "+a)}else 2E4>a?B=script_functionTableX2[a-1E4](b[1],b[2],b[3],b[4],b[5],b[6]):script_functionTableX3&&script_functionTableX3[a-2E4]&&(B=script_functionTableX3[a-2E4](c,b[1],b[2],b[3],b[4],b[5],b[6]));void 0!=B&&c.setVar(r[0],B)}catch(h){"object"==typeof h&&
(h=h.message),c.setVar("_exception",h)}}1==c.state&&c.ip>=c.script.length&&(c.state=0,c.stop());if(c.onStep)c.onStep(c);return c}};c.xxStepDialogOk=function(a){c.variables.DialogSelect=a;c.state=1;c.dialog=!1;if(c.onStep)c.onStep(c)};c.xxWsmanReturn=function(a,b,n,p){c.setVar(b,n);c.setVar("wsman_result",p);c.setVar("wsman_result_str",httpErrorTable[p]?httpErrorTable[p]:"Error #"+p);c.state=1;if(c.onStep)c.onStep(c)};c.xxSignWithDummyCaReturn=function(a){c.setVar("signed_cert",btoa(_arrayBufferToString(a)));
c.state=1;if(c.onStep)c.onStep(c)};c.toString=function(a){return"object"==typeof a?JSON.stringify(a):a};c.reset();return c}
2018-10-03 22:03:09 +03:00
function script_compile(a,b){var c="",d=a.split("\n"),f={},n=[],p=[],r;for(r in d){var l=d[r];if(l.startsWith("##SWAP ")){var k=l.split(" ");3==k.length&&(p[k[1]]=k[2])}if("#"!=l[0]&&0!=l.length){for(k in p)l=l.split(k).join(p[k]);var v=l.match(/"[^"]*"|[^\s"]+/g);if(0!=v.length)if(":"==l[0])f[v[0].toUpperCase()]=c.length;else{l=script_functionTable1.indexOf(v[0].toLowerCase());-1==l&&(l=script_functionTable2.indexOf(v[0].toLowerCase()),0<=l&&(l+=1E4));-1==l&&(l=script_functionTable3.indexOf(v[0].toLowerCase()),
0<=l&&(l+=2E4));if(-1==l)return b&&b("Unabled to compile, unknown command: "+v[0]),"";var e=ShortToStr(v.length-1),u;for(u in v)if(0!=u)if(":"==v[u][0])n.push([v[u],c.length+e.length+7]),e+=ShortToStr(5)+String.fromCharCode(3)+IntToStr(4294967295);else var B=parseInt(v[u]),e=B==v[u]?e+(ShortToStr(5)+String.fromCharCode(2)+IntToStr(B)):'"'==v[u][0]&&'"'==v[u][v[u].length-1]?e+(ShortToStr(v[u].length-1)+String.fromCharCode(1)+v[u].substring(1,v[u].length-1)):e+(ShortToStr(v[u].length+1)+String.fromCharCode(0)+
v[u]);e=ShortToStr(l)+ShortToStr(e.length+4)+e;c+=e}}}for(r in n){d=n[r][0].toUpperCase();p=n[r][1];k=f[d];if(void 0==k)return b&&b("Unabled to compile, unknown label: "+d),"";c=c.substr(0,p)+IntToStr(k)+c.substr(p+4)}return IntToStr(612182341)+ShortToStr(1)+c}
function script_decompile(a,b){var c="",d=6,f={};if(0<=b)d=b;else{if(6>a.length)return"# Invalid script length";var n=ReadInt(a,0),p=ReadShort(a,4);if(612182341!=n)return"# Invalid binary script: "+n;if(1!=p)return"# Invalid script version"}for(;d<a.length;){var n=ReadShort(a,d),p=ReadShort(a,d+2),r=ReadShort(a,d+4),l=d+6,k="";0<=b||(c+=":label"+(d-6)+"\n");for(var v=0;v<r;v++){var e=ReadShort(a,l),u=a.substring(l+2,l+2+e),B=u.charCodeAt(0);0==B?k+=" "+u.substring(1):1==B?k+=' "'+u.substring(1)+'"':
2==B?k+=" "+ReadInt(u,1):3==B&&(u=ReadInt(u,1),B=f[u],B||(B=":label"+u,f[B]=u),k+=" "+B);l+=2+e}c=1E4>n?c+(script_functionTable1[n]+k+"\n"):2E4<=n?c+(script_functionTable3[n-2E4]+k+"\n"):c+(script_functionTable2[n-1E4]+k+"\n");d+=p;if(0<=b)return c}d=c.split("\n");c="";for(v in d)n=d[v],":"!=n[0]?c+=n+"\n":f[n]&&(c+=n+"\n");return c}
2018-08-24 02:55:06 +03:00
var saveAs=saveAs||function(a){if("undefined"===typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var b=a.document.createElementNS("http://www.w3.org/1999/xhtml","a"),c="download"in b,d=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),f=a.webkitRequestFileSystem,n=a.requestFileSystem||f||a.mozRequestFileSystem,p=function(b){(a.setImmediate||a.setTimeout)(function(){throw b;},0)},r=0,l=function(b){var c=function(){"string"===typeof b?(a.URL||a.webkitURL||a).revokeObjectURL(b):b.remove()};
2018-11-15 02:44:28 +03:00
a.chrome?c():setTimeout(c,500)},k=function(a,b,c){b=[].concat(b);for(var d=b.length;d--;){var e=a["on"+b[d]];if("function"===typeof e)try{e.call(a,c||a)}catch(f){p(f)}}},v=function(a){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\ufeff",a],{type:a.type}):a},e=function(e,h,g){g||(e=v(e));var p=this;g=e.type;var m=!1,u,w,y=function(){k(p,["writestart","progress","write","writeend"])},C=function(){if(w&&d&&"undefined"!==typeof FileReader){var b=
new FileReader;b.onloadend=function(){var a=b.result;w.location.href="data:attachment/file"+a.slice(a.search(/[,;]/));p.readyState=p.DONE;y()};b.readAsDataURL(e);p.readyState=p.INIT}else{if(m||!u)u=(a.URL||a.webkitURL||a).createObjectURL(e);w?w.location.href=u:void 0==a.open(u,"_blank")&&d&&(a.location.href=u);p.readyState=p.DONE;y();l(u)}},A=function(a){return function(){if(p.readyState!==p.DONE)return a.apply(this,arguments)}},L={create:!0,exclusive:!1},z;p.readyState=p.INIT;h||(h="download");if(c)u=
(a.URL||a.webkitURL||a).createObjectURL(e),b.href=u,b.download=h,setTimeout(function(){var a=new MouseEvent("click");b.dispatchEvent(a);y();l(u);p.readyState=p.DONE});else{a.chrome&&g&&"application/octet-stream"!==g&&(z=e.slice||e.webkitSlice,e=z.call(e,0,e.size,"application/octet-stream"),m=!0);f&&"download"!==h&&(h+=".download");if("application/octet-stream"===g||f)w=a;n?(r+=e.size,n(a.TEMPORARY,r,A(function(a){a.root.getDirectory("saved",L,A(function(a){var b=function(){a.getFile(h,L,A(function(a){a.createWriter(A(function(b){b.onwriteend=
function(b){w.location.href=a.toURL();p.readyState=p.DONE;k(p,"writeend",b);l(a)};b.onerror=function(){var a=b.error;a.code!==a.ABORT_ERR&&C()};["writestart","progress","write","abort"].forEach(function(a){b["on"+a]=p["on"+a]});b.write(e);p.abort=function(){b.abort();p.readyState=p.DONE};p.readyState=p.WRITING}),C)}),C)};a.getFile(h,{create:!1},A(function(a){a.remove();b()}),A(function(a){a.code===a.NOT_FOUND_ERR?b():C()}))}),C)}),C)):C()}},u=e.prototype;if("undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob)return function(a,
2018-10-03 22:03:09 +03:00
b,c){c||(a=v(a));return navigator.msSaveOrOpenBlob(a,b||"download")};u.abort=function(){this.readyState=this.DONE;k(this,"abort")};u.readyState=u.INIT=0;u.WRITING=1;u.DONE=2;u.error=u.onwritestart=u.onprogress=u.onwrite=u.onabort=u.onerror=u.onwriteend=null;return function(a,b,c){return new e(a,b,c)}}}("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this.content);
2018-08-24 02:55:06 +03:00
"undefined"!==typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!==typeof define&&null!==define&&null!=define.amd&&define([],function(){return saveAs});
2018-11-15 02:44:28 +03:00
var version="0.7.3",urlvars={},amtstack,wsstack=null,AllWsman="AMT_8021xCredentialContext AMT_8021XProfile AMT_ActiveFilterStatistics AMT_AgentPresenceCapabilities AMT_AgentPresenceInterfacePolicy AMT_AgentPresenceService AMT_AgentPresenceWatchdog AMT_AgentPresenceWatchdogAction AMT_AlarmClockService IPS_AlarmClockOccurrence AMT_AssetTable AMT_AssetTableService AMT_AuditLog AMT_AuditPolicyRule AMT_AuthorizationService AMT_BootCapabilities AMT_BootSettingData AMT_ComplexFilterEntryBase AMT_CRL AMT_CryptographicCapabilities AMT_EACCredentialContext AMT_EndpointAccessControlService AMT_EnvironmentDetectionInterfacePolicy AMT_EnvironmentDetectionSettingData AMT_EthernetPortSettings AMT_EventLogEntry AMT_EventManagerService AMT_EventSubscriber AMT_FilterEntryBase AMT_FilterInSystemDefensePolicy AMT_GeneralSettings AMT_GeneralSystemDefenseCapabilities AMT_Hdr8021Filter AMT_HeuristicPacketFilterInterfacePolicy AMT_HeuristicPacketFilterSettings AMT_HeuristicPacketFilterStatistics AMT_InterfacePolicy AMT_IPHeadersFilter AMT_KerberosSettingData AMT_ManagementPresenceRemoteSAP AMT_MessageLog AMT_MPSUsernamePassword AMT_NetworkFilter AMT_NetworkPortDefaultSystemDefensePolicy AMT_NetworkPortSystemDefenseCapabilities AMT_NetworkPortSystemDefensePolicy AMT_PCIDevice AMT_PETCapabilities AMT_PETFilterForTarget AMT_PETFilterSetting AMT_ProvisioningCertificateHash AMT_PublicKeyCertificate AMT_PublicKeyManagementCapabilities AMT_PublicKeyManagementService AMT_PublicPrivateKeyPair AMT_RedirectionService AMT_RemoteAccessCapabilities AMT_RemoteAccessCredentialContext AMT_RemoteAccessPolicyAppliesToMPS AMT_RemoteAccessPolicyRule AMT_RemoteAccessService AMT_SetupAndConfigurationService AMT_SNMPEventSubscriber AMT_StateTransitionCondition AMT_SystemDefensePolicy AMT_SystemDefensePolicyInService AMT_SystemDefenseService AMT_SystemPowerScheme AMT_ThirdPartyDataStorageAdministrationService AMT_ThirdPartyDataStorageService AMT_TimeSynchronizationService AMT_TLSCredentialContext AMT_TLSProtocolEndpoint AMT_TLSProtocolEndpointCollection AMT_TLSSettingData AMT_TrapTargetForService AMT_UserInitiatedConnectionService AMT_WebUIService AMT_WiFiPortConfigurationService CIM_AbstractIndicationSubscription CIM_Account CIM_AccountManagementCapabilities CIM_AccountManagementService CIM_AccountOnSystem CIM_AdminDomain CIM_AlertIndication CIM_AssignedIdentity CIM_AssociatedPowerManagementService CIM_AuthenticationService CIM_AuthorizationService CIM_BIOSElement CIM_BIOSFeature CIM_BIOSFeatureBIOSElements CIM_BootConfigSetting CIM_BootService CIM_BootSettingData CIM_BootSourceSetting CIM_Capabilities CIM_Card CIM_Chassis CIM_Chip CIM_Collection CIM_Component CIM_ComputerSystem CIM_ComputerSystemPackage CIM_ConcreteComponent CIM_ConcreteDependency CIM_Controller CIM_CoolingDevice CIM_Credential CIM_CredentialContext CIM_CredentialManagementService CIM_Dependency CIM_DeviceSAPImplementation CIM_ElementCapabilities CIM_ElementConformsToProfile CIM_ElementLocation CIM_ElementSettingData CIM_ElementSoftwareIdentity CIM_ElementStatisticalData CIM_EnabledLogicalElement CIM_EnabledLogicalElementCapabilities CIM_EthernetPort CIM_Fan CIM_FilterCollection CIM_FilterCollectionSubscription CIM_HostedAccessPoint CIM_HostedDependency CIM_HostedService CIM_Identity CIM_IEEE8021xCapabilities CIM_IEEE8021xSettings CIM_Indication CIM_IndicationService CIM_InstalledSoftwareIdentity CIM_KVMRedirectionSAP CIM_LANEndpoint CIM_ListenerDestination CIM_ListenerDestinationWSManagement CIM_Location CIM_Log CIM_LogEntry CIM_LogicalDevice CIM_LogicalElement CIM_LogicalPort CIM_LogicalPortCapabilities CIM_LogManagesRecord CIM_ManagedCredential CIM_ManagedElement CIM_ManagedSystemElement CIM_MediaAccessDevice CIM_MemberOfCollection CIM_Memory CIM_MessageLog CIM_NetworkPort CIM_NetworkPortCapabilities CIM_NetworkPortConfigurationService CIM_OrderedComponent CIM_OwningCollectionElement CIM_OwningJobElement CIM_PCIController CIM_PhysicalComponent CIM_PhysicalElement CIM_PhysicalElementLocation CIM_PhysicalFrame CIM_PhysicalMemory CIM_PhysicalPackage CIM_Policy CIM_PolicyAction CIM_PolicyCondition CI
2018-08-24 02:55:06 +03:00
null,currentView=0,LoadingHtml="<div style=text-align:center;padding-top:20px>Loading...<div>",amtversion=0,amtversionmin=0,amtFirstPull=0,amtwirelessif=-1,currentMeshNode=null,webcompilerfeatures="AgentPresence Alarms AuditLog Certificates ComputerSelectorToolbar EventLog EventSubscriptions FileSaver HardwareInfo Look-MeshCentral Mode-MeshCentral2 NetworkSettings PowerControl PowerControl-Advanced RemoteAccess Scripting Scripting-Editor Storage SystemDefense VersionWarning Wireless WsmanBrowser".split(" "),
StatusStrs=["Disconnected","Connecting...","Setup...","Connected"],scriptstate,t,t2,rsepass=null;
function startup(){var a=document.getElementsByTagName("input");for(t=0;t<a.length;t++)a[t].id&&(window[a[t].id]=a[t]);urlvars=getUrlVars();for(var b in AllWsman)a=document.createElement("option"),a.text=AllWsman[b],a.id="WSB-"+AllWsman[b],Q(22).add(a);document.addEventListener("dragover",haltEvent,!1);document.addEventListener("dragleave",haltEvent,!1);document.addEventListener("drop",documentFileSelectHandler,!1);Q("p16").addEventListener("dragover",haltEvent,!1);Q("p16").addEventListener("dragleave",
haltEvent,!1);Q("p16").addEventListener("drop",cert_FileSelectHandler,!1);document.onkeyup=handleKeyUp;document.onkeydown=handleKeyDown;document.onkeypress=handleKeyPress;window.onresize=center;center();scriptLoadStartingBlocks()}
function documentFileSelectHandler(a){haltEvent(a);if(null!=a.dataTransfer&&1==a.dataTransfer.files.length){var b=null,c=a.dataTransfer.files[0].name.toLowerCase();21==currentView?UploadToStorage(a.dataTransfer.files[0],c):(null!=wsstack&&(c.endsWith(".mescript")||c.endsWith(".meblocks"))&&(b=script_onScriptRead),null!=b&&(c=new FileReader,c.onload=b,c.readAsBinaryString(a.dataTransfer.files[0])))}}
function connectButtonfunction(){wsstack&&0!=wsstack.socketState?disconnect():meshcentral2credCallback()}function connectButtonfunctionEx(){currentMeshNode=parent.getCurrentNode();connect(currentMeshNode._id,16992,null,null,0);Q("xconnectbutton1").value="Disconnect"}function getCurrentMeshNode(){return currentMeshNode}function setConnectionState(a){QE("xconnectbutton1",a);0==a&&disconnect()}function setFrameHeight(a){}function setAuthCallback(a){meshcentral2credCallback=a}function cleanup(){}
function handleKeyUp(a){}function handleKeyDown(a){}function handleKeyPress(a){}
function connect(a,b,c,d,f){go(0);wsstack=WsmanStackCreateService(a,b,c,d,f);amtstack=AmtStackCreateService(wsstack);amtstack.onProcessChanged=onProcessChanged;for(a=2;25>a;a++)QV("go"+a,!1);QV("go8",!0);QV("go12",!0);QV("go20",!0);amtversion=amtversionmin=amtFirstPull=0;amtsysstate=amtdeltatime=amtlogicalelements=HardwareInventory=void 0;amtPowerBootCapabilities=null;xxAccountFetch=999;QH(15,LoadingHtml);QH(19,LoadingHtml);amtwirelessif=-1;xxWireless=void 0;
QH(20,"");QH(16,LoadingHtml);xxAccountAdminName=null;xxAccountRealmInfo={};QH(21,LoadingHtml);eventmessages=null;QH(17,"");QH(18,LoadingHtml);auditLog=null;QH(25,"");QH(26,LoadingHtml);xxCertificates=null;QH(27,LoadingHtml);QH(24,"");xxPolicies=xxMPSUserPass=xxRemoteAccessCredentiaLinks=xxUserInitiatedCira=xxCiraServers=xxEnvironementDetection=xxRemoteAccess=
null;QH(28,LoadingHtml);QH(30,LoadingHtml);xxSystemDefense=null;xxSystemDefenceLinkedPolicy={};xxUpdatingDefenseStats=!1;xxFilterStatistics=[{},{}];xxFilterStatisticsTimer=null;xxFilterStatisticsTimerActive=!1;QH(29,LoadingHtml);amtstack.BatchEnum("",["CIM_SoftwareIdentity","*AMT_SetupAndConfigurationService"],processSystemVersion);QV(11,!1);fupdatescript()}
function disconnect(){StopDefenseStatsTimer();script_Stop();breakScriptButton();dialogclose(0);amtstack&&(amtstack.onProcessChanged=null,amtstack.CancelAllQueries(999),amtstack=null);cleanup();wsstack=null;delete amtstack;onProcessChanged(0,1);go(101);Q("xconnectbutton1").value="Connect";QH(5,"Disconnected");go(100)}
function onProcessChanged(a,b){QS(3).width=100*a/b+"%";0==a&&refreshButtons(!0);0==a&&amtstack&&(0<amtversion&&0==(amtFirstPull&64)?(amtFirstPull|=64,PullPowerPolicy(),subscriptionsFilters=null,PullEventSubscriptions(),PullWatchdog(),scriptViewButton(script_BuildingBlocks?1:0),5<amtversion&&(PullCertificates(),PullRemoteAccess())):0==(amtFirstPull&1)?PullHardware():0==(amtFirstPull&16)?PullEventLog():0==(amtFirstPull&32)&&PullAuditLog())}
function checkAmtVersion(a){var b=a.split(".");a=parseInt(b[0]);var c=parseInt(b[1]),b=parseInt(b[2]),b=1E3*c+b,d=0;5>=a||12<=a?d=1:6==a&&2061<=b?d=1:7==a&&1091<=b?d=1:8==a&&1071<=b?d=1:9==a?5>c&&1041<=b?d=1:5061<=b&&(d=1):10==a&&55<=b?d=1:11==a&&(5>c&&25<=b?d=1:6027<=b&&(d=1));return 0==d}
function processSystemVersion(a,b,c,d){if(200==d||400==d){if(200==d){amtlogicalelements=[];null!=c&&null!=c.CIM_SoftwareIdentity&&null!=c.CIM_SoftwareIdentity.responses&&(amtlogicalelements=c.CIM_SoftwareIdentity.responses,null!=c.AMT_SetupAndConfigurationService&&null!=c.AMT_SetupAndConfigurationService.response&&amtlogicalelements.push(c.AMT_SetupAndConfigurationService.response));if(0==amtlogicalelements.length){console.error("ERROR: Could not get Intel AMT version.");disconnect();return}b=getInstance(amtlogicalelements,
"AMT").VersionString}else if(b=a.wsman.comm.amtVersion,!b){errcheck(400,a);return}amtversion=parseInt(b.split(".")[0]);amtversionmin=parseInt(b.split(".")[1]);QV(11,checkAmtVersion(b));PullUserInfo();PullSystemStatus();updateSystemStatus();8<=amtversion&&PullAlarms()}else errcheck(d,a)}var refreshButtonsState=!0;
function refreshButtons(a){if(refreshButtonsState!=a){refreshButtonsState=a;for(var b=0,c=document.getElementsByTagName("input");b<c.length;b++)"refreshbtn"==c[b].name&&(c[b].disabled=!a)}}function PullPowerState(){amtstack&&0==amtstack.GetPendingActions()&&amtsysstate&&amtsysstate.CIM_ServiceAvailableToElement&&amtstack.Enum("CIM_ServiceAvailableToElement",function(a,b,c,d){errcheck(d,a)||(amtsysstate.CIM_ServiceAvailableToElement.responses=c,updateSystemStatus())})}
function PullSystemStatus(a){refreshButtons(!1);amtstack.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch(processSystemTime);var b=["CIM_ServiceAvailableToElement","*AMT_GeneralSettings","AMT_EthernetPortSettings","*AMT_RedirectionService","CIM_ElementSettingData"];5<amtversion&&b.push("IPS_IPv6PortSettings","*CIM_KVMRedirectionSAP","*IPS_OptInService","*IPS_KVMRedirectionSettingData");9<amtversion&&b.push("*IPS_ScreenConfigurationService");amtstack.BatchEnum("",b,processSystemStatus,!0);1==
a&&PullWireless()}function processSystemTime(a,b,c,d){errcheck(d,a)||200!=d||(a=new Date,b=new Date,a.setTime(1E3*c.Body.Ta0+6E4*a.getTimezoneOffset()),amtdeltatime=a-b,updateSystemStatus())}var amtdeltatime,amtsysstate,amtlogicalelements,amtfeatures={};
function processSystemStatus(a,b,c,d){if(void 0==c.IPS_ScreenConfigurationService||400==c.IPS_ScreenConfigurationService.status)c.IPS_ScreenConfigurationService=null;if(void 0==c.IPS_KVMRedirectionSettingData||400==c.IPS_KVMRedirectionSettingData.status)c.IPS_KVMRedirectionSettingData=null;if(void 0==c.CIM_KVMRedirectionSAP||400==c.CIM_KVMRedirectionSAP.status)c.CIM_KVMRedirectionSAP=null;if(void 0==c.IPS_OptInService||400==c.IPS_OptInService.status)c.IPS_OptInService=null;200==c.AMT_RedirectionService.status&&
QV("go13",!0);d=0;for(var f in c)null!=c[f]&&c[f].status>d&&(d=c[f].status);400!=d&&errcheck(d,a)||(amtsysstate=c,updateSystemStatus())}var DMTFPowerStates=";;Power on;Light sleep;Deep sleep;Power cycle (Soft off);Off - Hard;Hibernate (Off soft);Soft off;Power cycle (Off-hard);Master bus reset;Diagnostic interrupt (NMI);Not applicable;Off - Soft graceful;Off - Hard graceful;Master bus reset graceful;Power cycle (Off - Soft graceful);Power cycle (Off - Hard graceful);Diagnostic interrupt (INIT)".split(";");
function updateSystemStatus(){if(amtsysstate&&!(99<currentView)){var a=0,b,c,d=TableStart(),f="",n=amtsysstate.AMT_GeneralSettings.response;t="Unknown";null!=amtsysstate.CIM_ServiceAvailableToElement&&(t=DMTFPowerStates[amtsysstate.CIM_ServiceAvailableToElement.responses[0].PowerState]);n.PowerSource&&(t+=[", Plugged-in",", On Battery"][n.PowerSource]);d+=TableEntry("Power",addLink(t,"showPowerActionDlg()"));b=n.HostName;c=n.DomainName;null!=c&&0<c.length&&(b+="."+c);b=0==b.length?"<i>None</i>":EscapeHtml(b);
d+=TableEntry("Name & Domain",addLinkConditional(b,"showEditNameDlg()",xxAccountAdminName));HardwareInventory&&(d+=TableEntry("System ID",guidToStr(HardwareInventory.CIM_ComputerSystemPackage.response.PlatformGUID.toLowerCase())));if(amtlogicalelements){var p="",r=getItem(amtlogicalelements,"CreationClassName","AMT_SetupAndConfigurationService");2==r.ProvisioningState&&5<amtversion&&(p=" activated in Admin Control Mode (ACM)",4==r.ProvisioningMode&&(p=" activated in Client Control Mode (CCM)",a=9));
2018-08-27 22:24:15 +03:00
d+=TableEntry("Intel&reg; ME","v"+getItem(amtlogicalelements,"InstanceID","AMT").VersionString+p)}if(200==amtsysstate.AMT_RedirectionService.status){var p=amtfeatures[0]=1==amtsysstate.AMT_RedirectionService.response.ListenerEnabled,r=amtfeatures[1]=0!=(amtsysstate.AMT_RedirectionService.response.EnabledState&2),l=amtfeatures[2]=0!=(amtsysstate.AMT_RedirectionService.response.EnabledState&1),k=amtfeatures[3]=void 0;5<amtversion&&null!=amtsysstate.CIM_KVMRedirectionSAP&&(k=amtfeatures[3]=6==amtsysstate.CIM_KVMRedirectionSAP.response.EnabledState&&
2==amtsysstate.CIM_KVMRedirectionSAP.response.RequestedState||2==amtsysstate.CIM_KVMRedirectionSAP.response.EnabledState||6==amtsysstate.CIM_KVMRedirectionSAP.response.EnabledState);p&&(f+=", Redirection Port");r&&(f+=", Serial-over-LAN");l&&(f+=", IDE-Redirect");k&&(f+=", KVM");""==f&&(f=" None");d+=TableEntry("Active Features",addLinkConditional(f.substring(2),"showFeaturesDlg()",xxAccountAdminName))}null!=amtsysstate.IPS_KVMRedirectionSettingData&&amtsysstate.IPS_KVMRedirectionSettingData.response&&
(p=amtsysstate.IPS_KVMRedirectionSettingData.response,f="Primary display",7<amtversion&&void 0!==p.DefaultScreen&&255>p.DefaultScreen&&(f=["Primary display","Secondary display","3rd display"][p.DefaultScreen]),f='<span title="The default remote display is the '+f.toLowerCase()+'">'+f+"</span>",1==p.Is5900PortEnabled&&(f+=", Port 5900 enabled"),1==p.OptInPolicy&&(f+=", "+p.OptInPolicyTimeout+" second"+(0<p.OptInPolicyTimeout?"s":"")+" opt-in"),f+=", "+p.SessionTimeout+" minute"+(0<p.SessionTimeout?
"s":"")+" session timeout",9<amtversion&&null!=amtsysstate.IPS_ScreenConfigurationService&&0!=(amtsysstate.IPS_ScreenConfigurationService.response.EnabledState&1)&&(f+=", Blanking Allowed"),d+=TableEntry("Remote Desktop",f));5<amtversion&&null!=amtsysstate.IPS_OptInService&&void 0!=amtsysstate.IPS_OptInService.response&&(f="Unknown state",p=amtsysstate.IPS_OptInService.response.OptInRequired,0==p&&(f="Not Required"),1==p&&(f="Required for KVM only"),4294967295==p&&(f="Always Required"),1==amtsysstate.IPS_OptInService.response.CanModifyOptInPolicy&&
(f=addLinkConditional(f,"showConsentDlg()",xxAccountAdminName)),d+=TableEntry("User Consent",f));if(null!=AmtSystemPowerSchemes)for(f=amtsysstate.CIM_ElementSettingData.responses,p=0;p<f.length;p++)if(f[p].SettingData&&1==f[p].IsCurrent&&"http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SystemPowerScheme"==f[p].SettingData.ReferenceParameters.ResourceURI)for(r=f[p].SettingData.ReferenceParameters.SelectorSet.Selector[1].Value,l=0;l<AmtSystemPowerSchemes.length;l++)AmtSystemPowerSchemes[l].SchemeGUID==
r&&(d+=TableEntry("Power Policy",addLinkConditional(AmtSystemPowerSchemes[l].Description.split(":")[1],'showPowerPolicyDlg("'+r+'")',xxAccountAdminName)));amtdeltatime&&(d+=TableEntry("Date & Time",(new Date((new Date).getTime()+amtdeltatime)).toLocaleString()));f=AddRefreshButton("PullSystemStatus()")+" ";f+=AddButton("Power Actions...","showPowerActionDlg()")+" ";f+=AddButton("Save State...","saveEntireAmtState()")+" ";f+=AddButton("Run Script...","script_runScriptDlg()")+" ";d+=TableEnd(f);QH(15,
d);d="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px>"+TableEnd("<div>&nbsp;"+AddRefreshButton("PullSystemStatus(1)")+" Changing network settings may cause this page to becaume unavailable.");d=d+"<br><h2>General Settings</h2>"+TableStart();f="";"<i>None</i>"!=b&&(1==n.SharedFQDN&&(f=", shared with OS"),0==n.SharedFQDN&&(f=", different from OS"));d+=TableEntry("Name & Domain",addLinkConditional(b+f,"showEditNameDlg(1)",xxAccountAdminName));b="Disabled";1==n.DDNSUpdateEnabled?
b="Enabled each "+n.DDNSPeriodicUpdateInterval+" minutes, TTL is "+n.DDNSTTL+" minutes":1==n.DDNSUpdateByDHCPServerEnabled&&(b="Update by DHCP server");d+=TableEntry("Dynamic DNS",addLinkConditional(b,"showEditDnsDlg()",xxAccountAdminName));d+=TableEnd();for(c in amtsysstate.AMT_EthernetPortSettings.responses){b=amtsysstate.AMT_EthernetPortSettings.responses[c];if(b.WLANLinkProtectionLevel||1==c)amtwirelessif=c;if(0!=c||amtwirelessif==c||"00-00-00-00-00-00"!=b.MACAddress){0==c&&a++;d+="<br><h2>"+
(amtwirelessif==c?"Wireless":"Wired")+" Interface</h2>";d+=TableStart();d+=TableEntry("Link state",1==b.LinkIsUp?"Link is up":"Link is down");"00-00-00-00-00-00"!=b.MACAddress&&(d+=TableEntry("MAC address",b.MACAddress));amtwirelessif==c&&xxWireless&&xxWireless.CIM_WiFiPortCapabilities.response&&(d+=TableEntry("State",addLinkConditional(xxWifiState[xxWireless.CIM_WiFiPort.response.EnabledState],"showWifiStateDlg()",xxAccountAdminName)),s=xxWireless.CIM_WiFiEndpoint.response.LANID,d+=TableEntry("Radio State",
xxRadioState[xxWireless.CIM_WiFiEndpoint.response.EnabledState]+", SSID: "+(s?s:"<i>None</i>")));amtwirelessif!=c&&(d+=TableEntry("Respond to ping",addLinkConditional(["Disabled","ICMP response","RMCP response","ICMP & RMCP response"][n.PingResponseEnabled+(n.RmcpPingResponseEnabled<<1)],"showPingActionDlg()",xxAccountAdminName)),d+=TableEntry("IPv4 state",addLinkConditional(1==b.DHCPEnabled?"Automatic using DHCP server":"Static IP address","showIPSetupDlg()",xxAccountAdminName)));d+=TableEntry("IPv4 address",
2018-10-03 22:03:09 +03:00
isIpAddress(b.IPAddress,"None"));isIpAddress(b.DefaultGateway)&&(d+=TableEntry("IPv4 gateway / Mask",b.DefaultGateway+" / "+isIpAddress(b.SubnetMask,"None")));f=b.PrimaryDNS;isIpAddress(f)&&(b.SecondaryDNS&&(f+=" / "+b.SecondaryDNS),d+=TableEntry("IPv4 domain name server",f));if(200==amtsysstate.IPS_IPv6PortSettings.status&&5<amtversion){b=amtsysstate.IPS_IPv6PortSettings.responses[c];for(var r="Disabled",v,f=amtsysstate.CIM_ElementSettingData.responses,p=0;p<f.length;p++)f[p].SettingData&&f[p].SettingData.ReferenceParameters.SelectorSet.Selector.Value==
"Intel(r) IPS IPv6 Settings "+c&&(v=1==f[p].IsCurrent);1==v&&(f=isIpAddress(b.IPv6Address)||isIpAddress(b.DefaultRouter)||isIpAddress(b.PrimaryDNS)||isIpAddress(b.SecondaryDNS),r="Enabled, Automatic "+(f?"& manual":"")+" addresses");d+=TableEntry("IPv6 state",addLinkConditional(r,"showIPv6StateDlg("+c+","+v+")",xxAccountAdminName));if(1==v){if(b.CurrentAddressInfo&&0<b.CurrentAddressInfo.length){b.CurrentAddressInfo=MakeToArray(b.CurrentAddressInfo);ipv6addr="";for(p=0;p<b.CurrentAddressInfo.length;p++)0<
2018-08-27 22:24:15 +03:00
ipv6addr.length&&(ipv6addr+=", "),ipv6addr+=b.CurrentAddressInfo[p].split(",")[0];d+=TableEntry("IPv6 address",addLink(ipv6addr,"showIPv6AddrDlg("+c+',"'+b.CurrentAddressInfo+'")'))}else d+=TableEntry("IPv6 address","None");isIpAddress(b.CurrentDefaultRouter)&&(d+=TableEntry("IPv6 default router",b.CurrentDefaultRouter));isIpAddress(b.CurrentPrimaryDNS)&&(f=b.CurrentPrimaryDNS,isIpAddress(b.CurrentSecondaryDNS)&&(f+=" / "+b.CurrentSecondaryDNS),d+=TableEntry("IPv6 domain name server",f))}}d+=TableEnd()}}-1!=
amtwirelessif&&0==(amtFirstPull&2)&&PullWireless();QH(19,d);1==a&&0==(amtFirstPull&4)&&PullSystemDefense();0==(amtFirstPull&8)&&(11<amtversion||11==amtversion&&5<amtversionmin)&&PullStorage();0==currentView&&go(1,1)}}function isIpAddress(a,b){return a&&null!=a&&0<a.length&&"::"!=a&&"::0"!=a?a:b}var IntelAmtEntireState,IntelAmtEntireStateCalls;
2018-08-24 02:55:06 +03:00
function saveEntireAmtState(){if(!xxdialogMode){var a="",b=new Date;amtsysstate&&(a="-"+amtsysstate.AMT_GeneralSettings.response.HostName);a+="-"+b.getFullYear()+"-"+("0"+(b.getMonth()+1)).slice(-2)+"-"+("0"+b.getDate()).slice(-2)+"-"+("0"+b.getHours()).slice(-2)+"-"+("0"+b.getMinutes()).slice(-2);c18.value="amtstate"+a+".json";setDialogMode(19,"Save Entire Intel&reg; AMT State",3,saveEntireAmtStateOk)}}
function saveEntireAmtStateOk(){IntelAmtEntireState={webappversion:version,localtime:Date(),utctime:(new Date).toUTCString(),isotime:(new Date).toISOString()};QH(36,"Fetching entire state, please wait...");setDialogMode(1,"Save Entire Intel&reg; AMT State",0,null);IntelAmtEntireStateCalls=3;amtstack.BatchEnum(null,AllWsman,saveEntireAmtStateOk2,null,!0);amtstack.GetAuditLog(saveEntireAmtStateOk3);amtstack.GetMessageLog(saveEntireAmtStateOk4)}
function saveEntireAmtStateOk2(a,b,c,d){IntelAmtEntireState.wsmanenums=c;saveEntireAmtStateDone()}function saveEntireAmtStateOk3(a,b){IntelAmtEntireState.auditlog=b;saveEntireAmtStateDone()}function saveEntireAmtStateOk4(a,b){IntelAmtEntireState.eventlog=b;saveEntireAmtStateDone()}function saveEntireAmtStateDone(){0==--IntelAmtEntireStateCalls&&(setDialogMode(),saveAs(data2blob(JSON.stringify(IntelAmtEntireState,null," ").replace(/\n/g,"\r\n")),c18.value))}
function PullEventLog(a){1==a&&xxdialogMode||(amtFirstPull|=16,amtstack.Enum("AMT_MessageLog",processMessageLog0),amtstack.GetMessageLog(processMessageLog1))}var processMessageLog0responses=null;
function processMessageLog0(a,b,c,d){200==d&&(d&&QV("go6",!0),c&&(processMessageLog0responses=c),a="",b="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px>",null!=processMessageLog0responses&&(a=1==processMessageLog0responses[0].IsFrozen?AddButton("Un-freeze Log","FreezeLog(0)"):AddButton("Freeze Log","FreezeLog(1)")),b+=TableEnd("<div style=float:right><input id=eventFilter placeholder=Filter style=margin:4px onkeyup=eventFilter()>&nbsp;</div><div>&nbsp;"+AddRefreshButton("PullEventLog(1)")+
AddButton("Clear Log","ClearLog()")+AddButton("Save...","SaveEventLog()")+a),QH(17,b+"<br>"))}function SaveEventLog(){xxdialogMode||null==eventmessages||SaveJsonFile("IntelAmtEventlog","events","Intel AMT Event Log",eventmessages)}var eventmessages=null;
function processMessageLog1(a,b){eventmessages=b;var c,d=0,f;f="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td width=80px><p><td><td><td><tr><td class=r1 style=width:90px><b>&nbsp;&nbsp;Event</b><td class=r1 style=width:110px><b>Time</b><td class=r1 style=width:160px><b>Source</b><td class=r1><b>Description</b>";for(c in b){d++;var n=1,p=b[c];8<=p.EventSeverity&&(n=2);16<=p.EventSeverity&&(n=3);f+="<tr id=xamtevent"+c+" class=r3 onclick=showEventDetails("+
c+")><td class=r1><p><div class=icon"+n+" style=display:block;float:left;margin-left:5px;margin-right:5px></div>"+(parseInt(c)+1)+"<td class=r1 title='"+p.Time.toLocaleString()+"'>"+p.Time.toLocaleDateString("en",{year:"numeric",month:"2-digit",day:"numeric"})+"<br>"+p.Time.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",second:"2-digit"})+"<td class=r1>"+p.EntityStr.replace("(r)","&reg;")+"<td class=r1>"+p.Desc}f+=TableEnd(0==d?"&nbsp;":"");QH(18,f+"<br>");processMessageLog0()}
function FreezeLog(a){xxdialogMode||amtstack.AMT_MessageLog_FreezeLog(a,function(){amtstack.Enum("AMT_MessageLog",processMessageLog0)})}function ClearLog(a){xxdialogMode||(QH(36,"Clear event log?"),setDialogMode(1,"Event Log",3,ClearLogEx))}function ClearLogEx(){amtstack.AMT_MessageLog_ClearLog(function(a,b,c,d){200!=d?messagebox("Event Log","Unable to clear, Error: "+d):PullEventLog()})}
function showEventDetails(a){if(!xxdialogMode){var b=eventmessages[a],c;c="<div style=text-align:left>"+addHtmlValue("Time",b.Time.toLocaleString());c+=addHtmlValue("Source",b.EntityStr.replace("(r)","&reg;"));c+=addHtmlValue("Description",b.Desc);c+=MoreStart();c+=addHtmlValue("Device Address",b.DeviceAddress);c+=addHtmlValue("Entity",b.Entity);c+=addHtmlValue("Entity Instance",b.EntityInstance);var d="",f;for(f in b.EventData)0<d.length&&(d+=","),d+=b.EventData[f];c+=addHtmlValue("Data",d);c+=addHtmlValue("Offset",
b.EventOffset);c+=addHtmlValue("Sensor Type",b.EventSensorType);c+=addHtmlValue("Severity",b.EventSeverity);c+=addHtmlValue("Source Type",b.EventSourceType);c+=addHtmlValue("Type",b.EventType);c+=addHtmlValue("Sensor Number",b.SensorNumber);c+=MoreEnd();messagebox("Event #"+(a+1)+" Details",c+"</div>")}}
function eventFilter(){var a=Q("eventFilter").value.toLowerCase(),b;for(b in eventmessages)QV("xamtevent"+b,""==a||0<=eventmessages[b].Desc.toLowerCase().indexOf(a)||0<=eventmessages[b].EntityStr.toLowerCase().indexOf(a))}var subscriptionsFilters=null,subscriptionsListeners=null;
function PullEventSubscriptions(){null==subscriptionsFilters&&amtstack.Enum("CIM_FilterCollection",processEventSubscriptions0);amtstack.BatchEnum(null,["CIM_ListenerDestination","CIM_FilterCollectionSubscription"],processEventSubscriptions1)}function processEventSubscriptions0(a,b,c,d){408!=d&&400!=d&&(d&&errcheck(d,a)||(subscriptionsFilters=c))}
function processEventSubscriptions1(a,b,c,d){if(!(408==d||400==d||d&&errcheck(d,a))){d&&QV("go22",!0);c&&(subscriptionsListeners=c);b=0;a=TableStart2()+"<tr><td class=r1 style=padding-left:15px><br>Manage event subscribers.<br><br>";for(var f in subscriptionsListeners.CIM_ListenerDestination.responses)c=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[f].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","&reg;"),d=subscriptionsListeners.CIM_ListenerDestination.responses[f],
a+="<div class=itemBar onclick='showSubscriptionDetails("+f+")'><div style=float:right></div><div style=padding-top:3px;overflow-x:hidden title='"+c+" - "+d.Destination+"'><b>"+c+"</b> - "+d.Destination+"</div><div style=padding-top:3px></div></div>",b++;0==b&&(a+="<div style=padding-left:15px><br><i>No subscriptions found.</i></div><br>");f="<div>&nbsp;"+AddRefreshButton("PullEventSubscriptions()");xxAccountAdminName&&(f+=AddButton("New Subscription","newSubscriptionButton()"));a+="<br><td class=r1>"+
TableEnd(f+"</div>");QH(32,a)}}var subscriptionDeliveryModes={2:"Push",3:"Push with ACK",4:"Events",5:"Pull"};
function showSubscriptionDetails(a){if(!xxdialogMode){var b=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[a].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","&reg;"),c=subscriptionsListeners.CIM_ListenerDestination.responses[a],d;d="<div style=text-align:left>"+addHtmlValue("Destination",c.Destination);d+=addHtmlValue("Filter",b);d+=addHtmlValue("Delivery Mode",subscriptionDeliveryModes[c.DeliveryMode]);setDialogMode(11,"Subscription "+(a+1),xxAccountAdminName?
5:1,deleteSubscriptionButton,d+"</div>",a)}}
function deleteSubscriptionButton(a,b){2==a&&amtstack.UnSubscribe("CIM_FilterCollectionSubscription",PullEventSubscriptions,null,1,{Filter:'<a:EndpointReference><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_FilterCollection</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">'+subscriptionsListeners.CIM_FilterCollectionSubscription.responses[b].Filter.ReferenceParameters.SelectorSet.Selector.Value+"</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference>",
Handler:'<a:EndpointReference><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ListenerDestinationWSManagement</w:ResourceURI><w:SelectorSet><w:Selector Name="CreationClassName">CIM_ListenerDestinationWSMAN</w:Selector><w:Selector Name="Name">'+subscriptionsListeners.CIM_ListenerDestination.responses[b].Name+'</w:Selector><w:Selector Name="SystemCreationClassName">CIM_ComputerSystem</w:Selector><w:Selector Name="SystemName">Intel(r) AMT</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference>'})}
function newSubscriptionButton(){if(!xxdialogMode&&null!=subscriptionsFilters){var a;a="<div style=height:26px;margin-top:4px><select id=subtype style=float:right;width:260px><option value=Push>Push</option><option value=PushWithAck>Push with ACK</option></select><div style=padding-top:4px>Type</div></div><div style=height:26px;margin-top:4px><select id=subfilter style=float:right;width:260px>";for(var b in subscriptionsFilters)a+="<option value='"+subscriptionsFilters[b].InstanceID+"'>"+subscriptionsFilters[b].CollectionName.substring(13)+
"</option>";a+="</select><div style=padding-top:4px>Filter</div></div>";a+="<div style=height:26px;margin-top:4px><input id=suburl style=float:right;width:260px maxlength=253 onkeyup=newSubscriptionUpdate() value='http://'><div style=padding-top:4px>URL</div></div>";a+="<div style=height:26px;margin-top:4px><select id=subauth style=float:right;width:260px onchange=newSubscriptionUpdate()><option value=0>None</option><option value=1>Digest</option></select><div style=padding-top:4px>Authentication</div></div>";
a+="<div style=height:26px;margin-top:4px id=subxuser><input id=subuser style=float:right;width:260px maxlength=32 onkeyup=newSubscriptionUpdate()><div style=padding-top:4px>Username</div></div>";a+="<div style=height:26px;margin-top:4px id=subxpass><input id=subpass style=float:right;width:260px maxlength=32 onkeyup=newSubscriptionUpdate()><div style=padding-top:4px>Password</div></div>";a+="<div style=height:26px;margin-top:4px><input id=subargs style=float:right;width:260px maxlength=128><div style=padding-top:4px>Arguments</div></div>";
setDialogMode(11,"Add Event Subscription",3,newSubscriptionButtonOk,a);newSubscriptionUpdate()}}function newSubscriptionUpdate(){QE("c37",0<Q("suburl").value.length&&Q("suburl").value.startsWith("http://")&&(0==Q("subauth").value||0<Q("subuser").value.length&&0<Q("subpass").value.length));QV("subxuser",1==Q("subauth").value);QV("subxpass",1==Q("subauth").value)}
function newSubscriptionButtonOk(){var a=0==Q("subuser").value.length?void 0:Q("subuser").value,b=0==Q("subpass").value.length?void 0:Q("subpass").value;amtstack.Subscribe("CIM_FilterCollection",Q("subtype").value,Q("suburl").value,newSubscriptionButtonOk2,null,1,{InstanceID:Q("subfilter").value},0<Q("subargs").value.length?Q("subargs").value:null,a,b)}function newSubscriptionButtonOk2(a,b,c,d){200==d&&PullEventSubscriptions()}
function PullAuditLog(a){1==a&&xxdialogMode||(amtFirstPull|=32,amtstack.Enum("AMT_AuditLog",processAuditLog0))}var auditLog=null,auditLogEnabledStates="Unknown;Other;Enabled;Disabled;Shutting Down;Not Applicable;Enabled but Offline;In Test;Deferred;Quiesce;Starting".split(";");
function processAuditLog0(a,b,c,d){200==d&&(QV("go15",!0),b=c[0].AuditState,a=b&1?"Disabled":"Enabled",b&2&&(a+=", Locked"),b&4&&(a+=", Almost Full"),b&8&&(a+=", Full"),b&16&&(a+=", NoKey"),b="<h1>Audit Log Settings</h1>"+TableStart(),b+=TableEntry("State",a),b+=TableEntry("Storage",c[0].CurrentNumberOfRecords+" record(s), "+c[0].PercentageFree+"% free"),b+=TableEntry("Overwrite policy",2==c[0].OverwritePolicy?"Wraps when full":"Never overwrites"),b+=TableEnd(),QH(25,b),amtstack.GetAuditLog(processAuditLog1))}
function processAuditLog1(a,b){auditLog=b;var c,d;d="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px>"+(TableEnd("<div style=float:right><input id=auditFilter placeholder=Filter style=margin:4px onkeyup=auditFilter()>&nbsp;</div><div> "+AddRefreshButton("PullAuditLog(1)")+AddButton("Save...","SaveAuditLog()")+AddButton("Clear Log","ClearAuditLog()"))+"<br>");if(0==b.length)d="No audit log events found.";else{var f=0;d+="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td width=80px><p><td><td><td><tr><td class=r1 style=width:110px>&nbsp;&nbsp;<b>Time</b><td class=r1 style=width:260px><b>Initiator</b><td class=r1><b>Action</b>";
for(c in b){var n=b[c],p=n.AuditApp,r=n.Initiator;f++;var l="";0<n.NetAddress.length&&(l=n.NetAddress.replace("0000:0000:0000:0000:0000:0000:0000:0001","::1"));n.Event&&(p+=", "+n.Event);null!=n.ExStr&&(p+=", "+n.ExStr);""!=r&&""!=l&&(r+=", ");d+="<tr id=xamtaudit"+c+" class=r3 onclick=showAuditDetails("+c+")><td class=r1 title='"+n.Time.toLocaleString()+"'>&nbsp;&nbsp;"+n.Time.toLocaleDateString("en",{year:"numeric",month:"2-digit",day:"numeric"})+"<br>&nbsp;&nbsp;"+n.Time.toLocaleTimeString("en",
{hour:"2-digit",minute:"2-digit",second:"2-digit"})+"<td class=r1>"+r+l+"<td class=r1>"+p}d+=TableEnd(0==f?"&nbsp;":"")+"<br>"}QH(26,d)}function auditFilter(){var a=Q("auditFilter").value.toLowerCase(),b;for(b in auditLog)QV("xamtaudit"+b,""==a||0<=JSON.stringify(auditLog[b]).toLowerCase().indexOf(a))}function SaveAuditLog(){xxdialogMode||null==auditLog||SaveJsonFile("IntelAmtAuditlog","auditevents","Intel AMT Audit Log",auditLog)}
function ClearAuditLog(a){QH(36,"Clear audit log?");setDialogMode(1,"Audit Log",3,ClearAuditLogEx)}function ClearAuditLogEx(){var a=amtstack.AMT_AuditLog_SetAuditLock(1,0,a,function(){amtstack.AMT_AuditLog_ClearLog(function(){amtstack.AMT_AuditLog_SetAuditLock(0,2,a,function(){setTimeout(PullAuditLog,1E3)})})})}function ShowAuditLogSettings(){xxdialogMode||amtstack.AMT_AuditLog_RequestStateChange(2,0,AuditLogSettingsCompleted)}
function AuditLogSettingsCompleted(a,b,c,d){200==d?PullAuditLog():messagebox("Audit Log","Error: "+d)}
function showAuditDetails(a){if(!xxdialogMode){var b,c=auditLog[a],d;d="<div style=text-align:left>"+addHtmlValue("Time",c.Time.toLocaleString());""!=c.Initiator&&(d+=addHtmlValue("Initiator",c.Initiator));""!=c.NetAddress&&(d+=addHtmlValue("Address",c.NetAddress));d+=addHtmlValue("Application",c.AuditApp);d+=addHtmlValue("Event",c.Event);if(null!=c.ExStr)d+=addHtmlValue("Extended Data",c.ExStr);else if(0<c.Ex.length){var f="";for(b in c.Ex)0<f.length&&(f+=","),f+=c.Ex.charCodeAt(b);""!=f&&(d+=addHtmlValue("Data Values",
f));2<c.Ex.length&&ReadShort(c.Ex,0)==c.Ex.length-2&&(d+=addHtmlValue("Data String",c.Ex.substring(2)))}messagebox("Audit Event #"+(a+1)+" Details",d+"</div>")}}var xxCertificates=null,xxCertPrivateKeys=null,xxTlsSettings=null,xxTlsCurrentCert=null,xxTLSCredentialContext=null,xxCaPrivateKey=null,xxCaSubjectAttributes=null;function PullCertificates(){amtstack.BatchEnum(null,["AMT_PublicKeyCertificate","AMT_PublicPrivateKeyPair","AMT_TLSSettingData","AMT_TLSCredentialContext"],processCerts1)}
function processCerts1(a,b,c,d){if(400!=d&&!errcheck(d,a)){QV("go16",!0);xxCertificates=c.AMT_PublicKeyCertificate.responses;xxCertPrivateKeys=c.AMT_PublicPrivateKeyPair.responses;xxTlsSettings=c.AMT_TLSSettingData.responses;xxTLSCredentialContext=c.AMT_TLSCredentialContext.responses;xxTlsCurrentCert=null;if(0<xxTLSCredentialContext.length){a=xxTLSCredentialContext[0].ElementInContext.ReferenceParameters.SelectorSet.Selector.Value;for(var f in xxCertificates)xxCertificates[f].InstanceID==a&&(xxTlsCurrentCert=
f)}for(f in xxCertificates)xxCertificates[f].TrustedRootCertficate=1==xxCertificates[f].TrustedRootCertficate,xxCertificates[f].X509Certificate=window.atob(xxCertificates[f].X509Certificate),xxCertificates[f].XIssuer=parseCertName(xxCertificates[f].Issuer),xxCertificates[f].XSubject=parseCertName(xxCertificates[f].Subject);amtcert_linkCertPrivateKey(xxCertificates,xxCertPrivateKeys);updateCertificates()}}
function parseCertName(a){var b={},c=a.split(","),d;for(d in c)a=c[d].indexOf("="),b[c[d].substring(0,a)]=c[d].substring(a+1);return b}
function getTlsSecurityState(a){if(0==xxTlsSettings[a].Enabled)return"Disabled";var b=(1==xxTlsSettings[a].MutualAuthentication?"Mutual-auth TLS":"Server-auth TLS")+(1==xxTlsSettings[a].AcceptNonSecureConnections?" and non-TLS":"");1==xxTlsSettings[a].MutualAuthentication&&xxTlsSettings[a].TrustedCN&&(a=MakeToArray(xxTlsSettings[a].TrustedCN),0<a.length&&(b+=", Trusted name"+(1<a.length?"s":"")+": "+a.join(", ")+"."));return b}
function updateCertificates(){if(null!=xxCertificates){var a="Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1,b=1-a,c=TableStart(),c=c+TableEntry("Remote TLS security",addLinkConditional(getTlsSecurityState(b),"showSetTlsSecurityDlg()",xxAccountAdminName)),c=c+TableEntry("Local TLS security",addLinkConditional(getTlsSecurityState(a),"showSetTlsSecurityDlg()",xxAccountAdminName)),c=c+TableEnd(),c=c+("<br>"+TableStart2()+"<tr><td class=r1 style=padding-left:15px><br>Manage Intel&reg; AMT certificates for this computer.<br><br>");
if(0==xxCertificates.length&&0==xxCertPrivateKeys.length)c+="<div style=padding-left:15px><br><i>No certificates found.</i></div><br>";else{for(var d in xxCertificates)a="",xxCertificates[d].TrustedRootCertficate&&(a=", Trusted Root"),xxCertificates[d].XPrivateKey&&(a=", Private Key"),d==xxTlsCurrentCert&&(a+=", TLS cert"),c+="<div class=itemBar onclick=showCertDetails("+d+")><div style=padding-top:3px><b>"+EscapeHtml(xxCertificates[d].XSubject.CN)+"</b><i>"+a+"</i></div></div>";for(d in xxCertPrivateKeys)xxCertPrivateKeys[d].XCert||
(c+="<div class=itemBar onclick=showKeyPairDetails("+d+")><div style=padding-top:3px><i>Unassigned Private Key Pair #"+d+"</i></div></div>")}d=AddRefreshButton("PullCertificates()");xxAccountAdminName&&(d+=AddButton("Add Certificate...","addCertButton()")+AddButton("Issue Certificate...","issueCertButton()"));c+="<br><td class=r1>"+TableEnd(d);QH(27,c)}}
function showKeyPairDetails(a){setDialogMode(11,"Key Pair #"+a,5,function(b){2==b&&amtstack.Delete("AMT_PublicPrivateKeyPair",{InstanceID:xxCertPrivateKeys[a].InstanceID},PullCertificates,0,1)},"This is a public/private certificate key pair that does not belong to any certificates. This entry should be temporary.")}var xxCertSubjectNames={CN:"Common Name",O:"Organization",OU:"Org Unit",S:"State/Province",ST:"State/Province",L:"Locality",C:"Country",SN:"Surname",GN:"Given name"};
function showCertDetails(a){if(!xxdialogMode){var b=xxCertificates[a],c;c="<br>"+addHtmlValue("Certificate",b.X509Certificate.length+" bytes, <a style=cursor:pointer;color:blue onclick=downloadCert("+a+")>Download</a>");c+=addHtmlValue("Trusted root",b.TrustedRootCertficate?"Yes":"No");0==b.TrustedRootCertficate&&b.XPrivateKey&&(c+=addHtmlValue("Private key","Present"));c+='<br><div style="border-bottom:1px solid gray"><i>Certificate Subject</i></div><br>';for(var d in b.XSubject)b.XSubject[d]&&(c+=
addHtmlValue(xxCertSubjectNames[d]?xxCertSubjectNames[d]:d,EscapeHtml(b.XSubject[d])));c+='<br><div style="border-bottom:1px solid gray"><i>Issuer Certificate</i></div><br>';for(d in b.XIssuer)b.XIssuer[d]&&(c+=addHtmlValue(xxCertSubjectNames[d]?xxCertSubjectNames[d]:d,EscapeHtml(b.XIssuer[d])));setDialogMode(11,"Certificate - "+EscapeHtml(b.XSubject.CN),5,function(b){2==b&&(xxCertificates[a].XPrivateKey&&amtstack.Delete("AMT_PublicPrivateKeyPair",{InstanceID:xxCertificates[a].XPrivateKey.InstanceID},
function(){},0,1),amtstack.Delete("AMT_PublicKeyCertificate",xxCertificates[a],certificateRemoved,0,1))},c)}}function downloadCert(a){saveAs(data2blob(xxCertificates[a].X509Certificate),xxCertificates[a].XSubject.CN+".cer")}function cert_FileSelectHandler(a){haltEvent(a);1==a.dataTransfer.files.length&&(a.dataTransfer.files[0].name.toLowerCase().endsWith(".p12")?issueCertButton(a.dataTransfer.files):addCertButton(a.dataTransfer.files))}var xxDragDropCertFiles=null;
function addCertButton(a){!xxdialogMode&&xxAccountAdminName&&(xxDragDropCertFiles=a,a="<input id=certopen onchange=addCertButtonUpdate() type=file style=float:right;width:260px accept='.cer,.pem'>",xxDragDropCertFiles&&(a='<input style=float:right;width:260px readonly disabled value="'+xxDragDropCertFiles[0].name+'">'),a="<div style=height:10px></div>"+("<div style=height:26px;margin-top:4px>"+a+"<div style=padding-top:4px>Certificate file</div></div>")+"<div style=height:26px;margin-top:4px><select id=certtype style=float:right;width:260px><option value=0>Chain Certificate</option><option value=1>Trusted Root Certificate</option></select><div style=padding-top:4px>Certificate type</div></div>",
setDialogMode(11,"Add Certificate",3,addCertButtonOk,a),addCertButtonUpdate())}function addCertButtonUpdate(){var a=getInputElement("certopen");QE("c37",!a||1==a.files.length)}function addCertButtonOk(){var a=getInputElement("certopen"),b=xxDragDropCertFiles;a&&(b=a.files);b&&1==b.length&&(a=new FileReader,a.onload=addCertButtonOk2,a.readAsBinaryString(b[0]))}
function addCertButtonOk2(a){a=a.target.result;var b=a.indexOf("-----BEGIN CERTIFICATE-----");0<b?(a=a.substring(b+27),b=a.indexOf("-----END CERTIFICATE-----"),0<b&&(a=a.substring(0,b)),a=a.replace(/\r\n/g,"")):a=btoa(a);1==getSelectElement("certtype").value?amtstack.AMT_PublicKeyManagementService_AddTrustedRootCertificate(a,certificateAdded):amtstack.AMT_PublicKeyManagementService_AddCertificate(a,certificateAdded)}
function issueCertButton(a){!xxdialogMode&&xxAccountAdminName&&(xxDragDropCertFiles=a,a="<input id=certopen type=file style=float:right;width:230px onchange=issueCertButtonUpdate() accept='.p12'>",xxDragDropCertFiles&&(a='<input style=float:right;width:230px readonly disabled value="'+xxDragDropCertFiles[0].name+'">'),a=""+("<div styleheight:26px;margin-top:14px>"+a+"<div style=padding-top:4px>Certificate file</div></div>")+"<div style=height:26px;margin-top:4px><input onkeyup=issueCertButtonUpdate() id=certopenpass type=password autocomplete=off style=float:right;width:230px><div style=padding-top:4px>Certificate password</div></div>",
a+='<br><div style="border-bottom:1px solid gray"><i>Intel&reg; AMT Certificate</i></div>',a+="<div style=height:26px;margin-top:4px><input onkeyup=issueCertButtonUpdate() id=certcn style=float:right;width:230px><div style=padding-top:4px>Common Name</div></div>",a+="<div style=height:26px;margin-top:4px><input onkeyup=issueCertButtonUpdate() id=certo style=float:right;width:230px><div style=padding-top:4px>Organization</div></div>",a+="<div style=height:26px;margin-top:4px><input onkeyup=issueCertButtonUpdate() id=certst style=float:right;width:230px><div style=padding-top:4px>State/Province</div></div>",
a+="<div style=height:26px;margin-top:4px><input onkeyup=issueCertButtonUpdate() id=certc style=float:right;width:230px><div style=padding-top:4px>Country</div></div>",a+='<div>Certificate Usages</div><ul style="list-style-type:none;height:100px;overflow:auto;width:100%;border: 1px solid #000;background-color:white;overflow-x:hidden;margin:0;padding:0">',a+="<li><label><input type=checkbox id=d11_cu4 checked>TLS Server (HTTPS)</label></li>",a+="<li><label><input type=checkbox id=d11_cu5>TLS Client (HTTPS)</label></li>",
a+="<li><label><input type=checkbox id=d11_cu6>Email Protection</label></li>",a+="<li><label><input type=checkbox id=d11_cu7>Code Signing</label></li>",a+="<li><label><input type=checkbox id=d11_cu8>Time Stamp</label></li>",a+="</ul>",setDialogMode(11,"Issue Certificate",3,issueCertButtonOk,a),issueCertButtonUpdate())}
function issueCertButtonUpdate(){var a=getInputElement("certopen");QE("certopenpass",!a||a&&1==a.files.length);var b=!a||2>a.files.length;1==(!a||a&&a.files.length)&&""==Q("certopenpass").value&&(b=!1);if(""==getInputElement("certcn").value||""==getInputElement("certo").value||""==getInputElement("certst").value||""==getInputElement("certc").value)b=!1;QE("c37",b)}
function issueCertButtonOk(){var a=getInputElement("certopen"),b=xxDragDropCertFiles;a&&(b=a.files);b&&1==b.length?(a=new FileReader,a.onload=issueCertButtonOk2,a.readAsBinaryString(b[0])):issueCertButtonOk3(null)}function issueCertButtonOk2(a){0==amtcert_loadP12File(a.target.result,Q("certopenpass").value,issueCertButtonOk3)&&messagebox("Issue Certificate","Unable to decrypt/decode certificate.")}
function issueCertButtonOk3(a,b,c){xxCaPrivateKey=a;xxCaSubjectAttributes=b;amtstack.AMT_PublicKeyManagementService_GenerateKeyPair(0,2048,GenerateKeyPairResponse)}
function GenerateKeyPairResponse(a,b,c,d){200!=d?messagebox("Issue Certificate","Failed to generate key pair. Status: "+d):0!=c.Body.ReturnValue?messagebox("Issue Certificate","Failed to generate key pair, "+c.Body.ReturnValueStr):amtstack.Enum("AMT_PublicPrivateKeyPair",GenerateKeyPairResponse2,c.Body.KeyPair.ReferenceParameters.SelectorSet.Selector.Value)}
function GenerateKeyPairResponse2(a,b,c,d,f){if(200!=d)messagebox("Issue Certificate","Failed to generate key pair. Status: "+d);else{a=null;for(var n in c)c[n].InstanceID==f&&(a=c[n].DERKey);c={CN:getInputElement("certcn").value,O:getInputElement("certo").value,ST:getInputElement("certst").value,C:getInputElement("certc").value};f={CN:"Untrusted Root Certificate"};if(null!=xxCaPrivateKey&&xxCaSubjectAttributes)for(n in f={},xxCaSubjectAttributes)f[xxCaSubjectAttributes[n].shortName]=xxCaSubjectAttributes[n].value;
n={name:"extKeyUsage"};Q("d11_cu4").checked&&(n.serverAuth=!0);Q("d11_cu5").checked&&(n.clientAuth=!0);Q("d11_cu6").checked&&(n.emailProtection=!0);Q("d11_cu7").checked&&(n.codeSigning=!0);Q("d11_cu8").checked&&(n.timeStamping=!0);n=amtcert_signWithCaKey(a,xxCaPrivateKey,c,f,n);null==n?messagebox("Issue Certificate","Unable to sign certificate."):(n=forge.pki.certificateToPem(n).replace(/(\r\n|\n|\r)/gm,""),amtstack.AMT_PublicKeyManagementService_AddCertificate(n.substring(27,n.length-25),GenerateKeyPairResponse4))}}
function GenerateKeyPairResponse4(a,b,c,d){200!=d?messagebox("Issue Certificate","Failed to generate key pair. Status: "+d):PullCertificates()}function certificateAdded(a,b,c,d){200!=d||0!=c.Body.ReturnValue?messagebox("Add Certificate","Unable to add certificate, error "+(200!=d?d:c.Body.ReturnValueStr)):PullCertificates()}function certificateRemoved(a,b,c,d){200!=d?messagebox("Remove Certificate","Unable to remove certificate, error "+d):PullCertificates()}
function getInputElement(a){var b=document.getElementsByTagName("input");for(t=0;t<b.length;t++)if(b[t].id==a)return b[t]}function getSelectElement(a){var b=document.getElementsByTagName("select");for(t=0;t<b.length;t++)if(b[t].id==a)return b[t]}
function showSetTlsSecurityDlg(a){if(!xxdialogMode){a="<div style=height:26px;margin-top:4px><select onchange=showSetTlsSecurityDlgUpdate() id=tlscert style=float:right;width:260px><option value=-1>No Certificate, TLS Disabled</option>";for(var b in xxCertificates)0!=xxCertificates[b].TrustedRootCertficate||!xxCertificates[b].XPrivateKey||null!=xxTlsCurrentCert&&xxTlsCurrentCert!=b||(a+="<option value="+b+">"+xxCertificates[b].XSubject.CN+"</option>");a+="</select><div style=padding-top:4px>Certificate</div></div><div style=height:26px;margin-top:4px><select id=tlsremote style=float:right;width:260px onchange=showSetTlsSecurityDlgUpdate()><option value=0>Server-auth TLS only</option><option value=1>Server-auth, non-TLS allowed</option>";
8>amtversion&&(a+="<option value=2>Mutual-auth TLS only</option><option value=3>Mutual-auth, non-TLS allowed</option>");a+="</select><div style=padding-top:4px>Security</div></div><div style=height:26px id=d11rcn title='Comma seperated list of certificate common names that will be allowed to connect remotely.'><input id=d11_rcn style=float:right;width:260px onkeyup=showSetTlsSecurityDlgUpdate() placeholder='name1, name2'><div style=padding-top:4px>Remote CN's</div></div>";setDialogMode(11,"TLS Settings",
3,showSetTlsSecurityDlgOk,a);if(0==xxTLSCredentialContext.length||0==xxTlsSettings[0].Enabled||0==xxTlsSettings[1].Enabled)getSelectElement("tlscert").value=-1;else for(b in a=xxTLSCredentialContext[0].ElementInContext.ReferenceParameters.SelectorSet.Selector.Value,xxCertificates)xxCertificates[b].InstanceID==a&&(getSelectElement("tlscert").value=b);b=1-("Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1);getSelectElement("tlsremote").value=(1==xxTlsSettings[b].MutualAuthentication?
2:0)+(1==xxTlsSettings[b].AcceptNonSecureConnections?1:0);xxTlsSettings[b].TrustedCN&&(Q("d11_rcn").value=MakeToArray(xxTlsSettings[b].TrustedCN).join(", "));showSetTlsSecurityDlgUpdate()}}function showSetTlsSecurityDlgUpdate(){var a=getSelectElement("tlscert").value;QE("tlsremote",-1!=a);QV("d11rcn",-1!=a&&1<getSelectElement("tlsremote").value);a=!0;1<getSelectElement("tlsremote").value&&!splitDomains(Q("d11_rcn").value)&&(a=!1);QE("c37",a)}var setTlsSecurityPendingCalls,setTlsSecurityDeleteCredentialContext;
function showSetTlsSecurityDlgOk(){var a=getSelectElement("tlscert").value,b=getSelectElement("tlsremote").value,c=Clone(xxTlsSettings);setTlsSecurityPendingCalls=0;setTlsSecurityDeleteCredentialContext=null;if(-1!=a){if(0<xxTLSCredentialContext.length){var d=Clone(xxTLSCredentialContext[0]);d.ElementInContext.ReferenceParameters.SelectorSet.Selector.Value=xxCertificates[a].InstanceID;amtstack.Put("AMT_TLSCredentialContext",d,setTlsSecurityResponse,0,1)}else amtstack.Create("AMT_TLSCredentialContext",
{ElementInContext:"<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+amtstack.CompleteName("AMT_PublicKeyCertificate")+'</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">'+xxCertificates[a].InstanceID+"</w:Selector></w:SelectorSet></a:ReferenceParameters>",ElementProvidingContext:"<a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+amtstack.CompleteName("AMT_TLSProtocolEndpointCollection")+'</w:ResourceURI><w:SelectorSet><w:Selector Name="ElementName">TLSProtocolEndpointInstances Collection</w:Selector></w:SelectorSet></a:ReferenceParameters>'},
setTlsSecurityResponse);setTlsSecurityPendingCalls++}else 0<xxTLSCredentialContext.length&&(setTlsSecurityDeleteCredentialContext=Clone(xxTLSCredentialContext[0]));var d="Intel(r) AMT LMS TLS Settings"==xxTlsSettings[0].InstanceID?0:1,f=1-d;c[f].Enabled=-1!=a;c[f].MutualAuthentication=2<=b;c[f].AcceptNonSecureConnections=1==b%2;c[f].TrustedCN=splitDomains(Q("d11_rcn").value);c[d].Enabled=-1!=a;amtstack.Put("AMT_TLSSettingData",c[0],setTlsSecurityResponse,0,1,c[0]);amtstack.Put("AMT_TLSSettingData",
c[1],setTlsSecurityResponse,0,1,c[1]);setTlsSecurityPendingCalls+=2;statusbox("TLS Settings","Applying new security settings...")}function splitDomains(a){a=a.split(",");if(0!=a.length){for(var b in a)if(a[b]=a[b].trim(),0<=a[b].indexOf(" ")||0==a[b].length)return;if(!(4<a.length))return a}}
function setTlsSecurityResponse(a,b,c,d,f){200!=d?messagebox("","Failed to set TLS security, status = "+d):c.Body.ReturnValueStr&&!methodcheck(c)||0!=--setTlsSecurityPendingCalls||amtstack.AMT_SetupAndConfigurationService_CommitChanges(null,setTlsSecurityResponse2)}function setTlsSecurityResponse2(a,b,c,d){200!=d?messagebox("","Failed to set TLS security, status = "+d):setTimeout(setTlsSecurityResponse3,2E3)}
function setTlsSecurityResponse3(){null!=setTlsSecurityDeleteCredentialContext&&amtstack.Delete("AMT_TLSCredentialContext",setTlsSecurityDeleteCredentialContext,function(){});PullCertificates();setDialogMode()}var xxWatchdog=null;function PullWatchdog(){amtstack.BatchEnum(null,["*AMT_AgentPresenceCapabilities","AMT_AgentPresenceWatchdog","AMT_AgentPresenceWatchdogAction","AMT_StateTransitionCondition","CIM_ConcreteDependency"],PullWatchdogResponse)}
function PullWatchdogResponse(a,b,c,d){if(200==d&&200==c.AMT_AgentPresenceCapabilities.status){xxWatchdog=c;for(var f in xxWatchdog.CIM_ConcreteDependency.responses)a=xxWatchdog.CIM_ConcreteDependency.responses[f],(b=getItem(a.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","CreationClassName"))&&"AMT_AgentPresenceWatchdog"==b.Value&&(d=getItem(a.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","DeviceID").Value,c=getItem(a.Dependent.ReferenceParameters.SelectorSet.Selector,
"@Name","PolicyConditionName").Value,d=getItem(xxWatchdog.AMT_AgentPresenceWatchdog.responses,"DeviceID",d),c=getItem(xxWatchdog.AMT_StateTransitionCondition.responses,"PolicyConditionName",c),d.transitions||(d.transitions=[]),d.transitions.push(c)),b&&"AMT_StateTransitionCondition"==b.Value&&(c=getItem(a.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","PolicyConditionName").Value,a=getItem(a.Dependent.ReferenceParameters.SelectorSet.Selector,"@Name","PolicyActionName").Value,c=getItem(xxWatchdog.AMT_StateTransitionCondition.responses,
"PolicyConditionName",c),a=getItem(xxWatchdog.AMT_AgentPresenceWatchdogAction.responses,"PolicyActionName",a),c.actions||(c.actions=[]),c.actions.push(a));updateWatchdog();QV("go19",!0)}}var watchdogEnabledStates="Unknown;Other;Enabled;Disabled;Shutting Down;Not Applicable;Enabled but Offline;In Test;Deferred;Quiesce;Starting".split(";"),watchdogMonitoredEntity="Unknown;Other;Operating System;Operating System Boot Process;Operating System Shutdown Process;Firmware Boot Process;BIOS Boot Process;Application;Service Processor".split(";");
function updateWatchdog(){if(null!=xxWatchdog){var a;a=""+TableStart();a+=TableEntry("Maximum Watchdogs",xxWatchdog.AMT_AgentPresenceCapabilities.response.MaxTotalAgents+" watchdogs");a+=TableEntry("Maximum Total Actions",xxWatchdog.AMT_AgentPresenceCapabilities.response.MaxTotalActions+" actions");a+=TableEnd()+"<br>";a+=TableStart2();a+="<tr><td class=r1 style=padding-left:15px><br>Manage Intel&reg; AMT agent presence watchdogs.<br><br>";if(null==xxWatchdog.AMT_AgentPresenceWatchdog.responses||
0==xxWatchdog.AMT_AgentPresenceWatchdog.responses.length)a+="<div style=padding-left:15px><i>No agent presence watchdog found.</i></div><br>";else for(var b in xxWatchdog.AMT_AgentPresenceWatchdog.responses){var c=xxWatchdog.AMT_AgentPresenceWatchdog.responses[b],d=guidToStr(rstr2hex(atob(c.DeviceID)));c.MonitoredEntityDescription&&""!=c.MonitoredEntityDescription&&(d=EscapeHtml(c.MonitoredEntityDescription));a+="<div class=itemBar onclick=showWatchdogDetails("+b+")><input type=button style=float:right value='Add Action...' onclick=addWatchdogAction(event,"+
b+")>";c.transitions&&(a+="<input type=button style=float:right value='Delete Actions...' onclick=deleteWatchdogActions(event,"+b+")>");a+="<div style=padding-top:3px><b>"+d+"</b>, "+amtstack.WatchdogCurrentStates[c.CurrentState]+"</div>";var d="",f;for(f in c.transitions){var n=c.transitions[f];""!=d&&(d+="<br>");d+=getWatchdogTransitionStr(n.OldState)+" &rarr; "+getWatchdogTransitionStr(n.NewState);n.actions&&1==n.actions[0].EventOnTransition&&(d+=" : Event to log")}""!=d&&(a+="<div style=padding:12px>"+
d+"</div>");a+="</div>"}a=a+"<br>"+TableEnd(AddRefreshButton("PullWatchdog()")+AddButton("Add Watchdog...","AddWatchdog()"));a+="<br>";QH(30,a)}}function getWatchdogTransitionStr(a){if(31==a)return"Any State";var b="",c;for(c in amtstack.WatchdogCurrentStates)0!=(a&c)&&(b+=", "+amtstack.WatchdogCurrentStates[c]);return b.substring(2)}
function showWatchdogDetails(a){a=xxWatchdog.AMT_AgentPresenceWatchdog.responses[a];var b="";a.MonitoredEntityDescription&&""!=a.MonitoredEntityDescription&&(b+=addHtmlValue("Description",EscapeHtml(a.MonitoredEntityDescription)));b+=addHtmlValue("Monitored Entity",watchdogMonitoredEntity[a.MonitoredEntity]);b+=addHtmlValue("Current State",amtstack.WatchdogCurrentStates[a.CurrentState]);b+=addHtmlValue("Enabled State",watchdogEnabledStates[a.EnabledState]);b+=addHtmlValue("Startup Interval",a.StartupInterval+
" second(s)");b+=addHtmlValue("Timeout Interval",a.TimeoutInterval+" second(s)");setDialogMode(11,"Watchdog "+guidToStr(rstr2hex(atob(a.DeviceID))),5,showWatchdogDetailsOk,b,a)}function showWatchdogDetailsOk(a,b){2==a&&amtstack.Delete("AMT_AgentPresenceWatchdog",{DeviceID:b.DeviceID},PullWatchdog)}
function AddWatchdog(){var a;a="<div style=height:26px;margin-top:4px><input id=wgname style=float:right;width:240px maxlength=16 onkeyup=AddWatchdogUpdate()><div style=padding-top:4px>Name</div></div>"+("<div style=height:26px;margin-top:4px><input id=wgguid style=float:right;width:240px maxlength=36 onkeyup=AddWatchdogUpdate()><div style=padding-top:4px title='Generate random DeviceID'>"+addLink("DeviceID","GenerateWatchdogGuid()")+"</div></div>");a+="<div style=height:26px;margin-top:4px><input id=wgstart style=float:right;width:240px maxlength=8 placeholder=3600 onkeyup=AddWatchdogUpdate()><div style=padding-top:4px>Startup (seconds)</div></div>";
a+="<div style=height:26px;margin-top:4px><input id=wgtimeout style=float:right;width:240px maxlength=8 placeholder=60 onkeyup=AddWatchdogUpdate()><div style=padding-top:4px>Timeout (seconds)</div></div>";setDialogMode(11,"Add Watchdog",3,AddWatchdogOk,a);AddWatchdogUpdate()}function GenerateWatchdogGuid(){var a,b="";for(a=0;16>a;a++)b+=String.fromCharCode(random(255));Q("wgguid").value=guidToStr(rstr2hex(b));AddWatchdogUpdate()}
function AddWatchdogUpdate(){for(var a=(""==Q("wgstart").value||0<parseInt(Q("wgstart").value))&&(""==Q("wgtimeout").value||0<parseInt(Q("wgtimeout").value)),b=0,c=Q("wgguid").value.toLowerCase(),d=0;d<c.length;d++){var f=c.charCodeAt(d);45!=f&&(48<=f&&57>=f||97<=f&&102>=f?b++:a=!1)}32!=b&&(a=!1);QE("dlgOkButton",a)}
function AddWatchdogOk(){var a=Q("wgtimeout").value,b=Q("wgstart").value;""==a&&(a=60);""==b&&(b=3600);a={CreationClassName:0,DeviceID:btoa(hex2rstr(guidToStr(Q("wgguid").value.replace(/-/g,"")).replace(/-/g,""))),StartupInterval:b,SystemCreationClassName:0,SystemName:0,TimeoutInterval:a,MonitoredEntityDescription:Q("wgname").value};amtstack.Create("AMT_AgentPresenceWatchdog",a,AddWatchdogOk2)}
function AddWatchdogOk2(a,b,c,d){200!=d?messagebox("Watchdog","Unable to add watchdog, error #"+d):PullWatchdog()}
function addWatchdogAction(a,b){var c=xxWatchdog.AMT_AgentPresenceWatchdog.responses[b],d;d="<table><td style=width:180px>From<br>";for(b in amtstack.WatchdogCurrentStates)d+="<input id=wgsa"+b+" type=checkbox onclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br />";d+="<td>To<br>";for(b in amtstack.WatchdogCurrentStates)d+="<input id=wgsb"+b+" type=checkbox onclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br />";setDialogMode(11,"Add Watchdog Action",
3,addWatchdogActionOk,d+"</table><br>Perform Action<br><input id=wgsevent type=checkbox checked onclick=addWatchdogActionUpdate()>Write to event log<br />",c);addWatchdogActionUpdate();haltEvent(a)}function addWatchdogActionUpdate(){var a=0,b=0,c;for(c in amtstack.WatchdogCurrentStates)1==Q("wgsa"+c).checked&&(a+=parseInt(c)),1==Q("wgsb"+c).checked&&(b+=parseInt(c));QE("dlgOkButton",0<a&&0<b&&1==Q("wgsevent").checked)}
function addWatchdogActionOk(a,b){var c=0,d=0,f;for(f in amtstack.WatchdogCurrentStates)1==Q("wgsa"+f).checked&&(c+=parseInt(f)),1==Q("wgsb"+f).checked&&(d+=parseInt(f));amtstack.AMT_AgentPresenceWatchdog_AddAction(c,d,Q("wgsevent").checked,null,null,AddWatchdogActionResponse,null,0,{DeviceID:b.DeviceID})}function AddWatchdogActionResponse(a,b,c,d){200!=d?messagebox("Watchdog Action","Unable to add watchdog action, error #"+d):PullWatchdog()}
function deleteWatchdogActions(a,b){setDialogMode(11,"Delete Watchdog Actions",3,deleteWatchdogActionsOk,"Delete all actions for this watchdog?",xxWatchdog.AMT_AgentPresenceWatchdog.responses[b]);haltEvent(a)}function deleteWatchdogActionsOk(a,b){amtstack.AMT_AgentPresenceWatchdog_DeleteAllActions(deleteWatchdogActionResponse,null,0,{DeviceID:b.DeviceID})}
function deleteWatchdogActionResponse(a,b,c,d){200!=d?messagebox("Watchdog Action","Unable to remove watchdog actions, error #"+d):PullWatchdog()}
var xxSystemDefense=null,xxSystemDefenceLinkedPolicy={},xxUpdatingDefenseStats=!1,xxFilterStatistics=[{},{}],xxFilterStatisticsTimer=null,xxFilterStatisticsTimerActive=!1,xxSystemDefenceFilterEthernetTypes={2048:"All IP Packets",2054:"All ARP Packets"},xxSystemDefenceFilterIPTypes={4:"IPv4",6:"IPv6"},xxSystemDefenceFilterDesc={0:"Allow, Count",1:"Drop, Count",2:"Rate limit",3:"Allow",4:"Drop"},xxSystemDefenceFilters={HdrProtocolID:1,HdrDestAddress:2,HdrDestMask:2,HdrSrcAddress:2,HdrSrcMask:2,HdrSrcPortStart:1,
HdrSrcPortEnd:1,HdrDestPortStart:1,HdrDestPortEnd:1,HdrSrcAddressEndOfRange:2,"HdrDestAddressEndOfRange ":2,TCPFlagsOn:3,TCPFlagsOff:3};function PullSystemDefense(){amtFirstPull|=4;amtstack.BatchEnum(null,["AMT_SystemDefensePolicy","AMT_NetworkPortSystemDefensePolicy","AMT_Hdr8021Filter","AMT_IPHeadersFilter","AMT_NetworkFilter"],PullSystemDefenseResponse)}function PullSystemDefenseResponse(a,b,c,d){200==d&&(xxSystemDefense=c,updateSystemDefense(),QV("go18",!0))}
function updateSystemDefense(){if(null!=xxSystemDefense){var a="";xxSystemDefenceLinkedPolicy={};for(var b in xxSystemDefense.AMT_NetworkPortSystemDefensePolicy.responses){var c=xxSystemDefense.AMT_NetworkPortSystemDefensePolicy.responses[b],d=+getItem(c.Antecedent.ReferenceParameters.SelectorSet.Selector,"@Name","DeviceID").Value.substring(27),c=getItem(xxSystemDefense.AMT_SystemDefensePolicy.responses,"InstanceID",c.Dependent.ReferenceParameters.SelectorSet.Selector.Value);xxSystemDefenceLinkedPolicy[d]=
c}a+=TableStart();b="<i>None</i>";xxSystemDefenceLinkedPolicy[0]&&(b=xxSystemDefenceLinkedPolicy[0].PolicyName);a+=TableEntry("Default Wired Policy",addLink(b,"changeDefaultPolicy(0)"));for(b=0;2>b;b++){var c=xxFilterStatistics[b],f;for(f in c)d=c[f],d=1==d?d+" packet":d+" packets",a+=TableEntry((0==b?"Wired ":"Wireless ")+f,d)}a+=TableEnd();a=a+"<br>"+TableStart2();a+="<tr><td class=r1 style=padding-left:15px;border:0><br>Manage Intel&reg; AMT system defense policies.<br><br>";if(0==xxSystemDefense.AMT_SystemDefensePolicy.responses.length)a+=
"<div style=padding-left:15px><i>No system defense policies found.</i></div><br>";else for(b in xxSystemDefense.AMT_SystemDefensePolicy.responses)c=xxSystemDefense.AMT_SystemDefensePolicy.responses[b],d="",c.FilterCreationHandles&&(c.FilterCreationHandles=MakeToArray(c.FilterCreationHandles),d=c.FilterCreationHandles.length,d=", "+d+" filter"+(1<d?"s":"")),a+="<div class=itemBar onclick=showPolicyDetails("+b+")><div style=padding-top:3px><b>"+EscapeHtml(c.PolicyName)+"</b>"+d+"</div></div>";a+="<tr><td class=r1 style=padding-left:15px><br>Manage Intel&reg; AMT system defense filters.<br><br>";
if(0==xxSystemDefense.AMT_Hdr8021Filter.responses.length&&0==xxSystemDefense.AMT_IPHeadersFilter.responses.length)a+="<div style=padding-left:15px><i>No system defense filters found.</i></div><br>";else{for(b in xxSystemDefense.AMT_Hdr8021Filter.responses)c=xxSystemDefense.AMT_Hdr8021Filter.responses[b],(d=xxSystemDefenceFilterEthernetTypes[c.HdrProtocolID8021])||(d="All Ethernet Protocol "+c.HdrProtocolID8021),d+=", "+xxSystemDefenceFilterDesc[c.FilterProfile],2==c.FilterProfile&&(d+=" at "+c.FilterProfileData+
" packet / sec"),1==c.ActionEventOnMatch&&(d+=", Event on match"),a+="<div class=itemBar onclick=showFilterDetails(0,"+b+")><div style=padding-top:3px><b>"+(0==c.FilterDirection?"&#8592; ":"&#8594; ")+EscapeHtml(c.Name)+"</b>, "+d+"</div></div>";for(b in xxSystemDefense.AMT_IPHeadersFilter.responses){c=xxSystemDefense.AMT_IPHeadersFilter.responses[b];(d=xxSystemDefenceFilterIPTypes[c.HdrIPVersion])||(d="All Ethernet Protocol "+c.HdrIPVersion);d+=", "+xxSystemDefenceFilterDesc[c.FilterProfile];2==
c.FilterProfile&&(d+=" at "+c.FilterProfileData+" packet / sec");1==c.ActionEventOnMatch&&(d+=", Event on match");var n=0;for(f in xxSystemDefenceFilters)c[f]&&n++;0<n&&(d+=", "+n+" filter"+(1<n?"s":""));a+="<div class=itemBar onclick=showFilterDetails(1,"+b+")><div style=padding-top:3px><b>"+(0==c.FilterDirection?"&#8592; ":"&#8594; ")+EscapeHtml(c.Name)+"</b>, "+d+"</div></div>"}}a+="<br><td class=r1>"+TableEnd(AddRefreshButton("PullSystemDefense()")+AddButton("Add Filter...","AddDefenseFilter()")+
AddButton("Add Policy...","AddDefensePolicy()"));QH(29,a);null==xxFilterStatisticsTimer&&(UpdateDefenseStats(),xxFilterStatisticsTimerActive=!1,urlvars.norefresh||(xxFilterStatisticsTimer=setInterval(UpdateDefenseStats,5E3)))}}function StopDefenseStatsTimer(){null!=xxFilterStatisticsTimer&&(clearInterval(xxFilterStatisticsTimer),xxFilterStatisticsTimer=null);xxFilterStatisticsTimerActive=!1}
function UpdateDefenseStats(a){if(a||1!=xxFilterStatisticsTimerActive)xxFilterStatisticsTimerActive=!0,a=a?a:0,xxSystemDefenceLinkedPolicy[a]?amtstack.AMT_SystemDefensePolicy_UpdateStatistics('<a:Address></a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</w:ResourceURI><w:SelectorSet><w:Selector Name="DeviceID">Intel(r) AMT Ethernet Port '+a+"</w:Selector></w:SelectorSet></a:ReferenceParameters>",!1,UpdateDefenseStats2,a,0,{InstanceID:xxSystemDefenceLinkedPolicy[a].InstanceID}):
(xxFilterStatistics[a]={},updateSystemDefense(),StopDefenseStatsTimer())}function UpdateDefenseStats2(a,b,c,d,f){200==d?amtstack.Enum("AMT_ActiveFilterStatistics",UpdateDefenseStats3,f):StopDefenseStatsTimer()}
function UpdateDefenseStats3(a,b,c,d,f){a=0;if(200==d){xxFilterStatistics[f]={};for(var n in c)d=c[n].ReadCount,b=getItem(c[n].Dependent.ReferenceParameters.SelectorSet.Selector[1].Value.EndpointReference.ReferenceParameters.SelectorSet.Selector,"@Name","Name").Value,xxFilterStatistics[f][b]=d,a++;updateSystemDefense()}xxFilterStatisticsTimerActive=!1;0==a&&StopDefenseStatsTimer()}
function changeDefaultPolicy(a){if(!xxdialogMode){var b;b="<div style=height:26px;margin-top:4px><select id=policySelection style=float:right;width:266px><option value=-1>None";for(var c in xxSystemDefense.AMT_SystemDefensePolicy.responses)b+="<option value="+c+(xxSystemDefenceLinkedPolicy[a]&&xxSystemDefense.AMT_SystemDefensePolicy.responses[c].InstanceID==xxSystemDefenceLinkedPolicy[a].InstanceID?" selected":"")+">"+xxSystemDefense.AMT_SystemDefensePolicy.responses[c].PolicyName;setDialogMode(11,
"Default System Defense Policy",3,changeDefaultPolicyOk,b+"</select><div style=padding-top:4px>Default Policy</div></div>",a)}}
function changeDefaultPolicyOk(a,b){var c=Q("policySelection").value,d=xxSystemDefenceLinkedPolicy[b];d&&amtstack.Delete("AMT_NetworkPortSystemDefensePolicy",'<w:SelectorSet><w:Selector Name="Antecedent"><a:EndpointReference xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</w:ResourceURI><w:SelectorSet><w:Selector Name="CreationClassName">CIM_EthernetPort</w:Selector><w:Selector Name="DeviceID">Intel(r) AMT Ethernet Port '+b+
'</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference></w:Selector><w:Selector Name="Dependent"><a:EndpointReference xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address><a:ReferenceParameters><w:ResourceURI>http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SystemDefensePolicy</w:ResourceURI><w:SelectorSet><w:Selector Name="InstanceID">'+
d.InstanceID+"</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference></w:Selector></w:SelectorSet>",-1==c?PullSystemDefense:function(){});0<=c&&amtstack.Create("AMT_NetworkPortSystemDefensePolicy",{Antecedent:'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="DeviceID">Intel(r) AMT Ethernet Port '+
b+"</Selector></SelectorSet></ReferenceParameters>",Dependent:'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SystemDefensePolicy</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">'+
xxSystemDefense.AMT_SystemDefensePolicy.responses[c].InstanceID+"</Selector></SelectorSet></ReferenceParameters>"},changeDefaultPolicyOk2)}function changeDefaultPolicyOk2(a,b,c,d){200!=d?messagebox("Default System Defense Policy","Unable to set policy, error "+d):PullSystemDefense()}
function AddDefenseFilter(){if(!xxdialogMode){var a;a="<div style=height:26px;margin-top:4px><input id=filtername style=float:right;width:260px maxlength=16 onkeyup=AddDefenseFilterUpdate()><div style=padding-top:4px>Name</div></div><div style=height:26px;margin-top:4px><select id=filtertype style=float:right;width:266px onchange=AddDefenseFilterUpdate()><option value=0>Ethernet IP Packet Filter<option value=1>Ethernet ARP Packet Filter<option value=2>IPv4 Packet Filter<option value=3>IPv6 Packet Filter</select><div style=padding-top:4px>Type</div></div>";a+=
'<div style=height:26px;margin-top:4px id=ipfilterdiv><input id=ipfilter style=float:right;width:260px placeholder="Optional Rules" onkeyup=AddDefenseFilterUpdate()><div style=padding-top:4px>Matching Rules</div></div>';a+="<div style=height:26px;margin-top:4px><select id=filterdir style=float:right;width:266px onchange=AddDefenseFilterUpdate()><option value=0>Outbound / Transmit<option value=1>Inbound / Receive</select><div style=padding-top:4px>Direction</div></div>";a+="<div style=height:26px;margin-top:4px><select id=filterprofile style=float:right;width:266px onchange=AddDefenseFilterUpdate()><option value=0>Allow, Count<option value=1>Drop, Count<option value=2>Rate Limit<option value=3>Allow<option value=4>Drop</select><div style=padding-top:4px>Action</div></div>";
a+="<div style=height:26px;margin-top:4px id=filterdatadiv><input id=filterdata style=float:right;width:260px maxlength=8 onkeyup=AddDefenseFilterUpdate()><div style=padding-top:4px>Packets / second</div></div>";a+="<div style=height:26px;margin-top:4px><select id=filteraction style=float:right;width:266px onchange=AddDefenseFilterUpdate()><option value=false>Do Nothing<option value=1>Event on match</select><div style=padding-top:4px>Event Log</div></div>";setDialogMode(11,"Add System Defense Filter",
3,AddDefenseFilterOk,a);AddDefenseFilterUpdate()}}
function AddDefenseFilterOk(){if(1>=Q("filtertype").value){var a=0==Q("filtertype").value?2048:2054,b={"InstanceID ":0,Name:Q("filtername").value,CreationClassName:0,SystemName:0,SystemCreationClassName:0,HdrProtocolID8021:a,FilterProfile:Q("filterprofile").value,FilterDirection:Q("filterdir").value,ActionEventOnMatch:Q("filteraction").value};2==Q("filterprofile").value&&(b.FilterProfileData=Q("filterdata").value);amtstack.Create("AMT_Hdr8021Filter",b,AddDefenseFilterOk2)}else{var a=2==Q("filtertype").value?
4:6,b={"InstanceID ":0,Name:Q("filtername").value,CreationClassName:0,SystemName:0,SystemCreationClassName:0,HdrIPVersion:a,FilterProfile:Q("filterprofile").value,FilterDirection:Q("filterdir").value,ActionEventOnMatch:Q("filteraction").value},c=Q("ipfilter").value.split(","),d;for(d in c){var f=c[d].indexOf("="),n=c[d].substring(0,f),f=c[d].substring(f+1),p=xxSystemDefenceFilters[n];p||(n="Hdr"+n,p=xxSystemDefenceFilters[n]);p&&(2==p&&4==a?(f=f.split("."),4==f.length&&(b[n]=rstr2hex(String.fromCharCode(parseInt(f[0]),
parseInt(f[1]),parseInt(f[2]),parseInt(f[3]))))):b[n]=f)}2==Q("filterprofile").value&&(b.FilterProfileData=Q("filterdata").value);amtstack.Create("AMT_IPHeadersFilter",b,AddDefenseFilterOk2)}}function AddDefenseFilterUpdate(){var a=0<Q("filtername").value.length;a&&2==Q("filterprofile").value&&(a=parseInt(Q("filterdata").value),a=0<a&&4294967295>a);QE("c37",a);QV("filterdatadiv",2==Q("filterprofile").value);QV("ipfilterdiv",2<=Q("filtertype").value)}
function AddDefenseFilterOk2(a,b,c,d){200!=d?messagebox("Add System Defense Filter","Unable to add filter, error #"+d):PullSystemDefense()}
function showFilterDetails(a,b){if(!xxdialogMode){var c,d,f,n;0==a?(n="AMT_Hdr8021Filter",f="Ethernet Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterEthernetTypes[d.HdrProtocolID8021])||(c="All Ethernet Protocol "+d.HdrProtocolID8021)):(n="AMT_IPHeadersFilter",f="IP Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterIPTypes[d.HdrIPVersion])||(c="All IP Protocol "+d.HdrIPVersion));var p;p=""+addHtmlValue("Name",EscapeHtml(d.Name));p+=addHtmlValue("Type",f);p+=addHtmlValue("Matching Traffic",
c);p+=addHtmlValue("Direction",0==d.FilterDirection?"Outbound / Transmit":"Inbound / Receive");if(1==a)for(var r in xxSystemDefenceFilters)d[r]&&(c=r,f=d[r],a=xxSystemDefenceFilters[r],2==a&&4==f.length&&(f=hex2rstr(f),f=f.charCodeAt(0)+"."+f.charCodeAt(1)+"."+f.charCodeAt(2)+"."+f.charCodeAt(3)),c.startsWith("Hdr")&&(c=c.substring(3)),p+=addHtmlValue("Filter "+c,f));p+=addHtmlValue("Event on match",1==d.ActionEventOnMatch?"Yes":"No");setDialogMode(11,"Ethernet Filter #"+d.InstanceID,5,showFilterDetailsOk,
p,[n,d])}}function showFilterDetailsOk(a,b){2==a&&amtstack.Delete(b[0],b[1],deleteDefenseFilter)}function deleteDefenseFilter(a,b,c,d){200!=d?messagebox("Remove Filter","Unable to remove filter, make sure it's not in use."):PullSystemDefense()}var xxAddDefensePolicyFilters;
function AddDefensePolicy(){if(!xxdialogMode){xxAddDefensePolicyFilters=[];var a;a="<div style=height:26px;margin-top:4px><input id=policyname title='<policy name>:<policy precedence number>' style=float:right;width:260px maxlength=16 onkeyup=AddDefensePolicyUpdate()><div style=padding-top:4px>Name</div></div><div style=height:26px;margin-top:4px><select id=policytx title='Default action to take for outbound traffic' style=float:right;width:133px><option value=0>Allow<option value=1>Drop<option value=2>Allow,Count<option value=3>Drop,Count<option value=4>Allow,Count,Event<option value=5>Drop,Count,Event</select><select id=policyrx style=float:right;width:133px title='Default action to take for inbound traffic'><option value=0>Allow<option value=1>Drop<option value=2>Allow,Count<option value=3>Drop,Count<option value=4>Allow,Count,Event<option value=5>Drop,Count,Event</select><div style=padding-top:4px>Default TX / RX</div></div>";a+=
"<div id=policyFilters></div>";if(0<xxSystemDefense.AMT_Hdr8021Filter.responses.length||0<xxSystemDefense.AMT_IPHeadersFilter.responses.length){a+="<div style=height:26px;margin-top:4px><div style=float:right><select id=xfilter style=width:186px>";for(var b in xxSystemDefense.AMT_Hdr8021Filter.responses){var c=xxSystemDefense.AMT_Hdr8021Filter.responses[b];a+="<option value="+c.InstanceID+">"+c.Name}for(b in xxSystemDefense.AMT_IPHeadersFilter.responses)c=xxSystemDefense.AMT_IPHeadersFilter.responses[b],
a+="<option value="+c.InstanceID+">"+c.Name;a+="</select><input id=addFilterButton type=button value=Add style=width:80px onclick=addFilterButton()></div><div style=padding-top:4px>Add Filter</div></div>"}setDialogMode(11,"Add System Defense Policy",3,AddDefensePolicyOk,a);AddDefensePolicyUpdate()}}function addFilterButton(){0<=xxAddDefensePolicyFilters.indexOf(Q("xfilter").value)||(xxAddDefensePolicyFilters.push(Q("xfilter").value),AddDefensePolicyUpdate())}
function removeFilterButton(a){xxAddDefensePolicyFilters.splice(a,1);AddDefensePolicyUpdate()}
function AddDefensePolicyUpdate(){var a=0<Q("policyname").value.split(":")[0].length;QE("c37",a);if(0==xxAddDefensePolicyFilters.length)QH("policyFilters","<br><i>This policy contains no filters.</i><br><br>");else{var a="",b;for(b in xxAddDefensePolicyFilters)a+="<div class=itemBar style=margin-right:0><div style=float:right>"+AddButton2("Remove","removeFilterButton("+b+")")+"</div><div style=padding-top:3px;max-width:260px;overflow:hidden><b>"+GetFilterById(xxAddDefensePolicyFilters[b]).Name+
"</b></div></div>";QH("policyFilters",a)}}function GetFilterById(a){for(var b in xxSystemDefense.AMT_Hdr8021Filter.responses){var c=xxSystemDefense.AMT_Hdr8021Filter.responses[b];if(c.InstanceID==a)return c}for(b in xxSystemDefense.AMT_IPHeadersFilter.responses)if(c=xxSystemDefense.AMT_IPHeadersFilter.responses[b],c.InstanceID==a)return c}
function AddDefensePolicyOk(){var a=Q("policytx").value,b=Q("policyrx").value,c=0,d=Q("policyname").value.split(":");2==d.length&&(c=parseInt(d[1]));a={"InstanceID ":0,PolicyName:d[0],PolicyPrecedence:c,TxDefaultCount:1<a,TxDefaultDrop:1==a%2,TxDefaultMatchEvent:3<a,RxDefaultCount:1<b,RxDefaultDrop:1==b%2,RxDefaultMatchEvent:3<b};0<xxAddDefensePolicyFilters.length&&(a.FilterCreationHandles=xxAddDefensePolicyFilters);amtstack.Create("AMT_SystemDefensePolicy",a,AddDefensePolicyOk2)}
function AddDefensePolicyOk2(a,b,c,d){200!=d?messagebox("Add System Defense Policy","Unable to add policy, error #"+d):PullSystemDefense()}
function showPolicyDetails(a){if(!xxdialogMode){var b=xxSystemDefense.AMT_SystemDefensePolicy.responses[a],c;c=""+addHtmlValue("Name",EscapeHtml(b.PolicyName));0!=b.PolicyPrecedence&&(c+=addHtmlValue("Precedence",b.PolicyPrecedence));var d=1==b.TxDefaultDrop?"Drop":"Allow";1==b.TxDefaultCount&&(d+=", Count");1==b.TxDefaultMatchEvent&&(d+=", Event");c+=addHtmlValue("Default TX Action",d);d=1==b.RxDefaultDrop?"Drop":"Allow";1==b.RxDefaultCount&&(d+=", Count");1==b.RxDefaultMatchEvent&&(d+=", Event");
c+=addHtmlValue("Default RX Action",d);if(b.FilterCreationHandles)for(a in b.FilterCreationHandles)c+=addHtmlValue("Filter #"+(+a+1),GetFilterById(b.FilterCreationHandles[a]).Name);setDialogMode(11,"Policy #"+b.InstanceID.substring(20),5,showPolicyDetailsOk,c,b)}}function showPolicyDetailsOk(a,b){2==a&&amtstack.Delete("AMT_SystemDefensePolicy",b,deleteDefensePolicy)}
function deleteDefensePolicy(a,b,c,d){200!=d?messagebox("Remove Policy","Unable to remove policy, make sure it's not in use."):PullSystemDefense()}var xxWireless;function PullWireless(){amtFirstPull|=2;-1!=amtwirelessif&&amtstack.BatchEnum("",["*CIM_WiFiPortCapabilities","*CIM_WiFiPort","*CIM_WiFiEndpoint","CIM_WiFiEndpointSettings"],processWireless)}function wifiRefresh(){xxdialogMode||PullWireless()}
var xxWifiState={3:"Disabled",32768:"Enabled in S0",32769:"Enabled in S0, Sx/AC"},xxRadioState={2:"On, Connected",3:"Off",6:"On, Disconnected"},xxWifiAuthenticationMethod={1:"Other",2:"Open",3:"Shared Key",4:"WPA PSK",5:"WPA IEEE 802.1x",6:"WPA2 PSK",7:"WPA2 IEEE 802.1x"},xxWifiEncryptionMethod={1:"Other",2:"WEP",3:"TKIP-RC4",4:"CCMP-AES",5:"None"};function processWireless(a,b,c,d){xxWireless=200==d?c:void 0;updateSystemStatus();showWirelessInfo()}
function showWirelessInfo(){if(xxWireless){var a,b,c="",d,f;if(xxWireless.CIM_WiFiPortCapabilities.response){f="<br><h2>Wireless Profiles</h2>"+TableStart2();f+="<tr><td class=r2 style=padding-left:15px><br>Wireless profiles that Intel&reg; AMT will use for network connectivity.<br><br>";for(a=c=0;256>a;a++)for(b in xxWireless.CIM_WiFiEndpointSettings.responses)d=xxWireless.CIM_WiFiEndpointSettings.responses[b],1!=d.AuthenticationMethod&&d.Priority==a&&(f+="<div class=itemBar onclick=showWifiDetails("+
b+")><div style=float:right>"+EscapeHtml(d.SSID)+", "+xxWifiAuthenticationMethod[d.AuthenticationMethod]+", "+xxWifiEncryptionMethod[d.EncryptionMethod]+" &nbsp; ",xxAccountAdminName&&(f+=AddButton2("Remove",'wifiRemoveButton("'+b+'")')),f+="</div><div style=padding-top:3px><b>"+EscapeHtml(d.ElementName)+"</b></div></div>",c++);0==c&&(f+="<i>No Wireless Profiles Present</i><br>");f+="<br><td class=r2>";f=xxAccountAdminName?f+TableEnd(AddButton("New Profile","showWifiNewProfile()")):f+TableEnd("");
QH(20,f+"<br>")}}}function showWifiStateDlg(){if(!xxdialogMode){var a="",b;for(b in xxWifiState)a+="<input type=radio name=d11 id=wl"+b+" value="+b+" "+(xxWireless.CIM_WiFiPort.response.EnabledState==b?"checked":"")+">"+xxWifiState[b]+"<br>";setDialogMode(11,"Wireless State",3,wifiStateDlg,a)}}
function wifiStateDlg(){amtstack.CIM_WiFiPort_RequestStateChange(document.querySelector("input[name=d11]:checked").value,null,function(){amtstack.Get("CIM_WiFiPort",function(a,b,c,d){200==d&&(xxWireless.CIM_WiFiPort.response=c.Body,showWirelessInfo())})})}
function showWifiDetails(a){if(!xxdialogMode){a=xxWireless.CIM_WiFiEndpointSettings.responses[a];var b;b="<div style=text-align:left>"+addHtmlValue("Profile Name",EscapeHtml(a.ElementName));b+=addHtmlValue("SSID",a.SSID);b+=addHtmlValue("Authentication",xxWifiAuthenticationMethod[a.AuthenticationMethod]);b+=addHtmlValue("Encryption",xxWifiEncryptionMethod[a.EncryptionMethod]);b+=addHtmlValue("Priority",a.Priority);messagebox("Wireless Profile",b+"</div>")}}
function wifiRemoveButton(a){xxdialogMode||(QH(36,'Remove wireless profile "'+xxWireless.CIM_WiFiEndpointSettings.responses[a].ElementName+'"?'),setDialogMode(1,"Wireless Profile",3,function(){removeWifiButtonEx(a)}))}function removeWifiButtonEx(a){amtstack.Delete("CIM_WiFiEndpointSettings",{InstanceID:xxWireless.CIM_WiFiEndpointSettings.responses[a].InstanceID},removeWifiEntryResponse,0,1)}
function removeWifiEntryResponse(a,b,c,d,f){methodcheck(c)||amtstack.Enum("CIM_WiFiEndpointSettings",function(a,b,c,d){200==d&&(xxWireless.CIM_WiFiEndpointSettings.responses=c,showWirelessInfo())})}
function showWifiNewProfile(){if(!xxdialogMode){var a="";for(i=1;256>i;i++){var b=1;for(j in xxWireless.CIM_WiFiEndpointSettings.responses)xxWireless.CIM_WiFiEndpointSettings.responses[j].Priority==i&&(b=0);b&&(a+="<option value="+i+">"+i)}QH("c13",a);c14.value=6;c15.value=4;c11.value=c12.value=c16.value=c17.value="";setDialogMode(12,"Add Wireless Profile",3,function(){addWifiProfile()});updateWifiDialog()}}
function addWifiProfile(){amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings({__parameterType:"reference",__resourceUri:amtstack.CompleteName("CIM_WiFiEndpoint"),Name:"WiFi Endpoint 0"},{__parameterType:"instance",__namespace:amtstack.CompleteName("CIM_WiFiEndpointSettings"),ElementName:c11.value,InstanceID:"Intel(r) AMT:WiFi Endpoint Settings "+c11.value,AuthenticationMethod:c14.value,EncryptionMethod:c15.value,SSID:c12.value,Priority:c13.value,
PSKPassPhrase:c16.value},null,null,null,removeWifiEntryResponse)}
function updateWifiDialog(){var a=!0,b=c14.value,c=c15.value;QV(42,4>b);QV(41,3<b);QV(40,3<b);QV(43,4>b);4>b&&(3==c||4==c)&&(c15.value=2);3<b&&(2==c||5==c)&&(c15.value=3);for(var d in xxWireless.CIM_WiFiEndpointSettings.responses)xxWireless.CIM_WiFiEndpointSettings.responses[d].ElementName==c11.value&&(a=!1);QE("c37",1==a&&0<c11.value.length&&0<c12.value.length&&7<c16.value.length&&c16.value==
c17.value)}function PullHardware(){amtstack.BatchEnum("","*CIM_ComputerSystemPackage CIM_SystemPackaging *CIM_Chassis CIM_Chip *CIM_Card *CIM_BIOSElement CIM_Processor CIM_PhysicalMemory CIM_MediaAccessDevice CIM_PhysicalPackage".split(" "),processHardware);amtFirstPull|=1}
var DMTFCPUStatus="Unknown;Enabled;Disabled by User;Disabled By BIOS (POST Error);Idle;Other".split(";"),DMTFMemType="Unknown;Other;DRAM;Synchronous DRAM;Cache DRAM;EDO;EDRAM;VRAM;SRAM;RAM;ROM;Flash;EEPROM;FEPROM;EPROM;CDRAM;3DRAM;SDRAM;SGRAM;RDRAM;DDR;DDR-2;BRAM;FB-DIMM;DDR3;FBD2;DDR4;LPDDR;LPDDR2;LPDDR3;LPDDR4".split(";"),DMTFMemFormFactor=";Other;Unknown;SIMM;SIP;Chip;DIP;ZIP;Proprietary Card;DIMM;TSOP;Row of chips;RIMM;SODIMM;SRIMM;FB-DIM".split(";"),DMTFProcFamilly={191:"Intel&reg; Core&trade; 2 Duo Processor",
192:"Intel&reg; Core&trade; 2 Solo processor",193:"Intel&reg; Core&trade; 2 Extreme processor",194:"Intel&reg; Core&trade; 2 Quad processor",195:"Intel&reg; Core&trade; 2 Extreme mobile processor",196:"Intel&reg; Core&trade; 2 Duo mobile processor",197:"Intel&reg; Core&trade; 2 Solo mobile processor",198:"Intel&reg; Core&trade; i7 processor",199:"Dual-Core Intel&reg; Celeron&reg; processor"},HardwareInventory;
function processHardware(a,b,c,d){if(200==d){var f;a="<table class=log1 cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px>";HardwareInventory=c;QV("go2",!0);a+=TableEnd("<div>&nbsp;"+AddRefreshButton("PullHardware(1)")+AddButton("Save...","SaveHardwareLog()")+" Hardware information is gathered at system boot time.");b=c.CIM_Chassis.response;d=c.CIM_Card.response;var n=c.CIM_BIOSElement.response.SoftwareElementID;a=a+"<br><h2>Platform</h2>"+FullTable({"Computer model":b.Model,Manufacturer:b.Manufacturer,
Version:b.Version,"Serial number":b.SerialNumber,"System ID":guidToStr(c.CIM_SystemPackaging.responses[0].PlatformGUID).toLowerCase()},"");a+="<br><h2>Baseboard</h2>";a+=FullTable({Manufacturer:d.Manufacturer,"Product name":d.Model,Version:d.Version,"Serial number":d.SerialNumber,"Asset tag":d.Tag,"Replaceable?":1==d.CanBeFRUed?"Yes":"No"},"");a+="<br><h2>BIOS</h2>";a+=FullTable({Vendor:c.CIM_BIOSElement.response.Manufacturer,Version:n,"Release date":(new Date(c.CIM_BIOSElement.response.ReleaseDate.Datetime)).toLocaleDateString("en",
{timeZone:"UTC"})},"");a+="<br>";for(f in c.CIM_Processor.responses)b=c.CIM_Processor.responses[f],d=c.CIM_Chip.responses[f],a+="<h2>Processor "+(parseInt(f)+1)+"</h2>",a+=FullTable({Manufacturer:trademarks(d.Manufacturer),Family:DMTFProcFamilly[b.Family],Version:trademarks(d.Version),"Maximum socket speed":b.MaxClockSpeed+" MHz",Status:DMTFCPUStatus[b.CPUStatus]},"");a+="<br>";for(f in c.CIM_PhysicalMemory.responses)b=c.CIM_PhysicalMemory.responses[f],a+="<h2>Memory Module "+(+f+1)+"</h2>",a+=FullTable({"Bank Label":b.BankLabel,
Manufacturer:b.Manufacturer,"Serial Number":b.SerialNumber,Size:parseInt(b.Capacity/1048576)+" MB","Form factor":DMTFMemFormFactor[b.FormFactor],Type:DMTFMemType[b.MemoryType],"Asset tag":b.Tag,"Part number":b.PartNumber},"");a+="<br>";for(f in c.CIM_MediaAccessDevice.responses)b=c.CIM_MediaAccessDevice.responses[f],d=c.CIM_PhysicalPackage.responses[+f+1],a+="<h2>Storage Media "+(parseInt(f)+1)+"</h2>",a+=FullTable({Model:d.Model,"Serial number":""==d.SerialNumber?"Unknown":d.SerialNumber,Size:parseInt(Math.round(1E3*
b.MaxMediaSize/1048576))+" MB"},"");a+="<br>";QH(16,a);updateSystemStatus()}}function SaveHardwareLog(){!xxdialogMode&&HardwareInventory&&SaveJsonFile("IntelAmtHardware","hardware","Intel AMT Hardware Information",HardwareInventory)}var AmtSystemPowerSchemes=null;function PullPowerPolicy(){amtstack.Enum("AMT_SystemPowerScheme",powerPolicyResponse)}function powerPolicyResponse(a,b,c,d){AmtSystemPowerSchemes=c;updateSystemStatus()}
function showPowerPolicyDlg(a){if(!xxdialogMode){for(var b="",c=0;c<AmtSystemPowerSchemes.length;c++)b+='<input type=radio name=powerpolicy value="'+AmtSystemPowerSchemes[c].InstanceID+'" '+(AmtSystemPowerSchemes[c].SchemeGUID==a?" checked":"")+">"+AmtSystemPowerSchemes[c].Description+"<br>";setDialogMode(11,"Intel&reg; AMT Power Policy",3,showPowerPolicyDlgOk,b)}}
function showPowerPolicyDlgOk(){for(var a=null,b=0,c=document.getElementsByTagName("input");b<c.length;b++)"powerpolicy"==c[b].name&&c[b].checked&&(a=c[b].value);amtstack.AMT_SystemPowerScheme_SetPowerScheme(showPowerPolicyDlgOkDone,a)}function showPowerPolicyDlgOkDone(a,b,c,d){200==d&&PullSystemStatus()}var xxAccountAdminName,xxAccountRealmInfo,xxAccountEnabledInfo={},xxAccountFetch,showHiddenAccounts=!1;
function PullUserInfo(){xxAccountFetch=1;delete xxAccountAdminName;xxAccountRealmInfo={};amtstack.AMT_AuthorizationService_GetAdminAclEntry(getAdminAclEntryResponse);amtstack.AMT_AuthorizationService_EnumerateUserAclEntries(1,enumerateUserAclEntriesResponse)}function getAdminAclEntryResponse(a,b,c,d){200==d&&(xxAccountRealmInfo[-1]={AccessPermission:999,DigestUsername:c.Body.Username,Realms:null},xxAccountAdminName=c.Body.Username,updateAccounts())}
function enumerateUserAclEntriesResponse(a,b,c,d){if(200==d){methodcheck(c);QV("go11",!0);xxAccountFetch=c.Body.Handles.length;for(var f in c.Body.Handles)a=c.Body.Handles[f],amtstack.AMT_AuthorizationService_GetAclEnabledState(a,getAclEnabledStateResponse,a),amtstack.AMT_AuthorizationService_GetUserAclEntryEx(a,getUserAclEntryExResponse,a);updateAccounts()}}
function getUserAclEntryExResponse(a,b,c,d,f){xxAccountFetch--;200==d&&(c.Body.Handle=f,c.Body.Realms?Array.isArray(c.Body.Realms)||(c.Body.Realms=[c.Body.Realms]):c.Body.Realms=[],xxAccountRealmInfo[f]=c.Body,updateAccounts())}function getAclEnabledStateResponse(a,b,c,d,f){200==d&&(xxAccountEnabledInfo[f]=c.Body,updateAccounts())}function setAclEnabledStateResponse(a,b,c,d,f){errcheck(d,a)||(methodcheck(c),amtstack.AMT_AuthorizationService_GetAclEnabledState(f,getAclEnabledStateResponse,f))}
function updateAccounts(){if(!(0<xxAccountFetch)){var a=TableStart2(),a=a+"<tr><td class=r1 style=padding-left:15px><br>Manage the Intel&reg; AMT user accounts for this computer.<br><br>",b;for(b in xxAccountRealmInfo){var c=xxAccountRealmInfo[b],d,f=!1,n=0;c.DigestUsername?(d=c.DigestUsername,f="$"==d[0]&&"$"==d[1]):d=GetSidString(atob(c.KerberosUserSid));xxAccountEnabledInfo[b]&&"$$OsAdmin"!=d&&(n=1==xxAccountEnabledInfo[b].Enabled?1:2);if(showHiddenAccounts||!f){var p="";if(999!=c.AccessPermission){2==
n&&(p+="Disabled, ");var r=0;for(b in c.Realms)""!=amtstack.RealmNames[c.Realms[b]]&&r++;0<=c.Realms.indexOf(20)&&(p+="Auditor, ");p=0<=c.Realms.indexOf(3)?p+"Administrator":1==r?p+"1 realm":p+(r+" realms")}else p+="Administrator",c.Handle=-1;a+="<div class=itemBar onclick=showUserDetails("+c.Handle+")><div style=float:right>";0<n&&xxAccountAdminName&&(a+=" "+AddButton2(1==n?"Disable":"Enable","changeAccountStateButton(event,"+c.Handle+","+n+")"));!f&&xxAccountAdminName&&(a+=" "+AddButton2("Edit...",
"changeAccountButton(event,"+c.Handle+")"));a+="</div><div style=padding-top:3px;width:330px;float:left;overflow-x:hidden title='"+d+"'><b>"+d+"</b></div><div style=padding-top:3px>"+p+"</div></div>"}}b="<div style=float:right;margin-right:8px><a title='Toggle hidden accounts' style=color:gray;cursor:pointer onclick=toggleAccountButton()>"+(showHiddenAccounts?"&#x25B2;":"&#x25BC;")+"</a></div><div>&nbsp;"+AddRefreshButton("xxAccountFetch=999;PullUserInfo()");xxAccountAdminName&&(b+=AddButton("New Account",
"newAccountButton()"));a+="<br><td class=r1>"+TableEnd(b+"</div>");QH(21,a)}}function toggleAccountButton(){showHiddenAccounts=!showHiddenAccounts;updateAccounts()}function removeUserAclEntryResponse(a,b,c,d,f){methodcheck(c)||PullUserInfo()}function changeAccountStateButton(a,b,c){haltEvent(a);xxdialogMode||amtstack.AMT_AuthorizationService_SetAclEnabledState(b,1==c?!1:!0,setAclEnabledStateResponse,b)}
function changeAccountButton(a,b){haltEvent(a);xxdialogMode||(updateRealms(xxAccountRealmInfo[b].Realms),d2username.value=xxAccountRealmInfo[b].DigestUsername?xxAccountRealmInfo[b].DigestUsername:GetSidString(atob(xxAccountRealmInfo[b].KerberosUserSid)),d2password1.value=d2password2.value="",d2permission.value=xxAccountRealmInfo[b].AccessPermission,setDialogMode(2,"Edit Account",-1==b?3:7,function(a){changeAccountButtonEx(b,a)}),updateAccountDialog())}
function newAccountButton(){xxdialogMode||(updateRealms([]),d2username.value=d2password1.value=d2password2.value="",d2permission.value=2,setDialogMode(2,"New Account",3,function(){changeAccountButtonEx(null,1)}),updateAccountDialog())}
function changeAccountButtonEx(a,b){if(1==b){var c=[],d=d2username.value,f=d2permission.value,n=d2password1.value,p=GetSidByteArray(Q("d2username").value),r=null;if(0==d.length||n!=d2password2.value){messagebox("Account Error","Invalid Parameters");return}null==p?r=window.btoa(rstr_md5(d+":"+amtsysstate.AMT_GeneralSettings.response.DigestRealm+":"+n)):(d=null,p=btoa(p));if(-1!=a)for(var l in amtstack.RealmNames)(amtstack.RealmNames[l]||3==l)&&Q("rx"+l).checked&&c.push(l);null==a?amtstack.AMT_AuthorizationService_AddUserAclEntryEx(d,
r,p,f,c,userAclEntryExResponse):-1==a?amtstack.AMT_AuthorizationService_SetAdminAclEntryEx(d,r,userAclEntryExResponse):amtstack.AMT_AuthorizationService_UpdateUserAclEntryEx(a,d,r,p,f,c,userAclEntryExResponse)}2==b&&amtstack.AMT_AuthorizationService_RemoveUserAclEntry(a,removeUserAclEntryResponse)}function userAclEntryExResponse(a,b,c,d,f){methodcheck(c)||PullUserInfo()}
function updateRealms(a){QV(37,null!=a);if(null!=a){var b="<li><label><input type=checkbox onchange=updateAccountDialog() id=rx3"+(0<=a.indexOf(3)?" checked":"")+">Administrator</label></li><hr />",c;for(c in amtstack.RealmNames){var d="";0<=a.indexOf(parseInt(c))&&(d=" checked");amtstack.RealmNames[c]&&(b+="<li><label><input type=checkbox onchange=updateAccountDialog() id=rx"+c+d+">"+amtstack.RealmNames[c]+"</label></li>")}QH(38,b)}}
function updateAccountDialog(){var a=!1,b;for(b in amtstack.RealmNames)(amtstack.RealmNames[b]||3==b)&&Q("rx"+b).checked&&(a=!0);a&=0<d2username.value.length&&passwordcheck(d2password1.value)&&d2password1.value==d2password2.value;QE("c37",a)}var xxUserPermissions=["Local only","Network only","All (Local & Network)"];
function showUserDetails(a){if(!xxdialogMode){var b=xxAccountRealmInfo[a],c="<div style=text-align:left>",d,f=b.DigestUsername;f||(f=GetSidString(atob(b.KerberosUserSid)));c+=addHtmlValue("Name",f);xxAccountEnabledInfo[a]&&(c+=addHtmlValue("State",1==xxAccountEnabledInfo[a].Enabled?"Enabled":"Disabled"));if(f==xxAccountAdminName)c+=addHtmlValue("Permission","Administrator");else{var c=c+addHtmlValue("Permission",xxUserPermissions[b.AccessPermission]),n="";if(0<=b.Realms.indexOf(3))n="Administrator",
0<=b.Realms.indexOf(20)&&(n+=", Auditor");else for(d in xxAccountRealmInfo[a].Realms)""!=amtstack.RealmNames[b.Realms[d]]&&(0<n.length&&(n+=", "),n+=amtstack.RealmNames[b.Realms[d]]);0==n.length&&(n="None");c+=addHtmlValue("Realms","")+"<b>"+n+"</b>"}messagebox("Account "+f,c+"</div>")}}
function wsmanQuery(){QH(24,"");var a=getSelectedOptions(Q(22)),b=[],c;for(c in a)""==QS("WSB-"+a[c]).display&&b.push(a[c]);0!=b.length&&(QE(23,!1),b&&0<b.length&&amtstack.BatchEnum("Browser",b,browserResponse,null,!0))}
function browserResponse(a,b,c,d){QE(23,!0);a="";for(var f in c)b=c[f],a+="<h2>"+f+"</h2><div style=margin-left:20px>",a=200==b.status?0==b.responses.length?a+"<br>(Empty)":a+ObjectToString(b.responses).replace(/Intel\(r\)/g,"Intel&reg"):a+("<br><div style=color:red>Error #"+b.status+"</div>"),a+="</div><br>";QH(24,a)}
function wsmanFilter(){var a=c0.value.toLowerCase(),b;for(b in AllWsman)QV("WSB-"+AllWsman[b],""==a||0<=AllWsman[b].toLowerCase().indexOf(a))}var xxRemoteAccess=null,xxEnvironementDetection=null,xxCiraServers=null,xxUserInitiatedCira=null,xxUserInitiatedEnabledState={32768:"Disabled",32769:"BIOS enabled",32770:"OS enable",32771:"BIOS & OS enabled"},xxRemoteAccessCredentiaLinks=null,xxMPSUserPass=null,xxPolicies=null;
2018-10-03 22:03:09 +03:00
function PullRemoteAccess(){var a="*AMT_EnvironmentDetectionSettingData AMT_ManagementPresenceRemoteSAP AMT_RemoteAccessCredentialContext AMT_RemoteAccessPolicyAppliesToMPS AMT_RemoteAccessPolicyRule *AMT_UserInitiatedConnectionService AMT_MPSUsernamePassword".split(" ");11<amtversion&&a.push("*IPS_HTTPProxyService","IPS_HTTPProxyAccessPoint");amtstack.BatchEnum(null,a,processRemote1)}
2018-08-24 02:55:06 +03:00
function processRemote1(a,b,c,d){if(400!=d&&!errcheck(d,a)&&void 0!=c.AMT_UserInitiatedConnectionService&&void 0!=c.AMT_UserInitiatedConnectionService.response){QV("go17",!0);xxRemoteAccess=c;xxEnvironementDetection=c.AMT_EnvironmentDetectionSettingData.response;xxEnvironementDetection.DetectionStrings=MakeToArray(xxEnvironementDetection.DetectionStrings);xxCiraServers=c.AMT_ManagementPresenceRemoteSAP.responses;xxUserInitiatedCira=c.AMT_UserInitiatedConnectionService.response;xxRemoteAccessCredentiaLinks=
2018-11-15 02:44:28 +03:00
c.AMT_RemoteAccessCredentialContext.responses;xxMPSUserPass=c.AMT_MPSUsernamePassword.responses;xxPolicies={User:[],Alert:[],Periodic:[]};for(var f in c.AMT_RemoteAccessPolicyAppliesToMPS.responses)b=c.AMT_RemoteAccessPolicyAppliesToMPS.responses[f],a=Clone(getItem(xxCiraServers,"Name",getItem(b.ManagedElement.ReferenceParameters.SelectorSet.Selector,"@Name","Name").Value)),a.MpsType=b.MpsType,b=getItem(b.PolicySet.ReferenceParameters.SelectorSet.Selector,"@Name","PolicyRuleName").Value.split(" ")[0],
xxPolicies[b].push(a);updateRemoteAccess()}}
2018-10-03 22:03:09 +03:00
function updateRemoteAccess(){if(null!=xxEnvironementDetection){var a,b="Disabled",c=xxRemoteAccess.IPS_HTTPProxyService&&xxRemoteAccess.IPS_HTTPProxyAccessPoint;xxEnvironementDetection.DetectionStrings&&0<xxEnvironementDetection.DetectionStrings.length&&(b="Enabled, "+xxEnvironementDetection.DetectionStrings.length+" domain"+(1<xxEnvironementDetection.DetectionStrings.length?"s":""));a=""+TableStart();a+=TableEntry("Environment detection",addLink(b,"editEnvironmentDetection()"));a+=TableEntry("User initiation options",
2018-11-15 02:44:28 +03:00
addLinkConditional(xxUserInitiatedEnabledState[xxUserInitiatedCira.EnabledState],"editUserInitiatedCira()",xxAccountAdminName));b="<i>None</i>";if(0<xxPolicies.User.length){var b="",d;for(d in xxPolicies.User)0<b.length&&(b+=", "),b+=xxPolicies.User[d].AccessInfo,1==xxPolicies.User[d].MpsType&&(b+=" (CILA)")}a+=TableEntry("User initiated connection",addLinkConditional(b,'editMpsPolicy("User")',xxAccountAdminName));b="<i>None</i>";if(0<xxPolicies.Alert.length)for(d in b="",xxPolicies.Alert)0<b.length&&
(b+=", "),b+=xxPolicies.Alert[d].AccessInfo,1==xxPolicies.Alert[d].MpsType&&(b+=" (CILA)");a+=TableEntry("Alert initiated connection",addLinkConditional(b,'editMpsPolicy("Alert")',xxAccountAdminName));b="<i>None</i>";if(0<xxPolicies.Periodic.length)for(d in b="",xxPolicies.Periodic)0<b.length&&(b+=", "),b+=xxPolicies.Periodic[d].AccessInfo,1==xxPolicies.Periodic[d].MpsType&&(b+=" (CILA)");var f=getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName","Periodic");if(f){var n=atob(f.ExtendedData);
0==ReadInt(n,0)&&(b+=", each "+ReadInt(n,4)+" seconds");1==ReadInt(n,0)&&(f=ReadInt(n,4),n=ReadInt(n,8),10>n&&(n="0"+n),b+=", at "+f+":"+n+" daily")}a+=TableEntry("Periodic connection",addLinkConditional(b,'editMpsPolicy("Periodic")',xxAccountAdminName));a+=TableEnd();a=a+"<br>"+TableStart2();a+="<tr><td class=r1 style=padding-left:15px><br>Manage Intel&reg; AMT remote management servers.<br><br>";if(0==xxCiraServers.length)a+="<div style=padding-left:15px><br><i>No remote servers found.</i></div><br>";
else for(d in xxCiraServers)b=":"+xxCiraServers[d].Port,xxCiraServers[d].CN&&(b+=", "+xxCiraServers[d].CN),a+="<div class=itemBar onclick=showServerDetails("+d+")><div style=padding-top:3px><b>"+xxCiraServers[d].AccessInfo+"</b>"+EscapeHtml(b)+"</div></div>";if(c)if(a+="<br>Manage HTTP proxies used for management connections.<br><br>",b=xxRemoteAccess.IPS_HTTPProxyAccessPoint.responses,0==b.length)a+="<div style=padding-left:15px><br><i>No proxies configured.</i></div><br>";else for(d in b)a+="<div class=itemBar onclick=showProxyDetails("+
d+")><div style=padding-top:3px><b>"+EscapeHtml(b[d].AccessInfo)+":"+b[d].Port+"</b> / "+EscapeHtml(b[d].NetworkDnsSuffix)+"</div></div>";d="";xxAccountAdminName&&(d=AddButton("Add Server...","AddRemoteAccessServer()"),c&&(d+=AddButton("Add Proxy...","AddRemoteAccessProxy()")));a+="<br><td class=r1>"+TableEnd(AddRefreshButton("PullRemoteAccess()")+d);QH(28,a)}}var xxEditMpsPolicyType;
function editMpsPolicy(a){var b="",c=11<amtversion||11==amtversion&&6<=amtversion,d=xxEditMpsPolicyType=a;"User"==d&&(d="User Initiated");var d=getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName",d),b=b+"<div style=height:26px><select id=d2server1 style=float:right;width:206px onchange=editMpsPolicyUpdate()><option value=-1>(None)",f;for(f in xxCiraServers)b+="<option value="+f+""+(xxPolicies[a][0]&&xxPolicies[a][0].Name==xxCiraServers[f].Name?" selected":"")+">"+xxCiraServers[f].AccessInfo;
b+="</select><div>Primary server</div></div>";c&&(b+="<div style=height:26px><select id=d2server1cira style=float:right;width:206px onchange=editMpsPolicyUpdate()><option value=0>CIRA - External<option value=1"+(xxPolicies[a][0]&&1==xxPolicies[a][0].MpsType?" selected":"")+">CILA - Internal</select><div>Primary MPS Type</div></div>");if(1<xxCiraServers.length){b+="<div style=height:26px><select id=d2server2 style=float:right;width:206px onchange=editMpsPolicyUpdate()>";b+="<option value=-1>(None)";
for(f in xxCiraServers)b+="<option value="+f+""+(xxPolicies[a][1]&&xxPolicies[a][1].Name==xxCiraServers[f].Name?" selected":"")+">"+xxCiraServers[f].AccessInfo;b+="</select><div>Secondary server</div></div>";c&&(b+="<div style=height:26px><select id=d2server2cira style=float:right;width:206px onchange=editMpsPolicyUpdate()><option value=0>CIRA - External<option value=1"+(xxPolicies[a][1]&&1==xxPolicies[a][1].MpsType?" selected":"")+">CILA - Internal</select><div>Secondary MPS Type</div></div>")}f=
0;d&&(f=d.TunnelLifeTime);b+="<div style=height:26px><input id=d2lifetime style=float:right;width:200px onchange=editMpsPolicyUpdate() value="+f+">";b+="<div>Tunnel lifetime (Seconds)</div></div>";"Periodic"==a&&(c=0,f=3600,d&&(d=atob(d.ExtendedData),c=ReadInt(d,0),f=ReadInt(d,4),1==c&&(d=ReadInt(d,8),10>d&&(d="0"+d),f+=":"+d)),b+="<div style=height:26px><select id=d2ttype style=float:right;width:206px onchange=editMpsPolicyUpdate()>",b+="<option value=0"+(0==c?" selected":"")+">Periodic, time interval<option value=1"+
(1==c?" selected":"")+">Time of day, once a day",b+="</select><div>Trigger type</div></div><div style=height:26px><input id=d2timer style=float:right;width:200px onkeyup=editMpsPolicyUpdate() value="+f+"><div id=ttypelabel></div></div>");setDialogMode(11,a+" Connection",3,editMpsPolicyOk,b);editMpsPolicyUpdate()}
function editMpsPolicyUpdate(){var a=11<amtversion||11==amtversion&&6<=amtversion,b=1>=xxCiraServers.length||-1==Q("d2server1").value||Q("d2server1").value!=Q("d2server2").value;if(1==b&&"Periodic"==xxEditMpsPolicyType&&1==Q("d2ttype").value){var c=Q("d2timer").value.split(":");if(2!=c.length)b=!1;else{var d=parseInt(c[0]),c=parseInt(c[1]);if(0>d||23<d||0>c||59<c)b=!1}}QE("c37",b);1<xxCiraServers.length&&QE("d2server2",-1!=Q("d2server1").value);"Periodic"==xxEditMpsPolicyType&&(QE("d2timer",
-1!=Q("d2server1").value),QH("ttypelabel",0==Q("d2ttype").value?"Trigger interval (Seconds)":"Time of day (HH:MM)"),QE("d2ttype",-1!=Q("d2server1").value));QE("d2lifetime",-1!=Q("d2server1").value);a&&(QE("d2server1cira",-1<Q("d2server1").value),1<xxCiraServers.length&&QE("d2server2cira",-1<Q("d2server1").value&&-1<Q("d2server2").value))}
function editMpsPolicyOk(){var a=xxEditMpsPolicyType;"User"==a&&(a="User Initiated");getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName",a)?amtstack.Delete("AMT_RemoteAccessPolicyRule",{PolicyRuleName:a},editMpsPolicyOk2):editMpsPolicyOk2()}
function editMpsPolicyOk2(a,b,c,d){a=11<amtversion||11==amtversion&&6<=amtversion;if(-1==Q("d2server1").value)PullRemoteAccess();else{b=0;"Alert"==xxEditMpsPolicyType&&(b=1);"Periodic"==xxEditMpsPolicyType&&(b=2);c=null;2==b&&(c=Q("d2ttype").value,d=IntToStr(Q("d2timer").value),1==c&&(d=Q("d2timer").value.split(":"),d=IntToStr(parseInt(d[0]))+IntToStr(parseInt(d[1]))),c=btoa(IntToStr(c)+d));var f,n;0<=Q("d2server1").value&&(f='<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">'+
xxCiraServers[Q("d2server1").value].Name+"</Selector></SelectorSet></ReferenceParameters>");0<=Q("d2server1").value&&1<xxCiraServers.length&&0<=Q("d2server2").value&&(n='<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">'+
xxCiraServers[Q("d2server2").value].Name+"</Selector></SelectorSet></ReferenceParameters>");d=[];var p=[];a?f&&(0==Q("d2server1cira").value?d.push(f):p.push(f),n&&(0==Q("d2server2cira").value?d.push(n):p.push(n))):f&&(d.push(f),n&&d.push(n));amtstack.AMT_RemoteAccessService_AddRemoteAccessPolicyRule(b,Q("d2lifetime").value,c,d,p,PullRemoteAccess)}}var editEnvironmentDetectionTmp;
2018-08-24 02:55:06 +03:00
function editEnvironmentDetection(a){1!=a&&(editEnvironmentDetectionTmp=xxEnvironementDetection.DetectionStrings?Clone(xxEnvironementDetection.DetectionStrings):[]);var b="";xxAccountAdminName&&(b+="Enter up to 4 intranet domain suffix. If the computer is outside these domains, Intel&reg; AMT local ports will be closed and remote server connections will be active.<br><br>");0==editEnvironmentDetectionTmp.length&&(b+="<i>No intranet domains, Environemnt detection disabled.</i><br>");for(var c in editEnvironmentDetectionTmp)b+=
"<div class=itemBar style=margin-right:0><div style=float:right>"+AddButton2("Remove","editEnvironmentDetectionRemove("+c+")")+"</div><div style=padding-top:3px;max-width:260px;overflow:hidden title='"+editEnvironmentDetectionTmp[c]+"'><b>"+editEnvironmentDetectionTmp[c]+"</b></div></div>";xxAccountAdminName&&4>editEnvironmentDetectionTmp.length&&(b+="<br><input id=edInput placeholder=intranet.org style=width:276px onkeyup=edInputChg() maxlength=63><input type=button id=edAdd value=Add style=width:80px;margin-left:5px onclick=editEnvironmentDetectionAdd()>");
1==a?QH(39,b):setDialogMode(11,"Environment Detection",xxAccountAdminName?3:1,editEnvironmentDetectionDlg,b);edInputChg()}function editEnvironmentDetectionDlg(){if(xxAccountAdminName){var a=Clone(xxEnvironementDetection);a.DetectionStrings=editEnvironmentDetectionTmp;amtstack.Put("AMT_EnvironmentDetectionSettingData",a,editEnvironmentDetectionDlg2,0,1)}}
function editEnvironmentDetectionDlg2(a,b,c,d){200!=d?messagebox("Environment Detection","Failed to add server, status "+d):c.Body.ReturnValue&&0!=c.Body.ReturnValue?messagebox("Environment Detection",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}function edInputChg(){4>editEnvironmentDetectionTmp.length&&QE("edAdd",0<Q("edInput").value.length)}function editEnvironmentDetectionAdd(){editEnvironmentDetectionTmp.push(Q("edInput").value);editEnvironmentDetection(1)}
function editEnvironmentDetectionRemove(a){editEnvironmentDetectionTmp.splice(a,1);editEnvironmentDetection(1)}function editUserInitiatedCira(){if(!xxdialogMode){var a="",b;for(b in xxUserInitiatedEnabledState)a+="<input type=radio name=d11 id=wl"+b+" value="+b+" "+(xxUserInitiatedCira.EnabledState==b?"checked":"")+">"+xxUserInitiatedEnabledState[b]+"<br>";setDialogMode(11,"User Initiated Tunnel",3,editUserInitiatedCiraDlg,a)}}
function editUserInitiatedCiraDlg(){amtstack.AMT_UserInitiatedConnectionService_RequestStateChange(document.querySelector("input[name=d11]:checked").value,null,editUserInitiatedCiraDlg2)}function editUserInitiatedCiraDlg2(a,b,c,d){200==d&&amtstack.Get("AMT_UserInitiatedConnectionService",editUserInitiatedCiraDlg3,0,1)}function editUserInitiatedCiraDlg3(a,b,c,d){200==d&&(xxUserInitiatedCira=c.Body,updateRemoteAccess())}var xxShowServerDetailsHandle;
function showServerDetails(a){xxShowServerDetailsHandle=a;var b=xxCiraServers[a],c;c=""+addHtmlValue("Access Name",b.AccessInfo);b.Port&&(c+=addHtmlValue("Port",b.Port));b.CN&&(c+=addHtmlValue("Common Name",b.CN));if(b=getElementWithContextSelectorValue(xxRemoteAccessCredentiaLinks,b.Name))b=b.ElementInContext.ReferenceParameters.SelectorSet.Selector.Value,0<b.indexOf("Username")?(c+=addHtmlValue("Authentication Type","User & Pass / Server-Auth TLS"),c+=addHtmlValue("Remote ID",getInstance(xxMPSUserPass,
b).RemoteID)):(c+=addHtmlValue("Authentication Type","Certificate / Mutual-Auth TLS"),b=getInstance(xxCertificates,b),c+=addHtmlValue("Certificate Name",parseCertName(b.Subject).CN));b=1;xxAccountAdminName&&(b=5);setDialogMode(11,"Remote Server #"+(a+1),b,showServerDetailsOk,c)}
function getElementWithContextSelectorValue(a,b){for(var c in a){a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector=MakeToArray(a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector);for(var d in a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector)if(a[c].ElementProvidingContext.ReferenceParameters.SelectorSet.Selector[d].Value==b)return a[c]}return null}
function showServerDetailsOk(a){2==a&&amtstack.Delete("AMT_ManagementPresenceRemoteSAP",{Name:xxCiraServers[xxShowServerDetailsHandle].Name},showServerDetailsOk2)}function showServerDetailsOk2(a,b,c,d){408==d?messagebox("Remote Server Removal","Unable to remove server, access denied."):PullRemoteAccess()}function parseCertName(a){var b={},c=a.split(","),d;for(d in c)a=c[d].indexOf("="),b[c[d].substring(0,a)]=c[d].substring(a+1);return b}
2018-10-03 22:03:09 +03:00
function showProxyDetails(a){var b=xxRemoteAccess.IPS_HTTPProxyAccessPoint.responses[a],c=addHtmlValue("Access name",b.AccessInfo+":"+b.ProxyPort),c=c+addHtmlValue("DNS suffex",b.NetworkDnsSuffix),c=c+addHtmlValue("Proxy type",["Administrator","Operating system"][b.Type]),b=1;xxAccountAdminName&&(b=5);setDialogMode(11,"HTTP Proxy #"+(a+1),b,showProxyDetailsOk,c,a)}
function showProxyDetailsOk(a,b){var c=xxRemoteAccess.IPS_HTTPProxyAccessPoint.responses[b];2==a&&amtstack.Delete("IPS_HTTPProxyAccessPoint",{Name:c.Name},showProxyDetailsOk2)}function showProxyDetailsOk2(a,b,c,d){408==d?messagebox("HTTP Proxy Removal","Unable to remove HTTP proxy, access denied."):PullRemoteAccess()}
function AddRemoteAccessProxy(){var a;a='<div style=height:26px><select id=d2type style=float:right;width:206px onchange=AddRemoteAccessProxyUpdate()><option value=2>Hostname FQDN<option value=3>IPv4 address<option value=4>IPv6 address</select><div>Connection type</div></div><div style=height:26px><input id=d2host style=float:right;width:200px maxlength=255 onkeyup=AddRemoteAccessProxyUpdate()><div id=d2typespan></div></div><div style=height:26px><input id=d2port onkeypress="return (event.charCode == 0 || (event.charCode >= 48 && event.charCode <= 57))" style=float:right;width:200px onkeyup=AddRemoteAccessProxyUpdate()><div>Port</div></div>';a+=
"<div style=height:26px><input id=d2domain style=float:right;width:200px maxlength=191 onkeyup=AddRemoteAccessProxyUpdate()><div>DNS suffix</div></div>";setDialogMode(11,"Add HTTP Proxy",3,AddRemoteAccessProxyOk,a);AddRemoteAccessProxyUpdate()}
function AddRemoteAccessProxyUpdate(){var a=0!=Q("d2host").value.length&&0!=Q("d2domain").value.length;if(0==Q("d2port").value.length||65535<parseInt(Q("d2port").value))a=!1;QE("c37",a);QH("d2typespan",["","","FQDN / hostname","IPv4 address","IPv6 address"][Q("d2type").value])}function AddRemoteAccessProxyOk(){amtstack.IPS_HTTPProxyService_AddProxyAccessPoint(Q("d2host").value,Q("d2type").value,parseInt(Q("d2port").value),Q("d2domain").value,AddRemoteAccessProxyOk2)}
function AddRemoteAccessProxyOk2(a,b,c,d){200!=d?messagebox("Add Proxy Server","Failed to add proxy, status "+d):0!=c.Body.ReturnValue?messagebox("Add Proxy Server",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}
function AddRemoteAccessServer(){var a=[],b;for(b in xxCertificates)xxCertificates[b].XPrivateKey&&a.push(xxCertificates[b]);var c;c="<div style=height:26px><select id=d2type style=float:right;width:206px onchange=AddRemoteAccessServerUpdate()><option value=201>Hostname FQDN<option value=3>IPv4 address</select><div>Connection type</div></div><div style=height:26px><input id=d2name style=float:right;width:200px onkeyup=AddRemoteAccessServerUpdate()><div id=d2lname></div></div>";c+='<div style=height:26px><input id=d2port onkeypress="return (event.charCode == 0 || (event.charCode >= 48 && event.charCode <= 57))" style=float:right;width:200px value=4433 onkeyup=AddRemoteAccessServerUpdate()><div>Server port</div></div>';
c+="<div style=height:26px id=d2ucn><input id=d2cn style=float:right;width:200px onkeyup=AddRemoteAccessServerUpdate()><div>Server Common Name</div></div>";c+="<div style=height:26px><select id=d2auth style=float:right;width:206px onchange=AddRemoteAccessServerUpdate()>";0<a.length&&(c+="<option value=1>Certificate");c+="<option value=2>Username/Password</select><div>Authentication type</div></div>";c+="<span id=d2utype>";c+="<div style=height:26px><input id=d2user style=float:right;width:200px onkeyup=AddRemoteAccessServerUpdate()><div>Username</div></div>";
2018-08-24 02:55:06 +03:00
c+="<div style=height:26px><input id=d2pass style=float:right;width:200px onkeyup=AddRemoteAccessServerUpdate()><div>Strong Password</div></div>";c+="</span>";c+="<span id=d2ctype>";c+="<div style=height:26px><select id=d2cert style=float:right;width:206px onchange=AddRemoteAccessServerUpdate()>";for(b in a)c+="<option value="+a[b].InstanceID.substring(34)+">"+parseCertName(a[b].Subject).CN;c+="</select><div>Certificate</div></div></span>";setDialogMode(11,"Add Remote Server",3,AddRemoteAccessServerOk,
c);AddRemoteAccessServerUpdate()}
function AddRemoteAccessServerOk(){var a,b,c,d;1==Q("d2auth").value?a='<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT Certificate: Handle: '+Q("d2cert").value+
"</Selector></SelectorSet></ReferenceParameters>":(b=Q("d2user").value,c=Q("d2pass").value);0<Q("d2cn").value.length&&(d=Q("d2cn").value);amtstack.AMT_RemoteAccessService_AddMpServer(Q("d2name").value,Q("d2type").value,Q("d2port").value,Q("d2auth").value,a,b,c,d,AddRemoteAccessServerOk2)}
function AddRemoteAccessServerOk2(a,b,c,d){200!=d?messagebox("Add Internet Server","Failed to add server, status "+d):0!=c.Body.ReturnValue?messagebox("Add Internet Server",c.Body.ReturnValueStr.replace(/_/g," ")):PullRemoteAccess()}
function AddRemoteAccessServerUpdate(){var a=0!=Q("d2name").value.length;3==Q("d2type").value&&1==a&&(a=0!=Q("d2cn").value.length);2==Q("d2auth").value&&1==a&&(a=0!=Q("d2user").value.length&&passwordcheck(Q("d2pass").value));if(0==Q("d2port").value.length||65535<parseInt(Q("d2port").value))a=!1;if(-1!=Q("d2name").value.indexOf(":")||3==Q("d2type").value&&-1!=Q("d2cn").value.indexOf(":"))a=!1;QH("d2lname",201==Q("d2type").value?"Hostname":"IPv4 Address");QV("d2utype",2==Q("d2auth").value);QV("d2ucn",
3==Q("d2type").value);QV("d2ctype",1==Q("d2auth").value);QE("c37",a)}
function showEditNameDlg(a){if(!xxdialogMode){var b=amtsysstate.AMT_GeneralSettings.response.HostName,c=amtsysstate.AMT_GeneralSettings.response.DomainName;null!=c&&0<c.length&&(b+="."+c);b='<br><div style=height:26px><input id=d11name value="'+b+'" style=float:right;width:200px><div>Name & Domain</div></div>';1==a&&(a=1==amtsysstate.AMT_GeneralSettings.response.SharedFQDN,b+="<div style=height:26px><select id=d11fqdn style=float:right;width:200px><option value=true "+(a?"selected":"")+'>Shared, same as OS<option value="false" '+
(a?"":"selected")+">Dedicated, different from OS</select><div>Name Sharing</div></div>");setDialogMode(11,"Computer Name",3,editNameDlgOk,b)}}function editNameDlgOk(){var a=Q("d11name").value,b=a.indexOf("."),c="";0<=b&&(c=a.substring(b+1),a=a.substring(0,b));b=Clone(amtsysstate.AMT_GeneralSettings.response);b.HostName=a;b.DomainName=c;Q("d11fqdn")&&(b.SharedFQDN=d11fqdn.value);amtstack.Put("AMT_GeneralSettings",b,function(){amtstack.Get("AMT_GeneralSettings",computerNameGet,0,1)},0,1)}
function computerNameGet(a,b,c,d){200==d&&(amtsysstate.AMT_GeneralSettings.response=c.Body,updateSystemStatus())}function showEditDnsDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_GeneralSettings.response,b=0;1==a.DDNSUpdateByDHCPServerEnabled&&(b=1);1==a.DDNSUpdateEnabled&&(b=2);c24.value=b;c25.value=a.DDNSPeriodicUpdateInterval;c26.value=a.DDNSTTL;showEditDnsDlgChange();setDialogMode(23,"Dynamic DNS client",3,showEditDnsDlgOk)}}
function showEditDnsDlgOk(){var a=Clone(amtsysstate.AMT_GeneralSettings.response);a.DDNSUpdateEnabled=2==c24.value?!0:!1;a.DDNSUpdateByDHCPServerEnabled=1==c24.value?!0:!1;2==c24.value&&(a.DDNSPeriodicUpdateInterval=c25.value,a.DDNSTTL=c26.value);amtstack.Put("AMT_GeneralSettings",a,function(){amtstack.Get("AMT_GeneralSettings",computerNameGet,0,1)},0,1)}
function showEditDnsDlgChange(){QE("c25",2==c24.value);QE("c26",2==c24.value)}function showFeaturesDlg(){!xxdialogMode&&xxAccountAdminName&&(c3.checked=amtfeatures[0],c5.checked=amtfeatures[3],c6.checked=amtfeatures[2],c7.checked=amtfeatures[1],QV("c4",void 0!=amtfeatures[3]),setDialogMode(9,"Intel&reg; AMT Features",3,featuresDlgOk))}
function featuresDlgOk(){var a=amtsysstate.AMT_RedirectionService.response;a.ListenerEnabled=c3.checked;a.EnabledState=32768+((c6.checked?1:0)+(c7.checked?2:0));amtstack.AMT_RedirectionService_RequestStateChange(a.EnabledState,function(b,c,d,f){200!=f?messagebox("Error","RedirectionService, RequestStateChange Error "+f):amtstack.CIM_KVMRedirectionSAP_RequestStateChange(c5.checked?2:3,0,function(b,c,d,f){200!=f?messagebox("Error","KVMRedirectionSAP, RequestStateChange Error "+
f):amtstack.Put("AMT_RedirectionService",a,function(a,b,c,d){200!=d?messagebox("Error","RedirectionService PUT Error "+d):(amtstack.Get("AMT_RedirectionService",featuresDlgGet1,0,1),amtstack.Get("CIM_KVMRedirectionSAP",featuresDlgGet2,0,1))},0,1)})})}function featuresDlgGet1(a,b,c,d){200==d&&(amtsysstate.AMT_RedirectionService.response=c.Body,updateSystemStatus())}function featuresDlgGet2(a,b,c,d){200==d&&(amtsysstate.CIM_KVMRedirectionSAP.response=c.Body,updateSystemStatus())}
function showConsentDlg(){if(!xxdialogMode){var a=amtsysstate.IPS_OptInService.response.OptInRequired;c8.checked=0==a;c9.checked=1==a;c10.checked=4294967295==a;setDialogMode(10,"User Consent",3,consentDlgOk)}}function consentDlgOk(){amtsysstate.IPS_OptInService.response.OptInRequired=document.querySelector("input[name=d10]:checked").value;amtstack.Put("IPS_OptInService",amtsysstate.IPS_OptInService.response,function(){amtstack.Get("IPS_OptInService",consentGet,0,1)},0,1)}
function consentGet(a,b,c,d){200==d&&PullSystemStatus()}var ipv6addrtype="Link local address;Network local address;Global address;User configured;Not allowed;DAD in progress;valid;deprecated;preferred/deprecated;expired;collision;not allowed".split(";");
function showIPv6AddrDlg(a,b){if(!xxdialogMode){var c=TableStart();t=b.split(",");for(var d=0;d<t.length;d+=3)c+=TableEntry("<b>"+t[d]+"</b><br><span style=font-size:10px>"+ipv6addrtype[t[d+1]]+", "+ipv6addrtype[+t[d+2]+5]+"</span>","");setDialogMode(11,"IPv6 addresses for "+(0==a?"wired":"wireless")+" interface",1,null,c+TableEnd())}}
function showIPv6StateDlg(a,b){if(!xxdialogMode&&amtsysstate){var c=amtsysstate.IPS_IPv6PortSettings.responses[a];ipv6manual=0==a&&(isIpAddress(c.IPv6Address)||isIpAddress(c.DefaultRouter)||isIpAddress(c.PrimaryDNS)||isIpAddress(c.SecondaryDNS));QV(44,0==a);QV(45,!1);QV("d21o0",!0);QV("d21l0",!0);QH("d21l0","IPv6 disabled");QH("d21l1","IPv6 enabled, automatic");QH("d21l2","IPv6 enabled, automatic + manual addresse");d21o0.checked=!b;d21o1.checked=b&&!ipv6manual;d21o2.checked=
b&&ipv6manual;c19.value=isIpAddress(c.IPv6Address,"");c21.value=isIpAddress(c.DefaultRouter,"");c22.value=isIpAddress(c.PrimaryDNS,"");c23.value=isIpAddress(c.SecondaryDNS,"");updateIPSetupDlg();setDialogMode(21,"IPv6 support for "+(0==a?"wired":"wireless")+" interface",3,function(){showIPv6StateDlgOk(a)})}}
function showIPv6StateDlgOk(a){var b=amtsysstate.IPS_IPv6PortSettings.responses[a];0==a&&(d21o1.checked&&(b.IPv6Address=b.DefaultRouter=b.PrimaryDNS=b.SecondaryDNS="::",amtstack.Put("IPS_IPv6PortSettings",b,showIPv6StateDlgDone)),d21o2.checked&&(b.IPv6Address=c19.value,b.DefaultRouter=c21.value,b.PrimaryDNS=c22.value,b.SecondaryDNS=c23.value,amtstack.Put("IPS_IPv6PortSettings",b,showIPv6StateDlgDone)));for(var b=amtsysstate.CIM_ElementSettingData.responses,c=
0;c<b.length;c++)if(b[c].SettingData&&b[c].SettingData.ReferenceParameters.SelectorSet.Selector.Value=="Intel(r) IPS IPv6 Settings "+a){var d=Clone(b[c]);d.IsCurrent=d21o0.checked?2:1;amtstack.Put("CIM_ElementSettingData",d,showIPv6StateDlgDone)}}function showIPv6StateDlgDone(a,b,c,d){200==d?(amtsysstate=void 0,PullSystemStatus()):messagebox("IPv6 support","Unable to set IPv6 state, error "+d)}
function showPingActionDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_GeneralSettings.response,a=(1==a.PingResponseEnabled)+((1==a.RmcpPingResponseEnabled)<<1);d20a.checked=0==a;d20b.checked=1==a;d20c.checked=2==a;d20d.checked=3==a;setDialogMode(20,"Intel&reg; AMT Ping Response",3,showPingActionDlgOk)}}
function showPingActionDlgOk(){var a=Clone(amtsysstate.AMT_GeneralSettings.response),b=document.querySelector("input[name=d20]:checked").value;a.PingResponseEnabled=0!=(b&1);a.RmcpPingResponseEnabled=0!=(b&2);amtstack.Put("AMT_GeneralSettings",a,PullSystemStatus,0,1)}
function showIPSetupDlg(){if(!xxdialogMode){var a=amtsysstate.AMT_EthernetPortSettings.responses[0];QV(44,!0);QV(45,!0);QV("d21o0",!1);QV("d21l0",!1);QH("d21l1","Automatic configuration using DHCP server");QH("d21l2","Static configuration using IPv4 settings below");d21o1.checked=1==a.DHCPEnabled;d21o2.checked=!d21o1.checked;c19.value=isIpAddress(a.IPAddress,"");c20.value=isIpAddress(a.SubnetMask,"");c21.value=isIpAddress(a.DefaultGateway,
"");c22.value=isIpAddress(a.PrimaryDNS,"");c23.value=isIpAddress(a.SecondaryDNS,"");updateIPSetupDlg();setDialogMode(21,"IPv4 Settings",3,showIPSetupDlgOk)}}function updateIPSetupDlg(){c19.disabled=c20.disabled=c21.disabled=c22.disabled=c23.disabled=!d21o2.checked}
function showIPSetupDlgOk(){var a=Clone(amtsysstate.AMT_EthernetPortSettings.responses[0]);a.DHCPEnabled=d21o1.checked;delete a.IPAddress;delete a.SubnetMask;delete a.DefaultGateway;delete a.PrimaryDNS;delete a.SecondaryDNS;0==d21o1.checked&&(a.IPAddress=c19.value,a.SubnetMask=c20.value,a.DefaultGateway=c21.value,""!=c22.value&&(a.PrimaryDNS=c22.value),""!=c23.value&&(a.SecondaryDNS=c23.value));amtstack.Put("AMT_EthernetPortSettings",
a,showIPSetupDlgDone,0,1)}function showIPSetupDlgDone(a,b,c,d){200==d?(amtsysstate=void 0,PullSystemStatus()):messagebox("IPv4 Settings","Unable to set network parameters, error "+d)}amtPowerBootCapabilities=null;function showPowerActionDlg(){xxdialogMode||(statusbox("Power Actions","Checking capabilities..."),amtstack.Get("AMT_BootCapabilities",powerActionResponse00,0,1))}
2018-10-03 22:03:09 +03:00
function powerActionResponse00(a,b,c,d){200==d?(amtPowerBootCapabilities=c.Body,QH("d5actionSelect",""),addOption("d5actionSelect","Power up",2),addOption("d5actionSelect","Power cycle",5),addOption("d5actionSelect","Power down",8),addOption("d5actionSelect","Reset",10),1==amtPowerBootCapabilities.ForceDiagnosticBoot&&(addOption("d5actionSelect","Power on to diagnostic",300),addOption("d5actionSelect","Reset to diagnostic",301)),9<amtversion&&(addOption("d5actionSelect","Soft-off",12),addOption("d5actionSelect",
"Soft-reset",14),addOption("d5actionSelect","Sleep",4),addOption("d5actionSelect","Hibernate",7)),1==amtPowerBootCapabilities.BIOSSetup&&(addOption("d5actionSelect","Power up to BIOS",100),addOption("d5actionSelect","Reset to BIOS",101)),1==amtPowerBootCapabilities.SecureErase&&(addOption("d5actionSelect","Power up to Secure Erase",104),addOption("d5actionSelect","Reset to Secure Erase",105)),addOption("d5actionSelect","Reset to PXE",400),addOption("d5actionSelect","Power on to PXE",401),addOption("d5actionSelect",
"Custom action...",999),5<amtversion&&addOption("d5actionSelect","User consent...",998),setDialogMode(5,"Power Actions",3,powerActionDlgCheck)):messagebox("Power Action","Unable to get system capabilities, error "+d)}
2018-08-24 02:55:06 +03:00
function powerActionDlgCheck(){var a=d5actionSelect.value;104==a||105==a?(a="Confirm execution of Intel&reg Remote Secure Erase?<br>Enter Secure Erase password if required.<br><br><div style=height:16px><input type=password id=rsepass maxlength=32 style=float:right;width:240px><div>Password</div></div><br><div style=color:red><b>WARNING:</b> This will wipe data on the remote system.</div>",rsepass=1,setDialogMode(11,"Power Actions",3,powerActionDlg,a)):powerActionDlg()}
function powerActionDlg(){var a=d5actionSelect.value;if(999==a)showAdvPowerDlg();else if(998==a)amtstack.Get("IPS_OptInService",powerActionResponse0,0,1);else{statusbox("Power Action","Checking state...");null!=rsepass&&1===rsepass&&(rsepass=Q("rsepass").value);var b=!0;6>amtversion&&(b=!1);13==currentView&&8==a&&(b=!1);13!=currentView&&10>=a&&(b=!1);b?amtstack.Get("IPS_OptInService",powerActionResponse0,0,1):amtstack.Get("AMT_BootSettingData",powerActionResponse1,0,1)}}var AvdPowerDlg;
function showAdvPowerDlg(){QV("d24dBiosPause",1==amtPowerBootCapabilities.BIOSPause);QV("d24dReflashBios",1==amtPowerBootCapabilities.BIOSReflash);QV("d24dBiosSetup",1==amtPowerBootCapabilities.BIOSSetup);QV("d24dForceProgressEvents",1==amtPowerBootCapabilities.ForcedProgressEvents);QV("d24dUseIDER",1==amtPowerBootCapabilities.IDER);QV("d24dLockKeyboard",1==amtPowerBootCapabilities.KeyboardLock);QV("d24dLockPowerButton",1==amtPowerBootCapabilities.PowerButtonLock);QV("d24dLockResetButton",1==amtPowerBootCapabilities.ResetButtonLock);
QV("d24dSerialOverLan",1==amtPowerBootCapabilities.SOL);QV("d24dSecureErase",1==amtPowerBootCapabilities.SecureErase);QV("d24dLockSleepButton",1==amtPowerBootCapabilities.SleepButtonLock);QV("d24dUserPasswordBypass",1==amtPowerBootCapabilities.UserPasswordBypass);QV("c33",1==amtPowerBootCapabilities.VerbosityQuiet);QV("c34",1==amtPowerBootCapabilities.VerbosityVerbose);QV("c35",1==amtPowerBootCapabilities.VerbosityScreenBlank);setDialogMode(24,"Custom Power Action",
2018-10-03 22:03:09 +03:00
3,showAdvPowerDlgOk);showAdvPowerDlgChange()}
function showAdvPowerDlgChange(){QV("idd_d24IDERBootDevice",Q("d24UseIDER").checked);QV("idd_d24RSEPass",Q("d24SecureErase")?Q("d24SecureErase").checked:!1);var a="d24BiosPause d24BiosSetup d24ForceProgressEvents d24LockPowerButton d24LockResetButton d24LockSleepButton d24LockKeyboard d24UserPasswordBypass d24ReflashBios d24SafeMode d24UseIDER d24SerialOverLan d24SecureErase".split(" ");if(0<c29.value)for(var b in a)Q(a[b]).checked=!1;for(b in a)QE(a[b],0==c29.value)}
2018-08-24 02:55:06 +03:00
function showAdvPowerDlgOk(){AvdPowerDlg={};AvdPowerDlg.Action=Q("c27").value;AvdPowerDlg.BIOSPause=Q("d24BiosPause").checked;AvdPowerDlg.BIOSSetup=Q("d24BiosSetup").checked;AvdPowerDlg.BootMediaIndex=Q("c30").value;AvdPowerDlg.FirmwareVerbosity=Q("c32").value;AvdPowerDlg.ForcedProgressEvents=Q("d24ForceProgressEvents").checked;AvdPowerDlg.IDERBootDevice=Q("c31").value;AvdPowerDlg.LockKeyboard=Q("d24LockKeyboard").checked;AvdPowerDlg.LockPowerButton=
Q("d24LockPowerButton").checked;AvdPowerDlg.LockResetButton=Q("d24LockResetButton").checked;AvdPowerDlg.LockSleepButton=Q("d24LockSleepButton").checked;AvdPowerDlg.ReflashBIOS=Q("d24ReflashBios").checked;AvdPowerDlg.UseIDER=Q("d24UseIDER").checked;AvdPowerDlg.UseSOL=Q("d24SerialOverLan").checked;AvdPowerDlg.UseSafeMode=Q("d24SafeMode").checked;AvdPowerDlg.UserPasswordBypass=Q("d24UserPasswordBypass").checked;AvdPowerDlg.SecureErase=Q("d24SecureErase").checked;!0===AvdPowerDlg.SecureErase&&0<Q("d24rsepass").value.length&&
(AvdPowerDlg.RSEPassword=Q("d24rsepass").value);statusbox("Power Action","Checking state...");amtstack.Get("IPS_OptInService",powerActionResponse0,0,1)}
function powerActionResponse0(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):4294967295==c.Body.OptInRequired&&3!=c.Body.OptInState&&4!=c.Body.OptInState?2==c.Body.OptInState?(d6ConsentText.value="",setDialogMode(6,"User Consent",11,powerActionSendConsent),checkConsentDisplay(),consentChanged()):(statusbox("Power Action","Starting opt-in..."),amtstack.IPS_OptInService_StartOptIn(powerActionResponseC1,0,1)):998==d5actionSelect.value?messagebox("User Consent","User consent not needed."):(statusbox("Power Action",
"Getting Boot Settings..."),amtstack.Get("AMT_BootSettingData",powerActionResponse1,0,1))}
function powerActionResponseC1(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):0!=c.Body.ReturnValue?messagebox("User Consent Error",c.Body.ReturnValueStr.replace(/_/g," ")):(d6ConsentText.value="",setDialogMode(6,"User Consent",11,powerActionSendConsent),checkConsentDisplay(),consentChanged(),amtstack.Enum("CIM_ServiceAvailableToElement",function(a,b,c,d){errcheck(d,a)||(amtsysstate.CIM_ServiceAvailableToElement.responses=c,updateSystemStatus(),2!=amtsysstate.CIM_ServiceAvailableToElement.responses[0].PowerState&&
amtstack.RequestPowerStateChange(2,function(a,b,c,d){}))}))}function powerActionSendConsent(a){0==a?amtstack.IPS_OptInService_CancelOptIn(function(){}):(statusbox("Power Action","Sending user consent..."),amtstack.IPS_OptInService_SendOptInCode(d6ConsentText.value,powerActionResponseC2,0,1))}
function powerActionResponseC2(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):0!=c.Body.ReturnValue?amtstack.Get("IPS_OptInService",powerActionResponse0,0,1):998==d5actionSelect.value?messagebox("User Consent","User consent succesful."):(statusbox("Power Action","Checking state..."),amtstack.Get("AMT_BootSettingData",powerActionResponse1,0,1))}
function powerActionResponse1(a,b,c,d){200!=d?messagebox("Power Action","Error #"+d):(a=d5actionSelect.value,c=c.Body,c.ConfigurationDataReset=!1,999==a?(c.BIOSPause=AvdPowerDlg.BIOSPause,c.BIOSSetup=AvdPowerDlg.BIOSSetup,c.BootMediaIndex=AvdPowerDlg.BootMediaIndex,c.FirmwareVerbosity=AvdPowerDlg.FirmwareVerbosity,c.ForcedProgressEvents=AvdPowerDlg.ForcedProgressEvents,c.IDERBootDevice=AvdPowerDlg.IDERBootDevice,c.LockKeyboard=AvdPowerDlg.LockKeyboard,c.LockPowerButton=AvdPowerDlg.LockPowerButton,
c.LockResetButton=AvdPowerDlg.LockResetButton,c.LockSleepButton=AvdPowerDlg.LockSleepButton,c.ReflashBIOS=AvdPowerDlg.ReflashBIOS,c.UseIDER=AvdPowerDlg.UseIDER,c.UseSOL=AvdPowerDlg.UseSOL,c.UseSafeMode=AvdPowerDlg.UseSafeMode,c.UserPasswordBypass=AvdPowerDlg.UserPasswordBypass,null!=c.SecureErase&&(c.SecureErase=AvdPowerDlg.SecureErase&&1==amtPowerBootCapabilities.SecureErase,1==c.SecureErase&&AvdPowerDlg.RSEPassword&&(c.RSEPassword=AvdPowerDlg.RSEPassword))):(c.BIOSPause=!1,c.BIOSSetup=99<a&&104>
2018-10-03 22:03:09 +03:00
a,c.BootMediaIndex=0,c.FirmwareVerbosity=0,c.ForcedProgressEvents=!1,c.IDERBootDevice=202==a||203==a?1:0,c.LockKeyboard=!1,c.LockPowerButton=!1,c.LockResetButton=!1,c.LockSleepButton=!1,c.ReflashBIOS=!1,c.UseIDER=199<a&&300>a,c.UseSOL=13==currentView&&8!=a&&300>a,c.UseSafeMode=!1,c.UserPasswordBypass=!1,null!=c.SecureErase&&(c.SecureErase=(104==a||105==a)&&1==amtPowerBootCapabilities.SecureErase,!0===c.SecureErase&&0<rsepass.length&&(c.RSEPassword=rsepass)),rsepass=null),console.log("Boot Action: "+
a),console.log("Setting Boot Settings: "+ObjectToString2(c)),statusbox("Power Action","Setting boot settings..."),amtstack.Put("AMT_BootSettingData",c,powerActionResponse2,c,1))}function powerActionResponse2(a,b,c,d,f){200!=d?(messagebox("Power Action","PUT AMT_BootSettingData, Error #"+d),console.log(f)):(statusbox("Power Action","Setting next boot..."),amtstack.SetBootConfigRole(1,powerActionResponse3x,0,1))}
2018-08-24 02:55:06 +03:00
function powerActionResponse3x(a,b,c,d){a=d5actionSelect.value;b=null;if(999==a)0<c29.value&&(b=["Force CD/DVD Boot","Force PXE Boot","Force Hard-drive Boot","Force Diagnostic Boot"][c29.value-1]);else{if(300==a||301==a)b="Force Diagnostic Boot";if(400==a||401==a)b="Force PXE Boot"}console.log("ChangeBootOrder: "+b);amtstack.CIM_BootConfigSetting_ChangeBootOrder(null==b?b:'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: '+
b+"</Selector></SelectorSet></ReferenceParameters>",powerActionResponse3)}var targetPowerAction=0;
function powerActionResponse3(a,b,c,d){console.log("powerActionResponse3("+b+","+c+","+d+")");if(!errcheck(d,a)){statusbox("Power Action","Performing power action...");a=d5actionSelect.value;if(100==a||201==a||203==a||300==a||401==a)a=2;if(101==a||200==a||202==a||301==a||400==a)a=10;104==a&&(a=2);105==a&&(a=10);999==a&&(a=AvdPowerDlg.Action);targetPowerAction=a;11==a&&(a=10);999>a?(console.log("RequestPowerStateChange("+a+")"),amtstack.RequestPowerStateChange(a,powerActionResponse4)):messagebox("Power Action",
"Next boot action set.")}}function powerActionResponse4(a,b,c,d){200==d&&(QH(36,"Power action completed."),setDialogMode(1,"Power Action",0),setTimeout(function(){setDialogMode(0)},1300));amtstack.Get("CIM_AssociatedPowerManagementService",powerActionResponse5,0,1)}function powerActionResponse5(a,b,c,d){}function consentChanged(){QE("c37",6==d6ConsentText.value.length)}function changeConsentDisplay(){xxchangeConsentDisplay=!0;checkConsentDisplay()}
function checkConsentDisplay(){amtstack.Get("IPS_SecIOService",checkConsentDisplayResponse1)}var xxchangeConsentDisplay=!1;
function checkConsentDisplayResponse1(a,b,c,d){200==d&&(c.Body.DefaultScreen&&(c.Body.DefaultScreen=parseInt(c.Body.DefaultScreen)),c.Body.NumberOfScreens&&(c.Body.NumberOfScreens=parseInt(c.Body.NumberOfScreens)),1==xxchangeConsentDisplay?(xxchangeConsentDisplay=!1,c.Body.DefaultScreen=d6Display.value,amtstack.Put("IPS_SecIOService",c.Body,checkConsentDisplayResponse1)):(d6Display.value=c.Body.DefaultScreen,QV("d6ThirdDisplay",2<c.Body.NumberOfScreens)))}
var xxStorage=null,xxStorageVendors=[],xxStorageApplications=[];function PullStorage(){amtFirstPull|=8;wsstack.comm.PerformAjax("",PullStorageResponse,null,0,"/amt-storage/","GET")}
2018-10-03 22:03:09 +03:00
function PullStorageResponse(a,b,c){0==amtstack.PendingBatchOperations&&refreshButtons(!0);if(200==b){QV("go21",!0);for(b=0;32>b;b++){do c=a.length,a=a.replace(String.fromCharCode(b),"");while(c>a.length)}try{xxStorage=JSON.parse(a)}catch(u){return}xxStorageVendors=[];xxStorageApplications=[];a=xxStorage.content;if(Array.isArray(a)){c={};for(b in a){var d=a[b].vendor?a[b].vendor:"";c[d]||(c[d]={});var f=a[b].app?a[b].app:"";c[d][f]||(c[d][f]={});a[b].name&&(c[d][f][a[b].name]=a[b])}xxStorage.content=
a=c}else{if(a["index.htm"]||a["logon.htm"])a[""]={"":{}};a["index.htm"]&&(a[""][""]["index.htm"]=a["index.htm"],delete a["index.htm"]);a["logon.htm"]&&(a[""][""]["logon.htm"]=a["logon.htm"],delete a["logon.htm"])}c=0;var d=TableStart2()+"<tr><td class=r1 style=padding-left:15px><br>Manage Intel&reg; AMT storage for this computer.<br><br>",n,p,f="";for(b in a){var r=0,l;for(l in a[b]){r++;var k=0,v;for(v in a[b][l]){k++;if(b!=n||l!=p)""!=f&&(d+=f,f="<br>"),n=b,p=l,f=""!=b?f+EscapeHtml(b+" / "+l):f+
"Root";var e='"'+b+(""!=b?"/":"")+l+(""!=l?"/":"")+v+'"',f=f+('<div class=itemBar onclick=showStorageDetails("'+b+'","'+l+'","'+v+'",'+e+")><div style=float:right>"),f=f+(" "+AddButton2("Download","DownloadFromStorage("+e+',"'+v+'",event)')),f=f+("</div><div style=padding-top:3px><b>"+EscapeHtml(v)+"</b>, <i>"+a[b][l][v].size+" bytes</i></div></div>");c++;-1==xxStorageVendors.indexOf(b)&&xxStorageVendors.push(b);-1==xxStorageApplications.indexOf(l)&&xxStorageApplications.push(l)}0==k&&wsstack.comm.PerformAjax("",
2018-08-24 02:55:06 +03:00
function(){},null,0,"/amt-storage/"+b+"/"+l,"DELETE")}0==r&&wsstack.comm.PerformAjax("",function(){},null,0,"/amt-storage/"+b,"DELETE")}""!=f&&(d+=f);0==c&&(d+="<div style=padding-left:15px><br><i>No files found.</i></div><br>");d+="<br><td class=r1>"+TableEnd(AddRefreshButton("PullStorage()")+AddButton("Upload...","UploadToStorage()"));QH(31,d)}else QH(31,"Unable to load storage data...<br/>"+AddButton("Refresh","PullStorage()"))}
function showStorageDetails(a,b,c,d){if(!xxdialogMode){var f="",n=xxStorage.content[a][b][c];""!=a&&(f+=addHtmlValue("Vendor",a));""!=b&&(f+=addHtmlValue("Application",b));f+=addHtmlValue("Name",c);f+=addHtmlValue("Size",n.size+" bytes");n.link&&(f+=addHtmlValue("Link",n.link));setDialogMode(11,"Storage Item",5,showStorageDetailsEx,f,d)}}function showStorageDetailsEx(a,b){2==a&&wsstack.comm.PerformAjax("",storageDeleteResponse,null,0,"/amt-storage/"+b,"DELETE")}
function storageDeleteResponse(a,b){200!=b?messagebox("Storage","Unable to delete file (ERR"+b+"), check that the computer is powered on."):PullStorage()}function DownloadFromStorage(a,b,c){xxdialogMode||(haltEvent(c),wsstack.comm.PerformAjax("",DownloadFromStorageEx,b,0,"/amt-storage/"+a,"GET"))}function DownloadFromStorageEx(a,b,c){200!=b||null==a?console.log(b,"Data = null"):saveAs(data2blob(a),c)}
function OpenFromStorage(a,b){xxdialogMode||(haltEvent(b),window.open("http://"+wsstack.comm.host+":"+wsstack.comm.port+"/amt-storage/"+a,"_blank").focus())}function PushToStorage(a,b,c){var d=null;7E3<b.length&&(d=[a,b.substring(7E3)],b=b.substring(0,7E3));wsstack.comm.PerformAjax(b,PushToStorageResponse,d,0,"/amt-storage/"+a+(1==c?"?append=":""),"PUT")}
function PushToStorageResponse(a,b,c){200!=b?messagebox("Storage","Unable to push file (ERR"+b+"), check that the computer is powered on."):null!=c?PushToStorage(c[0],c[1],!0):PullStorage()}
function UploadToStorage(a,b){if(!xxdialogMode){b||(b="");var c;c="<br>Select a small file to upload to storage and enter a vendor, application and filename.<br>";c=(a?c+('<br><div style=height:20px><input id=mstoragefile style=float:right;width:240px readonly disabled=disabled value="'+b+'" ><div>Upload file</div></div>'):c+"<br><div style=height:20px><input type=file id=mstoragefile style=float:right;width:240px onchange=SetStorageName()><div>Upload file</div></div>")+"<br><div style=height:16px><input id=mstoragevendor placeholder=Vendor list=mstoragevendorlist maxlength=11 style=float:right;width:240px><div>Vendor name</div></div>";
c+="<br><div style=height:16px><input id=mstorageapplication placeholder=App list=mstorageapplicationlist maxlength=11 style=float:right;width:240px><div>Application name</div></div>";c+="<br><div style=height:16px><input id=mstoragefilename placeholder=Filename maxlength=11 style=float:right;width:240px><div>Filename</div></div>";c+="<br><div style=height:16px><input id=mstoragetype placeholder=application/octet-stream list=mstoragetypelist style=float:right;width:240px><div>MIME Type</div></div>";
c+='<br><div style=height:16px><input id=mstoragelink style=float:right;width:240px><div title="If set, creates a link to this content from the main web page">Link</div></div><br>';c+="<datalist id=mstoragevendorlist>";for(var d in xxStorageVendors)c+='<option value="'+xxStorageVendors[d]+'">';c+="</datalist>";c+="<datalist id=mstorageapplicationlist>";for(d in xxStorageApplications)c+='<option value="'+xxStorageApplications[d]+'">';c+='</datalist><datalist id=mstoragetypelist><option value="application/octet-stream"><option value="image/jpeg"><option value="text/html"><option value="text/plain"></datalist>';
setDialogMode(11,"Storage Upload",3,UploadToStorageEx,c,a);a&&SetStorageName(b)}}function UploadToStorageEx(a,b){if(b)d=new FileReader,d.onload=UploadToStorageEx2,d.filename=Q("mstoragefile").value,d.readAsBinaryString(b);else{var c=Q("mstoragefile");if(1==c.files.length){var d=new FileReader;d.onload=UploadToStorageEx2;d.filename=c.files[0].name;d.readAsBinaryString(c.files[0])}}}
function SetStorageName(a){a||(a=Q("mstoragefile"),a=1==a.files.length?a.files[0].name:"");a=a.split(" ").join("");var b=a.split("-");3==b.length&&12>b[0].length&&12>b[1].length&&(Q("mstoragevendor").value=b[0],Q("mstorageapplication").value=b[1],a=b[2]);a=a.split("-").join("");a.endsWith(".gz")&&(a=a.substring(0,a.length-3));a.endsWith(".htm")||a.endsWith(".html")?Q("mstoragetype").value="text/html":a.endsWith(".txt")&&(Q("mstoragetype").value="text/plain");11<a.length&&(a=a.substring(0,11));Q("mstoragefilename").value=
a}
function UploadToStorageEx2(a){var b;b=Q("mstoragevendor").value;var c=Q("mstorageapplication").value,d=Q("mstoragefilename").value;""==d&&(d="Filename");var f=Q("mstoragetype").value;""==f&&(f="application/octet-stream");var n=Q("mstoragelink").value;""!=b||""!=c||"logon.htm"!=d.toLowerCase()&&"index.htm"!=d.toLowerCase()?(""==b&&(b="Vendor"),""==c&&(c="App"),b=b+"/"+c+"/"+d):b=d.toLowerCase();c="<metadata><headers>";d=a.target.filename;d||(d=Q("mstoragefile").files[0].name);d.endsWith(".gz")&&(c+=
"<h>Content-Encoding: gzip</h>");c+="<h>Content-Type: "+f+"</h></headers>";""!=n&&(c+="<link>"+n+"</link>");c+="</metadata>"+a.target.result;PushToStorage(b,c)}function _fmtdatetime(a){return a.replace("T"," ").replace("Z","")}
function _fmtinterval(a){a=a.replace("T","").substring(a.indexOf("P")+1);a=" "+a.replace("D"," days ").replace("H"," hours ").replace("M"," minutes ");a=a.replace(" 1 days "," 1 day ").replace(" 1 hours "," 1 hour ").replace(" 1 minutes "," 1 minute ");return a.substring(0,a.length-1)}function _fmttimepad(a){for(a=""+a;2>a.length;)a="0"+a;return a}var xxAlarms=null;
function PullAlarms(){var a=TableStart2()+"<tr><td class=r1 style=padding-left:15px><br>Manage wake alarms.<br><br>";amtstack.Enum("IPS_AlarmClockOccurrence",function(b,c,d,f){if(200==f){QV("go23",!0);if(0<d.length)for(xxAlarms=d,b=0;b<d.length;b++)c="<b>"+d[b].ElementName+"</b>, wake on "+(new Date(d[b].StartTime.Datetime)).toLocaleString().replace(", "," at "),void 0!=d[b].Interval&&(c+=" and each"+_fmtinterval(d[b].Interval.Interval)),1==d[b].DeleteOnCompletion&&(c+=", delete when done"),a+="<div class=itemBar onclick=showAlertDetails("+
b+")><div style=float:right>",xxAccountAdminName&&(a+=" "+AddButton2("Edit...","showAddAlarm("+b+")")),a+="</div><div style=padding-top:3px;width:auto;float:left;overflow-x:hidden>"+c+"</div></div>";else xxAlarms=null,a+="<div style=padding-left:15px><br><i>No wake alarms registered.</i></div><br>";d="<div>&nbsp;"+AddRefreshButton("PullAlarms()");xxAccountAdminName&&(d+=AddButton("Remove all alarms","RemoveAllAlarms()")+AddButton("Add","showAddAlarm()"));a+="<br><td class=r1>"+TableEnd(d+"</div>");
QH(33,a)}},null,!0)}
function prepareAlarmOccurenceTemplate(a,b,c,d,f){return'<d:AlarmTemplate xmlns:d="http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService" xmlns:s="http://intel.com/wbem/wscim/1/ips-schema/1/IPS_AlarmClockOccurrence"><s:InstanceID>'+a+"</s:InstanceID><s:ElementName>"+b+'</s:ElementName><s:StartTime><p:Datetime xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+c+'</p:Datetime></s:StartTime><s:Interval><p:Interval xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Interval></s:Interval><s:DeleteOnCompletion>"+
f+"</s:DeleteOnCompletion></d:AlarmTemplate>"}function RemoveAllAlarms(){setDialogMode(1,"Remove all wake alarms",3,RemoveAllAlarmsEx,"Confirm removal of all wake alarms?")}function RemoveAllAlarmsEx(){var a=xxAlarms.length,b;for(b in xxAlarms)amtstack.Delete("IPS_AlarmClockOccurrence",xxAlarms[b],function(b,d,f,n){0==--a&&PullAlarms()})}
function showAddAlarm(a){if(!xxdialogMode){QE("d25alarm_name",!a);if(void 0!=a){var b=xxAlarms[a],c=new Date(b.StartTime.Datetime);Q("d25alarm_name").value=b.ElementName;Q("d25alarm_sdate").value=c.getFullYear()+"-"+_fmttimepad(c.getMonth()+1)+"-"+_fmttimepad(c.getDate());Q("d25alarm_stime").value=c.getHours()+":"+_fmttimepad(c.getMinutes())+":"+_fmttimepad(c.getSeconds());if(b.Interval){var c=b.Interval.Interval.replace("P","").replace("T","").replace("D","D,").replace("H","H,").replace("M","M,").split(","),
d=[0,0,0],f;for(f in c){var n=c[f].length-1;"D"==c[f][n]&&(d[0]=parseInt(c[f].substring(0,n)));"H"==c[f][n]&&(d[1]=parseInt(c[f].substring(0,n)));"M"==c[f][n]&&(d[2]=parseInt(c[f].substring(0,n)))}Q("d25alarm_interval").value=d.join("-")}else Q("d25alarm_interval").value="";Q("d25alarm_doc").value=1==b.DeleteOnCompletion?1:0}else b=new Date,b.setDate((new Date).getDate()+1),Q("d25alarm_name").value="",Q("d25alarm_sdate").value=b.getFullYear()+"-"+_fmttimepad(b.getMonth()+1)+"-"+_fmttimepad(b.getDate()),
Q("d25alarm_stime").value=b.getHours()+":"+_fmttimepad(b.getMinutes())+":00",Q("d25alarm_interval").value="",Q("d25alarm_doc").value=0;setDialogMode(25,"Add new alarm",void 0!=a?7:3,showAddAlarmOk,"",a);alertDialogUpdate()}}function alertDialogUpdate(){var a=Q("d25alarm_interval").value.split("-").length,a=0<Q("d25alarm_name").value.length&&3==Q("d25alarm_sdate").value.split("-").length&&3==Q("d25alarm_stime").value.split(":").length&&(1==a||3==a);QE("c37",a)}
function showAddAlarmOk(a,b){if(2==a)showAlertDetailsDelete(a,b);else{var c=Q("d25alarm_name").value,d=Q("d25alarm_sdate").value.split("-"),f=Q("d25alarm_stime").value.split(":"),d=new Date(d[0],d[1],d[2],f[0],f[1],f[2],0),d=_fmttimepad(d.getUTCFullYear())+"-"+_fmttimepad(d.getUTCMonth())+"-"+_fmttimepad(d.getUTCDate())+"T"+_fmttimepad(d.getUTCHours())+":"+_fmttimepad(d.getUTCMinutes())+":"+_fmttimepad(d.getUTCSeconds())+"Z",f=Q("d25alarm_interval").value.split("-");3!=f.length&&(f=[0,0,0]);var f=
"P"+f[0]+"DT"+f[1]+"H"+f[2]+"M",n=1==Q("d25alarm_doc").value,c=prepareAlarmOccurenceTemplate(c,c,d,f,n);void 0==b?wsstack.ExecMethodXml(amtstack.CompleteName("AMT_AlarmClockService"),"AddAlarm",c,function(a,b,c,d){200!=d?messagebox("Add alarm","Failed to add alarm. Status: "+d):0!=c.Body.ReturnValue?messagebox("Add alarm","Failed to add alarm, "+c.Body.ReturnValueStr):PullAlarms()}):(c=Clone(xxAlarms[b]),c.StartTime='<p:Datetime xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Datetime>",
c.Interval='<p:Interval xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+f+"</p:Interval>",c.DeleteOnCompletion=n,amtstack.Put("IPS_AlarmClockOccurrence",c,function(a,b,c,d){200!=d?messagebox("Edit alarm","Failed to change alarm. Status: "+d):PullAlarms()},null,null,{InstanceID:c.InstanceID}))}}
function showAlertDetails(a){if(!xxdialogMode){var b=xxAlarms[a],c=new Date(b.StartTime.Datetime),c="<div style=text-align:left>"+addHtmlValue("Name",b.ElementName)+addHtmlValue("Wake time",c.toLocaleString().replace(", "," at "));void 0!=b.Interval&&(c+=addHtmlValue("Internal",_fmtinterval(b.Interval.Interval)));c+=addHtmlValue("After wake",1==b.DeleteOnCompletion?"Delete Alarm":"Keep Alarm")+"</div>";messagebox("Alarm "+b.ElementName,c);setDialogMode(11,"Alarm "+b.ElementName,5,showAlertDetailsDelete,
c,a)}}function showAlertDetailsDelete(a,b){2==a&&amtstack.Delete("IPS_AlarmClockOccurrence",xxAlarms[b],function(a,b,f,n){PullAlarms()})}function script_runScriptDlg(){xxdialogMode||scriptstate||setDialogMode(11,"Run Script",3,script_runScriptDlgOk,"<br><input id=scriptopen type=file style=width:100% accept=.mescript>")}function script_runScriptDlgOk(a){if(1==a&&(a=Q("scriptopen"),1==a.files.length)){var b=new FileReader;b.onload=script_onScriptRead;b.readAsBinaryString(a.files[0])}}
function script_onScriptRead(a){var b;try{b=JSON.parse(a.target.result)}catch(f){}if(20==currentView){b.scriptText&&(Q("scriptarea").value=b.scriptText);b.mescript&&(Q("compiledarea").value=rstr2hex(atob(b.mescript)));b.blocks?(script_setBuildBlocks(b.blocks),scriptViewButton(1)):(script_setBuildBlocks(),scriptViewButton(0));b.scriptBlocks?script_BlockScript=b.scriptBlocks:script_BuildingBlocks||(script_BlockScript=[]);for(var c in script_BlockScript)if(b=script_BlockScript[c],a=script_BuildingBlocks[b.xname]){a=
Clone(a);a.id=b.id;a.xname=b.xname;for(var d in a.vars)b.vars[d]&&(a.vars[d].value=b.vars[d].value);script_BlockScript[c]=a}fupdatescript();delete scriptstate;resetScriptButton()}else c={_interactive:1,_certificates:1,_mode:"Firmware"},b&&b.mescript&&(scriptstate=script_setup(atob(b.mescript),c)),scriptstate?(scriptstate.wsstack=wsstack,scriptstate.amtstack=amtstack,scriptstate.onStep=script_updateScriptState,scriptstate.onConsole=script_console,scriptstate.start(100)):messagebox("Run Script","Invalid script file.")}
function script_updateScriptState(){scriptstate&&(QV(9,0<scriptstate.state),center(),0==scriptstate.state&&(scriptstate=void 0))}function script_console(a){0==a.indexOf("INFO: ")&&(a=a.substring(6));0==a.indexOf("SUCCESS: ")&&(a=a.substring(9));0==a.indexOf("ERROR: ")&&(a=a.substring(7));QH(10,", "+a)}function script_Stop(){scriptstate&&(1==scriptstate.dialog&&setDialogMode(0),scriptstate.stop(),scriptstate.state=0,script_updateScriptState())}
var script_BuildingBlocks,script_StartingBuildingBlocks,script_BlockScript=[],script_BlockScriptSelectedId=null,script_BuilderView=0,editscriptstate;
function scriptLoadStartingBlocks(){var a=new XMLHttpRequest;a.onload=function(){if(200<=a.status&&400>a.status){var b;try{b=JSON.parse(a.responseText)}catch(c){}b&&b.blocks&&(script_StartingBuildingBlocks=b.blocks,script_setBuildBlocks(script_StartingBuildingBlocks))}};a.onerror=function(){console.log("Failed to get script blocks")};a.open("GET","scriptblocks.txt",!0);a.send()}
function scriptViewButton(a){script_BuilderView=a;QV("scripteditor",0==a);QV("scriptbuilder",1==a);QV("viewEditorButton",script_BuildingBlocks&&1==a);QV("viewBuilderButton",script_BuildingBlocks&&0==a)}
function script_setBuildBlocks(a){script_BuildingBlocks=a;var b="";if(a)for(var c in a)95!=c.charCodeAt(0)&&(b+="<div id=sblock_"+c+' style=cursor:pointer;background-color:#ccc;width:auto;padding:5px;margin:2px ondblclick=script_faddblock("'+c+'") draggable=true ondragstart=script_fondragstart(event,this) ondragend=script_fondragend(event,this) title="'+a[c].desc+'"',b+=">"+a[c].name+"</div>");QH("blocks",b);script_fonfilterchanged();scriptViewButton(script_BuildingBlocks?1:0)}
function script_faddblock(a){var b=Clone(script_BuildingBlocks[a]);b.id=Math.random();b.xname=a;script_BlockScript.push(b);script_BlockScriptSelectedId=script_BlockScript.length-1;fupdatescript()}function script_feditblock(a){xxdialogMode||setDialogMode(11,"Edit "+script_BuildingBlocks[a].name,3,script_feditblockEx,"Edit this block? This operation will reset the block editor and load the block code into the code editor.",a)}
function script_feditblockEx(a,b){script_newScriptDlgOk();scriptViewButton(0);var c,d=script_BuildingBlocks[b];c=""+("##!BLOCK!##\r\n#id="+b+"\r\n#name="+d.name+"\r\n#desc="+d.desc+"\r\n##!BLOCK!##\r\n");for(var f in d.vars){var n=d.vars[f];c+="##!VAR!##\r\n#id="+f+"\r\n#name="+n.name+"\r\n#desc="+n.desc+"\r\n#type="+n.type+"\r\n";n.maxlength&&(c+="#maxlength="+n.maxlength+"\r\n");if(n.values)for(var p in n.values)c+="#values-"+p+"="+n.values[p]+"\r\n";c+="#value="+n.value+"\r\n##SWAP %%%"+f+"%%% "+
n.value+"\r\n"}c+="##!VAR!##\r\n##SWAP %%%~%%% 0\r\n\r\n##!BLOCK!##\r\n"+d.code+"\r\n##!BLOCK!##\r\n";Q("scriptarea").value=c}
function script_fConvertScriptToJsonBlock(a){var b={};a=a.split("##!BLOCK!##\n");var c=a[1].split("\n"),d;for(d in c){var f=c[d].split("=");2==f.length&&(b[f[0].substring(1)]=f[1])}b.vars={};scriptvariables=a[2].split("##!VAR!##\n");for(d in scriptvariables){var c=scriptvariables[d].split("\n"),n={},p={},r=0,l;for(l in c)f=c[l].split("="),2==f.length&&f[1]&&f[0]&&0<f[0].length&&("#values-"==f[0].substring(0,8)?(p[f[0].substring(8)]=f[1],r++):n[f[0].substring(1)]=f[1]);n.id&&(0<r&&(n.values=p),c=n.id,
delete n.id,b.vars[c]=n)}b.code=a[3];c=b.id;delete b.id;d={};d[c]=b;return JSON.stringify(d,null," ")}function script_fonfilterchanged(){var a=Q("blockfilter").value.toLowerCase(),b;for(b in script_BuildingBlocks)95!=b.charCodeAt(0)&&QV("sblock_"+b,0<=script_BuildingBlocks[b].name.toLowerCase().indexOf(a)||0<=script_BuildingBlocks[b].desc.toLowerCase().indexOf(a))}var script_fonclickDblClickDetectIndex=null,script_fonclickDblClickDetectTime=null;
function script_fonclick(a,b){if(!xxdialogMode){script_BlockScriptSelectedId=null;b&&(b=fgetParentWithId(b),b.id.startsWith("xblock_")&&(script_BlockScriptSelectedId=b.id.substring(7)));fupdatescript();haltEvent(a);if(script_fonclickDblClickDetectIndex==script_BlockScriptSelectedId&&250>(new Date).getTime()-script_fonclickDblClickDetectTime)return script_foneditclick(script_BlockScriptSelectedId);script_fonclickDblClickDetectIndex=script_BlockScriptSelectedId;script_fonclickDblClickDetectTime=(new Date).getTime()}}
function script_fondragstart(a,b){xxdialogMode||(b=fgetParentWithId(b),b.style.opacity="0.4",a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("scriptbuilder/block",b.id))}function script_fondragend(a,b){xxdialogMode||(b=fgetParentWithId(b),b.style.opacity="1.0")}function script_fondragenter(a,b){xxdialogMode||(fgetParentWithId(b).style["border-top"]="solid 2px black")}
function script_fondragleave(a,b){if(!xxdialogMode){a=a.originalEvent||a;var c=document.elementFromPoint(a.pageX,a.pageY);b.contains(c)||(fgetParentWithId(b).style["border-top"]="none")}}
function script_fondrop(a,b){if(!xxdialogMode){b=fgetParentWithId(b);var c,d=a.dataTransfer.getData("scriptbuilder/block"),f=parseInt(b.id.substring(7));""==d?documentFileSelectHandler(a):(d.startsWith("sblock_")?(c=Clone(script_BuildingBlocks[d.substring(7)]),c.id=Math.random(),c.xname=d.substring(7)):(d=parseInt(d.substring(7)),c=script_BlockScript[d],script_BlockScript.splice(d,1),f>d&&f--),"scriptblocks"==b.id?(c&&script_BlockScript.push(c),script_BlockScriptSelectedId=script_BlockScript.length-
1):(script_BlockScript.splice(f,0,c),script_BlockScriptSelectedId=f),fupdatescript(),haltEvent(a))}}
function script_foneditclick(a){if(!xxdialogMode){var b=script_BlockScript[a];script_BlockScriptSelectedId=a;fupdatescript();if(null!=b){var c=b.vars?7:5,d=b.desc+"<br><br>";if(b.vars)for(var f in b.vars){var n=b.vars[f].value,p="";b.vars[f].maxlength&&(p+=" maxlength="+b.vars[f].maxlength);2==b.vars[f].type&&(p+=" onkeypress='return numbersOnly(event)'");if(1==b.vars[f].type||2==b.vars[f].type)n="<input title='"+b.vars[f].desc+"' id=scriptXvalue_"+f+" value='"+b.vars[f].value+"' "+p+" style=width:100%></input>";
if(3==b.vars[f].type){var n="<select title='"+b.vars[f].desc+"' id=scriptXvalue_"+f+" style=width:100%;padding:0;margin:0>",r;for(r in b.vars[f].values)n+="<option value="+r+(r==b.vars[f].value?" selected":"")+">"+b.vars[f].values[r]+"</option>";n+="</select>"}4==b.vars[f].type&&(n="<input type=password autocomplete=off title='"+b.vars[f].desc+"' id=scriptXvalue_"+f+" value='"+b.vars[f].value+"' "+p+" style=width:100%></input>");5==b.vars[f].type&&(n="");6==b.vars[f].type&&(n="<input type=file title='"+
b.vars[f].desc+"' id=scriptXvalue_"+f+" "+p+" style=width:100%></input>");d+='<table style=width:100% title="'+b.vars[f].desc+'"><td style=width:120px>'+b.vars[f].name+"<td><b>"+n+"</b></table>";if(5==b.vars[f].type){var d=d+("<ul id=scriptXvalue_"+f+' style="list-style-type:none;height:100px;overflow:auto;width:100%;border:1px solid #000;background-color:white;overflow-x:hidden;margin:0;padding:0">'),l;for(l in b.vars[f].values)n="",0<=b.vars[f].value.indexOf(l)&&(n=" checked"),d+="<li><label><input type=checkbox id=scriptXvaluex_"+
f+"-"+l+""+n+">"+b.vars[f].values[l]+"</label></li>";d+="</ul>"}}}setDialogMode(11,b.name,c,script_foneditclickEx,d,a)}}
function script_foneditclickEx(a,b){if(!xxdialogMode){if(2==a)script_BlockScript.splice(b,1),script_BlockScriptSelectedId==b&&(script_BlockScriptSelectedId=null);else{var c=script_BlockScript[b];if(c.vars)for(var d in c.vars)if(5==c.vars[d].type){c.vars[d].value=[];for(var f in c.vars[d].values)Q("scriptXvaluex_"+d+"-"+f).checked&&c.vars[d].value.push(f)}else if(6==c.vars[d].type){var n=Q("scriptXvalue_"+d);if(1==n.files.length){var p=new FileReader;p.onload=function(a){c.vars[d].value=btoa(a.target.result);
fupdatescript()};p.readAsBinaryString(n.files[0])}}else c.vars[d].value=Q("scriptXvalue_"+d).value}fupdatescript()}}function fgetParentWithId(a){for(;!a.id;)a=a.parentElement;return a}
function fupdatescript(){var a="",b;for(b in script_BlockScript){a+="<div id=xblock_"+b+" style=cursor:pointer;min-height:24px;background-color:#"+(script_BlockScriptSelectedId==b?"aaa":"ccc")+';width:auto;padding:5px;margin:2px draggable=true onclick=script_fonclick(event,this) ondragenter=script_fondragenter(event,this) ondragleave=script_fondragleave(event,this) ondragstart=script_fondragstart(event,this) ondragend=script_fondragend(event,this) ondrop=script_fondrop(event,this) title="'+script_BlockScript[b].desc+
'"';a+="><input style=float:right type=button value=Edit... onclick=script_foneditclick("+b+")><div style=font-size:16px><b>"+script_BlockScript[b].name+"</b>";if(script_BlockScript[b].vars){var c=0,a=a+"<table class='scriptBlockVar us' cellpadding=0 cellspacing=0 style=width:100%;border-radius:5px;margin-top:8px>",d;for(d in script_BlockScript[b].vars){var f=script_BlockScript[b].vars[d].value;4==script_BlockScript[b].vars[d].type&&0<script_BlockScript[b].vars[d].value.length&&(f="*****");3==script_BlockScript[b].vars[d].type&&
(f=script_BlockScript[b].vars[d].values[script_BlockScript[b].vars[d].value]);6==script_BlockScript[b].vars[d].type&&(f=script_BlockScript[b].vars[d].value?"Binary file, "+script_BlockScript[b].vars[d].value.length+" bytes":"Not set");a+="<tr title='"+script_BlockScript[b].vars[d].desc+"'><td width=200px style='"+(0<c?"border-top:1px solid #a810a8":"")+"'><p>"+script_BlockScript[b].vars[d].name+"<td style='"+(0<c?"border-top:1px solid #a810a8":"")+"'>"+f;c++}a+="<tr><td style=height:3px></table>"}a+=
"</div></div>"}""==a&&(a='<div style="padding:15px;color:gray">Start your script by drag & dropping blocks from the left side into this scripting box.<div>');QH("scriptblocks",a+"<div style=height:80px></div>");for(b in script_BlockScript)QS("xblock_"+b).borderLeft=script_CurrentHighlightBlock==b?"3px solid black":"";script_blocksToScript()}
function script_blocksToScript(){var a="";if(script_BuildingBlocks){script_BuildingBlocks._start&&(a+="##### Starting Block #####\r\n"+script_BuildingBlocks._start.code+"\r\n\r\n");for(var b in script_BlockScript){var c=script_BlockScript[b].code,c=c.split("%%%~%%%").join(b),d;for(d in script_BlockScript[b].vars)c=c.split("%%%"+d+"%%%").join(script_BlockScript[b].vars[d].value);a+="##### Block: "+script_BlockScript[b].name+" #####\r\nHighlightBlock __t "+b+"\r\n"+c+"\r\n\r\n"}script_BuildingBlocks._end&&
(a+="##### Ending Block #####\r\n"+script_BuildingBlocks._end.code+"\r\nHighlightBlock\r\n")}Q("scriptarea").value=a}var script_CurrentHighlightBlock;function script_HighlightBlock(a,b){if(a==editscriptstate){script_CurrentHighlightBlock=b;for(var c in script_BlockScript)QS("xblock_"+c).borderLeft=script_CurrentHighlightBlock==c?"3px solid black":""}}function script_newScriptDlg(){xxdialogMode||setDialogMode(11,"New Script",3,script_newScriptDlgOk,"<br>Reset & clear the script editor?")}
function script_newScriptDlgOk(){script_setBuildBlocks(script_StartingBuildingBlocks);script_BlockScript=[];script_BlockScriptSelectedId=null;delete editscriptstate;scriptViewButton(script_BuildingBlocks?1:0);QH("variables","");Q("scriptarea").value="";resetScriptButton()}
function resetScriptButton(){breakScriptButton();Q("compiledarea").value=rstr2hex(script_compile(Q("scriptarea").value,function(a){messagebox("Script Compile Error",a)}));delete editscriptstate;Q("console").value="";QH("variables","");QH("EditScriptStatus","Stopped");1==script_BuilderView&&fupdatescript();0!=Q("compiledarea").value.length&&(editscriptstate=script_setup(hex2rstr(Q("compiledarea").value),{_interactive:1,_certificates:1,_mode:"Firmware"}),editscriptstate.wsstack=wsstack,editscriptstate.amtstack=
amtstack,editscriptstate.onStep=editscript_updateScriptState,editscriptstate.onConsole=editscript_console,editscript_updateScriptState(editscriptstate))}function runScriptButton(){null==editscriptstate&&resetScriptButton();null!=editscriptstate&&editscriptstate.start(100)}function breakScriptButton(){null!=editscriptstate&&editscriptstate.stop()}function stepScriptButton(){null==editscriptstate&&resetScriptButton();null!=editscriptstate&&(breakScriptButton(),editscriptstate.step())}
function editscript_console(a){Q("console").value+=a+"\n"}var script_states=["Stopped","Running","Paused"];
function editscript_updateScriptState(a){var b="";if(a&&null!=a){var c=[],d;for(d in a.variables)d.startsWith("__")||c.push(d);c.sort();for(d in c)b="object"==typeof a.variables[c[d]]?b+("<b>"+c[d]+"</b> = "+ObjectToStringEx(a.variables[c[d]],2)+"<br>"):b+("<b>"+c[d]+"</b> = "+EscapeHtml(script_toString(a.variables[c[d]]))+"<br>")}QH("variables",b);b="Stopped, No Script";a&&null!=a&&(b=script_states[a.state],0<a.state&&(b+=", "+a.ip+" : "+script_decompile(a.script,a.ip)));50<b.length&&(b=b.substring(0,
50)+"...");QH("EditScriptStatus",b)}function script_toString(a){return"object"==typeof a?JSON.stringify(a):a}
function script_saveScript(a){xxdialogMode||scriptstate||(a&&1==a.shiftKey?(setDialogMode(11,"Script Block",1,null,"<br><textarea id=scriptSaveScriptJsonBlock style=width:100%;height:200px;resize:vertical />"),QH("scriptSaveScriptJsonBlock",script_fConvertScriptToJsonBlock(Q("scriptarea").value))):setDialogMode(11,"Save Script",3,script_saveScriptOk,"<br><input id=scriptsavename style=width:100% value=test.mescript >"))}
function script_saveScriptOk(){if(!xxdialogMode){var a=JSON.stringify({scriptText:Q("scriptarea").value,mescript:btoa(script_compile(Q("scriptarea").value)),blocks:script_StartingBuildingBlocks,scriptBlocks:script_BlockScript},null," ");saveAs(data2blob(a),Q("scriptsavename").value)}}var xxdialogMode,xxdialogFunc,xxdialogButtons,xxdialogTag;
function setDialogMode(a,b,c,d,f,n){xxdialogMode=a;xxdialogFunc=d;xxdialogButtons=c;xxdialogTag=n;QE("c37",!0);QV("c37",c&1);QV("c36",c&2);QV(34,c&2);QV("c38",c&4);b&&QH(35,b);for(b=1;26>b;b++)QV("dialog"+b,b==a);QV("dialog",a);f&&(11==a?QH(39,f):QH(36,f))}function dialogclose(a){var b=xxdialogFunc,c=xxdialogButtons,d=xxdialogTag;setDialogMode();(c&8||a)&&b&&b(a,d)}
function center(){QS("dialog").left=(getDocWidth()-400)/2+"px"}function messagebox(a,b){QH(36,b);setDialogMode(1,a,1)}function statusbox(a,b){QH(36,b);setDialogMode(1,a)}
function SaveJsonFile(a,b,c,d){var f="",n={},p=new Date;amtsysstate&&(f="-"+amtsysstate.AMT_GeneralSettings.response.HostName,n={webappversion:version,description:c,hostname:amtsysstate.AMT_GeneralSettings.response.HostName,localtime:Date(),utctime:(new Date).toUTCString(),isotime:(new Date).toISOString()},HardwareInventory&&(n.systemid=guidToStr(HardwareInventory.CIM_ComputerSystemPackage.response.PlatformGUID.toLowerCase())));f+="-"+p.getFullYear()+"-"+("0"+(p.getMonth()+1)).slice(-2)+"-"+("0"+
p.getDate()).slice(-2)+"-"+("0"+p.getHours()).slice(-2)+"-"+("0"+p.getMinutes()).slice(-2);n[b]=d;saveAs(data2blob(JSON.stringify(n,null," ").replace(/\n/g,"\r\n")),a+f+".json")}var httpErrorTable={200:"OK",401:"Authentication Error",408:"Timeout Error",601:"WSMAN Parsing Error",602:"Unable to parse HTTP response header",603:"Unexpected HTTP enum response",604:"Unexpected HTTP pull response"};
function errcheck(a,b){if(null==wsstack||amtstack!=b)return!0;200!=a&&9!=a&&(setDialogMode(),wsstack.comm.FailAllError=999,amtstack.CancelAllQueries(999),QH(5,httpErrorTable[a]?httpErrorTable[a]:"Error #"+a),401==a&&QH(5,'Authentication Error<br /><br /><input type=button value="Set new credentials" onclick=meshcentral2credCallback(true)></input>'),go(100),QS(3).width=0);return 200!=a}
function goiFrame(a,b,c){if(!xxdialogMode){go(b);if(1==a.shiftKey||0==Q(13).src.endsWith(c))Q(13).src=c;QV(14,!1);QV(12,!0)}}function go(a,b){if(!xxdialogMode||1==b){QV(12,!1);QV(14,!0);QV(4,100==a);QV(6,100>a);for(var c=0;80>c;c++){QV("p"+c,c==a);var d=QS("go"+c);d&&(d["background-color"]=c==a?"#abcae1":"");d&&(d["background-color"]=c==a?"gray":"")}currentView=a}}
function portsFromHost(a,b){var c=decodeURIComponent(a).split(":"),d=0==b?16992:16993,f=0==b?16994:16995;1<c.length&&(d=parseInt(c[1]));2<c.length&&(f=parseInt(c[2]));return{host:c[0],http:d,redir:f}}function addLink(a,b){return"<a style=cursor:pointer;color:blue onclick='"+b+"'>&diams; "+a+"</a>"}function addLinkConditional(a,b,c){return c?addLink(a,b):a}function haltEvent(a){a.preventDefault&&a.preventDefault();a.stopPropagation&&a.stopPropagation();return!1}
function addOption(a,b,c){var d=document.createElement("option");d.text=b;d.value=c;Q(a).add(d)}function addDisabledOption(a,b,c){var d=document.createElement("option");d.text=b;d.value=c;d.disabled=1;Q(a).add(d)}function passwordcheck(a){if(8>a.length)return!1;var b=0,c=0,d=0,f=0,n;for(n in a){var p=a.charCodeAt(n);64<p&&91>p?b=1:96<p&&123>p?c=1:47<p&&58>p?d=1:f=1}return 4==b+c+d+f}
function methodcheck(a){return a&&null!=a&&a.Body&&0!=a.Body.ReturnValue?(messagebox("Call Error",a.Header.Method+": "+(a.Body.ReturnValueStr+"").replace("_"," ")),!0):!1}function TableStart(){return"<table class='log1 us' cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td width=200px><p><td>"}function TableStart2(){return"<table class='log1 us' cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td><p><td>"}
2018-11-15 02:44:28 +03:00
function TableEntry(a,b){return"<tr><td class=r1><p>"+a+"<td class=r1>"+b}function FullTable(a,b){var c=TableStart();for(i in a)i&&a[i]&&(c+=TableEntry(i,a[i]));return c+TableEnd(b)}function TableEnd(a){return"<tr><td colspan=2><p>"+(a?a:"")+"</table>"}function AddButton(a,b){return"<input type=button value='"+a+"' onclick='"+b+"' style=margin:4px>"}function AddButton2(a,b,c){return"<input type=button value='"+a+"' onclick='"+b+"' "+c+">"}
2018-08-24 02:55:06 +03:00
function AddRefreshButton(a){return"<input type=button name=refreshbtn value=Refresh onclick='refreshButtons(false);"+a+"' style=margin:4px "+(0==refreshButtonsState?"disabled":"")+">"}function MoreStart(){return'<a style=cursor:pointer;color:blue id=morexxx1 onclick=QV("morexxx1",false);QV("morexxx2",true)>&#x25BC; More</a><div id=morexxx2 style=display:none><br><hr>'}
function MoreEnd(){return'<a style=cursor:pointer;color:blue onclick=QV("morexxx2",false);QV("morexxx1",true)>&#x25B2; Less</a></div>'}function getSelectedOptions(a){for(var b=[],c,d=0,f=a.options.length;d<f;d++)c=a.options[d],c.selected&&b.push(c.value);return b}function getInstance(a,b){for(var c in a)if(a[c].InstanceID==b)return a[c];return null}function getItem(a,b,c){for(var d in a)if(a[d][b]==c)return a[d];return null}
function guidToStr(a){return a.substring(6,8)+a.substring(4,6)+a.substring(2,4)+a.substring(0,2)+"-"+a.substring(10,12)+a.substring(8,10)+"-"+a.substring(14,16)+a.substring(12,14)+"-"+a.substring(16,20)+"-"+a.substring(20)}function getUrlVars(){for(var a,b=[],c=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),d=0;d<c.length;d++)a=c[d].indexOf("="),0<a&&(b[c[d].substring(0,a)]=c[d].substring(a+1,c[d].length));return b}
function getDocWidth(){return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth&&0!=document.documentElement.clientWidth?document.documentElement.clientWidth:document.getElementsByTagName("body")[0].clientWidth}
function getDocHeight(){return window.innerHeight?window.innerHeight:document.documentElement&&document.documentElement.clientHeight&&0!=document.documentElement.clientHeight?document.documentElement.clientHeight:document.getElementsByTagName("body")[0].clientHeight}function addHtmlValue(a,b){return'<div style=height:20px><div style=float:right;width:220px;overflow:hidden><b title="'+b+'">'+b+"</b></div><div>"+a+"</div></div>"}
function addHtmlValueNoTitle(a,b){return"<div style=height:20px><div style=float:right;width:220px;overflow:hidden>"+b+"</b></div><div>"+a+"</div></div>"}function numbersOnly(a,b){return 0==event.charCode||event.charCode==b||48<=event.charCode&&57>=event.charCode}startup();
</script>