!function(t,r){if("function"==typeof define&&define.amd)define(["exports"],r);else if("undefined"!=typeof exports)r(exports);else{var i={};r(i),t.SmCrypto=i}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(_exports){"use strict";Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.doSm3AndSm2Encrypt=doSm3AndSm2Encrypt;var AostarJS=AostarJS||(d=Math,f={},g=f.jx={},h=g.Base={extend:function(t){r.prototype=this;var i=new r;return t&&i.nz(t),i.hasOwnProperty("dV")||(i.dV=function(){i.wd.dV.apply(this,arguments)}),(i.dV.prototype=i).wd=this,i},create:function(){var t=this.extend();return t.dV.apply(t,arguments),t},dV:function(){},nz:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.dV.prototype.extend(this)}},i=g.eR=h.extend({dV:function(t,r){t=this.cu=t||[],this.fe=null!=r?r:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var r=this.cu,i=t.cu,e=this.fe,n=t.fe;if(this.eC(),e%4)for(var s=0;s>>2]>>>24-s%4*8&255;r[e+s>>>2]|=o<<24-(e+s)%4*8}else if(65535>>2]=i[s>>>2];else r.push.apply(r,i);return this.fe+=n,this},eC:function(){var t=this.cu,r=this.fe;t[r>>>2]&=4294967295<<32-r%4*8,t.length=d.ceil(r/4)},clone:function(){var t=h.clone.call(this);return t.cu=this.cu.slice(0),t},random:function(t){for(var r=[],e=0;e>>0,t=(e*=t)>>>0,t+=4294967296*(e-=t)}for(;;){if((new Date).getTime().toString()!=r)return 2.3283064365386963e-10*(t>>>0)}}},l=j.hx={stringify:function(t){for(var r=t.cu,i=t.fe,e=[],n=0;n>>2]>>>24-n%4*8&255;e.push((s>>>4).toString(16)),e.push((15&s).toString(16))}return e.join("")},parse:function(t){for(var r=t.length,e=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new i.dV(e,r/2)}},m=j.pL={stringify:function(t){for(var r=t.cu,i=t.fe,e=[],n=0;n>>2]>>>24-n%4*8&255;e.push(String.fromCharCode(s))}return e.join("")},parse:function(t){for(var r=t.length,e=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new i.dV(e,r)}},n=j.fc={stringify:function(t){try{return decodeURIComponent(escape(m.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return m.parse(unescape(encodeURIComponent(t)))}},o=g.jh=h.extend({reset:function(){this.hz=new i.dV,this.qJ=0},mE:function(t){"string"==typeof t&&(t=n.parse(t)),this.hz.concat(t),this.qJ+=t.fe},iG:function(t){var r=this.hz,e=r.cu,n=r.fe,s=this.dX,o=n/(4*s),h=(o=t?d.ceil(o):d.max((0|o)-this.qR,0))*s,f=d.min(4*h,n);if(h){for(var c=0;c":">",'"':""","'":"'","/":"/","`":"`"},Lb=["toString","valueOf"],Mb={isArray:function(t){return"[object Array]"===Fb.toString.apply(t)},va:function(t){return"boolean"==typeof t},isFunction:function(t){return"function"==typeof t||"[object Function]"===Fb.toString.apply(t)},xN:function(t){return null===t},oc:function(t){return"number"==typeof t&&isFinite(t)},lb:function(t){return t&&("object"==typeof t||Eb.isFunction(t))||!1},nB:function(t){return"string"==typeof t},rH:function(t){return void 0===t},qv:QMX.hs.ua.sn?function(t,r){var i,e,n;for(i=0;i"'\/`]/g,function(t){return Kb[t]})},extend:function(t,r,i){if(!r||!t)throw new Error("extend failed, please check that all dependencies are included.");function e(){}var n;if(e.prototype=r.prototype,t.prototype=new e,(t.prototype.constructor=t).ff=r.prototype,r.prototype.constructor==Fb.constructor&&(r.prototype.constructor=r),i){for(n in i)Eb.hasOwnProperty(i,n)&&(t.prototype[n]=i[n]);Eb.qv(t.prototype,i)}},qu:function(t,r){if(!r||!t)throw new Error("Absorb failed, fY dependencies.");var i,e,n=arguments,s=n[2];if(s&&!0!==s)for(i=2;i "),Eb.lb(t[i])?n.push(0=r?t:new Array(r-t.length+1).join("0")+t},this.uQ=function(){return this.s},this.iE=function(t){this.ft=null,this.fG=!0,this.s=t,this.dq=kM(t)},this.yI=function(t,r,i,e,n,s){var o=new Date(Date.UTC(t,r-1,i,e,n,s,0));this.nf(o)},this.gm=function(){return this.dq}},QMX.lang.extend(Aostar.cI.nj,Aostar.cI.hH),Aostar.cI.ok=function(t){Aostar.cI.iM.ff.constructor.call(this);this.vY=function(t){this.ft=null,this.fG=!0,this.it=t},this.vj=function(t){this.ft=null,this.fG=!0,this.it.push(t)},this.it=new Array,void 0!==t&&void 0!==t.array&&(this.it=t.array)},QMX.lang.extend(Aostar.cI.ok,Aostar.cI.hH),Aostar.cI.oB=function(){Aostar.cI.oB.ff.constructor.call(this),this.fq="01",this.ft="0101ff"},QMX.lang.extend(Aostar.cI.oB,Aostar.cI.hH),Aostar.cI.gW=function(t){Aostar.cI.gW.ff.constructor.call(this),this.fq="02",this.nm=function(t){this.ft=null,this.fG=!0,this.dq=Aostar.cI.hi.qw(t)},this.jZ=function(t){var r=new K(String(t),10);this.nm(r)},this.kb=function(t){this.dq=t},this.gm=function(){return this.dq},void 0!==t&&(void 0!==t.ku?this.nm(t.ku):void 0!==t.int?this.jZ(t.int):"number"==typeof t?this.jZ(t):void 0!==t.dv&&this.kb(t.dv))},QMX.lang.extend(Aostar.cI.gW,Aostar.cI.hH),Aostar.cI.ps=function(t){if(void 0!==t&&void 0!==t.eI){var r=Aostar.cI.hi.jd(t.eI);t.dv="00"+r.hc()}Aostar.cI.ps.ff.constructor.call(this),this.fq="03",this.qB=function(t){this.ft=null,this.fG=!0,this.dq=t},this.xK=function(t,r){if(t<0||7>6)+ib.charAt(63&i);if(r+1==t.length?(i=parseInt(t.substring(r,r+1),16),e+=ib.charAt(i<<2)):r+2==t.length&&(i=parseInt(t.substring(r,r+2),16),e+=ib.charAt(i>>2)+ib.charAt((3&i)<<4)),ot)for(;0<(3&e.length);)e+=ot;return e}function cV(t){var r,i,e,n="",s=0;for(r=0;r>2),i=3&e,1):1==s?(n+=ax(i<<2|e>>4),i=15&e,2):2==s?(n+=ax(i),n+=ax(e>>2),i=3&e,3):(n+=ax(i<<2|e>>4),n+=ax(15&e),0));return 1==s&&(n+=ax(i<<2)),n}function cn(t){var r,i=cV(t),e=new Array;for(r=0;2*ri.dY()?t.dY()-1:i.dY()-1;for(var n=this.bZ.hk(),s=this.add(r);0<=e;)n=n.ko(),t.eE(e)?n=i.eE(e)?n.add(s):n.add(this):i.eE(e)&&(n=n.add(r)),--e;return n}function ag(t,r,i){this.q=t,this.a=this.ev(r),this.b=this.ev(i),this.og=new O(this,null,null)}function dG(){return this.q}function dp(){return this.a}function ck(){return this.b}function cS(t){return t==this||this.q.fI(t.q)&&this.a.fI(t.a)&&this.b.fI(t.b)}function cL(){return this.og}function bY(t){return new V(this.q,t)}function cw(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.og;case 2:case 3:return null;case 4:case 6:case 7:var r=(t.length-2)/2,i=t.substr(2,r),e=t.substr(2+r,r);return new O(this,this.ev(new K(i,16)),this.ev(new K(e,16)));default:return null}}if(AostarJS.jx.jP||function(){var t=AostarJS,r=t.jx,i=r.Base,f=r.eR,e=r.jh,n=t.ef,s=(n.fc,n.po),o=t.hl.qG,h=r.jP=e.extend({dF:i.extend(),oW:function(t,r){return this.create(this.oH,t,r)},oq:function(t,r){return this.create(this.uq,t,r)},dV:function(t,r,i){this.dF=this.dF.extend(i),this.pV=t,this.wD=r,this.reset()},reset:function(){e.reset.call(this),this.pR()},wc:function(t){return this.mE(t),this.iG()},jF:function(t){return t&&this.mE(t),this.nh()},he:4,kh:4,oH:1,uq:2,ri:function(e){return{nr:function(t,r,i){return c(r).nr(e,t,r,i)},mU:function(t,r,i){return c(r).mU(e,t,r,i)}}}});function c(t){return"string"==typeof t?A:y}r.tJ=h.extend({nh:function(){return this.iG(!0)},dX:1});var u,a=t.mode={},F=r.qZ=i.extend({oW:function(t,r){return this.tF.create(t,r)},oq:function(t,r){return this.vR.create(t,r)},dV:function(t,r){this.qs=t,this.qb=r}}),l=a.CBC=((u=F.extend()).tF=u.extend({qC:function(t,r){var i=this.qs,e=i.dX;p.call(this,t,r,e),i.yB(t,r),this.qS=t.slice(r,r+e)}}),u.vR=u.extend({qC:function(t,r){var i=this.qs,e=i.dX,n=t.slice(r,r+e);i.wb(t,r),p.call(this,t,r,e),this.qS=n}}),u);function p(t,r,i){var e=this.qb;if(e){var n=e;this.qb=void 0}else n=this.qS;for(var s=0;s>>2];t.fe-=r}},v=(r.tK=h.extend({dF:h.dF.extend({mode:l,padding:d}),reset:function(){h.reset.call(this);var t=this.dF,r=t.eO,i=t.mode;if(this.pV==this.oH)var e=i.oW;else{e=i.oq;this.qR=1}this.vQ=e.call(i,this,r&&r.cu)},qp:function(t,r){this.vQ.qC(t,r)},nh:function(){var t=this.dF.padding;if(this.pV==this.oH){t.gh(this.hz,this.dX);var r=this.iG(!0)}else{r=this.iG(!0);t.tq(r)}return r},dX:4}),r.mf=i.extend({dV:function(t){this.nz(t)},toString:function(t){return(t||this.ny).stringify(this)}})),g=(t.format={}).vq={stringify:function(t){var r=t.fz,i=t.gb;if(i)var e=f.create([1398893684,1701076831]).concat(i).concat(r);else e=r;return e.toString(s)},parse:function(t){var r=s.parse(t),i=r.cu;if(1398893684==i[0]&&1701076831==i[1]){var e=f.create(i.slice(2,4));i.splice(0,4),r.fe-=16}return v.create({fz:r,gb:e})}},y=r.jW=i.extend({dF:i.extend({format:g}),nr:function(t,r,i,e){e=this.dF.extend(e);var n=t.oW(i,e),s=n.jF(r),o=n.dF;return v.create({fz:s,key:i,eO:o.eO,wp:t,mode:o.mode,padding:o.padding,dX:t.dX,ny:e.format})},mU:function(t,r,i,e){return e=this.dF.extend(e),r=this.qh(r,e.format),t.oq(i,e).jF(r.fz||r)},qh:function(t,r){return"string"==typeof t?r.parse(t,this):t}}),m=(t.qE={}).vq={ql:function(t,r,i,e){e=e||f.random(8);var n=o.create({he:r+i}).xI(t,e),s=f.create(n.cu.slice(r),4*i);return n.fe=4*r,v.create({key:n,eO:s,gb:e})}},A=r.pD=y.extend({dF:y.dF.extend({qE:m}),nr:function(t,r,i,e){var n=(e=this.dF.extend(e)).qE.ql(i,t.he,t.kh);e.eO=n.eO;var s=y.nr.call(this,t,r,n.key,e);return s.nz(n),s},mU:function(t,r,i,e){e=this.dF.extend(e),r=this.qh(r,e.format);var n=e.qE.ql(i,t.he,t.kh,r.gb);return e.eO=n.eO,y.mU.call(this,t,r,n.key,e)}})}(),V.prototype.fI=dA,V.prototype.cl=bW,V.prototype.ht=cE,V.prototype.add=dm,V.prototype.eB=dK,V.prototype.multiply=cW,V.prototype.square=dr,V.prototype.divide=dN,O.prototype.eS=dC,O.prototype.ew=dQ,O.prototype.fI=cq,O.prototype.fX=ce,O.prototype.ht=cY,O.prototype.add=dI,O.prototype.ko=cb,O.prototype.multiply=cZ,O.prototype.xS=cQ,ag.prototype.pv=dG,ag.prototype.wo=dp,ag.prototype.uN=ck,ag.prototype.fI=cS,ag.prototype.hk=cL,ag.prototype.ev=bY,ag.prototype.wP=cw,void 0===Aostar||!Aostar)var Aostar={};void 0!==Aostar.crypto&&Aostar.crypto||(Aostar.crypto={}),Aostar.crypto.eJ=function(t){var r=new bG;this.type="EC",this.jc=function(t){return new K(t.dY(),r).fJ(t.eB(K.ONE)).add(K.ONE)},this.nl=function(t){this.fm=Aostar.crypto.hD.getByName(t),this.eh=null,this.cv=null,this.ed=t},this.kA=function(t){this.tf=!0,this.eh=t},this.kO=function(t){this.rC=!0,this.cv=t},this.xY=function(){var t=this.cv;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var r=this.fm.hO/4;if(t.length!==2+2*r)throw"malformed public key dv length";var i={};return i.x=t.substr(2,r),i.y=t.substr(2+r),i},this.yY=function(){var t=this.ed;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":null},this.oh=function(){var t=this.fm.n,r=this.jc(t),i=this.fm.G.multiply(r),e=i.eS().cl(),n=i.ew().cl(),s=this.fm.hO/4,o=("0000000000"+r.toString(16)).slice(-s),h="04"+("0000000000"+e.toString(16)).slice(-s)+("0000000000"+n.toString(16)).slice(-s);return this.kA(o),this.kO(h),{ecprvhex:o,ecpubhex:h}},this.vc=function(t){var r=new K(t,16),i=this.fm.G.multiply(r),e=i.eS().cl(),n=i.ew().cl(),s=this.fm.hO/4;return{ecprvhex:("0000000000"+r.toString(16)).slice(-s),ecpubhex:"04"+("0000000000"+e.toString(16)).slice(-s)+("0000000000"+n.toString(16)).slice(-s)}},this.mL=function(t){return this.jz(t,this.eh)},this.jz=function(t,r){var i=new K(r,16),e=this.fm.n,n=new K(t,16);do{var s=this.jc(e),o=this.fm.G.multiply(s).eS().cl().fJ(e)}while(o.dU(K.ZERO)<=0);var h=s.hm(e).multiply(n.add(i.multiply(o))).fJ(e);return Aostar.crypto.eJ.pk(o,h)},this.gX=function(t,r){var i=r,e=this.fm.n,n=K.hq(t);do{var s=this.jc(e),o=this.fm.G.multiply(s).eS().cl().fJ(e)}while(o.dU(K.ZERO)<=0);var h=s.hm(e).multiply(n.add(i.multiply(o))).fJ(e);return this.mX(o,h)},this.lJ=function(t,r){return this.jQ(t,r,this.cv)},this.jQ=function(t,r,i){var e,n,s,o=Aostar.crypto.eJ.rG(r);e=o.r,n=o.s,s=O.ll(this.fm.bZ,i);var h=new K(t,16);return this.kk(h,e,n,s)},this.fY=function(t,r,i){var e,n,s;if(oG.fW.isArray(r)){var o=this.lL(r);e=o.r,n=o.s}else{if("object"!=typeof r||!r.r||!r.s)throw"Invalid value for signature";e=r.r,n=r.s}if(i instanceof O)s=i;else{if(!oG.fW.isArray(i))throw"Invalid format for gk value, must be byte array fv O";s=O.qk(this.fm.bZ,i)}var h=K.hq(t);return this.kk(h,e,n,s)},this.kk=function(t,r,i,e){var n=this.fm.n,s=this.fm.G;if(r.dU(K.ONE)<0||0<=r.dU(n))return!1;if(i.dU(K.ONE)<0||0<=i.dU(n))return!1;var o=i.hm(n),h=t.multiply(o).fJ(n),f=r.multiply(o).fJ(n);return s.multiply(h).add(e.multiply(f)).eS().cl().fJ(n).fI(r)},this.mX=function(t,r){var i=t.mZ(),e=r.mZ(),n=[];return n.push(2),n.push(i.length),(n=n.concat(i)).push(2),n.push(e.length),(n=n.concat(e)).unshift(n.length),n.unshift(48),n},this.lL=function(t){var r;if(48!=t[0])throw new Error("gn not a valid jt");if((r=2)!=t[r])throw new Error("First element in signature must be a gW");var i=t.slice(r+2,r+2+t[r+1]);if(2!=t[r+=2+t[r+1]])throw new Error("Second element in signature must be a gW");var e=t.slice(r+2,r+2+t[r+1]);return r+=2+t[r+1],{r:K.hq(i),s:K.hq(e)}},this.sl=function(t){if(65!==t.length)throw"gn has the wrong length";var r=t[0]-27;if(r<0||7i.length;)i.unshift(0);return i}var i=this.eS().cl(),e=this.ew().cl(),n=r(i,32);return t?e.ez()?n.unshift(2):n.unshift(3):(n.unshift(4),n=n.concat(r(e,32))),n},O.qk=function(t,r){r[0];var i=r.length-1,e=r.slice(1,1+i/2),n=r.slice(1+i/2,1+i);e.unshift(0),n.unshift(0);var s=new K(e),o=new K(n);return new O(t,t.ev(s),t.ev(o))},O.ll=function(t,r){r.substr(0,2);var i=r.length-2,e=r.substr(2,i/2),n=r.substr(2+i/2,i/2),s=new K(e,16),o=new K(n,16);return new O(t,t.ev(s),t.ev(o))},O.prototype.hw=function(t){if(this.fX())return t;if(t.fX())return this;if(this.x.fI(t.x))return this.y.fI(t.y)?this.ko():this.bZ.hk();var r=t.x.eB(this.x),i=t.y.eB(this.y).divide(r),e=i.square().eB(this.x).eB(t.x),n=i.multiply(this.x.eB(e)).eB(this.y);return new O(this.bZ,e,n)},O.prototype.pY=function(){if(this.fX())return this;if(0==this.y.cl().eN())return this.bZ.hk();var t=this.bZ.ev(K.valueOf(2)),r=this.bZ.ev(K.valueOf(3)),i=this.x.square().multiply(r).add(this.bZ.a).divide(this.y.multiply(t)),e=i.square().eB(this.x.multiply(t)),n=i.multiply(this.x.eB(e)).eB(this.y);return new O(this.bZ,e,n)},O.prototype.yo=function(t){if(this.fX())return this;if(0==t.eN())return this.bZ.hk();var r,i=t,e=i.multiply(new K("3")),n=this.ht(),s=this;for(r=e.dY()-2;0>15,f=s;f--;){var c=32767&this[t],u=this[t++]>>15,a=h*c+u*o;n=((c=o*c+((32767&a)<<15)+i[e]+(1073741823&n))>>>30)+(a>>>15)+h*u+(n>>>30),i[e++]=1073741823&c}return n}function cN(t,r,i,e,n,s){for(var o=16383&r,h=r>>14;0<=--s;){var f=16383&this[t],c=this[t++]>>14,u=h*f+c*o;n=((f=o*f+((16383&u)<<14)+i[e]+n)>>28)+(u>>14)+h*c,i[e++]=268435455&f}return n}var rI="undefined"!=typeof navigator;ji=rI&&st&&"Microsoft Internet Explorer"==navigator.appName?(K.prototype.eA=cD,30):rI&&st&&"Netscape"!=navigator.appName?(K.prototype.eA=dg,26):(K.prototype.eA=cN,28),K.prototype.cj=ji,K.prototype.eH=(1<this.cj?(this[this.t-1]|=(o&(1<>this.cj-s):this[this.t-1]|=o<=this.cj&&(s-=this.cj))}8==i&&0!=(128&t[0])&&(this.s=-1,0>h)&&(n=!0,s=ax(i));0<=o;)h>(h+=this.cj-r)):(i=this[o]>>(h-=r)&e,h<=0&&(h+=this.cj,--o)),0>>16)&&(t=r,i+=16),0!=(r=t>>8)&&(t=r,i+=8),0!=(r=t>>4)&&(t=r,i+=4),0!=(r=t>>2)&&(t=r,i+=2),0!=(r=t>>1)&&(t=r,i+=1),i}function cX(){return this.t<=0?0:this.cj*(this.t-1)+bj(this[this.t-1]^this.s&this.eH)}function dB(t,r){var i;for(i=this.t-1;0<=i;--i)r[i+t]=this[i];for(i=t-1;0<=i;--i)r[i]=0;r.t=this.t+t,r.s=this.s}function df(t,r){for(var i=t;i>n|h,h=(this[i]&s)<=this.t)r.t=0;else{var e=t%this.cj,n=this.cj-e,s=(1<>e;for(var o=i+1;o>e;0>=this.cj;if(t.t>=this.cj;e+=this.s}else{for(e+=this.s;i>=this.cj;e-=t.s}r.s=e<0?-1:0,e<-1?r[i++]=this.ek+e:0=r.ek&&(t[i+r.t]-=r.ek,t[i+r.t+1]=1)}0>this.rf:0),F=this.vA/a,l=(1<>15,this.tz=(1<>15)*this.sg&this.tz)<<15)&t.eH;for(t[i=r+this.m.t]+=this.m.eA(0,e,t,r,0,this.m.t);t[i]>=t.ek;)t[i]-=t.ek,t[++i]++}t.eC(),t.jE(this.m.t,t),0<=t.dU(this.m)&&t.fM(this.m,t)}function cC(t,r){t.jv(r),this.reduce(r)}function ap(t,r,i){t.iy(r,i),this.reduce(i)}function cz(){return 0==(0>24}function bp(){return 0==this.t?this.s:this[0]<<16>>16}function aW(t){return Math.floor(Math.LN2*this.cj/Math.log(t))}function aZ(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function aA(t){if(null==t&&(t=10),0==this.eN()||t<2||36=i&&(this.kL(e),this.hy(o,0),o=s=0))}0t&&this.fM(K.ONE.shiftLeft(t-1),this);else{var e=new Array,n=7&t;e.length=1+(t>>3),r.nN(e),0>e)!=(this.s&this.eH)>>e&&(r[n++]=i|this.s<>(e+=this.cj-8)):(i=this[t]>>(e-=8)&255,e<=0&&(e+=this.cj,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(0>=16,r+=16),0==(255&t)&&(t>>=8,r+=8),0==(15&t)&&(t>>=4,r+=4),0==(3&t)&&(t>>=2,r+=2),0==(1&t)&&++r,r}function aQ(){for(var t=0;t=this.t?0!=this.s:0!=(this[r]&1<>=this.cj;if(t.t>=this.cj;e+=this.s}else{for(e+=this.s;i>=this.cj;e+=t.s}r.s=e<0?-1:0,0=this.ek;)this[r]-=this.ek,++r>=this.t&&(this[this.t++]=0),++this[r]}}function bS(){}function al(t){return t}function af(t,r,i){t.iy(r,i)}function aC(t,r){t.jv(r)}function bJ(t){return this.exp(t,new bS)}function az(t,r,i){var e,n=Math.min(this.t+t.t,r);for(i.s=0,i.t=n;02*this.m.t)return t.fJ(this.m);if(t.dU(this.m)<0)return t;var r=T();return t.gr(r),this.reduce(r),r}function bI(t){return t}function bz(t){for(t.jE(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.eC()),this.nM.nC(this.r2,this.m.t+1,this.jU),this.m.nT(this.jU,this.m.t+1,this.r2);t.dU(this.r2)<0;)t.hy(1,this.m.t+1);for(t.fM(this.r2,t);0<=t.dU(this.m);)t.fM(this.m,t)}function bv(t,r){t.jv(r),this.reduce(r)}function bK(t,r,i){t.iy(r,i),this.reduce(i)}function ak(t,r){var i,e,n=t.dY(),s=bx(1);if(n<=0)return s;i=n<18?1:n<48?3:n<144?4:n<768?5:6,e=n<8?new be(r):r.ez()?new aJ(r):new aX(r);var o=new Array,h=3,f=i-1,c=(1<>n-f&c:(a=(t[l]&(1<>this.cj+n-f)),h=i;0==(1&a);)a>>=1,--h;if((n-=h)<0&&(n+=this.cj,--l),p)o[a].gr(s),p=!1;else{for(;1>1)>fh.length&&(t=fh.length);for(var n=T(),s=0;s>8&255,fK[fg++]^=t>>16&255,fK[fg++]^=t>>24&255,jD<=fg&&(fg-=jD)}function bu(){bD((new Date).getTime())}if(K.prototype.lo=aW,K.prototype.dW=aA,K.prototype.ro=ad,K.prototype.mG=as,K.prototype.gz=bH,K.prototype.iw=aE,K.prototype.gA=bc,K.prototype.kL=aH,K.prototype.hy=aN,K.prototype.nT=az,K.prototype.nC=aG,K.prototype.oQ=aS,K.prototype.nI=av,K.prototype.clone=bf,K.prototype.hI=bg,K.prototype.ty=bP,K.prototype.vm=bp,K.prototype.eN=aZ,K.prototype.tu=aT,K.prototype.fI=aI,K.prototype.min=bB,K.prototype.max=bd,K.prototype.and=aD,K.prototype.fv=ar,K.prototype.xor=aO,K.prototype.ue=ai,K.prototype.not=ah,K.prototype.shiftLeft=aM,K.prototype.lO=aK,K.prototype.gs=aQ,K.prototype.ub=ab,K.prototype.eE=bN,K.prototype.uO=by,K.prototype.sc=aw,K.prototype.vp=aF,K.prototype.add=aa,K.prototype.eB=aV,K.prototype.multiply=ao,K.prototype.divide=aP,K.prototype.vU=aY,K.prototype.wO=aj,K.prototype.oz=ak,K.prototype.hm=au,K.prototype.pow=bJ,K.prototype.wA=bw,K.prototype.oV=an,K.prototype.square=aq,K.prototype.aJ=aJ,null==fK){var t;if(fK=new Array,fg=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.nK){var ua=new Uint8Array(32);for(window.crypto.nK(ua),t=0;t<32;++t)fK[fg++]=ua[t]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var z=window.crypto.random(32);for(t=0;t>>8,fK[fg++]=255&t;fg=0,bu()}function ay(){if(null==hn){for(bu(),(hn=bQ()).dV(fK),fg=0;fgn)throw"key is too short for SigAlg: hO="+i+","+r;for(var s="00"+e,o="",h=n-"0001".length-s.length,f=0;f>24&255),t.gf(this.kq>>16&255),t.gf(this.kq>>8&255),t.gf(255&this.kq),t.jy(this.key,0),this.jK=0,this.kq++},qF:function(t){var r,i,e=new Aostar.crypto.eJ({bZ:"sm2"}),n=null==this.gY?this.pF(e):e.vc(this.gY);r=new K(n.ecprvhex,16);var s=n.ecpubhex;return i=O.ll(e.fm.bZ,s),this.jR=t.multiply(r),this.Reset(),i},pF:function(t){var r=t.oh();return this.uy(r.ecpubhex)?r:this.pF(t)},uy:function(t){var r=t.length-2,i=t.substr(2,2),e=t.substr(2+r/2,2);return"00"!==i&&"00"!==e},qj:function(t){this.hQ.fl(t,0,t.length);for(var r=0;r>>3]|=parseInt(t[i])<<24-e%8*4,i++;return new AostarJS.jx.eR.dV(r,t.length)},jX:function(t,r){var i,e,n="04"===r.substr(0,2)?r.substr(2):r,s=n.substr(0,64),o=n.substr(0+s.length,64);this.eb==CipherMode.C1C3C2?(i=n.substr(s.length+o.length,64),e=n.substr(s.length+o.length+64)):(e=n.substr(s.length+o.length,n.length-192),i=n.substr(n.length-64));var h=this.fL(e),f=this.iz(s,o);this.rR(t,f),this.pZ(h);var c=new Array(32);if(this.mb(c),this.er(c).toString().toUpperCase()==i.toUpperCase())return this.er(h);throw new Error("[SM2:jX] C3 is not match!")},kI:function(t,r){var i,e,n=r,s=dE.kK(n),o=s[0],h=s[1];if(this.eb==CipherMode.C1C3C2)i=s[2],e=s[3];else{if(this.eb!=CipherMode.C1C2C3)throw new Error("[SM2:kI]invalid type eb("+this.eb+")");e=s[2],i=s[3]}var f=this.fL(e),c=this.iz(o,h);this.rR(t,c),this.pZ(f);var u=new Array(32);if(this.mb(u),this.er(u).toString().toUpperCase()==i.toUpperCase())return this.er(f);throw new Error("[SM2:kI] C3 is not match!")},iz:function(t,r){var i=new Aostar.crypto.eJ({bZ:"sm2"}),e="04"+(t=t.length<64?this.le(t,64):t.substr(t.length-64,64))+(r=r.length<64?this.le(r,64):r.substr(r.length-64,64));return O.ll(i.fm.bZ,e)}},window.CipherMode={C1C2C3:0,C1C3C2:1},window.SM2={C1C2C3:0,C1C3C2:1,c1c2c3:0,c1c3c2:1},void 0===Aostar||!Aostar)var Aostar={};function bA(){this.uz=64,this.eY=new Array,this.ij=0,this.hM=0,this.qy=32,this.oR=[1937774191,1226093241,388252375,-628488704,-1452330820,372324522,-477237683,-1325724082],this.v=new Array(8),this.uE=new Array(8),this.mI=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.X=new Array(68),this.ii=0,this.sQ=2043430169,this.rV=2055708042,0>>-r}function de(t){if(2147483647>24,n=255&t>>16,s=255&t>>8,o=255&t;r[i]=128>>32-r},this.rD=function(t){var r,i=new Array(4),e=new Array(4);return this.iW(t,i,0),e[0]=this.iu(i[0]),e[1]=this.iu(i[1]),e[2]=this.iu(i[2]),e[3]=this.iu(i[3]),(r=this.gc(e,0))^this.iT(r,2)^this.iT(r,10)^this.iT(r,18)^this.iT(r,24)},this.uZ=function(t,r,i,e,n){return t^this.rD(r^i^e^n)},this.sS=function(t){var r,i=new Array(4),e=new Array(4);return this.iW(t,i,0),e[0]=this.iu(i[0]),e[1]=this.iu(i[1]),e[2]=this.iu(i[2]),e[3]=this.iu(i[3]),(r=this.gc(e,0))^this.iT(r,13)^this.iT(r,23)},this.iu=function(t){var r=i[255&t];return 128>>31}var u=(e<<5|e>>>27)+h+uE[f];u+=f<20?1518500249+(n&s|~n&o):f<40?1859775393+(n^s^o):f<60?(n&s|n&o|s&o)-1894007588:(n^s^o)-899497514,h=o,o=s,s=n<<30|n>>>2,n=e,e=u}i[0]=i[0]+e|0,i[1]=i[1]+n|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+h|0},nh:function(){var t=this.hz,r=t.cu,i=8*this.qJ,e=8*t.fe;return r[e>>>5]|=128<<24-e%32,r[14+(64+e>>>9<<4)]=Math.floor(i/4294967296),r[15+(64+e>>>9<<4)]=i,t.fe=4*r.length,this.iG(),this.jM},clone:function(){var t=sE.clone.call(this);return t.jM=this.jM.clone(),t}}),oE.kc=sE.ri(vE),oE.yf=sE.uv(vE),bA.prototype={Init:function(){this.eY=new Array(4),this.Reset()},sD:function(t){this.eY=new Array(t.eY.length),Array.Copy(t.eY,0,this.eY,0,t.eY.length),this.ij=t.ij,this.hM=t.hM,Array.Copy(t.X,0,this.X,0,t.X.length),this.ii=t.ii,Array.Copy(t.v,0,this.v,0,t.v.length)},oM:function(){return this.qy},Reset:function(){this.hM=0,this.ij=0,Array.Clear(this.eY,0,this.eY.length),Array.Copy(this.oR,0,this.v,0,this.oR.length),this.ii=0,Array.Copy(this.mI,0,this.X,0,this.mI.length)},vT:function(){return this.uz},nD:function(){var t,r=this.X,i=new Array(64);for(t=16;t<68;t++)r[t]=this.wS(r[t-16]^r[t-9]^J(r[t-3],15))^J(r[t-13],7)^r[t-6];for(t=0;t<64;t++)i[t]=r[t]^r[t+4];var e,n,s,o,h,f=this.v,c=this.uE;for(Array.Copy(f,0,c,0,this.oR.length),t=0;t<16;t++)n=(e=J(e=(h=J(c[0],12))+c[4]+J(this.sQ,t),7))^h,s=this.wC(c[0],c[1],c[2])+c[3]+n+i[t],o=this.wQ(c[4],c[5],c[6])+c[7]+e+r[t],c[3]=c[2],c[2]=J(c[1],9),c[1]=c[0],c[0]=s,c[7]=c[6],c[6]=J(c[5],19),c[5]=c[4],c[4]=this.sp(o);for(t=16;t<64;t++)n=(e=J(e=(h=J(c[0],12))+c[4]+J(this.rV,t),7))^h,s=this.wx(c[0],c[1],c[2])+c[3]+n+i[t],o=this.wy(c[4],c[5],c[6])+c[7]+e+r[t],c[3]=c[2],c[2]=J(c[1],9),c[1]=c[0],c[0]=s,c[7]=c[6],c[6]=J(c[5],19),c[5]=c[4],c[4]=this.sp(o);for(t=0;t<8;t++)f[t]^=c[t];this.ii=0,Array.Copy(this.mI,0,this.X,0,this.mI.length)},qL:function(t,r){var i=t[r]<<24;i|=(255&t[++r])<<16,i|=(255&t[++r])<<8,i|=255&t[++r],this.X[this.ii]=i,16==++this.ii&&this.nD()},uU:function(t){14>>24&255,r[++i]=t>>>16&255,r[++i]=t>>>8&255,r[++i]=255&t},jy:function(t,r){this.vV();for(var i=0;i<8;i++)this.rz(this.v[i],t,r+4*i);return this.Reset(),this.qy},gf:function(t){this.eY[this.ij++]=t,this.ij==this.eY.length&&(this.qL(this.eY,0),this.ij=0),this.hM++},fl:function(t,r,i){for(;0!=this.ij&&0this.eY.length;)this.qL(t,r),r+=this.eY.length,i-=this.eY.length,this.hM+=this.eY.length;for(;0sZ.ss||t>r:(t>>r)+(2<<~r)},tN:function(t,r){var i,e=new K;if(e.hf(t),0<=e.eN())i=e.lO(r).hI();else{var n=new K;n.hf(2);var s=~r,o="";if(s<0){for(var h=64+s,f=0;f>r);var u=new K("10"+o,2);o=u.dW(10),i=u.add(c).dW(10)}else i=(t>>r)+(o=n.shiftLeft(~r).hI())}return i},qY:function(t,r,i){var e=AostarJS.ef.fc.parse(i),n=4*e.cu.length*8;this.gf(n>>8&255),this.gf(255&n);var s=this.fL(e.toString());this.fl(s,0,s.length);var o=this.fL(t.bZ.a.cl().dW(16)),h=this.fL(t.bZ.b.cl().dW(16)),f=this.fL(t.eS().cl().dW(16)),c=this.fL(t.ew().cl().dW(16)),u=this.fL(r.substr(0,64)),a=this.fL(r.substr(64,64));this.fl(o,0,o.length),this.fl(h,0,h.length),this.fl(f,0,f.length),this.fl(c,0,c.length),this.fl(u,0,u.length),this.fl(a,0,a.length);var F=new Array(this.oM());return this.jy(F,0),F},fL:function(t){for(var r=[],i=t.length,e=0;e>>3]|=parseInt(t[i])<<24-e%8*4,i++;return new AostarJS.jx.eR.dV(r,t.length)}},Array.Clear=function(t,r,i){for(var e in t)t[e]=null},Array.Copy=function(t,r,i,e,n){for(var s=t.slice(r,r+n),o=0;othis.ss){var n;for(r=(n=Number(t).toString(2)).substr(n.length-31,31),i="",e=0;e>>4).toString(16)),r.push((15&t[i]).toString(16));return r.join("").toUpperCase()},stringToHex:function(t){return AostarJS.ef.fc.parse(t).toString().toUpperCase()},stringToBytes:function(t){return this.hexToBytes(this.stringToHex(t))},bytesToString:function(t){for(var r=[1,1,1,1,2,2,3,0],i=t.length,e="",n=0;n>3&7];if(!(64&s)||!o||i>o;0