var UnisignWebEngine=function(w,da){function Qa(){eval(H({eval:!1,intergrity:!0,name:"browsersign",url:"unisignweb/js/browsersign.js"}));return eval("__crosscertlocalstorage")(a)}function gb(){eval(H({eval:!1,intergrity:!0,name:"cloudsign",url:"unisignweb/js/cloudsign.js"}));return eval("__crosscertcloudsign")(a)}function hb(){eval(H({eval:!1,intergrity:!0,name:"whale",url:"unisignweb/js/whale.js"}));return eval("__crosscertwhale")(a)}function H(a){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",u.SRCPath+a.url+"?version=1.0.4.9",!1);b.send(null);if(200==b.status){if(!0===a.intergrity){var c={};c.name=a.name+".js";c.data=b.responseText;S[Ra++]=c}return null==a.eval||1==a.eval?eval(b.responseText):b.responseText}404!=b.status&&(M=!1);return null}function n(b,d){var c={};c.resultCode=b?b:0;c.resultMessage=d?d:"";c.jsonSignedData="";c.certAttrs="";c.certIndex="";c.b64RValue="";c.hashValue="";c.encryptedData="";c.decryptedData="";c.signedData="";c.theCert="";c.theDN="";c.thePri="";c.kmCert="";c.kmPri="";c.pfx="";c.curDrive="";c.curDevice="";c.tokenLabel="";c.password="";c.pin="";c.mac="";a.ERROR.Code=b;a.ERROR.Message=d;return c}function ma(b){return"1.2.840.113549.1.1.5"==b.signatureOid||"1.2.410.200004.1.9"==b.signatureOid?a.usWebToolkit.md.sha1.create():"1.2.840.113549.1.1.4"==b.signatureOid?a.usWebToolkit.md.md5.create():"1.2.840.113549.1.1.11"==b.signatureOid||"1.2.840.113549.1.1.10"==b.signatureOid?a.usWebToolkit.md.sha256.create():null}function N(b,d,c,e,g,f,h,k,l,p){if(b)Sa(0,b,d,c,e,g,f,h,k,l,p);else{var t=a.loadUI("ssn")({type:null,onConfirm:function(a){Sa(1,a,d,c,e,g,f,h,k,l,p);t.dispose()},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();k(n(a.ERROR.Code,a.ERROR.Message));t.dispose();ClearAllUserCertList()}});t.show()}}function Sa(b,d,c,e,g,f,h,k,l,p,t){a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_VID_VERIFY_MESSAGE);var m=n();m.certAttrs=f;m.curDevice=h;m.tokenLabel=k;if("undefined"!==typeof c&&"undefined"!==typeof e)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(h))if(h!=a.CONST.__USFB_M_DISK.device&&h!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(h==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");b=a.usWebToolkit.pki.certificateFromBase64(t);p=a.usWebToolkit.util.decode64(p);var r=a.usWebToolkit.pkcs8.verifyVIDForHSM(p,d,b);r?(m.signedData=g,l(m)):(a.ERROR.Code=14208,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID,l(n(14208,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))}else a.nimservice()?a.nimservice().VerifyVID(c,e,b,d,function(b,d){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?(m.signedData=g,l(m)):(4305E4==b&&(b=14208),a.ERROR.Code=b,a.ERROR.Message=d,l(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))}):(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_NIM_ERROR_UNLOAD,a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"),l(n(a.ERROR.Code,a.ERROR.Message)),ClearAllUserCertList());else a.Whale().verifyVID(c,e,d,function(b,d){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?(m.signedData=g,l(m)):(3061==b&&(b=14208),a.ERROR.Code=b,a.ERROR.Message=d,l(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))});else{a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");try{var q=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[c].signcert),x=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri);r=a.usWebToolkit.pkcs8.verifyVID(x,e,d,q);e=d="";r?(m.signedData=g,l(m)):(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_VID_ERROR_VERIFICATION,l(n(a.ERROR.Code,a.ERROR.Message)))}catch(v){e=d="",a.ERROR.Code=v.code,a.ERROR.Message=v.message,l(n(v.code,v.message))}e=d=""}}function ha(b,d,c,e,g,f,h){function k(d){var c="",e;for(e in b)""!=b[e]&&(c+=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[e])),c+="|");a.Whale().normalizeXML(c,function(c,e,f){if(0!=c)a.ERROR.Code=c,a.ERROR.Message=e,a.uiUtil().loadingBox(!1,"us-div-list-load"),d(n(c,e));else{c=f.split("|");e={};f=0;for(var g in b)e[g]=""==b[g]?"":c[f++];d(e)}})}var l=n();if("undefined"!==typeof c&&"undefined"!==typeof e){var p={},t=0;"sha256WithRSAEncryption"!=d.signAlgo&&(t=1);var m=H({eval:!0,intergrity:!1,name:"xml_template_"+u.Language,url:"unisignweb/rsrc/lang/"+u.Language+"/xml_template_"+u.Language+".js"}),r="sha1";1!=t&&(r="sha256");k(function(k){for(var q in k)if(!(null==k[q]||0>=k[q].length||"undefined"==k[q]||"undefined"==b[q])){var v=k[q].split(";"),y={};y.key=q;y.plainText=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(v[0]));var n=a.usWebToolkit.md.algorithms[r].create();n.start();n.update(a.usWebToolkit.util.decode64(v[1]));v=a.usWebToolkit.util.encode64(n.digest().getBytes());y.Signature=m.XMLSignatureTemplate[t].replace("$$DV$$",v);y.SignedInfo=m.XMLSignedInfoTemplate[t].replace("$$DV$$",v);y.Signature=y.Signature.replace("$$Cert$$",g);b[q]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(y.SignedInfo));p[q]=y}a.Whale().getSignDataP1(b,c,e,function(b,g,k){l.resultCode=b;l.resultMessage=g;if(0!=b)a.ERROR.Code=b,a.ERROR.Message=g,h(l);else{"string"==typeof k&&(k=[k]);for(var q in k)""!=k[q]&&(p[q].Signature=p[q].Signature.replace("$$Sign$$",k[q]),b=p[q].plainText.substr(0,p[q].plainText.indexOf(m.KEY_START)),b+=p[q].Signature,b+=p[q].plainText.substr(p[q].plainText.indexOf(m.KEY_START),p[q].plainText.length),k[q]=b);l.signedData=k;l.certAttrs=d;l.tokenLabel="";f?a.Whale().getCertR(c,e,function(b,c,d){a.uiUtil().loadingBox(!1,"us-div-list-load",1);if(0==b)try{var e=a.usWebToolkit.util.hexToBytes(d),g=a.usWebToolkit.pki.certificateFromBase64(f),k=a.usWebToolkit.pkcs7.createEnvelopedData();k.addRecipient(g);k.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];k.content=e;k.encrypt();l.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(k);h(l)}catch(O){h(l)}else h(l)}):h(l)}})})}else h(null);return!0}function Ua(b){try{var d=a.PFSH.GetP12ForBuToPc(1,b,"binary"),c=d.p12,e=a.certUtil().getCN(d.dn);e+=".p12";a.fileUtil().save(e,c)}catch(g){alert("failure\nerr code : "+g.code+"\nerr msg : "+g.message)}}function Va(){var b=null,d=null,c=null;try{b=a.PFSH.GetP12ForBuToMo(1,"hex"),d=b.key,c=b.p12}catch(f){alert("failure\nerr code : "+f.code+"\nerr msg : "+f.message);return}try{b="default";"android"===a.osName?"android samsung"===a.browserName||"android lg"===a.browserName||"android browser"===a.browserName?b="default":"android chrome"===a.browserName&&(b="chrome"):"ios"==a.osName&&("ios safari"===a.browserName?b="default":"ios chrome"===a.browserName&&(b="googlechrome"));var e=window.location.href.split(/[?#]/)[0],g=e.lastIndexOf("/");e=e.substr(0,g+1)+a.ESVS.SRCPath+"unisignweb/rsrc/layout/mobile/w2a/m_exportcertresult.html";UniSignW2A.backupStore(e,b,c,d,"0","recall")}catch(f){alert("failure\ne : "+f)}}function Wa(b){try{a.CCPFSH().GetP12ForBuToPc(1,b,"base64",function(b,c,e,g){b=a.usWebToolkit.util.decode64(g);c=Array(b.length);for(g=0;gc||0>e)return-1;c==a.CONST.__PF_M_SS.device?ib(b,d,function(a){h(a)}):a.nimservice().ImportCertEx(c,e,g,f,b,d,function(a,b){h(n(a,b))});return-1}function ab(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return!1;var c=n();a.reInitialize();Dialog=a.loadUI("storageselect")({type:"CERT_STORAGE",args:{possibleWhale:!1},onConfirm:function(e,g){Dialog.dispose();2===e||3===e?(PWDialog=a.loadUI("password")({type:null,args:null,onConfirm:function(f){PWDialog.dispose();var h=null;h=2===e?"PIN_SECURITY_TOKEN":"PIN_SAVE_TOKEN";PINDialog=a.loadUI("pin")({type:h,args:null,onConfirm:function(a){PINDialog.dispose();c.curDevice=e;c.curDrive=g;c.password=f;c.pin=a;b(c);f=null},onCancel:function(){PINDialog.dispose();f=null;a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}});PINDialog.show()},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}}),PWDialog.show()):(c.curDevice=e,c.curDrive=g,c.password=null,c.pin=null,b(c))},onCancel:function(){Dialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}});Dialog.show()}}function jb(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d&&!c||document.getElementById("us-div-cert-select")||!g)return!1;var h=n();b||(b="DIGITAL_SIGNATURE_P7_EXT");a.reInitialize();var k=a.loadUI("certselect")({type:b,args:{dn:e,possibleWhale:!1},onConfirm:function(b,d,e,f,r){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r))a.nimservice()?a.nimservice().GetSignDataP7(d,e,c,"utf8",!0,null,!0,!1,function(b,c,q,m,p,l){0!=b?(a.ERROR.Code=h.resultCode=b,a.ERROR.Message=h.resultMessage=c,a.uiUtil().errMsgBox(c,a.ERROR.Code)):(h.signedData=q,h.certIndex=d,h.password=e,h.curDevice=f,h.curDrive=r,h.tokenLabel=l);g(h);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10)}):(setTimeout(function(){k.dispose(!0)},10),g(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)));else try{var q=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[d].signcert),m=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[d].signpri),p=a.usWebToolkit.pkcs7.createSignedData(),l=a.usWebToolkit.util.decode64(c);p.signForTransfer(l,q,m,e);h.signedData=a.usWebToolkit.pkcs7.messageToBase64(p);h.certIndex=d;h.password=e;h.curDevice=f;h.curDrive=r;h.tokenLabel="";setTimeout(function(){k.dispose(!0)},10);g(h)}catch(G){a.ERROR.Code=G.code,a.ERROR.Message=G.message,112047==G.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD),setTimeout(function(){k.dispose(!0)},10),g(n(G.code,G.message))}},onCancel:function(b){k.dispose(!0);b?h.resultCode=-2:a.uiUtil().getUserCancelErrCodeNMsg(h);g(h)}});k.show();return!0}}function na(b,d,c,e,g,f,h,k,l,p){var t={},m=n();if("undefined"!==typeof e&&"undefined"!==typeof g)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(f))if(f!=a.CONST.__USFB_M_DISK.device&&f!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(f==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){l={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(c){c=JSON.parse(c);if(0!=c.returnObj.returnCode&&"E1000"!=c.returnObj.returnCode)m.resultMessage=a.ERROR.Message=c.returnObj.returnMsg,m.resultCode=a.ERROR.Code=c.returnObj.returnCode,setTimeout(function(){k.dispose(!0)},10),p(m);else if("E1000"==c.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(m),setTimeout(function(){k.dispose(!0)},10),p(m);else{var q=c.signResult.b64Signer;_certAttrs=a.certUtil().getTheCertAttributes(q,"Base64");B(e,g,f,q,_certAttrs);m.certAttrs=_certAttrs;var r=c.signResult.b64SignedData;q=a.usWebToolkit.pki.certificateFromBase64(q);if(1==r.length){var l=c.signResult.b64SignedData[0];l=a.usWebToolkit.util.decode64(l);var x=a.usWebToolkit.pkcs7.createSignedData();x.signWithHashDataNP1(l,a.usWebToolkit.util.decode64(b),d.toLowerCase(),q);m.jsonSignedData=a.usWebToolkit.pkcs7.messageToBase64(x)}else{r=0;m.jsonSignedData={};for(var v in b)""==b[v]?m.jsonSignedData[v]="":(l=c.signResult.b64SignedData[r++],l=a.usWebToolkit.util.decode64(l),x=a.usWebToolkit.pkcs7.createSignedData(),x.signWithHashDataNP1(l,a.usWebToolkit.util.decode64(b[v]),d.toLowerCase(),q),m.jsonSignedData[v]=a.usWebToolkit.pkcs7.messageToBase64(x))}if(h)try{var y=a.usWebToolkit.util.decode64(c.signResult.R[0]),t=a.usWebToolkit.pki.certificateFromBase64(h),n=a.usWebToolkit.pkcs7.createEnvelopedData();n.addRecipient(t);n.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];n.content=y;n.encrypt();m.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(n)}catch(kb){}m.curDevice=f;m.tokenLabel="";p(m);setTimeout(function(){k.dispose()},10)}},multisignYn:"Y",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};if("object"==typeof b){l.multisignYn="Y";for(var r in b)if(""!=b[r]){var q=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.util.decode64(b[r]));l.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+q))}}else l.multisignYn="N",q=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.util.decode64(b)),l.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+q));jSmartCertNP.SignByJSON(l).Open()}else if(a.nimservice()){q=0;var x=[];if(b)for(r in b)x[q]=b[r],q++;l=1==l?1:0;a.nimservice().GetSignDataP7WithHash(e,g,d,x,"utf8",!1,h,a.ESVS.multiuse,l,function(d,h,q,r,l,x){if(0!=d)a.ERROR.Code=d,a.ERROR.Message=h,a.uiUtil().errMsgBox(h,a.ERROR.Code),p(n(a.ERROR.Code,a.ERROR.Message));else{d=0;if("object"==typeof q)for(var G in b)t[G]=q[d++];else t=q;q=null;q=a.CONST.__USFB_M_MOBILETOKEN.device==f?a.certUtil().getTheCertAttributes(l,"Base64"):a.certUtil().getTheCertAttributes(c,"Base64");m.jsonSignedData=t;m.b64RValue=r;m.tokenLabel=x;m.certAttrs=q;p(m)}e=g=v=y=null;a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k&&k.dispose()},10)})}else p(null),setTimeout(function(){k&&k.dispose(!0)},10);else-1==e||""==g?(p(null),setTimeout(function(){k&&k.dispose(!0)},10)):a.Whale().getSignDataP7_noConWithHash(b,e,g,d,l,function(b,d,f){0!=b?(a.ERROR.Code=b,a.ERROR.Message=d,a.uiUtil().errMsgBox(d,a.ERROR.Code),p(n(b,d))):(m.jsonSignedData=f,m.tokenLabel="",m.certAttrs=a.certUtil().getTheCertAttributes(c,"Base64"),h?a.Whale().getCertR(e,g,function(b,d,c){a.uiUtil().loadingBox(!1,"us-div-list-load",1);if(0==b)try{var e=a.usWebToolkit.util.hexToBytes(c),f=a.usWebToolkit.pki.certificateFromBase64(h),g=a.usWebToolkit.pkcs7.createEnvelopedData();g.addRecipient(f);g.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];g.content=e;g.encrypt();m.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(g)}catch(kb){}p(m);setTimeout(function(){k.dispose()},10)}):(p(m),setTimeout(function(){k.dispose()},10)));e=g=v=y=null;a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k&&k.dispose()},10)});else{a.uiUtil().loadingBox(!0,"us-div-list-load");try{var v=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[e].signcert),y=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[e].signpri);q=a.usWebToolkit.pkcs8.decryptPrivateKeyInfo(y,g);x=a.usWebToolkit.pkcs8.getPrivateKeyAttributesRandom(q)}catch(D){a.ERROR.Code=D.code;a.ERROR.Message=D.message;a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code);p(n(D.code,D.message));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k&&k.dispose(!0)},10);return}try{if(b)for(r in b){var G=a.usWebToolkit.pkcs7.createSignedData();G.signWithHashData(a.usWebToolkit.util.decode64(b[r]),d.toLowerCase(),v,y,g,null,null,l);t[r]=a.usWebToolkit.pkcs7.messageToBase64(G)}}catch(D){a.ERROR.Code=D.code;a.ERROR.Message=D.message;a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code);p(n(D.code,D.message));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k&&k.dispose(!0)},10);return}m.jsonSignedData=t;if(h)try{var z=a.usWebToolkit.pki.certificateFromBase64(h),A=a.usWebToolkit.pkcs7.createEnvelopedData();A.addRecipient(z);A.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];A.content=x;A.encrypt();m.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(A)}catch(D){}m.curDevice=f;m.certAttrs=a.certUtil().getTheCertAttributes(a.PFUC[e].signcert,"Base64");p(m);e=g=v=y=null;a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k&&k.dispose(!0)},10)}else p(null),setTimeout(function(){k&&k.dispose(!0)},10)}function U(){4&a.ESVS.Mode&&a.nimservice()&&a.nimservice().ClearAllUserCertList(function(a,d){})}function oa(){2>=L||a.nimservice().checkInstall(function(b){u.chkEXESetup=a.ESVS.chkEXESetup=b;1==b?a.changeDefaultMedia():null==a.Whale()||"harddisk"!=ja&&"removable"!=ja||a.changeDefaultMedia()})}if(w&&da){var L=w.Mode,X=w.EncAlgo,Y=w.HashAlgo,Z=w.SecureKeyboardType,Aa=w.PKI,Ba=w.SRCPath,C=w.Language,V=w.TargetObj,ka=w.TabIndex,K=w.Embedded,ea=w.LimitNumOfTimesToTryToInputPW,Ca=w.CMPIP,pa=w.CMPPort,aa=w.CMPURL,la=w.SHARESTORAGE,qa=w.NimCheckURL,I=w.Media,Da=w.Organization,ra=w.Policy,sa=w.ShowExpiredCerts,Q=w.LimitMinNewPWLen,R=w.LimitMaxNewPWLen,ba=w.LimitNewPWPattern,Ea=w.ChangePWByNPKINewPattern,ta=w.CertRequestPageEnable,Fa=w.CertFindBtnEnable,Ga=w.SDInstallURL,Ha=w.IssueCertInBIOToken,lb=w.License,ua=!1,bb=!1,va=1E4,ja=w.afterSetupDefaultDevice,mb=w.iraq,nb=w.installPageOpenOption,Ia=w.TransServerIP,wa=w.TransServerPort,Ja=w.TransCfmWindowFlag,fa=!0;w.ShowGuide&&(bb=!0);1E4L||6wa||!wa)wa=443;u.TransServerPort=wa;Ja||(Ja=!1);u.TransCfmWindowFlag=Ja;Aa||(Aa="NPKI");u.PKI=Aa;u.BSPKI="NPKI";if(C){X=C.split("-");if(2ka||!ka)ka=0;u.TabIndex=ka;K||(K=!1);u.Embedded=K;if(0>=ea||10pa||!pa)pa=4502;u.CMPPort=pa;aa||(aa="http://ca.crosscert.com:9992/webcmp/");u.CMPURL=aa;I?(I.list=I.list?I.list.toLowerCase():null,I.defaultdevice?(I.defaultdevice=I.defaultdevice.toLowerCase(),null!=I.list&&(I.defaultdevice=0>I.list.indexOf(I.defaultdevice)?I.list.split("|")[0]:I.defaultdevice)):I.defaultdevice=null):(fa=!1,I=2==L?{defaultdevice:"browsersign",list:"cloudsign|browsersign"}:6==L?{defaultdevice:"harddisk",list:"harddisk|removable|sectoken|savetoken|mobilephone|cloudsign|browsersign"}:{defaultdevice:"harddisk",list:"harddisk|removable|sectoken|savetoken|mobilephone"});if(void 0==I.defaultdevice||null==I.defaultdevice)I.defaultdevice=2==L?"browsersign":"harddisk";-1!=I.list.indexOf("browsersign")?(la=w.SHARESTORAGE?w.SHARESTORAGE:"https://browsersign.crosscert.com",document.writeln("")):la="";u.SHARESTORAGE=la;0<=u.PKI.indexOf("MilPKI")&&(I.defaultdevice="harddisk",I.list="harddisk");u.Media=I;Da||(Da=null);u.Organization=Da;ra||(ra=null);u.Policy=ra;"boolean"!==typeof sa&&(sa=!0);u.ShowExpiredCerts=sa;if("NPKI"===u.PKI){if(10>Q||64R||64R)R=64;u.LimitMaxNewPWLen=R;ba=2}else{if(8>Q||64R||64R)R=64;u.LimitMaxNewPWLen=R;if(0>ba||2=a.pubkey.length?"":GetEncDataFun(a.pubkey,b,d)},GetDecryptPwd:function(b,d){b=GetEncDataFun("-----BEGIN CERTIFICATE-----MIIDZzCCAk+gAwIBAgIBATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJLUjESMBAGA1UEChMJQ3Jvc3NDZXJ0MQ4wDAYDVQQLEwVTVExhYjEXMBUGA1UEAxMOQ3Jvc3NDZXJ0V2ViVjMwHhcNMTQwNjI1MDAwMDAwWhcNMjkxMjMxMjM1OTAwWjBKMQswCQYDVQQGEwJLUjESMBAGA1UEChMJQ3Jvc3NDZXJ0MQ4wDAYDVQQLEwVTVExhYjEXMBUGA1UEAxMOQ3Jvc3NDZXJ0V2ViVjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIm9p0HiCrpFVSfRVdnC3V4kEC75F8bUWV/Ewa7TmuirbVOYsdtSpz+Yceh+Tindducrf6zGNlhhNpyhFQ6+4/f0qLdwALapojECOUQg/lISRD2FO88hEhBj/rOjZiVzHYyHm8K2bTtBJXNauBBCb1yUKNdHuAvw4xub/jcgZ2PRtWORrQwuStcGBSSnqCIHZcGb5KKdHtY15ppcZoZBXB75kKKdK8qJm/6A/bBW0S+o3ooN+oaGrFFEVH61AHi45sBHGO4e1oyRT8dfIgKUzUQOKSZ1r3Wln4CSqQR8tZOd/T+LzzSB7r4N/rzNo3T4oO5O6lkQBw3NZg25nMXBj7AgMBAAGjWDBWMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFJ7NboZBgBMwRmav8MSGpsMab+NjMA4GA1UdDwEB/wQEAwIGwDAXBgNVHSAEEDAOMAwGCiqDGoyaRAUEAQEwDQYJKoZIhvcNAQELBQADggEBAIU2d1CH6vsZaTAeSCdBM1tKcl/8YpnUSqt3w6DB45E9akGCODgEI1K/KPtRIhrjBBYopQJN9Z3F411xiw2Te0LJQKA9snAtRZCEbL/1FzjyUXKEv5QB9Zgch4KvbqhOdVb1bJsztJH1kV/lbeNbil2TI1NntWbKyPWDKlzdPsGbSAgaFkUtbt7fxcGJBoXAEsaohtNiDM3chfJWv4d0dlDito5isOMIMDN+bfLcBp745T+wEpig6bfbVZnDjzGbXhJJjVvFKydQrZfrLBnVLCpElD1xN1Ipw+6UGJXEuxqXS51drnG9jVU1FL9JDtDE7BNByXV2V9y9b1/6PSeSYMw=-----END CERTIFICATE-----",b,d);if(0>=b.length)return"";b=a.usWebToolkit.util.decode64(b);d=b.substr(0,256);b=b.substr(256,b.length);var c=a.usWebToolkit.pki.privateKeyFromBase64("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDIm9p0HiCrpFVSfRVdnC3V4kEC75F8bUWV/Ewa7TmuirbVOYsdtSpz+Yceh+Tindducrf6zGNlhhNpyhFQ6+4/f0qLdwALapojECOUQg/lISRD2FO88hEhBj/rOjZiVzHYyHm8K2bTtBJXNauBBCb1yUKNdHuAvw4xub/jcgZ2PRtWORrQwuStcGBSSnqCIHZcGb5KKdHtY15ppcZoZBXB75kKKdK8qJm/6A/bBW0S+o3ooN+oaGrFFEVH61AHi45sBHGO4e1oyRT8dfIgKUzUQOKSZ1r3Wln4CSqQR8tZOd/T+LzzSB7r4N/rzNo3T4oO5O6lkQBw3NZg25nMXBj7AgMBAAECggEATCIZ/geRDpMHbo7aFPS40HtVgO+6nyY5Snq9x1pQkdVDHhkAmv2uZuVESmn4i6irodcXy67V6inAJF3zxGpFuQNuHw/CjJKgfL4bQqDvt12kjbsDzKlxpr7gcz1cdmXxHPy4dpliJOYqL77Gn+gbgRwojdavKGVZ1bVRBdi4axaImRM8khRckQnQbypLuFAIoptbKLo940P/LC3lFmVZDvDW0I4CG/gvTpxdDo58y7jeMngeklJDJ+aKv1Ji6Cqo0eSNhjz1hBm6Go1eob/7JxyZ07Vykr9y718SoHhjGMDlX6zoR1NV0/bYDuwRhddcokvJxGvFKudSNgZI7tVpQQKBgQD/IT8wPbbwyftCZsYdnqCLKhyoxg492ci5aLKfHZNVhOatFlIPKCqvWDVAQPqMIisFk1X7PNajEK8y2SOwy6rhy36fqrAf9WC8yYpUiInf4SdItHoQiCKDq0vmae/Jua4Rwmiut2L4soLyTTXvQ7b51Hv+ZkcuDHqewvGca1YZLQKBgQDJSwEasIPwNbvANIajgsrB6jpegtEn58dpzF0dM9ErEts+xhf2h3VRglbhRm3mroy72Dul+urmUD/9tGNOmF9ON3teVmBzmvB5QZUlDaHtfoHA5MTL35f0Hpt8T7sGzIu97HxLSbD5WuoIPSMO/1yX3m4Vi7oJfgctWfojso8DxwKBgQCS7yLlNaXWp3z9kRMom+L6QxaeXPJ2zKa9oX6+BNqFtjTkGqbH8+ohcju49bNWYZdFbsVmHHPBFirQrh3QBHw17mzOqA8nWLqN/8SbSsedGJ73UHm8a6r1CgJ8gSaIl1eZAs4nUZa+hJDF25HkaqtG1wlSSrVT3/v+02czHt5HQQKBgQC6klKLsmAYHTXQiN7iXzAfXEKNpyLFogcrAMitcIHHMssT+/fqANO0oOJ2GxlyXwcCdQGUbmWa43bsaG5DQufTT4mBfv4XKN0LBsZ+eYxE3KTXbTMa5DurgVMMfboUKzK67p6mCb+G38VbrY75L6da/Ed8oO3mLnHojyVSQQZdsQKBgAar8TGlK5fe+TKFa81jR5n8pD9rVHpLoagsjK3ueA7tnRHwXHxVTItGU/S9HyZxPuA1EA9VVSol73a924Q569sFd/sd9rJCF5Z3EUmM3IXKpfEhA5E5lJ9ZkqjjWVgNiu2cJG4MDdAB3FSJ0tB+WjAHUrXWkQrF7D+Av0XUP0uB").decrypt(d);if(32>c.length)return"";d=c.substr(0,16);c=c.substr(16,c.length);d=a.usWebToolkit.cipher.algorithms.seed.startDecrypting(d,c);d.update(a.usWebToolkit.util.createBuffer(b));d.finish();return d.output.getBytes()},GetEnvelopedPwd:function(b){if(null==b||0>=b.length)return"";var d=a.usWebToolkit.pki.certificateFromBase64(a.ESVS.CertforKeyboard),c=a.usWebToolkit.pkcs7.createEnvelopedData();c.addRecipient(d);c.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];c.content=a.usWebToolkit.util.createBuffer(b);c.encrypt();return a.usWebToolkit.pkcs7.messageToBase64(c)}};var La=function(){this._errormsglang=eval(eval(function(){return H({eval:!1,intergrity:!1,name:"errormsg_"+u.Language,url:"unisignweb/rsrc/lang/"+u.Language+"/errormsg_"+u.Language+".js"})})())};La.prototype={isValidDevice:function(b){for(var d in a.CONST.medias)if(a.CONST.medias[d].device===b)return!0;return!1},getMediaName:function(b){var d="",c;for(c in a.CONST.medias)if(a.CONST.medias[c].device===b){d=a.CONST.medias[c].name;break}return d},getMediaDevice:function(b){var d=-1,c;for(c in a.CONST.medias)if(a.CONST.medias[c].name===b){d=a.CONST.medias[c].device;break}return d},isItPortableDevice:function(){return"android"===a.osName||"ios"===a.osName?!0:!1},isItLGAndroidBrowser:function(){return"android lg"===a.browserName?!0:!1},isItSamsungAndroidBrowser:function(){return"android samsung"===a.browserName?!0:!1},isItSupportingPFCertBackUp:function(){if(!(2&a.ESVS.Mode))return!1;if(this.isItPortableDevice())return"android samsung"===a.browserName||"android lg"===a.browserName||"android browser"===a.browserName||"android chrome"===a.browserName||"ios safari"===a.browserName||"ios chrome"===a.browserName?!0:!1;if("chrome"===a.browserName)return!0;if("msie"===a.browserName){if(10<=parseInt(a.browserVersion))return!0}else{if("firefox"===a.browserName)return parseInt(a.browserVersion),!0;if("safari"===a.browserName){if(6.1<=parseFloat(a.browserVersion))return!0}else if("opera"===a.browserName)return parseInt(a.browserVersion),!0}return!1},isItPFDevice:function(b){switch(b){case a.CONST.__PF_M_SS.device:case a.CONST.__PF_M_LS.device:case a.CONST.__PF_M_TOUCHSIGN.device:case a.CONST.__PF_M_SMARTSIGN.device:case a.CONST.__PF_M_WEBSECTOKEN.device:case a.CONST.__PF_M_WEBSOFTTOKEN.device:case a.CONST.__PF_M_CLOUDSIGN.device:return!0}return!1},isItSupportingThisStorage:function(b){if(!b)return!1;var d=!1;if(1===(255&a.ESVS.Mode)||4===a.ESVS.Mode)switch(b.device){case a.CONST.__USFB_M_DISK.device:case a.CONST.__USFB_M_HSMKEY.device:case a.CONST.__USFB_M_SMARTCARD.device:case a.CONST.__USFB_M_MOBILE.device:case a.CONST.__USFB_M_HDD.device:case a.CONST.__USFB_M_MOBILETOKEN.device:case a.CONST.__USFB_M_SECUREDISK.device:d=this.isItPortableDevice()?!1:!0;break;default:d=!1}else if(2===(255&a.ESVS.Mode))switch(b.device){case a.CONST.__PF_M_LS.device:case a.CONST.__PF_M_SS.device:case a.CONST.__PF_M_CLOUDSIGN.device:d=!0;break;case a.CONST.__PF_M_TOUCHSIGN.device:case a.CONST.__PF_M_SMARTSIGN.device:case a.CONST.__PF_M_WEBSECTOKEN.device:case a.CONST.__PF_M_WEBSOFTTOKEN.device:d=this.isItPortableDevice()?!1:!0;break;default:d=!1}else if(3===(255&a.ESVS.Mode)||6===(255&a.ESVS.Mode))switch(b.device){case a.CONST.__USFB_M_DISK.device:case a.CONST.__USFB_M_HSMKEY.device:case a.CONST.__USFB_M_SMARTCARD.device:case a.CONST.__USFB_M_MOBILE.device:case a.CONST.__USFB_M_HDD.device:case a.CONST.__USFB_M_MOBILETOKEN.device:case a.CONST.__USFB_M_SECUREDISK.device:d=this.isItPortableDevice()?!1:!0;break;case a.CONST.__PF_M_SS.device:case a.CONST.__PF_M_LS.device:case a.CONST.__PF_M_CLOUDSIGN.device:d=!0;break;case a.CONST.__PF_M_TOUCHSIGN.device:case a.CONST.__PF_M_SMARTSIGN.device:case a.CONST.__PF_M_WEBSECTOKEN.device:case a.CONST.__PF_M_WEBSOFTTOKEN.device:d=this.isItPortableDevice()?!1:!0;break;default:d=!1}return d},getScrollTop:function(){return self.pageYOffset?self.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop},getScrollLeft:function(){return self.pageXOffset?self.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft},getViewportHeight:function(){return window.undefined!=window.innerHeight?window.innerHeight:"CSS1Compat"==document.compatMode?document.documentElement.clientHeight:document.body?document.body.clientHeight:window.undefined},getViewportWidth:function(){return window.undefined!=window.innerWidth?window.innerWidth:"CSS1Compat"==document.compatMode?document.documentElement.clientWidth:document.body?document.body.clientWidth:window.undefined},getStyle:function(a,d,c){return a&&d&&c?a.currentStyle?a.currentStyle[d]:window.getComputedStyle?window.getComputedStyle(a,"").getPropertyValue(c):null:null},getNumSize:function(a){if(!a)return-1;a=a.toLowerCase();if(-1a||!a)return null;var b=document.createElement("div");b.style.zIndex=a;b.style.backgroundImage="none";b.style.margin="0px";b.style.cursor="auto";b.style.display="none";b.onclick=null;b.style.position="fixed";b.style.width="100%";b.style.height="100%";b.style.top="0";b.style.left="0";b.style.filter="alpha(opacity=50)";b.style.backgroundColor="#000";b.style.opacity="0.5";return b},loadingBox:function(b,d,c){if(null==d||""==d)d="us-div-list-load";d=document.getElementById(d);if(null!=d){var e=document.getElementById("us-cert-processing-img");null!=e&&e.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/processing-img.gif",0);null==c&&(c=0);e=document.getElementById("us-cert-processing-text");null!=e&&(e.innerHTML="",e.appendChild(document.createTextNode(this._errormsglang.IDS_CERT_LOADING_MSG[c])));d.style.display=b?"":"none"}},createLoadingBox:function(b,d,c){if(null==d||""==d)d="us-div-loading-dialog";null==document.getElementById(d)?"hide"!=b&&(b=va+1,a.ESVS.TargetObj.innerHTML='
',b=document.getElementById("us-div-loading-dialog-img"),null!=b&&b.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/processing-img.gif",0),b=document.getElementById("us-div-loading-dialog-text"),null!=b&&(b.innerHTML="",b.appendChild(document.createTextNode(c)))):"change"==b?(b=document.getElementById("us-div-loading-dialog-text"),null!=b&&(b.innerHTML="",b.appendChild(c))):a.ESVS.TargetObj.innerHTML=""},addCapsLockEvent:function(a,d,c,e){a=document.getElementById(a);var b=document.getElementById(d);if(!b||!a)return null;d=document.getElementById(d+"-text");""!=c&&d.appendChild(document.createTextNode(c));var f=function(){b&&(b.style.display="block")},h=!1,k=!1;a.onkeyup=function(a){a=a||event;a.which&&16==a.which&&(h=!1)};a.onkeydown=function(a){a=a||event;var c=0;a.which&&16==a.which&&(h=!0);window.event?c=a.keyCode:a.which&&(c=a.which);c&&20==c?k?(k=!1,b&&(b.style.display="none")):(k=!0,f()):c&&13==c&&e&&e(a?a:event)};a.onkeypress=function(a){a=a||event;var c=0,d=!1;window.event?(c=a.keyCode,d=a.shiftKey):a.which&&(c=a.which,d=h);65<=c&&90>=c&&!d?(k=!0,f()):97<=c&&122>=c&&d?(k=!0,f()):48<=c&&57>=c||(k=!1,b&&(b.style.display="none"))};try{-1!=navigator.appVersion.toLowerCase().indexOf("win")&&(document.msCapsLockWarningOff=!0)}catch(l){}},offsetResize:function(a,d){if(a){var b=this.getViewportHeight()/2-a.offsetHeight/2,e=this.getViewportWidth()/2-a.offsetWidth/2;0>b&&(b=0);0>e&&(e=0);a.style.position="fixed";!d||"center"!=d&&"center"!=d.split(",")[0]?d&&"center"!=d?(a.style.top=d.split(",")[0]+"px",a.style.left=d.split(",")[1]+"px"):(a.style.top="30px",a.style.left=e+"px"):(a.style.top=b+"px",a.style.left=e+"px")}},setCookie:function(a){localStorage.setItem("cookie",JSON.stringify(a))},getCookie:function(){var a=localStorage.getItem("cookie");return a?JSON.parse(a):null},msgBox:function(a){a&&alert(a)},setFirstFocus:function(a){a&&("string"==typeof a&&(a=document.getElementById(a)),a&&(a.focus(),setTimeout(function(){a.focus()},10)))},setRotationTabFocus:function(a,d,c){function b(a){return"string"==typeof a?document.getElementById(a):a}a&&d&&c&&(a=b(a),d=b(d),c=b(c),a.onkeydown=function(b){var e=b||window.event;9==(e.which||e.keyCode)&&(a.onblur=function(){setTimeout(function(){(e.shiftKey?d:c).focus()},10)})})},flagAlert:function(a){a&&0!=M&&alert(a)},errMsgBox:function(a,d){a&&alert(a+"\n\nError Code [ "+d+" ]")},getErrorMessageLang:function(){return this._errormsglang},getUserCancelErrCodeNMsg:function(b){11003!=a.ERROR.Code&&21002!=a.ERROR.Code&&31001!=a.ERROR.Code&&(a.ERROR.Code=999,a.ERROR.Message=this._errormsglang.IDS_ERROR_USER_CANCEL);b&&(b.resultCode=a.ERROR.Code,b.resultMessage=a.ERROR.Message)},CheckPwdPattern:function(b,d){var c=!0;if(4&a.ESVS.Mode&&a.bsUtil().isKeyProtected())a.nimservice().CheckPasswdCombination(b,a.ESVS.LimitMinNewPWLen,a.ESVS.LimitMaxNewPWLen,a.ESVS.LimitNewPWPattern,function(a,b){0!=a?d(!1):d(!0)});else{a.ESVS.LimitMinNewPWLen>b.length&&(c=!1);a.bsUtil().isKeyProtected()&&d(c);if("NPKI"===a.ESVS.PKI||2===a.ESVS.LimitNewPWPattern){var e=/^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[^a-zA-Z0-9])/g;e.exec(b)||(c=!1)}else 1===a.ESVS.LimitNewPWPattern&&(e=/^(?=.*[a-zA-Z])(?=.*[0-9])/g,e.exec(b)||(c=!1));if("NPKI"===a.ESVS.PKI&&(e=/['"\\|]/g,e.exec(b)&&(c=!1),2c&&(c="0"+c);10>b&&(b="0"+b);return a+"-"+c+"-"+b},getLocalDateNTime:function(a){if(!a)return"undefined";var b=new Date(a);a=b.getFullYear();var c=b.getMonth()+1,e=b.getDate(),g=b.getHours(),f=b.getMinutes();b=b.getSeconds();10>c&&(c="0"+c);10>e&&(e="0"+e);10>g&&(g="0"+g);10>f&&(f="0"+f);10>b&&(b="0"+b);return a+"-"+c+"-"+e+" "+g+":"+f+":"+b},getCertType:function(b){if("MPKI"==a.ESVS.PKI)return"Symantec";if(!b)return"undefined";b=this._certOidNameTable[b];return null==b||""==b?this._certOidNameTable.restriction:b},getIssuerName:function(a){return a?-1!=a.indexOf(this._certCAOidTable.crosscert)?this._certCANameTable.crosscert:-1!=a.indexOf(this._certCAOidTable.yessign)?this._certCANameTable.yessign:-1!=a.indexOf(this._certCAOidTable.koscom)?this._certCANameTable.koscom:-1!=a.indexOf(this._certCAOidTable.ktnet)?this._certCANameTable.ktnet:-1!=a.indexOf(this._certCAOidTable.kica)?this._certCANameTable.kica:-1!=a.indexOf(this._certCAOidTable.inipass)?this._certCANameTable.inipass:-1!=a.indexOf(this._certCAOidTable.verisign)?this._certCANameTable.verisign:"undefined":"undefined"},getIssuerEnName:function(a){return a?-1!=a.indexOf(this._certCAOidTable.crosscert)?"crosscert":-1!=a.indexOf(this._certCAOidTable.yessign)?"yessign":-1!=a.indexOf(this._certCAOidTable.koscom)?"SignKorea":-1!=a.indexOf(this._certCAOidTable.ktnet)?"tradesign":-1!=a.indexOf(this._certCAOidTable.kica)?"kica":-1!=a.indexOf(this._certCAOidTable.inipass)?"inipass":-1!=a.indexOf(this._certCAOidTable.verisign)?"verisign":"other":"undefined"},getExpirationState:function(a){if(!a)return"undefined";a=new Date(a);var b=(new Date).getTime();a=a.getTime()-b;return 0>>> SignData : ["+b.length+"] "+b.substring(0,10)+"..."+b.substring(b.length-10,b.length)):a.logger(" >>>> SignData ERROR : "+b);var c=null;try{var e=b;c=a.usWebToolkit.pkcs7.messageFromBase64(b);var g=b;c.verify()}catch(f){a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : "+f.code);M=!1;a.logger(M+" >> signdata :: ("+(e==g)+") "+this._lang.IDS_MSGBOX_ERROR_VERIFY_SIGNED_DATA_OF_MD_TABLE+"\nerror code : "+f.code+"\nerror msg : "+f.message+"\na:"+e+"\nb:"+g);return}if(1==c.verifyResult)a.intergrity.data=c.content;else if(-1> verifyResult :: "+this._lang.IDS_MSGBOX_ERROR_VERIFY_SIGNED_DATA_OF_MD_TABLE);return}try{d=a.usWebToolkit.pki.certificateToBase64(c.certificates[0])}catch(f){a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : "+f.code);M=!1;a.logger(">> certificate error :: "+this._lang.IDS_MSGBOX_ERROR_GET_THE_CERT_FROM_SIGNED_DATA);return}}a.usWebToolkit.x509Certificate.parser(d,"Base64");Na();b=a.usWebToolkit.x509Certificate.getSubjectName();if(!b||0>=b.length||"cn=crosscertwebv3,ou=stlab,o=crosscert,c=kr"!==b.toLowerCase())a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : 1401"),M=!1,a.logger(">> get dn : "+this._lang.IDS_MSGBOX_ERROR_VERIFY_THE_CERT);else if(b=a.usWebToolkit.x509Certificate.getSubjectKeyIdentifier(),!b||0>=b.length||"9ecd6e86418013304666aff0c486a6c31a6fe363"!==b)a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : 1411"),M=!1,a.logger(">> get ski : "+this._lang.IDS_MSGBOX_ERROR_VERIFY_THE_CERT)};ya.prototype={verify:function(b,d){Na();var c=a.intergrity.getList();if(!c||0>=c.length)return null;if(!b||!d)return this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE;this._md.start();this._md.update(d);d=this._md.digest().toHex();for(var e=0;e>2],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d]&3)<<4|a[d+1]>>4],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[d+1]&15)<<2|a[d+2]>>6],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d+2]&63];2===c%3?e=e.substring(0,e.length-1)+"=":1===c%3&&(e=e.substring(0,e.length-2)+"==");return e},String.prototype.toArrayBuffer=function(){var a=.75*this.length,d=this.length,c=0;"="===this[this.length-1]&&(a--,"="===this[this.length-2]&&a--);var e=new ArrayBuffer(a),g=new Uint8Array(e);for(a=0;a>4;g[c++]=(h&15)<<4|k>>2;g[c++]=(k&3)<<6|l&63}return e});var Oa=function(){};Oa.prototype={save:function(a,d){!a||0>=a.length||!d||(d=new Blob([d],{type:"application/octet-stream"}),xa(d,a))}};var E=K=null,P=0;w=null;K=navigator.platform;C=navigator.userAgent;K=0<=K.indexOf("Win")?"win":0<=K.indexOf("Mac")?"mac":0<=K.indexOf("Linux")?"linux":0<=K.indexOf("iPhone")||0<=K.indexOf("iPad")||0<=K.indexOf("iPod")?"ios":"unknown";0<=C.indexOf("Android")&&(K="android");"android"===K?0<=C.indexOf("SAMSUNG")?(E="android samsung",w=/Version\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("OPR")?(E="android opera",w=/OPR\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Opera")?(E="android opera classic",w=/Version\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Firefox")?(E="android firefox",w=/Firefox\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("NAVER")?E="android naver":0<=C.indexOf("DaumApps")?(E="android daum",w=/DaumApps\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("nate_app")?E="android nate":0<=C.indexOf("UCBrowser")?(E="android uc",w=/UCBrowser\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Chrome")?0<=C.indexOf("Version")?(E=0<=C.indexOf("LG")?"android lg":"android browser",w=/Version\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("LG")?((w=/Chrome\/([0-9]{1,}[.0-9]{0,})/,w.exec(C))&&(P=parseFloat(RegExp.$1)),E=39>P?"android lg":"android chrome"):(E="android chrome",w=/Chrome\/([0-9]{1,}[.0-9]{0,})/):(E="unknown",P=0):"ios"===K?0<=C.indexOf("CriOS")?(E="ios chrome",w=/CriOS\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("NAVER")?E="ios naver":0<=C.indexOf("DaumApps")?(E="ios daum",w=/DaumApps\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Coast")?(E="ios opera coast",w=/Coast\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Safari")?(E="ios safari",w=/Version\/([0-9]{1,}[.0-9]{0,})/):(E="unknown",P=0):0<=C.indexOf("MSIE")?(E="msie","BackCompat"==document.compatMode?P=5:document.documentMode?P=document.documentMode:w=/MSIE ([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Edge")||0<=C.indexOf("Edg")?(E="edge",w=/Edge\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("OPR")?(E="opera",w=/OPR\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Whale")?(E="whale",w=/whale\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Chrome")?(E="chrome",w=/Chrome\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Safari")?(E="safari",w=/Version\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Firefox")?(E="firefox",w=/Firefox\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("Opera")?(E="opera",w=/Version\/([0-9]{1,}[.0-9]{0,})/):0<=C.indexOf("rv:11.")?(E="msie",w=/rv:([0-9]{1,}[.0-9]{0,})/):(E="unknown",P=0);w&&w.exec(C)&&(P=parseFloat(RegExp.$1));var Na=function(){return"msie"==E?10>P:"chrome"==E?10>P:"firefox"==E?10>P:"safari"==E?6.1>P:"opera"==E?15>P:!0},pb=H({intergrity:!1,name:"transfer_"+u.Language,url:"unisignweb/rsrc/lang/"+u.Language+"/transfer_"+u.Language+".js"}),a={ver:"1.0.4.9",nimVersion:"2.0.11.2",osName:K,browserName:E,browserVersion:P,usWebToolkit:window.crosscert,isAvailable:function(){return null==M?!1:M},isSKModule:null,pubkey:null,intergrity:{data:null,list:null,getList:function(){null==this.list&&(this.list=this.parser(this.data));return this.list},parser:function(a){"string"!==typeof a&&(a=new String(a));var b=[];a=a.split(/\r\n|\r|\n/g);for(var c=0;c=b.length)return null;var d=b+".js";var c=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");a.uiUtil().isItPortableDevice()?"gridlist"!=b?(d="m_"+d,c.open("GET",u.SRCPath+"unisignweb/js/mobile/m_"+b+".js?version=1.0.4.9",!1)):c.open("GET",u.SRCPath+"unisignweb/js/"+b+".js?version=1.0.4.9",!1):c.open("GET",u.SRCPath+"unisignweb/js/"+b+".js?version=1.0.4.9",!1);c.send(null);var e=c.responseText;"certprocessing.js"!=d&&(d=a.forgeryUtil().verify(d,e),"success"!=d&&null!=d&&(a.uiUtil().flagAlert(d),M=!1));eval(c.responseText);return eval("__"+b)(a)},CCPFSH:function(){return Pa},ActiveUI:null,ESVS:u,STATUS:{HadCheckedLicense:!1},PFSH:Ka,PFUC:null,PFCS:function(){return eb},Whale:function(){return fb},ERROR:{Code:0,Message:null},errPopup:function(b,d){var c=a.transferLang();switch(b){case 0:break;case -1:a.uiUtil().errMsgBox(c.IDS_CANCEL_PROCESS,b);break;case -2:a.uiUtil().errMsgBox(c.IDS_WRONG_PROCESS,b);break;case 2011:a.uiUtil().errMsgBox(c.IDS_ERR_WRONG_LICENSE,b);break;case 2012:a.uiUtil().errMsgBox(c.IDS_ERR_LICENSE_AUTHORITY,b);break;case 2013:a.uiUtil().errMsgBox(c.IDS_ERR_EXPIRED_LICENSE,b);break;case 2014:a.uiUtil().errMsgBox(c.IDS_ERR_DOMAIN_PARSING,b);break;case 2015:a.uiUtil().errMsgBox(c.IDS_ERR_LICENSE_PARSING,b);break;case 2016:a.uiUtil().errMsgBox(c.IDS_ERR_SIGN_VERIFYING,b);break;case -1001:case -1002:case -1003:case -1004:case -1005:case -1006:case -1007:case -1009:case -1010:case -1011:case -1012:case -1013:case -1015:case -1017:case -1018:case -1019:case -1021:case -1022:case -1023:case -1024:case -1054:case -1055:case -1056:a.uiUtil().errMsgBox(c.IDS_ERR_NETWORK,b);break;case -1008:a.uiUtil().errMsgBox(c.IDS_ERR_TIME_OUT,b);break;case -1020:a.uiUtil().errMsgBox(c.IDS_ERR_CANCEL,b);break;case -1033:a.uiUtil().errMsgBox(c.IDS_ERR_CREATE_NUM,b);break;case -1034:case -1035:case -1041:case -1042:case -1043:case -1044:case -1061:a.uiUtil().errMsgBox(c.IDS_ERR_MEMORY,b);break;case -1050:a.uiUtil().errMsgBox(c.IDS_ERR_INTERNET,b);break;case -1052:a.uiUtil().errMsgBox(c.IDS_ERR_CHECK_NUM,b);break;case -1110:a.uiUtil().errMsgBox(c.IDS_ERR_AUTH_NUM,b);break;case -1114:a.uiUtil().errMsgBox(c.IDS_ERR_PC_TO_PC,b);break;case -1200:case -1201:case -1202:case -1203:case -1204:case -1205:case -1206:a.uiUtil().errMsgBox(c.IDS_ERR_SIGN_VERIFYING,b);break;case -1207:case -1208:a.uiUtil().errMsgBox(c.IDS_INVALID_CONTEXT,b);break;default:d?a.uiUtil().errMsgBox(d,b):a.uiUtil().errMsgBox(c.IDS_ERR_TRANSFER,b)}},CONST:{__USFB_M_DISK:{device:1,name:"removable"},__USFB_M_HSMKEY:{device:2,name:"sectoken"},__USFB_M_SMARTCARD:{device:3,name:"savetoken"},__USFB_M_MOBILE:{device:4,name:"mobilephone"},__USFB_M_HDD:{device:5,name:"harddisk"},__USFB_M_MOBILETOKEN:{device:6,name:"mobiletoken"},__USFB_M_SECUREDISK:{device:7,name:"securedisk"},__USFB_M_ETC:{device:9,name:"USFB_M_ETC"},__PF_M_LS:{device:11,name:"webstorage"},__PF_M_SS:{device:21,name:"browsersign"},__PF_M_TOUCHSIGN:{device:12,name:"touchsign"},__PF_M_SMARTSIGN:{device:13,name:"smartsign"},__PF_M_WEBSECTOKEN:{device:14,name:"websectoken"},__PF_M_WEBSOFTTOKEN:{device:15,name:"websofttoken"},__PF_M_CLOUDSIGN:{device:16,name:"cloudsign"},__PF_M_ETC:{device:19,name:"PF_M_ETC"},medias:{}},SELECTINFO:{index:0,pw:null,curdevice:5,cert:null,certattrs:null},transferLang:function(){return pb},changeDefaultMedia:function(){6==a.ESVS.Mode&&ja&&(I.defaultdevice=a.ESVS.Media.defaultdevice=u.Media.defaultdevice=ja)},CustomEval:function(a,d){return ob(a,d)}};a.usWebToolkit.usWebCMP.info.CMPUrl=aa;__UIUtil=new La;__CertUtil=new Ma;__ForgeryUtil=new ya;__FileUtil=new Oa;__BSUtil=new da;var qb=function(){if(!(u.Mode&4))return null;eval(H({eval:!1,intergrity:!0,name:"nimservice",url:"unisignweb/js/nimservice.js"}));return eval("__nimservice")(a)}(a),Pa=null,fb=null;-1!=I.list.indexOf("browsersign")&&(Pa=Qa(a));var eb=null;-1!=I.list.indexOf("cloudsign")&&(eb=gb(a));navigator.whaleCertManager&&"NPKI"==a.ESVS.PKI&&(fb=hb(a));"ahnlab"==a.ESVS.SecureKeyboardType&&(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_KS_INSTALL_CHECK),$ASTX2.init(function(){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");a.isSKModule=!0},function(){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");a.isSKModule=!1;$ASTX2.getLastError()}));a.CONST.medias={removable:a.CONST.__USFB_M_DISK,sectoken:a.CONST.__USFB_M_HSMKEY,savetoken:a.CONST.__USFB_M_SMARTCARD,mobilephone:a.CONST.__USFB_M_MOBILE,harddisk:a.CONST.__USFB_M_HDD,mobiletoken:a.CONST.__USFB_M_MOBILETOKEN,securedisk:a.CONST.__USFB_M_SECUREDISK,webstorage:a.CONST.__PF_M_LS,browsersign:a.CONST.__PF_M_SS,touchsign:a.CONST.__PF_M_TOUCHSIGN,smartsign:a.CONST.__PF_M_SMARTSIGN,websectoken:a.CONST.__PF_M_WEBSECTOKEN,websofttoken:a.CONST.__PF_M_WEBSOFTTOKEN,cloudsign:a.CONST.__PF_M_CLOUDSIGN};VerifyLicense=function(){var b="";null!=a.ESVS.License&&"undefined"!==typeof a.ESVS.License&&(b=H({eval:!1,intergrity:!1,name:"License",url:a.ESVS.License}));if("touchen"==a.ESVS.SecureKeyboardType&&a.bsUtil().isTouchEnKeyUsable())a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_KS_INSTALL_CHECK),a.nimservice().GetCertForKeyboardEncrypt(document.domain,b,function(b,c,e){0==b?a.pubkey=e:a.ESVS.SecureKeyboardType="";a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");return!0});else return!0};VerifyPFLicense=function(){return!0};if(4&a.ESVS.Mode&&a.nimservice())VerifyLicense(function(a){});else if(!VerifyPFLicense())return;aa=function(){CheckIntergrity()&&(S=null,null==M&&(M=!0))};null!=a.intergrity.data?aa():setTimeout(aa,1E3);if(a.PFSH)try{a.PFSH.LoadAllCerts(document.domain)}catch(b){301E5===b.code&&(a.PFSH.InstallCACerts(document.domain),a.PFSH.LoadAllCerts(document.domain))}4<=L&&oa();return{Available:function(){return a.isAvailable()},isMilPKI:function(){return 0<=a.ESVS.PKI.indexOf("MilPKI")?!0:!1},GetLocale:function(b){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return!1;var d=n();4&a.ESVS.Mode?a.nimservice().GetLocale(function(c,e,g){0==c?(d.locale=g,b(d)):(a.ERROR.Code=c,a.ERROR.Message=e,b(n(a.ERROR.Code,a.ERROR.Message)))}):(d.locale=navigator.language,b(d))}},IsValidity:function(){return 0==a.isAvailable()?(a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE),!1):a.nimservice()?!0:!1},GetLastError:function(b){0==a.isAvailable()?a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE):(b(a.ERROR.Code,a.ERROR.Message),a.ERROR.Code=0,a.ERROR.Message=null)},SetEmbeddedUI:function(b){0==a.isAvailable()?a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE):a.ESVS.Embedded=b?!0:!1},SignDataP1:function(b,d,c){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!c||document.getElementById("us-div-cert-select"))return!1;oa();var e=n(),g=function(a){1==c.length?c(a):(null==a&&(a=n()),c(a.signedData,a.theCert,a.theDN))};a.reInitialize();var f=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:d,possibleWhale:!0},onConfirm:function(c,d,l,p,t,m){e.theCert=c;e.theDN=d;if("undefined"!==typeof p&&"undefined"!==typeof t){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(m))if(m!=a.CONST.__USFB_M_DISK.device&&m!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(m==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){var h=a.usWebToolkit.md.algorithms.sha256.create();h.start();h.update(a.usWebToolkit.util.encodeUtf8(b));d=h.digest().toHex();d=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+d);l={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(b){b=JSON.parse(b);if(0!=b.returnObj.returnCode&&"E1000"!=b.returnObj.returnCode)e.resultMessage=a.ERROR.Message=b.returnObj.returnMsg,e.resultCode=a.ERROR.Code=b.returnObj.returnCode,setTimeout(function(){f.dispose(!0)},10),g(e);else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(e),setTimeout(function(){f.dispose(!0)},10),g(e);else{var c=b.signResult.b64Signer;_certAttrs=a.certUtil().getTheCertAttributes(c,"Base64");B(p,t,m,c,_certAttrs);e.certAttrs=_certAttrs;e.signedData=b.signResult.b64SignedData[0];e.theCert=b.signResult.b64Signer;e.theDN=_certAttrs.subjectName;e.tokenlabel="";g(e);setTimeout(function(){f.dispose()},10)}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};l.msg[0]=d;l.plainText=[];l.plainText[0]=a.usWebToolkit.util.encodeUtf8(b);jSmartCertNP.SignByJSON(l).Open()}else a.nimservice()?(d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP1(p,t,d,null,!1,function(b,d,h,q,k,r){0!=b?(a.ERROR.Code=e.resultCode=b,a.ERROR.Message=e.resultMessage=d,a.uiUtil().errMsgBox(d,b)):(null==c&&a.CONST.__USFB_M_MOBILETOKEN.device==m&&(_certAttrs=a.certUtil().getTheCertAttributes(k,"Base64"),e.theCert=k,e.theDN=_certAttrs.subjectName),e.signedData=h,e.tokenlabel=r);g(e);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){f.dispose()},10)})):(a.ERROR.Code=e.resultCode=-1,a.ERROR.Message=e.resultMessage=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_NIM_ERROR_UNLOAD,g(e),setTimeout(function(){f.dispose(!0)},10));else-1==p||""==t?(e.resultMessage=a.ERROR.Message=l,e.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){f.dispose(!0)},10),g(e)):(a.uiUtil().loadingBox(!0,"us-div-list-load",1),d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP1(d,p,t,function(b,c,d){0!=b?(e.resultCode=b,e.resultMessage=c):(e.signedData=d,e.tokenlabel="");setTimeout(function(){f.dispose()},10);a.uiUtil().loadingBox(!1,"us-div-list-load",1);g(e)}));else if(m==a.CONST.__PF_M_CLOUDSIGN.device)a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGenSignNonVerifyPin(p,a.usWebToolkit.util.encodeUtf8(b),"Y",function(b,c,d){0!=b&&(a.ERROR.Code=b,a.ERROR.Message=c,setTimeout(function(){f.dispose()},10),g(n(b,c)));e.signedData=d;setTimeout(function(){f.dispose()},10);g(e)});else{try{var q=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[p].signcert),k=a.usWebToolkit.pkcs8.decryptRsaPrivateKeyFromBase64(a.PFUC[p].signpri,t);h=null;switch(a.usWebToolkit.pki.oids[q.signatureOid]){case "sha1WithRSAEncryption":h=crosscert.md.algorithms.sha1.create();break;case "kcdsaWithSHA1":q.md=crosscert.md.algorithms.sha1.create();break;case "md5WithRSAEncryption":h=crosscert.md.algorithms.md5.create();break;case "sha256WithRSAEncryption":h=crosscert.md.algorithms.sha256.create();break;case "RSASSA-PSS":h=crosscert.md.algorithms.sha256.create()}h.update(a.usWebToolkit.util.encodeUtf8(b));var v=k.sign(h);e.signedData=a.usWebToolkit.util.encode64(v);g(e)}catch(y){a.ERROR.Code=y.code,a.ERROR.Message=y.message,a.uiUtil().errMsgBox(l,a.ERROR.Code),g(n(a.ERROR.Code,a.ERROR.Message))}setTimeout(function(){f.dispose()},10)}p=t=q=pri=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(e);g(e);f.dispose(!0)}});f.show();return!0}},VerifySignedDataP1:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if(b&&d&&c||e(-1),a.reInitialize(),4&a.ESVS.Mode&&a.ESVS.chkEXESetup)if(null!=a.Whale()){d=a.usWebToolkit.util.decode64(d);c=a.usWebToolkit.pki.certificateFromBase64(c);var g=ma(c);g.update(a.usWebToolkit.util.encodeUtf8(b));try{var f=c.publicKey.verify(g.digest().getBytes(),d)}catch(h){f=!1}f?e(0):e(-1)}else a.nimservice()&&(b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().VerifyP1SignData(b,d,c,function(b,c){0!=b&&(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage());e(b);a.uiUtil().loadingBox(!1,"us-div-list-load")}));else{d=a.usWebToolkit.util.decode64(d);c=a.usWebToolkit.pki.certificateFromBase64(c);g=ma(c);g.update(b);try{f=c.publicKey.verify(g.digest().getBytes(),d)}catch(h){f=!1}return f?0:-1}},SignDataP7:function(b,d,c,e,g){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!g||document.getElementById("us-div-cert-select"))return!1;oa();var f=n(),h=function(a){1==g.length?g(a):(null==a&&(a=n(-1)),g(a.signedData,a.curDevice,a.certAttrs,a.b64RValue))};a.reInitialize();var k=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:d,possibleWhale:!0},onConfirm:function(d,g,t,m,r,q){var p=t;if("undefined"!==typeof m&&"undefined"!==typeof r)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(q))q!=a.CONST.__USFB_M_DISK.device&&q!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?q==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP?(d=a.usWebToolkit.md.algorithms.sha256.create(),d.start(),d.update(a.usWebToolkit.util.encodeUtf8(b)),d=d.digest().toHex(),d=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+d),t={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(c){c=JSON.parse(c);if(0!=c.returnObj.returnCode&&"E1000"!=c.returnObj.returnCode)f.resultMessage=a.ERROR.Message=c.returnObj.returnMsg,f.resultCode=a.ERROR.Code=c.returnObj.returnCode,setTimeout(function(){k.dispose(!0)},10),h(f);else if("E1000"==c.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(f),setTimeout(function(){k.dispose(!0)},10),h(f);else{var d=c.signResult.b64Signer;p=a.certUtil().getTheCertAttributes(d,"Base64");B(m,r,q,d,p);f.certAttrs=p;var g=a.usWebToolkit.util.decode64(c.signResult.b64SignedData[0]);d=a.usWebToolkit.pki.certificateFromBase64(d);var l=a.usWebToolkit.pkcs7.createSignedData();l.signWithP1(g,b,d,null,null);f.signedData=a.usWebToolkit.pkcs7.messageToBase64(l);f.curDevice=q;if(e)try{var x=a.usWebToolkit.util.decode64(c.signResult.R[0]),v=a.usWebToolkit.pki.certificateFromBase64(e);l=a.usWebToolkit.pkcs7.createEnvelopedData();l.addRecipient(v);l.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];l.content=x;l.encrypt();f.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(l)}catch(Ta){}f.tokenLabel="";h(f);setTimeout(function(){k.dispose()},10)}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]},t.msg[0]=d,c&&(t.plainText=[],t.plainText[0]=a.usWebToolkit.util.encodeUtf8(b)),jSmartCertNP.SignByJSON(t).Open()):a.nimservice()?(setTimeout(function(){k.dispose()},10),a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[1]),d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP7(m,r,d,"utf8",c,e,a.ESVS.multiuse,!1,function(b,c,d,e,k,x){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=b?(a.ERROR.Code=f.resultCode=b,a.ERROR.Message=f.resultMessage=c):(null==p&&a.CONST.__USFB_M_MOBILETOKEN.device==q?(p=a.certUtil().getTheCertAttributes(k,"Base64"),B(m,r,q,k,p)):B(m,r,q,g,p),f.certAttrs=p,f.signedData=d,f.curDevice=q,f.b64RValue=e,f.tokenLabel=x);h(f);m=r=g=l=null})):(a.ERROR.Code=f.resultCode=-1,a.ERROR.Message=f.resultMessage=a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER,h(f),setTimeout(function(){k.dispose(!0)},10)):-1==m||""==r?(f.resultMessage=a.ERROR.Message=d,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){k.dispose(!0)},10),h(f)):(a.uiUtil().loadingBox(!0,"us-div-list-load",1),d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP7(d,m,r,c,function(b,c,d){0!=b?(f.resultCode=b,f.resultMessage=c,a.uiUtil().loadingBox(!1,"us-div-list-load",1),h(f),setTimeout(function(){k.dispose()},10)):(f.certAttrs=p,f.signedData=d,f.curDevice=q,e?a.Whale().getCertR(m,r,function(b,c,d){a.uiUtil().loadingBox(!1,"us-div-list-load",1);if(0==b)try{var g=a.usWebToolkit.util.hexToBytes(d),q=a.usWebToolkit.pki.certificateFromBase64(e),m=a.usWebToolkit.pkcs7.createEnvelopedData();m.addRecipient(q);m.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];m.content=g;m.encrypt();f.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(m)}catch(sb){}h(f);setTimeout(function(){k.dispose()},10)}):(a.uiUtil().loadingBox(!1,"us-div-list-load",1),h(f),setTimeout(function(){k.dispose()},10)))}));else if(q==a.CONST.__PF_M_CLOUDSIGN.device)-1==m?(f.resultMessage=a.ERROR.Message=d,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){k.dispose(!0)},10),h(f)):(a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGetCertR(m,function(c,d,x){0!=c&&(f.resultCode=c,f.resultMessage=d,setTimeout(function(){k.dispose()},10),h(n(c,d)));a.PFCS().reqGenSignNonVerifyPin(m,a.usWebToolkit.util.encodeUtf8(b),"Y",function(c,d,v){0!=c?(a.ERROR.Code=c,a.ERROR.Message=d,h(n(c,d))):(B(m,r,q,g,p),c=a.usWebToolkit.util.decode64(v),d=a.usWebToolkit.pki.certificateFromBase64(g),v=crosscert.pkcs7.createSignedData(),v.signWithP1(c,b,d,null,null),f.signedData=a.usWebToolkit.pkcs7.messageToBase64(v),f.curDevice=q,f.RValue=x,e&&(c=a.usWebToolkit.util.hexToBytes(x),d=a.usWebToolkit.pki.certificateFromBase64(e),v=a.usWebToolkit.pkcs7.createEnvelopedData(),v.addRecipient(d),v.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"],v.content=c,v.encrypt(),f.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(v)),h(f));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10);m=r=g=l=null})}));else if(-1==m||""==r)f.resultMessage=a.ERROR.Message=d,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){k.dispose(!0)},10),h(f);else{try{g=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[m].signcert);var l=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[m].signpri),y=a.usWebToolkit.pkcs7.createSignedData();y.sign(b,g,l,r,null,null);var G=a.usWebToolkit.pkcs8.decryptPrivateKeyInfo(l,r),z=a.usWebToolkit.pkcs8.getPrivateKeyAttributesRandom(G);B(m,r,q,g,p);f.signedData=a.usWebToolkit.pkcs7.messageToBase64(y);f.RValue=a.usWebToolkit.util.bytesToHex(z);f.certAttrs=p;f.curDevice=q;if(e){var A=a.usWebToolkit.pki.certificateFromBase64(e),D=a.usWebToolkit.pkcs7.createEnvelopedData();D.addRecipient(A);D.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];D.content=z;D.encrypt();f.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(D)}h(f)}catch(F){a.ERROR.Code=F.code,a.ERROR.Message=F.message,112047==F.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD),a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),h(n(F.code,F.message))}setTimeout(function(){k.dispose()},10);m=r=g=l=null}else f.resultMessage=a.ERROR.Message=d,f.resultCode=a.ERROR.Code=43021E3,f.theDN="",setTimeout(function(){k.dispose(!0)},10),h(f)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(f);h(f);k.dispose(!0)}});k.show();return!0}},VerifySignedDataP7:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return null;var c=null;a.reInitialize();if(2&a.ESVS.Mode){c=null;try{c=a.usWebToolkit.pkcs7.messageFromBase64(b),c.verify()}catch(e){if(a.ERROR.Code=e.code,a.ERROR.Message=e.message,d)d(null);else return null}if(c.verifyResult)if(c=c.content,d)d(c);else return c}else if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice))if(null!=a.Whale()){c=null;try{c=a.usWebToolkit.pkcs7.messageFromBase64(b),c.verify()}catch(e){if(a.ERROR.Code=e.code,a.ERROR.Message=e.message,d)d(null);else return null}if(c.verifyResult)if(c=c.content,d)d(c);else return c}else a.nimservice()&&a.nimservice().VerifySignedData(null,b,function(b,c,f){0!=b?(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),d(null)):d(a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(f)));a.uiUtil().loadingBox(!1,"us-div-list-load")});else{c=null;try{c=a.usWebToolkit.pkcs7.messageFromBase64(b),c.verify()}catch(e){return a.ERROR.Code=e.code,a.ERROR.Message=e.message,null}if(c.verifyResult)return c=c.content}}},SignDataP7Ext:function(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d&&!c||document.getElementById("us-div-cert-select")||!g)return!1;var h=n();b||(b="DIGITAL_SIGNATURE_P7_EXT");a.reInitialize();var k=a.loadUI("certselect")({type:b,args:{dn:e,possibleWhale:!1},onConfirm:function(b,d,e,f,r){4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r)&&(a.nimservice()?a.nimservice().GetSignDataP7(d,e,c,"utf8",!0,null,!0,!1,function(b,c,m,p,l,t){0!=b?(a.ERROR.Code=h.resultCode=b,a.ERROR.Message=h.resultMessage=c,a.uiUtil().errMsgBox(c,a.ERROR.Code)):(h.signedData=m,h.certIndex=d,h.password=e,h.curDevice=f,h.curDrive=r,h.tokenLabel=t);g(h);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10)}):(setTimeout(function(){k.dispose(!0)},10),g(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER))))},onCancel:function(){k.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg(h);g(h)}});k.show();return!0}},SelectMediaForCertImporting:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return!1;var c=n();a.reInitialize();Dialog=a.loadUI("storageselect")({type:"CERT_STORAGE",args:{possibleWhale:!1},onConfirm:function(e,g){Dialog.dispose();2===e||3===e?(PWDialog=a.loadUI("password")({type:null,args:null,onConfirm:function(f){PWDialog.dispose();var h=null;h=2===e?"PIN_SECURITY_TOKEN":"PIN_SAVE_TOKEN";PINDialog=a.loadUI("pin")({type:h,args:null,onConfirm:function(a){PINDialog.dispose();c.curDevice=e;c.curDrive=g;c.password=f;c.pin=a;b(c);f=null},onCancel:function(){PINDialog.dispose();f=null;a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}});PINDialog.show()},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}}),PWDialog.show()):(c.curDevice=e,c.curDrive=g,c.password=null,c.pin=null,b(c))},onCancel:function(){Dialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();d&&d()}});Dialog.show()}},ExportCert:function(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return null;var h=n();a.reInitialize();if(-1==b){var k=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_EXT_DISABLE_SECTOKEN",args:{dn:null,possibleWhale:!1},onConfirm:function(b,c,d,g,r){4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r)&&(a.nimservice()?a.nimservice().ExportCertEx(g,r,c,e,d,function(a,b,c){h.resultCode=a;h.resultMessage=b;h.pfx=c;f(h)}):f(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)));setTimeout(function(){k.dispose()},10)},onCancel:function(){k.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg(h);f(h)}});k.show()}else 4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(d)&&(a.nimservice()?a.nimservice().ExportCertEx(d,c,b,e,g,function(a,b,c){h.resultCode=a;h.resultMessage=b;h.pfx=c;f(h)}):f(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)))}},ImportCert:function(b,d,c,e,g,f,h){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(1>c||0>e)return-1;a.reInitialize();4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(c)&&(a.nimservice()?a.nimservice().ImportCertEx(c,e,g,f,b,d,function(a,b){h(n(a,b))}):h(n(-1,a.uiUtil().getErrorMessageLang().IDS_MSGBOX_NIM_ERROR_UNLOAD)));return-1}},IssueCert:function(b,d,c){function e(b,c,d,e,f){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(b))if(b!=a.CONST.__USFB_M_DISK.device&&b!=a.CONST.__USFB_M_HDD.device||null==a.Whale())a.nimservice()?(g=a.loadUI("certprocessing"),IssuingDialog=g({type:"CERT_ISSUE",args:null,onConfirm:null,onCancel:null}),IssuingDialog.show(),setTimeout(function(){a.nimservice().GetAllUserCertListNum(5,0,"",function(g,q,m){a.nimservice().IssueCertificate(a.ESVS.CMPIP,a.ESVS.CMPPort,h,k,d,e,b,c,f,function(b,c){if(0!=b)return a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),IssuingDialog.dispose(b,a.ERROR.Code,a.ERROR.Message,!1,function(){l(n(b,c))}),!1;IssuingDialog.dispose(b,0,null,!1,function(){l(n(b))});return!0})})},1E3)):(l(n(-1)),d=f=null);else{var g=a.loadUI("certprocessing");IssuingDialog=g({type:"CERT_ISSUE",args:null,onConfirm:null,onCancel:null});IssuingDialog.show();g="root";b==a.CONST.__USFB_M_DISK.device&&(g="");a.Whale().issueCertificate(h,k,e,g,c,function(b,c){if(0!=b)return IssuingDialog.dispose(b,a.ERROR.Code,a.ERROR.Message,!1,function(){l(n(b,c))}),!1;IssuingDialog.dispose(b,0,null,!1,function(){l(n(b))});return!0})}else if(2&a.ESVS.Mode&&a.uiUtil().isItPFDevice(b)){var q=function(b){if(b==a.CONST.__PF_M_LS.device){if(!a.PFSH)return l(null),!1;try{a.usWebToolkit.usWebCMP.issueCert(h,k,d,document.domain,"",a.PFSH,function(b,c,e){1===b?IssuingDialog.dispose(0,0,null,!0,function(){var b=a.loadUI("confirm")({type:null,args:{msg:m.IDS_CONFIRMBOX_WILL_YOU_BACKUP_CERT},onConfirm:function(){b.dispose();a.uiUtil().isItPortableDevice()?Va():Ua(d);d=null;l(n())},onCancel:function(){b.dispose();d=null;l(n(998,a.uiUtil().getErrorMessageLang().IDS_CANCEL_BACKUP))}});b.show()}):(2===b?(a.ERROR.Code=-1,a.ERROR.Message=c,IssuingDialog.dispose(-1,a.ERROR.Code,a.ERROR.Message,!0,function(){l(n(a.ERROR.Code,a.ERROR.Message))})):(a.ERROR.Code=e.code,a.ERROR.Message=e.message,IssuingDialog.dispose(-2,a.ERROR.Code,a.ERROR.Message,!0,function(){l(n(a.ERROR.Code,a.ERROR.Message))})),d=null)})}catch(F){a.ERROR.Code=F.code,a.ERROR.Message=F.message,IssuingDialog.dispose(-2,a.ERROR.Code,a.ERROR.Message,!1,function(){l(n(a.ERROR.Code,a.ERROR.Message))}),d=null}}else if(b==a.CONST.__PF_M_SS.device)try{var c=function(b,c,e){1==b?IssuingDialog.dispose(0,0,null,!0,function(){var b=a.loadUI("confirm")({type:null,args:{msg:m.IDS_CONFIRMBOX_WILL_YOU_BACKUP_CERT},onConfirm:function(){b.dispose();a.uiUtil().isItPortableDevice()?Xa():Wa(d);d=null;l(n())},onCancel:function(){b.dispose();d=null;l(n(998,a.uiUtil().getErrorMessageLang().IDS_CANCEL_BACKUP))}});b.show()}):2==b?IssuingDialog.dispose(b,b,c,!0,function(){l(n(b,c))}):3==b&&(b=e.code,IssuingDialog.dispose(b,b,e.message,!0,function(){l(n(e.code,e.message))}))},e=function(b,c,d,e){a.CCPFSH().SaveUserCert(d,c,!0,function(a,b){0!=a?e(!1):e(!0)})};a.CCPFSH().GetCCStorageHandler(u.EncAlgo,u.HashAlgo,u.BSPKI,function(b,f){a.usWebToolkit.usWebCMP.issueCert(h,k,d,null,"",f,c,null,null,e)})}catch(F){a.ERROR.Code=F.code,a.ERROR.Message=F.message,IssuingDialog.dispose(-2,a.ERROR.Code,a.ERROR.Message,!0,function(){l(n(F.code,F.message))}),d=null}};g=a.loadUI("certprocessing");IssuingDialog=g({type:"CERT_ISSUE",args:null,onConfirm:null,onCancel:null});IssuingDialog.show();g=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");g.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/lang/"+a.ESVS.Language+"/certbackup_"+a.ESVS.Language+".js?version="+a.ver,!1);g.send(null);var m=eval(g.responseText);setTimeout(function(){q(b)},1E3)}}function g(b,c,d){6===b?e(b,c,"",d):(PWDialog=a.loadUI(2===b?"pin":"newpassword")({type:null,args:null,onConfirm:function(a,f){PWDialog.dispose();e(b,c,a,f,d)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();l(n(a.ERROR.Code,a.ERROR.Message));PWDialog.dispose()}}),PWDialog.show())}function f(){p=a.loadUI("storageselect")({type:"CERT_STORAGE",args:{possibleWhale:!0},onConfirm:function(b,c,d){p.dispose();0==a.ESVS.IssueCertInBIOToken&&b==a.CONST.__USFB_M_HSMKEY.device&&-1!=d.indexOf("BIO_")?(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_CANT_ISSUECERT_BIOTOKEN,l(n(a.ERROR.Code,a.ERROR.Message))):3===b?(PINDialog=a.loadUI("pin")({type:"PIN_SAVE_TOKEN",args:null,onConfirm:function(a){PINDialog.dispose();g(b,c,a)},onCancel:function(){PINDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();l(n(a.ERROR.Code,a.ERROR.Message))}}),PINDialog.show()):g(b,c,"")},onCancel:function(){p.dispose();a.uiUtil().getUserCancelErrCodeNMsg();l(n(a.ERROR.Code,a.ERROR.Message))}});p.show()}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!c)return!1;var h=b,k=d,l=c;a.reInitialize();if(h&&k)f();else{var p=a.loadUI("certissue")({type:null,args:null,onConfirm:function(a,b){h=a;k=b;p.dispose();f()},onCancel:function(){p.dispose();a.uiUtil().getUserCancelErrCodeNMsg();l(n(a.ERROR.Code,a.ERROR.Message))}});p.show()}return!0}},IssueKMCert:function(b){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if(b&&!document.getElementById("us-div-cert-select")){var d=n();a.reInitialize();var c=a.loadUI("certselect")({type:"CERT_RENEWAL_KMCERT",args:{dn:null,possibleWhale:!1},onConfirm:function(e,g,f,h,k,l){c.dispose();if(confirm(g)){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(f))return a.nimservice()?(RenewingDialog=a.loadUI("certprocessing")({type:"CERT_ISSUE",args:null,onConfirm:null,onCancel:null}),RenewingDialog.show(),a.nimservice().IssueKMCertificate(a.ESVS.CMPIP,a.ESVS.CMPPort,k,l,function(c,e){0==c?RenewingDialog.dispose(0,0,null,!0,function(){b(d)}):(a.ERROR.Code=c,a.ERROR.Message=e,RenewingDialog.dispose(c,a.ERROR.Code,a.ERROR.Message,!1,function(){b(n(c,e))}))})):b(n(-1)),!1}else a.uiUtil().getUserCancelErrCodeNMsg(),b(n(a.ERROR.Code,a.ERROR.Message))},onCancel:function(){c.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();b(n(a.ERROR.Code,a.ERROR.Message))}});c.show();return!0}},RevocateCert:function(b,d){function c(b,c,d,f){var h=a.loadUI("certrevoke")({type:null,args:null,onConfirm:function(f){h.dispose();if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(d))if(d!=a.CONST.__USFB_M_DISK.device&&d!=a.CONST.__USFB_M_HDD.device||null==a.Whale())a.nimservice()?(k=a.loadUI("certprocessing"),RevokingDialog=k({type:"CERT_REVOCATION",args:null,onConfirm:null,onCancel:null}),RevokingDialog.show(),a.nimservice().RevokeCertificate(a.ESVS.CMPIP,a.ESVS.CMPPort,b,c,f,1,function(a,b){0===a?RevokingDialog.dispose(0,null,null,!0,function(){e(n(0))}):RevokingDialog.dispose(a,a,b,!1,function(){e(n(a,b))})})):(U(),e(n(-1)));else{var k=a.loadUI("certprocessing");RevokingDialog=k({type:"CERT_REVOCATION",args:null,onConfirm:null,onCancel:null});RevokingDialog.show();k="key_compromise";switch(parseInt(f)){case 1:k="key_compromise";break;case 3:k="affiliation_changed";break;case 5:k="cessation_of_operation"}a.Whale().revokeCertificate(b,c,k,function(a,b){0===a?RevokingDialog.dispose(0,null,null,!0,function(){e(n(0))}):RevokingDialog.dispose(a,a,b,!1,function(){e(n(a,b))})})}else if(2&a.ESVS.Mode&&a.uiUtil().isItPFDevice(d)){var q=function(){if(d==a.CONST.__PF_M_LS.device)return a.PFSH;if(d==a.CONST.__PF_M_SS.device)return a.CCPFSH()};k=a.loadUI("certprocessing");RevokingDialog=k({type:"CERT_REVOCATION",args:null,onConfirm:null,onCancel:null});RevokingDialog.show();setTimeout(function(){var d=a.usWebToolkit.usWebCMP.revReason.keyCompromise;switch(f){case 1:d=a.usWebToolkit.usWebCMP.revReason.keyCompromise;break;case 3:d=a.usWebToolkit.usWebCMP.revReason.afilationChanged;break;case 5:d=a.usWebToolkit.usWebCMP.revReason.superseded}try{a.usWebToolkit.usWebCMP.revocation(a.PFUC[b].signcert,a.PFUC[b].signpri,a.PFUC[b].kmcert,c,document.domain,d,q(),function(d,f,h){b=0;c=null;1===d?RevokingDialog.dispose(0,0,null,!0,function(){e(g)}):2===d?(a.ERROR.Code=-1,a.ERROR.Message=f,g.resultCode=a.ERROR.Code,g.resultMessage=a.ERROR.Message,RevokingDialog.dispose(-1,a.ERROR.Code,a.ERROR.Message,!0,function(){e(g)})):(a.ERROR.Code=h.code,a.ERROR.Message=h.message,g.resultCode=a.ERROR.Code,g.resultMessage=a.ERROR.Message,RevokingDialog.dispose(-2,a.ERROR.Code,a.ERROR.Message,!0,function(){e(g)}))})}catch(v){b=0,c=null,a.ERROR.Code=v.code,a.ERROR.Message=v.message,g.resultCode=a.ERROR.Code,g.resultMessage=a.ERROR.Message,RevokingDialog.dispose(-2,a.ERROR.Code,a.ERROR.Message,!0,function(){e(g)})}},1E3)}},onCancel:function(){U();h.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});h.show()}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if(b&&!document.getElementById("us-div-cert-select")){var e=b,g={};a.reInitialize();var f=a.loadUI("certselect")({type:"CERT_REVOCATION",args:{dn:null,possibleWhale:!0},onConfirm:function(b,k,l,p,t,m){f.dispose();var h=!0;d&&(h=d(m));if(!h)return g.resultCode=a.ERROR.Code=998,g.resultMessage=a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_NOALLOW_REVOCATION,g.certAttrs=m,e(g),!0;var q=a.loadUI("confirm")({type:null,args:{msg:b},onConfirm:function(){q.dispose();c(k,l,p,t)},onCancel:function(){U();q.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});q.show()},onCancel:function(){f.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});f.show();return!0}},SOECert:function(b,d){function c(b,c,d,f){4<=a.ESVS.Mode&&(a.nimservice()?(RevokingDialog=a.loadUI("certprocessing")({type:"CERT_SOE",args:null,onConfirm:null,onCancel:null}),RevokingDialog.show(),a.nimservice().RevokeCertificate(a.ESVS.CMPIP,a.ESVS.CMPPort,b,c,6,0,function(a,b){0===a?RevokingDialog.dispose(0,null,null,!0,function(){e(n(0))}):RevokingDialog.dispose(a,a,b,!1,function(){e(n(a,b))})})):(U(),e(n(-1))))}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||document.getElementById("us-div-cert-select"))return!1;var e=b,g={};a.reInitialize();var f=a.loadUI("certselect")({type:"CERT_SOE",args:{dn:null,possibleWhale:!1},onConfirm:function(b,k,l,p,t,m){f.dispose();var h=!0;d&&(h=d(m));if(!h)return g.resultCode=a.ERROR.Code=998,g.resultMessage=a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_NOALLOW_SOE,g.certAttrs=m,e(g),!0;var q=a.loadUI("confirm")({type:null,args:{msg:b},onConfirm:function(){q.dispose();c(k,l,p,t)},onCancel:function(){U();q.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});q.show()},onCancel:function(){f.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});f.show();return!0}},VerifyVID:function(b,d){function c(b,c,f,p,t,m,r){if("PFS"==r)try{var h=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[f].signcert),k=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[f].signpri),l=a.usWebToolkit.pkcs8.verifyVID(k,p,c,h);p=c="";l?g(n(0)):g(n(14208,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID))}catch(y){p=c="",a.ERROR.Code=y.code,a.ERROR.Message=y.message,g(n(y.code,y.message))}else"NIM"==r&&(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_VID_VERIFY_MESSAGE),a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.SELECTINFO.curdevice==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP?(b=a.usWebToolkit.md.algorithms.sha256.create(),b.start(),b.update(a.usWebToolkit.util.encodeUtf8(_plainText)),b=b.digest().toHex(),b=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+b),f={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(b){b=JSON.parse(b);if(0!=b.returnObj.returnCode&&"E1000"!=b.returnObj.returnCode)e.resultMessage=a.ERROR.Message=b.returnObj.returnMsg,e.resultCode=a.ERROR.Code=b.returnObj.returnCode,g(e);else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(e),g(e);else{var f=b.signResult.b64Signer;b=a.usWebToolkit.util.decode64(b.signResult.R[0]);f=a.usWebToolkit.pki.certificateFromBase64(f);a.usWebToolkit.pkcs8.verifyVIDForHSM(b,c,f)?g(n(0)):(a.ERROR.Code=14208,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID,d(n(14208,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]},f.msg[0]=b,jSmartCertNP.SignByJSON(f).Open()):a.nimservice().VerifyVID(f,p,b,c,function(b,d){4305E4==b&&(b=14208);a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?g(n(0)):(a.ERROR.Code=b,a.ERROR.Message=d,g(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)));p=c=""}):a.Whale().verifyVID(f,p,c,function(b,c){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?g(n(0)):(3061==b&&(b=14208),a.ERROR.Code=b,a.ERROR.Message=c,d(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))}))}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d||document.getElementById("us-div-cert-select"))return!1;var e=n(),g=function(a){1==d.length?d(a):(null==a&&(a=n(-1)),d(a.resultCode,a.resultMessage))};a.reInitialize();var f=a.loadUI("certselect")({type:"VID_VERIFICATION",args:{dn:null,possibleWhale:!0},onConfirm:function(d,e,l,p,t){f.dispose();if(b)c(0,b,d,e,l,p,t);else{var h=a.loadUI("ssn")({type:null,onConfirm:function(a){c(1,a,d,e,l,p,t);h.dispose()},onCancel:function(){U();h.dispose();a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});h.show()}},onCancel:function(){f.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});f.show();return!0}},ManageCert:function(){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{a.reInitialize();var b=a.loadUI("certmanage")({type:"CERT_MANAGEMENT",onConfirm:null,onCancel:function(){b.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg()}});b.show();return!0}},ManageCertByType:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(4&a.ESVS.Mode||1!=b&&6!=b&&7!=b){a.reInitialize();var c=null,e=n();d&&(c=d);var g=a.loadUI("certmanage")({type:"CERT_MANAGEMENT",args:{type:b},onConfirm:function(a,b){g.dispose(!0);c&&(e.certAttrs=b,e.driveName=a,c(e))},onCancel:function(){g.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg()}});g.show();return!0}a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_FUC_NOT_SUPPORT)}},ImportCertFromMobileApp:function(b,d,c){function e(){try{try{a.PFSH.SelectStorage(1)}catch(m){alert("error : "+m.detail),h(n(m.code,m.message))}try{a.PFSH.LoadAllCerts(document.domain)}catch(m){301E5===m.code?(a.PFSH.InstallCACerts(document.domain),a.PFSH.LoadAllCerts(document.domain)):(alert("error : "+m.detail),h(n(m.code,m.message)))}var c=a.PFSH.SetP12HexOnMemory(b,d),e=c.aluc[c.index];a.usWebToolkit.x509Certificate.parser(e.signcert,"Base64");var g=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),t=a.certUtil().getIssuerEnName(g);a.PFSH.SaveUserCert(t,e,document.domain,!0);h(f)}catch(m){alert("error : "+m.detail),h(null)}}function g(){a.CCPFSH().SetP12HexOnMemory(b,d,function(b,d,e){0==b?(b=e.aluc[e.index],a.usWebToolkit.x509Certificate.parser(b.signcert,"Base64"),d=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),d=a.certUtil().getIssuerEnName(d),a.CCPFSH().SaveUserCert(d,b,!0,function(a){h(n(a))})):c(n(b,d))})}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{d&&b||h(null);var f=n();a.PFSH||h(null);f=n();var h=function(a){1==c.length?c(a):(null==a&&(a=n(-1)),c(a.resultCode,a.resultMessage))};if(0==b.indexOf("MI")){for(b=b.replace(/_/g,"/").replace(/-/g,"+");0!=b.length%4;)b+="=";b=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.util.decode64(b))}a.reInitialize();SSDialog=a.loadUI("storageselect")({type:"CERT_STORAGE",args:{possibleWhale:!1},onConfirm:function(b,c){SSDialog.dispose();b==a.CONST.__PF_M_LS.device?e():b==a.CONST.__PF_M_SS.device&&a.CCPFSH().IsCCPFSHAvailable(function(b){0==b?g():a.CCPFSH().GetCCStorageHandler(a.ESVS.EncAlgo,a.ESVS.HashAlgo,a.ESVS.BSPKI,function(a,b){0==a?g():SSDialog.dispose()})})},onCancel:function(){SSDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();h(n(a.ERROR.Code,a.ERROR.Message))}});SSDialog.show()}},SetSelectedDevice:function(b){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{var d="",c;for(c in a.CONST.medias)if(a.CONST.medias[c].device===b){d=a.CONST.medias[c].name;break}a.ESVS.Media.defaultdevice=d}},NimServiceLoaded:function(){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else return a.nimservice()?a.nimservice().GetIframeLoaded():null},SecureMail:function(b,d,c,e,g){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if("seed"!=d&&(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_ALGORITHM,g(n(a.ERROR.Code,a.ERROR.Message))),null==c||""==c||1>c.length)alert(a.uiUtil().getErrorMessageLang().IDS_NOT_ENCRYPTED_DATA);else{a.reInitialize();var f=0,h=a.loadUI("securemail")({type:"SECURE_MAIL",args:{algorithm:d,data:c,decryptData:this.DecryptFileData,mode:b},onConfirm:function(c,d,p,t){if(3d;d++)g+="abcdefghijklmnopqrstuvwxyz".substr(f++,1);f=g+"0123450123456789";d=b.toLowerCase();if("seed"==d)g=f.substring(0,16),f=f.substring(16,32);else if("3des"==d)g=f.substring(0,24),f=f.substring(24,32);else if("rc2"==d)g=f.substring(0,5),f=f.substring(5,13);else if("des"==d)g=f.substring(0,8),f=f.substring(8,16);else return-10;c=a.usWebToolkit.util.decode64(c);"3des"==d&&(b="des");d=null;try{var h=a.usWebToolkit.cipher.algorithms[b].startDecrypting(g,f);h.update(a.usWebToolkit.util.createBuffer(c));if(0==h.finish())return-11;0==e||null==e?d=h.output.toHex():1==e&&(d=h.output.getBytes())}catch(k){return a.ERROR.Code=k.code,a.ERROR.Message=k.message,-12}if(0==e||null==e)try{d=a.usWebToolkit.unicode.hex2UTF8(d)}catch(k){return-13}return d}},getFileDownload:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if("function"==typeof xa){if(null==d||""==d||1>d.length)d=document.location.href.split("/"),d=d[d.length-1];b=new Blob([b],{type:"application/otect-stream"});try{xa(b,d)}catch(c){alert(a.uiUtil().getErrorMessageLang().IDS_ERROR_BROWSER_NOT_SUPPORT)}}else alert(a.uiUtil().getErrorMessageLang().IDS_ERROR_BROWSER_NOT_SUPPORT)},SignData_noConWithHash:function(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||document.getElementById("us-div-cert-select")||!f)return!1;var h=n(),k=function(a){1==f.length?f(a):(null==a&&(a=n(-1)),f(a.jsonSignedData,a.b64RValue,a.certAttrs))};a.reInitialize();var l=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:d,possibleWhale:!0},onConfirm:function(a,d,f,h,q,x){na(b,c,a,h,q,x,e,l,g,k)},onCancel:function(){l.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg(h);k(h)}});l.show();return!0}},SignData_noConWithHashEx:function(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d||!f)return!1;a.reInitialize();if(0==b){var h=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:c,possibleWhale:!0},onConfirm:function(a,b,c,n,m,r){na(d,e,a,n,m,r,null,h,g,f)},onCancel:function(){h.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});h.show()}else na(d,e,a.SELECTINFO.cert,a.SELECTINFO.index,a.SELECTINFO.pw,a.SELECTINFO.curdevice,null,null,g,f)}},SignDataP7NVID_noConWithHash:function(b,d,c,e,g,f,h){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||document.getElementById("us-div-cert-select")||!h)return!1;a.reInitialize();var k=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1_AND_VID_VERIFICATION",args:{dn:d,possibleWhale:!0},onConfirm:function(d,p,t,m,r,q){var x={};if("undefined"!==typeof d&&"undefined"!==typeof p)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(q))if(q!=a.CONST.__USFB_M_DISK.device&&q!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(q==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){t={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(e){e=JSON.parse(e);var f=n();if(0!=e.returnObj.returnCode&&"E1000"!=e.returnObj.returnCode)f.resultMessage=a.ERROR.Message=e.returnObj.returnMsg,f.resultCode=a.ERROR.Code=e.returnObj.returnCode,a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){k.dispose(!0)},10),h(f);else if("E1000"==e.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(f),a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){k.dispose(!0)},10),h(f);else{f=e.signResult.b64Signer;var m=null;_certAttrs=a.certUtil().getTheCertAttributes(f,"Base64");B(d,p,q,f,_certAttrs);if(1==e.signResult.b64SignedData.length){var r=e.signResult.b64SignedData[0];r=a.usWebToolkit.util.decode64(r);var x=a.usWebToolkit.pki.certificateFromBase64(f),v=a.usWebToolkit.pkcs7.createSignedData();v.signWithHashDataNP1(r,a.usWebToolkit.util.decode64(b),c.toLowerCase(),x);m=a.usWebToolkit.pkcs7.messageToBase64(v)}else{var l=0;m={};for(var y in b)""==b[y]?m[y]="":(r=e.signResult.b64SignedData[l++],r=a.usWebToolkit.util.decode64(r),x=a.usWebToolkit.pki.certificateFromBase64(f),v=a.usWebToolkit.pkcs7.createSignedData(),v.signWithHashDataNP1(r,a.usWebToolkit.util.decode64(b[y]),c.toLowerCase(),x),m[y]=a.usWebToolkit.pkcs7.messageToBase64(v))}N(g,d,p,m,_certAttrs,q,"",h,e.signResult.R[0],f);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10)}},multisignYn:"Y",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};if("object"==typeof b){t.multisignYn="Y";for(var v in b)""!=b[v]&&(m=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.util.decode64(b[v])),t.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+m)))}else t.multisignYn="N",m=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.util.decode64(b[v])),t.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+m));jSmartCertNP.SignByJSON(t).Open()}else if(a.nimservice()){t=0;m=[];if(b)for(v in b)m[t]=b[v],t++;a.nimservice().GetSignDataP7WithHash(d,p,c,m,"utf8",!1,null,!0,f,function(c,e,f,m,v,l){if(0!=c)a.ERROR.Code=c,a.ERROR.Message=e,a.uiUtil().errMsgBox(e,a.ERROR.Code),h(n(c,e));else{c=0;if("object"==typeof f)for(var y in b)x[y]=f[c++];else x=f;null==r&&a.CONST.__USFB_M_MOBILETOKEN.device==q&&(r=a.certUtil().getTheCertAttributes(v,"Base64"));N(g,d,p,x,r,q,l,h)}p=g="";a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10)})}else h(null),setTimeout(function(){k.dispose(!0)},10);else-1==d||""==p?(resultObject.resultMessage=a.ERROR.Message=t,resultObject.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){k.dispose(!0)},10),h(resultObject)):a.Whale().getSignDataP7_noConWithHash(b,d,p,c,f,function(b,c,e){0!=b?(a.ERROR.Code=b,a.ERROR.Message=c,a.uiUtil().errMsgBox(c,a.ERROR.Code),h(n(b,c))):N(g,d,p,e,r,q,"",h);p=g="";a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){k.dispose()},10)});else{try{na(b,c,a.PFUC[d].signcert,d,p,q,e,k,f,function(b){N(g,d,p,b.jsonSignedData,a.certUtil().getTheCertAttributes(a.PFUC[d].signcert,"Base64"),q,"",h)})}catch(y){a.ERROR.Code=y.code,a.ERROR.Message=y.message,a.uiUtil().errMsgBox(y.message,a.ERROR.Code),h(n(y.code,y.message))}d=p=pri=null;setTimeout(function(){k.dispose(!0)},10)}else h(null),setTimeout(function(){k.dispose(!0)},10)},onCancel:function(){k.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();h(n(a.ERROR.Code,a.ERROR.Message))}});k.show();return!0}},VerifySignData_noConWithHash:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!d)return!1;a.reInitialize();c=null;try{var g=a.usWebToolkit.util.decode64(b);c=a.usWebToolkit.pkcs7.messageFromBase64(d);c.verifyWithHash(g);1==c.verifyResult?e(0):e(-1)}catch(f){a.ERROR.Code=f.code,a.ERROR.Message=f.message,e(f.code)}}},SignMultiDataP7:function(b,d,c,e,g,f){if(!b&&!d||!f||document.getElementById("us-div-cert-select"))return!1;var h=n(),k=function(a){1==f.length?f(a):(null==a&&(a=n(-1)),f(a.jsonSignedData,a.b64RValue,a.certAttrs,a.curDevice))};a.reInitialize();var l=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:c,possibleWhale:!0},onConfirm:function(c,f,m,r,q,x){var p=1,y={},t=m;if("undefined"!==typeof r&&"undefined"!==typeof q)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(x))if(x!=a.CONST.__USFB_M_DISK.device&&x!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(x==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){c={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(c){c=JSON.parse(c);if(0!=c.returnObj.returnCode&&"E1000"!=c.returnObj.returnCode)h.resultMessage=a.ERROR.Message=c.returnObj.returnMsg,h.resultCode=a.ERROR.Code=c.returnObj.returnCode,setTimeout(function(){l.dispose(!0)},10),k(h);else if("E1000"==c.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(h),setTimeout(function(){l.dispose(!0)},10),k(h);else{var d=c.signResult.b64Signer;t=a.certUtil().getTheCertAttributes(d,"Base64");B(r,q,x,d,t);h.certAttrs=t;if(1==c.signResult.b64SignedData.length){var e=c.signResult.b64SignedData[0];e=a.usWebToolkit.util.decode64(e);var f=a.usWebToolkit.pki.certificateFromBase64(d),m=a.usWebToolkit.pkcs7.createSignedData();m.signWithP1(e,b,f,null,null);h.jsonSignedData=a.usWebToolkit.pkcs7.messageToBase64(m)}else{var p=0;h.jsonSignedData={};for(var v in b)""==b[v]?h.jsonSignedData[v]="":(e=c.signResult.b64SignedData[p++],e=a.usWebToolkit.util.decode64(e),f=a.usWebToolkit.pki.certificateFromBase64(d),m=a.usWebToolkit.pkcs7.createSignedData(),m.signWithP1(e,b[v],f,null,null),h.jsonSignedData[v]=a.usWebToolkit.pkcs7.messageToBase64(m))}if(g)try{var n=a.usWebToolkit.util.decode64(c.signResult.R[0]),y=a.usWebToolkit.pki.certificateFromBase64(g);m=a.usWebToolkit.pkcs7.createEnvelopedData();m.addRecipient(y);m.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];m.content=n;m.encrypt();h.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(m)}catch(rb){}h.curDevice=x;h.tokenLabel="";k(h);setTimeout(function(){l.dispose()},10)}},multisignYn:"Y",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[],plainText:[]};if(b)if("object"==typeof b)for(D in b){if(""!=b[D]){var z=a.usWebToolkit.util.encodeUtf8(b[D]),A=a.usWebToolkit.md.algorithms.sha256.create();A.start();A.update(z);A=A.digest().toHex();c.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+A));e&&c.plainText.push(z)}}else z=a.usWebToolkit.util.encodeUtf8(b),A=a.usWebToolkit.md.algorithms.sha256.create(),A.start(),A.update(z),A=A.digest().toHex(),c.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+A)),e&&c.plainText.push(z);else if("object"==typeof b)for(D in jsonPlainData)z[D]=d[D];else z=d;jSmartCertNP.SignByJSON(c).Open()}else if(a.nimservice()){A=0;z=[];if(b)if("object"==typeof b)for(D in b)z[A++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[D]));else z=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));else if("object"==typeof jsonPlainData)for(D in jsonPlainData)z[A++]=d[D];else z=d;a.nimservice().GetSignDataP7(r,q,z,"utf8",e,g,a.ESVS.multiuse,!1,function(c,e,g,m,p,v){if(0!=c)a.ERROR.Code=c,a.ERROR.Message=e,k(n(a.ERROR.Code,a.ERROR.Message));else{c=0;e=b;d&&(e=d);if("object"==typeof g)for(var z in e)y[z]=g[c++];else y=g;null==t&&a.CONST.__USFB_M_MOBILETOKEN.device==x?(t=a.certUtil().getTheCertAttributes(p,"Base64"),B(r,q,x,p,t)):B(r,q,x,f,t);h.jsonSignedData=y;h.b64RValue=m;h.certAttrs=t;h.curDevice=x;h.tokenLabel=v;k(h)}r=q=f=F=null;a.uiUtil().loadingBox(!1,"us-div-list-load");l.dispose()})}else k(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),l.dispose(!0);else if(-1==r||""==q)h.resultMessage=a.ERROR.Message=c,h.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){l.dispose(!0)},10),k(h);else{a.uiUtil().loadingBox(!0,"us-div-list-load",1);z={};if(b)if("object"==typeof b)for(var D in b)z[D]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[D]));else z=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));else if("object"==typeof b)for(D in jsonPlainData)z[D]=d[D];else z=d;a.Whale().getSignDataP7(z,r,q,e,function(b,c,d){0!=b?(h.resultCode=b,h.resultMessage=c,k(h)):(B(r,q,x,f,t),h.jsonSignedData=d,h.certAttrs=t,h.curDevice=x,h.tokenLabel="",g?a.Whale().getCertR(r,q,function(b,c,d){a.uiUtil().loadingBox(!1,"us-div-list-load",1);if(0==b)try{var e=a.usWebToolkit.util.hexToBytes(d),f=a.usWebToolkit.pki.certificateFromBase64(g),q=a.usWebToolkit.pkcs7.createEnvelopedData();q.addRecipient(f);q.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];q.content=e;q.encrypt();h.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(q)}catch(rb){}k(h);setTimeout(function(){l.dispose()},10)}):(k(h),setTimeout(function(){l.dispose()},10)))})}else{a.uiUtil().loadingBox(!0,"us-div-list-load");if(e)try{f=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[r].signcert);var F=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[r].signpri),J=a.usWebToolkit.pkcs8.decryptPrivateKeyInfo(F,q),W=a.usWebToolkit.pkcs8.getPrivateKeyAttributesRandom(J);if("object"==typeof b)for(p in b){var w=a.usWebToolkit.pkcs7.createSignedData();w.sign(b[p],f,F,q,null,null);y[p]=a.usWebToolkit.pkcs7.messageToBase64(w)}else w=a.usWebToolkit.pkcs7.createSignedData(),w.sign(b,f,F,q,null,null),y=a.usWebToolkit.pkcs7.messageToBase64(w);h.jsonSignedData=y;if(g)try{var za=a.usWebToolkit.pki.certificateFromBase64(g),T=a.usWebToolkit.pkcs7.createEnvelopedData();T.addRecipient(za);T.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];T.content=W;T.encrypt();h.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(T)}catch(O){}h.curDevice=x;h.certAttrs=a.certUtil().getTheCertAttributes(a.PFUC[r].signcert,"Base64");k(h)}catch(O){a.ERROR.Code=O.code,a.ERROR.Message=O.message,a.uiUtil().errMsgBox(O.message,a.ERROR.Code),k(n(O.code,O.message))}else try{f=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[r].signcert);F=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[r].signpri);J=a.usWebToolkit.pkcs8.decryptPrivateKeyInfo(F,q);W=a.usWebToolkit.pkcs8.getPrivateKeyAttributesRandom(J);for(p in b){A=a.usWebToolkit.md.algorithms.sha256.create();A.start();var Ta=a.usWebToolkit.util.encodeUtf8(b[p]);A.update(Ta);w=a.usWebToolkit.pkcs7.createSignedData();w.signWithHashData(A.digest().getBytes(),"sha256",f,F,q,null,null,!1);y[p]=a.usWebToolkit.pkcs7.messageToBase64(w)}h.jsonSignedData=y;if(g)try{za=a.usWebToolkit.pki.certificateFromBase64(g),T=a.usWebToolkit.pkcs7.createEnvelopedData(),T.addRecipient(za),T.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"],T.content=W,T.encrypt(),h.b64RValue=a.usWebToolkit.pkcs7.messageToBase64(T)}catch(O){}h.curDevice=x;h.certAttrs=a.certUtil().getTheCertAttributes(a.PFUC[r].signcert,"Base64");k(h)}catch(O){a.ERROR.Code=O.code,a.ERROR.Message=O.message,a.uiUtil().errMsgBox(O.message,a.ERROR.Code),k(n(O.code,O.message))}a.uiUtil().loadingBox(!1,"us-div-list-load");l.dispose();r=q=f=F=null}},onCancel:function(){l.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();k(n(a.ERROR.Code,a.ERROR.Message))}});l.show();return!0},SignMultiDataP7NVerifyVID:function(b,d,c,e,g,f){if(!b&&!d||!f||document.getElementById("us-div-cert-select"))return!1;var h=n(),k=function(a){1==f.length?f(a):(null==a&&(a=n(-1)),f(a.resultCode,a.signedData,a.certAttrs,a.curDevice))};a.reInitialize();var l=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:c,possibleWhale:!0},onConfirm:function(c,f,m,r,q,x){var v=1,p={},t=m;if("undefined"!==typeof r&&"undefined"!==typeof q)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(x))if(x!=a.CONST.__USFB_M_DISK.device&&x!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(x==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){c={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(c){c=JSON.parse(c);if(0!=c.returnObj.returnCode&&"E1000"!=c.returnObj.returnCode)h.resultMessage=a.ERROR.Message=c.returnObj.returnMsg,h.resultCode=a.ERROR.Code=c.returnObj.returnCode,setTimeout(function(){l.dispose(!0)},10),k(h);else if("E1000"==c.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(h),setTimeout(function(){l.dispose(!0)},10),k(h);else{var d=c.signResult.b64Signer;t=a.certUtil().getTheCertAttributes(d,"Base64");B(r,q,x,d,t);h.certAttrs=t;var e="";if(1==c.signResult.b64SignedData.length){var f=c.signResult.b64SignedData[0];f=a.usWebToolkit.util.decode64(f);var m=a.usWebToolkit.pki.certificateFromBase64(d),p=a.usWebToolkit.pkcs7.createSignedData();p.signWithP1(f,b,m,null,null);e=a.usWebToolkit.pkcs7.messageToBase64(p)}else{var v=0;e={};for(var n in b)""==b[n]?e[n]="":(f=c.signResult.b64SignedData[v++],f=a.usWebToolkit.util.decode64(f),m=a.usWebToolkit.pki.certificateFromBase64(d),p=a.usWebToolkit.pkcs7.createSignedData(),p.signWithP1(f,b[n],m,null,null),e[n]=a.usWebToolkit.pkcs7.messageToBase64(p))}N(g,r,q,e,t,x,"",k,c.signResult.R[0],d);a.uiUtil().loadingBox(!1,"us-div-list-load",1);setTimeout(function(){l.dispose()},10)}},multisignYn:"Y",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[],plainText:[]};if(b)if("object"==typeof b)for(A in b){if(""!=b[A]){var z=a.usWebToolkit.util.encodeUtf8(b[A]);m=a.usWebToolkit.md.algorithms.sha256.create();m.start();m.update(z);m=m.digest().toHex();c.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+m));e&&c.plainText.push(z)}}else z=a.usWebToolkit.util.encodeUtf8(b),m=a.usWebToolkit.md.algorithms.sha256.create(),m.start(),m.update(z),m=m.digest().toHex(),c.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+m)),e&&c.plainText.push(z);else if("object"==typeof b)for(A in jsonPlainData)z[A]=d[A];else z=d;jSmartCertNP.SignByJSON(c).Open()}else if(a.nimservice()){c=0;z=[];if(b)if("object"==typeof b)for(A in b)z[c++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[A]));else z=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));else if("object"==typeof b)for(A in jsonPlainData)z[c++]=d[A];else z=d;a.nimservice().GetSignDataP7(r,q,z,"utf8",e,null,!0,!1,function(c,e,h,m,v,y){if(0!=c)a.ERROR.Code=c,a.ERROR.Message=e,k(n(a.ERROR.Code,a.ERROR.Message));else{c=0;e=b;d&&(e=d);if("object"==typeof h)for(var z in e)p[z]=h[c++];else p=h;null==t&&a.CONST.__USFB_M_MOBILETOKEN.device==x&&(t=a.certUtil().getTheCertAttributes(v,"Base64"));N(g,r,q,p,t,x,y,k)}r=q=f=D=null;a.uiUtil().loadingBox(!1,"us-div-list-load");l.dispose()})}else k(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),l.dispose(!0);else if(-1==r||""==q)h.resultMessage=a.ERROR.Message=c,h.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){l.dispose(!0)},10),k(h);else{a.uiUtil().loadingBox(!0,"us-div-list-load",1);z={};if(b)if("object"==typeof b)for(var A in b)z[A]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[A]));else z=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));else if("object"==typeof b)for(A in jsonPlainData)z[A]=d[A];else z=d;a.Whale().getSignDataP7(z,r,q,e,function(b,c,d){0!=b?(h.resultCode=b,h.resultMessage=c,k(h)):(N(g,r,q,d,t,x,"",k),r=q=f=D=null);a.uiUtil().loadingBox(!1,"us-div-list-load",1);setTimeout(function(){l.dispose()},10)})}else{if(e)try{f=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[r].signcert);var D=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[r].signpri);if("object"==typeof b)for(v in b){var F=a.usWebToolkit.pkcs7.createSignedData();F.sign(b[v],f,D,q,null,null);p[v]=a.usWebToolkit.pkcs7.messageToBase64(F)}else F=a.usWebToolkit.pkcs7.createSignedData(),F.sign(b,f,D,q,null,null),p=a.usWebToolkit.pkcs7.messageToBase64(F);N(g,r,q,p,m,x,"",k)}catch(J){a.ERROR.Code=J.code,a.ERROR.Message=J.message,a.uiUtil().errMsgBox(J.message,a.ERROR.Code),k(n(J.code,J.message))}else a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_BROWSER_NOT_SUPPORT,k(n(a.ERROR.Code,a.ERROR.Message));r=q=f=D=null;l.dispose(!0)}else k(null),l.dispose(!0)},onCancel:function(){l.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();k(n(a.ERROR.Code,a.ERROR.Message))}});l.show();return!0},Base64Encoding:function(b,d){b=d&&"binary"==d?b:a.usWebToolkit.util.encodeUtf8(b);return(b=a.usWebToolkit.util.encode64(b))?b:""},Base64Decoding:function(b,d){b=a.usWebToolkit.util.decode64(b);return(d=d&&"binary"==d?b:a.usWebToolkit.util.decodeUtf8(b))?d:""},SignUCPIDReqInfo:function(b,d,c,e,g,f){if(!b||!d||5>d.length||!f||document.getElementById("us-div-cert-select"))return!1;g=a.usWebToolkit.util.decode64(c);var h=n();a.reInitialize();c=function(b,c,d){var e=null,g=b,h=!1,q=a.usWebToolkit.asn1.Class.UNIVERSAL;switch(c){case "UTF8":try{g=a.usWebToolkit.util.encodeUtf8(b)}catch(J){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT UTIL ERROR] during encoding utf8 character set.\ndetail : "+J;f(n(a.ERROR.Code,a.ERROR.Message));return}break;case "INTEGER":g=String.fromCharCode(b);break;case "SEQUENCE":g=[];h=!0;for(var m in b)g.push(b[m]);break;case "EXPLICIT":h=!0,q=a.usWebToolkit.asn1.Class.CONTEXT_SPECIFIC+d,c="NONE",g=[],g.push(b)}try{e=a.usWebToolkit.asn1.create(q,a.usWebToolkit.asn1.Type[c],h,g)}catch(J){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT ASN.1 ERROR] during creating useragreement asn.1 struct.\ndetail : "+J;return}return e};var k=a.nimVersion.split(".");d={version:2,ucpidNonce:g,personIfo:{userAgreement:b,userAgree:d},moduleInfo:{moduleName:"UniSign",moduleVenderName:"CrossCert",moduleVersion:{major:k[0],minor:k[1],build:k[2],revision:k[3]}},ispUrlInfo:document.domain};b={};for(var l in d)if("object"==typeof d[l]){g={};for(var p in d[l])if("object"==typeof d[l][p]){k={};var t={},m;for(m in d[l][p])"major"==m||"minor"==m?k[m]=c(d[l][p][m],"INTEGER"):(t=c(d[l][p][m],"INTEGER"),k[m]="build"==m?c(t,"EXPLICIT",0):c(t,"EXPLICIT",1));g[p]=c(k,"SEQUENCE")}else isNaN(d[l][p])?g[p]=c(d[l][p],"UTF8"):(t=d[l][p],k=0,"1"===t.charAt(0)&&(k|=128),"1"===t.charAt(1)&&(k|=64),"1"===t.charAt(2)&&(k|=32),"1"===t.charAt(3)&&(k|=16),"1"===t.charAt(4)&&(k|=8),t=String.fromCharCode(3),k=String.fromCharCode(k),g[p]=c(t+k,"BITSTRING"));b[l]=c(g,"SEQUENCE")}else"string"==typeof d[l]?b[l]="ucpidNonce"==l?c(d[l],"OCTETSTRING"):c(d[l],"UTF8"):"number"==typeof d[l]&&(b[l]=c(d[l],"INTEGER"));b=c(b,"SEQUENCE");l=null;try{l=a.usWebToolkit.asn1.toDer(b)}catch(x){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT ASN.1 ERROR] during converting object to der format.\ndetail : "+x;f(n(a.ERROR.Code,a.ERROR.Message));return}var r=null;try{r=a.usWebToolkit.util.encode64(l.getBytes())}catch(x){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT UTIL ERROR] during encoding base64 string.\ndetail : "+x;f(n(a.ERROR.Code,a.ERROR.Message));return}var q=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:e},onConfirm:function(b,c,d,e,g,m){"undefined"!==typeof e&&"undefined"!==typeof g&&4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(m)&&(a.nimservice()?a.nimservice().GetSignDataP7(e,g,r,"utf8",!0,null,!1,!1,function(b,c,e){0!=b?(a.ERROR.Code=b,a.ERROR.Message=c,f(n(a.ERROR.Code,a.ERROR.Message))):(h.signedData=e,h.certAttrs=d,f(h));a.uiUtil().loadingBox(!1,"us-div-list-load");q.dispose()}):(f(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),q.dispose(!0)))},onCancel:function(){q.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});q.show();return!0},MultiSignUCPIDReqInfo:function(b,d,c,e){if("object"!=typeof b||!e||document.getElementById("us-div-cert-select"))return!1;var g=n(),f=function(a){return a.replaceAll("/","_").replaceAll("+","-").replaceAll("=","")};a.reInitialize();var h=a.nimVersion.split("."),k=function(b){var c;for(c=b.ucpidNonce.replaceAll("_","/").replaceAll("-","+");0!=c.length%4;)c+="=";c=a.usWebToolkit.util.decode64(c);var d=b.userAgreement,e=b.userAgreeInfo,f=0,g;for(g in e)switch(g){case "realName":e[g]?f+=1E4:f+0;break;case "gender":e[g]?f+=1E3:f+0;break;case "nationalInfo":e[g]?f+=100:f+0;break;case "birthDate":e[g]?f+=10:f+0;break;case "ci":e[g]?f+=1:f+0}for(g=f+"";0!=g.length%5;)g="0"+g;return{version:2,ucpidNonce:c,personIfo:{userAgreement:d,userAgree:g},moduleInfo:{moduleName:"UniSign",moduleVenderName:"CrossCert",moduleVersion:{major:h[0],minor:h[1],build:h[2],revision:h[3]}},ispUrlInfo:b.ispUrlInfo}},l=function(b,c,d){var f=null,g=b,h=!1,q=a.usWebToolkit.asn1.Class.UNIVERSAL;switch(c){case "UTF8":try{g=a.usWebToolkit.util.encodeUtf8(b)}catch(A){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT UTIL ERROR] during encoding utf8 character set.\ndetail : "+A;e(n(a.ERROR.Code,a.ERROR.Message));return}break;case "INTEGER":g=String.fromCharCode(b);break;case "SEQUENCE":g=[];h=!0;for(var k in b)g.push(b[k]);break;case "EXPLICIT":h=!0,q=a.usWebToolkit.asn1.Class.CONTEXT_SPECIFIC+d,c="NONE",g=[],g.push(b)}try{f=a.usWebToolkit.asn1.create(q,a.usWebToolkit.asn1.Type[c],h,g)}catch(A){a.ERROR.Code=1E7;a.ERROR.Message="[TOOLKIT ASN.1 ERROR] during creating useragreement asn.1 struct.\ndetail : "+A;return}return f},p=function(b){var c={},d;for(d in b)if("object"==typeof b[d]){var f={},g;for(g in b[d])if("object"==typeof b[d][g]){var h={},k;for(k in b[d][g])if("major"==k||"minor"==k)h[k]=l(b[d][g][k],"INTEGER");else{var m=l(b[d][g][k],"INTEGER");h[k]="build"==k?l(m,"EXPLICIT",0):l(m,"EXPLICIT",1)}f[g]=l(h,"SEQUENCE")}else isNaN(b[d][g])?f[g]=l(b[d][g],"UTF8"):(m=b[d][g],h=0,"1"===m.charAt(0)&&(h|=128),"1"===m.charAt(1)&&(h|=64),"1"===m.charAt(2)&&(h|=32),"1"===m.charAt(3)&&(h|=16),"1"===m.charAt(4)&&(h|=8),m=String.fromCharCode(3),h=String.fromCharCode(h),f[g]=l(m+h,"BITSTRING"));c[d]=l(f,"SEQUENCE")}else"string"==typeof b[d]?c[d]="ucpidNonce"==d?l(b[d],"OCTETSTRING"):l(b[d],"UTF8"):"number"==typeof b[d]&&(c[d]=l(b[d],"INTEGER"));c=l(c,"SEQUENCE");b=null;try{b=a.usWebToolkit.asn1.toDer(c)}catch(A){return a.ERROR.Code=1E7,a.ERROR.Message="[TOOLKIT ASN.1 ERROR] during converting object to der format.\ndetail : "+A,e(n(a.ERROR.Code,a.ERROR.Message)),""}c=null;try{c=a.usWebToolkit.util.encode64(b.getBytes())}catch(A){return a.ERROR.Code=1E7,a.ERROR.Message="[TOOLKIT UTIL ERROR] during encoding base64 string.\ndetail : "+A,e(n(a.ERROR.Code,a.ERROR.Message)),""}return c},t=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:d},onConfirm:function(c,d,h,l,v,y){if("undefined"!==typeof l&&"undefined"!==typeof v)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(y))if(a.nimservice()){for(var q=[],m=[],r=0;r=b.length)c(0,"","");else if(4&a.ESVS.Mode)a.nimservice()?"FilePath"===l?(b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().MakeHash(1,b,d,function(b,d,e){0==b?c(b,d,e):(a.ERROR.Code=b,a.ERROR.Message=d,c(b,d,""))})):(b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().MakeHash(0,b,d,function(b,d,e){0==b?c(b,d,e):(a.ERROR.Code=b,a.ERROR.Message=d,c(b,d,""))})):(a.ERROR.Code=-1,c(-1,"",""));else if("FilePath"!==l)try{var e=a.usWebToolkit.util.encodeUtf8(h),f=crosscert.md.algorithms[k.toLowerCase()].create();f.start();f.update(e);c(0,"",a.usWebToolkit.util.encode64(f.digest().getBytes()))}catch(G){a.ERROR.Code=G.code,a.ERROR.Message=G.message,c(G.code,G.message,"")}}function f(a){g(a,function(a,b,c){0!=a?m(n(a,b)):(p[r]=c,r++,h.length==r?(t.hashValue=p,m(t)):f(h[r]))})}if(!b)return null;var h=b,k=d,l=c,p=[];k&&"undefined"!==typeof k||(k="SHA256");var t=n(),m=function(a){1==e.length?e(a):(null==a&&(a=n(-1)),e(a.resultCode,a.hashValue))};"string"===typeof b&&(h=[b]);var r=0;f(h[r])},EncryptData:function(b,d,c,e,g){function f(b,c,d,e,f,g,k,l){4&a.ESVS.Mode&&(a.nimservice()?(f=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(f)),a.nimservice().EnvelopData(b,c,d,e,f,!1,function(b,c,d){0==b?(h.encryptedData=d,k(h)):(a.ERROR.Code=b,a.uiUtil().errMsgBox(c,a.ERROR.Code),k(n(b,c)));l.dispose()})):(a.ERROR.Code=-1,k(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),l&&l.dispose(!0)))}if(!b||!g||document.getElementById("us-div-cert-select"))return!1;var h=n(),k=function(a){1==g.length?g(a):(null==a&&(a=n(-1)),g(a.resultCode,a.encryptedData))};a.reInitialize();if(c&&0d.list.indexOf(d.defaultdevice)?d.list.split("|")[0]:d.defaultdevice)):d.defaultdevice=null;if(void 0==d.defaultdevice||null==d.defaultdevice)d.defaultdevice=2==L?"browsersign":"harddisk";var c="";if(-1!=d.list.indexOf("browsersign")){c="https://browsersign.crosscert.com";var e=document.createElement("iframe");e.src=c+"/index.html";e.name="shareframe";e.id="shareframe";e.style.visibility="hidden";e.style.position="absolute";document.body.appendChild(e);Pa=Qa(a)}else la="";a.ESVS.SHARESTORAGE=u.SHARESTORAGE=c;a.ESVS.Media=u.Media=d}"undefined"!=typeof b.TabIndex&&(a.ESVS.TabIndex=u.TabIndex=ka=b.TabIndex);"undefined"!=typeof b.LimitNumOfTimesToTryToInputPW&&(a.ESVS.LimitNumOfTimesToTryToInputPW=u.LimitNumOfTimesToTryToInputPW=ea=b.LimitNumOfTimesToTryToInputPW);"undefined"!=typeof b.Policy&&(a.ESVS.Policy=u.Policy=ra=b.Policy);"undefined"!=typeof b.ShowExpiredCerts&&(a.ESVS.ShowExpiredCerts=u.ShowExpiredCerts=sa=b.ShowExpiredCerts);"undefined"!=typeof b.LimitMinNewPWLen&&(a.ESVS.LimitMinNewPWLen=u.LimitMinNewPWLen=Q=b.LimitMinNewPWLen);"undefined"!=typeof b.LimitMaxNewPWLen&&(a.ESVS.LimitMaxNewPWLen=u.LimitMaxNewPWLen=R=b.LimitMaxNewPWLen);"undefined"!=typeof b.LimitNewPWPattern&&(a.ESVS.LimitNewPWPattern=u.LimitNewPWPattern=ba=b.LimitNewPWPattern);"undefined"!=typeof b.CertRequestPageEnable&&(a.ESVS.CertRequestPageEnable=u.CertRequestPageEnable=ta=b.CertRequestPageEnable)},SignFileP7:function(b,d,c,e,g,f){if(document.getElementById("us-div-cert-select")||!f||!b||0=f.length)h="http://download.smartcert.kr";a.usimEnv={sitecode:b,modecode:d,siteURL:c,serviceIP:e,servicePort:g,downloadURL:h}},DecryptData:function(b,d){function c(c,d,f,p){4&a.ESVS.Mode&&(a.nimservice()?a.nimservice().DeEnvelopData("kmcert",c,d,b,function(b,c,d){0==b?(e.decryptedData=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(d)),g(e)):(a.ERROR.Code=b,a.uiUtil().errMsgBox(c,a.ERROR.Code),g(n(b,c)));p.dispose()}):(a.ERROR.Code=-1,g(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),p.dispose()))}if(!b||!d||document.getElementById("us-div-cert-select"))return!1;var e=n(),g=function(a){1==d.length?d(a):(null==a&&(a=n(-1)),d(a.resultCode,a.decryptedData))};a.reInitialize();var f=a.loadUI("certselect")({type:"ENCRYPT_P7",args:{dn:null,possibleWhale:!1},onConfirm:function(a,b,d){c(a,b,d,f)},onCancel:function(){f.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});f.show();return!0},VerifyKeyPair:function(b){function d(c,d,g,l,p,t,m){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(p))a.nimservice().GetSignDataP7(g,l,"1234","utf8",!0,null,!0,!1,function(c,d,f,g,h,k){0!=c?(a.ERROR.Code=c,a.ERROR.Message=d,e.errmsg=d,t&&t.dispose(!0),b(n(a.ERROR.Code,e))):a.nimservice().VerifySignedData(null,f,function(b,c,d){0!=b?(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),e.signcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_SIGN+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+a.uiUtil().getErrorMessageLang().IDS_VERIFY_SIGN+")"):e.signcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_SIGN+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_OK;m(0)})});else{c="";try{var f=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[g].signcert),h=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[g].signpri),k=a.usWebToolkit.pkcs7.createSignedData();k.sign("1234",f,h,l,null,null);c=a.usWebToolkit.pkcs7.messageToBase64(k)}catch(y){a.ERROR.Code=y.code;a.ERROR.Message=y.message;112047==y.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD);t&&t.dispose(!0);e.errmsg=a.ERROR.Message;m(0);return}try{var v=a.usWebToolkit.pkcs7.messageFromBase64(c);v.verify()}catch(y){a.ERROR.Code=y.code,a.ERROR.Message=y.message,e.signcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_SIGN+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+a.uiUtil().getErrorMessageLang().IDS_VERIFY_SIGN+")",m(0)}e.signcert=v.verifyResult?a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_SIGN+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_OK:a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_SIGN+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+a.uiUtil().getErrorMessageLang().IDS_VERIFY_SIGN+")";m(0)}}function c(c,d,g,l,p,t){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(p))a.nimservice().EnvelopData("kmcert",g,l,null,"1234",!0,function(c,d,f){0==c?a.nimservice().DeEnvelopData("kmcert",g,l,f,function(c,d,f){e.kmcert=0==c?a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_OK:-2==c?a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_NONE:a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+d+")";t&&t.dispose();b(n(0,e))}):(e.kmcert=-2==c?a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_NONE:a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+d+")",t&&t.dispose(),b(n(0,e)))});else{if(a.PFUC[g].kmcert){c="";try{var f=crosscert.pkcs7.createEnvelopedData(),h=crosscert.pki.certificateFromBase64(a.PFUC[g].kmcert);f.addRecipient(h);f.encContent.algorithm=crosscert.pki.oids["seed-CBC"];f.content=crosscert.util.createBuffer("1234");f.encrypt();c=crosscert.pkcs7.messageToBase64(f)}catch(x){e.kmcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+x.message+")";t&&t.dispose();b(n(0,e));return}try{f=crosscert.pkcs7.messageFromBase64(c);var q=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[g].kmpri);privKey=crosscert.pkcs8.decryptPrivateKeyInfo(q,l);privKey=crosscert.pki.privateKeyFromAsn1(privKey);f.decrypt(f.recipients[0],privKey);f.content&&(e.kmcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_OK)}catch(x){e.kmcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+x.message+")"}}else e.kmcert=a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_KM+" : "+a.uiUtil().getErrorMessageLang().IDS_VERIFYKEY_FAIL+"("+a.uiUtil().getErrorMessageLang().IDS_NO_KMCERT+")";t&&t.dispose();b(n(0,e))}}if(!b)return!1;n();var e={errmsg:"",signcert:"",kmcert:""};a.reInitialize();var g=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null,possibleWhale:!1},onConfirm:function(a,b,e,l,p,n){d(a,e,l,p,n,g,function(b){c(a,e,l,p,n,g)})},onCancel:function(){g.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();e.errmsg=a.ERROR.Message;b(n(a.ERROR.Code,e))}});g.show();return!0},VerifyP7SignedFileWithFile:function(b,d,c,e,g,f){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!c||0d?l():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=d||null==a.SELECTINFO.pw?p(d,c):p(d,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(d,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var m=t();0>m?l():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=m||null==a.SELECTINFO.pw?p(m,c):p(m,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(m,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}}return!0}},MakeTaxXMLDSIG:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!e)return!1;var g=b;"string"===typeof b&&(g=[b]);var f=n();a.reInitialize();var h=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_XML",args:{dn:d,possibleWhale:!0},onConfirm:function(b,d,p,t,m,r){var q={};if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(m))if(m!=a.CONST.__USFB_M_DISK.device&&m!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(a.nimservice()){var k=0;b=[];for(var l in g)b[k++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(g[l]));a.nimservice().MakeXMLDSIG(p,t,b,c,0,function(b,c,r,l,p,v){if(0!=b)a.ERROR.Code=b,a.ERROR.Message=c,e(n(a.ERROR.Code,a.ERROR.Message));else{k=0;if("object"==typeof r)for(var t in g)q[t]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(r[k++]));else q=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(r));a.CONST.__USFB_M_MOBILETOKEN.device==m&&(d=a.certUtil().getTheCertAttributes(p,"Base64"));f.signedData=q;f.b64RValue=l;f.certAttrs=d;f.tokenLabel=v;e(f)}a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.dispose()},10)})}else e(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),setTimeout(function(){h.dispose(!0)},10);else-1==p||""==t?(f.resultMessage=a.ERROR.Message=b,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){h.dispose(!0)},10),e(f)):ha(g,d,p,t,r,c,function(b){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.dispose()},10);e(b)})},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message));h.dispose(!0)}});h.show();return!0}},MakeTaxXMLDSIGNonEnveloped:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!e)return!1;var g=b;"string"===typeof b&&(g=[b]);var f=n();a.reInitialize();var h=function(){var b=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_XML",args:{dn:null,possibleWhale:!0},onConfirm:function(c,d,h,k,l,p){var q={};if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))if(l!=a.CONST.__USFB_M_DISK.device&&l!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(a.nimservice()){var m=0;c=[];for(var r in g)c[m++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(g[r]));a.nimservice().MakeXMLDSIG(h,k,c,"",1,function(c,h,k,r,p,v){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10);if(0!=c)a.ERROR.Code=c,a.ERROR.Message=h,e(n(a.ERROR.Code,a.ERROR.Message));else{m=0;if("object"==typeof k)for(var t in g)q[t]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(k[m++]));else q=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(k));a.CONST.__USFB_M_MOBILETOKEN.device==l&&(d=a.certUtil().getTheCertAttributes(p,"Base64"));f.signedData=q;f.certAttrs=d;f.tokenLabel=v;e(f)}})}else e(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),setTimeout(function(){b.dispose(!0)},10);else-1==h||""==k?(f.resultMessage=a.ERROR.Message=c,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){b.dispose(!0)},10),e(f)):ha(g,d,h,k,p,null,function(c){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10);e(c)})},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message));b.dispose(!0)}});b.show()};if(""==d||null==d)h();else{b=function(b,c,d){b!=a.CONST.__USFB_M_DISK.device&&b!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice().GetAllUserCertListNum(b,c,"",function(c,e,f){nCertsCnt=f;if(0==c)0d?h():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=d||null==a.SELECTINFO.pw?k(d,c):k(d,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();k(d,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var p=l();0>p?h():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=p||null==a.SELECTINFO.pw?k(p,c):k(p,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();k(p,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}}return!0}},DecryptWithUserSymmKey:function(b,d,c,e,g){function f(c,d,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(0==b){for(;-1d.length)return-11}else if(1==b&&6>d.length)return-11;var f=d;var g=0;for(d=d.length;16>d;d++)f+="abcdefghijklmnopqrstuvwxyz".substr(g++,1);g=f+"0123450123456789";f=g.substring(0,16);g=g.substring(16,32);e=a.usWebToolkit.util.decode64(e);d=null;try{var h=a.usWebToolkit.cipher.algorithms[c].startDecrypting(f,g);h.update(a.usWebToolkit.util.createBuffer(e));if(0==h.finish())return-11;d=h.output.getBytes()}catch(v){return a.ERROR.Code=v.code,a.ERROR.Message=v.message,-12}return d}}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{var h=n();if("seed"!=d)a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_ALGORITHM,g(n(a.ERROR.Code,a.ERROR.Message));else if(null==e||""==e||1>e.length)alert(a.uiUtil().getErrorMessageLang().IDS_NOT_ENCRYPTED_DATA);else{a.reInitialize();var k=0,l=a.loadUI("securemail")({type:"SECURE_MAIL",args:{algorithm:d,data:e,decryptData:f,mode:b},onConfirm:function(c,d,e,r){3e?k():null!=d&&""!=d||null!=a.SELECTINFO.pw?null!=d&&""!=d||a.SELECTINFO.index!=e||null==a.SELECTINFO.pw?f(e,d):f(e,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();f(e,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();c(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var l=h();0>l?k():null!=d&&""!=d||null!=a.SELECTINFO.pw?null!=d&&""!=d||a.SELECTINFO.index!=l||null==a.SELECTINFO.pw?f(l,d):f(l,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();f(l,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();c(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}else k();return!0}},GetUserDN:function(b){if(!b)return!1;var d=n(),c=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null,possibleWhale:!0},onConfirm:function(e,g,f,h,k,l){var p=f;if("undefined"!==typeof h&&"undefined"!==typeof k)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))l!=a.CONST.__USFB_M_DISK.device&&l!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice()?(setTimeout(function(){c.dispose()},10),a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[1]),e=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00")),a.nimservice().GetSignDataP7(h,k,e,"utf8",!0,null,!0,!1,function(c,e,f,m,n,t){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=c?(a.ERROR.Code=d.resultCode=c,a.ERROR.Message=d.resultMessage=e):(null==p&&a.CONST.__USFB_M_MOBILETOKEN.device==l?(p=a.certUtil().getTheCertAttributes(n,"Base64"),B(h,k,l,n,p)):B(h,k,l,g,p),d.userDN=p.subjectName,d.certAttrs=p);b(d)})):(a.ERROR.Code=d.resultCode=-1,a.ERROR.Message=d.resultMessage=a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER,b(d),setTimeout(function(){c.dispose(!0)},10)):-1==h||""==k?(d.resultMessage=a.ERROR.Message=e,d.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){c.dispose(!0)},10),b(d)):(a.uiUtil().loadingBox(!0,"us-div-list-load",1),e=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00")),a.Whale().getSignDataP7(e,h,k,!0,function(e,f,m){0!=e?(d.resultCode=e,d.resultMessage=f):(B(h,k,l,g,p),d.certAttrs=p,d.userDN=p.subjectName);a.uiUtil().loadingBox(!1,"us-div-list-load",1);b(d);setTimeout(function(){c.dispose()},10)}));else if(l==a.CONST.__PF_M_CLOUDSIGN.device)a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGetCertR(h,function(e,f,m){0!=e&&(d.resultCode=e,d.resultMessage=f,setTimeout(function(){c.dispose()},10),b(n(e,f)));a.PFCS().reqGenSignNonVerifyPin(h,a.usWebToolkit.util.encodeUtf8("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00"),"Y",function(e,f,q){0!=e?(a.ERROR.Code=e,a.ERROR.Message=f,b(n(e,f))):(B(h,k,l,g,p),d.userDN=p.subjectName,b(d));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){c.dispose()},10)})});else{try{g=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[h].signcert);var t=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[h].signpri),m=a.usWebToolkit.pkcs7.createSignedData();m.sign("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00",g,t,k,null,null);a.usWebToolkit.pkcs7.messageToBase64(m);B(h,k,l,g,p);d.userDN=f.subjectName;b(d)}catch(r){d.resultCode=a.ERROR.Code=r.code,d.resultMessage=112047==r.code?a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD:a.ERROR.Message=r.message,a.uiUtil().errMsgBox(e,a.ERROR.Code),b(d)}setTimeout(function(){c.dispose()},10)}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(d);b(d);c.dispose(!0)}});c.show();return!0},VerifyCertVID:function(b,d,c,e){if(!e)return!1;var g=n(),f=function(a){1==e.length?e(a):(null==a&&(a=n(-1)),e(a.resultCode,a.resultMessage))};a.reInitialize();a.ESVS.multiuse=!0;var h=function(b,c,d,h,k,m,l){if("PFS"==l)try{var q=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[d].signcert),p=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[d].signpri),r=a.usWebToolkit.pkcs8.verifyVID(p,h,c,q);h=c="";r?f(n(0)):f(null)}catch(J){h=c="",a.ERROR.Code=J.code,a.ERROR.Message=J.message,f(n(J.code,J.message))}else"NIM"==l?(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_VID_VERIFY_MESSAGE),a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.SELECTINFO.curdevice==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP?(b=a.usWebToolkit.md.algorithms.sha256.create(),b.start(),b.update(a.usWebToolkit.util.encodeUtf8("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00")),b=b.digest().toHex(),b=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+b),d={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(b){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");b=JSON.parse(b);if(0!=b.returnObj.returnCode&&"E1000"!=b.returnObj.returnCode)g.resultMessage=a.ERROR.Message=b.returnObj.returnMsg,g.resultCode=a.ERROR.Code=b.returnObj.returnCode,f(g);else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(g),f(g);else{var d=b.signResult.b64Signer;b=a.usWebToolkit.util.decode64(b.signResult.R[0]);d=a.usWebToolkit.pki.certificateFromBase64(d);a.usWebToolkit.pkcs8.verifyVIDForHSM(b,c,d)?f(n(0)):(a.ERROR.Code=14208,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID,e(n(14208,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]},d.msg[0]=b,jSmartCertNP.SignByJSON(d).Open()):a.nimservice().VerifyVID(d,h,b,c,function(b,d){4305E4==b&&(b=14208);a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?f(n(0)):(a.ERROR.Code=b,a.ERROR.Message=d,f(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)));h=c=""}):a.Whale().verifyVID(d,h,c,function(b,c){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?f(n(0)):(3061==b&&(b=14208),a.ERROR.Code=b,a.ERROR.Message=c,e(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)))})):"CLOUDSIGN"==l&&a.PFCS().reqVerifyVID(d,c,function(b,c,d){0!=b?(a.ERROR.Code=b,a.ERROR.Message=c,f(n(b,c))):d?f(g):(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_VID_ERROR_VERIFICATION,f(n(-1,a.ERROR.Message)))})},k=function(b){var c=a.loadUI("certselect")({type:"VID_VERIFICATION",args:{dn:null,possibleWhale:!0},onConfirm:function(d,e,g,k,q,l,m,p){c.dispose();B(d,e,p,l,m);if(b)h(0,b,d,e,g,k,q);else{var r=a.loadUI("ssn")({type:null,onConfirm:function(a){h(1,a,d,e,g,k,q);r.dispose()},onCancel:function(){r.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});r.show()}},onCancel:function(){c.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});c.show()},l=function(b,c,d){b!=a.CONST.__USFB_M_DISK.device&&b!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice().GetAllUserCertListNum(b,c,"",function(c,e,f){nCertsCnt=f;if(0==c)0g?k(c):null!=d&&""!=d||a.SELECTINFO.index==g?null!=d&&""!=d||a.SELECTINFO.index!=g||null==a.SELECTINFO.pw?p(g,d,c):p(g,a.SELECTINFO.pw,c):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(g,a,c)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var m=t(b);0>m?k(c):null!=d&&""!=d||a.SELECTINFO.index==m?null!=d&&""!=d||a.SELECTINFO.index!=m||null==a.SELECTINFO.pw?p(m,d,c):p(m,a.SELECTINFO.pw,c):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(m,a,c)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}return!0},SignDataP7NonEnveloped:function(b,d,c,e,g){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!g)return!1;var f=n(),h=function(a){1==g.length?g(a):(null==a&&(a=n(-1)),g(a.signedData,a.curDevice,a.certAttrs))};a.reInitialize();var k=function(){var c=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null,possibleWhale:!0},onConfirm:function(d,g,k,l,m,p){var q=k;if("undefined"!==typeof l&&"undefined"!==typeof m)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(p))p!=a.CONST.__USFB_M_DISK.device&&p!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice()?(setTimeout(function(){c.dispose()},10),a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[1]),d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP7(l,m,d,"utf8",e,"",1,!1,function(b,c,d,e,k,n){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=b?(a.ERROR.Code=f.resultCode=b,a.ERROR.Message=f.resultMessage=c):(null==q&&a.CONST.__USFB_M_MOBILETOKEN.device==p?(q=a.certUtil().getTheCertAttributes(k,"Base64"),B(l,m,p,k,q)):B(l,m,p,g,q),f.certAttrs=q,f.signedData=d,f.curDevice=p,f.tokenLabel=n);h(f);l=m=g=r=null})):(a.ERROR.Code=f.resultCode=-1,a.ERROR.Message=f.resultMessage=a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER,h(f),setTimeout(function(){c.dispose(!0)},10)):-1==l||""==m?(f.resultMessage=a.ERROR.Message=d,f.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){c.dispose(!0)},10),h(f)):(a.uiUtil().loadingBox(!0,"us-div-list-load",1),d=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP7(d,l,m,e,function(b,d,e){0!=b?(f.resultCode=b,f.resultMessage=d):(B(l,m,p,g,q),f.certAttrs=q,f.signedData=e,f.curDevice=p,f.tokenLabel="");a.uiUtil().loadingBox(!1,"us-div-list-load",1);h(f);setTimeout(function(){c.dispose()},10)}));else if(p==a.CONST.__PF_M_CLOUDSIGN.device)a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGenSign(l,m,function(b,d,e,g){0!=b?(a.ERROR.Code=b,a.ERROR.Message=d,h(n(b,d))):(f.signedData=e,f.curDevice=p,h(f));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){c.dispose()},10)});else{try{g=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[l].signcert);var r=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[l].signpri),t=a.usWebToolkit.pkcs7.createSignedData();B(l,m,p,g,q);t.sign(b,g,r,m,null,null);var v=a.usWebToolkit.pkcs7.messageToBase64(t);f.certAttrs=k;f.signedData=v;f.curDevice=p;h(f)}catch(W){f.resultCode=a.ERROR.Code=W.code,f.resultMessage=112047==W.code?a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD:a.ERROR.Message=W.message,a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),h(f)}setTimeout(function(){c.dispose()},10);l=m=g=r=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(f);setTimeout(function(){c.dispose()},10);h(f)}});c.show()};if(""==d||null==d)k();else{var l=function(b,c,d){b!=a.CONST.__USFB_M_DISK.device&&b!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice().GetAllUserCertListNum(b,c,"",function(c,e,f){nCertsCnt=f;if(0==c)0d?k():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=d||null==a.SELECTINFO.pw?p(d,c):p(d,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(d,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();h(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var m=t();0>m?k():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=m||null==a.SELECTINFO.pw?p(m,c):p(m,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();p(m,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();h(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}}return!0}},SignDataP1WithPwd:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||!e)return!1;var g=n(),f=function(a){1==e.length?e(a):(null==a&&(a=n()),e(a.signedData,a.theCert,a.theDN))};a.reInitialize();var h=function(){var c=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:d,possibleWhale:!0},onConfirm:function(d,e,h,k,l,m){if("undefined"!==typeof k&&"undefined"!==typeof l){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(m))if(m!=a.CONST.__USFB_M_DISK.device&&m!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(m==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){var q=a.usWebToolkit.md.algorithms.sha256.create();q.start();q.update(a.usWebToolkit.util.encodeUtf8(b));h=q.digest().toHex();h=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+h);q={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(b){b=JSON.parse(b);a.uiUtil().loadingBox(!1,"us-div-list-load",1);if(0!=b.returnObj.returnCode&&"E1000"!=b.returnObj.returnCode)g.resultMessage=a.ERROR.Message=b.returnObj.returnMsg,g.resultCode=a.ERROR.Code=b.returnObj.returnCode,setTimeout(function(){c.dispose(!0)},10),f(g);else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(g),setTimeout(function(){c.dispose(!0)},10),f(g);else{var d=b.signResult.b64Signer;_certAttrs=a.certUtil().getTheCertAttributes(d,"Base64");B(k,l,m,d,_certAttrs);g.certAttrs=_certAttrs;g.signedData=b.signResult.b64SignedData[0];g.theCert=b.signResult.b64Signer;g.theDN=_certAttrs.subjectName;g.tokenlabel="";f(g);setTimeout(function(){c.dispose()},10)}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};q.msg[0]=h;q.plainText=[];q.plainText[0]=a.usWebToolkit.util.encodeUtf8(b);jSmartCertNP.SignByJSON(q).Open()}else a.nimservice()?(h=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP1(k,l,h,null,!0,function(b,h,q,p,n,r){0!=b?(a.ERROR.Code=g.resultCode=b,a.ERROR.Message=g.resultMessage=h,a.uiUtil().errMsgBox(h,b)):(null==d&&a.CONST.__USFB_M_MOBILETOKEN.device==m&&(_certAttrs=a.certUtil().getTheCertAttributes(n,"Base64"),d=n,e=_certAttrs.subjectName),B(k,l,m,d,a.certUtil().getTheCertAttributes(d,"Base64")),g.theCert=d,g.theDN=e,g.signedData=q,g.tokenlabel=r);f(g);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){c.dispose()},10)})):(a.ERROR.Code=g.resultCode=-1,a.ERROR.Message=g.resultMessage=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_NIM_ERROR_UNLOAD,f(g),setTimeout(function(){c.dispose(!0)},10));else-1==k||""==l?(g.resultMessage=a.ERROR.Message=h,g.resultCode=a.ERROR.Code=43021E3,a.uiUtil().loadingBox(!1,"us-div-list-load",1),setTimeout(function(){c.dispose(!0)},10),f(g)):(h=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP1(h,k,l,function(b,h,q){0!=b?(g.resultCode=b,g.resultMessage=h):(B(k,l,m,d,a.certUtil().getTheCertAttributes(d,"Base64")),g.theCert=d,g.theDN=e,g.signedData=q,g.tokenlabel="");setTimeout(function(){c.dispose()},10);a.uiUtil().loadingBox(!1,"us-div-list-load",1);f(g)}));else{try{var p=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[k].signcert),n=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[k].signpri);n=crosscert.pki.privateKeyFromAsn1(crosscert.asn1.fromDer(n));q=null;switch(oids[p.signatureOid]){case "sha1WithRSAEncryption":q=crosscert.md.algorithms[sha1].create();break;case "kcdsaWithSHA1":p.md=crosscert.md.algorithms[sha1].create();break;case "md5WithRSAEncryption":q=crosscert.md.algorithms[md5].create();break;case "sha256WithRSAEncryption":q=crosscert.md.algorithms[sha256].create();break;case "RSASSA-PSS":q=crosscert.md.algorithms[sha256].create()}q.update(b);var r=n.sign(q);a.usWebToolkit.pkcs7.messageToBase64(r);g.theCert=d;g.theDN=e;g.signedData=signedData;f(g)}catch(J){a.ERROR.Code=g.resultCode=J.code,a.ERROR.Message=g.resultMessage=J.message,a.uiUtil().errMsgBox(h,a.ERROR.Code),f(g)}setTimeout(function(){c.dispose()},10)}k=l=p=pri=null}else g.resultMessage=a.ERROR.Message=h,g.resultCode=a.ERROR.Code=43021E3,a.uiUtil().loadingBox(!1,"us-div-list-load",1),setTimeout(function(){c.dispose(!0)},10),f(g)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(g);f(g);c.dispose(!0)}});c.show()};if(""==d||null==d)h();else{var k=function(b,c,d){b!=a.CONST.__USFB_M_DISK.device&&b!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice().GetAllUserCertListNum(b,c,"",function(c,e,f){nCertsCnt=f;if(0==c)0d?h():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=d||null==a.SELECTINFO.pw?l(d,c):l(d,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();l(d,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}});else{var t=p();0>t?h():null!=c&&""!=c||null!=a.SELECTINFO.pw?null!=c&&""!=c||a.SELECTINFO.index!=t||null==a.SELECTINFO.pw?l(t,c):l(t,a.SELECTINFO.pw):(PWDialog=a.loadUI("password")({type:null,args:{},onConfirm:function(a){PWDialog.dispose();l(t,a)},onCancel:function(){PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}}return!0}},getCertPEMType:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d)return!1;var c=n(),e=function(a){1==d.length?d(a):(null==a&&(a=n()),d(a.signedData,a.theCert,a.theDN))};if(""==b)return e(c),!0;var g=function(b,c,d){a.nimservice().GetAllUserCertListNum(b,c,"",function(c,e,f){nCertsCnt=f;if(0==c)0a.SELECTINFO.index)return d.certPath="",b(d),!0;4&a.ESVS.Mode?a.nimservice().GetCertPath(a.SELECTINFO.index,function(c,e,g){0!=c?(a.ERROR.Code=c,a.ERROR.Message=e,b(n(c,e))):(d.certPath=g,b(d))}):(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_BROWSER_NOT_SUPPORT,b(n(a.ERROR.Code,a.ERROR.Message)));return!0},EnvelopedData:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d||document.getElementById("us-div-cert-select"))return!1;var c=n(),e=function(a){1==d.length?d(a):(null==a&&(a=n(-1)),d(a.signedData,a.curDevice,a.certAttrs,a.b64RValue))};a.reInitialize();var g=a.loadUI("certselect")({type:"CERT_SELECT",args:{dn:null},onConfirm:function(d,h,k,l,p,t,m){if("undefined"!==typeof l&&"undefined"!==typeof p)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(t))a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){g.dispose()},10);else if(t==a.CONST.__PF_M_CLOUDSIGN.device)a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){g.dispose()},10);else{try{try{h=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[l].signcert);var f=a.usWebToolkit.pkcs7.createEnvelopedData();f.addRecipient(h);f.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];f.content=a.usWebToolkit.util.createBuffer(a.usWebToolkit.util.encodeUtf8(b));f.encrypt();c.encryptData=a.usWebToolkit.pkcs7.messageToBase64(f);e(c)}catch(q){a.ERROR.Code=q.code,a.ERROR.Message=q.message,e(n(a.ERROR.Code,a.ERROR.Message))}}catch(q){a.ERROR.Code=q.code,a.ERROR.Message=q.message,112047==q.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD),a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),e(n(q.code,q.message))}setTimeout(function(){g.dispose()},10);l=p=h=pri=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message));g.dispose()}});g.show();return!0}},DeEnvelopedData:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d||document.getElementById("us-div-cert-select"))return!1;var c=n(),e=function(a){1==d.length?d(a):(null==a&&(a=n(-1)),d(a.decryptData,a.curDevice,a.certAttrs,a.b64RValue))};a.reInitialize();var g=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null},onConfirm:function(d,h,k,l,p,t,m){c.certAttrs=k;if("undefined"!==typeof l&&"undefined"!==typeof p)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(t))a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){g.dispose()},10);else if(t==a.CONST.__PF_M_CLOUDSIGN.device)a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){g.dispose()},10);else{try{try{var f=a.usWebToolkit.pkcs8.decryptRsaPrivateKeyFromBase64(a.PFUC[l].signpri,p),q=crosscert.pkcs7.messageFromBase64(b);q.decrypt(q.recipients[0],f);c.decryptData=a.usWebToolkit.util.decodeUtf8(q.content.data);e(c)}catch(x){a.ERROR.Code=x.code,a.ERROR.Message=x.message,e(n(a.ERROR.Code,a.ERROR.Message))}}catch(x){a.ERROR.Code=x.code,a.ERROR.Message=x.message,112047==x.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD),a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),e(n(x.code,x.message))}setTimeout(function(){g.dispose()},10);l=p=pri=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message));g.dispose()}});g.show();return!0}},MakeSymmetricKey:function(b){var d={};switch(b.toLowerCase()){case "3des":b=24;var c=8;break;case "des":c=b=8;break;default:c=b=16}try{d.resultCode=0,d.symmKey=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.random.getBytes(b)),d.symmIV=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.random.getBytes(c))}catch(e){d.resultCode=e.code,d.errMsg=e.message}return d},SymmetricKeyEncrypt:function(b,d,c,e){var g={};d=d.toLowerCase();switch(d){case "3des":d="des";case "aes":case "seed":case "des":break;default:d="seed"}try{var f=a.usWebToolkit.cipher.algorithms[d].startEncrypting(a.usWebToolkit.util.hexToBytes(c),a.usWebToolkit.util.hexToBytes(e));f.update(a.usWebToolkit.util.createBuffer(a.usWebToolkit.util.encodeUtf8(b)));f.finish();g.resultCode=0;g.encryptData=a.usWebToolkit.util.encode64(f.output.getBytes())}catch(h){g.resultCode=h.code,g.errMsg=h.message}return g},SymmetricKeyDecrypt:function(b,d,c,e){var g={};d=d.toLowerCase();switch(d){case "3des":d="des";case "aes":case "seed":case "des":break;default:d="seed"}try{var f=a.usWebToolkit.cipher.algorithms[d].startDecrypting(a.usWebToolkit.util.hexToBytes(c),a.usWebToolkit.util.hexToBytes(e));f.update(a.usWebToolkit.util.createBuffer(a.usWebToolkit.util.decode64(b)));f.finish();g.resultCode=0;g.decryptData=a.usWebToolkit.util.decodeUtf8(f.output.getBytes());return g}catch(h){g.resultCode=h.code,g.errMsg=h.message}return g},GetHashData:function(b,d,c){var e={},g=!1;"undefined"!=typeof c&&(g=c);d=d.toLowerCase();switch(d){case "md5":case "sha1":case "sha256":break;default:d="sha256"}try{var f=a.usWebToolkit.md.algorithms[d].create();f.start();d=b;g&&(d=a.usWebToolkit.util.encodeUtf8(b));f.update(d);e.resultCode=0;e.hashData=f.digest().toHex()}catch(h){e.resultCode=h.code,e.errMsg=h.message}return e},GetRandomData:function(b){var d=32;b&&(d=b);b={};try{b.resultCode=0,b.rendomData=a.usWebToolkit.util.bytesToHex(a.usWebToolkit.random.getBytes(d))}catch(c){b.resultCode=c.code,b.errMsg=c.message}return b},VerifyCertificate:function(b){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b||document.getElementById("us-div-cert-select"))return!1;n();var d=function(a){1==b.length?b(a):(null==a&&(a=n(-1)),b(a.decryptData,a.curDevice,a.certAttrs,a.b64RValue))};a.reInitialize();var c=a.loadUI("certselect")({type:"CERT_SELECT",args:{dn:null,possibleWhale:!0},onConfirm:function(b,g,f,h,k,l,p){b=null;try{var e=a.usWebToolkit.pki.createCaStore();b=a.PFSH.GetCACerts();for(var m in b)caCert=b[m],e.addCertificate(a.usWebToolkit.pki.certificateFromBase64(caCert));var r=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[h].signcert);a.usWebToolkit.pki.verifyCertificateChain(e,r,function(b,c,e){if(!0===b){a.usWebToolkit.x509Certificate.parser(a.PFUC[h].signcert,"Base64");var f=a.usWebToolkit.x509Certificate.getcRLDistributionPoints();if(""==f)b=3060,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_ERROR_CHECKING_ISSUER_FAIL;else if(b=a.usWebToolkit.x509Certificate.crlDownload(a.usWebToolkit.usWebCMP.info.CMPUrl,f),null!=b&&""!=b){c=b;if("object"==typeof b){f=f.split("?");var g="";1=l.length?(a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"),0==g?c(-1305,a.transferLang().IDS_ERR_NETWORK):c(g,h),e(g,b,null)):d(g,h,k,l,f.certIndex,f.password,f.curDevice,f.curDrive)})}))},function(){c(-1);e(-1,b,null)}))})},m=function(b,e,f){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");ExportingDialog=a.loadUI("certexport")({type:null,args:{authNum:e,qrCodeData:f},onConfirm:null,onCancel:function(){r(b,ExportingDialog);c(-1);d&&setTimeout(function(){d(-1)},0);ExportingDialog=null}});ExportingDialog.show();return ExportingDialog},r=function(b,c){canceled=!0;c&&c.dispose();b&&a.nimservice().Stop(b,function(a,c){b=null})};a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_INIT);b=H({eval:!1,intergrity:!1,name:"license",url:a.ESVS.License});null==b&&(b="Fail to load license");a.nimservice().Init(a.ESVS.TransServerIP,a.ESVS.TransServerPort,b,function(b,d,g){0!=b?(a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"),c(b,d),e(b,g,null)):(f=g,t(f,function(b,d,h,k,l,p,q,r){var t=m(f,h,k);a.nimservice().AsyncWaitForReceiver(g,function(b,d,f,h,k,m){0!=b?0==canceled&&(c(b,d),e(b,g,t)):a.ESVS.TransCfmWindowFlag?confirm("["+k+"] "+a.transferLang().IDS_CFM_DEVICE)?n(t,g,l,p,q,r):(c(-1),e(b,g,t)):n(t,g,l,p,q,r)})}))})}},CertTransferV1:function(b,d){function c(b,c){a.ERROR.Code=b;a.ERROR.Message=c;a.errPopup(a.ERROR.Code,a.ERROR.Message)}function e(b,c,d){l.defaultdevice&&(u.Media.defaultdevice=l.defaultdevice);l.list&&(u.Media.list=l.list.slice());a.ESVS.Media=u.Media;d&&d.dispose();c&&268500992!=b&&-1207!=b&&-1208!=b&&a.nimservice().AbnormalFinalize(c,function(a,b){});k&&setTimeout(function(){k(b)},0)}function g(b,c,d){l.defaultdevice&&(u.Media.defaultdevice=l.defaultdevice);l.list&&(u.Media.list=l.list.slice());a.ESVS.Media=u.Media;d&&d.dispose();c&&268500992!=b&&a.nimservice().Finalize(c,function(a,b){});k&&setTimeout(function(){k(b)},0)}function f(b,d,f){fa||(a.ESVS.Media=6==L?u.Media={defaultdevice:"harddisk",list:"harddisk|removable|sectoken|savetoken|mobilephone|browsersign"}:u.Media={defaultdevice:"harddisk",list:"harddisk|removable|sectoken|savetoken|mobilephone"});a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_TRANSFER);a.nimservice().ImportPFXEx(b,1,function(d,f,h,k){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=d?(c(d,f),g(d,b,null)):ab(function(d){a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_SAVE);$a(h,k,d.curDevice,d.curDrive,d.pin,d.password,function(d){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=d.resultCode?(c(d.resultCode,d.resultMessage),e(d.resultCode,b,null)):(a.uiUtil().msgBox(a.transferLang().IDS_SUC_DONE),g(d.resultCode,b,null))})},function(){a.uiUtil().msgBox(a.transferLang().IDS_CANCEL_SAVING);e(-1,b,null)})})}function h(b,d,f){a.nimservice().GetPassword(b,function(d,f,h){0==d?(fa||(a.ESVS.Media=6==L?u.Media={defaultdevice:"harddisk",list:"harddisk|removable|browsersign"}:u.Media={defaultdevice:"harddisk",list:"harddisk|removable"}),Za(-1,-1,-1,h,"",function(d){0!=d.resultCode?(c(d.resultCode,d.resultMessage),e(d.resultCode,b,null)):(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_TRANSFER),a.nimservice().ExportPFXEx(b,1,d.pfx,h,function(d,e){0!=d?c(d,e):a.uiUtil().msgBox(a.transferLang().IDS_SUC_DONE);g(d,b,null);a.uiUtil().createLoadingBox("hide","us-div-loading-dialog")}))})):(c(d,f),e(d,b,null),a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"))})}if(0==a.isAvailable())return a.uiUtil().msgBox(a.transferLang().IDS_ERROR_DO_NOT_AVAILABLE),!1;var k=d?d:null,l={};l.defaultdevice=a.ESVS.Media.defaultdevice;l.list=a.ESVS.Media.list.slice();d=H({eval:!1,intergrity:!1,name:"license",url:a.ESVS.License});null==d&&(d="Fail to load license");ImportingDialog=a.loadUI("certimport")({type:null,args:{license:d},onConfirm:function(d,g){ImportingDialog.dispose();a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_CONNECTTOSMART);a.nimservice().ConnectToSmartPhone(g,d,function(d,k,l,n,p){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=d?(c(d,k),e(d,g,null)):b!=n?(c(-2,k),e(d,g,null)):32==b?f(g,l,p):h(g,l,p)})},onCancel:function(){ImportingDialog.dispose();e(-1,null,ImportingDialog);c(-1)}});ImportingDialog.show()}}}alert("Failed to initialize Unisign Core.")};