var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(b){var d=0;return function(){return de.compareTo(a);)e=e.add(b.p);b=e.subtract(a).multiply(b.qInv).mod(b.p).multiply(b.q).add(a)}return b};d.rsa.encrypt=function(a,c,e){if(null==a||"undefined"==typeof a)throw{code:"101002",message:k["101002"]};if(null==c||"undefined"==typeof c)throw{code:"101003",message:k["101003"]};if(null==e||"undefined"==typeof e)throw{code:"101004",message:k["101004"]};var g=e,l=b.util.createBuffer(),d=Math.ceil(c.n.bitLength()/8);if(!1!==e&&!0!==e){if(a.length>d-11)throw{code:"101005",message:k["101005"]+"(length:"+a.length+", max:"+(d-11)+")"};l.putByte(0);l.putByte(e);var f=d-3-a.length;if(0===e||1===e){g=!1;e=0===e?0:255;for(var m=0;m>1,pBits:a-(a>>1),pqState:0,num:null,six:new BigInteger(null),addNext:2,keys:null};a.six.fromInt(6);return a};d.rsa.stepKeyPairGenerationState=function(a,c){for(var d=+new Date,g,f=0;null===a.keys&&(0>=c||fg?(a.addNext=null,a.num.subTo(BigInteger.ONE.shiftLeft(k),a.num)):a.addNext=4===a.addNext?2:4,++a.itrs):a.pqState=0}else 2===a.pqState?a.pqState=0===a.num.subtract(BigInteger.ONE).gcd(a.e).compareTo(BigInteger.ONE)?3:0:3===a.pqState&&(a.pqState=0,a.num.isProbablePrime(10)&&(null===a.p?a.p=a.num:a.q=a.num,null!==a.p&&null!==a.q&&++a.state),a.num=null)}else 1===a.state?(0>a.p.compareTo(a.q)&&(a.num=a.p,a.p=a.q,a.q=a.num),++a.state):2===a.state?(a.p1=a.p.subtract(BigInteger.ONE),a.q1=a.q.subtract(BigInteger.ONE),a.phi=a.p1.multiply(a.q1),++a.state):3===a.state?0===a.phi.gcd(a.e).compareTo(BigInteger.ONE)?++a.state:(a.p=null,a.q=null,a.state=0):4===a.state?(a.n=a.p.multiply(a.q),a.n.bitLength()===a.bits?++a.state:(a.q=null,a.state=0)):5===a.state&&(g=a.e.modInverse(a.phi),a.keys={privateKey:b.pki.rsa.setPrivateKey(a.n,a.e,g,a.p,a.q,g.mod(a.p1),g.mod(a.q1),a.q.modInverse(a.p)),publicKey:b.pki.rsa.setPublicKey(a.n,a.e)});g=+new Date;f+=g-d;d=g}return null!==a.keys};d.rsa.generateKeyPair=function(a,b){a=d.rsa.createKeyPairGenerationState(a,b);d.rsa.stepKeyPairGenerationState(a,0);return a.keys};d.rsa.setPublicKey=function(a,b){var e={n:a,e:b,encrypt:function(a){return d.rsa.encrypt(a,e,2)},verify:function(a,b,f){if(null==a||"undefined"==typeof a)throw{code:"104002",message:k["104002"]};if(null==b||"undefined"==typeof b)throw{code:"104003",message:k["104003"]};b=d.rsa.decrypt(b,e,!0,void 0===f?void 0:!1);return void 0===f?(f=c.fromDer(b),a===f.value[1].value):f.verify(a,b,e.n.bitLength())}};return e};d.rsa.setPrivateKey=function(a,h,e,g,p,n,q,m){var l={n:a,e:h,d:e,p:g,q:p,dP:n,dQ:q,qInv:m,decrypt:function(a){return d.rsa.decrypt(a,l,!1)},sign:function(a,b){if(null==a||"undefined"==typeof a)throw{code:"104001",message:k["104001"]};var c=!1;void 0===b&&(b={encode:f},c=1);a=b.encode(a,l.n.bitLength());return d.rsa.encrypt(a,l,c)},signWithHash:function(a,e){if(null==a||"undefined"==typeof a)throw{code:"104002",message:k["104002"]};var f=!1;void 0===e&&(f=1);var g=c.oidToDer(b.pki.oids.sha256).getBytes();e=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]);var h=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]);h.value.push(c.create(c.Class.UNIVERSAL,c.Type.OID,!1,g));h.value.push(c.create(c.Class.UNIVERSAL,c.Type.NULL,!1,""));a=c.create(c.Class.UNIVERSAL,c.Type.OCTETSTRING,!1,a);e.value.push(h);e.value.push(a);return d.rsa.encrypt(c.toDer(e).getBytes(),l,f)}};return l}}var d="./asn1 ./oids ./random ./util ./jsbn ./jsustoolkitErrCode".split(" "),f=null;"function"!==typeof define&&("object"===typeof module&&module.exports?f=function(b,c){c(require,module)}:(crosscert=window.crosscert=window.crosscert||{},b(crosscert)));(f||"function"===typeof define)&&(f||define)(["require","module"].concat(d),function(f,c){c.exports=function(c){var h=d.map(function(b){return f(b)}).concat(b);c=c||{};c.defined=c.defined||{};if(c.defined.rsa)return c.rsa;c.defined.rsa=!0;for(var k=0;k