1 |
- 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;g<b.length;g++)c[g]=b.charCodeAt(g);b=new Uint8Array(c);e=a.certUtil().getCN(e);e+=".p12";a.fileUtil().save(e,b)})}catch(d){alert("failure\nerr code : "+d.code+"\nerr msg : "+d.message)}}function Xa(){var b=null,d=null;a.CCPFSH().GetP12ForBuToMo(1,"base64",function(c,e,g,f){if(0==c){b=g;c=a.usWebToolkit.util.decode64(f);d=crosscert.util.bytesToHex(c);try{c="default";"android"===a.osName?"android samsung"===a.browserName||"android lg"===a.browserName||"android browser"===a.browserName?c="default":"android chrome"===a.browserName&&(c="chrome"):"ios"==a.osName&&("ios safari"===a.browserName?c="default":"ios chrome"===a.browserName&&(c="googlechrome"));var h=window.location.href.split(/[?#]/)[0],k=h.lastIndexOf("/");h=h.substr(0,k+1)+a.ESVS.SRCPath+"unisignweb/rsrc/layout/mobile/w2a/m_exportcertresult.html";UniSignW2A.backupStore(h,c,d,b,"0","recall")}catch(l){alert("failure\ne : "+l)}}else alert("failure\nerr code : "+c+"\nerr msg : "+e)})}function B(b,d,c,e,g){a.SELECTINFO={index:b,pw:d,curdevice:c,cert:e,certattrs:g}}function Ya(a,d){var b={errCode:0,errMsg:""};a&&"object"==typeof a&&d||(b.errCode=-1,b.errMsg="No Data");var e=null;try{e=crosscert.pki.certificateFromBase64(a.signcert)}catch(k){b.errCode=k.code,b.errMsg=k.message}var g=null;try{g=crosscert.pkcs8.encryptedPrivateKeyFromBase64(a.signpri)}catch(k){b.errCode=k.code,b.errMsg=k.message}var f=null,h=null;if(a.kmcert){try{f=crosscert.pki.certificateFromBase64(a.kmcert)}catch(k){b.errCode=k.code,b.errMsg=k.message}try{h=crosscert.pkcs8.encryptedPrivateKeyFromBase64(a.kmpri)}catch(k){b.errCode=k.code,b.errMsg=k.message}}try{p12=crosscert.pkcs12.makePKCS12FromCertNEncPKCS8(e,g,f,h,d,{useMac:!0,generateLocalKeyId:!0,count:1024})}catch(k){b.errCode=k.code,b.errMsg=k.message}try{strP12=crosscert.util.encode64(crosscert.asn1.toDer(p12).getBytes()),b.pfx=strP12}catch(k){b.errCode=k.code,b.errMsg=k.message}return b}function Za(b,d,c,e,g,f){if(!b)return null;var h=n();if(-1==b){var k=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_EXT_DISABLE_SECTOKEN",args:{dn:null,possibleWhale:!1},onConfirm:function(b,d,c,g,r){g==a.CONST.__PF_M_SS.device?(b=Ya(a.PFUC[d],a.usWebToolkit.util.decode64(e)),h.resultCode=b.errCode,h.resultMessage=b.errMsg,h.pfx=b.pfx,f(h)):a.nimservice()&&a.nimservice().ExportCertEx(g,r,d,e,c,function(a,b,d){h.resultCode=a;h.resultMessage=b;h.pfx=d;f(h)});setTimeout(function(){k.dispose()},10)},onCancel:function(b){k.dispose(!0);b?h.resultCode=-2:a.uiUtil().getUserCancelErrCodeNMsg(h);f(h)}});k.show()}else d==a.CONST.__PF_M_SS.device?(b=Ya(a.PFUC[b],a.usWebToolkit.util.decode64(e)),h.resultCode=b.errCode,h.resultMessage=b.errMsg,h.pfx=b.pfx,f(h)):a.nimservice().ExportCertEx(d,c,b,e,g,function(a,b,d){h.resultCode=a;h.resultMessage=b;h.pfx=d;f(h)})}function ib(b,d,c){try{var e=a.usWebToolkit.asn1.fromDer(a.usWebToolkit.util.decode64(b)),g=a.usWebToolkit.pkcs12.getCertNKeyFromPKCS12WithEncPKCS8(e,a.usWebToolkit.util.decode64(d)).getCertAndKeyFromPKCS12(a.usWebToolkit.util.decode64(d)),f={};f.signcert=a.usWebToolkit.pki.certificateToBase64(g.sign.cert);f.signpri=a.usWebToolkit.pkcs8.encryptedPrivateKeyToBase64(g.sign.prikey);g.km&&(f.kmcert=a.usWebToolkit.pki.certificateToBase64(g.km.cert),f.kmpri=a.usWebToolkit.pkcs8.encryptedPrivateKeyToBase64(g.km.prikey));a.usWebToolkit.x509Certificate.parser(f.signcert,"Base64");var h=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),k=a.certUtil().getIssuerEnName(h);a.CCPFSH().GetCCStorageHandler(a.ESVS.EncAlgo,a.ESVS.HashAlgo,a.ESVS.BSPKI,function(b,d){0==b?a.CCPFSH().SaveUserCert(k,f,!0,function(b){0==b?c(n(b,"")):c(n(b,a.transferLang().IDS_ERR_SAVING))}):c(n(b,a.transferLang().IDS_ERR_SAVING))})}catch(l){c(n(l.code,l.message))}}function $a(b,d,c,e,g,f,h){if(1>c||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);1E4<w.zIndex&&(va=w.zIndex);var M=null,Ka=null,u={};u.zIndex=va;u.afterSetupDefaultDevice=ja;u.installPageOpenOption=nb;u.CertforKeyboard="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=";if(!L||"undefined"===typeof L||1>L||6<L)L=6;u.Mode=L;u.useQRCode="boolean"!=typeof w.useQRCode||w.useQRCode?w.useQRCode=!0:w.useQRCode=!1;u.g2b="boolean"==typeof w.g2b&&w.g2b?w.g2b=!0:w.g2b=!1;u.toss="boolean"==typeof w.toss&&w.toss?w.toss=!0:w.toss=!1;X&&"undefined"!==typeof X||(X="3des");u.EncAlgo=X;Y&&"undefined"!==typeof Y||(Y="sha256");u.HashAlgo=Y;Ba||(Ba="");var ob=function(a,d){return d?function(){return eval(eval(a)())}():function(){return eval(a)}()};u.SRCPath=Ba;u.ShowGuide=bb;Z?"ahnlab"==Z&&(eval(H({eval:!1,intergrity:!1,name:"astx2.min.js",url:"unisignweb/framework/keyboard/astx2.min.js"})),eval(H({eval:!1,intergrity:!1,name:"astx2_custom.js",url:"unisignweb/framework/keyboard/astx2_custom.js"}))):Z="";u.SecureKeyboardType=Z;Ia||(Ia="211.192.169.44");u.TransServerIP=Ia;if(0>wa||!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(2<X.length)for(Y=1;Y<X.length;Y++)C=C.replace("-","_");else C=C.replace("-","_");C=C.toLowerCase()}else C=!navigator.browserLanguage||"ko"!=navigator.browserLanguage.toLowerCase()&&"kr"!=navigator.browserLanguage.toLowerCase()&&"ko-kr"!=navigator.browserLanguage.toLowerCase()?!document.documentElement.lang||"ko"!=document.documentElement.lang.toLowerCase()&&"kr"!=document.documentElement.lang.toLowerCase()&&"ko-kr"!=document.documentElement.lang.toLowerCase()?!navigator.language||"ko"!=navigator.language.toLowerCase()&&"kr"!=navigator.language.toLowerCase()&&"ko-kr"!=navigator.language.toLowerCase()?"en_us":"ko_kr":"ko_kr":"ko_kr";u.Language=C;qa||(qa="../install/Obj_check.html");u._NimCheckURL=qa;if(0==K||!K){var cb=function(){!V&&document.body&&(V=document.createElement("div"),V.style.width="0px",V.style.height="0px",document.body.insertBefore(V,document.body.firstChild));V?u.TargetObj=V:setTimeout(cb,500)};setTimeout(cb,300)}u.TargetObj=V;if(0>ka||!ka)ka=0;u.TabIndex=ka;K||(K=!1);u.Embedded=K;if(0>=ea||10<ea||!ea)ea=3;u.LimitNumOfTimesToTryToInputPW=ea;Ca||(Ca="211.192.169.70");u.CMPIP=Ca;if(0>pa||!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("<iframe src='"+la+"/index.html' name='shareframe' id='shareframe' style='visibility:hidden;position:absolute'></iframe>")):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||64<Q||!Q)Q=10;u.LimitMinNewPWLen=Q;if(10>R||64<R||!R||Q>R)R=64;u.LimitMaxNewPWLen=R;ba=2}else{if(8>Q||64<Q||!Q)Q=8;u.LimitMinNewPWLen=Q;if(8>R||64<R||!R||Q>R)R=64;u.LimitMaxNewPWLen=R;if(0>ba||2<ba||!ba)ba=0}u.LimitNewPWPattern=ba;Ea||(Ea=!1);u.ChangePWByNPKINewPattern=Ea;"undefined"===typeof ta&&(ta=1);u.CertRequestPageEnable=ta;"undefined"===typeof Fa&&(Fa=1);u.CertFindBtnEnable=Fa;"undefined"===typeof Ga&&(Ga="");u.SDInstallURL=Ga;"undefined"===typeof Ha&&(Ha=!1);u.IssueCertInBIOToken=Ha;u.License=lb;ua&&"undefined"!==typeof ua||(ua=!1);u.multiuse=ua;u.memberURL=w.memberURL;u.smsURL=w.smsURL;u.siteName=w.siteName;u.joinCode=w.joinCode;window.ESVS=u;var xa=null,S=[],Ra=0;w={};w.name=da.NAME;w.data=da.DATA;S[Ra++]=w;var ca=[{eval:!0,intergrity:!0,name:"json2",url:"unisignweb/framework/json2.js"},{eval:!0,intergrity:!0,name:"Blob",url:"unisignweb/framework/Blob.js"},{eval:!1,intergrity:!0,name:"FileSaver",url:"unisignweb/framework/FileSaver.js"},{eval:!1,intergrity:!0,name:"UniSignW2AUtil",url:"unisignweb/framework/UniSignW2AUtil.js"},{eval:!1,intergrity:!0,name:"UniSignW2AExtension",url:"unisignweb/framework/UniSignW2AExtension.js"},{eval:!0,intergrity:!0,name:"draggable",url:"unisignweb/framework/draggable.js"},{eval:!0,intergrity:!0,name:"jsustoolkitErrCode",url:"jsustoolkit/jsustoolkitErrCode.js"},{eval:!0,intergrity:!0,name:"asn1",url:"jsustoolkit/toolkit/asn1.js"},{eval:!0,intergrity:!0,name:"jsbn",url:"jsustoolkit/toolkit/jsbn.js"},{eval:!0,intergrity:!0,name:"oids",url:"jsustoolkit/toolkit/oids.js"},{eval:!0,intergrity:!0,name:"util",url:"jsustoolkit/toolkit/util.js"},{eval:!0,intergrity:!0,name:"unicode",url:"jsustoolkit/toolkit/unicode.js"},{eval:!0,intergrity:!0,name:"aes",url:"jsustoolkit/crypto/aes.js"},{eval:!0,intergrity:!0,name:"des",url:"jsustoolkit/crypto/des.js"},{eval:!0,intergrity:!0,name:"desofb",url:"jsustoolkit/crypto/desofb.js"},{eval:!0,intergrity:!0,name:"seed",url:"jsustoolkit/crypto/seed.js"},{eval:!0,intergrity:!0,name:"rc2",url:"jsustoolkit/crypto/rc2.js"},{eval:!0,intergrity:!0,name:"hmac",url:"jsustoolkit/crypto/hmac.js"},{eval:!0,intergrity:!0,name:"md5",url:"jsustoolkit/crypto/md5.js"},{eval:!0,intergrity:!0,name:"sha1",url:"jsustoolkit/crypto/sha1.js"},{eval:!0,intergrity:!0,name:"sha256",url:"jsustoolkit/crypto/sha256.js"},{eval:!0,intergrity:!0,name:"rsa",url:"jsustoolkit/crypto/rsa.js"},{eval:!0,intergrity:!0,name:"prng",url:"jsustoolkit/crypto/prng.js"},{eval:!0,intergrity:!0,name:"random",url:"jsustoolkit/crypto/random.js"},{eval:!0,intergrity:!0,name:"pki",url:"jsustoolkit/toolkit/pki.js"},{eval:!0,intergrity:!0,name:"pkcs5",url:"jsustoolkit/toolkit/pkcs5.js"},{eval:!0,intergrity:!0,name:"pkcs8",url:"jsustoolkit/toolkit/pkcs8.js"},{eval:!0,intergrity:!0,name:"pkcs7",url:"jsustoolkit/toolkit/pkcs7.js"},{eval:!0,intergrity:!0,name:"pkcs7asn1",url:"jsustoolkit/toolkit/pkcs7asn1.js"},{eval:!0,intergrity:!0,name:"pkcs12",url:"jsustoolkit/toolkit/pkcs12.js"},{eval:!0,intergrity:!0,name:"x509Certificate",url:"jsustoolkit/toolkit/x509Certificate.js"},{eval:!0,intergrity:!0,name:"cmpasn1",url:"jsustoolkit/toolkit/cmpasn1.js"},{eval:!0,intergrity:!0,name:"cmp",url:"jsustoolkit/toolkit/cmp.js"},{eval:!0,intergrity:!0,name:"usWebCMPXMLHttp",url:"jsustoolkit/webcmp/usWebCMPXMLHttp.js"},{eval:!0,intergrity:!0,name:"usWebCMP",url:"jsustoolkit/webcmp/usWebCMP.js"}],db=[{eval:!1,intergrity:!0,name:"npkicacerts",url:"unisignweb/js/storage/ins/npkicacerts.js"},{eval:!1,intergrity:!0,name:"encryptstorage",url:"unisignweb/js/storage/enc/encryptstorage.js"},{eval:!1,intergrity:!0,name:"localstorage",url:"unisignweb/js/storage/ls/localstorage.js"},{eval:!1,intergrity:!0,name:"localstoragehandler",url:"unisignweb/js/storage/ls/localstoragehandler.js"},{eval:!1,intergrity:!0,name:"storagehandler",url:"unisignweb/js/storage/storagehandler.js"},{eval:!1,intergrity:!0,name:"storageerrcode",url:"unisignweb/js/storage/err/storageerrcode.js"}];new function(){for(var a=0;a<ca.length;a++)0==a?"object"!==typeof JSON&&H(ca[a]):1==a||2==a?document.createElementNS&&(2==a?(eval(H(ca[a])),xa=eval("saveAs")):H(ca[a])):3==a?(H(ca[3]),H(ca[4]),a=4):H(ca[a]);var d=null;for(a=0;a<db.length;a++)d=eval(H(db[a]));try{Ka=new StorageHandler(1,{enc_algo:u.EncAlgo,hash_algo:u.HashAlgo,pki:u.BSPKI,domain:document.domain,error_code:d})}catch(c){a=window.console||{log:function(){}},a.log("*** StorageHandler initializing error ***"),a.log("e.code : ",c.code,"e.message : ",c.message,"e.detail : ",c.detail),Ka=null}};da=function(){};da.prototype={isKeyProtected:function(){return"touchen"==a.ESVS.SecureKeyboardType&&a.bsUtil().isTouchEnKeyUsable()||"ahnlab"==a.ESVS.SecureKeyboardType&&a.bsUtil().isAhnlabProtectorUsable()?!0:!1},GetKeyboardType:function(){if("touchen"==a.ESVS.SecureKeyboardType){if("undefined"!=typeof isInstalledTouchEnKey)return a.ESVS.SecureKeyboardType}else if("ahnlab"==a.ESVS.SecureKeyboardType&&1==a.isSKModule)return a.ESVS.SecureKeyboardType;return""},isTouchEnKeyUsable:function(){return 2&a.ESVS.Mode||"undefined"==typeof isInstalledTouchEnKey?!1:isInstalledTouchEnKey()},ahnlabInit:function(b){0<=Z.indexOf("ahnlab")&&"undefined"!=typeof $ASTX2&&"undefined"!=typeof $ASTX2.init&&"undefined"!=typeof $ASTX2.initNonE2E&&0!=a.isSKModule&&$ASTX2.init(function(){$ASTX2.initNonE2E(2522);b&&b()},function(){$ASTX2.getLastError();b&&b()})},isAhnlabProtectorUsable:function(){return 2&a.ESVS.Mode||"undefined"==typeof $ASTX2||"undefined"==typeof $ASTX2.init||"undefined"==typeof $ASTX2.initNonE2E?!1:a.isSKModule},GetAhnlabEncInputInfo:function(a){return{type:3,value:{pageID:$ASTX2.getE2EPageID()+"",inputID:$ASTX2.getE2EInputID(document.getElementById(a))}}},AhnlabClearText:function(b){"ahnlab"==a.ESVS.SecureKeyboardType&&this.isAhnlabProtectorUsable()&&$ASTX2.clearE2EText(document.getElementById(b))},SetSecurityStatus:function(b){b=document.getElementById(b);"touchen"==a.ESVS.SecureKeyboardType&&this.isTouchEnKeyUsable()?b.setAttribute("data-enc","on"):b.setAttribute("data-enc","off")},SetReScan:function(){"touchen"==a.ESVS.SecureKeyboardType&&this.isTouchEnKeyUsable()&&TouchEnKey_ReScan()},GetEncryptPwd:function(b,d){return null==a.pubkey||0>=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(-1<a.indexOf("px"))a=a.substring(0,a.indexOf("px"));else return-1;return parseInt(a)},getOverlay:function(a){if(0>a||!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='<div id="us-div-loading-dialog" style="z-index:'+b+'" class="us-layout-loading-o"></div><div style="z-index:'+b+'" class="us-layout-loading"><span class="us-layout-cert-processing-img"><img id="us-div-loading-dialog-img" class="us-layout-cert-processing-img"></span><span id="us-div-loading-dialog-text" class="us-layout-cert-processing-text"></span></div>',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),2<b.length)){for(e=0;e<b.length-2;e++)if(b.charAt(e)===b.charAt(e+1)&&b.charAt(e)===b.charAt(e+2)){c=!1;break}for(e=0;e<b.length-2;e++)if(b.charCodeAt(e)===b.charCodeAt(e+1)-1&&b.charCodeAt(e)===b.charCodeAt(e+2)-2){c=!1;break}}d(c)}},isIraq:function(){return!0===mb?!0:!1}};var Ma=function(){var a=eval(eval(function(){return H({intergrity:!1,name:"errormsg_"+u.Language,url:"unisignweb/rsrc/lang/"+u.Language+"/certlist_"+u.Language+".js"})})());this._certOidNameTable={};this._certOidNameTable["1.2.410.200004.5.1.1.5"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.1.1.7"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.2.1.1"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.2.1.2"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.3.1.1"]=a.IDS_AGENCY_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.3.1.2"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.3.1.9"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.4.1.1"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.4.1.2"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.4.1.3"]=a.IDS_SERVER_CERTIFICATE;this._certOidNameTable["1.2.410.200004.5.5.1.1"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.5.1.2"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200005.1.1.1"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200005.1.1.5"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200012.1.1.1"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200012.1.1.3"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.2.1.7.1"]=a.IDS_PERSON_BANKING_N_INSURANCE;this._certOidNameTable["1.2.410.200004.5.2.1.7.2"]=a.IDS_PERSON_STOCKTRADING_N_INSURANCE;this._certOidNameTable["1.2.410.200004.5.2.1.7.3"]=a.IDS_PERSON_CREDITCARD;this._certOidNameTable["1.2.410.200004.5.1.1.9"]=a.IDS_PERSON_STOCKTRADING_N_INSURANCE;this._certOidNameTable["1.2.410.200004.5.1.1.9.2"]=a.IDS_PERSON_CREDITCARD;this._certOidNameTable["1.2.410.200005.1.1.4"]=a.IDS_PERSON_BANKING_N_INSURANCE;this._certOidNameTable["1.2.410.200005.1.1.6.2"]=a.IDS_PERSON_CREDITCARD;this._certOidNameTable["1.2.410.200004.5.4.1.101"]=a.IDS_PERSON_BANKING_N_INSURANCE;this._certOidNameTable["1.2.410.200004.5.4.1.102"]=a.IDS_PERSON_STOCKTRADING_N_INSURANCE;this._certOidNameTable["1.2.410.200004.5.4.1.103"]=a.IDS_PERSON_CREDITCARD;this._certOidNameTable["1.2.410.200004.5.4.1.104"]=a.IDS_PERSON_ELECTRONIC_CIVIL_APPEAL;this._certOidNameTable["1.2.410.200012.1.1.101"]=a.IDS_PERSON_BANKING_N_INSURANCE;this._certOidNameTable["1.2.410.200012.1.1.103"]=a.IDS_PERSON_STOCKTRADING_N_INSURANCE;this._certOidNameTable["1.2.410.200012.1.1.105"]=a.IDS_PERSON_CREDITCARD;this._certOidNameTable["1.2.410.200004.5.5.1.1"]=a.IDS_PERSON_GENERAL_PURPOSE;this._certOidNameTable["1.2.410.200004.5.5.1.2"]=a.IDS_CORPORATION_GENERAL_PURPOSE;this._certOidNameTable["1.1.1.1.1.1.1.1.1.1"]=a.IDS_VERISIGN;this._certOidNameTable.restriction=a.IDS_RESTRICTION;this._certCAOidTable={};this._certCAOidTable.crosscert="1.2.410.200004.5.4";this._certCAOidTable.yessign="1.2.410.200005.1.1";this._certCAOidTable.koscom="1.2.410.200004.5.1";this._certCAOidTable.ktnet="1.2.410.200012.1.1";this._certCAOidTable.kica="1.2.410.200004.5.2";this._certCAOidTable.inipass="1.2.410.200004.5.5";this._certCAOidTable.verisign="1.1.1.1.1.1";this._certCANameTable={};this._certCANameTable.crosscert=a.IDS_CA_CROSSCERT;this._certCANameTable.yessign=a.IDS_CA_YESSIGN;this._certCANameTable.koscom=a.IDS_CA_KOSCOM;this._certCANameTable.ktnet=a.IDS_CA_KTNET;this._certCANameTable.kica=a.IDS_CA_KICA;this._certCANameTable.inipass=a.IDS_CA_INIPASS;this._certValidState={};this._certValidState.valid=a.IDS_CERT_STATE_VALID;this._certValidState.invalid=a.IDS_CERT_STATE_INVALID;this._certValidState.notice1=a.IDS_CERT_STATE_NOTICE_1;this._certValidState.notice2=a.IDS_CERT_STATE_NOTICE_2;this.certDNAttribute=[];this.certDNAttribute[0]="cn";this.certDNAttribute[1]="c";this.certDNAttribute[2]="l";this.certDNAttribute[3]="s";this.certDNAttribute[4]="st";this.certDNAttribute[5]="street";this.certDNAttribute[6]="o";this.certDNAttribute[7]="ou";this.certDNAttribute[8]="dnqualifier";this.certDNAttribute[9]="dc";this.certDNAttribute[10]="serialnumber";this.certDNAttribute[11]="e"};Ma.prototype={getCN:function(a){if(!a)return"undefined";var b=null,c=a.replace(/(^\s*)|(\s*$)/gi,"").split("="),e=c.length,g=[],f=0;if(1<e){for(var h=0;h<e;h++)if(-1!=c[h].indexOf(","))for(var k=c[h].split(","),l=k.length,p=0;p<l;p++)g[f++]=k[p];else g[f++]=c[h];for(c=0;c<f;c++)if(this.certDNAttribute[0]==g[c].toLowerCase()){b=g[++c];break}if(f<=c+1)return null===b?this.getOU(a):b;a=this.certDNAttribute.length;do{++c;for(p=1;p<a;p++)if(this.certDNAttribute[p]==g[c].toLowerCase())return b;b=b+", "+g[c]}while(c<f)}return"undefined"},getO:function(a){if(!a)return"undefined";var b=null,c=a.replace(/\s/g,"").replace(/(^\s*)|(\s*$)/gi,"").split("="),e=c.length;a=[];var g=0;if(1<e){for(var f=0;f<e;f++)if(-1!=c[f].indexOf(","))for(var h=c[f].split(","),k=h.length,l=0;l<k;l++)a[g++]=h[l];else a[g++]=c[f];for(c=0;c<g;c++)if(this.certDNAttribute[6]==a[c].toLowerCase()){b=a[++c];break}if(g<=c+1)return null===b?"undefined":b;e=this.certDNAttribute.length;do{++c;for(l=0;l<e;l++)if(this.certDNAttribute[l]==a[c].toLowerCase())return b;b=b+", "+a[c]}while(c<g)}return"undefined"},getOU:function(a){if(!a)return"undefined";var b=null,c=a.replace(/(^\s*)|(\s*$)/gi,"").split("="),e=c.length;a=[];var g=0;if(1<e){for(var f=0;f<e;f++)if(-1!=c[f].indexOf(","))for(var h=c[f].split(","),k=h.length,l=0;l<k;l++)a[g++]=h[l];else a[g++]=c[f];for(c=0;c<g;c++)if(this.certDNAttribute[7]==a[c].toLowerCase()){b=a[++c];break}if(g<=c+1)return null===b?"undefined":b;e=this.certDNAttribute.length;do{++c;for(l=0;l<e;l++)if(this.certDNAttribute[l]==a[c].toLowerCase())return b;b=b+", "+a[c]}while(c<g)}return"undefined"},getLocalDate:function(a){if(!a)return"undefined";var b=new Date(a);a=b.getFullYear();var c=b.getMonth()+1;b=b.getDate();10>c&&(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<a?2592E6<=a?this._certValidState.valid:this._certValidState.notice1+parseInt(a/1E3/60/60/24)+this._certValidState.notice2:this._certValidState.invalid},getExpirationStateValue:function(a){if(!a)return-1;a=new Date(a);var b=(new Date).getTime();a=a.getTime()-b;return 0<a?2592E6<=a?0:1:2},getTheCertAttributes:function(b,d){if(!b||!d)return{};a.usWebToolkit.x509Certificate.parser(b,d);b=null;try{b=a.usWebToolkit.x509Certificate.getVersion()}catch(z){}d=null;try{d=a.usWebToolkit.x509Certificate.getSerialNumber()}catch(z){}var c=null;try{c=a.usWebToolkit.x509Certificate.getSignAlgo()}catch(z){}var e=null;try{e=a.usWebToolkit.x509Certificate.getIssuerName()}catch(z){}var g=null;try{g=a.usWebToolkit.x509Certificate.getNotBefore()}catch(z){}var f=null;try{f=a.usWebToolkit.x509Certificate.getNotAfter()}catch(z){}var h=null;try{h=a.usWebToolkit.x509Certificate.getSubjectName()}catch(z){}var k=null;try{k=a.usWebToolkit.x509Certificate.getPublickey()}catch(z){}var l=null;try{l=a.usWebToolkit.x509Certificate.getAuthorityKeyIdentifier()}catch(z){}var p=null;try{p=a.usWebToolkit.x509Certificate.getSubjectKeyIdentifier()}catch(z){}var t=null;try{t=a.usWebToolkit.x509Certificate.getKeyUsage()}catch(z){}var m=null;try{m=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid()}catch(z){}var r=null;try{r=a.usWebToolkit.x509Certificate.getSubjectAltName()}catch(z){}var q=null;try{q=a.usWebToolkit.x509Certificate.getAuthorityInfoAccess()}catch(z){}var x=null;try{x=a.usWebToolkit.x509Certificate.getcRLDistributionPoints()}catch(z){}var v=null;try{v=a.usWebToolkit.x509Certificate.getCertificatePoliciesCPS()}catch(z){}var y=null;try{y=a.usWebToolkit.x509Certificate.getCertificatePoliciesUserNotice()}catch(z){}var n=null;try{n=a.usWebToolkit.x509Certificate.getSignature()}catch(z){}return{version:b,serialNumber:d,signAlgo:c,issuerName:e,validateFrom:g,validateTo:f,subjectName:h,publicKey:k,authorityKeyIdentifier:l,subjectKeyIdentifier:p,keyUsage:t,policiesOid:m,subjectAltName:r,authorityInfoAccess:q,crlDistributionPoints:x,policiesCps:v,policiesUserNotice:y,signature:n}}};var ya=function(){this._lang=eval(eval(function(){return H({eval:!1,intergrity:!1,name:"forgery_"+u.Language,url:"unisignweb/rsrc/lang/"+u.Language+"/forgery_"+u.Language+".js"})})());this._md=a.usWebToolkit.md.algorithms.sha256.create();this._integrityList=[];var b=H({eval:!1,intergrity:!1,name:"unisign",url:"unisignweb/integrity/unisign.js"}),d=null;if(!(1&a.ESVS.Mode)){null!=b||11<b.length?a.logger(" >>>> 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<navigator.userAgent.indexOf("compatible"))a.nimservice()?a.nimservice().VerifySignedData(null,b,function(b,c,d){0!=b?(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : 1368"),M=!1):a.intergrity.data=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(d))}):(a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : 1509"),M=!1);else{a.uiUtil().flagAlert(this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE+"\nErrCode : 1513");M=!1;a.logger(">> 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<c.length;e++)if(c[e].name==b){if(c[e].data==d)return"success";a.logger("*** Suspicion Forgery ***\nintergrity file name : "+c[e].name+"\nintergrity file md data : "+c[e].data+"\ndownloaded file name : "+b+"\ndownloaded file md data : "+d+"\n"+this._lang.IDS_MSGBOX_WARNING_SUSPICION_FORGERY);break}return this._lang.IDS_MSGBOX_ERROR_NEW_MESSAGE}};CheckIntergrity=function(){Na();for(var b,d,c=0;c<S.length;c++)if(b=S[c].name,d=S[c].data,rstr=a.forgeryUtil().verify(b,d),"success"===rstr)S[c].name=null,S[c].data=null,S[c]=null;else if(rstr){S[c].name=null;S[c].data=null;S[c]=null;a.uiUtil().flagAlert(rstr);M=!1;break}else return!1;return!0};String.prototype.endsWith=function(a){return this.length<a.length?!1:this.lastIndexOf(a)+a.length==this.length};String.prototype.startsWith=function(a){return this.length<a.length?!1:0==this.indexOf(a)};"undefined"!=typeof window.FileReader&&(ArrayBuffer.prototype.toBase64=function(){var a=new Uint8Array(this),d,c=a.length,e="";for(d=0;d<c;d+=3)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[d]>>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<d;a+=4){var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(this[a]);var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(this[a+1]);var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(this[a+2]);var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(this[a+3]);g[c++]=f<<2|h>>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<a.length;c++){var e=a[c].split("|"),g={};g.name=e[0];g.data=e[1];b[c]=g}return b}},logger:function(a){},trace:function(a){},nimCheckUrl:qa,plugin:function(){return document.getElementById("unisignwebplugin")},nimservice:function(){return qb},options:{img_src:null},ubiKeyEnv:{version:"1.3.0.7",siteInfo:"CROSSCERT|http://www.ubikey.co.kr/infovine/download.html",securityInfo:"CROSSCERT|NULL",downloadURL:"http://www.ubikey.co.kr/infovine/download.html"},usimEnv:{sitecode:"303010001",modecode:"0003",siteURL:document.location.hostname,serviceIP:"service.smartcert.kr",servicePort:"443",downloadURL:"http://download.smartcert.kr"},uiUtil:function(){return __UIUtil},certUtil:function(){return __CertUtil},forgeryUtil:function(){return __ForgeryUtil},fileUtil:function(){return __FileUtil},bsUtil:function(){return __BSUtil},uiLayerLevel:va,certsList:null,reInitialize:function(){VerifyPFLicense()&&(__ForgeryUtil=new ya)},loadUI:function(b){if(!b||0>=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(3<f)null!=document.getElementById("html_encripted")&&(document.getElementById("html_encripted").innerHTML=""),alert(p.IDS_KEY_TYPE[b]+p.IDS_PASSWORD_WRONG),h.dispose();else{var k=document.getElementById("us-input-secure-mail-password");c=t(c,k.value,d,e);if(-10===c)return a.ERROR.Code=-10,a.ERROR.Message=p.IDS_ALGORITHM_ALERT,h.dispose(),g(n(a.ERROR.Code,a.ERROR.Message));if(-11===c){a.ERROR.Code=-11;a.ERROR.Message=p.IDS_KEY_TYPE[b]+p.IDS_PASSWORD_WRONG;if(4<f)return h.dispose(),g(n(a.ERROR.Code,a.ERROR.Message));f+=1;alert(p.IDS_KEY_TYPE[b]+p.IDS_DISCORDANCE_PASSWORD.replace("@",f));k.value=""}else{if(-12===c)return h.dispose(),g(n(-12));if(-13===c){a.ERROR.Code=-13;a.ERROR.Message=p.IDS_KEY_TYPE[b]+p.IDS_PASSWORD_WRONG;if(4<f)return h.dispose(),g(n(-13));f+=1;alert(p.IDS_KEY_TYPE[b]+p.IDS_DISCORDANCE_PASSWORD.replace("@",f));k.value=""}else h.dispose(),p=n(),p.decryptedData=c,g(p)}}},onCancel:function(){h.dispose();a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});h.show()}},DecryptFileData:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{var g=d;var f=0;for(d=d.length;16>d;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;r++){m.push(b[r].orgCode);q.push(p(k(b[r].ucpidRequestInfo)));var x=a.usWebToolkit.util.encodeUtf8(JSON.stringify(b[r].consentInfo));q.push(a.usWebToolkit.util.encode64(x))}a.nimservice().GetSignDataP7(l,v,q,"utf8",!0,null,!0,!0,function(b,c,d){if(0!=b)a.ERROR.Code=b,a.ERROR.Message=c,e(n(a.ERROR.Code,a.ERROR.Message));else{g.signedData={};g.signedData.caOrg=a.certUtil().getO(h.subjectName);g.signedData.signedDataList=[];for(c=b=0;b<d.length;b++,c++){var q={};q.orgCode=m[c];q.signedPersonInfoReq=f(d[b++]);q.signedConsent=f(d[b]);g.signedData.signedDataList.push(q)}g.certAttrs=h;e(g)}a.uiUtil().loadingBox(!1,"us-div-list-load");t.dispose()})}else e(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),t.dispose(!0);else if(-1==l||""==v)g.resultMessage=a.ERROR.Message=c,g.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){t.dispose(!0)},10),e(g);else{try{q=[];m=[];for(r=0;r<b.length;r++)m.push(b[r].orgCode),q.push(p(k(b[r].ucpidRequestInfo))),x=JSON.stringify(b[r].consentInfo),q.push(x);d=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[l].signcert);var u=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[l].signpri);g.signedData={};g.signedData.caOrg=a.certUtil().getO(h.subjectName);g.signedData.signedDataList=[];for(c=r=0;r<q.length;r++,c++){l={};l.orgCode=m[c];var J=a.usWebToolkit.pkcs7.createSignedData();J.sign(a.usWebToolkit.util.decode64(q[r++]),d,u,v,null,null,!0,!0);l.signedPersonInfoReq=f(a.usWebToolkit.pkcs7.messageToBase64(J));var w=a.usWebToolkit.pkcs7.createSignedData();w.sign(q[r],d,u,v,null,null,!0,!1);l.signedConsent=f(a.usWebToolkit.pkcs7.messageToBase64(w));g.signedData.signedDataList.push(l)}g.certAttrs=h;e(g)}catch(ia){a.ERROR.Code=ia.code,a.ERROR.Message=ia.message,112047==ia.code&&(a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD),a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),e(n(ia.code,ia.message))}setTimeout(function(){t.dispose()},10);l=v=d=u=null}},onCancel:function(){t.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});t.show();return!0},SignMultiDataP1:function(b,d,c){if(!b||!c||document.getElementById("us-div-cert-select"))return!1;var e=n(),g=function(a){1==c.length?c(a):(null==a&&(a=n(-1)),c(a.jsonSignedData,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){var h={};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){l={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(c){c=JSON.parse(c);if(0!=c.returnObj.returnCode&&"E1000"!=c.returnObj.returnCode)e.resultMessage=a.ERROR.Message=c.returnObj.returnMsg,e.resultCode=a.ERROR.Code=c.returnObj.returnCode,setTimeout(function(){f.dispose(!0)},10),g(e);else if("E1000"==c.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(e),setTimeout(function(){f.dispose(!0)},10),g(e);else{var d=c.signResult.b64Signer;_certAttrs=a.certUtil().getTheCertAttributes(d,"Base64");B(p,t,m,d,_certAttrs);e.certAttrs=_certAttrs;e.theCert=d;e.theDN=_certAttrs.subjectName;if(1==c.signResult.b64SignedData.length)e.jsonSignedData=c.signResult.b64SignedData[0];else{d=0;e.jsonSignedData={};for(var h in b)e.jsonSignedData[h]=""==b[h]?"":c.signResult.b64SignedData[d++]}e.curDevice=m;e.tokenLabel="";g(e);setTimeout(function(){f.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(v in b){if(""!=b[v]){var q=a.usWebToolkit.util.encodeUtf8(b[v]),k=a.usWebToolkit.md.algorithms.sha256.create();k.start();k.update(q);k=k.digest().toHex();l.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+k));_inclCon&&l.plainText.push(q)}}else q=a.usWebToolkit.util.encodeUtf8(b),k=a.usWebToolkit.md.algorithms.sha256.create(),k.start(),k.update(q),k=k.digest().toHex(),l.msg.push(a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+k)),_inclCon&&l.plainText.push(q);else if("object"==typeof b)for(v in jsonPlainData)q[v]=_jsonPlainB64Text[v];else q=_jsonPlainB64Text;jSmartCertNP.SignByJSON(l).Open()}else if(a.nimservice()){l=0;q=[];if(b)if("object"==typeof b)for(v in b)q[l++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[v]));else q=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));a.nimservice().GetSignDataP1(p,t,q,null,a.ESVS.multiuse,function(q,k,r,p,l,v){if(0!=q)a.ERROR.Code=q,a.ERROR.Message=k,a.uiUtil().errMsgBox(k,a.ERROR.Code),g(n(q,k));else{q=0;if("object"==typeof r)for(var x in b)h[x]=r[q++];else h=r;null==c&&a.CONST.__USFB_M_MOBILETOKEN.device==m&&(r=a.certUtil().getTheCertAttributes(l,"Base64"),c=l,d=r.subjectName);e.jsonSignedData=h;e.theCert=c;e.theDN=d;e.tokenLabel=v;g(e)}a.uiUtil().loadingBox(!1,"us-div-list-load");f.dispose()})}else g(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),f.dispose(!0);else if(-1==p||""==t)e.resultMessage=a.ERROR.Message=l,e.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){f.dispose(!0)},10),g(e);else{a.uiUtil().loadingBox(!0,"us-div-list-load",1);q=[];if(b)if("object"==typeof b)for(var v in b)q[v]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[v]));else q=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));a.Whale().getSignDataP1(q,p,t,function(b,h,q){0!=b?(e.resultCode=b,e.resultMessage=h,a.uiUtil().errMsgBox(h,b)):(e.jsonSignedData=q,e.theCert=c,e.theDN=d,e.tokenLabel="");setTimeout(function(){f.dispose()},10);a.uiUtil().loadingBox(!1,"us-div-list-load",1);g(e)})}else p=t=cert=pri=null,f.dispose()},onCancel:function(){f.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});f.show();return!0},VerifySignedDataP7ExcludedContent:function(b,d,c){if(!d)return null;a.reInitialize();if(4&a.ESVS.Mode)if(null!=a.Whale()){var e=null;try{e=a.usWebToolkit.pkcs7.messageFromBase64(d),e.verify(void 0,b)}catch(g){a.ERROR.Code=g.code;a.ERROR.Message=g.message;c(g.code);return}if(1==e.verifyResult)return c(0),0;c(-1)}else a.nimservice()&&(b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().VerifySignedData(b,d,function(b,d,e){0!=b&&(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage());c(b);a.uiUtil().loadingBox(!1,"us-div-list-load")}));else{e=null;try{e=a.usWebToolkit.pkcs7.messageFromBase64(d),e.verify(void 0,b)}catch(g){a.ERROR.Code=g.code;a.ERROR.Message=g.message;_rvCallback(g.code);return}if(1==e.verifyResult)return _rvCallback(0),0;_rvCallback(-1)}},SignDataP7AndVerifyVID:function(b,d,c,e){if(!b&&!plainB64Text||!e||document.getElementById("us-div-cert-select"))return!1;oa();var g=n(),f=function(a){1==e.length?e(a):(null==a&&(a=n(-1)),e(a.resultCode,a.signedData,a.certAttrs,a.curDevice))};a.reInitialize();var h=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_AND_VID_VERIFICATION",args:{dn:d,possibleWhale:!0},onConfirm:function(d,e,p,t,m,r){var q=m;if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r))if(r!=a.CONST.__USFB_M_DISK.device&&r!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(r==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){p=a.usWebToolkit.md.algorithms.sha256.create();p.start();p.update(a.usWebToolkit.util.encodeUtf8(b));p=p.digest().toHex();p=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+p);var k={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(k){k=JSON.parse(k);if(0!=k.returnObj.returnCode&&"E1000"!=k.returnObj.returnCode)g.resultMessage=a.ERROR.Message=k.returnObj.returnMsg,g.resultCode=a.ERROR.Code=k.returnObj.returnCode,a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){h.dispose(!0)},10),f(g);else if("E1000"==k.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(g),a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){h.dispose(!0)},10),f(g);else{var m=k.signResult.b64Signer;q=a.certUtil().getTheCertAttributes(m,"Base64");B(d,e,r,m,q);var p=a.usWebToolkit.util.decode64(k.signResult.b64SignedData[0]),l=a.usWebToolkit.pki.certificateFromBase64(m),v=a.usWebToolkit.pkcs7.createSignedData();v.signWithP1(p,b,l,null,null);p=a.usWebToolkit.pkcs7.messageToBase64(v);N(c,d,e,p,q,r,"",f,k.signResult.R[0],m);a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.dispose()},10)}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};k.msg[0]=p;k.plainText=[];k.plainText[0]=a.usWebToolkit.util.encodeUtf8(b);jSmartCertNP.SignByJSON(k).Open()}else p=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP7(d,e,p,"utf8",!0,null,!0,!1,function(b,g,k,m,p,l){0!=b?(a.ERROR.Code=b,a.ERROR.Message=g,f(n(b,g))):(null==q&&a.CONST.__USFB_M_MOBILETOKEN.device==r?(q=a.certUtil().getTheCertAttributes(p,"Base64"),B(d,e,r,p,q)):B(d,e,r,t,q),N(c,d,e,k,q,r,l,f));e=c="";a.uiUtil().loadingBox(!1,"us-div-list-load");h.dispose()});else-1==d||""==e?(g.resultMessage=a.ERROR.Message=p,g.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){h.dispose(!0)},10),f(g)):(p=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP7(p,d,e,!0,function(b,k,m){0!=b?(g.resultCode=b,g.resultMessage=k,f(g)):(B(d,e,r,t,q),N(c,d,e,m,q,r,"",f));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.dispose()},10)}));else if(r==a.CONST.__PF_M_CLOUDSIGN.device){a.uiUtil().loadingBox(!0,"us-div-list-load",1);var l=function(c,d,k,m,r,p){a.PFCS().reqVerifyVID(c,d,function(d,m,l){0==d?l?a.PFCS().reqGetCertR(c,function(d,m,l){0!=d&&(g.resultCode=d,g.resultMessage=m,setTimeout(function(){h.dispose()},10),p(n(d,m)));a.PFCS().reqGenSignNonVerifyPin(c,a.usWebToolkit.util.encodeUtf8(b),"Y",function(b,d,m){0!=b?(a.ERROR.Code=b,a.ERROR.Message=d,f(n(b,d))):(B(c,e,r,t,q),b=a.usWebToolkit.util.decode64(m),d=a.usWebToolkit.pki.certificateFromBase64(t),m=crosscert.pkcs7.createSignedData(),m.signWithP1(b,k,d,null,null),g.certAttrs=q,g.signedData=a.usWebToolkit.pkcs7.messageToBase64(m),g.curDevice=r,f(g));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.dispose()},10)})}):(a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_VID_ERROR_VERIFICATION,a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){h.dispose()},10),p(n(a.ERROR.Code,a.ERROR.Message))):(a.ERROR.Code=d,a.ERROR.Message=m,a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){h.dispose()},10),p(n(d,m)))})};if(c)l(d,c,b,m,r,f);else{var y=a.loadUI("ssn")({type:null,onConfirm:function(a){l(d,a,b,m,r,f);y.dispose()},onCancel:function(){f(n(-1,a.uiUtil().getUserCancelErrCodeNMsg()));y.dispose()}});y.show()}}else{try{t=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[d].signcert);k=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[d].signpri);var G=a.usWebToolkit.pkcs7.createSignedData();G.sign(b,t,k,e,null,null);var z=a.usWebToolkit.pkcs7.messageToBase64(G);N(c,d,e,z,m,r,"",f);h.dispose()}catch(A){a.ERROR.Code=A.code,a.ERROR.Message=A.message,a.uiUtil().errMsgBox(A.message,a.ERROR.Code),f(n(A.code,A.message))}setTimeout(function(){h.dispose()},10);d=e=t=k=null}},onCancel:function(){h.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});h.show();return!0},MakeHash:function(b,d,c,e){function g(b,c){if(null==b||0>=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&&0<c.length)f("kmcert",-1,"",c,b,null,k,null);else{var l=a.loadUI("certselect")({type:"ENCRYPT_P7",args:{dn:d,possibleWhale:!1},onConfirm:function(a,d,e){f("kmcert",a,d,c,b,e,k,l)},onCancel:function(){l.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();k(n(a.ERROR.Code,a.ERROR.Message))}});l.show()}return!0},EncryptDatabySymm:function(b,d){if(!b)return null;var c=n();4&a.ESVS.Mode&&(a.nimservice()?(b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().EncryptData(b,function(b,g,f){0==b?(c.encryptedData=f,d(c)):(a.ERROR.Code=b,d(n(b,g)))})):(a.ERROR.Code=-1,d(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER))))},EncryptDataWithSymmKey:function(b,d,c,e,g){if(!c||!d)return null;var f=n();if(4&a.ESVS.Mode)a.nimservice()?(c=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(c)),a.nimservice().EncryptDataWithSymmKey(b,d,c,e,!0,function(b,c,d){0==b?(f.encryptedData=d,g(f)):(a.ERROR.Code=b,g(n(b,c)))})):(a.ERROR.Code=-1,g(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)));else try{var h=crosscert.cipher.algorithms[symmAlgo].startEncrypting(key,iv);h.update(crosscert.util.createBuffer(c));h.finish();f.encryptedData=a.usWebToolkit.util.encode64(h.output.getBytes());g(f)}catch(k){a.ERROR.Code=k.code,a.ERROR.Message=k.message,g(n(a.ERROR.Code,a.ERROR.Message))}},DecryptDataWithSymmKey:function(b,d,c,e,g,f){if(!c||!d)return null;var h=n(),k=function(a){1==f.length?f(a):(null==a&&(a=n(-1)),f(a.resultCode,a.decryptedData))};if(4&a.ESVS.Mode)a.nimservice()?a.nimservice().DecryptDataWithSymmKey(b,d,c,e,g,function(b,c,d){0==b?("utf-8"==g.toLowerCase()?h.decryptedData=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(d)):h.decryptedData=a.usWebToolkit.util.decode64(d),k(h)):(a.ERROR.Code=b,k(n(b,c)))}):(a.ERROR.Code=-1,k(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)));else try{var l=a.usWebToolkit.util.decode64(c),p=crosscert.cipher.algorithms[symmAlgo].startDecrypting(key,iv);p.update(crosscert.util.createBuffer(l));p.finish();h.decryptedData=p.output.getBytes();k(h)}catch(t){a.ERROR.Code=t.code,a.ERROR.Message=t.message,k(n(a.ERROR.Code,a.ERROR.Message))}},SetConfigInfo:function(b){"undefined"!=typeof b.Mode&&(a.ESVS.Mode=u.Mode=L=b.Mode);"undefined"!=typeof b.SecureKeyboardType&&(a.ESVS.SecureKeyboardType=u.SecureKeyboardType=Z=b.SecureKeyboardType,"ahnlab"==Z&&(eval(H({eval:!1,intergrity:!1,name:"astx2.min.js",url:"unisignweb/framework/keyboard/astx2.min.js"})),eval(H({eval:!1,intergrity:!1,name:"astx2_custom.js",url:"unisignweb/framework/keyboard/astx2_custom.js"}))));if("undefined"!=typeof b.Language){var d=b.Language.toLowerCase().replace("-","_");a.ESVS.Language="ko_kr"!=d&&"en_us"!=d?"ko_kr":d;__FileUtil=__ForgeryUtil=__CertUtil=__UIUtil=null;__UIUtil=new La;__CertUtil=new Ma;__ForgeryUtil=new ya;__FileUtil=new Oa}if("undefined"!=typeof b.Media){d=b.Media;fa=!0;d.list=d.list?d.list.toLowerCase():null;d.defaultdevice?(d.defaultdevice=d.defaultdevice.toLowerCase(),null!=d.list&&(d.defaultdevice=0>d.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<c&&!e)return!1;var h=n(),k=function(a){1==f.length?f(a):(null==a&&(a=n(-1)),f(a.resultCode,a.signedData,a.curDevice))};a.reInitialize();var l=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_FILE",args:{dn:d,possibleWhale:!1},onConfirm:function(d,f,m,r,q,x){4&a.ESVS.Mode&&(a.nimservice()?(m=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),r="",null!=e&&(r=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(e))),m=[m,c,r,1],a.nimservice().GetSignFileP7(d,f,m,g,null,function(b,e,g,q,m,r){0!=b?(a.ERROR.Code=b,a.ERROR.Message=e,k(n(a.ERROR.Code,a.ERROR.Message))):(h.curDevice=x,h.tokenLabel=r,h.signedData=0<c?a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(g)):g,k(h));d=f=cert=pri=null;a.uiUtil().loadingBox(!1,"us-div-list-load");l.dispose()})):(k(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),l.dispose(!0)))},onCancel:function(){l.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();k(n(a.ERROR.Code,a.ERROR.Message))}});l.show();return!0},SignMultiFileP7:function(b,d,c,e,g,f){if(!b||!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.jsonSignedData,a.curDevice))};a.reInitialize();var l=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_FILE",args:{dn:d,possibleWhale:!1},onConfirm:function(d,f,m,r,q,x){var p={};if(4&a.ESVS.Mode)if(a.nimservice()){m=0;r=[];q=[];if(b)if("object"==typeof b)for(var t in b)r[m++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b[t]));else r=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));if(e)if(m=0,"object"==typeof b)for(t in e)q[m++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(e[t]));else q=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(e));t=[r,c,q,1];a.nimservice().GetSignFileP7(d,f,t,g,null,function(e,g,q,m,r,v){if(0!=e)a.ERROR.Code=e,a.ERROR.Message=g,k(n(a.ERROR.Code,a.ERROR.Message));else{e=0;if(1==c)if("object"==typeof q)for(var t in b)p[t]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(q[e++]));else p=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(q));else if("object"==typeof q)for(t in b)p[t]=q[e++];else p=q;h.curDevice=x;h.jsonSignedData=p;h.tokenLabel=v;k(h)}d=f=cert=pri=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 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},SetUBIKeyEnvInfo:function(b,d,c,e){b=b.replace(",",".");a.ubiKeyEnv={version:b,siteInfo:d,securityInfo:c,downloadURL:e}},SetMobileTokenEnvInfo:function(b,d,c,e,g,f){var h=f;if("undefined"!==typeof f||null==f||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||0<e&&!g)return null;a.reInitialize();if(4&a.ESVS.Mode&&a.nimservice()){var h=null;null!=b&&(h=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)));b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(c));g=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(g));a.nimservice().VerifySignedFile(h,d,b,e,g,function(b,c,d,g){0!=b?(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),f(b,null)):0<e?(c=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(d)),f(b,c,g)):f(b,d,g);a.uiUtil().loadingBox(!1,"us-div-list-load")})}}},VerifyP7SignedDataWithFile:function(b,d,c,e,g){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!d||1==c&&!e)return null;a.reInitialize();if(4&a.ESVS.Mode&&a.nimservice()){var f=null;null!=b&&(f=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)));b=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(e));a.nimservice().VerifySignedFile(f,0,d,c,b,function(b,d,e,f){0!=b?(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),g(b,null)):1==c?(d=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(e)),g(b,d,f)):g(b,e,f);a.uiUtil().loadingBox(!1,"us-div-list-load")})}}},RenewCertNSignedSubjectDn:function(b,d,c,e,g,f,h,k){function l(b,c,d,h,k,r,l,p,w){b=!0;d!=a.CONST.__USFB_M_MOBILETOKEN.device&&(b=confirm(c));if(b){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()?(c=a.loadUI("certprocessing"),RenewingDialog=c({type:"CERT_RENEWAL",args:null,onConfirm:null,onCancel:null}),RenewingDialog.show(),a.nimservice().RenewCertificate(a.ESVS.CMPIP,a.ESVS.CMPPort,k,r,l,p,e,function(b,c,q){m.resultCode=b;m.resultMessage=c;m.curDevice=d;m.curDrive=h;d==a.CONST.__USFB_M_MOBILETOKEN.device&&q&&(w=a.certUtil().getTheCertAttributes(q,"Base64"));if(0==b)RenewingDialog.dispose(0,0,null,!1,function(){m.certAttrs=w;t(m)}),a.uiUtil().loadingBox(!1,"us-div-list-load");else if(a.ERROR.Code=b,a.ERROR.Message=c,a.uiUtil().loadingBox(!1,"us-div-list-load"),1==e&&null!=w&&w.subjectName){var r=1==g?"utf8":"euckr",l=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(w.subjectName));a.nimservice().GetAllUserCertListNum(d,h,p,function(e,g,h){a.nimservice().GetSignDataP7(k,p,l,r,!0,null,!1,!1,function(e,g,h,q,k,r){RenewingDialog.dispose(b,a.ERROR.Code,a.ERROR.Message,f,function(){0==e?(null==w&&a.CONST.__USFB_M_MOBILETOKEN.device==d&&(w=a.certUtil().getTheCertAttributes(k,"Base64")),m.certAttrs=w,m.signedData=h):(m.resultMessage=c,m.certAttrs=w);t(m);a.uiUtil().loadingBox(!1,"us-div-list-load")})})})}else U(),a.uiUtil().loadingBox(!1,"us-div-list-load"),RenewingDialog.dispose(b,a.ERROR.Code,c?c:a.ERROR.Message,!1,function(){m.resultCode=b;m.resultMessage=c;m.certAttrs=w;m.curDevice=d;m.curDrive=h;t(m)})})):(U(),t(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)));else{c=a.loadUI("certprocessing");RenewingDialog=c({type:"CERT_RENEWAL",args:null,onConfirm:null,onCancel:null});RenewingDialog.show();var q=p;""!=l&&(q=l);a.Whale().reNewCertificate(k,q,function(b,c){m.resultCode=b;m.resultMessage=c;m.curDevice=d;m.curDrive=h;if(0==b)RenewingDialog.dispose(0,0,null,!1,function(){m.certAttrs=w;t(m)}),a.uiUtil().loadingBox(!1,"us-div-list-load");else{a.ERROR.Code=b;var g=c;3604==b&&(g=a.uiUtil().getErrorMessageLang().IDS_ERROR_RENEW_WHALE,m.resultMessage=g);a.ERROR.Message=g;a.uiUtil().loadingBox(!1,"us-div-list-load");1==e&&null!=w&&w.subjectName?(c=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(w.subjectName)),a.Whale().getSignDataP7(c,k,p,!0,function(c,d,e){RenewingDialog.dispose(b,a.ERROR.Code,a.ERROR.Message,f,function(){0==c?(m.certAttrs=w,m.signedData=e):(m.resultMessage=a.ERROR.Message,m.certAttrs=w);t(m);a.uiUtil().loadingBox(!1,"us-div-list-load")})})):(a.uiUtil().loadingBox(!1,"us-div-list-load"),RenewingDialog.dispose(b,a.ERROR.Code,g?g:a.ERROR.Message,!1,function(){m.resultCode=b;m.resultMessage=g;m.certAttrs=w;m.curDevice=d;m.curDrive=h;t(m)}))}})}return!1}if(2&a.ESVS.Mode&&a.uiUtil().isItPFDevice(d)){var v=function(b,c,e){1==b?RenewingDialog.dispose(0,0,null,!0,function(){var b=a.loadUI("confirm")({type:null,args:{msg:x.IDS_CONFIRMBOX_WILL_YOU_BACKUP_CERT},onConfirm:function(){b.dispose();a.CONST.__PF_M_LS.device===d?a.uiUtil().isItPortableDevice()?Va():Ua(q):a.CONST.__PF_M_SS.device===d&&(a.uiUtil().isItPortableDevice()?Xa():Wa(q));q=null;t(m)},onCancel:function(){b.dispose();pw=null;a.uiUtil().getUserCancelErrCodeNMsg();t(n(a.ERROR.Code,a.ERROR.Message))}});b.show()}):2==b?RenewingDialog.dispose(b,b,c,!0,function(){t(n(b,c))}):3==b&&(b=e.code,RenewingDialog.dispose(b,b,e.message,!0,function(){t(n(b,e.message))}))};c=a.loadUI("certprocessing");RenewingDialog=c({type:"CERT_RENEWAL",args:null,onConfirm:null,onCancel:null});RenewingDialog.show();q=p;""!=l&&(q=l);r=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");r.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/lang/"+a.ESVS.Language+"/certbackup_"+a.ESVS.Language+".js?version="+a.ver,!1);r.send(null);var x=eval(r.responseText);if(a.CONST.__PF_M_LS.device===d)a.usWebToolkit.usWebCMP.update(a.PFUC[k].signcert,a.PFUC[k].signpri,a.PFUC[k].kmcert,a.PFUC[k].kmpri,pwd,document.domain,"",a.PFSH,v);else if(a.CONST.__PF_M_SS.device===d){var y=function(b,c,d,e){a.CCPFSH().SaveUserCert(d,c,!1,function(a,b){e(a)})};a.CCPFSH().GetCCStorageHandler(u.EncAlgo,u.HashAlgo,u.BSPKI,function(b,c){a.usWebToolkit.usWebCMP.update(a.PFUC[k].signcert,a.PFUC[k].signpri,a.PFUC[k].kmcert,a.PFUC[k].kmpri,q,null,"",c,v,null,null,null,y)})}}}else U()}if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else if(h&&!document.getElementById("us-div-cert-select")){var p=b;b&&a.uiUtil().isValidDevice(b)||(c=null,p=d=-1);var t=h,m=n();a.reInitialize();var r=a.loadUI("certselect")({type:"CERT_RENEWAL_SIGN",args:{device:p,drive:d,dn:c,possibleWhale:!0},onConfirm:function(b,c,d,e,f,g,h){r.dispose();var q=!0;k&&(q=k(h));if(!q)return m.resultCode=a.ERROR.Code=998,m.resultMessage=a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_NOALLOW_UPDATECERT,m.certAttrs=h,t(m),!0;a.CONST.__USFB_M_HSMKEY.device!=d&&a.CONST.__USFB_M_SMARTCARD.device!=d&&a.CONST.__USFB_M_MOBILETOKEN.device!=d?a.uiUtil().CheckPwdPattern(g,function(q){1==q?l(b,c,d,e,f,"","",g,h):(PWDialog=a.loadUI("newpassword")({type:null,args:{renew:!0,pw:g},onConfirm:function(a,q){PWDialog.dispose();l(b,c,d,e,f,a,q,g,h)},onCancel:function(){U();PWDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg();t(n(a.ERROR.Code,a.ERROR.Message))}}),PWDialog.show())}):l(b,c,d,e,f,"","",g,h)},onCancel:function(){r.dispose(!0);a.uiUtil().getUserCancelErrCodeNMsg();t(n(a.ERROR.Code,a.ERROR.Message))}});r.show();return!0}},SetOptions:function(b,d){a.options[b]=d},MakeTaxXMLDSIGNVID: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||!f)return!1;var h=b;"string"===typeof b&&(h=[b]);var k=n();a.reInitialize();a.ESVS.multiuse=!0;var l=function(){var b=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7_XML",args:{dn:null,possibleWhale:!0},onConfirm:function(c,d,m,r,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())a.nimservice()?(v=d,N(e,m,r,"",v,l,"",function(c){if(0!=c.resultCode)a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){b.dispose()},10),f(c);else{var d=0;c=[];for(var e in h)c[d++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(h[e]));a.nimservice().MakeXMLDSIG(m,r,c,g,1,function(c,e,g,x,t,y){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10);if(0!=c)a.ERROR.Code=c,a.ERROR.Message=e,f(n(a.ERROR.Code,a.ERROR.Message));else{d=0;if("object"==typeof g)for(var z in h)q[z]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(g[d++]));else q=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(g));a.CONST.__USFB_M_MOBILETOKEN.device==l?(v=a.certUtil().getTheCertAttributes(t,"Base64"),B(m,r,l,t,v)):B(m,r,l,p,v);k.signedData=q;k.certAttrs=v;k.tokenLabel=y;k.b64RValue=x;f(k)}})}})):(f(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)),setTimeout(function(){b.dispose(!0)},10));else if(-1==m||""==r)k.resultMessage=a.ERROR.Message=c,k.resultCode=a.ERROR.Code=43021E3,setTimeout(function(){b.dispose(!0)},10),f(k);else{var v=d;N(e,m,r,"",v,l,"",function(c){0!=c.resultCode?(a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){b.dispose()},10),f(c)):ha(h,v,m,r,p,g,function(c){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10);f(c)})})}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message));b.dispose(!0)}});b.show()};if(""==d||null==d)l();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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})};var p=function(b,c){var d={};4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice)&&(a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale()?a.nimservice()?N(e,b,c,"",a.SELECTINFO.certattrs,a.SELECTINFO.curdevice,"",function(e){if(0!=e.resultCode)f(e);else{var q=0;e=[];for(var m in h)e[q++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(h[m]));a.nimservice().MakeXMLDSIG(b,c,e,g,1,function(e,g,m,r,l,p){if(0!=e)a.ERROR.Code=e,a.ERROR.Message=g,f(n(a.ERROR.Code,a.ERROR.Message));else{q=0;if("object"==typeof m)for(var v in h)d[v]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(m[q++]));else d=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(m));e=a.SELECTINFO.certattrs;a.CONST.__USFB_M_MOBILETOKEN.device==a.SELECTINFO.curdevice?(e=a.certUtil().getTheCertAttributes(l,"Base64"),B(b,pw,a.SELECTINFO.curdevice,l,e)):B(b,c,a.SELECTINFO.curdevice,a.SELECTINFO.cert,e);k.signedData=d;k.certAttrs=e;k.tokenLabel=p;k.b64RValue=r;f(k)}})}}):f(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER)):N(e,b,c,"",a.SELECTINFO.certattrs,a.SELECTINFO.curdevice,"",function(d){0!=d.resultCode?f(d):ha(h,a.SELECTINFO.certattrs,b,c,a.SELECTINFO.cert,g,function(a){f(a)})}))},t=function(){for(var b=-1,c=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),d==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){b=a.certsList.list[e].index;c++;break}}else b=a.certsList.list[e].index,c++;1<c&&(b=-1);return b};if(null==a.certsList)b(a.SELECTINFO.curdevice,0,function(b){if(0!=b)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b);else{var d=t();0>d?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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})};var k=function(b,c){var d={};if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice))if(a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(a.nimservice()){var h=0,k=[],m;for(m in g)k[h++]=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(g[m]));a.nimservice().MakeXMLDSIG(b,c,k,"",1,function(b,c,k,q,m,l){if(0!=b)a.ERROR.Code=b,a.ERROR.Message=c,e(n(a.ERROR.Code,a.ERROR.Message));else{h=0;if("object"==typeof k)for(var r in g)d[r]=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(k[h++]));else d=a.usWebToolkit.util.decodeUtf8(a.usWebToolkit.util.decode64(k));b=a.SELECTINFO.certattrs;a.CONST.__USFB_M_MOBILETOKEN.device==a.SELECTINFO.curdevice&&(b=a.certUtil().getTheCertAttributes(m,"Base64"));f.signedData=d;f.certAttrs=b;f.tokenLabel=l;e(f)}})}else e(n(-1,a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER));else ha(g,a.SELECTINFO.certattrs,b,c,a.SELECTINFO.cert,null,function(a){e(a)})},l=function(){for(var b=-1,c=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),d==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){b=a.certsList.list[e].index;c++;break}}else b=a.certsList.list[e].index,c++;1<c&&(b=-1);return b};if(null==a.certsList)b(a.SELECTINFO.curdevice,0,function(b){if(0!=b)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b);else{var d=l();0>d?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(;-1<d.indexOf("-");)d=d.replace("-","");if(10>d.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){3<k?(null!=document.getElementById("html_encripted")&&(document.getElementById("html_encripted").innerHTML=""),alert(e.IDS_KEY_TYPE[b]+e.IDS_PASSWORD_WRONG),l.dispose()):(r=document.getElementById("us-input-secure-mail-password"),c=f(c,r.value,d),h.resultCode=c,-10===c?(a.ERROR.Code=-10,a.ERROR.Message=e.IDS_ALGORITHM_ALERT,l.dispose(),g(h)):-11===c?(a.ERROR.Code=-11,a.ERROR.Message=e.IDS_KEY_TYPE[b]+e.IDS_PASSWORD_WRONG,4<k?(l.dispose(),g(h)):(k+=1,alert(e.IDS_KEY_TYPE[b]+e.IDS_DISCORDANCE_PASSWORD.replace("@",k)),r.value="")):-12===c?(l.dispose(),g(h)):-13===c?(a.ERROR.Code=-13,a.ERROR.Message=e.IDS_KEY_TYPE[b]+e.IDS_PASSWORD_WRONG,4<k?(l.dispose(),g(h)):(k+=1,alert(e.IDS_KEY_TYPE[b]+e.IDS_DISCORDANCE_PASSWORD.replace("@",k)),r.value="")):(l.dispose(),h.resultCode=0,h.decryptedData=c,g(h)))},onCancel:function(){l.dispose();a.uiUtil().getUserCancelErrCodeNMsg();g(n(a.ERROR.Code,a.ERROR.Message))}});l.show()}}},EncryptDataWithCert:function(b,d,c){if(!b||!c)return!1;var e=n();a.reInitialize();try{var g=a.usWebToolkit.pki.certificateFromBase64(d),f=a.usWebToolkit.pkcs7.createEnvelopedData();f.addRecipient(g);f.encContent.algorithm=a.usWebToolkit.pki.oids["seed-CBC"];f.content=a.usWebToolkit.util.createBuffer(b);f.encrypt();e.encryptedData=a.usWebToolkit.pkcs7.messageToBase64(f);c(e)}catch(h){a.ERROR.Code=h.code,a.ERROR.Message=h.message,c(n(a.ERROR.Code,a.ERROR.Message))}},GetMacAddress:function(b,d){if(!d)return!1;var c=n();a.reInitialize();4&a.ESVS.Mode&&a.nimservice().GetMacAddress(b,function(b,g,f){0!=b?(a.ERROR.Code=b,a.ERROR.Message=g,d(n(a.ERROR.Code,a.ERROR.Message))):(c.mac=f,d(c))})},SetMultiUsingOpt:function(b){a.ESVS.multiuse=b},CheckConnectToCAServer:function(b,d,c){if(!c)return!1;a.reInitialize();4&a.ESVS.Mode&&a.nimservice().CheckConnectToCAServer(a.ESVS.CMPIP,a.ESVS.CMPPort,b,d,function(b,d){a.ERROR.Code=b;a.ERROR.Message=d;c(n(a.ERROR.Code,a.ERROR.Message))})},SetSystemTimeFromTimeServer:function(b,d,c){if(!c)return!1;a.reInitialize();4&a.ESVS.Mode&&a.nimservice().SetSystemTimeFromTimeServer(b,d,function(b,d){a.ERROR.Code=b;a.ERROR.Message=d;c(n(a.ERROR.Code,a.ERROR.Message))})},GetRValueFromKey:function(b,d,c){if(!c)return!1;var e=n(),g=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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})},f=function(b,d){a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]);if(a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice))if(a.SELECTINFO.curdevice==a.CONST.__PF_M_LS.device||a.SELECTINFO.curdevice==a.CONST.__PF_M_SS.device){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]);try{a.usWebToolkit.pki.certificateFromBase64(a.PFUC[b].signcert);var f=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[b].signpri),g=a.usWebToolkit.pkcs8.decryptPrivateKeyInfo(f,d),h=a.usWebToolkit.pkcs8.getPrivateKeyAttributesRandom(g);e.RValue=a.usWebToolkit.util.bytesToHex(h);e.b64RValue=a.usWebToolkit.util.encode64(h);c(e)}catch(x){e.resultCode=a.ERROR.Code=x.code,e.resultMessage=a.ERROR.Message=x.message,c(e)}}else a.SELECTINFO.curdevice==a.CONST.__PF_M_CLOUDSIGN.device&&(a.uiUtil().createLoadingBox("hide","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]),k());else 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",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]);a.uiUtil().loadingBox(!1,"us-div-list-load",1);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;else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(e);else{var d=a.usWebToolkit.util.decode64(b.signResult.R[0]);e.RValue=a.usWebToolkit.util.bytesToHex(d);e.b64RValue=b.signResult.R[0]}c(e)},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().GetRValueFromKey(b,d,function(b,d,f){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]);0!=b?(a.ERROR.Code=b,a.ERROR.Message=d,c(n(a.ERROR.Code,d))):(e.RValue=f,b=a.usWebToolkit.util.hexToBytes(f),e.b64RValue=a.usWebToolkit.util.encode64(b),c(e))}):a.Whale().getCertR(b,d,function(b,d,f){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[6]);0!=b?(e.resultCode=b,e.resultMessage=d):e.RValue=f;c(e)})},h=function(){for(var c=-1,d=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),b==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){c=a.certsList.list[e].index;d++;break}}else c=a.certsList.list[e].index,d++;1<d&&(c=-1);return c},k=function(){var b=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null,possibleWhale:!0},onConfirm:function(d,g,h,k,l,p){var q=h;if("undefined"!==typeof k&&"undefined"!==typeof l)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(p))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?(setTimeout(function(){b.dispose()},10),f(k,l)):a.nimservice()?(setTimeout(function(){b.dispose()},10),null==q&&a.CONST.__USFB_M_MOBILETOKEN.device==p?(q=a.certUtil().getTheCertAttributes(usimCert,"Base64"),B(k,l,p,usimCert,q)):B(k,l,p,g,q),e.certAttrs=q,f(k,l)):(a.ERROR.Code=e.resultCode=-1,a.ERROR.Message=e.resultMessage=a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER,B(k,l,p,g,q),c(e),setTimeout(function(){b.dispose(!0)},10)):(setTimeout(function(){b.dispose()},10),B(k,l,p,g,q),e.certAttrs=q,f(k,l));else if(p==a.CONST.__PF_M_CLOUDSIGN.device)a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGetCertR(k,function(d,f,h){0!=d&&(a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){b.dispose()},10),e.resultCode=d,e.resultMessage=f,c(n(d,f)));a.PFCS().reqGenSignNonVerifyPin(k,a.usWebToolkit.util.encodeUtf8(plainText),"Y",function(d,f,m){a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10);0!=d?(a.ERROR.Code=d,a.ERROR.Message=f,c(n(d,f))):(B(k,l,a.SELECTINFO.curdevice,g,q),e.RValue=h,e.b64RValue=a.usWebToolkit.util.encode64(a.usWebToolkit.util.hexToBytes(h)),c(e))})});else{try{g=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[k].signcert),B(k,l,p,g,q),e.certAttrs=q,f(k,l)}catch(G){e.resultCode=a.ERROR.Code=G.code,e.resultMessage=112047==G.code?a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD:a.ERROR.Message=G.message,a.uiUtil().errMsgBox(d,a.ERROR.Code),c(e)}setTimeout(function(){b.dispose()},10)}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg(e);c(e);b.dispose(!0)}});b.show()};if(a.SELECTINFO.curdevice==a.CONST.__USFB_M_MOBILETOKEN.device)k();else{if(null!=b&&""!=b)if(null==a.certsList)g(a.SELECTINFO.curdevice,0,function(b){if(0!=b)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b);else{var e=h();0>e?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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})},p=function(b,d,h){if(c)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.nimservice().VerifyVID(b,d,0,c,function(b,c){4305E4==b&&(b=14208);a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?f(n(0)):(a.ERROR.Code=b,a.ERROR.Message=c,f(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)));d=h=""}):a.Whale().verifyVID(b,d,h,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)));d=h=""});else{var k=a.loadUI("ssn")({type:null,onConfirm:function(c){k.dispose();a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_VID_VERIFY_MESSAGE);if(a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(a.SELECTINFO.curdevice==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("abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()\ud55c\uae00"));h=h.digest().toHex();h=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+h);var q={msgType:"originHash",signedDataType:"signature",siteDomain:document.domain,complete:function(b){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:[]};q.msg[0]=h;jSmartCertNP.SignByJSON(q).Open()}else a.nimservice().VerifyVID(b,d,1,c,function(b,e){4305E4==b&&(b=14208);a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?f(n(0)):(a.ERROR.Code=b,a.ERROR.Message=e,f(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)));d=c=""});else a.Whale().verifyVID(b,d,c,function(b,g){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0==b?f(n(0)):(3061==b&&(b=14208),a.ERROR.Code=b,a.ERROR.Message=g,e(n(b,a.uiUtil().getErrorMessageLang().IDS_ERROR_VERIFY_ID)));d=c=""})},onCancel:function(){k.dispose();a.uiUtil().getUserCancelErrCodeNMsg();f(n(a.ERROR.Code,a.ERROR.Message))}});k.show()}},t=function(b){for(var c=-1,d=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),b==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){c=a.certsList.list[e].index;d++;break}}else c=a.certsList.list[e].index,d++;1<d&&(c=-1);return c};if(""==b||null==b)k(c);else if(null==a.certsList)l(a.SELECTINFO.curdevice,0,function(e){if(0!=e)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,e);else{var g=t(b);0>g?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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})},p=function(c,d){if("undefined"!==typeof c&&"undefined"!==typeof d)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice))if(a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale())a.nimservice()?(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.uiUtil().getErrorMessageLang().IDS_CERT_LOADING_MSG[1]),g=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP7(c,d,g,"utf8",e,"",1,!1,function(b,e,g,m,q,p){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=b?(a.ERROR.Code=f.resultCode=b,a.ERROR.Message=f.resultMessage=e):(b=a.SELECTINFO.certattrs,null==b&&a.CONST.__USFB_M_MOBILETOKEN.device==a.SELECTINFO.curdevice?(b=a.certUtil().getTheCertAttributes(q,"Base64"),B(c,d,a.SELECTINFO.curdevice,q,b)):B(c,d,a.SELECTINFO.curdevice,k,b),f.certAttrs=b,f.signedData=g,f.curDevice=a.SELECTINFO.curdevice,f.tokenLabel=p);h(f);c=d=k=l=null})):(a.ERROR.Code=f.resultCode=-1,a.ERROR.Message=f.resultMessage=a.uiUtil().getErrorMessageLang().IDS_ERROR_LOADING_NIMSERVIER,h(f));else{a.uiUtil().loadingBox(!0,"us-div-list-load",1);var g=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b));a.Whale().getSignDataP7(g,c,d,e,function(b,c,d){0!=b?(f.resultCode=b,f.resultMessage=c):(f.certAttrs=a.SELECTINFO.certattrs,f.signedData=d,f.curDevice=a.SELECTINFO.curdevice,f.tokenLabel="");a.uiUtil().loadingBox(!1,"us-div-list-load",1);h(f)})}else if(a.SELECTINFO.curdevice==a.CONST.__PF_M_CLOUDSIGN.device)a.uiUtil().loadingBox(!0,"us-div-list-load",1),a.PFCS().reqGenSign(c,d,function(b,e,g,m){0!=b?(a.ERROR.Code=b,a.ERROR.Message=e,h(n(b,e))):(f.signedData=g,f.curDevice=a.SELECTINFO.curdevice,h(f));a.uiUtil().loadingBox(!1,"us-div-list-load");c=d=k=l=null});else{try{var k=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[c].signcert),l=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri);g=a.usWebToolkit.pkcs7.createSignedData();a.certUtil().getTheCertAttributes(a.PFUC[c].signcert,"Base64");g.sign(b,k,l,d,null,null);var m=a.usWebToolkit.pkcs7.messageToBase64(g);B(c,d,a.SELECTINFO.curdevice,k,a.SELECTINFO.certattrs);f.certAttrs=a.SELECTINFO.certattrs;f.signedData=m;f.curDevice=a.SELECTINFO.curdevice;h(f)}catch(z){f.resultCode=a.ERROR.Code=z.code,f.resultMessage=112047==z.code?a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_MATTCHED_PWD:a.ERROR.Message=z.message,a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),h(f)}c=d=k=l=null}},t=function(){for(var b=-1,c=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),d==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){b=a.certsList.list[e].index;c++;break}}else b=a.certsList.list[e].index,c++;1<c&&(b=-1);return b};if(null==a.certsList)l(a.SELECTINFO.curdevice,0,function(b){if(0!=b)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b);else{var d=t();0>d?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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}}):a.Whale().getCerts(__device,__drive,function(b,c,e){0==b?a.certsList={list:e}:a.uiUtil().errMsgBox(c,b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)})},l=function(c,e){var h=c,k=e;if("undefined"!==typeof h&&"undefined"!==typeof e){if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(a.SELECTINFO.curdevice))if(a.SELECTINFO.curdevice!=a.CONST.__USFB_M_DISK.device&&a.SELECTINFO.curdevice!=a.CONST.__USFB_M_HDD.device||null==a.Whale())if(a.SELECTINFO.curdevice==a.CONST.__USFB_M_MOBILETOKEN.device&&"undefined"!=typeof jSmartCertNP){var l=a.usWebToolkit.md.algorithms.sha256.create();l.start();l.update(a.usWebToolkit.util.encodeUtf8(b));l=l.digest().toHex();l=a.usWebToolkit.util.encode64("3031300d060960864801650304020105000420"+l);var m={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(){Dialog.dispose(!0)},10),f(g);else if("E1000"==b.returnObj.returnCode)a.uiUtil().getUserCancelErrCodeNMsg(g),setTimeout(function(){Dialog.dispose(!0)},10),f(g);else{var d=b.signResult.b64Signer;_certAttrs=a.certUtil().getTheCertAttributes(d,"Base64");B(c,e,device,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(){Dialog.dispose()},10)}},multisignYn:"N",oid:null==a.ESVS.Policy?"":a.ESVS.Policy,validate:u.ShowExpiredCerts?!1:!0,randomChk:!0,msg:[]};m.msg[0]=l;m.plainText=[];m.plainText[0]=a.usWebToolkit.util.encodeUtf8(b);jSmartCertNP.SignByJSON(m).Open()}else a.nimservice()?(l=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.nimservice().GetSignDataP1(h,e,l,null,!0,function(b,c,e,l,m,q){if(0!=b)a.ERROR.Code=g.resultCode=b,a.ERROR.Message=g.resultMessage=c,a.uiUtil().errMsgBox(c,b);else{b=d;c="";for(l=0;l<a.certsList.list.length&&(c=a.certsList.list[l].cert,h!=a.certsList.list[l].index);l++);a.CONST.__USFB_M_MOBILETOKEN.device==a.SELECTINFO.curdevice&&(c=m,b=a.SELECTINFO.certattrs.subjectName);B(h,k,a.SELECTINFO.curdevice,c,a.certUtil().getTheCertAttributes(c,"Base64"));g.theCert=c;g.theDN=b;g.signedData=e;g.tokenlabel=q}f(g);a.uiUtil().loadingBox(!1,"us-div-list-load")})):(a.ERROR.Code=g.resultCode=-1,a.ERROR.Message=g.resultMessage=a.uiUtil().getErrorMessageLang().IDS_MSGBOX_NIM_ERROR_UNLOAD,f(g));else l=a.usWebToolkit.util.encode64(a.usWebToolkit.util.encodeUtf8(b)),a.Whale().getSignDataP1(l,c,e,function(b,c,e){if(0!=b)g.resultCode=b,g.resultMessage=c;else{b="";for(c=0;c<a.certsList.list.length&&(b=a.certsList.list[c].cert,h!=a.certsList.list[c].index);c++);g.theCert=b;g.theDN=d;g.signedData=e;g.tokenlabel=""}a.uiUtil().loadingBox(!1,"us-div-list-load",1);f(g)});else try{m=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[c].signcert);var p=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri);p=crosscert.pki.privateKeyFromAsn1(crosscert.asn1.fromDer(p));l=null;switch(oids[m.signatureOid]){case "sha1WithRSAEncryption":l=crosscert.md.algorithms[sha1].create();break;case "kcdsaWithSHA1":m.md=crosscert.md.algorithms[sha1].create();break;case "md5WithRSAEncryption":l=crosscert.md.algorithms[md5].create();break;case "sha256WithRSAEncryption":l=crosscert.md.algorithms[sha256].create();break;case "RSASSA-PSS":l=crosscert.md.algorithms[sha256].create()}l.update(b);var n=p.sign(l);singedData=a.usWebToolkit.pkcs7.messageToBase64(n);g.theCert=theCert;g.theDN=theDN;g.signedData=signedData;f(g)}catch(A){a.ERROR.Code=g.resultCode=A.code,a.ERROR.Message=g.resultMessage=A.message,a.uiUtil().errMsgBox(userMsg,a.ERROR.Code),f(g)}c=e=m=pri=null}},p=function(){for(var b=-1,c=0,e=0;e<a.certsList.list.length;e++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[e].cert,"Base64"),d==a.usWebToolkit.x509Certificate.getSubjectName())if(0!=a.SELECTINFO.index){if(a.SELECTINFO.index==a.certsList.list[e].index){b=a.certsList.list[e].index;c++;break}}else b=a.certsList.list[e].index,c++;1<c&&(b=-1);return b};if(null==a.certsList)k(a.SELECTINFO.curdevice,0,function(b){if(0!=b)a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b);else{var d=p();0>d?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)0<nCertsCnt?a.nimservice().GetAllUserCert(f,function(b,c){0==b?a.certsList={list:c}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),b);a.uiUtil().loadingBox(!1,"us-div-cert-list-load");d(b)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-cert-list-load"),d(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=__lang.IDS_MSGBOX_NOT_INSTALL_MOBILE,document.getElementById("us-cls-btn").click(),"firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),a.certsList=null,d(c),!1;-1!==nCertsCnt&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());d(c);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-cert-list-load")}})},f=function(){for(var c="",d=0;d<a.certsList.list.length;d++)if(a.usWebToolkit.x509Certificate.parser(a.certsList.list[d].cert,"Base64"),b==a.usWebToolkit.x509Certificate.getSubjectName()){c=a.certsList.list[d].cert;break}return c};null==a.certsList?g(a.SELECTINFO.curdevice,0,function(b){0!=b?a.uiUtil().errMsgBox(a.uiUtil().getErrorMessageLang().IDS_MSGBOX_COMMON_ERROR_GET_CERT,b):(b=f(),""!=b&&(c.PEMCert=a.usWebToolkit.pki.certificateToPem(a.usWebToolkit.pki.certificateFromBase64(b))),e(c))}):(g=f(),""!=g&&(c.PEMCert=a.usWebToolkit.pki.certificateToPem(a.usWebToolkit.pki.certificateFromBase64(g))),e(c));return!0}},GetCertPath:function(b){if(!b)return!1;var d=n();if(1>a.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<f.length&&(g=f[1]);g&&(c=b[g])}!1===a.usWebToolkit.x509Certificate.verifyCRL(e[1],a.usWebToolkit.util.decode64(c)).verify?(b=-1,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_ERROR_REVOKED):(b=0,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_OK)}else b=3060,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_ERROR_CHECKING_ISSUER_FAIL}else null!=e&&void 0!=e&&0<=e.indexOf("Certificate is not valid yet or has expired")?(b=3005,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_ERROR_EXPIRED):null!=e&&void 0!=e&&0<=e.indexOf("no parent issuer, so certificate not trusted")?(b=3060,e=a.uiUtil().getErrorMessageLang().IDS_VERIFY_CERT_ERROR_CHECKING_ISSUER_FAIL):b=-1;d(n(b,e))})}catch(q){errCode=q.code,errMsg=q.message,d(n(q.code,q.message))}setTimeout(function(){c.dispose()},10);h=pri=null},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();d(n(a.ERROR.Code,a.ERROR.Message));c.dispose()}});c.show();return!0}},GetCertInfo: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;var d=n();a.reInitialize();var c=a.loadUI("certselect")({type:"CERT_SELECT",args:{dn:null,possibleWhale:!0},onConfirm:function(a,g,f,h,k,l,p){d.info=f;b(d);setTimeout(function(){c.dispose()},10)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();b(n(a.ERROR.Code,a.ERROR.Message));c.dispose()}});c.show();return!0}},SignP7File:function(b){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{var d=b;if(!d||document.getElementById("us-div-cert-select")||document.getElementById("us-div-import-cert"))return!1;var c=n();d=function(a){1==b.length?b(a):(null==a&&(a=n(-1)),b(a.signedData,a.curDevice,a.certAttrs,a.b64RValue))};a.reInitialize();var e=function(b){var e=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P7",args:{dn:null,possibleWhale:!1},onConfirm:function(f,g,h,n,m,r,q){c.certAttrs=h;if("undefined"!==typeof n&&"undefined"!==typeof m)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r))a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){e.dispose()},10);else if(r==a.CONST.__PF_M_CLOUDSIGN.device)a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){e.dispose()},10);else{g=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[n].signcert);f=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[n].signpri);h={};for(var k in b)try{var l=a.usWebToolkit.pkcs7.createSignedData();l.sign(a.usWebToolkit.util.decode64(b[k]),g,f,m,null,null);h[k]=a.usWebToolkit.pkcs7.messageToBase64(l)}catch(y){h[k]=""}c.signedData=h;d(c);setTimeout(function(){e.dispose()},10);n=m=g=f=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();d(n(a.ERROR.Code,a.ERROR.Message));e.dispose()}});e.show()},g=a.loadUI("importfile")({type:"importcert",args:null,onConfirm:function(a){g.dispose();for(var b={},c=0;c<a.length;c++)b[a[c].name]=a[c].data;e(b)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();d(n(a.ERROR.Code,a.ERROR.Message));g.dispose()}});g.show();return!0}},VerifyFileSignedDataP7:function(b,d){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!b)return null;n();a.reInitialize();var c=null,e={},g;for(g in b)try{c=a.usWebToolkit.pkcs7.messageFromBase64(b[g]),c.verify(),e[g]=c.verifyResult?c.content.data:""}catch(f){a.ERROR.Code=f.code,a.ERROR.Message=f.message,e[g]=""}d(e);return!0}},SignP1File: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")||document.getElementById("us-div-import-cert"))return!1;var d=n(),c=function(a){1==b.length?b(a):(null==a&&(a=n()),b(a.signedData,a.theCert,a.theDN))};a.reInitialize();var e=function(b){var e=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:null,possibleWhale:!1},onConfirm:function(f,g,h,n,m,r,q){d.theCert=f;d.theDN=g;if("undefined"!==typeof n&&"undefined"!==typeof m)if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(r))a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){e.dispose()},10),c(d);else if(r==a.CONST.__PF_M_CLOUDSIGN.device)a.ERROR.Code=-1,a.ERROR.Message=a.uiUtil().getErrorMessageLang().IDS_ERROR_NOT_SUPPORT_DEVICE,setTimeout(function(){e.dispose()},10),c(d);else{f=a.usWebToolkit.pki.certificateFromBase64(a.PFUC[n].signcert);n=a.usWebToolkit.pkcs8.decryptRsaPrivateKeyFromBase64(a.PFUC[n].signpri,m);m=ma(f);f={};g={};for(var k in b){g[k]=b[k];try{m.update(b[k]);var l=n.sign(m);f[k]=a.usWebToolkit.util.encode64(l)}catch(y){a.ERROR.Code=y.code,a.ERROR.Message=y.message,f[k]=""}}d.signedData=f;d.plainData=g;c(d);setTimeout(function(){e.dispose()},10);n=m=f=pri=null}},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();c(n(a.ERROR.Code,a.ERROR.Message));e.dispose()}});e.show()},g=a.loadUI("importfile")({type:"importcert",args:null,onConfirm:function(a){g.dispose();for(var b={},c=0;c<a.length;c++)b[a[c].name]=a[c].data;e(b)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();c(n(a.ERROR.Code,a.ERROR.Message));g.dispose()}});g.show();return!0}},VerifyFileSignedDataP1:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{b&&d&&c||e(-1);a.reInitialize();c=a.usWebToolkit.pki.certificateFromBase64(c);var g=ma(c),f={},h;for(h in d){var k=a.usWebToolkit.util.decode64(d[h]);g.update(b[h]);try{f[h]=c.publicKey.verify(g.digest().getBytes(),k)}catch(l){a.ERROR.Code=l.code,a.ERROR.Message=l.message,f[h]=!1}}resultObject=f;e(resultObject);return!0}},SymmetricKeyEncryptFile:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!e||document.getElementById("us-div-import-cert"))return!1;var g=n(),f=b.toLowerCase();switch(f){case "3des":f="des";case "aes":case "seed":case "des":break;default:f="seed"}var h=a.loadUI("importfile")({type:"importcert",args:null,onConfirm:function(b){for(var k={},n=0;n<b.length;n++)if(0==b[n].data.length)k[b[n].name]="";else try{var t=a.usWebToolkit.cipher.algorithms[f].startEncrypting(a.usWebToolkit.util.hexToBytes(d),a.usWebToolkit.util.hexToBytes(c));t.update(a.usWebToolkit.util.createBuffer(b[n].data));t.finish();k[b[n].name]=a.usWebToolkit.util.encode64(t.output.getBytes())}catch(m){k[b[n].name]=""}g.encryptData=k;h.dispose();e(g)},onCancel:function(){a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message));h.dispose()}});h.show()}},SymmetricKeyDecryptFile:function(b,d,c,e,g){var f={};d=d.toLowerCase();switch(d){case "3des":d="des";case "aes":case "seed":case "des":break;default:d="seed"}try{var h={},k;for(k in b){var l=a.usWebToolkit.cipher.algorithms[d].startDecrypting(a.usWebToolkit.util.hexToBytes(c),a.usWebToolkit.util.hexToBytes(e));l.update(a.usWebToolkit.util.createBuffer(a.usWebToolkit.util.decode64(b[k])));l.finish();h[k]=l.output.getBytes();g&&a.fileUtil().save(k,h[k].toArrayBuffer())}f.resultCode=0;f.decryptData=h;return f}catch(p){f.resultCode=p.code,f.resultMessage=p.message,f.decryptData}return f},EncryptDataP1:function(b,d,c){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!c||!d&&document.getElementById("us-div-cert-select"))return!1;var e=n(),g=a.usWebToolkit.util.encodeUtf8(b);if(d&&"string"==typeof d){try{var f=a.usWebToolkit.x509Certificate.parser(d,"Base64");e.encryptData=a.usWebToolkit.util.encode64(f.publicKey.encrypt(g))}catch(k){a.ERROR.Message=e.resultCode=k.code,a.ERROR.Code=e.resultMessage=k.message,e.encryptData}c(e)}else{var h=a.loadUI("certselect")({type:"CERT_SELECT",args:{dn:null},onConfirm:function(b,d,f,n,m,r,q){if(!a.PFUC[n].kmcert)return h.dispose(),a.ERROR.Message=e.resultMessage=a.uiUtil().getErrorMessageLang().IDS_NO_KMCERT,a.ERROR.Code=e.resultCode=3109E4,c(e),!1;b=h;try{var k=a.usWebToolkit.x509Certificate.parser(a.PFUC[n].kmcert,"Base64");e.encryptData=a.usWebToolkit.util.encode64(k.publicKey.encrypt(g))}catch(v){a.ERROR.Message=e.resultCode=v.code,a.ERROR.Code=e.resultMessage=v.message,e.encryptData}b.dispose();c(e)},onCancel:function(){h.dispose();a.uiUtil().getUserCancelErrCodeNMsg();c(n(a.ERROR.Code,a.ERROR.Message))}});h.show()}}},DecryptDataP1:function(b,d,c,e){if(0==a.isAvailable())a.uiUtil().msgBox(a.uiUtil().getErrorMessageLang().IDS_ERROR_DO_NOT_AVAILABLE);else{if(!e||!d&&document.getElementById("us-div-cert-select"))return!1;var g=n();if(d&&"string"==typeof d&&c){try{var f=a.usWebToolkit.util.decode64(b),h=a.usWebToolkit.pkcs8.decryptRsaPrivateKeyFromBase64(d,c);g.decryptData=a.usWebToolkit.util.decodeUtf8(h.decrypt(f))}catch(l){a.ERROR.Message=g.resultCode=l.code,a.ERROR.Code=g.resultMessage=l.message,g.decryptData}e(g)}else{var k=a.loadUI("certselect")({type:"DIGITAL_SIGNATURE_P1",args:{dn:null},onConfirm:function(c,d,f,h,n,q,u){if(!a.PFUC[h].kmpri)return k.dispose(),a.ERROR.Message=g.resultMessage=a.uiUtil().getErrorMessageLang().IDS_NO_KMCERT,a.ERROR.Code=g.resultCode=3109E4,e(g),!1;c=k;try{var l=a.usWebToolkit.util.decode64(b),m=a.usWebToolkit.pkcs8.decryptRsaPrivateKeyFromBase64(a.PFUC[h].kmpri,n);g.decryptData=a.usWebToolkit.util.decodeUtf8(m.decrypt(l))}catch(G){a.ERROR.Message=g.resultCode=G.code,a.ERROR.Code=g.resultMessage=G.message,g.decryptData}c.dispose();e(g)},onCancel:function(){k.dispose();a.uiUtil().getUserCancelErrCodeNMsg();e(n(a.ERROR.Code,a.ERROR.Message))}});k.show()}}},CertTransferV2: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){k.defaultdevice&&(u.Media.defaultdevice=k.defaultdevice);k.list&&(u.Media.list=k.list.slice());a.ESVS.Media=u.Media;d&&d.dispose();c&&268500992!=b&&-1207!=b&&-1208!=b&&a.nimservice().AbnormalFinalize(c,function(a,b){})}function g(b,c,d){k.defaultdevice&&(u.Media.defaultdevice=k.defaultdevice);k.list&&(u.Media.list=k.list.slice());a.ESVS.Media=u.Media;d&&d.dispose();c&&268500992!=b&&a.nimservice().Finalize(c,function(a,b){0==a&&h&&setTimeout(function(){h(a)},0)})}if(0==a.isAvailable())return a.uiUtil().msgBox(a.transferLang().IDS_ERROR_DO_NOT_AVAILABLE),!1;var f=null,h=d?d:null,k={};k.defaultdevice=a.ESVS.Media.defaultdevice;k.list=a.ESVS.Media.list.slice();if("import"==b){var l=function(b){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().ImportPFX(b,function(d,f,h,k){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=d?(c(d,f),g(d,b,null)):ab(function(c){var d=c.curDevice,f=c.curDrive,l=c.password;c=c.pin;a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_SAVE);$a(h,k,d,f,l,c,function(c){var d=c.resultCode;c=c.resultMessage;a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=d?(a.uiUtil().errMsgBox(c,d),e(d,b,null)):(a.uiUtil().msgBox(a.transferLang().IDS_SUC_DONE),g(d,b,null))})},function(){a.uiUtil().msgBox(a.transferLang().IDS_CANCEL_SAVING);e(-1,b,null)})})};a.nimservice()?(b=H({eval:!1,intergrity:!1,name:"license",url:a.ESVS.License}),null==b&&(b="Fail to load license"),ImportingDialog=a.loadUI("certimport")({type:null,args:{license:b},onConfirm:function(b,d){ImportingDialog.dispose();a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_SENDRECEIVER);a.nimservice().SendReceiverInfo(d,16,b,function(b,f){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=b?(c(b,f),e(b,d,null)):l(d)})},onCancel:function(){ImportingDialog.dispose();c(-1);d&&setTimeout(function(){d(-1)},0)}}),ImportingDialog.show()):a.uiUtil().msgBox(a.transferLang().IDS_ERR_NIMSERVICE_UNLOAD)}else{var n=function(b,d,f,k,l,m){a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_TRANSFER);a.nimservice().GetPassword(d,function(n,q,p){0==n?Za(f,l,m,p,k,function(f){var k=f.resultCode,l=f.resultMessage;0!=k?(-2!=k&&a.errPopup(k,l),e(k,d,b),a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"),999==k&&h?setTimeout(function(){h(-1)},0):-2==k&&h&&setTimeout(function(){h(-2)},0)):a.nimservice().ExportPFX(d,p,f.pfx,function(f,h){0!=f?(c(f,h),e(f,d,b)):(a.uiUtil().msgBox(a.transferLang().IDS_SUC_DONE),g(f,d,b));a.uiUtil().createLoadingBox("hide","us-div-loading-dialog")})}):(a.errPopup(n,q),e(n,d,b),a.uiUtil().createLoadingBox("hide","us-div-loading-dialog"))})},t=function(b,d){a.nimservice().GetSenderInfoMsg(b,function(f,g,k){a.uiUtil().createLoadingBox("hide","us-div-loading-dialog");0!=f?(c(f,g),e(f,b,null)):(fa||(a.ESVS.Media=6==L?u.Media={defaultdevice:"harddisk",list:"harddisk|removable|browsersign"}:u.Media={defaultdevice:"harddisk",list:"harddisk|removable"}),jb("DIGITAL_SIGNATURE_P7_EXT_DISABLE_SECTOKEN",null,k,null,function(f){0!=f.resultCode?(-2!=f.resultCode&&c(f.resultCode,f.resultMessage),e(f.resultCode,b,null),999==f.resultCode&&h?setTimeout(function(){h(-1)},0):-2==f.resultCode&&h&&setTimeout(function(){h(-2)},0)):(a.uiUtil().createLoadingBox("show","us-div-loading-dialog",a.transferLang().IDS_PROGRESS_GETCERTNUM),a.nimservice().GetCertNum(b,f.signedData,function(g,h,k){0!=g?(c(g,h),e(g,b,null),a.uiUtil().createLoadingBox("hide","us-div-loading-dialog")):a.nimservice().GetQRCodeData(b,k,function(g,h,l){0!=g||0>=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.")};
|