forked from franznoel/openid-implicit-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenidconnect.min.js
5 lines (5 loc) · 131 KB
/
openidconnect.min.js
1
2
3
4
5
function JSONObjToHTMLTable(a){try{var b='\n<table class="table table-striped">';for(var c in a)b=b+"\n<TR><TD>"+c+"</TD><TD>"+a[c]+"</TD></TR>";return b+="\n</table>"}catch(a){throw new OidcException("Unable to get JSON Obj to HTML table:"+a.toString())}}function OidcException(a){this.name="OidcException",this.message=a}function namespace(a){for(var b=a.split("."),c=window,d="",e=0,f=b.length;e<f;e++)d=b[e],c[d]=c[d]||{},c=c[d];return c}function hex2b64(a){var b,c,d="";for(b=0;b+3<=a.length;b+=3)c=parseInt(a.substring(b,b+3),16),d+=b64map.charAt(c>>6)+b64map.charAt(63&c);if(b+1==a.length?(c=parseInt(a.substring(b,b+1),16),d+=b64map.charAt(c<<2)):b+2==a.length&&(c=parseInt(a.substring(b,b+2),16),d+=b64map.charAt(c>>2)+b64map.charAt((3&c)<<4)),b64pad)for(;(3&d.length)>0;)d+=b64pad;return d}function b64tohex(a){var c,e,f,b="",d=0;for(c=0;c<a.length&&a.charAt(c)!=b64pad;++c)f=b64map.indexOf(a.charAt(c)),f<0||(0==d?(b+=int2char(f>>2),e=3&f,d=1):1==d?(b+=int2char(e<<2|f>>4),e=15&f,d=2):2==d?(b+=int2char(e),b+=int2char(f>>2),e=3&f,d=3):(b+=int2char(e<<2|f>>4),b+=int2char(15&f),d=0));return 1==d&&(b+=int2char(e<<2)),b}function b64toBA(a){var c,b=b64tohex(a),d=new Array;for(c=0;2*c<b.length;++c)d[c]=parseInt(b.substring(2*c,2*c+2),16);return d}function BigInteger(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}function am1(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function am2(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function am3(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function int2char(a){return BI_RM.charAt(a)}function intAt(a,b){var c=BI_RC[a.charCodeAt(b)];return null==c?-1:c}function bnpCopyTo(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function bnpFromInt(a){this.t=1,this.s=a<0?-1:0,a>0?this[0]=a:a<-1?this[0]=a+this.DV:this.t=0}function nbv(a){var b=nbi();return b.fromInt(a),b}function bnpFromString(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else{if(4!=b)return void this.fromRadix(a,b);c=2}this.t=0,this.s=0;for(var d=a.length,e=!1,f=0;--d>=0;){var g=8==c?255&a[d]:intAt(a,d);g<0?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<<this.DB-f)-1)<<f,this[this.t++]=g>>this.DB-f):this[this.t-1]|=g<<f,f+=c,f>=this.DB&&(f-=this.DB))}8==c&&0!=(128&a[0])&&(this.s=-1,f>0&&(this[this.t-1]|=(1<<this.DB-f)-1<<f)),this.clamp(),e&&BigInteger.ZERO.subTo(this,this)}function bnpClamp(){for(var a=this.s&this.DM;this.t>0&&this[this.t-1]==a;)--this.t}function bnToString(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var d,c=(1<<b)-1,e=!1,f="",g=this.t,h=this.DB-g*this.DB%b;if(g-- >0)for(h<this.DB&&(d=this[g]>>h)>0&&(e=!0,f=int2char(d));g>=0;)h<b?(d=(this[g]&(1<<h)-1)<<b-h,d|=this[--g]>>(h+=this.DB-b)):(d=this[g]>>(h-=b)&c,h<=0&&(h+=this.DB,--g)),d>0&&(e=!0),e&&(f+=int2char(d));return e?f:"0"}function bnNegate(){var a=nbi();return BigInteger.ZERO.subTo(this,a),a}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function nbits(a){var c,b=1;return 0!=(c=a>>>16)&&(a=c,b+=16),0!=(c=a>>8)&&(a=c,b+=8),0!=(c=a>>4)&&(a=c,b+=4),0!=(c=a>>2)&&(a=c,b+=2),0!=(c=a>>1)&&(a=c,b+=1),b}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function bnpDRShiftTo(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0),b.s=this.s}function bnpLShiftTo(a,b){var h,c=a%this.DB,d=this.DB-c,e=(1<<d)-1,f=Math.floor(a/this.DB),g=this.s<<c&this.DM;for(h=this.t-1;h>=0;--h)b[h+f+1]=this[h]>>d|g,g=(this[h]&e)<<c;for(h=f-1;h>=0;--h)b[h]=0;b[f]=g,b.t=this.t+f+1,b.s=this.s,b.clamp()}function bnpRShiftTo(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<<d)-1;b[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)b[g-c-1]|=(this[g]&f)<<e,b[g-c]=this[g]>>d;d>0&&(b[this.t-c-1]|=(this.s&f)<<e),b.t=this.t-c,b.clamp()}function bnpSubTo(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this.DM,d>>=this.DB;d-=a.s}b.s=d<0?-1:0,d<-1?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function bnpMultiplyTo(a,b){var c=this.abs(),d=a.abs(),e=c.t;for(b.t=e+d.t;--e>=0;)b[e]=0;for(e=0;e<d.t;++e)b[e+c.t]=c.am(0,d[e],b,e,0,c.t);b.s=0,b.clamp(),this.s!=a.s&&BigInteger.ZERO.subTo(b,b)}function bnpSquareTo(a){for(var b=this.abs(),c=a.t=2*b.t;--c>=0;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);(a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function bnpDivRemTo(a,b,c){var d=a.abs();if(!(d.t<=0)){var e=this.abs();if(e.t<d.t)return null!=b&&b.fromInt(0),void(null!=c&&this.copyTo(c));null==c&&(c=nbi());var f=nbi(),g=this.s,h=a.s,i=this.DB-nbits(d[d.t-1]);i>0?(d.lShiftTo(i,f),e.lShiftTo(i,c)):(d.copyTo(f),e.copyTo(c));var j=f.t,k=f[j-1];if(0!=k){var l=k*(1<<this.F1)+(j>1?f[j-2]>>this.F2:0),m=this.FV/l,n=(1<<this.F1)/l,o=1<<this.F2,p=c.t,q=p-j,r=null==b?nbi():b;for(f.dlShiftTo(q,r),c.compareTo(r)>=0&&(c[c.t++]=1,c.subTo(r,c)),BigInteger.ONE.dlShiftTo(j,r),r.subTo(f,f);f.t<j;)f[f.t++]=0;for(;--q>=0;){var s=c[--p]==k?this.DM:Math.floor(c[p]*m+(c[p-1]+o)*n);if((c[p]+=f.am(0,s,c,q,0,j))<s)for(f.dlShiftTo(q,r),c.subTo(r,c);c[p]<--s;)c.subTo(r,c)}null!=b&&(c.drShiftTo(j,b),g!=h&&BigInteger.ZERO.subTo(b,b)),c.t=j,c.clamp(),i>0&&c.rShiftTo(i,c),g<0&&BigInteger.ZERO.subTo(c,c)}}}function bnMod(a){var b=nbi();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(BigInteger.ZERO)>0&&a.subTo(b,b),b}function Classic(a){this.m=a}function cConvert(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function cSqrTo(a,b){a.squareTo(b),this.reduce(b)}function bnpInvDigit(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function Montgomery(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<a.DB-15)-1,this.mt2=2*a.t}function montConvert(a){var b=nbi();return a.abs().dlShiftTo(this.m.t,b),b.divRemTo(this.m,null,b),a.s<0&&b.compareTo(BigInteger.ZERO)>0&&this.m.subTo(b,b),b}function montRevert(a){var b=nbi();return a.copyTo(b),this.reduce(b),b}function montReduce(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=32767&a[b],d=c*this.mpl+((c*this.mph+(a[b]>>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function montSqrTo(a,b){a.squareTo(b),this.reduce(b)}function montMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(a,b){if(a>4294967295||a<1)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;for(e.copyTo(c);--f>=0;)if(b.sqrTo(c,d),(a&1<<f)>0)b.mulTo(d,e,c);else{var g=c;c=d,d=g}return b.revert(c)}function bnModPowInt(a,b){var c;return c=a<256||b.isEven()?new Classic(b):new Montgomery(b),this.exp(a,c)}function bnClone(){var a=nbi();return this.copyTo(a),a}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(a){if(null==a&&(a=10),0==this.signum()||a<2||a>36)return"0";var b=this.chunkSize(a),c=Math.pow(a,b),d=nbv(c),e=nbi(),f=nbi(),g="";for(this.divRemTo(d,e,f);e.signum()>0;)g=(c+f.intValue()).toString(a).substr(1)+g,e.divRemTo(d,e,f);return f.intValue().toString(a)+g}function bnpFromRadix(a,b){this.fromInt(0),null==b&&(b=10);for(var c=this.chunkSize(b),d=Math.pow(b,c),e=!1,f=0,g=0,h=0;h<a.length;++h){var i=intAt(a,h);i<0?"-"==a.charAt(h)&&0==this.signum()&&(e=!0):(g=b*g+i,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),f=0,g=0))}f>0&&(this.dMultiply(Math.pow(b,f)),this.dAddOffset(g,0)),e&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(a,b,c){if("number"==typeof b)if(a<2)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this);else{var d=new Array,e=7&a;d.length=(a>>3)+1,b.nextBytes(d),e>0?d[0]&=(1<<e)-1:d[0]=0,this.fromString(d,256)}}function bnToByteArray(){var a=this.t,b=new Array;b[0]=this.s;var d,c=this.DB-a*this.DB%8,e=0;if(a-- >0)for(c<this.DB&&(d=this[a]>>c)!=(this.s&this.DM)>>c&&(b[e++]=d|this.s<<this.DB-c);a>=0;)c<8?(d=(this[a]&(1<<c)-1)<<8-c,d|=this[--a]>>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,c<=0&&(c+=this.DB,--a)),0!=(128&d)&&(d|=-256),0==e&&(128&this.s)!=(128&d)&&++e,(e>0||d!=this.s)&&(b[e++]=d);return b}function bnEquals(a){return 0==this.compareTo(a)}function bnMin(a){return this.compareTo(a)<0?this:a}function bnMax(a){return this.compareTo(a)>0?this:a}function bnpBitwiseTo(a,b,c){var d,e,f=Math.min(a.t,this.t);for(d=0;d<f;++d)c[d]=b(this[d],a[d]);if(a.t<this.t){for(e=a.s&this.DM,d=f;d<this.t;++d)c[d]=b(this[d],e);c.t=this.t}else{for(e=this.s&this.DM,d=f;d<a.t;++d)c[d]=b(e,a[d]);c.t=a.t}c.s=b(this.s,a.s),c.clamp()}function op_and(a,b){return a&b}function bnAnd(a){var b=nbi();return this.bitwiseTo(a,op_and,b),b}function op_or(a,b){return a|b}function bnOr(a){var b=nbi();return this.bitwiseTo(a,op_or,b),b}function op_xor(a,b){return a^b}function bnXor(a){var b=nbi();return this.bitwiseTo(a,op_xor,b),b}function op_andnot(a,b){return a&~b}function bnAndNot(a){var b=nbi();return this.bitwiseTo(a,op_andnot,b),b}function bnNot(){for(var a=nbi(),b=0;b<this.t;++b)a[b]=this.DM&~this[b];return a.t=this.t,a.s=~this.s,a}function bnShiftLeft(a){var b=nbi();return a<0?this.rShiftTo(-a,b):this.lShiftTo(a,b),b}function bnShiftRight(a){var b=nbi();return a<0?this.lShiftTo(-a,b):this.rShiftTo(a,b),b}function lbit(a){if(0==a)return-1;var b=0;return 0==(65535&a)&&(a>>=16,b+=16),0==(255&a)&&(a>>=8,b+=8),0==(15&a)&&(a>>=4,b+=4),0==(3&a)&&(a>>=2,b+=2),0==(1&a)&&++b,b}function bnGetLowestSetBit(){for(var a=0;a<this.t;++a)if(0!=this[a])return a*this.DB+lbit(this[a]);return this.s<0?this.t*this.DB:-1}function cbit(a){for(var b=0;0!=a;)a&=a-1,++b;return b}function bnBitCount(){for(var a=0,b=this.s&this.DM,c=0;c<this.t;++c)a+=cbit(this[c]^b);return a}function bnTestBit(a){var b=Math.floor(a/this.DB);return b>=this.t?0!=this.s:0!=(this[b]&1<<a%this.DB)}function bnpChangeBit(a,b){var c=BigInteger.ONE.shiftLeft(a);return this.bitwiseTo(c,b,c),c}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this[c]+a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d+=a[c],b[c++]=d&this.DM,d>>=this.DB;d+=a.s}b.s=d<0?-1:0,d>0?b[c++]=d:d<-1&&(b[c++]=this.DV+d),b.t=c,b.clamp()}function bnAdd(a){var b=nbi();return this.addTo(a,b),b}function bnSubtract(a){var b=nbi();return this.subTo(a,b),b}function bnMultiply(a){var b=nbi();return this.multiplyTo(a,b),b}function bnSquare(){var a=nbi();return this.squareTo(a),a}function bnDivide(a){var b=nbi();return this.divRemTo(a,b,null),b}function bnRemainder(a){var b=nbi();return this.divRemTo(a,null,b),b}function bnDivideAndRemainder(a){var b=nbi(),c=nbi();return this.divRemTo(a,b,c),new Array(b,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,b,c){a.multiplyTo(b,c)}function nSqrTo(a,b){a.squareTo(b)}function bnPow(a){return this.exp(a,new NullExp)}function bnpMultiplyLowerTo(a,b,c){var d=Math.min(this.t+a.t,b);for(c.s=0,c.t=d;d>0;)c[--d]=0;var e;for(e=c.t-this.t;d<e;++d)c[d+this.t]=this.am(0,a[d],c,d,0,this.t);for(e=Math.min(a.t,b);d<e;++d)this.am(0,a[d],c,d,0,b-d);c.clamp()}function bnpMultiplyUpperTo(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;--d>=0;)c[d]=0;for(d=Math.max(b-this.t,0);d<a.t;++d)c[this.t+d-b]=this.am(b-d,a[d],c,0,0,this.t+d-b);c.clamp(),c.drShiftTo(1,c)}function Barrett(a){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*a.t,this.r2),this.mu=this.r2.divide(a),this.m=a}function barrettConvert(a){if(a.s<0||a.t>2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var b=nbi();return a.copyTo(b),this.reduce(b),b}function barrettRevert(a){return a}function barrettReduce(a){for(a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);a.compareTo(this.r2)<0;)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);a.compareTo(this.m)>=0;)a.subTo(this.m,a)}function barrettSqrTo(a,b){a.squareTo(b),this.reduce(b)}function barrettMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnModPow(a,b){var d,f,c=a.bitLength(),e=nbv(1);if(c<=0)return e;d=c<18?1:c<48?3:c<144?4:c<768?5:6,f=c<8?new Classic(b):b.isEven()?new Barrett(b):new Montgomery(b);var g=new Array,h=3,i=d-1,j=(1<<d)-1;if(g[1]=f.convert(this),d>1){var k=nbi();for(f.sqrTo(g[1],k);h<=j;)g[h]=nbi(),f.mulTo(k,g[h-2],g[h]),h+=2}var m,p,l=a.t-1,n=!0,o=nbi();for(c=nbits(a[l])-1;l>=0;){for(c>=i?m=a[l]>>c-i&j:(m=(a[l]&(1<<c+1)-1)<<i-c,l>0&&(m|=a[l-1]>>this.DB+c-i)),h=d;0==(1&m);)m>>=1,--h;if((c-=h)<0&&(c+=this.DB,--l),n)g[m].copyTo(e),n=!1;else{for(;h>1;)f.sqrTo(e,o),f.sqrTo(o,e),h-=2;h>0?f.sqrTo(e,o):(p=e,e=o,o=p),f.mulTo(o,g[m],e)}for(;l>=0&&0==(a[l]&1<<c);)f.sqrTo(e,o),p=e,e=o,o=p,--c<0&&(c=this.DB-1,--l)}return f.revert(e)}function bnGCD(a){var b=this.s<0?this.negate():this.clone(),c=a.s<0?a.negate():a.clone();if(b.compareTo(c)<0){var d=b;b=c,c=d}var e=b.getLowestSetBit(),f=c.getLowestSetBit();if(f<0)return b;for(e<f&&(f=e),f>0&&(b.rShiftTo(f,b),c.rShiftTo(f,c));b.signum()>0;)(e=b.getLowestSetBit())>0&&b.rShiftTo(e,b),(e=c.getLowestSetBit())>0&&c.rShiftTo(e,c),b.compareTo(c)>=0?(b.subTo(c,b),b.rShiftTo(1,b)):(c.subTo(b,c),c.rShiftTo(1,c));return f>0&&c.lShiftTo(f,c),c}function bnpModInt(a){if(a<=0)return 0;var b=this.DV%a,c=this.s<0?a-1:0;if(this.t>0)if(0==b)c=this[0]%a;else for(var d=this.t-1;d>=0;--d)c=(b*c+this[d])%a;return c}function bnModInverse(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return BigInteger.ZERO;for(var c=a.clone(),d=this.clone(),e=nbv(1),f=nbv(0),g=nbv(0),h=nbv(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(e.isEven()&&f.isEven()||(e.addTo(this,e),f.subTo(a,f)),e.rShiftTo(1,e)):f.isEven()||f.subTo(a,f),f.rShiftTo(1,f);for(;d.isEven();)d.rShiftTo(1,d),b?(g.isEven()&&h.isEven()||(g.addTo(this,g),h.subTo(a,h)),g.rShiftTo(1,g)):h.isEven()||h.subTo(a,h),h.rShiftTo(1,h);c.compareTo(d)>=0?(c.subTo(d,c),b&&e.subTo(g,e),f.subTo(h,f)):(d.subTo(c,d),b&&g.subTo(e,g),h.subTo(f,h))}return 0!=d.compareTo(BigInteger.ONE)?BigInteger.ZERO:h.compareTo(a)>=0?h.subtract(a):h.signum()<0?(h.addTo(a,h),h.signum()<0?h.add(a):h):h}function bnIsProbablePrime(a){var b,c=this.abs();if(1==c.t&&c[0]<=lowprimes[lowprimes.length-1]){for(b=0;b<lowprimes.length;++b)if(c[0]==lowprimes[b])return!0;return!1}if(c.isEven())return!1;for(b=1;b<lowprimes.length;){for(var d=lowprimes[b],e=b+1;e<lowprimes.length&&d<lplim;)d*=lowprimes[e++];for(d=c.modInt(d);b<e;)if(d%lowprimes[b++]==0)return!1}return c.millerRabin(a)}function bnpMillerRabin(a){var b=this.subtract(BigInteger.ONE),c=b.getLowestSetBit();if(c<=0)return!1;var d=b.shiftRight(c);a=a+1>>1,a>lowprimes.length&&(a=lowprimes.length);for(var e=nbi(),f=0;f<a;++f){e.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var g=e.modPow(d,this);if(0!=g.compareTo(BigInteger.ONE)&&0!=g.compareTo(b)){for(var h=1;h++<c&&0!=g.compareTo(b);)if(g=g.modPowInt(2,this),0==g.compareTo(BigInteger.ONE))return!1;if(0!=g.compareTo(b))return!1}}return!0}function parseBigInt(a,b){return new BigInteger(a,b)}function linebrk(a,b){for(var c="",d=0;d+b<a.length;)c+=a.substring(d,d+b)+"\n",d+=b;return c+a.substring(d,a.length)}function byte2Hex(a){return a<16?"0"+a.toString(16):a.toString(16)}function pkcs1pad2(a,b){if(b<a.length+11)return alert("Message too long for RSA"),null;for(var c=new Array,d=a.length-1;d>=0&&b>0;){var e=a.charCodeAt(d--);e<128?c[--b]=e:e>127&&e<2048?(c[--b]=63&e|128,c[--b]=e>>6|192):(c[--b]=63&e|128,c[--b]=e>>6&63|128,c[--b]=e>>12|224)}c[--b]=0;for(var f=new SecureRandom,g=new Array;b>2;){for(g[0]=0;0==g[0];)f.nextBytes(g);c[--b]=g[0]}return c[--b]=2,c[--b]=0,new BigInteger(c)}function oaep_mgf1_arr(a,b,c){for(var d="",e=0;d.length<b;)d+=c(String.fromCharCode.apply(String,a.concat([(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))),e+=1;return d}function oaep_pad(a,b,c){if(a.length+2*SHA1_SIZE+2>b)throw"Message too long for RSA";var e,d="";for(e=0;e<b-a.length-2*SHA1_SIZE-2;e+=1)d+="\0";var f=rstr_sha1("")+d+""+a,g=new Array(SHA1_SIZE);(new SecureRandom).nextBytes(g);var h=oaep_mgf1_arr(g,f.length,c||rstr_sha1),i=[];for(e=0;e<f.length;e+=1)i[e]=f.charCodeAt(e)^h.charCodeAt(e);var j=oaep_mgf1_arr(i,g.length,rstr_sha1),k=[0];for(e=0;e<g.length;e+=1)k[e+1]=g[e]^j.charCodeAt(e);return new BigInteger(k.concat(i))}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function RSASetPublic(a,b){this.isPublic=!0,"string"!=typeof a?(this.n=a,this.e=b):null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16)):alert("Invalid RSA public key")}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(a){var b=pkcs1pad2(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}function RSAEncryptOAEP(a,b){var c=oaep_pad(a,this.n.bitLength()+7>>3,b);if(null==c)return null;var d=this.doPublic(c);if(null==d)return null;var e=d.toString(16);return 0==(1&e.length)?e:"0"+e}function pkcs1unpad2(a,b){for(var c=a.toByteArray(),d=0;d<c.length&&0==c[d];)++d;if(c.length-d!=b-1||2!=c[d])return null;for(++d;0!=c[d];)if(++d>=c.length)return null;for(var e="";++d<c.length;){var f=255&c[d];f<128?e+=String.fromCharCode(f):f>191&&f<224?(e+=String.fromCharCode((31&f)<<6|63&c[d+1]),++d):(e+=String.fromCharCode((15&f)<<12|(63&c[d+1])<<6|63&c[d+2]),d+=2)}return e}function oaep_mgf1_str(a,b,c){for(var d="",e=0;d.length<b;)d+=c(a+String.fromCharCode.apply(String,[(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])),e+=1;return d}function oaep_unpad(a,b,c){a=a.toByteArray();var d;for(d=0;d<a.length;d+=1)a[d]&=255;for(;a.length<b;)a.unshift(0);if(a=String.fromCharCode.apply(String,a),a.length<2*SHA1_SIZE+2)throw"Cipher too short";var d,e=a.substr(1,SHA1_SIZE),f=a.substr(SHA1_SIZE+1),g=oaep_mgf1_str(f,SHA1_SIZE,c||rstr_sha1),h=[];for(d=0;d<e.length;d+=1)h[d]=e.charCodeAt(d)^g.charCodeAt(d);var i=oaep_mgf1_str(String.fromCharCode.apply(String,h),a.length-SHA1_SIZE,rstr_sha1),j=[];for(d=0;d<f.length;d+=1)j[d]=f.charCodeAt(d)^i.charCodeAt(d);if(j=String.fromCharCode.apply(String,j),j.substr(0,SHA1_SIZE)!==rstr_sha1(""))throw"Hash mismatch";j=j.substr(SHA1_SIZE);var k=j.indexOf(""),l=k!=-1?j.substr(0,k).lastIndexOf("\0"):-1;if(l+1!=k)throw"Malformed data";return j.substr(k+1)}function RSASetPrivate(a,b,c){this.isPrivate=!0,"string"!=typeof a?(this.n=a,this.e=b,this.d=c):null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16),this.d=parseBigInt(c,16)):alert("Invalid RSA private key")}function RSASetPrivateEx(a,b,c,d,e,f,g,h){if(this.isPrivate=!0,null==a)throw"RSASetPrivateEx N == null";if(null==b)throw"RSASetPrivateEx E == null";if(0==a.length)throw"RSASetPrivateEx N.length == 0";if(0==b.length)throw"RSASetPrivateEx E.length == 0";null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16),this.d=parseBigInt(c,16),this.p=parseBigInt(d,16),this.q=parseBigInt(e,16),this.dmp1=parseBigInt(f,16),this.dmq1=parseBigInt(g,16),this.coeff=parseBigInt(h,16)):alert("Invalid RSA private key in RSASetPrivateEx")}function RSAGenerate(a,b){var c=new SecureRandom,d=a>>1;this.e=parseInt(b,16);for(var e=new BigInteger(b,16);;){for(;this.p=new BigInteger(a-d,1,c),0!=this.p.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(d,1,c),0!=this.q.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var f=this.p;this.p=this.q,this.q=f}var g=this.p.subtract(BigInteger.ONE),h=this.q.subtract(BigInteger.ONE),i=g.multiply(h);if(0==i.gcd(e).compareTo(BigInteger.ONE)){this.n=this.p.multiply(this.q),this.d=e.modInverse(i),this.dmp1=this.d.mod(g),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}}function RSADoPrivate(a){if(null==this.p||null==this.q)return a.modPow(this.d,this.n);for(var b=a.mod(this.p).modPow(this.dmp1,this.p),c=a.mod(this.q).modPow(this.dmq1,this.q);b.compareTo(c)<0;)b=b.add(this.p);return b.subtract(c).multiply(this.coeff).mod(this.p).multiply(this.q).add(c)}function RSADecrypt(a){var b=parseBigInt(a,16),c=this.doPrivate(b);return null==c?null:pkcs1unpad2(c,this.n.bitLength()+7>>3)}function RSADecryptOAEP(a,b){var c=parseBigInt(a,16),d=this.doPrivate(c);return null==d?null:oaep_unpad(d,this.n.bitLength()+7>>3,b)}function _rsapem_pemToBase64(a){var b=a;return b=b.replace("-----BEGIN RSA PRIVATE KEY-----",""),b=b.replace("-----END RSA PRIVATE KEY-----",""),b=b.replace(/[ \n]+/g,"")}function _rsapem_getPosArrayOfChildrenFromHex(a){var b=new Array,c=ASN1HEX.getStartPosOfV_AtObj(a,0),d=ASN1HEX.getPosOfNextSibling_AtObj(a,c),e=ASN1HEX.getPosOfNextSibling_AtObj(a,d),f=ASN1HEX.getPosOfNextSibling_AtObj(a,e),g=ASN1HEX.getPosOfNextSibling_AtObj(a,f),h=ASN1HEX.getPosOfNextSibling_AtObj(a,g),i=ASN1HEX.getPosOfNextSibling_AtObj(a,h),j=ASN1HEX.getPosOfNextSibling_AtObj(a,i),k=ASN1HEX.getPosOfNextSibling_AtObj(a,j);return b.push(c,d,e,f,g,h,i,j,k),b}function _rsapem_getHexValueArrayOfChildrenFromHex(a){var b=_rsapem_getPosArrayOfChildrenFromHex(a),c=ASN1HEX.getHexOfV_AtObj(a,b[0]),d=ASN1HEX.getHexOfV_AtObj(a,b[1]),e=ASN1HEX.getHexOfV_AtObj(a,b[2]),f=ASN1HEX.getHexOfV_AtObj(a,b[3]),g=ASN1HEX.getHexOfV_AtObj(a,b[4]),h=ASN1HEX.getHexOfV_AtObj(a,b[5]),i=ASN1HEX.getHexOfV_AtObj(a,b[6]),j=ASN1HEX.getHexOfV_AtObj(a,b[7]),k=ASN1HEX.getHexOfV_AtObj(a,b[8]),l=new Array;return l.push(c,d,e,f,g,h,i,j,k),l}function _rsapem_readPrivateKeyFromASN1HexString(a){var b=_rsapem_getHexValueArrayOfChildrenFromHex(a);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])}function _rsapem_readPrivateKeyFromPEMString(a){var b=_rsapem_pemToBase64(a),c=b64tohex(b),d=_rsapem_getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8])}function _rsasign_getHexPaddedDigestInfoForString(a,b,c){var d=function(a){return KJUR.crypto.Util.hashString(a,c)},e=d(a);return KJUR.crypto.Util.getPaddedDigestInfoHex(e,c,b)}function _zeroPaddingOfSignature(a,b){for(var c="",d=b/4-a.length,e=0;e<d;e++)c+="0";return c+a}function _rsasign_signString(a,b){var c=function(a){return KJUR.crypto.Util.hashString(a,b)},d=c(a);return this.signWithMessageHash(d,b)}function _rsasign_signWithMessageHash(a,b){var c=KJUR.crypto.Util.getPaddedDigestInfoHex(a,b,this.n.bitLength()),d=parseBigInt(c,16),e=this.doPrivate(d),f=e.toString(16);return _zeroPaddingOfSignature(f,this.n.bitLength())}function _rsasign_signStringWithSHA1(a){return _rsasign_signString.call(this,a,"sha1")}function _rsasign_signStringWithSHA256(a){return _rsasign_signString.call(this,a,"sha256")}function pss_mgf1_str(a,b,c){for(var d="",e=0;d.length<b;)d+=hextorstr(c(rstrtohex(a+String.fromCharCode.apply(String,[(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])))),e+=1;return d}function _rsasign_signStringPSS(a,b,c){var d=function(a){return KJUR.crypto.Util.hashHex(a,b)},e=d(rstrtohex(a));return void 0===c&&(c=-1),this.signWithMessageHashPSS(e,b,c)}function _rsasign_signWithMessageHashPSS(a,b,c){var h,d=hextorstr(a),e=d.length,f=this.n.bitLength()-1,g=Math.ceil(f/8),i=function(a){return KJUR.crypto.Util.hashHex(a,b)};if(c===-1||void 0===c)c=e;else if(c===-2)c=g-e-2;else if(c<-2)throw"invalid salt length";if(g<e+c+2)throw"data too long";var j="";c>0&&(j=new Array(c),(new SecureRandom).nextBytes(j),j=String.fromCharCode.apply(String,j));var k=hextorstr(i(rstrtohex("\0\0\0\0\0\0\0\0"+d+j))),l=[];for(h=0;h<g-c-e-2;h+=1)l[h]=0;var m=String.fromCharCode.apply(String,l)+""+j,n=pss_mgf1_str(k,m.length,i),o=[];for(h=0;h<m.length;h+=1)o[h]=m.charCodeAt(h)^n.charCodeAt(h);var p=65280>>8*g-f&255;for(o[0]&=~p,h=0;h<e;h++)o.push(k.charCodeAt(h));return o.push(188),_zeroPaddingOfSignature(this.doPrivate(new BigInteger(o)).toString(16),this.n.bitLength())}function _rsasign_getDecryptSignatureBI(a,b,c){var d=new RSAKey;d.setPublic(b,c);var e=d.doPublic(a);return e}function _rsasign_getHexDigestInfoFromSig(a,b,c){var d=_rsasign_getDecryptSignatureBI(a,b,c),e=d.toString(16).replace(/^1f+00/,"");return e}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(a){for(var b in KJUR.crypto.Util.DIGESTINFOHEAD){var c=KJUR.crypto.Util.DIGESTINFOHEAD[b],d=c.length;if(a.substring(0,d)==c){var e=[b,a.substring(d)];return e}}return[]}function _rsasign_verifySignatureWithArgs(a,b,c,d){var e=_rsasign_getHexDigestInfoFromSig(b,c,d),f=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(0==f.length)return!1;var g=f[0],h=f[1],i=function(a){return KJUR.crypto.Util.hashString(a,g)},j=i(a);return h==j}function _rsasign_verifyHexSignatureForMessage(a,b){var c=parseBigInt(a,16),d=_rsasign_verifySignatureWithArgs(b,c,this.n.toString(16),this.e.toString(16));return d}function _rsasign_verifyString(a,b){b=b.replace(_RE_HEXDECONLY,""),b=b.replace(/[ \n]+/g,"");var c=parseBigInt(b,16);if(c.bitLength()>this.n.bitLength())return 0;var d=this.doPublic(c),e=d.toString(16).replace(/^1f+00/,""),f=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(0==f.length)return!1;var g=f[0],h=f[1],i=function(a){return KJUR.crypto.Util.hashString(a,g)},j=i(a);return h==j}function _rsasign_verifyWithMessageHash(a,b){b=b.replace(_RE_HEXDECONLY,""),b=b.replace(/[ \n]+/g,"");var c=parseBigInt(b,16);if(c.bitLength()>this.n.bitLength())return 0;var d=this.doPublic(c),e=d.toString(16).replace(/^1f+00/,""),f=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(0==f.length)return!1;var h=(f[0],f[1]);return h==a}function _rsasign_verifyStringPSS(a,b,c,d){var e=function(a){return KJUR.crypto.Util.hashHex(a,c)},f=e(rstrtohex(a));return void 0===d&&(d=-1),this.verifyWithMessageHashPSS(f,b,c,d)}function _rsasign_verifyWithMessageHashPSS(a,b,c,d){var e=new BigInteger(b,16);if(e.bitLength()>this.n.bitLength())return!1;var k,f=function(a){return KJUR.crypto.Util.hashHex(a,c)},g=hextorstr(a),h=g.length,i=this.n.bitLength()-1,j=Math.ceil(i/8);if(d===-1||void 0===d)d=h;else if(d===-2)d=j-h-2;else if(d<-2)throw"invalid salt length";if(j<h+d+2)throw"data too long";var l=this.doPublic(e).toByteArray();for(k=0;k<l.length;k+=1)l[k]&=255;for(;l.length<j;)l.unshift(0);if(188!==l[j-1])throw"encoded message does not end in 0xbc";l=String.fromCharCode.apply(String,l);var m=l.substr(0,j-h-1),n=l.substr(m.length,h),o=65280>>8*j-i&255;if(0!==(m.charCodeAt(0)&o))throw"bits beyond keysize not zero";var p=pss_mgf1_str(n,m.length,f),q=[];for(k=0;k<m.length;k+=1)q[k]=m.charCodeAt(k)^p.charCodeAt(k);q[0]&=~o;var r=j-h-d-2;for(k=0;k<r;k+=1)if(0!==q[k])throw"leftmost octets not zero";if(1!==q[r])throw"0x01 marker not found";return n===hextorstr(f(rstrtohex("\0\0\0\0\0\0\0\0"+g+String.fromCharCode.apply(String,q.slice(-d)))))}function X509(){this.subjectPublicKeyRSA=null,this.subjectPublicKeyRSA_hN=null,this.subjectPublicKeyRSA_hE=null,this.hex=null,this.getSerialNumberHex=function(){return ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,1])},this.getSignatureAlgorithmField=function(){var a=ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,2,0]),b=KJUR.asn1.ASN1Util.oidHexToInt(a),c=KJUR.asn1.x509.OID.oid2name(b);return c},this.getIssuerHex=function(){return ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,3])},this.getIssuerString=function(){return X509.hex2dn(ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,3]))},this.getSubjectHex=function(){return ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,5])},this.getSubjectString=function(){return X509.hex2dn(ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,5]))},this.getNotBefore=function(){var a=ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,4,0]);return a=a.replace(/(..)/g,"%$1"),a=decodeURIComponent(a)},this.getNotAfter=function(){var a=ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,4,1]);return a=a.replace(/(..)/g,"%$1"),a=decodeURIComponent(a)},this.readCertPEM=function(a){var b=X509.pemToHex(a),c=X509.getPublicKeyHexArrayFromCertHex(b),d=new RSAKey;d.setPublic(c[0],c[1]),this.subjectPublicKeyRSA=d,this.subjectPublicKeyRSA_hN=c[0],this.subjectPublicKeyRSA_hE=c[1],this.hex=b},this.readCertPEMWithoutRSAInit=function(a){var b=X509.pemToHex(a),c=X509.getPublicKeyHexArrayFromCertHex(b);"function"==typeof this.subjectPublicKeyRSA.setPublic&&this.subjectPublicKeyRSA.setPublic(c[0],c[1]),this.subjectPublicKeyRSA_hN=c[0],this.subjectPublicKeyRSA_hE=c[1],this.hex=b},this.getInfo=function(){var a="Basic Fields\n";a+=" serial number: "+this.getSerialNumberHex()+"\n",a+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",a+=" issuer: "+this.getIssuerString()+"\n",a+=" notBefore: "+this.getNotBefore()+"\n",a+=" notAfter: "+this.getNotAfter()+"\n",a+=" subject: "+this.getSubjectString()+"\n",a+=" subject public key info: \n";var b=X509.getSubjectPublicKeyInfoPosFromCertHex(this.hex),c=ASN1HEX.getHexOfTLV_AtObj(this.hex,b),d=KEYUTIL.getKey(c,null,"pkcs8pub");d instanceof RSAKey&&(a+=" key algorithm: RSA\n",a+=" n="+d.n.toString(16).substr(0,16)+"...\n",a+=" e="+d.e.toString(16)+"\n"),a+="X509v3 Extensions:\n";for(var e=X509.getV3ExtInfoListOfCertHex(this.hex),f=0;f<e.length;f++){var g=e[f],h=KJUR.asn1.x509.OID.oid2name(g.oid);""===h&&(h=g.oid);var i="";if(g.critical===!0&&(i="CRITICAL"),a+=" "+h+" "+i+":\n","basicConstraints"===h){var j=X509.getExtBasicConstraints(this.hex);void 0===j.cA?a+=" {}\n":(a+=" cA=true",void 0!==j.pathLen&&(a+=", pathLen="+j.pathLen),a+="\n")}else if("keyUsage"===h)a+=" "+X509.getExtKeyUsageString(this.hex)+"\n";else if("subjectKeyIdentifier"===h)a+=" "+X509.getExtSubjectKeyIdentifier(this.hex)+"\n";else if("authorityKeyIdentifier"===h){var k=X509.getExtAuthorityKeyIdentifier(this.hex);
void 0!==k.kid&&(a+=" kid="+k.kid+"\n")}else if("extKeyUsage"===h){var l=X509.getExtExtKeyUsageName(this.hex);a+=" "+l.join(", ")+"\n"}else if("subjectAltName"===h){var m=X509.getExtSubjectAltName(this.hex);a+=" "+m.join(", ")+"\n"}else if("cRLDistributionPoints"===h){var n=X509.getExtCRLDistributionPointsURI(this.hex);a+=" "+n+"\n"}else if("authorityInfoAccess"===h){var o=X509.getExtAIAInfo(this.hex);void 0!==o.ocsp&&(a+=" ocsp: "+o.ocsp.join(",")+"\n"),void 0!==o.caissuer&&(a+=" caissuer: "+o.caissuer.join(",")+"\n")}}return a+="signature algorithm: "+X509.getSignatureAlgorithmName(this.hex)+"\n",a+="signature: "+X509.getSignatureValueHex(this.hex).substr(0,16)+"...\n"}}function Base64x(){}function stoBA(a){for(var b=new Array,c=0;c<a.length;c++)b[c]=a.charCodeAt(c);return b}function BAtos(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(a[c]);return b}function BAtohex(a){for(var b="",c=0;c<a.length;c++){var d=a[c].toString(16);1==d.length&&(d="0"+d),b+=d}return b}function stohex(a){return BAtohex(stoBA(a))}function stob64(a){return hex2b64(stohex(a))}function stob64u(a){return b64tob64u(hex2b64(stohex(a)))}function b64utos(a){return BAtos(b64toBA(b64utob64(a)))}function b64tob64u(a){return a=a.replace(/\=/g,""),a=a.replace(/\+/g,"-"),a=a.replace(/\//g,"_")}function b64utob64(a){return a.length%4==2?a+="==":a.length%4==3&&(a+="="),a=a.replace(/-/g,"+"),a=a.replace(/_/g,"/")}function hextob64u(a){return a.length%2==1&&(a="0"+a),b64tob64u(hex2b64(a))}function b64utohex(a){return b64tohex(b64utob64(a))}function utf8tob64(a){return hex2b64(uricmptohex(encodeURIComponentAll(a)))}function b64toutf8(a){return decodeURIComponent(hextouricmp(b64tohex(a)))}function utf8tohex(a){return uricmptohex(encodeURIComponentAll(a))}function hextoutf8(a){return decodeURIComponent(hextouricmp(a))}function hextorstr(a){for(var b="",c=0;c<a.length-1;c+=2)b+=String.fromCharCode(parseInt(a.substr(c,2),16));return b}function rstrtohex(a){for(var b="",c=0;c<a.length;c++)b+=("0"+a.charCodeAt(c).toString(16)).slice(-2);return b}function hextob64(a){return hex2b64(a)}function hextob64nl(a){var b=hextob64(a),c=b.replace(/(.{64})/g,"$1\r\n");return c=c.replace(/\r\n$/,"")}function b64nltohex(a){var b=a.replace(/[^0-9A-Za-z\/+=]*/g,""),c=b64tohex(b);return c}function hextoArrayBuffer(a){if(a.length%2!=0)throw"input is not even length";if(null==a.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var b=new ArrayBuffer(a.length/2),c=new DataView(b),d=0;d<a.length/2;d++)c.setUint8(d,parseInt(a.substr(2*d,2),16));return b}function ArrayBuffertohex(a){for(var b="",c=new DataView(a),d=0;d<a.byteLength;d++)b+=("00"+c.getUint8(d).toString(16)).slice(-2);return b}function uricmptohex(a){return a.replace(/%/g,"")}function hextouricmp(a){return a.replace(/(..)/g,"%$1")}function encodeURIComponentAll(a){for(var b=encodeURIComponent(a),c="",d=0;d<b.length;d++)"%"==b[d]?(c+=b.substr(d,3),d+=2):c=c+"%"+stohex(b[d]);return c}function newline_toUnix(a){return a=a.replace(/\r\n/gm,"\n")}function newline_toDos(a){return a=a.replace(/\r\n/gm,"\n"),a=a.replace(/\n/gm,"\r\n")}function intarystrtohex(a){a=a.replace(/^\s*\[\s*/,""),a=a.replace(/\s*\]\s*$/,""),a=a.replace(/\s*/g,"");try{var b=a.split(/,/).map(function(a,b,c){var d=parseInt(a);if(d<0||255<d)throw"integer not in range 0-255";var e=("00"+d.toString(16)).slice(-2);return e}).join("");return b}catch(a){throw"malformed integer array string: "+a}}function Arcfour(){this.i=0,this.j=0,this.S=new Array}function ARC4init(a){var b,c,d;for(b=0;b<256;++b)this.S[b]=b;for(c=0,b=0;b<256;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function ARC4next(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function prng_newstate(){return new Arcfour}function rng_seed_int(a){rng_pool[rng_pptr++]^=255&a,rng_pool[rng_pptr++]^=a>>8&255,rng_pool[rng_pptr++]^=a>>16&255,rng_pool[rng_pptr++]^=a>>24&255,rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}function rng_seed_time(){rng_seed_int((new Date).getTime())}function rng_get_byte(){if(null==rng_state){for(rng_seed_time(),rng_state=prng_newstate(),rng_state.init(rng_pool),rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr)rng_pool[rng_pptr]=0;rng_pptr=0}return rng_state.next()}function rng_get_bytes(a){var b;for(b=0;b<a.length;++b)a[b]=rng_get_byte()}function SecureRandom(){}var OIDC=namespace("OIDC");OIDC.supportedProviderOptions=["issuer","authorization_endpoint","jwks_uri","claims_parameter_supported","request_parameter_supported","jwks"],OIDC.supportedRequestOptions=["scope","response_type","display","max_age","claims","request"],OIDC.supportedClientOptions=["client_id","redirect_uri"],OIDC.setProviderInfo=function(a){var b=this.supportedProviderOptions;try{if("undefined"!==a)for(var c=0;c<b.length;c++)"undefined"!==a[b[c]]&&(this[b[c]]=a[b[c]]);return!0}catch(a){throw new OidcException("Unable to set the Identity Provider's configuration parameters: "+a.toString())}},OIDC.setClientInfo=function(a){var b=this.supportedClientOptions;try{if("undefined"!=typeof a){"undefined"==typeof a.client_id&&(clientInfoFromServer=OIDC.registerClient(a.redirect_uri),a.client_id=clientInfoFromServer.client_id);for(var c=0;c<b.length;c++)"undefined"!=typeof a[b[c]]&&(this[b[c]]=a[b[c]])}return!0}catch(a){throw new OidcException("Unable to set the Client's configuration parameters: "+a.toString())}},OIDC.debug=function(a,b){if(1==a){var c=sessionStorage.providerInfo,d=sessionStorage.clientInfo,e=this.verifyIdTokenSig(b),f=this.isValidIdToken(b);console.log({provider:c,client:d}),f||console.log("Id_token is not valid!"),e||console.log("The signature of the id_token is not verified!"),e&&f&&console.log("Id_token is valid and its signature is verified!")}},OIDC.storeInfo=function(a,b){var c=this.supportedProviderOptions,d=this.supportedClientOptions,e={},f={};try{if(a){for(var g=0;g<c.length;g++)"undefined"!=typeof a[c[g]]&&(e[c[g]]=a[c[g]]);sessionStorage.providerInfo=JSON.stringify(e)}else sessionStorage.providerInfo&&sessionStorage.removeItem("providerInfo");if(b){for(g=0;g<d.length;g++)"undefined"!=typeof b[d[g]]&&(f[d[g]]=b[d[g]]);sessionStorage.clientInfo=JSON.stringify(f)}else sessionStorage.clientInfo&&sessionStorage.removeItem("clientInfo")}catch(a){throw new OidcException("Unable to store the Identity Provider and Client configuration options: "+a.toString())}},OIDC.restoreInfo=function(){var a=sessionStorage.providerInfo,b=sessionStorage.clientInfo;try{a&&this.setProviderInfo(JSON.parse(a)),b&&this.setClientInfo(JSON.parse(b))}catch(a){throw new OidcException("Unable to restore the Identity Provider and Client configuration options: "+a.toString())}},OIDC.checkRequiredInfo=function(a){try{if(a)for(var b=0;b<a.length;b++)if(!this[a[b]])throw new OidcException("Required parameter not set - "+a[b]);return!0}catch(a){throw new OidcException("Unable to check whether the required configuration parameters are set: "+a.toString())}},OIDC.clearProviderInfo=function(){try{for(var a=0;a<this.supportedProviderOptions.length;a++)this[this.supportedProviderOptions[a]]=null}catch(a){throw new OidcException("Unable to clear the Identity Provider configuration parameters: "+a.toString())}},OIDC.generateLoginRequest=function(a){try{this.checkRequiredInfo(new Array("client_id","redirect_uri","authorization_endpoint"));var b=null,c=null,d=window.crypto||window.msCrypto;if(d&&d.getRandomValues){var e=new Uint32Array(2);d.getRandomValues(e),b=e[0].toString(36),c=e[1].toString(36)}else{var f=function(a){for(var b=0,c=a.length-1;c>=0;c--)b=256*b+a[c];return b};rng_seed_time();var g=new SecureRandom,h=new Array(4);g.nextBytes(h),b=f(h).toString(36),rng_seed_time();var i=new Array(4);g.nextBytes(i),c=f(i).toString(36)}sessionStorage.state=b,sessionStorage.nonce=c;var j="id_token",k="openid",l=null,m=null,n=null,o={},p={};if(a){if(a.response_type){var q=a.response_type.split(" "),r=[];if(q)for(var s=0;s<q.length;s++)"code"!=q[s]&&"token"!=q[s]&&"id_token"!=q[s]||r.push(q[s]);r&&(j=r.join(" "))}if(a.scope&&(k=a.scope),a.display&&(l=a.display),a.max_age&&(m=a.max_age),a.claims){if(!this.claims_parameter_supported)throw new OidcException("Provider does not support claims request parameter");if(a.claims.id_token){for(var t=0;t<a.claims.id_token.length;t++)o[a.claims.id_token[t]]=null;n||(n={}),n.id_token=o}if(a.claims.userinfo){for(var u=0;u<a.claims.userinfo.length;u++)p[a.claims.userinfo[u]]=null;n||(n={}),n.userinfo=p}}}var v="";l&&(v+="&display="+l),m&&(v+="&max_age="+m),n&&(v+="&claims="+JSON.stringify(n));var w=this.authorization_endpoint+"?response_type="+j+"&scope="+k+"&nonce="+c+"&client_id="+this.client_id+"&redirect_uri="+this.redirect_uri+"&state="+b+v,x={authorization_endpoint:this.authorization_endpoint,response_type:j,scope:k,nonce:c,client_id:this.client_id,redirect_uri:this.redirect_uri,state:b,optional_parameters:v,url:w};return x}catch(a){throw new OidcException("Unable to generate login request: "+a.toString())}},OIDC.login=function(a){try{this.checkRequiredInfo(new Array("client_id","redirect_uri","authorization_endpoint"));var b=null,c=null,d=window.crypto||window.msCrypto;if(d&&d.getRandomValues){var e=new Uint32Array(2);d.getRandomValues(e),b=e[0].toString(36),c=e[1].toString(36)}else{var f=function(a){for(var b=0,c=a.length-1;c>=0;c--)b=256*b+a[c];return b};rng_seed_time();var g=new SecureRandom,h=new Array(4);g.nextBytes(h),b=f(h).toString(36),rng_seed_time();var i=new Array(4);g.nextBytes(i),c=f(i).toString(36)}sessionStorage.state=b,sessionStorage.nonce=c;var j="id_token",k="openid",l=null,m=null,n=null,o={},p={};if(a){if(a.response_type){var q=a.response_type.split(" "),r=[];if(q)for(var s=0;s<q.length;s++)"code"!=q[s]&&"token"!=q[s]&&"id_token"!=q[s]||r.push(q[s]);r&&(j=r.join(" "))}if(a.scope&&(k=a.scope),a.display&&(l=a.display),a.max_age&&(m=a.max_age),a.claims){if(!this.claims_parameter_supported)throw new OidcException("Provider does not support claims request parameter");if(a.claims.id_token){for(var t=0;t<a.claims.id_token.length;t++)o[a.claims.id_token[t]]=null;n||(n={}),n.id_token=o}if(a.claims.userinfo){for(var u=0;u<a.claims.userinfo.length;u++)p[a.claims.userinfo[u]]=null;n||(n={}),n.userinfo=p}}}var v="";l&&(v+="&display="+l),m&&(v+="&max_age="+m),n&&(v+="&claims="+JSON.stringify(n));var w=this.authorization_endpoint+"?response_type="+j+"&scope="+k+"&nonce="+c+"&client_id="+this.client_id+"&redirect_uri="+this.redirect_uri+"&state="+b+v;window.location.replace(w)}catch(a){throw new OidcException("Unable to redirect to the Identity Provider for authenticaton: "+a.toString())}},OIDC.verifyIdTokenSig=function(a){try{var b=!1,c=this.jwks_uri||this.jwks;if(!c)throw new OidcException("jwks_uri or jwks parameter not set");if(a){var d=this.getIdTokenParts(a),e=this.getJsonObject(d[0]),f=this.jwks||this.fetchJSON(this.jwks_uri);if(!f)throw new OidcException("No JWK keyset");if(!e.alg||"RS"!=e.alg.substr(0,2))throw new OidcException("Unsupported JWS signature algorithm "+e.alg);var g=this.jwk_get_key(f,"RSA","sig",e.kid);g?b=this.rsaVerifyJWS(a,g[0]):new OidcException("No matching JWK found")}return b}catch(a){throw new OidcException("Unable to verify the ID Token signature: "+a.toString())}},OIDC.isValidIdToken=function(a){try{var c=!1;if(this.checkRequiredInfo(["issuer","client_id"]),a){var d=this.getIdTokenParts(a),e=this.getJsonObject(d[1]);if(!e)throw new OidcException("Unable to parse JWS payload");var f=new Date/1e3;if(e.iat>f+300)throw new OidcException("ID Token issued time is later than current time");if(e.exp<f-300)throw new OidcException("ID Token expired");var g=null;if(e.aud&&(g=e.aud instanceof Array?e.aud[0]:e.aud),g!=this.client_id)throw new OidcException("invalid audience");if(e.iss!=this.issuer)throw new OidcException("invalid issuer "+e.iss+" != "+this.issuer);if(e.nonce!=sessionStorage.nonce)throw new OidcException("invalid nonce");c=!0}return c}catch(a){throw new OidcException("Unable to validate information in the ID Token: "+a.toString())}},OIDC.rsaVerifyJWS=function(a,b){try{if(a&&"object"==typeof b){if("RSA"!=b.kty)throw new OidcException("No RSA kty in JWK");var c=KJUR.jws.JWS;if(b.n&&b.e){var d=KEYUTIL.getKey({kty:"RSA",n:b.n,e:b.e});return c.verify(a,d,["RS256"])}if(b.x5c)return c.verifyJWSByPemX509Cert(a,"-----BEGIN CERTIFICATE-----\n"+b.x5c[0]+"\n-----END CERTIFICATE-----\n")}}catch(a){throw new OidcException("Unable to verify the JWS string: "+a.toString())}},OIDC.getValidIdToken=function(){try{var a=window.location.href,b=a.match("[?&]error=([^&]*)");if(b){var c=a.match("[?&]error_description=([^&]*)");throw new OidcException(b[1]+" Description: "+c[1])}var d=a.match("[?&]state=([^&]*)");if(d)var e=d[1],f=sessionStorage.state,g=e!=f;var h=a.match("[?&]id_token=([^&]*)");if(g)throw new OidcException("State mismatch");if(!h)throw new OidcException("No ID Token returned");var i=h[1];if(!i)throw new OidcException("Could not retrieve ID Token from the URL");var j=this.verifyIdTokenSig(i),k=this.isValidIdToken(i);if(j&&k)return i}catch(a){throw new OidcException("Unable to get the ID Token from the current page URL: "+a.toString())}},OIDC.getAccessToken=function(){try{var a=window.location.href,b=a.match("[?#]access_token=([^&]*)");return b?b[1]:(console.error(new Error("No access_token found on current page URL!")),null)}catch(a){throw new OidcException("Unable to get the Access Token from the current page URL: "+a.toString())}},OIDC.getCode=function(){try{var a=window.location.href,b=a.match("[?&]code=([^(&)]*)");if(b)return b[1]}catch(a){throw new OidcException("Unable to get the Authorization Code from the current page URL: "+a.toString())}},OIDC.getIdTokenParts=function(a){try{var b=new KJUR.jws.JWS;return b.parseJWS(a),new Array(b.parsedJWS.headS,b.parsedJWS.payloadS,b.parsedJWS.si)}catch(a){throw new OidcException("Unable to split the ID Token string: "+a.toString())}},OIDC.getIdTokenPayload=function(a){try{var b=this.getIdTokenParts(a);if(b)return this.getJsonObject(b[1])}catch(a){throw new OidcException("Unable to get the contents of the ID Token payload: "+a.toString())}},OIDC.getJsonObject=function(a){try{var b=KJUR.jws.JWS;if(b.isSafeJSONString(a))return b.readSafeJSONString(a)}catch(a){throw new OidcException("Unable to get the JSON object from JSON string: "+a.toString())}},OIDC.fetchJSON=function(a){try{var b=new XMLHttpRequest;if(b.open("GET",a,!1),b.send(null),200===b.status)return b.responseText;throw new OidcException("fetchJSON - "+b.status+" "+b.statusText)}catch(b){throw new OidcException("Unable to retrieve JSON file at "+a+" : "+b.toString())}return null},OIDC.jwk_get_key=function(a,b,c,d){try{var e=null,f=[];if(a&&("string"==typeof a?e=this.getJsonObject(a):"object"==typeof a&&(e=a),null!=e&&"object"==typeof e.keys)){if(0==e.keys.length)return null;for(var g=0;g<e.keys.length;g++)e.keys[g].kty==b&&f.push(e.keys[g]);if(0==f.length)return null;if(c){for(var h=[],i=0;i<f.length;i++)f[i].use?f[i].use==c&&h.push(f[i]):h.push(f[i]);f=h}if(0==f.length)return null;if(d){h=[];for(var j=0;j<f.length;j++)f[j].kid==d&&h.push(f[j]);f=h}return 0==f.length?null:f}}catch(a){throw new OidcException("Unable to retrieve the JWK key: "+a.toString())}},OIDC.discover=function(a){try{var b=null;if(a){var c=a+"/.well-known/openid-configuration",d=this.fetchJSON(c);d&&(b=this.getJsonObject(d))}return b}catch(a){throw new OidcException("Unable to perform discovery: "+a.toString())}},OIDC.getUserInfo=function(a){try{var b=JSON.parse(sessionStorage.providerInfo).issuer,c=OIDC.discover(b),d=new XMLHttpRequest;if(d.open("POST",c.userinfo_endpoint,!1),d.setRequestHeader("authorization","Bearer "+a),d.send(null),200===d.status)return d.responseText;throw new OidcException("getUserInfo - "+d.status+" "+d.statusText)}catch(a){throw new OidcException("Unable to get user info:"+a.toString())}},OIDC.registerClient=function(a){try{var b={redirect_uris:[a],application_type:"Web",client_name:"Dynamically Registered Client",subject_type:"public",grant_types:["implicit"],response_types:["token","id_token"],scopes:["email","openid","profile"]},c=new XMLHttpRequest;if(c.open("POST",providerInfo.registration_endpoint,!1),c.setRequestHeader("Content-Type","application/json"),c.setRequestHeader("Accept","application/json"),c.send(JSON.stringify(b)),200===c.status)return JSON.parse(c.responseText);throw new OidcException("getUserInfo - "+c.status+" "+c.statusText)}catch(a){throw new OidcException("Unable to register new client:"+a.toString())}},OidcException.prototype=new Error,OidcException.prototype.constructor=OidcException;var CryptoJS=CryptoJS||function(a,b){var c=Object.create||function(){function a(){}return function(b){var c;return a.prototype=b,c=new a,a.prototype=null,c}}(),d={},e=d.lib={},f=e.Base=function(){return{extend:function(a){var b=c(this);return a&&b.mixIn(a),b.hasOwnProperty("init")&&this.init!==b.init||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=e.WordArray=f.extend({init:function(a,c){a=this.words=a||[],c!=b?this.sigBytes=c:this.sigBytes=4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,e=a.sigBytes;if(this.clamp(),d%4)for(var f=0;f<e;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else for(var f=0;f<e;f+=4)b[d+f>>>2]=c[f>>>2];return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c,d=[],e=function(b){var b=b,c=987654321,d=4294967295;return function(){c=36969*(65535&c)+(c>>16)&d,b=18e3*(65535&b)+(b>>16)&d;var e=(c<<16)+b&d;return e/=4294967296,e+=.5,e*(a.random()>.5?1:-1)}},f=0;f<b;f+=4){var h=e(4294967296*(c||a.random()));c=987654071*h(),d.push(4294967296*h()|0)}return new g.init(d,b)}}),h=d.enc={},i=h.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;e<c;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;e<c;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw new Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=e.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=4*f,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*f,k=a.min(4*j,e);if(j){for(var l=0;l<j;l+=f)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new g.init(m,k)},clone:function(){var a=f.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0}),m=(e.Hasher=l.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}}),d.algo={});return d}(Math);!function(){var a=CryptoJS,b=a.lib,c=b.WordArray,d=b.Hasher,e=[],b=a.algo.SHA1=d.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],f=c[1],g=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)e[j]=0|a[b+j];else{var k=e[j-3]^e[j-8]^e[j-14]^e[j-16];e[j]=k<<1|k>>>31}k=(d<<5|d>>>27)+i+e[j],k=20>j?k+((f&g|~f&h)+1518500249):40>j?k+((f^g^h)+1859775393):60>j?k+((f&g|f&h|g&h)-1894007588):k+((f^g^h)-899497514),i=h,h=g,g=f<<30|f>>>2,f=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(b),a.HmacSHA1=d._createHmacHelper(b)}(),function(a){for(var b=CryptoJS,c=b.lib,d=c.WordArray,e=c.Hasher,c=b.algo,f=[],g=[],h=function(a){return 4294967296*(a-(0|a))|0},i=2,j=0;64>j;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[],c=c.SHA256=e.extend({_doReset:function(){this._hash=new d.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(c),b.HmacSHA256=e._createHmacHelper(c)}(Math),function(a){var b=CryptoJS,c=b.lib,d=c.Base,e=c.WordArray,b=b.x64={};b.Word=d.extend({init:function(a,b){this.high=a,this.low=b}}),b.WordArray=d.extend({init:function(b,c){b=this.words=b||[],this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],d=0;d<b;d++){var f=a[d];c.push(f.high),c.push(f.low)}return e.create(c,this.sigBytes)},clone:function(){for(var a=d.clone.call(this),b=a.words=this.words.slice(0),c=b.length,e=0;e<c;e++)b[e]=b[e].clone();return a}})}(),function(){function a(){return e.create.apply(e,arguments)}for(var b=CryptoJS,c=b.lib.Hasher,d=b.x64,e=d.Word,f=d.WordArray,d=b.algo,g=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],h=[],i=0;80>i;i++)h[i]=a();d=d.SHA512=c.extend({_doReset:function(){this._hash=new f.init([new e.init(1779033703,4089235720),new e.init(3144134277,2227873595),new e.init(1013904242,4271175723),new e.init(2773480762,1595750129),new e.init(1359893119,2917565137),new e.init(2600822924,725511199),new e.init(528734635,4215389547),new e.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],i=c[3],j=c[4],k=c[5],l=c[6],c=c[7],m=d.high,n=d.low,o=e.high,p=e.low,q=f.high,r=f.low,s=i.high,t=i.low,u=j.high,v=j.low,w=k.high,x=k.low,y=l.high,z=l.low,A=c.high,B=c.low,C=m,D=n,E=o,F=p,G=q,H=r,I=s,J=t,K=u,L=v,M=w,N=x,O=y,P=z,Q=A,R=B,S=0;80>S;S++){var T=h[S];if(16>S)var U=T.high=0|a[b+2*S],V=T.low=0|a[b+2*S+1];else{var U=h[S-15],V=U.high,W=U.low,U=(V>>>1|W<<31)^(V>>>8|W<<24)^V>>>7,W=(W>>>1|V<<31)^(W>>>8|V<<24)^(W>>>7|V<<25),X=h[S-2],V=X.high,Y=X.low,X=(V>>>19|Y<<13)^(V<<3|Y>>>29)^V>>>6,Y=(Y>>>19|V<<13)^(Y<<3|V>>>29)^(Y>>>6|V<<26),V=h[S-7],Z=V.high,$=h[S-16],_=$.high,$=$.low,V=W+V.low,U=U+Z+(V>>>0<W>>>0?1:0),V=V+Y,U=U+X+(V>>>0<Y>>>0?1:0),V=V+$,U=U+_+(V>>>0<$>>>0?1:0);T.high=U,T.low=V}var Z=K&M^~K&O,$=L&N^~L&P,T=C&E^C&G^E&G,aa=D&F^D&H^F&H,W=(C>>>28|D<<4)^(C<<30|D>>>2)^(C<<25|D>>>7),X=(D>>>28|C<<4)^(D<<30|C>>>2)^(D<<25|C>>>7),Y=g[S],ba=Y.high,ca=Y.low,Y=R+((L>>>14|K<<18)^(L>>>18|K<<14)^(L<<23|K>>>9)),_=Q+((K>>>14|L<<18)^(K>>>18|L<<14)^(K<<23|L>>>9))+(Y>>>0<R>>>0?1:0),Y=Y+$,_=_+Z+(Y>>>0<$>>>0?1:0),Y=Y+ca,_=_+ba+(Y>>>0<ca>>>0?1:0),Y=Y+V,_=_+U+(Y>>>0<V>>>0?1:0),V=X+aa,T=W+T+(V>>>0<X>>>0?1:0),Q=O,R=P,O=M,P=N,M=K,N=L,L=J+Y|0,K=I+_+(L>>>0<J>>>0?1:0)|0,I=G,J=H,G=E,H=F,E=C,F=D,D=Y+V|0,C=_+T+(D>>>0<Y>>>0?1:0)|0}n=d.low=n+D,d.high=m+C+(n>>>0<D>>>0?1:0),p=e.low=p+F,e.high=o+E+(p>>>0<F>>>0?1:0),r=f.low=r+H,f.high=q+G+(r>>>0<H>>>0?1:0),t=i.low=t+J,i.high=s+I+(t>>>0<J>>>0?1:0),v=j.low=v+L,j.high=u+K+(v>>>0<L>>>0?1:0),x=k.low=x+N,k.high=w+M+(x>>>0<N>>>0?1:0),z=l.low=z+P,l.high=y+O+(z>>>0<P>>>0?1:0),B=c.low=B+R,c.high=A+Q+(B>>>0<R>>>0?1:0)},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+128>>>10<<5)+30]=Math.floor(c/4294967296),b[(d+128>>>10<<5)+31]=c,a.sigBytes=4*b.length,this._process(),this._hash.toX32()},clone:function(){var a=c.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:32}),b.SHA512=c._createHelper(d),b.HmacSHA512=c._createHmacHelper(d)}(),function(){var a=CryptoJS,b=a.x64,c=b.Word,d=b.WordArray,b=a.algo,e=b.SHA512,b=b.SHA384=e.extend({_doReset:function(){this._hash=new d.init([new c.init(3418070365,3238371032),new c.init(1654270250,914150663),new c.init(2438529370,812702999),new c.init(355462360,4144912697),new c.init(1731405415,4290775857),new c.init(2394180231,1750603025),new c.init(3675008525,1694076839),new c.init(1203062813,3204075428)])},_doFinalize:function(){var a=e._doFinalize.call(this);return a.sigBytes-=16,a}});a.SHA384=e._createHelper(b),a.HmacSHA384=e._createHmacHelper(b)}();var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64pad="=",dbits,canary=0xdeadbeefcafe,j_lm=15715070==(16777215&canary);j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;var BI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP),BigInteger.prototype.F1=BI_FP-dbits,BigInteger.prototype.F2=2*dbits-BI_FP;var BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=new Array,rr,vv;for(rr="0".charCodeAt(0),vv=0;vv<=9;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,
BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare;var SHA1_SIZE=20;RSAKey.prototype.doPublic=RSADoPublic,RSAKey.prototype.setPublic=RSASetPublic,RSAKey.prototype.encrypt=RSAEncrypt,RSAKey.prototype.encryptOAEP=RSAEncryptOAEP,RSAKey.prototype.type="RSA";var SHA1_SIZE=20;RSAKey.prototype.doPrivate=RSADoPrivate,RSAKey.prototype.setPrivate=RSASetPrivate,RSAKey.prototype.setPrivateEx=RSASetPrivateEx,RSAKey.prototype.generate=RSAGenerate,RSAKey.prototype.decrypt=RSADecrypt,RSAKey.prototype.decryptOAEP=RSADecryptOAEP,RSAKey.prototype.readPrivateKeyFromPEMString=_rsapem_readPrivateKeyFromPEMString,RSAKey.prototype.readPrivateKeyFromASN1HexString=_rsapem_readPrivateKeyFromASN1HexString;var _RE_HEXDECONLY=new RegExp("");_RE_HEXDECONLY.compile("[^0-9a-f]","gi"),RSAKey.prototype.signWithMessageHash=_rsasign_signWithMessageHash,RSAKey.prototype.signString=_rsasign_signString,RSAKey.prototype.signStringWithSHA1=_rsasign_signStringWithSHA1,RSAKey.prototype.signStringWithSHA256=_rsasign_signStringWithSHA256,RSAKey.prototype.sign=_rsasign_signString,RSAKey.prototype.signWithSHA1=_rsasign_signStringWithSHA1,RSAKey.prototype.signWithSHA256=_rsasign_signStringWithSHA256,RSAKey.prototype.signWithMessageHashPSS=_rsasign_signWithMessageHashPSS,RSAKey.prototype.signStringPSS=_rsasign_signStringPSS,RSAKey.prototype.signPSS=_rsasign_signStringPSS,RSAKey.SALT_LEN_HLEN=-1,RSAKey.SALT_LEN_MAX=-2,RSAKey.prototype.verifyWithMessageHash=_rsasign_verifyWithMessageHash,RSAKey.prototype.verifyString=_rsasign_verifyString,RSAKey.prototype.verifyHexSignatureForMessage=_rsasign_verifyHexSignatureForMessage,RSAKey.prototype.verify=_rsasign_verifyString,RSAKey.prototype.verifyHexSignatureForByteArrayMessage=_rsasign_verifyHexSignatureForMessage,RSAKey.prototype.verifyWithMessageHashPSS=_rsasign_verifyWithMessageHashPSS,RSAKey.prototype.verifyStringPSS=_rsasign_verifyStringPSS,RSAKey.prototype.verifyPSS=_rsasign_verifyStringPSS,RSAKey.SALT_LEN_RECOVER=-2;var ASN1HEX=new function(){};ASN1HEX.getByteLengthOfL_AtObj=function(a,b){if("8"!=a.substring(b+2,b+3))return 1;var c=parseInt(a.substring(b+3,b+4));return 0==c?-1:0<c&&c<10?c+1:-2},ASN1HEX.getHexOfL_AtObj=function(a,b){var c=ASN1HEX.getByteLengthOfL_AtObj(a,b);return c<1?"":a.substring(b+2,b+2+2*c)},ASN1HEX.getIntOfL_AtObj=function(a,b){var c=ASN1HEX.getHexOfL_AtObj(a,b);if(""==c)return-1;var d;return d=parseInt(c.substring(0,1))<8?new BigInteger(c,16):new BigInteger(c.substring(2),16),d.intValue()},ASN1HEX.getStartPosOfV_AtObj=function(a,b){var c=ASN1HEX.getByteLengthOfL_AtObj(a,b);return c<0?c:b+2*(c+1)},ASN1HEX.getHexOfV_AtObj=function(a,b){var c=ASN1HEX.getStartPosOfV_AtObj(a,b),d=ASN1HEX.getIntOfL_AtObj(a,b);return a.substring(c,c+2*d)},ASN1HEX.getHexOfTLV_AtObj=function(a,b){var c=a.substr(b,2),d=ASN1HEX.getHexOfL_AtObj(a,b),e=ASN1HEX.getHexOfV_AtObj(a,b);return c+d+e},ASN1HEX.getPosOfNextSibling_AtObj=function(a,b){var c=ASN1HEX.getStartPosOfV_AtObj(a,b),d=ASN1HEX.getIntOfL_AtObj(a,b);return c+2*d},ASN1HEX.getPosArrayOfChildren_AtObj=function(a,b){var c=new Array,d=ASN1HEX.getStartPosOfV_AtObj(a,b);"03"==a.substr(b,2)?c.push(d+2):c.push(d);for(var e=ASN1HEX.getIntOfL_AtObj(a,b),f=d,g=0;;){var h=ASN1HEX.getPosOfNextSibling_AtObj(a,f);if(null==h||h-d>=2*e)break;if(g>=200)break;c.push(h),f=h,g++}return c},ASN1HEX.getNthChildIndex_AtObj=function(a,b,c){var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);return d[c]},ASN1HEX.getDecendantIndexByNthList=function(a,b,c){if(0==c.length)return b;var d=c.shift(),e=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);return ASN1HEX.getDecendantIndexByNthList(a,e[d],c)},ASN1HEX.getDecendantHexTLVByNthList=function(a,b,c){var d=ASN1HEX.getDecendantIndexByNthList(a,b,c);return ASN1HEX.getHexOfTLV_AtObj(a,d)},ASN1HEX.getDecendantHexVByNthList=function(a,b,c){var d=ASN1HEX.getDecendantIndexByNthList(a,b,c);return ASN1HEX.getHexOfV_AtObj(a,d)},ASN1HEX.getVbyList=function(a,b,c,d){var e=ASN1HEX.getDecendantIndexByNthList(a,b,c);if(void 0===e)throw"can't find nthList object";if(void 0!==d&&a.substr(e,2)!=d)throw"checking tag doesn't match: "+a.substr(e,2)+"!="+d;return ASN1HEX.getHexOfV_AtObj(a,e)},ASN1HEX.hextooidstr=function(a){var b=function(a,b){return a.length>=b?a:new Array(b-a.length+1).join("0")+a},c=[],d=a.substr(0,2),e=parseInt(d,16);c[0]=new String(Math.floor(e/40)),c[1]=new String(e%40);for(var f=a.substr(2),g=[],h=0;h<f.length/2;h++)g.push(parseInt(f.substr(2*h,2),16));for(var i=[],j="",h=0;h<g.length;h++)128&g[h]?j+=b((127&g[h]).toString(2),7):(j+=b((127&g[h]).toString(2),7),i.push(new String(parseInt(j,2))),j="");var k=c.join(".");return i.length>0&&(k=k+"."+i.join(".")),k},ASN1HEX.dump=function(a,b,c,d){var e=a;a instanceof KJUR.asn1.ASN1Object&&(e=a.getEncodedHex());var f=function(a,b){if(a.length<=2*b)return a;var c=a.substr(0,b)+"..(total "+a.length/2+"bytes).."+a.substr(a.length-b,b);return c};void 0===b&&(b={ommit_long_octet:32}),void 0===c&&(c=0),void 0===d&&(d="");var g=b.ommit_long_octet;if("01"==e.substr(c,2)){var h=ASN1HEX.getHexOfV_AtObj(e,c);return"00"==h?d+"BOOLEAN FALSE\n":d+"BOOLEAN TRUE\n"}if("02"==e.substr(c,2)){var h=ASN1HEX.getHexOfV_AtObj(e,c);return d+"INTEGER "+f(h,g)+"\n"}if("03"==e.substr(c,2)){var h=ASN1HEX.getHexOfV_AtObj(e,c);return d+"BITSTRING "+f(h,g)+"\n"}if("04"==e.substr(c,2)){var h=ASN1HEX.getHexOfV_AtObj(e,c);if(ASN1HEX.isASN1HEX(h)){var i=d+"OCTETSTRING, encapsulates\n";return i+=ASN1HEX.dump(h,b,0,d+" ")}return d+"OCTETSTRING "+f(h,g)+"\n"}if("05"==e.substr(c,2))return d+"NULL\n";if("06"==e.substr(c,2)){var j=ASN1HEX.getHexOfV_AtObj(e,c),k=KJUR.asn1.ASN1Util.oidHexToInt(j),l=KJUR.asn1.x509.OID.oid2name(k),m=k.replace(/\./g," ");return""!=l?d+"ObjectIdentifier "+l+" ("+m+")\n":d+"ObjectIdentifier ("+m+")\n"}if("0c"==e.substr(c,2))return d+"UTF8String '"+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"'\n";if("13"==e.substr(c,2))return d+"PrintableString '"+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"'\n";if("14"==e.substr(c,2))return d+"TeletexString '"+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"'\n";if("16"==e.substr(c,2))return d+"IA5String '"+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"'\n";if("17"==e.substr(c,2))return d+"UTCTime "+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"\n";if("18"==e.substr(c,2))return d+"GeneralizedTime "+hextoutf8(ASN1HEX.getHexOfV_AtObj(e,c))+"\n";if("30"==e.substr(c,2)){if("3000"==e.substr(c,4))return d+"SEQUENCE {}\n";var i=d+"SEQUENCE\n",n=ASN1HEX.getPosArrayOfChildren_AtObj(e,c),o=b;if((2==n.length||3==n.length)&&"06"==e.substr(n[0],2)&&"04"==e.substr(n[n.length-1],2)){var p=ASN1HEX.getHexOfV_AtObj(e,n[0]),k=KJUR.asn1.ASN1Util.oidHexToInt(p),l=KJUR.asn1.x509.OID.oid2name(k),q=JSON.parse(JSON.stringify(b));q.x509ExtName=l,o=q}for(var r=0;r<n.length;r++)i+=ASN1HEX.dump(e,o,n[r],d+" ");return i}if("31"==e.substr(c,2)){for(var i=d+"SET\n",n=ASN1HEX.getPosArrayOfChildren_AtObj(e,c),r=0;r<n.length;r++)i+=ASN1HEX.dump(e,b,n[r],d+" ");return i}var s=parseInt(e.substr(c,2),16);if(0!=(128&s)){var t=31&s;if(0!=(32&s)){for(var i=d+"["+t+"]\n",n=ASN1HEX.getPosArrayOfChildren_AtObj(e,c),r=0;r<n.length;r++)i+=ASN1HEX.dump(e,b,n[r],d+" ");return i}var h=ASN1HEX.getHexOfV_AtObj(e,c);"68747470"==h.substr(0,8)&&(h=hextoutf8(h)),"subjectAltName"===b.x509ExtName&&2==t&&(h=hextoutf8(h));var i=d+"["+t+"] "+h+"\n";return i}return d+"UNKNOWN("+e.substr(c,2)+") "+ASN1HEX.getHexOfV_AtObj(e,c)+"\n"},ASN1HEX.isASN1HEX=function(a){if(a.length%2==1)return!1;var b=ASN1HEX.getIntOfL_AtObj(a,0),c=a.substr(0,2),d=ASN1HEX.getHexOfL_AtObj(a,0),e=a.length-c.length-d.length;return e==2*b},X509.pemToBase64=function(a){var b=a;return b=b.replace("-----BEGIN CERTIFICATE-----",""),b=b.replace("-----END CERTIFICATE-----",""),b=b.replace(/[ \n]+/g,"")},X509.pemToHex=function(a){var b=X509.pemToBase64(a),c=b64tohex(b);return c},X509.getSubjectPublicKeyPosFromCertHex=function(a){var b=X509.getSubjectPublicKeyInfoPosFromCertHex(a);if(b==-1)return-1;var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);if(2!=c.length)return-1;var d=c[1];if("03"!=a.substring(d,d+2))return-1;var e=ASN1HEX.getStartPosOfV_AtObj(a,d);return"00"!=a.substring(e,e+2)?-1:e+2},X509.getSubjectPublicKeyInfoPosFromCertHex=function(a){var b=ASN1HEX.getStartPosOfV_AtObj(a,0),c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);return c.length<1?-1:"a003020102"==a.substring(c[0],c[0]+10)?c.length<6?-1:c[6]:c.length<5?-1:c[5]},X509.getPublicKeyHexArrayFromCertHex=function(a){var b=X509.getSubjectPublicKeyPosFromCertHex(a),c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);if(2!=c.length)return[];var d=ASN1HEX.getHexOfV_AtObj(a,c[0]),e=ASN1HEX.getHexOfV_AtObj(a,c[1]);return null!=d&&null!=e?[d,e]:[]},X509.getHexTbsCertificateFromCert=function(a){var b=ASN1HEX.getStartPosOfV_AtObj(a,0);return b},X509.getPublicKeyHexArrayFromCertPEM=function(a){var b=X509.pemToHex(a),c=X509.getPublicKeyHexArrayFromCertHex(b);return c},X509.hex2dn=function(a,b){if(void 0===b&&(b=0),"30"!==a.substr(b,2))throw"malformed DN";for(var c=new Array,d=ASN1HEX.getPosArrayOfChildren_AtObj(a,b),e=0;e<d.length;e++)c.push(X509.hex2rdn(a,d[e]));return c=c.map(function(a){return a.replace("/","\\/")}),"/"+c.join("/")},X509.hex2rdn=function(a,b){if(void 0===b&&(b=0),"31"!==a.substr(b,2))throw"malformed RDN";for(var c=new Array,d=ASN1HEX.getPosArrayOfChildren_AtObj(a,b),e=0;e<d.length;e++)c.push(X509.hex2attrTypeValue(a,d[e]));return c=c.map(function(a){return a.replace("+","\\+")}),c.join("+")},X509.hex2attrTypeValue=function(a,b){if(void 0===b&&(b=0),"30"!==a.substr(b,2))throw"malformed attribute type and value";var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);2!==c.length||"06"!==a.substr(c[0],2);var d=ASN1HEX.getHexOfV_AtObj(a,c[0]),e=KJUR.asn1.ASN1Util.oidHexToInt(d),f=KJUR.asn1.x509.OID.oid2atype(e),g=ASN1HEX.getHexOfV_AtObj(a,c[1]),h=hextorstr(g);return f+"="+h},X509.getPublicKeyFromCertPEM=function(a){var b=X509.getPublicKeyInfoPropOfCertPEM(a);if("2a864886f70d010101"==b.algoid){var c=KEYUTIL.parsePublicRawRSAKeyHex(b.keyhex),d=new RSAKey;return d.setPublic(c.n,c.e),d}if("2a8648ce3d0201"==b.algoid){var e=KJUR.crypto.OID.oidhex2name[b.algparam],d=new KJUR.crypto.ECDSA({curve:e,info:b.keyhex});return d.setPublicKeyHex(b.keyhex),d}if("2a8648ce380401"==b.algoid){var f=ASN1HEX.getVbyList(b.algparam,0,[0],"02"),g=ASN1HEX.getVbyList(b.algparam,0,[1],"02"),h=ASN1HEX.getVbyList(b.algparam,0,[2],"02"),i=ASN1HEX.getHexOfV_AtObj(b.keyhex,0);i=i.substr(2);var d=new KJUR.crypto.DSA;return d.setPublic(new BigInteger(f,16),new BigInteger(g,16),new BigInteger(h,16),new BigInteger(i,16)),d}throw"unsupported key"},X509.getPublicKeyInfoPropOfCertPEM=function(a){var b={};b.algparam=null;var c=X509.pemToHex(a),d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0);if(3!=d.length)throw"malformed X.509 certificate PEM (code:001)";if("30"!=c.substr(d[0],2))throw"malformed X.509 certificate PEM (code:002)";var e=ASN1HEX.getPosArrayOfChildren_AtObj(c,d[0]),f=6;if("a0"!==c.substr(e[0],2)&&(f=5),e.length<f+1)throw"malformed X.509 certificate PEM (code:003)";var g=ASN1HEX.getPosArrayOfChildren_AtObj(c,e[f]);if(2!=g.length)throw"malformed X.509 certificate PEM (code:004)";var h=ASN1HEX.getPosArrayOfChildren_AtObj(c,g[0]);if(2!=h.length)throw"malformed X.509 certificate PEM (code:005)";if(b.algoid=ASN1HEX.getHexOfV_AtObj(c,h[0]),"06"==c.substr(h[1],2)?b.algparam=ASN1HEX.getHexOfV_AtObj(c,h[1]):"30"==c.substr(h[1],2)&&(b.algparam=ASN1HEX.getHexOfTLV_AtObj(c,h[1])),"03"!=c.substr(g[1],2))throw"malformed X.509 certificate PEM (code:006)";var i=ASN1HEX.getHexOfV_AtObj(c,g[1]);return b.keyhex=i.substr(2),b},X509.getPublicKeyInfoPosOfCertHEX=function(a){var b=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(3!=b.length)throw"malformed X.509 certificate PEM (code:001)";if("30"!=a.substr(b[0],2))throw"malformed X.509 certificate PEM (code:002)";var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b[0]);if(c.length<7)throw"malformed X.509 certificate PEM (code:003)";return c[6]},X509.getV3ExtInfoListOfCertHex=function(a){var b=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(3!=b.length)throw"malformed X.509 certificate PEM (code:001)";if("30"!=a.substr(b[0],2))throw"malformed X.509 certificate PEM (code:002)";var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,b[0]);if(c.length<8)throw"malformed X.509 certificate PEM (code:003)";if("a3"!=a.substr(c[7],2))throw"malformed X.509 certificate PEM (code:004)";var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,c[7]);if(1!=d.length)throw"malformed X.509 certificate PEM (code:005)";if("30"!=a.substr(d[0],2))throw"malformed X.509 certificate PEM (code:006)";for(var e=ASN1HEX.getPosArrayOfChildren_AtObj(a,d[0]),f=e.length,g=new Array(f),h=0;h<f;h++)g[h]=X509.getV3ExtItemInfo_AtObj(a,e[h]);return g},X509.getV3ExtItemInfo_AtObj=function(a,b){var c={};c.posTLV=b;var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,b);if(2!=d.length&&3!=d.length)throw"malformed X.509v3 Ext (code:001)";if("06"!=a.substr(d[0],2))throw"malformed X.509v3 Ext (code:002)";var e=ASN1HEX.getHexOfV_AtObj(a,d[0]);c.oid=ASN1HEX.hextooidstr(e),c.critical=!1,3==d.length&&(c.critical=!0);var f=d[d.length-1];if("04"!=a.substr(f,2))throw"malformed X.509v3 Ext (code:003)";return c.posV=ASN1HEX.getStartPosOfV_AtObj(a,f),c},X509.getHexOfTLV_V3ExtValue=function(a,b){var c=X509.getPosOfTLV_V3ExtValue(a,b);return c==-1?null:ASN1HEX.getHexOfTLV_AtObj(a,c)},X509.getHexOfV_V3ExtValue=function(a,b){var c=X509.getPosOfTLV_V3ExtValue(a,b);return c==-1?null:ASN1HEX.getHexOfV_AtObj(a,c)},X509.getPosOfTLV_V3ExtValue=function(a,b){var c=b;if(b.match(/^[0-9.]+$/)||(c=KJUR.asn1.x509.OID.name2oid(b)),""==c)return-1;for(var d=X509.getV3ExtInfoListOfCertHex(a),e=0;e<d.length;e++){var f=d[e];if(f.oid==c)return f.posV}return-1},X509.getExtBasicConstraints=function(a){var b=X509.getHexOfV_V3ExtValue(a,"basicConstraints");if(null===b)return null;if(""===b)return{};if("0101ff"===b)return{cA:!0};if("0101ff02"===b.substr(0,8)){var c=ASN1HEX.getHexOfV_AtObj(b,6),d=parseInt(c,16);return{cA:!0,pathLen:d}}throw"unknown error"},X509.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],X509.getExtKeyUsageBin=function(a){var b=X509.getHexOfV_V3ExtValue(a,"keyUsage");if(""==b)return"";if(b.length%2!=0||b.length<=2)throw"malformed key usage value";var c=parseInt(b.substr(0,2)),d=parseInt(b.substr(2),16).toString(2);return d.substr(0,d.length-c)},X509.getExtKeyUsageString=function(a){for(var b=X509.getExtKeyUsageBin(a),c=new Array,d=0;d<b.length;d++)"1"==b.substr(d,1)&&c.push(X509.KEYUSAGE_NAME[d]);return c.join(",")},X509.getExtSubjectKeyIdentifier=function(a){var b=X509.getHexOfV_V3ExtValue(a,"subjectKeyIdentifier");return b},X509.getExtAuthorityKeyIdentifier=function(a){var b={},c=X509.getHexOfTLV_V3ExtValue(a,"authorityKeyIdentifier");if(null===c)return null;for(var d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0),e=0;e<d.length;e++)"80"===c.substr(d[e],2)&&(b.kid=ASN1HEX.getHexOfV_AtObj(c,d[e]));return b},X509.getExtExtKeyUsageName=function(a){var b=new Array,c=X509.getHexOfTLV_V3ExtValue(a,"extKeyUsage");if(null===c)return null;for(var d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0),e=0;e<d.length;e++){var f=ASN1HEX.getHexOfV_AtObj(c,d[e]),g=KJUR.asn1.ASN1Util.oidHexToInt(f),h=KJUR.asn1.x509.OID.oid2name(g);b.push(h)}return b},X509.getExtSubjectAltName=function(a){for(var b=new Array,c=X509.getHexOfTLV_V3ExtValue(a,"subjectAltName"),d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0),e=0;e<d.length;e++)if("82"===c.substr(d[e],2)){var f=hextoutf8(ASN1HEX.getHexOfV_AtObj(c,d[e]));b.push(f)}return b},X509.getExtCRLDistributionPointsURI=function(a){for(var b=new Array,c=X509.getHexOfTLV_V3ExtValue(a,"cRLDistributionPoints"),d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0),e=0;e<d.length;e++)for(var f=ASN1HEX.getHexOfTLV_AtObj(c,d[e]),g=ASN1HEX.getPosArrayOfChildren_AtObj(f,0),h=0;h<g.length;h++)if("a0"===f.substr(g[h],2)){var i=ASN1HEX.getHexOfV_AtObj(f,g[h]);if("a0"===i.substr(0,2)){var j=ASN1HEX.getHexOfV_AtObj(i,0);if("86"===j.substr(0,2)){var k=ASN1HEX.getHexOfV_AtObj(j,0),l=hextoutf8(k);b.push(l)}}}return b},X509.getExtAIAInfo=function(a){var b={};b.ocsp=[],b.caissuer=[];var c=X509.getPosOfTLV_V3ExtValue(a,"authorityInfoAccess");if(c==-1)return null;if("30"!=a.substr(c,2))throw"malformed AIA Extn Value";for(var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,c),e=0;e<d.length;e++){var f=d[e],g=ASN1HEX.getPosArrayOfChildren_AtObj(a,f);if(2!=g.length)throw"malformed AccessDescription of AIA Extn";var h=g[0],i=g[1];"2b06010505073001"==ASN1HEX.getHexOfV_AtObj(a,h)&&"86"==a.substr(i,2)&&b.ocsp.push(hextoutf8(ASN1HEX.getHexOfV_AtObj(a,i))),"2b06010505073002"==ASN1HEX.getHexOfV_AtObj(a,h)&&"86"==a.substr(i,2)&&b.caissuer.push(hextoutf8(ASN1HEX.getHexOfV_AtObj(a,i)))}return b},X509.getSignatureAlgorithmName=function(a){var b=ASN1HEX.getDecendantHexVByNthList(a,0,[1,0]),c=KJUR.asn1.ASN1Util.oidHexToInt(b),d=KJUR.asn1.x509.OID.oid2name(c);return d},X509.getSignatureValueHex=function(a){var b=ASN1HEX.getDecendantHexVByNthList(a,0,[2]);if("00"!==b.substr(0,2))throw"can't get signature value";return b.substr(2)},X509.getSerialNumberHex=function(a){return ASN1HEX.getDecendantHexVByNthList(a,0,[0,1])},"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.crypto&&KJUR.crypto||(KJUR.crypto={}),KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160},this.getDigestInfoHex=function(a,b){if("undefined"==typeof this.DIGESTINFOHEAD[b])throw"alg not supported in Util.DIGESTINFOHEAD: "+b;return this.DIGESTINFOHEAD[b]+a},this.getPaddedDigestInfoHex=function(a,b,c){var d=this.getDigestInfoHex(a,b),e=c/4;if(d.length+22>e)throw"key is too short for SigAlg: keylen="+c+","+b;for(var f="0001",g="00"+d,h="",i=e-f.length-g.length,j=0;j<i;j+=2)h+="ff";var k=f+h+g;return k},this.hashString=function(a,b){var c=new KJUR.crypto.MessageDigest({alg:b});return c.digestString(a)},this.hashHex=function(a,b){var c=new KJUR.crypto.MessageDigest({alg:b});return c.digestHex(a)},this.sha1=function(a){var b=new KJUR.crypto.MessageDigest({alg:"sha1",prov:"cryptojs"});return b.digestString(a)},this.sha256=function(a){var b=new KJUR.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return b.digestString(a)},this.sha256Hex=function(a){var b=new KJUR.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return b.digestHex(a)},this.sha512=function(a){var b=new KJUR.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"});return b.digestString(a)},this.sha512Hex=function(a){var b=new KJUR.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"});return b.digestHex(a)}},KJUR.crypto.Util.md5=function(a){var b=new KJUR.crypto.MessageDigest({alg:"md5",prov:"cryptojs"});return b.digestString(a)},KJUR.crypto.Util.ripemd160=function(a){var b=new KJUR.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"});return b.digestString(a)},KJUR.crypto.Util.SECURERANDOMGEN=new SecureRandom,KJUR.crypto.Util.getRandomHexOfNbytes=function(a){var b=new Array(a);return KJUR.crypto.Util.SECURERANDOMGEN.nextBytes(b),BAtohex(b)},KJUR.crypto.Util.getRandomBigIntegerOfNbytes=function(a){return new BigInteger(KJUR.crypto.Util.getRandomHexOfNbytes(a),16)},KJUR.crypto.Util.getRandomHexOfNbits=function(a){var b=a%8,c=(a-b)/8,d=new Array(c+1);return KJUR.crypto.Util.SECURERANDOMGEN.nextBytes(d),d[0]=(255<<b&255^255)&d[0],BAtohex(d)},KJUR.crypto.Util.getRandomBigIntegerOfNbits=function(a){return new BigInteger(KJUR.crypto.Util.getRandomHexOfNbits(a),16)},KJUR.crypto.Util.getRandomBigIntegerZeroToMax=function(a){for(var b=a.bitLength();;){var c=KJUR.crypto.Util.getRandomBigIntegerOfNbits(b);if(a.compareTo(c)!=-1)return c}},KJUR.crypto.Util.getRandomBigIntegerMinToMax=function(a,b){var c=a.compareTo(b);if(1==c)throw"biMin is greater than biMax";if(0==c)return a;var d=b.subtract(a),e=KJUR.crypto.Util.getRandomBigIntegerZeroToMax(d);return e.add(a)},KJUR.crypto.MessageDigest=function(a){this.setAlgAndProvider=function(a,b){if(a=KJUR.crypto.MessageDigest.getCanonicalAlgName(a),null!==a&&void 0===b&&(b=KJUR.crypto.Util.DEFAULTPROVIDER[a]),":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(a)!=-1&&"cryptojs"==b){try{this.md=KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[a].create()}catch(b){throw"setAlgAndProvider hash alg set fail alg="+a+"/"+b}this.updateString=function(a){this.md.update(a)},this.updateHex=function(a){var b=CryptoJS.enc.Hex.parse(a);this.md.update(b)},this.digest=function(){var a=this.md.finalize();return a.toString(CryptoJS.enc.Hex)},this.digestString=function(a){return this.updateString(a),this.digest()},this.digestHex=function(a){return this.updateHex(a),this.digest()}}if(":sha256:".indexOf(a)!=-1&&"sjcl"==b){try{this.md=new sjcl.hash.sha256}catch(b){throw"setAlgAndProvider hash alg set fail alg="+a+"/"+b}this.updateString=function(a){this.md.update(a)},this.updateHex=function(a){var b=sjcl.codec.hex.toBits(a);this.md.update(b)},this.digest=function(){var a=this.md.finalize();return sjcl.codec.hex.fromBits(a)},this.digestString=function(a){return this.updateString(a),this.digest()},this.digestHex=function(a){return this.updateHex(a),this.digest()}}},this.updateString=function(a){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(a){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(a){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(a){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==a&&void 0!==a.alg&&(this.algName=a.alg,void 0===a.prov&&(this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},KJUR.crypto.MessageDigest.getCanonicalAlgName=function(a){return"string"==typeof a&&(a=a.toLowerCase(),a=a.replace(/-/,"")),a},KJUR.crypto.MessageDigest.getHashLength=function(a){var b=KJUR.crypto.MessageDigest,c=b.getCanonicalAlgName(a);if(void 0===b.HASHLENGTH[c])throw"not supported algorithm: "+a;return b.HASHLENGTH[c]},KJUR.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},KJUR.crypto.Mac=function(a){this.setAlgAndProvider=function(a,b){if(a=a.toLowerCase(),null==a&&(a="hmacsha1"),a=a.toLowerCase(),"hmac"!=a.substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+a;void 0===b&&(b=KJUR.crypto.Util.DEFAULTPROVIDER[a]),this.algProv=a+"/"+b;var c=a.substr(4);if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(c)!=-1&&"cryptojs"==b){try{var d=KJUR.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[c];this.mac=CryptoJS.algo.HMAC.create(d,this.pass)}catch(a){throw"setAlgAndProvider hash alg set fail hashAlg="+c+"/"+a}this.updateString=function(a){this.mac.update(a)},this.updateHex=function(a){var b=CryptoJS.enc.Hex.parse(a);this.mac.update(b)},this.doFinal=function(){var a=this.mac.finalize();return a.toString(CryptoJS.enc.Hex)},this.doFinalString=function(a){return this.updateString(a),this.doFinal()},this.doFinalHex=function(a){return this.updateHex(a),this.doFinal()}}},this.updateString=function(a){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(a){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(a){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(a){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(a){if("string"==typeof a){var b=a;return a.length%2!=1&&a.match(/^[0-9A-Fa-f]+$/)||(b=rstrtohex(a)),void(this.pass=CryptoJS.enc.Hex.parse(b))}if("object"!=typeof a)throw"KJUR.crypto.Mac unsupported password type: "+a;var b=null;if(void 0!==a.hex){if(a.hex.length%2!=0||!a.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+a.hex;b=a.hex}if(void 0!==a.utf8&&(b=utf8tohex(a.utf8)),void 0!==a.rstr&&(b=rstrtohex(a.rstr)),void 0!==a.b64&&(b=b64tohex(a.b64)),void 0!==a.b64u&&(b=b64utohex(a.b64u)),null==b)throw"KJUR.crypto.Mac unsupported password type: "+a;this.pass=CryptoJS.enc.Hex.parse(b)},void 0!==a&&(void 0!==a.pass&&this.setPassword(a.pass),void 0!==a.alg&&(this.algName=a.alg,void 0===a.prov&&(this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},KJUR.crypto.Signature=function(a){var b=null;if(this._setAlgNames=function(){var a=this.algName.match(/^(.+)with(.+)$/);a&&(this.mdAlgName=a[1].toLowerCase(),this.pubkeyAlgName=a[2].toLowerCase())},this._zeroPaddingOfSignature=function(a,b){for(var c="",d=b/4-a.length,e=0;e<d;e++)c+="0";return c+a},this.setAlgAndProvider=function(a,b){if(this._setAlgNames(),"cryptojs/jsrsa"!=b)throw"provider not supported: "+b;if(":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)!=-1){try{this.md=new KJUR.crypto.MessageDigest({alg:this.mdAlgName})}catch(a){throw"setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+a}this.init=function(a,b){var c=null;try{c=void 0===b?KEYUTIL.getKey(a):KEYUTIL.getKey(a,b)}catch(a){throw"init failed:"+a}if(c.isPrivate===!0)this.prvKey=c,this.state="SIGN";else{if(c.isPublic!==!0)throw"init failed.:"+c;this.pubKey=c,this.state="VERIFY"}},this.initSign=function(a){"string"==typeof a.ecprvhex&&"string"==typeof a.eccurvename?(this.ecprvhex=a.ecprvhex,this.eccurvename=a.eccurvename):this.prvKey=a,this.state="SIGN"},this.initVerifyByPublicKey=function(a){"string"==typeof a.ecpubhex&&"string"==typeof a.eccurvename?(this.ecpubhex=a.ecpubhex,this.eccurvename=a.eccurvename):a instanceof KJUR.crypto.ECDSA?this.pubKey=a:a instanceof RSAKey&&(this.pubKey=a),this.state="VERIFY"},this.initVerifyByCertificatePEM=function(a){var b=new X509;b.readCertPEM(a),this.pubKey=b.subjectPublicKeyRSA,this.state="VERIFY"},this.updateString=function(a){this.md.updateString(a)},this.updateHex=function(a){this.md.updateHex(a)},this.sign=function(){if(this.sHashHex=this.md.digest(),"undefined"!=typeof this.ecprvhex&&"undefined"!=typeof this.eccurvename){var a=new KJUR.crypto.ECDSA({curve:this.eccurvename});this.hSign=a.signHex(this.sHashHex,this.ecprvhex)}else if(this.prvKey instanceof RSAKey&&"rsaandmgf1"==this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof RSAKey&&"rsa"==this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof KJUR.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof KJUR.crypto.DSA))throw"Signature: unsupported public key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(a){return this.updateString(a),this.sign()},this.signHex=function(a){return this.updateHex(a),this.sign()},this.verify=function(a){if(this.sHashHex=this.md.digest(),"undefined"!=typeof this.ecpubhex&&"undefined"!=typeof this.eccurvename){var b=new KJUR.crypto.ECDSA({curve:this.eccurvename});return b.verifyHex(this.sHashHex,a,this.ecpubhex)}if(this.pubKey instanceof RSAKey&&"rsaandmgf1"==this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,a,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof RSAKey&&"rsa"==this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,a);if(this.pubKey instanceof KJUR.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,a);if(this.pubKey instanceof KJUR.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,a);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(a,b){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.initVerifyByPublicKey=function(a){throw"initVerifyByPublicKey(rsaPubKeyy) not supported for this alg:prov="+this.algProvName},this.initVerifyByCertificatePEM=function(a){throw"initVerifyByCertificatePEM(certPEM) not supported for this alg:prov="+this.algProvName},this.initSign=function(a){throw"initSign(prvKey) not supported for this alg:prov="+this.algProvName},this.updateString=function(a){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(a){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(a){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(a){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(a){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=a,void 0!==a&&(void 0!==a.alg&&(this.algName=a.alg,void 0===a.prov?this.provName=KJUR.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=a.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==a.psssaltlen&&(this.pssSaltLen=a.psssaltlen),void 0!==a.prvkeypem)){if(void 0!==a.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{var b=new RSAKey;b.readPrivateKeyFromPEMString(a.prvkeypem),this.initSign(b)}catch(a){throw"fatal error to load pem private key: "+a}}},KJUR.crypto.Cipher=function(a){},KJUR.crypto.Cipher.encrypt=function(a,b,c){
if(b instanceof RSAKey&&b.isPublic){var d=KJUR.crypto.Cipher.getAlgByKeyAndName(b,c);if("RSA"===d)return b.encrypt(a);if("RSAOAEP"===d)return b.encryptOAEP(a,"sha1");var e=d.match(/^RSAOAEP(\d+)$/);if(null!==e)return b.encryptOAEP(a,"sha"+e[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+c}throw"Cipher.encrypt: unsupported key or algorithm"},KJUR.crypto.Cipher.decrypt=function(a,b,c){if(b instanceof RSAKey&&b.isPrivate){var d=KJUR.crypto.Cipher.getAlgByKeyAndName(b,c);if("RSA"===d)return b.decrypt(a);if("RSAOAEP"===d)return b.decryptOAEP(a,"sha1");var e=d.match(/^RSAOAEP(\d+)$/);if(null!==e)return b.decryptOAEP(a,"sha"+e[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+c}throw"Cipher.decrypt: unsupported key or algorithm"},KJUR.crypto.Cipher.getAlgByKeyAndName=function(a,b){if(a instanceof RSAKey){if(":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(b)!=-1)return b;if(null===b||void 0===b)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+b}throw"getAlgByKeyAndName: not supported algorithm name: "+b},KJUR.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}};var KJUR;"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.lang&&KJUR.lang||(KJUR.lang={}),KJUR.lang.String=function(){};var utf8tob64u,b64utoutf8;"function"==typeof Buffer?(utf8tob64u=function(a){return b64tob64u(new Buffer(a,"utf8").toString("base64"))},b64utoutf8=function(a){return new Buffer(b64utob64(a),"base64").toString("utf8")}):(utf8tob64u=function(a){return hextob64u(uricmptohex(encodeURIComponentAll(a)))},b64utoutf8=function(a){return decodeURIComponent(hextouricmp(b64utohex(a)))}),KJUR.lang.String.isInteger=function(a){return!!a.match(/^[0-9]+$/)||!!a.match(/^-[0-9]+$/)},KJUR.lang.String.isHex=function(a){return!(a.length%2!=0||!a.match(/^[0-9a-f]+$/)&&!a.match(/^[0-9A-F]+$/))},KJUR.lang.String.isBase64=function(a){return a=a.replace(/\s+/g,""),!(!a.match(/^[0-9A-Za-z+\/]+={0,3}$/)||a.length%4!=0)},KJUR.lang.String.isBase64URL=function(a){return!a.match(/[+\/=]/)&&(a=b64utob64(a),KJUR.lang.String.isBase64(a))},KJUR.lang.String.isIntegerArray=function(a){return a=a.replace(/\s+/g,""),!!a.match(/^\[[0-9,]+\]$/)};var strdiffidx=function(a,b){var c=a.length;a.length>b.length&&(c=b.length);for(var d=0;d<c;d++)if(a.charCodeAt(d)!=b.charCodeAt(d))return d;return a.length!=b.length?c:-1};Arcfour.prototype.init=ARC4init,Arcfour.prototype.next=ARC4next;var rng_psize=256,rng_state,rng_pool,rng_pptr;if(null==rng_pool){rng_pool=new Array,rng_pptr=0;var t;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t<z.length;++t)rng_pool[rng_pptr++]=255&z.charCodeAt(t)}for(;rng_pptr<rng_psize;)t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=255&t;rng_pptr=0,rng_seed_time()}SecureRandom.prototype.nextBytes=rng_get_bytes;var jsonParse=function(){function g(a,b,c){return b?f[b]:String.fromCharCode(parseInt(c,16))}var a="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",b='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))',c='(?:"'+b+'*")',d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+a+"|"+c+")","g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),f={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},h=new String(""),i="\\",k=({"{":Object,"[":Array},Object.hasOwnProperty);return function(a,b){var f,c=a.match(d),j=c[0],l=!1;"{"===j?f={}:"["===j?f=[]:(f=[],l=!0);for(var m,n=[f],o=1-l,p=c.length;o<p;++o){j=c[o];var q;switch(j.charCodeAt(0)){default:q=n[0],q[m||q.length]=+j,m=void 0;break;case 34:if(j=j.substring(1,j.length-1),j.indexOf(i)!==-1&&(j=j.replace(e,g)),q=n[0],!m){if(!(q instanceof Array)){m=j||h;break}m=q.length}q[m]=j,m=void 0;break;case 91:q=n[0],n.unshift(q[m||q.length]=[]),m=void 0;break;case 93:n.shift();break;case 102:q=n[0],q[m||q.length]=!1,m=void 0;break;case 110:q=n[0],q[m||q.length]=null,m=void 0;break;case 116:q=n[0],q[m||q.length]=!0,m=void 0;break;case 123:q=n[0],n.unshift(q[m||q.length]={}),m=void 0;break;case 125:n.shift()}}if(l){if(1!==n.length)throw new Error;f=f[0]}else if(n.length)throw new Error;if(b){var r=function(a,c){var d=a[c];if(d&&"object"==typeof d){var e=null;for(var f in d)if(k.call(d,f)&&d!==a){var g=r(d,f);void 0!==g?d[f]=g:(e||(e=[]),e.push(f))}if(e)for(var h=e.length;--h>=0;)delete d[e[h]]}return b.call(a,c,d)};f=r({"":f},"")}return f}}();"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.jws&&KJUR.jws||(KJUR.jws={}),KJUR.jws.JWS=function(){var a=KJUR.jws.JWS;this.parseJWS=function(b,c){if(void 0===this.parsedJWS||!c&&void 0===this.parsedJWS.sigvalH){var d=b.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==d)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var e=d[1],f=d[2],g=d[3],h=e+"."+f;if(this.parsedJWS={},this.parsedJWS.headB64U=e,this.parsedJWS.payloadB64U=f,this.parsedJWS.sigvalB64U=g,this.parsedJWS.si=h,!c){var i=b64utohex(g),j=parseBigInt(i,16);this.parsedJWS.sigvalH=i,this.parsedJWS.sigvalBI=j}var k=b64utoutf8(e),l=b64utoutf8(f);if(this.parsedJWS.headS=k,this.parsedJWS.payloadS=l,!a.isSafeJSONString(k,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+k}}},KJUR.jws.JWS.sign=function(a,b,c,d,e){var f,g,h,i=KJUR.jws.JWS;if("string"!=typeof b&&"object"!=typeof b)throw"spHeader must be JSON string or object: "+b;if("object"==typeof b&&(g=b,f=JSON.stringify(g)),"string"==typeof b){if(f=b,!i.isSafeJSONString(f))throw"JWS Head is not safe JSON string: "+f;g=i.readSafeJSONString(f)}if(h=c,"object"==typeof c&&(h=JSON.stringify(c)),""!=a&&null!=a||void 0===g.alg||(a=g.alg),""!=a&&null!=a&&void 0===g.alg&&(g.alg=a,f=JSON.stringify(g)),a!==g.alg)throw"alg and sHeader.alg doesn't match: "+a+"!="+g.alg;var j=null;if(void 0===i.jwsalg2sigalg[a])throw"unsupported alg name: "+a;j=i.jwsalg2sigalg[a];var k=utf8tob64u(f),l=utf8tob64u(h),m=k+"."+l,n="";if("Hmac"==j.substr(0,4)){if(void 0===d)throw"mac key shall be specified for HS* alg";var o=new KJUR.crypto.Mac({alg:j,prov:"cryptojs",pass:d});o.updateString(m),n=o.doFinal()}else if(j.indexOf("withECDSA")!=-1){var p=new KJUR.crypto.Signature({alg:j});p.init(d,e),p.updateString(m),hASN1Sig=p.sign(),n=KJUR.crypto.ECDSA.asn1SigToConcatSig(hASN1Sig)}else if("none"!=j){var p=new KJUR.crypto.Signature({alg:j});p.init(d,e),p.updateString(m),n=p.sign()}var q=hextob64u(n);return m+"."+q},KJUR.jws.JWS.verify=function(a,b,c){var d=KJUR.jws.JWS,e=a.split("."),f=e[0],g=e[1],h=f+"."+g,i=b64utohex(e[2]),j=d.readSafeJSONString(b64utoutf8(e[0])),k=null,l=null;if(void 0===j.alg)throw"algorithm not specified in header";if(k=j.alg,l=k.substr(0,2),null!=c&&"[object Array]"===Object.prototype.toString.call(c)&&c.length>0){var m=":"+c.join(":")+":";if(m.indexOf(":"+k+":")==-1)throw"algorithm '"+k+"' not accepted in the list"}if("none"!=k&&null===b)throw"key shall be specified to verify.";if("string"==typeof b&&b.indexOf("-----BEGIN ")!=-1&&(b=KEYUTIL.getKey(b)),!("RS"!=l&&"PS"!=l||b instanceof RSAKey))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==l&&!(b instanceof KJUR.crypto.ECDSA))throw"key shall be a ECDSA obj for ES* algs";var n=null;if(void 0===d.jwsalg2sigalg[j.alg])throw"unsupported alg name: "+k;if(n=d.jwsalg2sigalg[k],"none"==n)throw"not supported";if("Hmac"==n.substr(0,4)){var o=null;if(void 0===b)throw"hexadecimal key shall be specified for HMAC";var p=new KJUR.crypto.Mac({alg:n,pass:b});return p.updateString(h),o=p.doFinal(),i==o}if(n.indexOf("withECDSA")!=-1){var q=null;try{q=KJUR.crypto.ECDSA.concatSigToASN1Sig(i)}catch(a){return!1}var r=new KJUR.crypto.Signature({alg:n});return r.init(b),r.updateString(h),r.verify(q)}var r=new KJUR.crypto.Signature({alg:n});return r.init(b),r.updateString(h),r.verify(i)},KJUR.jws.JWS.parse=function(a){var b,c,d,e=a.split("."),f={};if(2!=e.length&&3!=e.length)throw"malformed sJWS: wrong number of '.' splitted elements";return b=e[0],c=e[1],3==e.length&&(d=e[2]),f.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(b)),f.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(c)),f.headerPP=JSON.stringify(f.headerObj,null," "),null==f.payloadObj?f.payloadPP=b64utoutf8(c):f.payloadPP=JSON.stringify(f.payloadObj,null," "),void 0!==d&&(f.sigHex=b64utohex(d)),f},KJUR.jws.JWS.verifyJWT=function(a,b,c){var d=KJUR.jws.JWS,e=a.split("."),f=e[0],g=e[1],h=(b64utohex(e[2]),d.readSafeJSONString(b64utoutf8(f))),i=d.readSafeJSONString(b64utoutf8(g));if(void 0===h.alg)return!1;if(void 0===c.alg)throw"acceptField.alg shall be specified";if(!d.inArray(h.alg,c.alg))return!1;if(void 0!==i.iss&&"object"==typeof c.iss&&!d.inArray(i.iss,c.iss))return!1;if(void 0!==i.sub&&"object"==typeof c.sub&&!d.inArray(i.sub,c.sub))return!1;if(void 0!==i.aud&&"object"==typeof c.aud)if("string"==typeof i.aud){if(!d.inArray(i.aud,c.aud))return!1}else if("object"==typeof i.aud&&!d.includedArray(i.aud,c.aud))return!1;var j=KJUR.jws.IntDate.getNow();return void 0!==c.verifyAt&&"number"==typeof c.verifyAt&&(j=c.verifyAt),void 0!==c.gracePeriod&&"number"==typeof c.gracePeriod||(c.gracePeriod=0),!(void 0!==i.exp&&"number"==typeof i.exp&&i.exp+c.gracePeriod<j||void 0!==i.nbf&&"number"==typeof i.nbf&&j<i.nbf-c.gracePeriod||void 0!==i.iat&&"number"==typeof i.iat&&j<i.iat-c.gracePeriod||void 0!==i.jti&&void 0!==c.jti&&i.jti!==c.jti||!KJUR.jws.JWS.verify(a,b,c.alg))},KJUR.jws.JWS.includedArray=function(a,b){var c=KJUR.jws.JWS.inArray;if(null===a)return!1;if("object"!=typeof a)return!1;if("number"!=typeof a.length)return!1;for(var d=0;d<a.length;d++)if(!c(a[d],b))return!1;return!0},KJUR.jws.JWS.inArray=function(a,b){if(null===b)return!1;if("object"!=typeof b)return!1;if("number"!=typeof b.length)return!1;for(var c=0;c<b.length;c++)if(b[c]==a)return!0;return!1},KJUR.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},KJUR.jws.JWS.isSafeJSONString=function(a,b,c){var d=null;try{return d=jsonParse(a),"object"!=typeof d?0:d.constructor===Array?0:(b&&(b[c]=d),1)}catch(a){return 0}},KJUR.jws.JWS.readSafeJSONString=function(a){var b=null;try{return b=jsonParse(a),"object"!=typeof b?null:b.constructor===Array?null:b}catch(a){return null}},KJUR.jws.JWS.getEncodedSignatureValueFromJWS=function(a){var b=a.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==b)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return b[1]},KJUR.jws.JWS.getJWKthumbprint=function(a){if("RSA"!==a.kty&&"EC"!==a.kty&&"oct"!==a.kty)throw"unsupported algorithm for JWK Thumprint";var b="{";if("RSA"===a.kty){if("string"!=typeof a.n||"string"!=typeof a.e)throw"wrong n and e value for RSA key";b+='"e":"'+a.e+'",',b+='"kty":"'+a.kty+'",',b+='"n":"'+a.n+'"}'}else if("EC"===a.kty){if("string"!=typeof a.crv||"string"!=typeof a.x||"string"!=typeof a.y)throw"wrong crv, x and y value for EC key";b+='"crv":"'+a.crv+'",',b+='"kty":"'+a.kty+'",',b+='"x":"'+a.x+'",',b+='"y":"'+a.y+'"}'}else if("oct"===a.kty){if("string"!=typeof a.k)throw"wrong k value for oct(symmetric) key";b+='"kty":"'+a.kty+'",',b+='"k":"'+a.k+'"}'}var c=rstrtohex(b),d=KJUR.crypto.Util.hashHex(c,"sha256"),e=hextob64u(d);return e},KJUR.jws.IntDate={},KJUR.jws.IntDate.get=function(a){if("now"==a)return KJUR.jws.IntDate.getNow();if("now + 1hour"==a)return KJUR.jws.IntDate.getNow()+3600;if("now + 1day"==a)return KJUR.jws.IntDate.getNow()+86400;if("now + 1month"==a)return KJUR.jws.IntDate.getNow()+2592e3;if("now + 1year"==a)return KJUR.jws.IntDate.getNow()+31536e3;if(a.match(/Z$/))return KJUR.jws.IntDate.getZulu(a);if(a.match(/^[0-9]+$/))return parseInt(a);throw"unsupported format: "+a},KJUR.jws.IntDate.getZulu=function(a){var b=a.match(/(\d+)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)Z/);if(b){var c=b[1],d=parseInt(c);if(4==c.length);else{if(2!=c.length)throw"malformed year string";if(50<=d&&d<100)d=1900+d;else{if(!(0<=d&&d<50))throw"malformed year string for UTCTime";d=2e3+d}}var e=parseInt(b[2])-1,f=parseInt(b[3]),g=parseInt(b[4]),h=parseInt(b[5]),i=parseInt(b[6]),j=new Date(Date.UTC(d,e,f,g,h,i));return~~(j/1e3)}throw"unsupported format: "+a},KJUR.jws.IntDate.getNow=function(){var a=~~(new Date/1e3);return a},KJUR.jws.IntDate.intDate2UTCString=function(a){var b=new Date(1e3*a);return b.toUTCString()},KJUR.jws.IntDate.intDate2Zulu=function(a){var b=new Date(1e3*a),c=("0000"+b.getUTCFullYear()).slice(-4),d=("00"+(b.getUTCMonth()+1)).slice(-2),e=("00"+b.getUTCDate()).slice(-2),f=("00"+b.getUTCHours()).slice(-2),g=("00"+b.getUTCMinutes()).slice(-2),h=("00"+b.getUTCSeconds()).slice(-2);return c+d+e+f+g+h+"Z"};var KEYUTIL=function(){var a=function(a,b,c){return d(CryptoJS.AES,a,b,c)},b=function(a,b,c){return d(CryptoJS.TripleDES,a,b,c)},c=function(a,b,c){return d(CryptoJS.DES,a,b,c)},d=function(a,b,c,d){var e=CryptoJS.enc.Hex.parse(b),f=CryptoJS.enc.Hex.parse(c),g=CryptoJS.enc.Hex.parse(d),h={};h.key=f,h.iv=g,h.ciphertext=e;var i=a.decrypt(h,f,{iv:g});return CryptoJS.enc.Hex.stringify(i)},e=function(a,b,c){return h(CryptoJS.AES,a,b,c)},f=function(a,b,c){return h(CryptoJS.TripleDES,a,b,c)},g=function(a,b,c){return h(CryptoJS.DES,a,b,c)},h=function(a,b,c,d){var e=CryptoJS.enc.Hex.parse(b),f=CryptoJS.enc.Hex.parse(c),g=CryptoJS.enc.Hex.parse(d),h=a.encrypt(e,f,{iv:g}),i=CryptoJS.enc.Hex.parse(h.toString()),j=CryptoJS.enc.Base64.stringify(i);return j},i={"AES-256-CBC":{proc:a,eproc:e,keylen:32,ivlen:16},"AES-192-CBC":{proc:a,eproc:e,keylen:24,ivlen:16},"AES-128-CBC":{proc:a,eproc:e,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:b,eproc:f,keylen:24,ivlen:8},"DES-CBC":{proc:c,eproc:g,keylen:8,ivlen:8}},j=function(a){return i[a].proc},k=function(a){var b=CryptoJS.lib.WordArray.random(a),c=CryptoJS.enc.Hex.stringify(b);return c},l=function(a){var b={},c=a.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));c&&(b.cipher=c[1],b.ivsalt=c[2]);var d=a.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));d&&(b.type=d[1]);var e=-1,f=0;a.indexOf("\r\n\r\n")!=-1&&(e=a.indexOf("\r\n\r\n"),f=2),a.indexOf("\n\n")!=-1&&(e=a.indexOf("\n\n"),f=1);var g=a.indexOf("-----END");if(e!=-1&&g!=-1){var h=a.substring(e+2*f,g-f);h=h.replace(/\s+/g,""),b.data=h}return b},m=function(a,b,c){for(var d=c.substring(0,16),e=CryptoJS.enc.Hex.parse(d),f=CryptoJS.enc.Utf8.parse(b),g=i[a].keylen+i[a].ivlen,h="",j=null;;){var k=CryptoJS.algo.MD5.create();if(null!=j&&k.update(j),k.update(f),k.update(e),j=k.finalize(),h+=CryptoJS.enc.Hex.stringify(j),h.length>=2*g)break}var l={};return l.keyhex=h.substr(0,2*i[a].keylen),l.ivhex=h.substr(2*i[a].keylen,2*i[a].ivlen),l},n=function(a,b,c,d){var e=CryptoJS.enc.Base64.parse(a),f=CryptoJS.enc.Hex.stringify(e),g=i[b].proc,h=g(f,c,d);return h},o=function(a,b,c,d){var e=i[b].eproc,f=e(a,c,d);return f};return{version:"1.0.0",getHexFromPEM:function(a,b){var c=a;if(c.indexOf("-----BEGIN ")==-1)throw"can't find PEM header: "+b;"string"==typeof b&&""!=b?(c=c.replace("-----BEGIN "+b+"-----",""),c=c.replace("-----END "+b+"-----","")):(c=c.replace(/-----BEGIN [^-]+-----/,""),c=c.replace(/-----END [^-]+-----/,""));var d=c.replace(/\s+/g,""),e=b64tohex(d);return e},getDecryptedKeyHexByKeyIV:function(a,b,c,d){var e=j(b);return e(a,c,d)},parsePKCS5PEM:function(a){return l(a)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(a,b,c){return m(a,b,c)},decryptKeyB64:function(a,b,c,d){return n(a,b,c,d)},getDecryptedKeyHex:function(a,b){var c=l(a),d=(c.type,c.cipher),e=c.ivsalt,f=c.data,g=m(d,b,e),h=g.keyhex,i=n(f,d,h,e);return i},getRSAKeyFromEncryptedPKCS5PEM:function(a,b){var c=this.getDecryptedKeyHex(a,b),d=new RSAKey;return d.readPrivateKeyFromASN1HexString(c),d},getEncryptedPKCS5PEMFromPrvKeyHex:function(a,b,c,d,e){var f="";if("undefined"!=typeof d&&null!=d||(d="AES-256-CBC"),"undefined"==typeof i[d])throw"KEYUTIL unsupported algorithm: "+d;if("undefined"==typeof e||null==e){var g=i[d].ivlen,h=k(g);e=h.toUpperCase()}var j=m(d,c,e),l=j.keyhex,n=o(b,d,l,e),p=n.replace(/(.{64})/g,"$1\r\n"),f="-----BEGIN "+a+" PRIVATE KEY-----\r\n";return f+="Proc-Type: 4,ENCRYPTED\r\n",f+="DEK-Info: "+d+","+e+"\r\n",f+="\r\n",f+=p,f+="\r\n-----END "+a+" PRIVATE KEY-----\r\n"},getEncryptedPKCS5PEMFromRSAKey:function(a,b,c,d){var e=new KJUR.asn1.DERInteger({int:0}),f=new KJUR.asn1.DERInteger({bigint:a.n}),g=new KJUR.asn1.DERInteger({int:a.e}),h=new KJUR.asn1.DERInteger({bigint:a.d}),i=new KJUR.asn1.DERInteger({bigint:a.p}),j=new KJUR.asn1.DERInteger({bigint:a.q}),k=new KJUR.asn1.DERInteger({bigint:a.dmp1}),l=new KJUR.asn1.DERInteger({bigint:a.dmq1}),m=new KJUR.asn1.DERInteger({bigint:a.coeff}),n=new KJUR.asn1.DERSequence({array:[e,f,g,h,i,j,k,l,m]}),o=n.getEncodedHex();return this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",o,b,c,d)},newEncryptedPKCS5PEM:function(a,b,c,d){"undefined"!=typeof b&&null!=b||(b=1024),"undefined"!=typeof c&&null!=c||(c="10001");var e=new RSAKey;e.generate(b,c);var f=null;return f="undefined"==typeof d||null==d?this.getEncryptedPKCS5PEMFromRSAKey(e,a):this.getEncryptedPKCS5PEMFromRSAKey(e,a,d)},getRSAKeyFromPlainPKCS8PEM:function(a){if(a.match(/ENCRYPTED/))throw"pem shall be not ENCRYPTED";var b=this.getHexFromPEM(a,"PRIVATE KEY"),c=this.getRSAKeyFromPlainPKCS8Hex(b);return c},getRSAKeyFromPlainPKCS8Hex:function(a){var b=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(3!=b.length)throw"outer DERSequence shall have 3 elements: "+b.length;var c=ASN1HEX.getHexOfTLV_AtObj(a,b[1]);if("300d06092a864886f70d0101010500"!=c)throw"PKCS8 AlgorithmIdentifier is not rsaEnc: "+c;var c=ASN1HEX.getHexOfTLV_AtObj(a,b[1]),d=ASN1HEX.getHexOfTLV_AtObj(a,b[2]),e=ASN1HEX.getHexOfV_AtObj(d,0),f=new RSAKey;return f.readPrivateKeyFromASN1HexString(e),f},parseHexOfEncryptedPKCS8:function(a){var b={},c=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(2!=c.length)throw"malformed format: SEQUENCE(0).items != 2: "+c.length;b.ciphertext=ASN1HEX.getHexOfV_AtObj(a,c[1]);var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,c[0]);if(2!=d.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+d.length;if("2a864886f70d01050d"!=ASN1HEX.getHexOfV_AtObj(a,d[0]))throw"this only supports pkcs5PBES2";var e=ASN1HEX.getPosArrayOfChildren_AtObj(a,d[1]);if(2!=d.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+e.length;var f=ASN1HEX.getPosArrayOfChildren_AtObj(a,e[1]);if(2!=f.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+f.length;if("2a864886f70d0307"!=ASN1HEX.getHexOfV_AtObj(a,f[0]))throw"this only supports TripleDES";b.encryptionSchemeAlg="TripleDES",b.encryptionSchemeIV=ASN1HEX.getHexOfV_AtObj(a,f[1]);var g=ASN1HEX.getPosArrayOfChildren_AtObj(a,e[0]);if(2!=g.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+g.length;if("2a864886f70d01050c"!=ASN1HEX.getHexOfV_AtObj(a,g[0]))throw"this only supports pkcs5PBKDF2";var h=ASN1HEX.getPosArrayOfChildren_AtObj(a,g[1]);if(h.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+h.length;b.pbkdf2Salt=ASN1HEX.getHexOfV_AtObj(a,h[0]);var i=ASN1HEX.getHexOfV_AtObj(a,h[1]);try{b.pbkdf2Iter=parseInt(i,16)}catch(a){throw"malformed format pbkdf2Iter: "+i}return b},getPBKDF2KeyHexFromParam:function(a,b){var c=CryptoJS.enc.Hex.parse(a.pbkdf2Salt),d=a.pbkdf2Iter,e=CryptoJS.PBKDF2(b,c,{keySize:6,iterations:d}),f=CryptoJS.enc.Hex.stringify(e);return f},getPlainPKCS8HexFromEncryptedPKCS8PEM:function(a,b){var c=this.getHexFromPEM(a,"ENCRYPTED PRIVATE KEY"),d=this.parseHexOfEncryptedPKCS8(c),e=KEYUTIL.getPBKDF2KeyHexFromParam(d,b),f={};f.ciphertext=CryptoJS.enc.Hex.parse(d.ciphertext);var g=CryptoJS.enc.Hex.parse(e),h=CryptoJS.enc.Hex.parse(d.encryptionSchemeIV),i=CryptoJS.TripleDES.decrypt(f,g,{iv:h}),j=CryptoJS.enc.Hex.stringify(i);return j},getRSAKeyFromEncryptedPKCS8PEM:function(a,b){var c=this.getPlainPKCS8HexFromEncryptedPKCS8PEM(a,b),d=this.getRSAKeyFromPlainPKCS8Hex(c);return d},getKeyFromEncryptedPKCS8PEM:function(a,b){var c=this.getPlainPKCS8HexFromEncryptedPKCS8PEM(a,b),d=this.getKeyFromPlainPrivatePKCS8Hex(c);return d},parsePlainPrivatePKCS8Hex:function(a){var b={};if(b.algparam=null,"30"!=a.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(3!=c.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=a.substr(c[1],2))throw"malformed PKCS8 private key(code:003)";var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,c[1]);if(2!=d.length)throw"malformed PKCS8 private key(code:004)";if("06"!=a.substr(d[0],2))throw"malformed PKCS8 private key(code:005)";if(b.algoid=ASN1HEX.getHexOfV_AtObj(a,d[0]),"06"==a.substr(d[1],2)&&(b.algparam=ASN1HEX.getHexOfV_AtObj(a,d[1])),"04"!=a.substr(c[2],2))throw"malformed PKCS8 private key(code:006)";return b.keyidx=ASN1HEX.getStartPosOfV_AtObj(a,c[2]),b},getKeyFromPlainPrivatePKCS8PEM:function(a){var b=this.getHexFromPEM(a,"PRIVATE KEY"),c=this.getKeyFromPlainPrivatePKCS8Hex(b);return c},getKeyFromPlainPrivatePKCS8Hex:function(a){var b=this.parsePlainPrivatePKCS8Hex(a);if("2a864886f70d010101"==b.algoid){this.parsePrivateRawRSAKeyHexAtObj(a,b);var c=b.key,d=new RSAKey;return d.setPrivateEx(c.n,c.e,c.d,c.p,c.q,c.dp,c.dq,c.co),d}if("2a8648ce3d0201"==b.algoid){if(this.parsePrivateRawECKeyHexAtObj(a,b),void 0===KJUR.crypto.OID.oidhex2name[b.algparam])throw"KJUR.crypto.OID.oidhex2name undefined: "+b.algparam;var e=KJUR.crypto.OID.oidhex2name[b.algparam],d=new KJUR.crypto.ECDSA({curve:e});return d.setPublicKeyHex(b.pubkey),d.setPrivateKeyHex(b.key),d.isPublic=!1,d}if("2a8648ce380401"==b.algoid){var f=ASN1HEX.getVbyList(a,0,[1,1,0],"02"),g=ASN1HEX.getVbyList(a,0,[1,1,1],"02"),h=ASN1HEX.getVbyList(a,0,[1,1,2],"02"),i=ASN1HEX.getVbyList(a,0,[2,0],"02"),j=new BigInteger(f,16),k=new BigInteger(g,16),l=new BigInteger(h,16),m=new BigInteger(i,16),d=new KJUR.crypto.DSA;return d.setPrivate(j,k,l,null,m),d}throw"unsupported private key algorithm"},getRSAKeyFromPublicPKCS8PEM:function(a){var b=this.getHexFromPEM(a,"PUBLIC KEY"),c=this.getRSAKeyFromPublicPKCS8Hex(b);return c},getKeyFromPublicPKCS8PEM:function(a){var b=this.getHexFromPEM(a,"PUBLIC KEY"),c=this.getKeyFromPublicPKCS8Hex(b);return c},getKeyFromPublicPKCS8Hex:function(a){var b=this.parsePublicPKCS8Hex(a);if("2a864886f70d010101"==b.algoid){var c=this.parsePublicRawRSAKeyHex(b.key),d=new RSAKey;return d.setPublic(c.n,c.e),d}if("2a8648ce3d0201"==b.algoid){if(void 0===KJUR.crypto.OID.oidhex2name[b.algparam])throw"KJUR.crypto.OID.oidhex2name undefined: "+b.algparam;var e=KJUR.crypto.OID.oidhex2name[b.algparam],d=new KJUR.crypto.ECDSA({curve:e,pub:b.key});return d}if("2a8648ce380401"==b.algoid){var f=b.algparam,g=ASN1HEX.getHexOfV_AtObj(b.key,0),d=new KJUR.crypto.DSA;return d.setPublic(new BigInteger(f.p,16),new BigInteger(f.q,16),new BigInteger(f.g,16),new BigInteger(g,16)),d}throw"unsupported public key algorithm"},parsePublicRawRSAKeyHex:function(a){var b={};if("30"!=a.substr(0,2))throw"malformed RSA key(code:001)";var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(2!=c.length)throw"malformed RSA key(code:002)";if("02"!=a.substr(c[0],2))throw"malformed RSA key(code:003)";if(b.n=ASN1HEX.getHexOfV_AtObj(a,c[0]),"02"!=a.substr(c[1],2))throw"malformed RSA key(code:004)";return b.e=ASN1HEX.getHexOfV_AtObj(a,c[1]),b},parsePrivateRawRSAKeyHexAtObj:function(a,b){var c=b.keyidx;if("30"!=a.substr(c,2))throw"malformed RSA private key(code:001)";var d=ASN1HEX.getPosArrayOfChildren_AtObj(a,c);if(9!=d.length)throw"malformed RSA private key(code:002)";b.key={},b.key.n=ASN1HEX.getHexOfV_AtObj(a,d[1]),b.key.e=ASN1HEX.getHexOfV_AtObj(a,d[2]),b.key.d=ASN1HEX.getHexOfV_AtObj(a,d[3]),b.key.p=ASN1HEX.getHexOfV_AtObj(a,d[4]),b.key.q=ASN1HEX.getHexOfV_AtObj(a,d[5]),b.key.dp=ASN1HEX.getHexOfV_AtObj(a,d[6]),b.key.dq=ASN1HEX.getHexOfV_AtObj(a,d[7]),b.key.co=ASN1HEX.getHexOfV_AtObj(a,d[8])},parsePrivateRawECKeyHexAtObj:function(a,b){var c=b.keyidx,d=ASN1HEX.getVbyList(a,c,[1],"04"),e=ASN1HEX.getVbyList(a,c,[2,0],"03").substr(2);b.key=d,b.pubkey=e},parsePublicPKCS8Hex:function(a){var b={};b.algparam=null;var c=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(2!=c.length)throw"outer DERSequence shall have 2 elements: "+c.length;var d=c[0];if("30"!=a.substr(d,2))throw"malformed PKCS8 public key(code:001)";var e=ASN1HEX.getPosArrayOfChildren_AtObj(a,d);if(2!=e.length)throw"malformed PKCS8 public key(code:002)";if("06"!=a.substr(e[0],2))throw"malformed PKCS8 public key(code:003)";if(b.algoid=ASN1HEX.getHexOfV_AtObj(a,e[0]),"06"==a.substr(e[1],2)?b.algparam=ASN1HEX.getHexOfV_AtObj(a,e[1]):"30"==a.substr(e[1],2)&&(b.algparam={},b.algparam.p=ASN1HEX.getVbyList(a,e[1],[0],"02"),b.algparam.q=ASN1HEX.getVbyList(a,e[1],[1],"02"),b.algparam.g=ASN1HEX.getVbyList(a,e[1],[2],"02")),"03"!=a.substr(c[1],2))throw"malformed PKCS8 public key(code:004)";return b.key=ASN1HEX.getHexOfV_AtObj(a,c[1]).substr(2),b},getRSAKeyFromPublicPKCS8Hex:function(a){var b=ASN1HEX.getPosArrayOfChildren_AtObj(a,0);if(2!=b.length)throw"outer DERSequence shall have 2 elements: "+b.length;var c=ASN1HEX.getHexOfTLV_AtObj(a,b[0]);if("300d06092a864886f70d0101010500"!=c)throw"PKCS8 AlgorithmId is not rsaEncryption";if("03"!=a.substr(b[1],2))throw"PKCS8 Public Key is not BITSTRING encapslated.";var d=ASN1HEX.getStartPosOfV_AtObj(a,b[1])+2;if("30"!=a.substr(d,2))throw"PKCS8 Public Key is not SEQUENCE.";var e=ASN1HEX.getPosArrayOfChildren_AtObj(a,d);if(2!=e.length)throw"inner DERSequence shall have 2 elements: "+e.length;if("02"!=a.substr(e[0],2))throw"N is not ASN.1 INTEGER";if("02"!=a.substr(e[1],2))throw"E is not ASN.1 INTEGER";var f=ASN1HEX.getHexOfV_AtObj(a,e[0]),g=ASN1HEX.getHexOfV_AtObj(a,e[1]),h=new RSAKey;return h.setPublic(f,g),h}}}();KEYUTIL.getKey=function(a,b,c){if("undefined"!=typeof RSAKey&&a instanceof RSAKey)return a;if("undefined"!=typeof KJUR.crypto.ECDSA&&a instanceof KJUR.crypto.ECDSA)return a;if("undefined"!=typeof KJUR.crypto.DSA&&a instanceof KJUR.crypto.DSA)return a;if(void 0!==a.curve&&void 0!==a.xy&&void 0===a.d)return new KJUR.crypto.ECDSA({pub:a.xy,curve:a.curve});if(void 0!==a.curve&&void 0!==a.d)return new KJUR.crypto.ECDSA({prv:a.d,curve:a.curve});if(void 0===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0===a.d){var d=new RSAKey;return d.setPublic(a.n,a.e),d}if(void 0===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0!==a.d&&void 0!==a.p&&void 0!==a.q&&void 0!==a.dp&&void 0!==a.dq&&void 0!==a.co&&void 0===a.qi){var d=new RSAKey;return d.setPrivateEx(a.n,a.e,a.d,a.p,a.q,a.dp,a.dq,a.co),d}if(void 0===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0!==a.d&&void 0===a.p){var d=new RSAKey;return d.setPrivate(a.n,a.e,a.d),d}if(void 0!==a.p&&void 0!==a.q&&void 0!==a.g&&void 0!==a.y&&void 0===a.x){var d=new KJUR.crypto.DSA;return d.setPublic(a.p,a.q,a.g,a.y),d}if(void 0!==a.p&&void 0!==a.q&&void 0!==a.g&&void 0!==a.y&&void 0!==a.x){var d=new KJUR.crypto.DSA;return d.setPrivate(a.p,a.q,a.g,a.y,a.x),d}if("RSA"===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0===a.d){var d=new RSAKey;return d.setPublic(b64utohex(a.n),b64utohex(a.e)),d}if("RSA"===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0!==a.d&&void 0!==a.p&&void 0!==a.q&&void 0!==a.dp&&void 0!==a.dq&&void 0!==a.qi){var d=new RSAKey;return d.setPrivateEx(b64utohex(a.n),b64utohex(a.e),b64utohex(a.d),b64utohex(a.p),b64utohex(a.q),b64utohex(a.dp),b64utohex(a.dq),b64utohex(a.qi)),d}if("RSA"===a.kty&&void 0!==a.n&&void 0!==a.e&&void 0!==a.d){var d=new RSAKey;return d.setPrivate(b64utohex(a.n),b64utohex(a.e),b64utohex(a.d)),d}if("EC"===a.kty&&void 0!==a.crv&&void 0!==a.x&&void 0!==a.y&&void 0===a.d){var e=new KJUR.crypto.ECDSA({curve:a.crv}),f=e.ecparams.keylen/4,g=("0000000000"+b64utohex(a.x)).slice(-f),h=("0000000000"+b64utohex(a.y)).slice(-f),i="04"+g+h;return e.setPublicKeyHex(i),e}if("EC"===a.kty&&void 0!==a.crv&&void 0!==a.x&&void 0!==a.y&&void 0!==a.d){var e=new KJUR.crypto.ECDSA({curve:a.crv}),f=e.ecparams.keylen/4,g=("0000000000"+b64utohex(a.x)).slice(-f),h=("0000000000"+b64utohex(a.y)).slice(-f),i="04"+g+h,j=("0000000000"+b64utohex(a.d)).slice(-f);return e.setPublicKeyHex(i),e.setPrivateKeyHex(j),e}if(a.indexOf("-END CERTIFICATE-",0)!=-1||a.indexOf("-END X509 CERTIFICATE-",0)!=-1||a.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return X509.getPublicKeyFromCertPEM(a);if("pkcs8pub"===c)return KEYUTIL.getKeyFromPublicPKCS8Hex(a);if(a.indexOf("-END PUBLIC KEY-")!=-1)return KEYUTIL.getKeyFromPublicPKCS8PEM(a);if("pkcs5prv"===c){var d=new RSAKey;return d.readPrivateKeyFromASN1HexString(a),d}if("pkcs5prv"===c){var d=new RSAKey;return d.readPrivateKeyFromASN1HexString(a),d}if(a.indexOf("-END RSA PRIVATE KEY-")!=-1&&a.indexOf("4,ENCRYPTED")==-1){var k=KEYUTIL.getHexFromPEM(a,"RSA PRIVATE KEY");return KEYUTIL.getKey(k,null,"pkcs5prv")}if(a.indexOf("-END DSA PRIVATE KEY-")!=-1&&a.indexOf("4,ENCRYPTED")==-1){var l=this.getHexFromPEM(a,"DSA PRIVATE KEY"),m=ASN1HEX.getVbyList(l,0,[1],"02"),n=ASN1HEX.getVbyList(l,0,[2],"02"),o=ASN1HEX.getVbyList(l,0,[3],"02"),p=ASN1HEX.getVbyList(l,0,[4],"02"),q=ASN1HEX.getVbyList(l,0,[5],"02"),d=new KJUR.crypto.DSA;return d.setPrivate(new BigInteger(m,16),new BigInteger(n,16),new BigInteger(o,16),new BigInteger(p,16),new BigInteger(q,16)),d}if(a.indexOf("-END PRIVATE KEY-")!=-1)return KEYUTIL.getKeyFromPlainPrivatePKCS8PEM(a);if(a.indexOf("-END RSA PRIVATE KEY-")!=-1&&a.indexOf("4,ENCRYPTED")!=-1)return KEYUTIL.getRSAKeyFromEncryptedPKCS5PEM(a,b);if(a.indexOf("-END EC PRIVATE KEY-")!=-1&&a.indexOf("4,ENCRYPTED")!=-1){var l=KEYUTIL.getDecryptedKeyHex(a,b),d=ASN1HEX.getVbyList(l,0,[1],"04"),r=ASN1HEX.getVbyList(l,0,[2,0],"06"),s=ASN1HEX.getVbyList(l,0,[3,0],"03").substr(2),t="";if(void 0===KJUR.crypto.OID.oidhex2name[r])throw"undefined OID(hex) in KJUR.crypto.OID: "+r;t=KJUR.crypto.OID.oidhex2name[r];var e=new KJUR.crypto.ECDSA({name:t});return e.setPublicKeyHex(s),e.setPrivateKeyHex(d),e.isPublic=!1,e}if(a.indexOf("-END DSA PRIVATE KEY-")!=-1&&a.indexOf("4,ENCRYPTED")!=-1){var l=KEYUTIL.getDecryptedKeyHex(a,b),m=ASN1HEX.getVbyList(l,0,[1],"02"),n=ASN1HEX.getVbyList(l,0,[2],"02"),o=ASN1HEX.getVbyList(l,0,[3],"02"),p=ASN1HEX.getVbyList(l,0,[4],"02"),q=ASN1HEX.getVbyList(l,0,[5],"02"),d=new KJUR.crypto.DSA;return d.setPrivate(new BigInteger(m,16),new BigInteger(n,16),new BigInteger(o,16),new BigInteger(p,16),new BigInteger(q,16)),d}if(a.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return KEYUTIL.getKeyFromEncryptedPKCS8PEM(a,b);throw"not supported argument"},KEYUTIL.generateKeypair=function(a,b){if("RSA"==a){var c=b,d=new RSAKey;d.generate(c,"10001"),d.isPrivate=!0,d.isPublic=!0;var e=new RSAKey,f=d.n.toString(16),g=d.e.toString(16);e.setPublic(f,g),e.isPrivate=!1,e.isPublic=!0;var h={};return h.prvKeyObj=d,h.pubKeyObj=e,h}if("EC"==a){var i=b,j=new KJUR.crypto.ECDSA({curve:i}),k=j.generateKeyPairHex(),d=new KJUR.crypto.ECDSA({curve:i});d.setPublicKeyHex(k.ecpubhex),d.setPrivateKeyHex(k.ecprvhex),d.isPrivate=!0,d.isPublic=!1;var e=new KJUR.crypto.ECDSA({curve:i});e.setPublicKeyHex(k.ecpubhex),e.isPrivate=!1,e.isPublic=!0;var h={};return h.prvKeyObj=d,h.pubKeyObj=e,h}throw"unknown algorithm: "+a},KEYUTIL.getPEM=function(a,b,c,d,e){function f(a){var b=KJUR.asn1.ASN1Util.newObject({seq:[{int:0},{int:{bigint:a.n}},{int:a.e},{int:{bigint:a.d}},{int:{bigint:a.p}},{int:{bigint:a.q}},{int:{bigint:a.dmp1}},{int:{bigint:a.dmq1}},{int:{bigint:a.coeff}}]});return b}function g(a){var b=KJUR.asn1.ASN1Util.newObject({seq:[{int:1},{octstr:{hex:a.prvKeyHex}},{tag:["a0",!0,{oid:{name:a.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+a.pubKeyHex}}]}]});return b}function h(a){var b=KJUR.asn1.ASN1Util.newObject({seq:[{int:0},{int:{bigint:a.p}},{int:{bigint:a.q}},{int:{bigint:a.g}},{int:{bigint:a.y}},{int:{bigint:a.x}}]});return b}var i=KJUR.asn1,j=KJUR.crypto;if(("undefined"!=typeof RSAKey&&a instanceof RSAKey||"undefined"!=typeof j.DSA&&a instanceof j.DSA||"undefined"!=typeof j.ECDSA&&a instanceof j.ECDSA)&&1==a.isPublic&&(void 0===b||"PKCS8PUB"==b)){
var k=new KJUR.asn1.x509.SubjectPublicKeyInfo(a),l=k.getEncodedHex();return i.ASN1Util.getPEMStringFromHex(l,"PUBLIC KEY")}if("PKCS1PRV"==b&&"undefined"!=typeof RSAKey&&a instanceof RSAKey&&(void 0===c||null==c)&&1==a.isPrivate){var k=f(a),l=k.getEncodedHex();return i.ASN1Util.getPEMStringFromHex(l,"RSA PRIVATE KEY")}if("PKCS1PRV"==b&&"undefined"!=typeof RSAKey&&a instanceof KJUR.crypto.ECDSA&&(void 0===c||null==c)&&1==a.isPrivate){var m=new KJUR.asn1.DERObjectIdentifier({name:a.curveName}),n=m.getEncodedHex(),o=g(a),p=o.getEncodedHex(),q="";return q+=i.ASN1Util.getPEMStringFromHex(n,"EC PARAMETERS"),q+=i.ASN1Util.getPEMStringFromHex(p,"EC PRIVATE KEY")}if("PKCS1PRV"==b&&"undefined"!=typeof KJUR.crypto.DSA&&a instanceof KJUR.crypto.DSA&&(void 0===c||null==c)&&1==a.isPrivate){var k=h(a),l=k.getEncodedHex();return i.ASN1Util.getPEMStringFromHex(l,"DSA PRIVATE KEY")}if("PKCS5PRV"==b&&"undefined"!=typeof RSAKey&&a instanceof RSAKey&&void 0!==c&&null!=c&&1==a.isPrivate){var k=f(a),l=k.getEncodedHex();return void 0===d&&(d="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",l,c,d)}if("PKCS5PRV"==b&&"undefined"!=typeof KJUR.crypto.ECDSA&&a instanceof KJUR.crypto.ECDSA&&void 0!==c&&null!=c&&1==a.isPrivate){var k=g(a),l=k.getEncodedHex();return void 0===d&&(d="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",l,c,d)}if("PKCS5PRV"==b&&"undefined"!=typeof KJUR.crypto.DSA&&a instanceof KJUR.crypto.DSA&&void 0!==c&&null!=c&&1==a.isPrivate){var k=h(a),l=k.getEncodedHex();return void 0===d&&(d="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",l,c,d)}var r=function(a,b){var c=s(a,b),d=new KJUR.asn1.ASN1Util.newObject({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:c.pbkdf2Salt}},{int:c.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:c.encryptionSchemeIV}}]}]}]},{octstr:{hex:c.ciphertext}}]});return d.getEncodedHex()},s=function(a,b){var c=100,d=CryptoJS.lib.WordArray.random(8),e="DES-EDE3-CBC",f=CryptoJS.lib.WordArray.random(8),g=CryptoJS.PBKDF2(b,d,{keySize:6,iterations:c}),h=CryptoJS.enc.Hex.parse(a),i=CryptoJS.TripleDES.encrypt(h,g,{iv:f})+"",j={};return j.ciphertext=i,j.pbkdf2Salt=CryptoJS.enc.Hex.stringify(d),j.pbkdf2Iter=c,j.encryptionSchemeAlg=e,j.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(f),j};if("PKCS8PRV"==b&&"undefined"!=typeof RSAKey&&a instanceof RSAKey&&1==a.isPrivate){var t=f(a),u=t.getEncodedHex(),k=KJUR.asn1.ASN1Util.newObject({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:u}}]}),l=k.getEncodedHex();if(void 0===c||null==c)return i.ASN1Util.getPEMStringFromHex(l,"PRIVATE KEY");var p=r(l,c);return i.ASN1Util.getPEMStringFromHex(p,"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==b&&"undefined"!=typeof KJUR.crypto.ECDSA&&a instanceof KJUR.crypto.ECDSA&&1==a.isPrivate){var t=new KJUR.asn1.ASN1Util.newObject({seq:[{int:1},{octstr:{hex:a.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+a.pubKeyHex}}]}]}),u=t.getEncodedHex(),k=KJUR.asn1.ASN1Util.newObject({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:a.curveName}}]},{octstr:{hex:u}}]}),l=k.getEncodedHex();if(void 0===c||null==c)return i.ASN1Util.getPEMStringFromHex(l,"PRIVATE KEY");var p=r(l,c);return i.ASN1Util.getPEMStringFromHex(p,"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==b&&"undefined"!=typeof KJUR.crypto.DSA&&a instanceof KJUR.crypto.DSA&&1==a.isPrivate){var t=new KJUR.asn1.DERInteger({bigint:a.x}),u=t.getEncodedHex(),k=KJUR.asn1.ASN1Util.newObject({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:a.p}},{int:{bigint:a.q}},{int:{bigint:a.g}}]}]},{octstr:{hex:u}}]}),l=k.getEncodedHex();if(void 0===c||null==c)return i.ASN1Util.getPEMStringFromHex(l,"PRIVATE KEY");var p=r(l,c);return i.ASN1Util.getPEMStringFromHex(p,"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},KEYUTIL.getKeyFromCSRPEM=function(a){var b=KEYUTIL.getHexFromPEM(a,"CERTIFICATE REQUEST"),c=KEYUTIL.getKeyFromCSRHex(b);return c},KEYUTIL.getKeyFromCSRHex=function(a){var b=KEYUTIL.parseCSRHex(a),c=KEYUTIL.getKey(b.p8pubkeyhex,null,"pkcs8pub");return c},KEYUTIL.parseCSRHex=function(a){var b={},c=a;if("30"!=c.substr(0,2))throw"malformed CSR(code:001)";var d=ASN1HEX.getPosArrayOfChildren_AtObj(c,0);if(d.length<1)throw"malformed CSR(code:002)";if("30"!=c.substr(d[0],2))throw"malformed CSR(code:003)";var e=ASN1HEX.getPosArrayOfChildren_AtObj(c,d[0]);if(e.length<3)throw"malformed CSR(code:004)";return b.p8pubkeyhex=ASN1HEX.getHexOfTLV_AtObj(c,e[2]),b},KEYUTIL.getJWKFromKey=function(a){var b={};if(a instanceof RSAKey&&a.isPrivate)return b.kty="RSA",b.n=hextob64u(a.n.toString(16)),b.e=hextob64u(a.e.toString(16)),b.d=hextob64u(a.d.toString(16)),b.p=hextob64u(a.p.toString(16)),b.q=hextob64u(a.q.toString(16)),b.dp=hextob64u(a.dmp1.toString(16)),b.dq=hextob64u(a.dmq1.toString(16)),b.qi=hextob64u(a.coeff.toString(16)),b;if(a instanceof RSAKey&&a.isPublic)return b.kty="RSA",b.n=hextob64u(a.n.toString(16)),b.e=hextob64u(a.e.toString(16)),b;if(a instanceof KJUR.crypto.ECDSA&&a.isPrivate){var c=a.getShortNISTPCurveName();if("P-256"!==c&&"P-384"!==c)throw"unsupported curve name for JWT: "+c;var d=a.getPublicKeyXYHex();return b.kty="EC",b.crv=c,b.x=hextob64u(d.x),b.y=hextob64u(d.y),b.d=hextob64u(a.prvKeyHex),b}if(a instanceof KJUR.crypto.ECDSA&&a.isPublic){var c=a.getShortNISTPCurveName();if("P-256"!==c&&"P-384"!==c)throw"unsupported curve name for JWT: "+c;var d=a.getPublicKeyXYHex();return b.kty="EC",b.crv=c,b.x=hextob64u(d.x),b.y=hextob64u(d.y),b}throw"not supported key object"};