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)}functionReadShortX(a,b){return(a.charCodeAt(b+1)<<8)+a.charCodeAt(b)}functionReadInt(a,b){return16777216*a.charCodeAt(b)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}functionReadSInt(a,b){return(a.charCodeAt(b)<<24)+(a.charCodeAt(b+1)<<16)+(a.charCodeAt(b+2)<<8)+a.charCodeAt(b+3)}
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+=" ";returnb}functiongap2(a){for(varb="",c=0;c<4*a;c++)b+="";returnb}functionObjectToString(a){returnObjectToStringEx(a,0)}
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);returnnewBlob([newUint8Array(b)])}functionrandom(a){returnMath.floor(Math.random()*a)}functiontrademarks(a){returna.replace(/\(R\)/g,"®").replace(/\(TM\)/g,"™")}
var CreateWsmanComm=function(a,b,c,d,g){function n(){l.socketState=2;l.socketParseState=0;l.socketAccumulator="";l.socketHeader=null;l.socketData="";for(i in l.pendingAjaxCall)l.sendRequest(l.pendingAjaxCall[i][0],l.pendingAjaxCall[i][3],l.pendingAjaxCall[i][4])}function r(a){if("object"==typeof a.data)if(1==e)v.push(a.data);else if(w.readAsBinaryString)e=!0,w.readAsBinaryString(new Blob([a.data]));else if(w.readAsArrayBuffer)e=!0,w.readAsArrayBuffer(a.data);else{var b="";a=new Uint8Array(a.data);
for(var c=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);u(b)}elseu(a.data)}functionu(a){if("object"===typeofa){varb="";a=newUint8Array(a);for(varc=a.byteLength,m=0;m<c;m++)b+=String.fromCharCode(a[m]);a=b}elseif("string"!==typeofa)return;for(l.socketAccumulator+=a;;){if(0==l.socketParseState){a=l.socketAccumulator.indexOf("\r\n\r\n");if(0>a)break;l.socketHeader=l.socketAccumulator.substring(0,a).split("\r\n");if(null==l.amtVersion)for(m in l.socketHeader)0==l.socketHeader[m].indexOf("Server: Intel(R) Active Management Technology ")&&
(l.amtVersion=l.socketHeader[m].substring(46));l.socketAccumulator=l.socketAccumulator.substring(a+4);l.socketParseState=1;l.socketData="";l.socketXHeader={Directive:l.socketHeader[0].split(" ")};for(m in l.socketHeader)0!=m&&(a=l.socketHeader[m].indexOf(":"),l.socketXHeader[l.socketHeader[m].substring(0,a).toLowerCase()]=l.socketHeader[m].substring(a+2))}if(1==l.socketParseState){b=-1;if(void 0==l.socketXHeader.connection||"close"!=l.socketXHeader.connection.toLowerCase()||void 0!=l.socketXHeader["transfer-encoding"]&&
new Uint8Array(a.length),d=0;d<a.length;++d)c[d]=a.charCodeAt(d);b.socket.send(c.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(varc="",d=0;d<a;d++)c+=b.xxRandomNonceX.charAt(Math.floor(Math.random()*
l.ExecPut=function(a,c,b,d,k,h){h="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+l.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+l.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>"+m(h)+"</Header><Body>";if(a&&null!=c){var C=l.GetNameFromUrl(a);a="<r:"+C+'xmlns:r="'+a+'">';for(var p in c)if(c.hasOwnProperty(p)&&
"</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>"+m(h)+"</Header><Body><g:"+C+'xmlns:g="'+a+'">';for(var p in c)a+="<g:"+p+">"+c[p]+"</g:"+p+">";l.PerformAjax(a+"</g:"+C+"></Body></Envelope>",b,d,k)};l.ExecDelete=function(a,c,b,d,k){a="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+l.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+l.NextMessageId++ +
c,b,m)};l.ExecMethod=function(a,c,b,m,k,h,d){var p="",F;for(F in b)if(null!=b[F])if(Array.isArray(b[F]))for(var y in b[F])p+="<r:"+F+">"+b[F][y]+"</r:"+F+">";else p+="<r:"+F+">"+b[F]+"</r:"+F+">";l.ExecMethodXml(a,c,p,m,k,h,d)};l.ExecMethodXml=function(a,c,b,d,k,h,C){l.PerformAjax(a+"/"+c+"</a:Action><a:To>"+l.Address+"</a:To><w:ResourceURI>"+a+"</w:ResourceURI><a:MessageID>"+l.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>"+
function AmtStackCreateService(a){function b(){var a=e.GetPendingActions();v<a&&(v=a);null!=e.onProcessChanged&&E!=a&&(E=a,e.onProcessChanged(a,v));0==a&&(v=0)}functionc(a,c,b,m,h,k,x){200!=h?(b(e,a,null,h,k),g(1)):null!=c&&"EnumerateResponse"==c.Header.Method&&c.Body.EnumerationContext?e.wsman.ExecPull(m,c.Body.EnumerationContext,function(c,m,h,e){d(a,h,b,m,[],e,k,x)}):(b(e,a,null,603,k),g(1))}functiond(a,c,m,h,k,p,x,l){if(200!=p)m(e,a,null,p,x),g(1);elseif(null==c||"PullResponse"!=c.Header.Method)m(e,
a,null,604,x),g(1);else{for(var w in c.Body.Items)if(c.Body.Items[w]instanceof Array)for(var v in c.Body.Items[w])"function"!=typeof c.Body.Items[w][v]&&k.push(c.Body.Items[w][v]);else"function"!=typeof c.Body.Items[w]&&k.push(c.Body.Items[w]);c.Body.EnumerationContext?e.wsman.ExecPull(h,c.Body.EnumerationContext,function(c,b,h,e){d(a,h,m,b,k,e,x,1)}):(g(1),m(e,a,k,p,x),b())}}function g(a){e.ActiveEnumsCount-=a;e.ActiveEnumsCount>=e.MaxActiveEnumsCount||0==e.PendingEnums.length?b():(a=e.PendingEnums.shift(),
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?"Allreceivedpacketfilterwasmatchedon"+c+"interface.":4294967292==a?"Alloutboundpacketfilterwasmatchedon"+
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.";
[a,c,[]])};var k="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(";"),
h="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(";"),
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:":"<",g=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()+g+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:SelectorName="'+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);returnb}
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++){varc=parseInt(a[b]);if(c!=a[b])returnnull;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]);returnc}
(new MutationObserver(function(){var c=a.slice();a.length=0;c.forEach(function(a){a()})})).observe(m,{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&&m.setAttribute("a",b=!b))}}d.nextTick=d.setImmediate}})();d.isArray=Array.isArray||function(a){return"[objectArray]"===Object.prototype.toString.call(a)};d.isArrayBuffer=function(a){return"undefined"!==typeofArrayBuffer&&ainstanceofArrayBuffer};d.isArrayBufferView=function(a){returna&&
(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);returnb};d.xorBytes=function(a,c,b){for(varm="",d="",h="",k=0,e=0;0<b;--b,++k)d=a.charCodeAt(k)^c.charCodeAt(k),10<=e&&(m+=h,h="",e=0),h+=String.fromCharCode(d),++e;returnm+h};d.hexToBytes=function(a){varc="",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));returnc};d.bytesToHex=
var m=c;m||(m=new Uint8Array(a.length));for(var h=b=b||0,k=0;k<a.length;++k)m[h++]=a.charCodeAt(k);returnc?h-b:m};d.text.utf8.decode=function(a){returnd.decodeUtf8(String.fromCharCode.apply(null,a))};d.text.utf16.encode=function(a,c,b){varm=c;m||(m=newUint8Array(2*a.length));for(vard=newUint16Array(m.buffer),h=b=b||0,k=b,e=0;e<a.length;++e)d[k++]=a.charCodeAt(e),h+=2;returnc?h-b:m};d.text.utf16.decode=function(a){returnString.fromCharCode.apply(null,newUint16Array(a.buffer))};d.deflate=function(a,
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 v=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;},E=function(a,c){if(!a)throw Error("WebStorage not available.");
var b=a.getItem(c);if(a.init)if(null===b.rval){if(b.error){var m=Error(b.error.message);m.id=b.error.id;m.name=b.error.name;throw m;}b=null}else b=b.rval;null!==b&&(b=JSON.parse(d.decode64(b)));return b},k=function(a,c,b,m){var d=E(a,c);null===d&&(d={});d[b]=m;v(a,c,d)},h=function(a,c,b){a=E(a,c);null!==a&&(a=b in a?a[b]:null);return a},C=function(a,c,b){var m=E(a,c);if(null!==m&&b in m){delete m[b];b=!0;for(var d in m){b=!1;break}b&&(m=null);v(a,c,m)}},p=function(a,c){v(a,c,null)},g=function(a,c,
b){var m=null;"undefined"===typeof b&&(b=["web","flash"]);var d,h=!1,k=null,e;for(e in b){d=b[e];try{if("flash"===d||"both"===d){if(null===c[0])throw Error("Flash local storage not available.");m=a.apply(this,c);h="flash"===d}if("web"===d||"both"===d)c[0]=localStorage,m=a.apply(this,c),h=!0}catch(p){k=p}if(h)break}if(!h)throw k;return m};d.setItem=function(a,c,b,m,d){g(k,arguments,d)};d.getItem=function(a,c,b,m){return g(h,arguments,m)};d.removeItem=function(a,c,b,m){g(C,arguments,m)};d.clearItems=
(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._outBlock=Array(this._ints)};v.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.");};v.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._partialBytes=0}d(this._inBlock)};v.ctr.prototype.decrypt=v.ctr.prototype.encrypt;v.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};v.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 h;
h="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,
"string"===typeof a&&(a=c.util.createBuffer(a));if(2>a.length()){var k=Error("Too few bytes to parse DER.");k.bytes=a.length();throw k;}var h=a.getByte(),k=h&192,g=h&31,p=d(a);if(a.length()<p){if(e)throwk=Error("ToofewbytestoreadASN.1value."),k.detail=a.length()+"<"+p,k;p=a.length()}varF,y=32===(h&32);F=y;if(!F&&k===b.Class.UNIVERSAL&&g===b.Type.BITSTRING&&1<p){varz=a.read;if(0===a.getByte()&&(h=a.getByte(),h&=192,h===b.Class.UNIVERSAL||h===b.Class.CONTEXT_SPECIFIC))try{if(F=d(a)===p-(a.read-
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)throwError("Integertoolarge;maxis32-bits.");returna.getSignedInt(b)};b.validate=function(a,d,e,h){varg=!1;if(a.tagClass!==d.tagClass&&"undefined"!==typeofd.tagClass||a.type!==d.type&&"undefined"!==typeofd.type)h&&(a.tagClass!==d.tagClass&&h.push("["+d.name+']Expectedtagclass"'+d.tagClass+
'", got "'+a.tagClass+'"'),a.type!==d.type&&h.push("["+d.name+'] Expected type "'+d.type+'", got "'+a.type+'"'));else if(a.constructed===d.constructed||"undefined"===typeof d.constructed){g=!0;if(d.value&&c.util.isArray(d.value))for(var p=0,w=0;g&&w<d.value.length;++w)g=d.value[w].optional||!1,a.value[p]&&((g=b.validate(a.value[p],d.value[w],e,h))?++p:d.value[w].optional&&(g=!0)),!g&&h&&h.push("["+d.name+'] Tag class "'+d.tagClass+'", type "'+d.type+'" expected value length "'+d.value.length+'", got "'+
"DEK-Info"!==z.name)g.headers.push(z);else{if(0===z.values.length)throw Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');g.dekInfo={algorithm:n[0],parameters:n[1]||null}}else g.contentDomain=n[0]||"";else{if("Proc-Type"!==z.name)throw Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==z.values.length)throw Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');g.procType={version:n[0],
type:n[1]}}}++y}if("ENCRYPTED"===g.procType&&!g.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 g=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,r=function(c,b){b.exports=function(b){var e=n.map(function(a){return c(a)}).concat(a);
var J=J&-15,I=I&-15,Y=b[J>>>28]|d[J>>>24&15]|h[J>>>20&15]|e[J>>>16&15]|k[J>>>12&15]|l[J>>>8&15]|g[J>>>4&15],Z=p[I>>>28]|q[I>>>24&15]|v[I>>>20&15]|w[I>>>16&15]|K[I>>>12&15]|y[I>>>8&15]|n[I>>>4&15];u=(Z>>>16^Y)&65535;F[r++]=Y^u;F[r++]=Z^u<<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",
y||(y=n);a=Math.ceil(a.n.bitLength()/8);g=a-2*n.digestLength-2;if(d.length>g)throw y=Error("RSAES-OAEP input message length is too long."),y.length=d.length,y.maxLength=g,y;w||(w="");n.update(w,"raw");w=n.digest();k="";g-=d.length;for(h=0;h<g;h++)k+="\x00";d=w.getBytes()+k+"\u0001"+d;if(!p)p=c.random.getBytes(n.digestLength);elseif(p.length!==n.digestLength)throwy=Error("InvalidRSAES-OAEPseed.Theseedlengthmustmatchthedigestlength."),y.seedLength=p.length,y.digestLength=n.digestLength,
2)throw Error("RSAES-OAEP key is too short for the hash function.");h||(h="");w.update(h,"raw");h=w.digest().getBytes();a=d.charAt(0);k=d.substring(1,w.digestLength+1);d=d.substring(1+w.digestLength);var n=b(d,w.digestLength,p);k=c.util.xorBytes(k,n,k.length);p=b(k,g-w.digestLength-1,p);d=c.util.xorBytes(d,p,d.length);g=d.substring(0,w.digestLength);p="\x00"!==a;for(a=0;a<w.digestLength;++a)p|=h.charAt(a)!==g.charAt(a);h=1;for(w=a=w.digestLength;w<d.length;w++)g=d.charCodeAt(w),k=g&1^1,p|=g&(h?65534:
Error("Message is too long for PKCS#1 v1.5 padding."),e.length=a.length,e.max=d-11,e;e.putByte(0);e.putByte(h);d=d-3-a.length;if(0===h||1===h){h=0===h?0:255;for(var k=0;k<d;++k)e.putByte(h)}elsefor(;0<d;){for(varg=0,l=c.random.getBytes(d),k=0;k<d;++k)h=l.charCodeAt(k),0===h?++g:e.putByte(h);d=g}e.putByte(0);e.putBytes(a);returne}functiond(a,b,e,h){b=Math.ceil(b.n.bitLength()/8);a=c.util.createBuffer(a);vark=a.getByte(),g=a.getByte();if(0!==k||e&&0!==g&&1!==g||!e&&2!=g||e&&0===g&&"undefined"===
typeof h)throw Error("Encryption block is invalid.");e=0;if(0===g)for(e=b-3-h,h=0;h<e;++h){if(0!==a.getByte())throwError("Encryptionblockisinvalid.");}elseif(1===g)for(e=0;1<a.length();){if(255!==a.getByte()){--a.read;break}++e}elseif(2===g)for(e=0;1<a.length();){if(0===a.getByte()){--a.read;break}++e}if(0!==a.getByte()||e!==b-3-a.length())throwError("Encryptionblockisinvalid.");returna.getBytes()}functione(a,b,d){functione(){h(a.pBits,function(c,b){if(c)returnd(c);a.p=b;if(null!==a.q)returng(c,
type:h.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:h.Class.UNIVERSAL,type:h.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:h.Class.UNIVERSAL,type:h.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:h.Class.UNIVERSAL,type:h.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},D=function(a){var c;if(a.algorithm in C.oids)c=C.oids[a.algorithm];
[h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(0).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(C.oids.rsaEncryption).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,"")]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(a).getBytes())])};C.privateKeyFromAsn1=function(a){var b={},d=[];h.validate(a,r,b,d)&&(a=h.fromDer(c.util.createBuffer(b.privateKey)));b={};d=[];if(!h.validate(a,y,b,d))throw b=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey."),
h.Type.INTEGER,!1,g(a.q)),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,g(a.dP)),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,g(a.dQ)),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,g(a.qInv))])};C.publicKeyFromAsn1=function(a){var b={},d=[];if(h.validate(a,A,b,d)){d=h.derToOid(b.publicKeyOid);if(d!==C.oids.rsaEncryption)throw b=Error("Cannot read public key. Unknown OID."),b.oid=d,b;a=b.rsaPublicKey}d=[];if(!h.validate(a,z,b,d))throw b=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey."),
var u=n*Math.ceil(q/n);d=new c.util.ByteBuffer;for(l=0;l<u;l++)d.putByte(b.at(l%q));u=n*Math.ceil(a/n);b=newc.util.ByteBuffer;for(l=0;l<u;l++)b.putByte(C.at(l%a));C=d;C.putBuffer(b);b=Math.ceil(e/w);for(d=1;d<=b;d++){u=newc.util.ByteBuffer;u.putBytes(r.bytes());u.putBytes(C.bytes());for(l=0;l<h;l++)k.start(),k.update(u.getBytes()),u=k.digest();varE=newc.util.ByteBuffer;for(l=0;l<n;l++)E.putByte(u.at(l%w));varS=Math.ceil(q/n)+Math.ceil(a/n),L=newc.util.ByteBuffer;for(g=0;g<S;g++){varR=newc.util.ByteBuffer(C.getBytes(n)),
case "aes256-CBC":n=32;l=c.aes.createDecryptionCipher;break;case "des-EDE3-CBC":n=24;l=c.des.createDecryptionCipher;break;case "desCBC":n=8,l=c.des.createDecryptionCipher}a=c.pkcs5.pbkdf2(d,b,w,n);k=k.encIv;l=l(a);l.start(k);return l};g.pbe.getCipherForPKCS12PBE=function(a,b,d){var h={},k=[];if(!e.validate(b,C,h,k))throw d=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo."),d.errors=k,d;var k=c.util.createBuffer(h.salt),h=c.util.createBuffer(h.iterations),
(a={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var b=a.md,d=a.mgf,g=b.digestLength,n=a.salt||null;"string"===typeof n&&(n=c.util.createBuffer(n));var k;if("saltLength"in a)k=a.saltLength;else if(null!==n)k=n.length();else throw Error("Salt length not specified or specific salt not given.");if(null!==n&&n.length()!==k)throw Error("Given salt length does not match length of given salt.");var h=a.prng||c.random;return{encode:function(a,l){var r,y=l-1,z=Math.ceil(y/8),u=a.digest().getBytes();
return D+u+String.fromCharCode(188)},verify:function(a,h,l){var n;n=l-1;l=Math.ceil(n/8);h=h.substr(-l);if(l<g+k+2)throwError("InconsistentparameterstoPSSsignatureverification.");if(188!==h.charCodeAt(l-1))throwError("Encodedmessagedoesnotendin0xBC.");varr=l-g-1,u=h.substr(0,r);h=h.substr(r,g);varD=65280>>8*l-n&255;if(0!==(u.charCodeAt(0)&D))throw Error("Bits beyond keysize not zero as expected.");var E=d.generate(h,r),x="";for(n=0;n<r;n++)x+=String.fromCharCode(u.charCodeAt(n)^E.charCodeAt(n));
var g=e.value,l=h.Type.PRINTABLESTRING;"valueTagClass"in e&&(l=e.valueTagClass,l===h.Type.UTF8&&(g=c.util.encodeUtf8(g)));e=h.create(h.Class.UNIVERSAL,h.Type.SET,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(e.type).getBytes()),h.create(h.Class.UNIVERSAL,l,!1,g)])]);b.value.push(e)}return b}function e(a){for(var c,b=0;b<a.length;++b){c=a[b];"undefined"===typeofc.name&&(c.type&&c.typeinr.oids?c.name=r.oids[c.type]:c.shortName&&c.shortNamein
u&&(c.name=r.oids[u[c.shortName]]));if("undefined"===typeof c.type)if(c.name&&c.name in r.oids)c.type=r.oids[c.name];else throw a=Error("Attribute type not specified."),a.attribute=c,a;"undefined"===typeof c.shortName&&c.name&&c.name in u&&(c.shortName=u[c.name]);if(c.type===p.extensionRequest&&(c.valueConstructed=!0,c.valueTagClass=h.Type.SEQUENCE,!c.value&&c.extensions)){c.value=[];for(var d=0;d<c.extensions.length;++d)c.value.push(r.certificateExtensionToAsn1(g(c.extensions[d])))}if("undefined"===
typeof c.value)throw a=Error("Attribute value not specified."),a.attribute=c,a;}}function g(a,b){b=b||{};"undefined"===typeof a.name&&a.id&&a.id in r.oids&&(a.name=r.oids[a.id]);if("undefined"===typeof a.id)if(a.name&&a.name in r.oids)a.id=r.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,k=0;a.digitalSignature&&(e|=128,d=7);a.nonRepudiation&&(e|=64,d=6);a.keyEncipherment&&(e|=32,d=5);a.dataEncipherment&&
"pathLenConstraint"in a&&a.value.value.push(h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(a.pathLenConstraint).getBytes()));else if("extKeyUsage"===a.name)for(e in a.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]),d=a.value.value,a)!0===a[e]&&(e in p?d.push(h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(p[e]).getBytes())):-1!==e.indexOf(".")&&d.push(h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(e).getBytes())));else if("nsCertType"===a.name)e=d=0,a.client&&(e|=128,
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?h.oidToDer(h.oidToDer(e.oid)):h.oidToDer(d));a.value.value.push(h.create(h.Class.CONTEXT_SPECIFIC,e.type,!1,d))}else"subjectKeyIdentifier"===a.name&&b.cert&&(d=b.cert.generateSubjectKeyIdentifier(),a.subjectKeyIdentifier=d.toHex(),a.value=h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,d.getBytes()));if("undefined"===typeof a.value)throw d=Error("Extension value not specified."),
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=h.fromDer(a.body,d);return r.certificateFromAsn1(d,b)};r.certificateToPem=function(a,b){var d={type:"CERTIFICATE",body:h.toDer(r.certificateToAsn1(a)).getBytes()};
return c.pem.encode(d,{maxline:b})};r.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=h.fromDer(a.body);return r.publicKeyFromAsn1(a)};r.publicKeyToPem=function(a,b){var d={type:"PUBLIC KEY",
body:h.toDer(r.publicKeyToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};r.publicKeyToRSAPublicKeyPem=function(a,b){var d={type:"RSA PUBLIC KEY",body:h.toDer(r.publicKeyToRSAPublicKey(a)).getBytes()};return c.pem.encode(d,{maxline:b})};r.getPublicKeyFingerprint=function(a,b){b=b||{};var d=b.md||c.md.sha1.create(),e;switch(b.type||"RSAPublicKey"){case "RSAPublicKey":e=h.toDer(r.publicKeyToRSAPublicKey(a)).getBytes();break;case "SubjectPublicKeyInfo":e=h.toDer(r.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};r.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=h.fromDer(a.body,d);return r.certificationRequestFromAsn1(d,b)};r.certificationRequestToPem=function(a,b){var d={type:"CERTIFICATE REQUEST",body:h.toDer(r.certificationRequestToAsn1(a)).getBytes()};return c.pem.encode(d,{maxline:b})};r.createCertificate=function(){var a={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};a.siginfo.algorithmOid=
a.sign=function(b,d){a.md=d||c.md.sha1.create();var e=p[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=r.getTBSCertificate(a);e=h.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 p)switch(p[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."),
c.util.hexToBytes(e.subjectKeyIdentifier)===b}return!1};return a};r.certificateFromAsn1=function(a,d){var k={},g=[];if(!h.validate(a,z,k,g))throw k=Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate."),k.errors=g,k;if("string"!==typeof k.certSignature){for(var g="\x00",n=0;n<k.certSignature.length;++n)g+=h.toDer(k.certSignature[n]).getBytes();k.certSignature=g}g=h.derToOid(k.publicKeyOid);if(g!==r.oids.rsaEncryption)throwError("Cannotreadpublickey.OIDisnotRSA.");
var q=r.createCertificate();q.version=k.certVersion?k.certVersion.charCodeAt(0):0;g=c.util.createBuffer(k.certSerialNumber);q.serialNumber=g.toHex();q.signatureOid=c.asn1.derToOid(k.certSignatureOid);q.signatureParameters=N(q.signatureOid,k.certSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(k.certinfoSignatureOid);q.siginfo.parameters=N(q.siginfo.algorithmOid,k.certinfoSignatureParams,!1);g=c.util.createBuffer(k.certSignature);++g.read;q.signature=g.getBytes();g=[];void 0!==k.certValidity1UTCTime&&
g.push(h.utcTimeToDate(k.certValidity1UTCTime));void 0!==k.certValidity2GeneralizedTime&&g.push(h.generalizedTimeToDate(k.certValidity2GeneralizedTime));void 0!==k.certValidity3UTCTime&&g.push(h.utcTimeToDate(k.certValidity3UTCTime));void 0!==k.certValidity4GeneralizedTime&&g.push(h.generalizedTimeToDate(k.certValidity4GeneralizedTime));if(2<g.length)throwError("CannotreadnotBefore/notAftervaliditytimes;morethantwotimeswereprovidedinthecertificate.");if(2>g.length)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");
q.validity.notBefore=g[0];q.validity.notAfter=g[1];q.tbsCertificate=k.tbsCertificate;if(d){q.md=null;if(q.signatureOid in p)switch(g=p[q.signatureOid],g){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 k=Error("Could not compute certificate digest. Unknown signature OID."),
function(a){var b={};b.id=h.derToOid(a.value[0].value);b.critical=!1;a.value[1].type===h.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 p)if(b.name=p[b.id],"keyUsage"===b.name){a=h.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=
h.derToOid(a.value[d].value),e in p?b[p[e]]=!0:b[e]=!0;else if("nsCertType"===b.name)a=h.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);elseif("subjectAltName"===b.name||"issuerAltName"===b.name)for(b.altNames=[],a=h.fromDer(b.value),e=0;e<a.value.length;++e){vard=a.value[e],k={type:d.type,value:d.value};b.altNames.push(k);
switch(d.type){case 7:k.ip=c.util.bytesToIP(d.value);break;case 8:k.oid=h.derToOid(d.value)}}else"subjectKeyIdentifier"===b.name&&(a=h.fromDer(b.value),b.subjectKeyIdentifier=c.util.bytesToHex(a.value));return b};r.certificationRequestFromAsn1=function(a,d){var k={},g=[];if(!h.validate(a,D,k,g))throw k=Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest."),k.errors=g,k;if("string"!==typeof k.csrSignature){for(var g="\x00",n=0;n<k.csrSignature.length;++n)g+=
h.toDer(k.csrSignature[n]).getBytes();k.csrSignature=g}g=h.derToOid(k.publicKeyOid);if(g!==r.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var q=r.createCertificationRequest();q.version=k.csrVersion?k.csrVersion.charCodeAt(0):0;q.signatureOid=c.asn1.derToOid(k.csrSignatureOid);q.signatureParameters=N(q.signatureOid,k.csrSignatureParams,!0);q.siginfo.algorithmOid=c.asn1.derToOid(k.csrSignatureOid);q.siginfo.parameters=N(q.siginfo.algorithmOid,k.csrSignatureParams,!1);g=
c.util.createBuffer(k.csrSignature);++g.read;q.signature=g.getBytes();q.certificationRequestInfo=k.certificationRequestInfo;if(d){q.md=null;if(q.signatureOid in p)switch(g=p[q.signatureOid],g){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 k=
Error("Could not compute certification request digest. Unknown signature OID."),k.signatureOid=q.signatureOid,k;g=h.toDer(q.certificationRequestInfo);q.md.update(g.getBytes())}g=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=r.RDNAttributesAsArray(k.certificationRequestInfoSubject,g);q.subject.hash=g.digest().toHex();q.publicKey=r.publicKeyFromAsn1(k.subjectPublicKeyInfo);q.getAttribute=
r.verifyCertificateChain=function(a,b,d){b=b.slice(0);var e=b.slice(0),h=new Date,k=!0,g=null,l=0;do{var p=b.shift(),n=null,v=!1;if(h<p.validity.notBefore||h>p.validity.notAfter)g={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:p.validity.notBefore,notAfter:p.validity.notAfter,now:h};if(null===g){n=b[0]||a.getIssuer(p);null===n&&p.isIssuer(p)&&(v=!0,n=p);if(n){var w=n;c.util.isArray(w)||(w=[w]);for(var u=!1;!u&&0<w.length;){n=w.shift();
try{u=n.verify(p)}catch(y){}}u||(g={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==g||n&&!v||a.hasCertificate(p)||(g={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}null===g&&n&&!p.isIssuer(n)&&(g={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate});if(null===g)for(w={keyUsage:!0,basicConstraints:!0},u=0;null===g&&u<p.extensions.length;++u){var z=p.extensions[u];!z.critical||z.name in w||(g=
{message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}null!==g||k&&(0!==b.length||n&&!v)||(k=p.getExtension("basicConstraints"),p=p.getExtension("keyUsage"),null!==p&&(p.keyCertSign&&null!==k||(g={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:r.certificateError.bad_certificate})),
null!==g||null===k||k.cA||(g={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===g&&null!==p&&"pathLenConstraint"in k&&l-1>k.pathLenConstraint&&(g={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate}));p=null===g?!0:g.error;k=d?d(p,l,e):p;if(!0===k)g=null;else{!0===p&&(g={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate});
a.errors=z,a;q=k.derToOid(r.contentType);if(q!==h.oids.data)throw a=Error("PKCS#12 EncryptedContentInfo ContentType is not Data."),a.oid=q,a;q=k.derToOid(r.encAlgorithm);q=h.pbe.getCipher(q,r.encParameter,y);r=d(r.encryptedContentAsn1);r=c.util.createBuffer(r.value);q.update(r);if(!q.finish())throw Error("Failed to decrypt PKCS#12 SafeContents.");q=q.output.getBytes();u.encrypted=!0;break;default:throw a=Error("Unsupported PKCS#12 contentType."),a.contentType=k.derToOid(r.contentType),a;}u.safeBags=
g(q,e,l);a.safeContents.push(u)}}function g(a,c,b){if(!c&&0===a.length)return[];a=k.fromDer(a,c);if(a.tagClass!==k.Class.UNIVERSAL||a.type!==k.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++){varm={},l=[];if(!k.validate(a.value[e],y,m,l))throwa=Error("CannotreadSafeBag."),a.errors=l,a;varp={type:k.derToOid(m.bagId),attributes:n(m.bagAttributes)};d.push(p);varv,w,r=m.bagValue.value[0];switch(p.type){caseh.oids.pkcs8ShroudedKeyBag:if(r=
h.decryptPrivateKeyInfo(r,b),null===r)throw Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case h.oids.keyBag:try{p.key=h.privateKeyFromAsn1(r)}catch(u){p.key=null,p.asn1=r}continue;case h.oids.certBag:v=A;w=function(){if(k.derToOid(m.certId)!==h.oids.x509Certificate){var a=Error("Unsupported certificate type, only X.509 supported.");a.oid=k.derToOid(m.certId);throw a;}a=k.fromDer(m.cert,c);try{p.cert=h.certificateFromAsn1(a,!0)}catch(b){p.cert=null,p.asn1=a}};break;default:throw a=
r.pkcs12FromAsn1=function(a,g,p){"string"===typeof g?(p=g,g=!0):void 0===g&&(g=!0);var n={};if(!k.validate(a,u,n,[]))throw g=Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX."),g.errors=g,g;var v={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(v.safeContents,null,null,a.bagType));void 0!==e&&
(d.localKeyId=b(v.safeContents,"localKeyId",e,a.bagType));"friendlyName"in a&&(d.friendlyName=b(v.safeContents,"friendlyName",a.friendlyName,a.bagType));return d},getBagsByFriendlyName:function(a,c){return b(v.safeContents,"friendlyName",a,c)},getBagsByLocalKeyId:function(a,c){return b(v.safeContents,"localKeyId",a,c)}};if(3!==n.version.charCodeAt(0))throw g=Error("PKCS#12 PFX of version other than 3 not supported."),g.version=n.version.charCodeAt(0),g;if(k.derToOid(n.contentType)!==h.oids.data)throw g=
Error("Only PKCS#12 PFX in password integrity mode supported."),g.oid=k.derToOid(n.contentType),g;a=n.content.value[0];if(a.tagClass!==k.Class.UNIVERSAL||a.type!==k.Type.OCTETSTRING)throw Error("PKCS#12 authSafe content data is not an OCTET STRING.");a=d(a);if(n.mac){var y=null,z=0,q=k.derToOid(n.macAlgorithm);switch(q){case h.oids.sha1:y=c.md.sha1.create();z=20;break;case h.oids.sha256:y=c.md.sha256.create();z=32;break;case h.oids.sha384:y=c.md.sha384.create();z=48;break;case h.oids.sha512:y=c.md.sha512.create();
z=64;break;case h.oids.md5:y=c.md.md5.create(),z=16}if(null===y)throw Error("PKCS#12 uses unsupported MAC algorithm: "+q);var q=new c.util.ByteBuffer(n.macSalt),A="macIterations"in n?parseInt(c.util.bytesToHex(n.macIterations),16):1,z=r.generateKey(p,q,3,A,z,y),q=c.hmac.create();q.start(y,z);q.update(a.value);if(q.getMac().getBytes()!==n.macDigest)throw Error("PKCS#12 MAC could not be verified. Invalid password?");}e(v,a.value,g,p);return v};r.toPkcs12Asn1=function(a,b,d,e){e=e||{};e.saltSize=e.saltSize||
function(){r.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 g=Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
g.headerType=a.type;throw g;}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,g){var n={type:"RSA PRIVATE KEY",body:b.toDer(d.privateKeyToAsn1(a)).getBytes()};return c.pem.encode(n,{maxline:g})};d.privateKeyInfoToPem=function(a,d){var g={type:"PRIVATE KEY",body:b.toDer(a).getBytes()};return c.pem.encode(g,{maxline:d})}}if("function"!==typeof c)if("object"===
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};k.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};k.CipherSuites={};k.getCipherSuite=function(a){var c=null,b;for(b in k.CipherSuites){var d=k.CipherSuites[b];if(d.id[0]===a.charCodeAt(0)&&d.id[1]===a.charCodeAt(1)){c=d;break}}return c};
k.handleUnexpected=function(a,c){(a.open||a.entity!==k.ConnectionEnd.client)&&a.error(a,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.unexpected_message}})};k.handleHelloRequest=function(a,c,b){!a.handshaking&&0<a.handshakes&&(k.queue(a,k.createAlert(a,{level:k.Alert.Level.warning,description:k.Alert.Description.no_renegotiation})),k.flush(a));a.process()};k.parseHelloMessage=function(a,b,d){var e=null,h=a.entity===
k.ConnectionEnd.client;if(38>d)a.error(a,{message:h?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.illegal_parameter}});else{b=b.fragment;var l=b.length(),e={version:{major:b.getByte(),minor:b.getByte()},random:c.util.createBuffer(b.getBytes(32)),session_id:g(b,1),extensions:[]};h?(e.cipher_suite=b.getBytes(2),e.compression_method=b.getByte()):(e.cipher_suites=g(b,2),e.compression_methods=
!1!==a.verifyClient&&k.queue(a,k.createRecord(a,{type:k.ContentType.handshake,data:k.createCertificateRequest(a)})),k.queue(a,k.createRecord(a,{type:k.ContentType.handshake,data:k.createServerHelloDone(a)}))));k.flush(a);a.process()}};k.handleCertificate=function(a,b,d){if(3>d)return a.error(a,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.illegal_parameter}});d=g(b.fragment,3);var e,h;b=[];try{for(;0<d.length();)e=
g(d,3),h=c.asn1.fromDer(e),e=c.pki.certificateFromAsn1(h,!0),b.push(e)}catch(l){return a.error(a,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.bad_certificate}})}e=a.entity===k.ConnectionEnd.client;!e&&!0!==a.verifyClient||0!==b.length?0===b.length?a.expect=e?r:x:(e?a.session.serverCertificate=b[0]:a.session.clientCertificate=b[0],k.verifyCertificateChain(a,b)&&(a.expect=e?r:x)):a.error(a,{message:e?"No server certificate provided.":
"No client certificate provided.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.illegal_parameter}});a.process()};k.handleServerKeyExchange=function(a,c,b){if(0<b)returna.error(a,{message:"Invalidkeyparameters.OnlyRSAissupported.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.unsupported_certificate}});a.expect=p;a.process()};k.handleClientKeyExchange=function(a,b,d){if(48>d)return a.error(a,{message:"Invalid key parameters. Only RSA is supported.",
send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.unsupported_certificate}});b=g(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:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}})}if(null===d)return a.error(a,{message:"No private key set.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}});
try{var h=a.session.sp;h.pre_master_secret=d.decrypt(b);var l=a.session.clientHelloVersion;if(l.major!==h.pre_master_secret.charCodeAt(0)||l.minor!==h.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.");}catch(e){h.pre_master_secret=c.random.getBytes(48)}a.expect=B;null!==a.session.clientCertificate&&(a.expect=G);a.process()};k.handleCertificateRequest=function(a,c,b){if(3>b)return a.error(a,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:k.Alert.Level.fatal,
description:k.Alert.Description.illegal_parameter}});c=c.fragment;c={certificate_types:g(c,1),certificate_authorities:g(c,2)};a.session.certificateRequest=c;a.expect=u;a.process()};k.handleCertificateVerify=function(a,b,d){if(2>d)return a.error(a,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.illegal_parameter}});d=b.fragment;d.read-=4;b=d.bytes();d.read+=4;d=g(d,2).getBytes();var e=c.util.createBuffer();e.putBuffer(a.session.md5.digest());
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(h){return a.error(a,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.handshake_failure}})}a.expect=B;a.process()};k.handleServerHelloDone=function(a,b,d){if(0<d)returna.error(a,{message:"InvalidServerHelloDonemessage.Invalidlength.",
send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.record_overflow}});if(null===a.serverCertificate&&(b={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.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));
break;case k.Alert.Description.no_renegotiation:d="Renegotiation not supported.";break;default:d="Unknown error."}if(b.description===k.Alert.Description.close_notify)return a.close();a.error(a,{message:d,send:!1,origin:a.entity===k.ConnectionEnd.client?"server":"client",alert:b});a.process()};k.handleHandshake=function(a,b){var d=b.fragment,e=d.getByte(),h=d.getInt24();if(h>d.length())return a.fragmented=b,b.fragment=c.util.createBuffer(),d.read-=4,a.process();a.fragmented=null;d.read-=4;var g=d.bytes(h+
4);d.read+=4;e in V[a.entity][a.expect]?(a.entity!==k.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!==k.HandshakeType.hello_request&&e!==k.HandshakeType.certificate_verify&&e!==k.HandshakeType.finished&&(a.session.md5.update(g),a.session.sha1.update(g)),V[a.entity][a.expect][e](a,b,h)):
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},h={read:b(),write:b()};h.read.update=function(a,c){h.read.cipherFunction(c,h.read)?h.read.compressFunction(a,c,h.read)||a.error(a,{message:"Could not decompress record.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.decompression_failure}}):
a.error(a,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.bad_record_mac}});return!a.fail};h.write.update=function(a,c){h.write.compressFunction(a,c,h.write)?h.write.cipherFunction(c,h.write)||a.error(a,{message:"Could not encrypt record.",send:!1,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}}):a.error(a,{message:"Could not compress record.",send:!1,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}});
var r=c.util.createBuffer();n(r,3,q);e.putBuffer(r)}d=c.pki.certificateFromAsn1(h);b?a.session.clientCertificate=d:a.session.serverCertificate=d}catch(v){return a.error(a,{message:"Could not send certificate list.",cause:v,send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.bad_certificate}})}a=3+e.length();b=c.util.createBuffer();b.putByte(k.HandshakeType.certificate);b.putInt24(a);n(b,3,e);return b};k.createClientKeyExchange=function(a){var b=c.util.createBuffer();b.putByte(a.session.clientHelloVersion.major);
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(h){a.error(a,{message:"Could not get private key.",cause:h,send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}})}null===e?a.error(a,{message:"No private key set.",send:!0,alert:{level:k.Alert.Level.fatal,description:k.Alert.Description.internal_error}}):
b=e.sign(b,null);d(a,b)};a.getSignature(a,d,b)};k.createCertificateVerify=function(a,b){var d=b.length+2,e=c.util.createBuffer();e.putByte(k.HandshakeType.certificate_verify);e.putInt24(d);e.putInt16(b.length);e.putBytes(b);return e};k.createCertificateRequest=function(a){var b=c.util.createBuffer();b.putByte(1);var d=c.util.createBuffer(),e;for(e in a.caStore.certs){var h=c.pki.distinguishedNameToAsn1(a.caStore.certs[e].subject);d.putBuffer(c.asn1.toDer(h))}a=1+b.length()+2+d.length();e=c.util.createBuffer();
case k.Alert.Description.certificate_expired:return c.pki.certificateError.certificate_expired;case k.Alert.Description.certificate_unknown:return c.pki.certificateError.certificate_unknown;case k.Alert.Description.unknown_ca:return c.pki.certificateError.unknown_ca;default:return c.pki.certificateError.bad_certificate}};k.verifyCertificateChain=function(a,b){try{c.pki.verifyCertificateChain(a.caStore,b,function(b,d,e){U(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:k.Alert.Level.fatal,description:k.Alert.Description.bad_certificate},d.message&&(b.message=d.message),d.alert&&(b.alert.description=d.alert),b;d!==b&&(d=X(d))}return d})}catch(d){var e=d;if("object"!==typeof e||c.util.isArray(e))e={send:!0,alert:{level:k.Alert.Level.fatal,description:U(d)}};"send"in e||(e.send=!0);"alert"in e||(e.alert={level:k.Alert.Level.fatal,description:U(e.error)});a.error(a,e)}return!a.fail};k.createSessionCache=
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&&eind.cache){b=d.cache[e];deleted.cache[e];for(varhind.order)if(d.order[h]===e){d.order.splice(h,1);break}}returnb};d.setSession=function(a,b){if(d.order.length===d.capacity){vare=d.order.shift();
delete d.cache[e]}e=c.util.bytesToHex(a);d.order.push(e);d.cache[e]=b}}return d};k.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 k.CipherSuites)d.push(k.CipherSuites[e])}e=a.server?k.ConnectionEnd.server:k.ConnectionEnd.client;var h=a.sessionCache?k.createSessionCache(a.sessionCache):null,g={version:{major:k.Version.major,minor:k.Version.minor},entity:e,
!1;g.fail=!(a||"undefined"===typeof a);g.input.clear();g.tlsData.clear();g.data.clear();g.state.current=k.createConnectionState(g)}};g.reset();g.handshake=function(a){if(g.entity!==k.ConnectionEnd.client)g.error(g,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(g.handshaking)g.error(g,{message:"Handshake already in progress.",fatal:!1});else{g.fail&&!g.open&&0===g.handshakes&&(g.fail=!1);g.handshaking=!0;a=a||"";var b=null;0<a.length&&(g.sessionCache&&(b=g.sessionCache.getSession(a)),
k.createAlert(g,{level:k.Alert.Level.warning,description:k.Alert.Description.close_notify})),k.flush(g);g.closed(g)}g.reset(a)};return g};c.tls=c.tls||{};for(var T in k)"function"!==typeof k[T]&&(c.tls[T]=k[T]);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());
p.Type.OCTETSTRING,!1,a.parameter.getBytes())]),p.create(p.Class.CONTEXT_SPECIFIC,0,!0,[p.create(p.Class.UNIVERSAL,p.Type.OCTETSTRING,!1,a.content.getBytes())])]}function h(a,b,d){var e={};if(!p.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(p.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=
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 p=c.asn1,u=c.pkcs7=c.pkcs7||{};u.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=p.fromDer(a.body);return u.messageFromAsn1(a)};u.messageToPem=function(a,b){var d={type:"PKCS7",body:p.toDer(a.toAsn1()).getBytes()};return c.pem.encode(d,{maxline:b})};u.messageFromAsn1=function(a){var b={},d=[];if(!p.validate(a,u.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=p.derToOid(b.contentType);switch(d){case c.pki.oids.envelopedData:d=
u.createEnvelopedData();break;case c.pki.oids.encryptedData:d=u.createEncryptedData();break;case c.pki.oids.signedData:d=u.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};u.createSignedData=function(){var a=null;return a={type:c.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(b){h(a,
p.Type.NULL,!1,"")]));if(2>a.contentInfo.value.length)throw Error("Could not sign PKCS#7 message; there is no content to sign.");var h=p.derToOid(a.contentInfo.value[0].value),d=a.contentInfo.value[1],d=d.value[0],k=p.toDer(d);k.getByte();p.getBerValueLength(k);var k=k.getBytes(),l;for(l in b)b[l].start().update(k);l=new Date;for(d=0;d<a.signers.length;++d){e=a.signers[d];if(0===e.authenticatedAttributes.length){if(h!==c.pki.oids.data)throwError("Invalidsigner;authenticatedAttributesmustbepresentwhentheContentInfocontenttypeisnotPKCS#7Data.");
null===a.parent||(a.parent.error=a.error,a.parent.swapTime=a.swapTime,a.parent.userData=a.userData,h(a.parent,c))};b?setTimeout(d,0):d(c)},r=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],k(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 g=!0;c=function(a,c){c(b,module)}}else return"undefined"===typeof forge&&(forge={}),a(forge);var n,r=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 g=0;g<e.length;++g)e[g](b);returnb.task}},
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 g=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++)g===b[n].DERKey+"-----ENDPUBLICKEY-----"&&(b[n].XCert=d,d.XPrivateKey=b[n])}catch(r){console.log(r)}}}
function amtcert_loadP12File(a,b,c){try{var d=window.forge.util.decode64(btoa(a)),g=window.forge.asn1.fromDer(d),n=window.forge.pkcs12.pkcs12FromAsn1(g,b),r=n.getBags({bagType:window.forge.pki.oids.pkcs8ShroudedKeyBag});console.assert(r[window.forge.pki.oids.pkcs8ShroudedKeyBag]&&0<r[window.forge.pki.oids.pkcs8ShroudedKeyBag].length);var u=r[window.forge.pki.oids.pkcs8ShroudedKeyBag][0].key,m=window.forge.pki.privateKeyToAsn1(u),l=window.forge.pki.wrapRsaPrivateKey(m);window.forge.asn1.toDer(l).getBytes();
var w=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(u,w,e);return!0}catch(v){}return!1}function amtcert_signWithCaKey(a,b,c,d,g){b&&null!=b||(b=amtcert_createCertificate(d).key);return amtcert_createCertificate(c,b,a,d,g)}
function amtcert_createCertificate(a,b,c,d,g){var n,r=forge.pki.createCertificate();c?r.publicKey=forge.pki.publicKeyFromPem("-----BEGIN PUBLIC KEY-----"+c+"-----END PUBLIC KEY-----"):(n=forge.pki.rsa.generateKeyPair(2048),r.publicKey=n.publicKey);r.serialNumber=""+Math.floor(1E5*Math.random()+1);r.validity.notBefore=new Date;r.validity.notBefore.setFullYear(r.validity.notBefore.getFullYear()-1);r.validity.notAfter=new Date;r.validity.notAfter.setFullYear(r.validity.notAfter.getFullYear()+30);var u=
c.ip+4),r=c.ip+6,u=[],m;for(m in c.variables)m.startsWith("__")&&delete c.variables[m];for(m=0;m<n;m++){varl=ReadShort(c.script,r),w=c.script.substring(r+2,r+2+l),e=w.charCodeAt(0),w=w.substring(1);if(2>e){for(;1<w.split("{").length;)varv=w.split("{").pop().split("}").shift(),w=w.replace("{"+v+"}",c.getVar(v));1==e&&(c.variables["__"+m]=decodeURI(w),w="__"+m);u.push(w)}if(2==e||3==e)c.variables["__"+m]=ReadSInt(w,0),u.push("__"+m);r+=2+l}c.ip+=b;b=[];for(m=0;10>m;m++)b.push(c.getVar(u[m]));var E;
function script_compile(a,b){var c="",d=a.split("\n"),g={},n=[],r=[],u;for(u in d){var m=d[u];if(m.startsWith("##SWAP ")){var l=m.split(" ");3==l.length&&(r[l[1]]=l[2])}if("#"!=m[0]&&0!=m.length){for(l in r)m=m.split(l).join(r[l]);var w=m.match(/"[^"]*"|[^\s"]+/g);if(0!=w.length)if(":"==m[0])g[w[0].toUpperCase()]=c.length;else{m=script_functionTable1.indexOf(w[0].toLowerCase());-1==m&&(m=script_functionTable2.indexOf(w[0].toLowerCase()),0<=m&&(m+=1E4));-1==m&&(m=script_functionTable3.indexOf(w[0].toLowerCase()),
0<=m&&(m+=2E4));if(-1==m)return b&&b("Unabled to compile, unknown command: "+w[0]),"";var e=ShortToStr(w.length-1),v;for(v in w)if(0!=v)if(":"==w[v][0])n.push([w[v],c.length+e.length+7]),e+=ShortToStr(5)+String.fromCharCode(3)+IntToStr(4294967295);else var E=parseInt(w[v]),e=E==w[v]?e+(ShortToStr(5)+String.fromCharCode(2)+IntToStr(E)):'"'==w[v][0]&&'"'==w[v][w[v].length-1]?e+(ShortToStr(w[v].length-1)+String.fromCharCode(1)+w[v].substring(1,w[v].length-1)):e+(ShortToStr(w[v].length+1)+String.fromCharCode(0)+
w[v]);e=ShortToStr(m)+ShortToStr(e.length+4)+e;c+=e}}}for(u in n){d=n[u][0].toUpperCase();r=n[u][1];l=g[d];if(void 0==l)return b&&b("Unabled to compile, unknown label: "+d),"";c=c.substr(0,r)+IntToStr(l)+c.substr(r+4)}return IntToStr(612182341)+ShortToStr(1)+c}
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(varbinAllWsman)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",
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 connect(a,b,c,d,g,n,r){go(0);fullscreenonly=!1;connectFunc=n;connectFuncTag=r;wsstack=WsmanStackCreateService(a,b,c,d,g);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,
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,
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)}}functionPullPowerState(){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==
200==c.AMT_RedirectionService.status&&QV("go13",!0);d=0;for(var g in c)null!=c[g]&&c[g].status>d&&(d=c[g].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)){vara=0,b,c,d=TableStart(),g="",n=amtsysstate.AMT_GeneralSettings.response;t="Unknown";null!=amtsysstate.CIM_ServiceAvailableToElement&&(t=DMTFPowerStates[amtsysstate.CIM_ServiceAvailableToElement.responses[0].PowerState]);n.PowerSource&&(t+=[",Plugged-in",",OnBattery"][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 r="",u=getItem(amtlogicalelements,"CreationClassName","AMT_SetupAndConfigurationService");2==u.ProvisioningState&&5<amtversion&&(r=" activated in Admin Control Mode (ACM)",4==u.ProvisioningMode&&(r="activatedinClientControlMode(CCM)",a=9));
d);d="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>"+TableEnd("<div> "+AddRefreshButton("PullSystemStatus(1)")+" Changing network settings may cause this page to becaume unavailable.");d=d+"<br><h2>General Settings</h2>"+TableStart();g="";"<i>None</i>"!=b&&(1==n.SharedFQDN&&(g=", shared with OS"),0==n.SharedFQDN&&(g=", different from OS"));d+=TableEntry("Name & Domain",addLinkConditional(b+g,"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",
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® 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® 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="<tableclass=log1cellpadding=0cellspacing=0style=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("<divstyle=float:right><inputid=eventFilterplaceholder=Filterstyle=margin:4pxonkeyup=eventFilter()> </div><div> "+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,g;g="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><tdwidth=80px><p><td><td><td><tr><tdclass=r1style=width:90px><b> Event</b><tdclass=r1style=width:110px><b>Time</b><tdclass=r1style=width:160px><b>Source</b><tdclass=r1><b>Description</b>";for(c in b){d++;var n=1,r=b[c];8<=r.EventSeverity&&(n=2);16<=r.EventSeverity&&(n=3);g+="<trid=xamtevent"+c+"class=r3onclick=showEventDetails("+
function showEventDetails(a){if(!xxdialogMode){var b=eventmessages[a],c;c="<divstyle=text-align:left>"+addHtmlValue("Time",b.Time.toLocaleString());c+=addHtmlValue("Source",b.EntityStr.replace("(r)","®"));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="",g;for(g in b.EventData)0<d.length&&(d+=","),d+=b.EventData[g];c+=addHtmlValue("Data",d);c+=addHtmlValue("Offset",
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><tdclass=r1style=padding-left:15px><br>Manage event subscribers.<br><br>";for(var g in subscriptionsListeners.CIM_ListenerDestination.responses)c=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[g].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","®"),d=subscriptionsListeners.CIM_ListenerDestination.responses[g],
function showSubscriptionDetails(a){if(!xxdialogMode){var b=subscriptionsListeners.CIM_FilterCollectionSubscription.responses[a].Filter.ReferenceParameters.SelectorSet.Selector.Value.replace("(r)","®"),c=subscriptionsListeners.CIM_ListenerDestination.responses[a],d;d="<divstyle=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:SelectorName="InstanceID">'+subscriptionsListeners.CIM_FilterCollectionSubscription.responses[b].Filter.ReferenceParameters.SelectorSet.Selector.Value+"</w:Selector></w:SelectorSet></a:ReferenceParameters></a:EndpointReference>",
function newSubscriptionButton(){if(!xxdialogMode&&null!=subscriptionsFilters){var a;a="<divstyle=height:26px;margin-top:4px><selectid=subtypestyle=float:right;width:260px><optionvalue=Push>Push</option><optionvalue=PushWithAck>Push with ACK</option></select><divstyle=padding-top:4px>Type</div></div><divstyle=height:26px;margin-top:4px><selectid=subfilterstyle=float:right;width:260px>";for(var b in subscriptionsFilters)a+="<optionvalue='"+subscriptionsFilters[b].InstanceID+"'>"+subscriptionsFilters[b].CollectionName.substring(13)+
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)}functionnewSubscriptionButtonOk2(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="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>"+(TableEnd("<divstyle=float:right><inputid=auditFilterplaceholder=Filterstyle=margin:4pxonkeyup=auditFilter()> </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 g=0;d+="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px><tr><tdwidth=80px><p><td><td><td><tr><tdclass=r1style=width:110px> <b>Time</b><tdclass=r1style=width:260px><b>Initiator</b><tdclass=r1><b>Action</b>";
for(c in b){var n=b[c],r=n.AuditApp,u=n.Initiator;g++;var m="";0<n.NetAddress.length&&(m=n.NetAddress.replace("0000:0000:0000:0000:0000:0000:0000:0001","::1"));n.Event&&(r+=","+n.Event);null!=n.ExStr&&(r+=","+n.ExStr);""!=u&&""!=m&&(u+=",");d+="<trid=xamtaudit"+c+"class=r3onclick=showAuditDetails("+c+")><tdclass=r1title='"+n.Time.toLocaleString()+"'> "+n.Time.toLocaleDateString("en",{year:"numeric",month:"2-digit",day:"numeric"})+"<br> "+n.Time.toLocaleTimeString("en",
{hour:"2-digit",minute:"2-digit",second:"2-digit"})+"<tdclass=r1>"+u+m+"<tdclass=r1>"+r}d+=TableEnd(0==g?" ":"")+"<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 showAuditDetails(a){if(!xxdialogMode){var b,c=auditLog[a],d;d="<divstyle=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){varg="";for(binc.Ex)0<g.length&&(g+=","),g+=c.Ex.charCodeAt(b);""!=g&&(d+=addHtmlValue("DataValues",
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(varginxxCertificates)xxCertificates[g].InstanceID==a&&(xxTlsCurrentCert=
g)}for(g in xxCertificates)xxCertificates[g].TrustedRootCertficate=1==xxCertificates[g].TrustedRootCertficate,xxCertificates[g].X509Certificate=window.atob(xxCertificates[g].X509Certificate),xxCertificates[g].XIssuer=parseCertName(xxCertificates[g].Issuer),xxCertificates[g].XSubject=parseCertName(xxCertificates[g].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+=",Trustedname"+(1<a.length?"s":"")+":"+a.join(",")+"."));returnb}
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><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT certificates for this computer.<br><br>");
if(0==xxCertificates.length&&0==xxCertPrivateKeys.length)c+="<divstyle=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+="<divclass=itemBaronclick=showCertDetails("+d+")><divstyle=padding-top:3px><b>"+EscapeHtml(xxCertificates[d].XSubject.CN)+"</b><i>"+a+"</i></div></div>";for(d in xxCertPrivateKeys)xxCertPrivateKeys[d].XCert||
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, <astyle=cursor:pointer;color:blueonclick=downloadCert("+a+")>Download</a>");c+=addHtmlValue("Trusted root",b.TrustedRootCertficate?"Yes":"No");0==b.TrustedRootCertficate&&b.XPrivateKey&&(c+=addHtmlValue("Private key","Present"));c+='<br><divstyle="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><divstyle="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 addCertButtonOk2(a){a=a.target.result;var b=a.indexOf("-----BEGIN CERTIFICATE-----");0<b?(a=a.substring(b+27),b=a.indexOf("-----ENDCERTIFICATE-----"),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="<inputid=certopentype=filestyle=float:right;width:230pxonchange=issueCertButtonUpdate()accept='.p12'>",xxDragDropCertFiles&&(a='<inputstyle=float:right;width:230pxreadonlydisabledvalue="'+xxDragDropCertFiles[0].name+'">'),a=""+("<divstyleheight:26px;margin-top:14px>"+a+"<divstyle=padding-top:4px>Certificate file</div></div>")+"<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certopenpasstype=passwordautocomplete=offstyle=float:right;width:230px><divstyle=padding-top:4px>Certificate password</div></div>",
a+='<br><divstyle="border-bottom:1px solid gray"><i>Intel® AMT Certificate</i></div>',a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certcnstyle=float:right;width:230px><divstyle=padding-top:4px>Common Name</div></div>",a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certostyle=float:right;width:230px><divstyle=padding-top:4px>Organization</div></div>",a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certststyle=float:right;width:230px><divstyle=padding-top:4px>State/Province</div></div>",
a+="<divstyle=height:26px;margin-top:4px><inputonkeyup=issueCertButtonUpdate()id=certcstyle=float:right;width:230px><divstyle=padding-top:4px>Country</div></div>",a+='<div>Certificate Usages</div><ulstyle="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><inputtype=checkboxid=d11_cu4checked>TLS Server (HTTPS)</label></li>",a+="<li><label><inputtype=checkboxid=d11_cu5>TLS Client (HTTPS)</label></li>",
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,g){if(200!=d)messagebox("Issue Certificate","Failed to generate key pair. Status: "+d);else{a=null;for(var n in c)c[n].InstanceID==g&&(a=c[n].DERKey);c={CN:getInputElement("certcn").value,O:getInputElement("certo").value,ST:getInputElement("certst").value,C:getInputElement("certc").value};g={CN:"Untrusted Root Certificate"};if(null!=xxCaPrivateKey&&xxCaSubjectAttributes)for(n in g={},xxCaSubjectAttributes)g[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,g,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)returnb[t]}functiongetSelectElement(a){varb=document.getElementsByTagName("select");for(t=0;t<b.length;t++)if(b[t].id==a)returnb[t]}
function showSetTlsSecurityDlg(a){if(!xxdialogMode){a="<divstyle=height:26px;margin-top:4px><selectonchange=showSetTlsSecurityDlgUpdate()id=tlscertstyle=float:right;width:260px><optionvalue=-1>No Certificate, TLS Disabled</option>";for(var b in xxCertificates)0!=xxCertificates[b].TrustedRootCertficate||!xxCertificates[b].XPrivateKey||null!=xxTlsCurrentCert&&xxTlsCurrentCert!=b||(a+="<optionvalue="+b+">"+xxCertificates[b].XSubject.CN+"</option>");a+="</select><divstyle=padding-top:4px>Certificate</div></div><divstyle=height:26px;margin-top:4px><selectid=tlsremotestyle=float:right;width:260pxonchange=showSetTlsSecurityDlgUpdate()><optionvalue=0>Server-auth TLS only</option><optionvalue=1>Server-auth, non-TLS allowed</option>";
8>amtversion&&(a+="<optionvalue=2>Mutual-auth TLS only</option><optionvalue=3>Mutual-auth, non-TLS allowed</option>");a+="</select><divstyle=padding-top:4px>Security</div></div><divstyle=height:26pxid=d11rcntitle='Comma seperated list of certificate common names that will be allowed to connect remotely.'><inputid=d11_rcnstyle=float:right;width:260pxonkeyup=showSetTlsSecurityDlgUpdate()placeholder='name1, name2'><divstyle=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?
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){vard=Clone(xxTLSCredentialContext[0]);d.ElementInContext.ReferenceParameters.SelectorSet.Selector.Value=xxCertificates[a].InstanceID;amtstack.Put("AMT_TLSCredentialContext",d,setTlsSecurityResponse,0,1)}elseamtstack.Create("AMT_TLSCredentialContext",
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))returna}}
function setTlsSecurityResponse(a,b,c,d,g){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 g in xxWatchdog.CIM_ConcreteDependency.responses)a=xxWatchdog.CIM_ConcreteDependency.responses[g],(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,
"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><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT agent presence watchdogs.<br><br>";if(null==xxWatchdog.AMT_AgentPresenceWatchdog.responses||
0==xxWatchdog.AMT_AgentPresenceWatchdog.responses.length)a+="<divstyle=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+="<divclass=itemBaronclick=showWatchdogDetails("+b+")><inputtype=buttonstyle=float:rightvalue='Add Action...'onclick=addWatchdogAction(event,"+
function AddWatchdog(){var a;a="<divstyle=height:26px;margin-top:4px><inputid=wgnamestyle=float:right;width:240pxmaxlength=16onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4px>Name</div></div>"+("<divstyle=height:26px;margin-top:4px><inputid=wgguidstyle=float:right;width:240pxmaxlength=36onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4pxtitle='Generate random DeviceID'>"+addLink("DeviceID","GenerateWatchdogGuid()")+"</div></div>");a+="<divstyle=height:26px;margin-top:4px><inputid=wgstartstyle=float:right;width:240pxmaxlength=8placeholder=3600onkeyup=AddWatchdogUpdate()><divstyle=padding-top:4px>Startup (seconds)</div></div>";
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++){varg=c.charCodeAt(d);45!=g&&(48<=g&&57>=g||97<=g&&102>=g?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><tdstyle=width:180px>From<br>";for(b in amtstack.WatchdogCurrentStates)d+="<inputid=wgsa"+b+"type=checkboxonclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br/>";d+="<td>To<br>";for(b in amtstack.WatchdogCurrentStates)d+="<inputid=wgsb"+b+"type=checkboxonclick=addWatchdogActionUpdate()> "+amtstack.WatchdogCurrentStates[b]+"<br/>";setDialogMode(11,"Add Watchdog Action",
3,addWatchdogActionOk,d+"</table><br>Perform Action<br><inputid=wgseventtype=checkboxcheckedonclick=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,g;for(g in amtstack.WatchdogCurrentStates)1==Q("wgsa"+g).checked&&(c+=parseInt(g)),1==Q("wgsb"+g).checked&&(d+=parseInt(g));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,
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],g;for(g in c)d=c[g],d=1==d?d+" packet":d+" packets",a+=TableEntry((0==b?"Wired ":"Wireless ")+g,d)}a+=TableEnd();a=a+"<br>"+TableStart2();a+="<tr><tdclass=r1style=padding-left:15px;border:0><br>Manage Intel® AMT system defense policies.<br><br>";if(0==xxSystemDefense.AMT_SystemDefensePolicy.responses.length)a+=
"<divstyle=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+="<divclass=itemBaronclick=showPolicyDetails("+b+")><divstyle=padding-top:3px><b>"+EscapeHtml(c.PolicyName)+"</b>"+d+"</div></div>";a+="<tr><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT system defense filters.<br><br>";
if(0==xxSystemDefense.AMT_Hdr8021Filter.responses.length&&0==xxSystemDefense.AMT_IPHeadersFilter.responses.length)a+="<divstyle=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+="<divclass=itemBaronclick=showFilterDetails(0,"+b+")><divstyle=padding-top:3px><b>"+(0==c.FilterDirection?"← ":"→ ")+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==
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:SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+a+"</w:Selector></w:SelectorSet></a:ReferenceParameters>",!1,UpdateDefenseStats2,a,0,{InstanceID:xxSystemDefenceLinkedPolicy[a].InstanceID}):
function UpdateDefenseStats3(a,b,c,d,g){a=0;if(200==d){xxFilterStatistics[g]={};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[g][b]=d,a++;updateSystemDefense()}xxFilterStatisticsTimerActive=!1;0==a&&StopDefenseStatsTimer()}
function changeDefaultPolicy(a){if(!xxdialogMode){var b;b="<divstyle=height:26px;margin-top:4px><selectid=policySelectionstyle=float:right;width:266px><optionvalue=-1>None";for(var c in xxSystemDefense.AMT_SystemDefensePolicy.responses)b+="<optionvalue="+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><divstyle=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:SelectorName="Antecedent"><a:EndpointReferencexmlns: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:SelectorName="CreationClassName">CIM_EthernetPort</w:Selector><w:SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+b+
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:'<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_EthernetPort</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="DeviceID">Intel(r) AMT Ethernet Port '+
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="<divstyle=height:26px;margin-top:4px><inputid=filternamestyle=float:right;width:260pxmaxlength=16onkeyup=AddDefenseFilterUpdate()><divstyle=padding-top:4px>Name</div></div><divstyle=height:26px;margin-top:4px><selectid=filtertypestyle=float:right;width:266pxonchange=AddDefenseFilterUpdate()><optionvalue=0>Ethernet IP Packet Filter<optionvalue=1>Ethernet ARP Packet Filter<optionvalue=2>IPv4 Packet Filter<optionvalue=3>IPv6 Packet Filter</select><divstyle=padding-top:4px>Type</div></div>";a+=
a+="<divstyle=height:26px;margin-top:4pxid=filterdatadiv><inputid=filterdatastyle=float:right;width:260pxmaxlength=8onkeyup=AddDefenseFilterUpdate()><divstyle=padding-top:4px>Packets / second</div></div>";a+="<divstyle=height:26px;margin-top:4px><selectid=filteractionstyle=float:right;width:266pxonchange=AddDefenseFilterUpdate()><optionvalue=false>Do Nothing<optionvalue=1>Event on match</select><divstyle=padding-top:4px>Event Log</div></div>";setDialogMode(11,"Add System Defense Filter",
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 g=c[d].indexOf("="),n=c[d].substring(0,g),g=c[d].substring(g+1),r=xxSystemDefenceFilters[n];r||(n="Hdr"+n,r=xxSystemDefenceFilters[n]);r&&(2==r&&4==a?(g=g.split("."),4==g.length&&(b[n]=rstr2hex(String.fromCharCode(parseInt(g[0]),
function showFilterDetails(a,b){if(!xxdialogMode){var c,d,g,n;0==a?(n="AMT_Hdr8021Filter",g="Ethernet Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterEthernetTypes[d.HdrProtocolID8021])||(c="All Ethernet Protocol "+d.HdrProtocolID8021)):(n="AMT_IPHeadersFilter",g="IP Traffic",d=xxSystemDefense[n].responses[b],(c=xxSystemDefenceFilterIPTypes[d.HdrIPVersion])||(c="All IP Protocol "+d.HdrIPVersion));var r;r=""+addHtmlValue("Name",EscapeHtml(d.Name));r+=addHtmlValue("Type",g);r+=addHtmlValue("Matching Traffic",
c);r+=addHtmlValue("Direction",0==d.FilterDirection?"Outbound / Transmit":"Inbound / Receive");if(1==a)for(var u in xxSystemDefenceFilters)d[u]&&(c=u,g=d[u],a=xxSystemDefenceFilters[u],2==a&&4==g.length&&(g=hex2rstr(g),g=g.charCodeAt(0)+"."+g.charCodeAt(1)+"."+g.charCodeAt(2)+"."+g.charCodeAt(3)),c.startsWith("Hdr")&&(c=c.substring(3)),r+=addHtmlValue("Filter "+c,g));r+=addHtmlValue("Event on match",1==d.ActionEventOnMatch?"Yes":"No");setDialogMode(11,"Ethernet Filter #"+d.InstanceID,5,showFilterDetailsOk,
r,[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="<divstyle=height:26px;margin-top:4px><inputid=policynametitle='<policy name>:<policy precedence number>'style=float:right;width:260pxmaxlength=16onkeyup=AddDefensePolicyUpdate()><divstyle=padding-top:4px>Name</div></div><divstyle=height:26px;margin-top:4px><selectid=policytxtitle='Default action to take for outbound traffic'style=float:right;width:133px><optionvalue=0>Allow<optionvalue=1>Drop<optionvalue=2>Allow,Count<optionvalue=3>Drop,Count<optionvalue=4>Allow,Count,Event<optionvalue=5>Drop,Count,Event</select><selectid=policyrxstyle=float:right;width:133pxtitle='Default action to take for inbound traffic'><optionvalue=0>Allow<optionvalue=1>Drop<optionvalue=2>Allow,Count<optionvalue=3>Drop,Count<optionvalue=4>Allow,Count,Event<optionvalue=5>Drop,Count,Event</select><divstyle=padding-top:4px>Default TX / RX</div></div>";a+=
"<divid=policyFilters></div>";if(0<xxSystemDefense.AMT_Hdr8021Filter.responses.length||0<xxSystemDefense.AMT_IPHeadersFilter.responses.length){a+="<divstyle=height:26px;margin-top:4px><divstyle=float:right><selectid=xfilterstyle=width:186px>";for(var b in xxSystemDefense.AMT_Hdr8021Filter.responses){var c=xxSystemDefense.AMT_Hdr8021Filter.responses[b];a+="<optionvalue="+c.InstanceID+">"+c.Name}for(b in xxSystemDefense.AMT_IPHeadersFilter.responses)c=xxSystemDefense.AMT_IPHeadersFilter.responses[b],
a+="<optionvalue="+c.InstanceID+">"+c.Name;a+="</select><inputid=addFilterButtontype=buttonvalue=Addstyle=width:80pxonclick=addFilterButton()></div><divstyle=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+="<divclass=itemBarstyle=margin-right:0><divstyle=float:right>"+AddButton2("Remove","removeFilterButton("+b+")")+"</div><divstyle=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,g;if(xxWireless.CIM_WiFiPortCapabilities.response){g="<br><h2>Wireless Profiles</h2>"+TableStart2();g+="<tr><tdclass=r2style=padding-left:15px><br>Wireless profiles that Intel® 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&&(g+="<divclass=itemBaronclick=showWifiDetails("+
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="<divstyle=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,g){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+="<optionvalue="+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,
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(vardinxxWireless.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==
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® Core™ 2 Duo Processor",
192:"Intel® Core™ 2 Solo processor",193:"Intel® Core™ 2 Extreme processor",194:"Intel® Core™ 2 Quad processor",195:"Intel® Core™ 2 Extreme mobile processor",196:"Intel® Core™ 2 Duo mobile processor",197:"Intel® Core™ 2 Solo mobile processor",198:"Intel® Core™ i7 processor",199:"Dual-Core Intel® Celeron® processor"},HardwareInventory;
function processHardware(a,b,c,d){if(200==d){var g;a="<tableclass=log1cellpadding=0cellspacing=0style=width:100%;border-radius:8px>";HardwareInventory=c;QV("go2",!0);a+=TableEnd("<div> "+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,
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+='<inputtype=radioname=powerpolicyvalue="'+AmtSystemPowerSchemes[c].InstanceID+'"'+(AmtSystemPowerSchemes[c].SchemeGUID==a?"checked":"")+">"+AmtSystemPowerSchemes[c].Description+"<br>";setDialogMode(11,"Intel® 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)}functionshowPowerPolicyDlgOkDone(a,b,c,d){200==d&&PullSystemStatus()}varxxAccountAdminName,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 g in c.Body.Handles)a=c.Body.Handles[g],amtstack.AMT_AuthorizationService_GetAclEnabledState(a,getAclEnabledStateResponse,a),amtstack.AMT_AuthorizationService_GetUserAclEntryEx(a,getUserAclEntryExResponse,a);updateAccounts()}}
function getUserAclEntryExResponse(a,b,c,d,g){xxAccountFetch--;200==d&&(c.Body.Handle=g,c.Body.Realms?Array.isArray(c.Body.Realms)||(c.Body.Realms=[c.Body.Realms]):c.Body.Realms=[],xxAccountRealmInfo[g]=c.Body,updateAccounts())}function getAclEnabledStateResponse(a,b,c,d,g){200==d&&(xxAccountEnabledInfo[g]=c.Body,updateAccounts())}function setAclEnabledStateResponse(a,b,c,d,g){errcheck(d,a)||(methodcheck(c),amtstack.AMT_AuthorizationService_GetAclEnabledState(g,getAclEnabledStateResponse,g))}
function updateAccounts(){if(!(0<xxAccountFetch)){vara=TableStart2(),a=a+"<tr><tdclass=r1style=padding-left:15px><br>Manage the Intel® AMT user accounts for this computer.<br><br>",b;for(b in xxAccountRealmInfo){var c=xxAccountRealmInfo[b],d,g=!1,n=0;c.DigestUsername?(d=c.DigestUsername,g="$"==d[0]&&"$"==d[1]):d=GetSidString(atob(c.KerberosUserSid));xxAccountEnabledInfo[b]&&"$$OsAdmin"!=d&&(n=1==xxAccountEnabledInfo[b].Enabled?1:2);if(showHiddenAccounts||!g){var r="";if(999!=c.AccessPermission){2==
n&&(r+="Disabled, ");var u=0;for(b in c.Realms)""!=amtstack.RealmNames[c.Realms[b]]&&u++;0<=c.Realms.indexOf(20)&&(r+="Auditor, ");r=0<=c.Realms.indexOf(3)?r+"Administrator":1==u?r+"1 realm":r+(u+" realms")}else r+="Administrator",c.Handle=-1;a+="<divclass=itemBaronclick=showUserDetails("+c.Handle+")><divstyle=float:right>";0<n&&xxAccountAdminName&&(a+=""+AddButton2(1==n?"Disable":"Enable","changeAccountStateButton(event,"+c.Handle+","+n+")"));!g&&xxAccountAdminName&&(a+=""+AddButton2("Edit...",
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,g=d2permission.value,n=d2password1.value,r=GetSidByteArray(Q("d2username").value),u=null;if(0==d.length||n!=d2password2.value){messagebox("Account Error","Invalid Parameters");return}null==r?u=window.btoa(rstr_md5(d+":"+amtsysstate.AMT_GeneralSettings.response.DigestRealm+":"+n)):(d=null,r=btoa(r));if(-1!=a)for(var m in amtstack.RealmNames)(amtstack.RealmNames[m]||3==m)&&Q("rx"+m).checked&&c.push(m);null==a?amtstack.AMT_AuthorizationService_AddUserAclEntryEx(d,
function updateRealms(a){QV(37,null!=a);if(null!=a){var b="<li><label><inputtype=checkboxonchange=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><inputtype=checkboxonchange=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="<divstyle=text-align:left>",d,g=b.DigestUsername;g||(g=GetSidString(atob(b.KerberosUserSid)));c+=addHtmlValue("Name",g);xxAccountEnabledInfo[a]&&(c+=addHtmlValue("State",1==xxAccountEnabledInfo[a].Enabled?"Enabled":"Disabled"));if(g==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 "+g,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 g in c)b=c[g],a+="<h2>"+g+"</h2><divstyle=margin-left:20px>",a=200==b.status?0==b.responses.length?a+"<br>(Empty)":a+ObjectToString(b.responses).replace(/Intel\(r\)/g,"Intel®"):a+("<br><divstyle=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;
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=
c.AMT_RemoteAccessCredentialContext.responses;xxMPSUserPass=c.AMT_MPSUsernamePassword.responses;xxPolicies={User:[],Alert:[],Periodic:[]};for(var g in c.AMT_RemoteAccessPolicyAppliesToMPS.responses)b=c.AMT_RemoteAccessPolicyAppliesToMPS.responses[g],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],
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("Environmentdetection",addLink(b,"editEnvironmentDetection()"));a+=TableEntry("Userinitiationoptions",
else for(d in xxCiraServers)b=":"+xxCiraServers[d].Port,xxCiraServers[d].CN&&(b+=", "+xxCiraServers[d].CN),a+="<divclass=itemBaronclick=showServerDetails("+d+")><divstyle=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+="<divstyle=padding-left:15px><br><i>No proxies configured.</i></div><br>";else for(d in b)a+="<divclass=itemBaronclick=showProxyDetails("+
function editMpsPolicy(a){var b="",c=11<amtversion||11==amtversion&&6<=amtversion,d=xxEditMpsPolicyType=a;"User"==d&&(d="UserInitiated");vard=getItem(xxRemoteAccess.AMT_RemoteAccessPolicyRule.responses,"PolicyRuleName",d),b=b+"<divstyle=height:26px><selectid=d2server1style=float:right;width:206pxonchange=editMpsPolicyUpdate()><optionvalue=-1>(None)",g;for(g in xxCiraServers)b+="<optionvalue="+g+""+(xxPolicies[a][0]&&xxPolicies[a][0].Name==xxCiraServers[g].Name?"selected":"")+">"+xxCiraServers[g].AccessInfo;
for(g in xxCiraServers)b+="<optionvalue="+g+""+(xxPolicies[a][1]&&xxPolicies[a][1].Name==xxCiraServers[g].Name?"selected":"")+">"+xxCiraServers[g].AccessInfo;b+="</select><div>Secondary server</div></div>";c&&(b+="<divstyle=height:26px><selectid=d2server2cirastyle=float:right;width:206pxonchange=editMpsPolicyUpdate()><optionvalue=0>CIRA - External<optionvalue=1"+(xxPolicies[a][1]&&1==xxPolicies[a][1].MpsType?"selected":"")+">CILA - Internal</select><div>Secondary MPS Type</div></div>")}g=
0;d&&(g=d.TunnelLifeTime);b+="<divstyle=height:26px><inputid=d2lifetimestyle=float:right;width:200pxonchange=editMpsPolicyUpdate()value="+g+">";b+="<div>Tunnel lifetime (Seconds)</div></div>";"Periodic"==a&&(c=0,g=3600,d&&(d=atob(d.ExtendedData),c=ReadInt(d,0),g=ReadInt(d,4),1==c&&(d=ReadInt(d,8),10>d&&(d="0"+d),g+=":"+d)),b+="<divstyle=height:26px><selectid=d2ttypestyle=float:right;width:206pxonchange=editMpsPolicyUpdate()>",b+="<optionvalue=0"+(0==c?"selected":"")+">Periodic, time interval<optionvalue=1"+
(1==c?" selected":"")+">Time of day, once a day",b+="</select><div>Trigger type</div></div><divstyle=height:26px><inputid=d2timerstyle=float:right;width:200pxonkeyup=editMpsPolicyUpdate()value="+g+"><divid=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 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® 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+=
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)}functioneditEnvironmentDetectionAdd(){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+="<inputtype=radioname=d11id=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("AuthenticationType","User&Pass/Server-AuthTLS"),c+=addHtmlValue("RemoteID",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}
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","IPv4address","IPv6address"][Q("d2type").value])}functionAddRemoteAccessProxyOk(){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()}
c+="<divstyle=height:26pxid=d2ucn><inputid=d2cnstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Server Common Name</div></div>";c+="<divstyle=height:26px><selectid=d2authstyle=float:right;width:206pxonchange=AddRemoteAccessServerUpdate()>";0<a.length&&(c+="<optionvalue=1>Certificate");c+="<optionvalue=2>Username/Password</select><div>Authentication type</div></div>";c+="<spanid=d2utype>";c+="<divstyle=height:26px><inputid=d2userstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Username</div></div>";
c+="<divstyle=height:26px><inputid=d2passstyle=float:right;width:200pxonkeyup=AddRemoteAccessServerUpdate()><div>Strong Password</div></div>";c+="</span>";c+="<spanid=d2ctype>";c+="<divstyle=height:26px><selectid=d2certstyle=float:right;width:206pxonchange=AddRemoteAccessServerUpdate()>";for(b in a)c+="<optionvalue="+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='<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="InstanceID">Intel(r) AMT Certificate: Handle: '+Q("d2cert").value+
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":"IPv4Address");QV("d2utype",2==Q("d2auth").value);QV("d2ucn",
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><divstyle=height:26px><inputid=d11namevalue="'+b+'"style=float:right;width:200px><div>Name & Domain</div></div>';1==a&&(a=1==amtsysstate.AMT_GeneralSettings.response.SharedFQDN,b+="<divstyle=height:26px><selectid=d11fqdnstyle=float:right;width:200px><optionvalue=true"+(a?"selected":"")+'>Shared, same as OS<optionvalue="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® AMT Features",3,featuresDlgOk))}
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><spanstyle=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())}}
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=
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®AMTPingResponse",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,
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",
function powerActionDlgCheck(){var a=d5actionSelect.value;104==a||105==a?(a="Confirm execution of Intel® Remote Secure Erase?<br>Enter Secure Erase password if required.<br><br><divstyle=height:16px><inputtype=passwordid=rsepassmaxlength=32style=float:right;width:240px><div>Password</div></div><br><divstyle=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("d24dBiosSecureBoot",1==amtPowerBootCapabilities.BIOSSecureBoot);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);
function showAdvPowerDlgOk(){AvdPowerDlg={};AvdPowerDlg.Action=Q("c27").value;AvdPowerDlg.BIOSPause=Q("d24BiosPause").checked;AvdPowerDlg.BIOSSecureBoot=Q("d24BiosSecureBoot").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=
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.EnforceSecureBoot=AvdPowerDlg.BIOSSecureBoot,c.BIOSSetup=AvdPowerDlg.BIOSSetup,c.BootMediaIndex=AvdPowerDlg.BootMediaIndex,c.FirmwareVerbosity=AvdPowerDlg.FirmwareVerbosity,c.ForcedProgressEvents=AvdPowerDlg.ForcedProgressEvents,c.IDERBootDevice=AvdPowerDlg.IDERBootDevice,c.LockKeyboard=AvdPowerDlg.LockKeyboard,
function powerActionResponse3x(a,b,c,d){a=d5actionSelect.value;b=null;if(999==a)0<c29.value&&(b=["ForceCD/DVDBoot","ForcePXEBoot","ForceHard-driveBoot","ForceDiagnosticBoot"][c29.value-1]);else{if(300==a||301==a)b="ForceDiagnosticBoot";if(400==a||401==a)b="ForcePXEBoot"}console.log("ChangeBootOrder:"+b);amtstack.CIM_BootConfigSetting_ChangeBootOrder(null==b?b:'<Addressxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParametersxmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURIxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting</ResourceURI><SelectorSetxmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><SelectorName="InstanceID">Intel(r) AMT: '+
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",
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")}
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(v){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 g=a[b].app?a[b].app:"";c[d][g]||(c[d][g]={});a[b].name&&(c[d][g][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><tdclass=r1style=padding-left:15px><br>Manage Intel® AMT storage for this computer.<br><br>",n,r,g="";for(b in a){var u=0,m;for(m in a[b]){u++;var l=0,w;for(w in a[b][m]){l++;if(b!=n||m!=r)""!=g&&(d+=g,g="<br>"),n=b,r=m,g=""!=b?g+EscapeHtml(b+" / "+m):g+
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){if(!xxdialogMode){haltEvent(b);var c=window.open("http://"+wsstack.comm.host+":"+wsstack.comm.port+"/amt-storage/"+a,"_blank");c.opener=null;c.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><divstyle=height:20px><inputid=mstoragefilestyle=float:right;width:240pxreadonlydisabled=disabledvalue="'+b+'"><div>Upload file</div></div>'):c+"<br><divstyle=height:20px><inputtype=fileid=mstoragefilestyle=float:right;width:240pxonchange=SetStorageName()><div>Upload file</div></div>")+"<br><divstyle=height:16px><inputid=mstoragevendorplaceholder=Vendorlist=mstoragevendorlistmaxlength=11style=float:right;width:240px><div>Vendor name</div></div>";
c+='<br><divstyle=height:16px><inputid=mstoragelinkstyle=float:right;width:240px><divtitle="If set, creates a link to this content from the main web page">Link</div></div><br>';c+="<datalistid=mstoragevendorlist>";for(var d in xxStorageVendors)c+='<optionvalue="'+xxStorageVendors[d]+'">';c+="</datalist>";c+="<datalistid=mstorageapplicationlist>";for(d in xxStorageApplications)c+='<optionvalue="'+xxStorageApplications[d]+'">';c+='</datalist><datalistid=mstoragetypelist><optionvalue="application/octet-stream"><optionvalue="image/jpeg"><optionvalue="text/html"><optionvalue="text/plain"></datalist>';
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=
function PullAlarms(){var a=TableStart2()+"<tr><tdclass=r1style=padding-left:15px><br>Manage wake alarms.<br><br>";amtstack.Enum("IPS_AlarmClockOccurrence",function(b,c,d,g){if(200==g){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+="<divclass=itemBaronclick=showAlertDetails("+
b+")><divstyle=float:right>",xxAccountAdminName&&(a+=" "+AddButton2("Edit...","showAddAlarm("+b+")")),a+="</div><divstyle=padding-top:3px;width:auto;float:left;overflow-x:hidden>"+c+"</div></div>";else xxAlarms=null,a+="<divstyle=padding-left:15px><br><i>No wake alarms registered.</i></div><br>";d="<div> "+AddRefreshButton("PullAlarms()");xxAccountAdminName&&(d+=AddButton("Remove all alarms","RemoveAllAlarms()")+AddButton("Add","showAddAlarm()"));a+="<br><tdclass=r1>"+TableEnd(d+"</div>");
function prepareAlarmOccurenceTemplate(a,b,c,d,g){return'<d:AlarmTemplatexmlns: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:StartTime><p:Datetimexmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+c+'</p:Datetime></s:StartTime><s:Interval><p:Intervalxmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Interval></s:Interval><s:DeleteOnCompletion>"+g+
"</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,g,n){0==--a&&PullAlarms()})}
function showAddAlarmOk(a,b){if(2==a)showAlertDetailsDelete(a,b);else{var c=Q("d25alarm_name").value,d=Q("d25alarm_sdate").value.split("-"),g=Q("d25alarm_stime").value.split(":"),d=new Date(d[0],d[1]-1,d[2],g[0],g[1],g[2],0),d=_fmttimepad(d.getUTCFullYear())+"-"+_fmttimepad(d.getUTCMonth()+1)+"-"+_fmttimepad(d.getUTCDate())+"T"+_fmttimepad(d.getUTCHours())+":"+_fmttimepad(d.getUTCMinutes())+":"+_fmttimepad(d.getUTCSeconds())+"Z",g=Q("d25alarm_interval").value.split("-");3!=g.length&&(g=[0,0,0]);var g=
"P"+g[0]+"DT"+g[1]+"H"+g[2]+"M",n=1==Q("d25alarm_doc").value,c=prepareAlarmOccurenceTemplate(c,c,d,g,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+".<br/>Verify the alarm is for a future time."):0!=c.Body.ReturnValue?messagebox("Add alarm","Failed to add alarm, "+c.Body.ReturnValueStr+".<br/>Verify the alarm is for a future time."):PullAlarms()}):(c=Clone(xxAlarms[b]),
c.StartTime='<p:Datetimexmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+d+"</p:Datetime>",c.Interval='<p:Intervalxmlns:p="http://schemas.dmtf.org/wbem/wscim/1/common">'+g+"</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+".<br/>Verify the alarm for at a future time."):PullAlarms()},null,null,{InstanceID:c.InstanceID}))}}
function script_onScriptRead(a){var b;try{b=JSON.parse(a.target.result)}catch(g){}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=void0))}functionscript_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)}functionscript_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+="<divid=sblock_"+c+'style=cursor:pointer;background-color:#ccc;width:auto;padding:5px;margin:2pxondblclick=script_faddblock("'+c+'")draggable=trueondragstart=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 g in d.vars){var n=d.vars[g];c+="##!VAR!##\r\n#id="+g+"\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 r in n.values)c+="#values-"+r+"="+n.values[r]+"\r\n";c+="#value="+n.value+"\r\n##SWAP %%%"+g+"%%% "+
function script_fConvertScriptToJsonBlock(a){var b={};a=a.split("##!BLOCK!##\n");var c=a[1].split("\n"),d;for(d in c){var g=c[d].split("=");2==g.length&&(b[g[0].substring(1)]=g[1])}b.vars={};scriptvariables=a[2].split("##!VAR!##\n");for(d in scriptvariables){var c=scriptvariables[d].split("\n"),n={},r={},u=0,m;for(m in c)g=c[m].split("="),2==g.length&&g[1]&&g[0]&&0<g[0].length&&("#values-"==g[0].substring(0,8)?(r[g[0].substring(8)]=g[1],u++):n[g[0].substring(1)]=g[1]);n.id&&(0<u&&(n.values=r),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"),g=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),g>d&&g--),"scriptblocks"==b.id?(c&&script_BlockScript.push(c),script_BlockScriptSelectedId=script_BlockScript.length-
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 g in b.vars){var n=b.vars[g].value,r="";b.vars[g].maxlength&&(r+=" maxlength="+b.vars[g].maxlength);2==b.vars[g].type&&(r+=" onkeypress='return numbersOnly(event)'");if(1==b.vars[g].type||2==b.vars[g].type)n="<inputtitle='"+b.vars[g].desc+"'id=scriptXvalue_"+g+"value='"+b.vars[g].value+"'"+r+"style=width:100%></input>";
if(3==b.vars[g].type){var n="<selecttitle='"+b.vars[g].desc+"'id=scriptXvalue_"+g+"style=width:100%;padding:0;margin:0>",u;for(u in b.vars[g].values)n+="<optionvalue="+u+(u==b.vars[g].value?"selected":"")+">"+b.vars[g].values[u]+"</option>";n+="</select>"}4==b.vars[g].type&&(n="<inputtype=passwordautocomplete=offtitle='"+b.vars[g].desc+"'id=scriptXvalue_"+g+"value='"+b.vars[g].value+"'"+r+"style=width:100%></input>");5==b.vars[g].type&&(n="");6==b.vars[g].type&&(n="<inputtype=filetitle='"+
b.vars[g].desc+"' id=scriptXvalue_"+g+" "+r+" style=width:100%></input>");d+='<tablestyle=width:100%title="'+b.vars[g].desc+'"><tdstyle=width:120px>'+b.vars[g].name+"<td><b>"+n+"</b></table>";if(5==b.vars[g].type){var d=d+("<ulid=scriptXvalue_"+g+'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">'),m;for(m in b.vars[g].values)n="",0<=b.vars[g].value.indexOf(m)&&(n=" checked"),d+="<li><label><inputtype=checkboxid=scriptXvaluex_"+
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 g in c.vars[d].values)Q("scriptXvaluex_"+d+"-"+g).checked&&c.vars[d].value.push(g)}else if(6==c.vars[d].type){var n=Q("scriptXvalue_"+d);if(1==n.files.length){var r=new FileReader;r.onload=function(a){c.vars[d].value=btoa(a.target.result);
function fupdatescript(){var a="",b;for(b in script_BlockScript){a+="<divid=xblock_"+b+"style=cursor:pointer;min-height:24px;background-color:#"+(script_BlockScriptSelectedId==b?"aaa":"ccc")+';width:auto;padding:5px;margin:2pxdraggable=trueonclick=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+
"</div></div>"}""==a&&(a='<divstyle="padding:15px;color:gray">Start your script by drag & dropping blocks from the left side into this scripting box.<div>');QH("scriptblocks",a+"<divstyle=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=
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,
function script_saveScript(a){xxdialogMode||scriptstate||(a&&1==a.shiftKey?(setDialogMode(11,"Script Block",1,null,"<br><textareaid=scriptSaveScriptJsonBlockstyle=width:100%;height:200px;resize:vertical/>"),QH("scriptSaveScriptJsonBlock",script_fConvertScriptToJsonBlock(Q("scriptarea").value))):setDialogMode(11,"Save Script",3,script_saveScriptOk,"<br><inputid=scriptsavenamestyle=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,g,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);g&&(11==a?QH(39,g):QH(36,g))}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 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/><inputtype=buttonvalue="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 TableEntry(a,b){return"<tr><tdclass=r1><p>"+a+"<tdclass=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><tdcolspan=2><p>"+(a?a:"")+"</table>"}function AddButton(a,b){return"<inputtype=buttonvalue='"+a+"'onclick='"+b+"'style=margin:4px>"}function AddButton2(a,b,c){return"<inputtype=buttonvalue='"+a+"'onclick='"+b+"'"+c+">"}
function AddRefreshButton(a){return"<inputtype=buttonname=refreshbtnvalue=Refreshonclick='refreshButtons(false);"+a+"'style=margin:4px"+(0==refreshButtonsState?"disabled":"")+">"}function MoreStart(){return'<astyle=cursor:pointer;color:blueid=morexxx1onclick=QV("morexxx1",false);QV("morexxx2",true)>▼ More</a><divid=morexxx2style=display:none><br><hr>'}
function MoreEnd(){return'<astyle=cursor:pointer;color:blueonclick=QV("morexxx2",false);QV("morexxx1",true)>▲ Less</a></div>'}function getSelectedOptions(a){for(var b=[],c,d=0,g=a.options.length;d<g;d++)c=a.options[d],c.selected&&b.push(c.value);returnb}functiongetInstance(a,b){for(varcina)if(a[c].InstanceID==b)returna[c];returnnull}functiongetItem(a,b,c){for(vardina)if(a[d][b]==c)returna[d];returnnull}
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));returnb}
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'<divstyle=height:20px><divstyle=float:right;width:220px;overflow:hidden><btitle="'+b+'">'+b+"</b></div><div>"+a+"</div></div>"}
function addHtmlValueNoTitle(a,b){return"<divstyle=height:20px><divstyle=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();